[tor-commits] [nyx/master] Fix 'Show/Hide Duplicates' menu item

atagar at torproject.org atagar at torproject.org
Sat Aug 27 18:23:50 UTC 2016


commit a23ff241d42299f02fcf56281823fe71568a67bf
Author: Damian Johnson <atagar at torproject.org>
Date:   Thu Aug 11 09:15:23 2016 -0700

    Fix 'Show/Hide Duplicates' menu item
    
    The menu option consulted our config to determine the present setting but
    that's actually stored in the panel, so the menu item never changed.
---
 nyx/menu.py      |  8 ++------
 nyx/panel/log.py | 13 +++++++++++--
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/nyx/menu.py b/nyx/menu.py
index aae2cdb..409842b 100644
--- a/nyx/menu.py
+++ b/nyx/menu.py
@@ -23,11 +23,7 @@ import stem.util.connection
 
 from nyx import tor_controller
 from nyx.curses import RED, WHITE, NORMAL, BOLD, UNDERLINE
-from stem.util import conf, str_tools
-
-CONFIG = conf.config_dict('nyx', {
-  'features.log.showDuplicateEntries': False,
-})
+from stem.util import str_tools
 
 
 class MenuItem(object):
@@ -381,7 +377,7 @@ def make_log_menu(log_panel):
   log_menu.add(MenuItem('Snapshot...', log_panel.show_snapshot_prompt))
   log_menu.add(MenuItem('Clear', log_panel.clear))
 
-  if CONFIG['features.log.showDuplicateEntries']:
+  if log_panel.is_duplicates_visible():
     label, arg = 'Hide', False
   else:
     label, arg = 'Show', True
diff --git a/nyx/panel/log.py b/nyx/panel/log.py
index 0437e0f..502e383 100644
--- a/nyx/panel/log.py
+++ b/nyx/panel/log.py
@@ -111,6 +111,15 @@ class LogPanel(nyx.panel.DaemonPanel):
 
     NYX_LOGGER.emit = self._register_nyx_event
 
+  def is_duplicates_visible(self):
+    """
+    Checks if duplicate log entries are collapsed or not.
+
+    :returns: **True** if duplicates are shown and **False** otherwise
+    """
+
+    return self._show_duplicates
+
   def set_duplicate_visability(self, is_visible):
     """
     Sets if duplicate log entries are collaped or expanded.
@@ -227,7 +236,7 @@ class LogPanel(nyx.panel.DaemonPanel):
           self._filter.select(selection)
 
     def _toggle_deduplication():
-      self.set_duplicate_visability(not self._show_duplicates)
+      self.set_duplicate_visability(not self.is_duplicates_visible())
       self.redraw()
 
     def _clear_log():
@@ -242,7 +251,7 @@ class LogPanel(nyx.panel.DaemonPanel):
       nyx.panel.KeyHandler('a', 'save snapshot of the log', self.show_snapshot_prompt),
       nyx.panel.KeyHandler('e', 'change logged events', self.show_event_selection_prompt),
       nyx.panel.KeyHandler('f', 'log regex filter', _pick_filter, 'enabled' if self._filter.selection() else 'disabled'),
-      nyx.panel.KeyHandler('u', 'duplicate log entries', _toggle_deduplication, 'visible' if self._show_duplicates else 'hidden'),
+      nyx.panel.KeyHandler('u', 'duplicate log entries', _toggle_deduplication, 'visible' if self.is_duplicates_visible() else 'hidden'),
       nyx.panel.KeyHandler('c', 'clear event log', _clear_log),
     )
 





More information about the tor-commits mailing list