2 Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
3 This file is part of GNU Radio
5 GNU Radio Companion is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 GNU Radio Companion is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 ##The list of actions for the toolbar.
27 Actions.FLOW_GRAPH_NEW,
28 Actions.FLOW_GRAPH_OPEN,
29 Actions.FLOW_GRAPH_SAVE,
30 Actions.FLOW_GRAPH_CLOSE,
32 Actions.FLOW_GRAPH_SCREEN_CAPTURE,
37 Actions.ELEMENT_DELETE,
39 Actions.FLOW_GRAPH_UNDO,
40 Actions.FLOW_GRAPH_REDO,
42 Actions.FLOW_GRAPH_GEN,
43 Actions.FLOW_GRAPH_EXEC,
44 Actions.FLOW_GRAPH_KILL,
46 Actions.BLOCK_ROTATE_CCW,
47 Actions.BLOCK_ROTATE_CW,
50 Actions.BLOCK_DISABLE,
53 ##The list of actions and categories for the menu bar.
55 (gtk.Action('File', '_File', None, None), [
56 Actions.FLOW_GRAPH_NEW,
57 Actions.FLOW_GRAPH_OPEN,
59 Actions.FLOW_GRAPH_SAVE,
60 Actions.FLOW_GRAPH_SAVE_AS,
62 Actions.FLOW_GRAPH_SCREEN_CAPTURE,
64 Actions.FLOW_GRAPH_CLOSE,
65 Actions.APPLICATION_QUIT,
67 (gtk.Action('Edit', '_Edit', None, None), [
68 Actions.FLOW_GRAPH_UNDO,
69 Actions.FLOW_GRAPH_REDO,
74 Actions.ELEMENT_DELETE,
76 Actions.BLOCK_ROTATE_CCW,
77 Actions.BLOCK_ROTATE_CW,
80 Actions.BLOCK_DISABLE,
82 Actions.BLOCK_PARAM_MODIFY,
84 (gtk.Action('Build', '_Build', None, None), [
85 Actions.FLOW_GRAPH_GEN,
86 Actions.FLOW_GRAPH_EXEC,
87 Actions.FLOW_GRAPH_KILL,
89 (gtk.Action('Help', '_Help', None, None), [
90 Actions.HELP_WINDOW_DISPLAY,
91 Actions.TYPES_WINDOW_DISPLAY,
93 Actions.ABOUT_WINDOW_DISPLAY,
97 class Toolbar(gtk.Toolbar):
98 """The gtk toolbar with actions added from the toolbar list."""
102 Parse the list of action names in the toolbar list.
103 Look up the action for each name in the action list and add it to the toolbar.
105 gtk.Toolbar.__init__(self)
106 self.set_style(gtk.TOOLBAR_ICONS)
107 for action in TOOLBAR_LIST:
108 if action: #add a tool item
109 self.add(action.create_tool_item())
110 #this reset of the tooltip property is required (after creating the tool item) for the tooltip to show
111 action.set_property('tooltip', action.get_property('tooltip'))
112 else: self.add(gtk.SeparatorToolItem())
114 class MenuBar(gtk.MenuBar):
115 """The gtk menu bar with actions added from the menu bar list."""
119 Parse the list of submenus from the menubar list.
120 For each submenu, get a list of action names.
121 Look up the action for each name in the action list and add it to the submenu.
122 Add the submenu to the menu bar.
124 gtk.MenuBar.__init__(self)
125 for main_action, actions in MENU_BAR_LIST:
126 #create the main menu item
127 main_menu_item = main_action.create_menu_item()
128 self.append(main_menu_item)
130 main_menu = gtk.Menu()
131 main_menu_item.set_submenu(main_menu)
132 for action in actions:
133 if action: #append a menu item
134 main_menu.append(action.create_menu_item())
135 else: main_menu.append(gtk.SeparatorMenuItem())
136 main_menu.show_all() #this show all is required for the separators to show