summaryrefslogtreecommitdiff
path: root/grc/gui/Bars.py
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2015-04-02 13:20:19 +0200
committerSebastian Koslowski <koslowski@kit.edu>2015-04-02 13:20:19 +0200
commita601b909daabe84c1a3c31ba13456e48c3871e46 (patch)
tree27003ad191368168e0ae15ec05c2ff79f6a5b47c /grc/gui/Bars.py
parentffb28308cefc7cf588da745508670122319c690f (diff)
grc: move context def into Bars.py and add submenu
Diffstat (limited to 'grc/gui/Bars.py')
-rw-r--r--grc/gui/Bars.py53
1 files changed, 50 insertions, 3 deletions
diff --git a/grc/gui/Bars.py b/grc/gui/Bars.py
index 5041a28f14..6ce614bc99 100644
--- a/grc/gui/Bars.py
+++ b/grc/gui/Bars.py
@@ -121,6 +121,30 @@ MENU_BAR_LIST = (
Actions.ABOUT_WINDOW_DISPLAY,
]),
)
+
+
+CONTEXT_MENU_LIST = [
+ Actions.BLOCK_CUT,
+ Actions.BLOCK_COPY,
+ Actions.BLOCK_PASTE,
+ Actions.ELEMENT_DELETE,
+ None,
+ Actions.BLOCK_ROTATE_CCW,
+ Actions.BLOCK_ROTATE_CW,
+ Actions.BLOCK_ENABLE,
+ Actions.BLOCK_DISABLE,
+ None,
+ (gtk.Action('More', '_More', None, None), [
+ Actions.BLOCK_CREATE_HIER,
+ Actions.OPEN_HIER,
+ None,
+ Actions.BUSSIFY_SOURCES,
+ Actions.BUSSIFY_SINKS,
+ ]),
+ Actions.BLOCK_PARAM_MODIFY
+]
+
+
class Toolbar(gtk.Toolbar):
"""The gtk toolbar with actions added from the toolbar list."""
@@ -138,6 +162,7 @@ class Toolbar(gtk.Toolbar):
action.set_property('tooltip', action.get_property('tooltip'))
else: self.add(gtk.SeparatorToolItem())
+
class MenuBar(gtk.MenuBar):
"""The gtk menu bar with actions added from the menu bar list."""
@@ -157,7 +182,29 @@ class MenuBar(gtk.MenuBar):
main_menu = gtk.Menu()
main_menu_item.set_submenu(main_menu)
for action in actions:
- if action: #append a menu item
- main_menu.append(action.create_menu_item())
- else: main_menu.append(gtk.SeparatorMenuItem())
+ main_menu.append(action.create_menu_item() if action else
+ gtk.SeparatorMenuItem())
main_menu.show_all() #this show all is required for the separators to show
+
+
+class ContextMenu(gtk.Menu):
+ """The gtk menu with actions added from the context menu list."""
+
+ def __init__(self):
+ gtk.Menu.__init__(self)
+ for action in CONTEXT_MENU_LIST:
+ if isinstance(action, tuple):
+ action, sub_menu_action_list = action
+ item = action.create_menu_item()
+ self.append(item)
+ sub_menu = gtk.Menu()
+ item.set_submenu(sub_menu)
+ for action in sub_menu_action_list:
+ sub_menu.append(action.create_menu_item() if action else
+ gtk.SeparatorMenuItem())
+ sub_menu.show_all()
+
+ else:
+ self.append(action.create_menu_item() if action else
+ gtk.SeparatorMenuItem())
+ self.show_all()