[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [arm/release] Binding handlers for the help submenu



commit 697468f2df30460fb381fac35a650cb4f7c412ae
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Jun 12 18:28:53 2011 -0700

    Binding handlers for the help submenu
---
 src/cli/configPanel.py           |    2 --
 src/cli/connections/connPanel.py |    2 --
 src/cli/graphing/graphPanel.py   |    4 ++--
 src/cli/logPanel.py              |    4 ----
 src/cli/menu/actions.py          |   15 +++++++++++++++
 src/cli/menu/item.py             |    8 +++++++-
 src/cli/popups.py                |   25 +++++++++++++++++++++++++
 src/cli/torrcPanel.py            |    3 ---
 8 files changed, 49 insertions(+), 14 deletions(-)

diff --git a/src/cli/configPanel.py b/src/cli/configPanel.py
index 4647286..fedf1f7 100644
--- a/src/cli/configPanel.py
+++ b/src/cli/configPanel.py
@@ -275,7 +275,6 @@ class ConfigPanel(panel.Panel):
     """
     
     # set ordering for config options
-    cli.controller.getController().requestRedraw(True)
     titleLabel = "Config Option Ordering:"
     options = [FIELD_ATTR[field][0] for field in Field.values()]
     oldSelection = [FIELD_ATTR[field][0] for field in self.sortOrdering]
@@ -357,7 +356,6 @@ class ConfigPanel(panel.Panel):
     """
     
     # display a popup for saving the current configuration
-    cli.controller.getController().requestRedraw(True)
     configLines = torConfig.getCustomOptions(True)
     popup, width, height = popups.init(len(configLines) + 2)
     if not popup: return
diff --git a/src/cli/connections/connPanel.py b/src/cli/connections/connPanel.py
index 9490ddc..edf5a14 100644
--- a/src/cli/connections/connPanel.py
+++ b/src/cli/connections/connPanel.py
@@ -6,7 +6,6 @@ import time
 import curses
 import threading
 
-import cli.controller
 import cli.descriptorPopup
 import cli.popups
 
@@ -157,7 +156,6 @@ class ConnectionPanel(panel.Panel, threading.Thread):
     """
     
     # set ordering for connection options
-    cli.controller.getController().requestRedraw(True)
     titleLabel = "Connection Ordering:"
     options = entries.SortAttr.values()
     oldSelection = self._sortOrdering
diff --git a/src/cli/graphing/graphPanel.py b/src/cli/graphing/graphPanel.py
index 8c3adf7..b080871 100644
--- a/src/cli/graphing/graphPanel.py
+++ b/src/cli/graphing/graphPanel.py
@@ -307,8 +307,6 @@ class GraphPanel(panel.Panel):
     panel.CURSES_LOCK.acquire()
     try:
       while True:
-        control.requestRedraw(True)
-        
         msg = "press the down/up to resize the graph, and enter when done"
         control.setMsg(msg, curses.A_BOLD, True)
         curses.cbreak()
@@ -325,6 +323,8 @@ class GraphPanel(panel.Panel):
         elif key == curses.KEY_UP:
           self.setGraphHeight(self.graphHeight - 1)
         elif uiTools.isSelectionKey(key): break
+        
+        control.requestRedraw(True)
     finally:
       control.setMsg()
       panel.CURSES_LOCK.release()
diff --git a/src/cli/logPanel.py b/src/cli/logPanel.py
index ef372ab..fc3bfc3 100644
--- a/src/cli/logPanel.py
+++ b/src/cli/logPanel.py
@@ -13,7 +13,6 @@ import threading
 from TorCtl import TorCtl
 
 import popups
-import cli.controller
 from version import VERSION
 from util import conf, log, panel, sysTools, torTools, uiTools
 
@@ -792,7 +791,6 @@ class LogPanel(panel.Panel, threading.Thread):
     Prompts the user to add a new regex filter.
     """
     
-    cli.controller.getController().requestRedraw(True)
     regexInput = popups.inputPrompt("Regular expression: ")
     
     if regexInput:
@@ -809,7 +807,6 @@ class LogPanel(panel.Panel, threading.Thread):
     """
     
     # allow user to enter new types of events to log - unchanged if left blank
-    cli.controller.getController().requestRedraw(True)
     popup, width, height = popups.init(11, 80)
     
     if popup:
@@ -837,7 +834,6 @@ class LogPanel(panel.Panel, threading.Thread):
     Lets user enter a path to take a snapshot, canceling if left blank.
     """
     
-    cli.controller.getController().requestRedraw(True)
     pathInput = popups.inputPrompt("Path to save log snapshot: ")
     
     if pathInput:
diff --git a/src/cli/menu/actions.py b/src/cli/menu/actions.py
index 53e5d1c..b8b59e1 100644
--- a/src/cli/menu/actions.py
+++ b/src/cli/menu/actions.py
@@ -4,6 +4,7 @@ Generates the menu for arm, binding options with their related actions.
 
 import functools
 
+import cli.popups
 import cli.controller
 import cli.menu.item
 import cli.graphing.graphPanel
@@ -33,6 +34,8 @@ def makeMenu():
     elif pagePanel.getName() == "torrc":
       baseMenu.add(makeTorrcMenu(pagePanel))
   
+  baseMenu.add(makeHelpMenu())
+  
   return baseMenu
 
 def makeActionsMenu():
@@ -90,6 +93,18 @@ def makeViewMenu():
   
   return viewMenu
 
+def makeHelpMenu():
+  """
+  Submenu consisting of...
+    Hotkeys
+    About
+  """
+  
+  helpMenu = cli.menu.item.Submenu("Help")
+  helpMenu.add(cli.menu.item.MenuItem("Hotkeys", cli.popups.showHelpPopup))
+  helpMenu.add(cli.menu.item.MenuItem("About", cli.popups.showAboutPopup))
+  return helpMenu
+
 def makeGraphMenu(graphPanel):
   """
   Submenu for the graph panel, consisting of...
diff --git a/src/cli/menu/item.py b/src/cli/menu/item.py
index beaac9c..f46cdbb 100644
--- a/src/cli/menu/item.py
+++ b/src/cli/menu/item.py
@@ -2,6 +2,8 @@
 Menu item, representing an option in the drop-down menu.
 """
 
+import cli.controller
+
 class MenuItem():
   """
   Option in a drop-down menu.
@@ -53,7 +55,11 @@ class MenuItem():
     the menu and false otherwise.
     """
     
-    if self._callback: self._callback()
+    if self._callback:
+      control = cli.controller.getController()
+      control.setMsg()
+      control.requestRedraw(True)
+      self._callback()
     return True
   
   def next(self):
diff --git a/src/cli/popups.py b/src/cli/popups.py
index 5f1eac2..7254f4a 100644
--- a/src/cli/popups.py
+++ b/src/cli/popups.py
@@ -4,6 +4,7 @@ Functions for displaying popups in the interface.
 
 import curses
 
+import version
 import cli.controller
 
 from util import panel, uiTools
@@ -155,6 +156,30 @@ def showHelpPopup():
     return exitKey
   else: return None
 
+def showAboutPopup():
+  """
+  Presents a popup with author and version information.
+  """
+  
+  popup, _, height = init(9, 80)
+  if not popup: return
+  
+  try:
+    control = cli.controller.getController()
+    
+    popup.win.box()
+    popup.addstr(0, 0, "About:", curses.A_STANDOUT)
+    popup.addstr(1, 2, "arm, version %s (released %s)" % (version.VERSION, version.LAST_MODIFIED), curses.A_BOLD)
+    popup.addstr(2, 4, "Written by Damian Johnson (atagar1@xxxxxxxxx)")
+    popup.addstr(3, 4, "Project page: www.atagar.com/arm")
+    popup.addstr(5, 2, "Released under the GPL v3 (http://www.gnu.org/licenses/gpl.html)")
+    popup.addstr(7, 2, "Press any key...")
+    popup.win.refresh()
+    
+    curses.cbreak()
+    control.getScreen().getch()
+  finally: finalize()
+
 def showSortDialog(title, options, oldSelection, optionColors):
   """
   Displays a sorting dialog of the form:
diff --git a/src/cli/torrcPanel.py b/src/cli/torrcPanel.py
index c273bf0..f651785 100644
--- a/src/cli/torrcPanel.py
+++ b/src/cli/torrcPanel.py
@@ -6,7 +6,6 @@ import math
 import curses
 import threading
 
-import cli.controller
 import popups
 
 from util import conf, enum, panel, torConfig, torTools, uiTools
@@ -89,8 +88,6 @@ class TorrcPanel(panel.Panel):
     Reloads the torrc, displaying an indicator of success or failure.
     """
     
-    cli.controller.getController().requestRedraw(True)
-    
     try:
       torConfig.getTorrc().load()
       self._lastContentHeightArgs = None



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits