[tor-commits] [arm/master] Adding an is_wide() helper for the header panel
atagar at torproject.org
atagar at torproject.org
Tue Sep 2 03:56:01 UTC 2014
commit 308a213009f43588a34c5b44d87de8d467ce9efe
Author: Damian Johnson <atagar at torproject.org>
Date: Mon Sep 1 17:31:58 2014 -0700
Adding an is_wide() helper for the header panel
Three things make decisions based on if we're showing two columns or not, so
adding a helper to answer it.
---
arm/header_panel.py | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/arm/header_panel.py b/arm/header_panel.py
index 6e1f381..c0ab850 100644
--- a/arm/header_panel.py
+++ b/arm/header_panel.py
@@ -51,18 +51,26 @@ class HeaderPanel(panel.Panel, threading.Thread):
tor_controller().add_status_listener(self.reset_listener)
+ def is_wide(self, width = None):
+ """
+ True if we should show two columns of information, False otherwise.
+ """
+
+ if width is None:
+ width = self.get_parent().getmaxyx()[1]
+
+ return width >= MIN_DUAL_COL_WIDTH
+
def get_height(self):
"""
Provides the height of the content, which is dynamically determined by the
panel's maximum width.
"""
- is_wide = self.get_parent().getmaxyx()[1] >= MIN_DUAL_COL_WIDTH
-
if self._vals.is_relay:
- return 4 if is_wide else 6
+ return 4 if self.is_wide() else 6
else:
- return 3 if is_wide else 4
+ return 3 if self.is_wide() else 4
def send_newnym(self):
"""
@@ -74,9 +82,7 @@ class HeaderPanel(panel.Panel, threading.Thread):
# If we're wide then the newnym label in this panel will give an
# indication that the signal was sent. Otherwise use a msg.
- is_wide = self.get_parent().getmaxyx()[1] >= MIN_DUAL_COL_WIDTH
-
- if not is_wide:
+ if not self.is_wide():
arm.popups.show_msg('Requesting a new identity', 1)
def handle_key(self, key):
@@ -134,7 +140,7 @@ class HeaderPanel(panel.Panel, threading.Thread):
def draw(self, width, height):
vals = self._vals # local reference to avoid concurrency concerns
- is_wide = width + 1 >= MIN_DUAL_COL_WIDTH
+ is_wide = self.is_wide(width)
# space available for content
More information about the tor-commits
mailing list