commit af0580268ef996be857eb8300aecf1848894b724 Author: Damian Johnson atagar@torproject.org Date: Sat Jun 11 18:53:02 2011 -0700
Moving menu generation into a dedicated file --- src/cli/menu/__init__.py | 2 +- src/cli/menu/actions.py | 73 ++++++++++++++++++++++++++++++++++++++++++++++ src/cli/menu/menu.py | 69 +------------------------------------------ 3 files changed, 76 insertions(+), 68 deletions(-)
diff --git a/src/cli/menu/__init__.py b/src/cli/menu/__init__.py index e6b5f10..f6d43ec 100644 --- a/src/cli/menu/__init__.py +++ b/src/cli/menu/__init__.py @@ -2,5 +2,5 @@ Resources for displaying the menu. """
-__all__ = ["item", "menu"] +__all__ = ["actions", "item", "menu"]
diff --git a/src/cli/menu/actions.py b/src/cli/menu/actions.py new file mode 100644 index 0000000..f6f88ba --- /dev/null +++ b/src/cli/menu/actions.py @@ -0,0 +1,73 @@ +""" +Generates the menu for arm, binding options with their related actions. +""" + +import cli.menu.item + +def makeMenu(): + """ + Constructs the base menu and all of its contents. + """ + + baseMenu = cli.menu.item.Submenu("") + + fileMenu = cli.menu.item.Submenu("File") + fileMenu.add(cli.menu.item.MenuItem("Exit", None)) + baseMenu.add(fileMenu) + + logsMenu = cli.menu.item.Submenu("Logs") + logsMenu.add(cli.menu.item.MenuItem("Events", None)) + logsMenu.add(cli.menu.item.MenuItem("Clear", None)) + logsMenu.add(cli.menu.item.MenuItem("Save", None)) + logsMenu.add(cli.menu.item.MenuItem("Filter", None)) + + duplicatesSubmenu = cli.menu.item.Submenu("Duplicates") + duplicatesSubmenu.add(cli.menu.item.MenuItem("Hidden", None)) + duplicatesSubmenu.add(cli.menu.item.MenuItem("Visible", None)) + logsMenu.add(duplicatesSubmenu) + baseMenu.add(logsMenu) + + viewMenu = cli.menu.item.Submenu("View") + viewMenu.add(cli.menu.item.MenuItem("Graph", None)) + viewMenu.add(cli.menu.item.MenuItem("Connections", None)) + viewMenu.add(cli.menu.item.MenuItem("Configuration", None)) + viewMenu.add(cli.menu.item.MenuItem("Configuration File", None)) + baseMenu.add(viewMenu) + + graphMenu = cli.menu.item.Submenu("Graph") + graphMenu.add(cli.menu.item.MenuItem("Stats", None)) + + sizeSubmenu = cli.menu.item.Submenu("Size") + sizeSubmenu.add(cli.menu.item.MenuItem("Increase", None)) + sizeSubmenu.add(cli.menu.item.MenuItem("Decrease", None)) + graphMenu.add(sizeSubmenu) + + graphMenu.add(cli.menu.item.MenuItem("Update Interval", None)) + + boundsSubmenu = cli.menu.item.Submenu("Bounds") + boundsSubmenu.add(cli.menu.item.MenuItem("Local Max", None)) + boundsSubmenu.add(cli.menu.item.MenuItem("Global Max", None)) + boundsSubmenu.add(cli.menu.item.MenuItem("Tight", None)) + graphMenu.add(boundsSubmenu) + baseMenu.add(graphMenu) + + connectionsMenu = cli.menu.item.Submenu("Connections") + connectionsMenu.add(cli.menu.item.MenuItem("Identity", None)) + connectionsMenu.add(cli.menu.item.MenuItem("Resolver", None)) + connectionsMenu.add(cli.menu.item.MenuItem("Sort Order", None)) + baseMenu.add(connectionsMenu) + + configurationMenu = cli.menu.item.Submenu("Configuration") + + commentsSubmenu = cli.menu.item.Submenu("Comments") + commentsSubmenu.add(cli.menu.item.MenuItem("Hidden", None)) + commentsSubmenu.add(cli.menu.item.MenuItem("Visible", None)) + configurationMenu.add(commentsSubmenu) + + configurationMenu.add(cli.menu.item.MenuItem("Reload", None)) + configurationMenu.add(cli.menu.item.MenuItem("Reset Tor", None)) + baseMenu.add(configurationMenu) + + return baseMenu + + diff --git a/src/cli/menu/menu.py b/src/cli/menu/menu.py index f83b76d..e0728e8 100644 --- a/src/cli/menu/menu.py +++ b/src/cli/menu/menu.py @@ -4,75 +4,10 @@ import curses import cli.popups import cli.controller import cli.menu.item +import cli.menu.actions
from util import uiTools
-def makeMenu(): - """ - Constructs the base menu and all of its contents. - """ - - baseMenu = cli.menu.item.Submenu("") - - fileMenu = cli.menu.item.Submenu("File") - fileMenu.add(cli.menu.item.MenuItem("Exit", None)) - baseMenu.add(fileMenu) - - logsMenu = cli.menu.item.Submenu("Logs") - logsMenu.add(cli.menu.item.MenuItem("Events", None)) - logsMenu.add(cli.menu.item.MenuItem("Clear", None)) - logsMenu.add(cli.menu.item.MenuItem("Save", None)) - logsMenu.add(cli.menu.item.MenuItem("Filter", None)) - - duplicatesSubmenu = cli.menu.item.Submenu("Duplicates") - duplicatesSubmenu.add(cli.menu.item.MenuItem("Hidden", None)) - duplicatesSubmenu.add(cli.menu.item.MenuItem("Visible", None)) - logsMenu.add(duplicatesSubmenu) - baseMenu.add(logsMenu) - - viewMenu = cli.menu.item.Submenu("View") - viewMenu.add(cli.menu.item.MenuItem("Graph", None)) - viewMenu.add(cli.menu.item.MenuItem("Connections", None)) - viewMenu.add(cli.menu.item.MenuItem("Configuration", None)) - viewMenu.add(cli.menu.item.MenuItem("Configuration File", None)) - baseMenu.add(viewMenu) - - graphMenu = cli.menu.item.Submenu("Graph") - graphMenu.add(cli.menu.item.MenuItem("Stats", None)) - - sizeSubmenu = cli.menu.item.Submenu("Size") - sizeSubmenu.add(cli.menu.item.MenuItem("Increase", None)) - sizeSubmenu.add(cli.menu.item.MenuItem("Decrease", None)) - graphMenu.add(sizeSubmenu) - - graphMenu.add(cli.menu.item.MenuItem("Update Interval", None)) - - boundsSubmenu = cli.menu.item.Submenu("Bounds") - boundsSubmenu.add(cli.menu.item.MenuItem("Local Max", None)) - boundsSubmenu.add(cli.menu.item.MenuItem("Global Max", None)) - boundsSubmenu.add(cli.menu.item.MenuItem("Tight", None)) - graphMenu.add(boundsSubmenu) - baseMenu.add(graphMenu) - - connectionsMenu = cli.menu.item.Submenu("Connections") - connectionsMenu.add(cli.menu.item.MenuItem("Identity", None)) - connectionsMenu.add(cli.menu.item.MenuItem("Resolver", None)) - connectionsMenu.add(cli.menu.item.MenuItem("Sort Order", None)) - baseMenu.add(connectionsMenu) - - configurationMenu = cli.menu.item.Submenu("Configuration") - - commentsSubmenu = cli.menu.item.Submenu("Comments") - commentsSubmenu.add(cli.menu.item.MenuItem("Hidden", None)) - commentsSubmenu.add(cli.menu.item.MenuItem("Visible", None)) - configurationMenu.add(commentsSubmenu) - - configurationMenu.add(cli.menu.item.MenuItem("Reload", None)) - configurationMenu.add(cli.menu.item.MenuItem("Reset Tor", None)) - baseMenu.add(configurationMenu) - - return baseMenu - class MenuCursor: """ Tracks selection and key handling in the menu. @@ -139,7 +74,7 @@ def showMenu(): try: # generates the menu and uses the initial selection of the first item in # the file menu - menu = makeMenu() + menu = cli.menu.actions.makeMenu() cursor = MenuCursor(menu.getChildren()[0].getChildren()[0])
while not cursor.isDone():
tor-commits@lists.torproject.org