2 Copyright 2007 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
19 ##@package grc.gui.Bars
20 #Create the GUI's toolbar and menubar
22 from grc.Actions import *
27 ##The list of actions for the toolbar.
34 FLOW_GRAPH_SCREEN_CAPTURE,
55 ##The list of actions and categories for the menu bar.
57 (gtk.Action('File', '_File', None, None), [
64 FLOW_GRAPH_SCREEN_CAPTURE,
69 (gtk.Action('Edit', '_Edit', None, None), [
86 (gtk.Action('Build', '_Build', None, None), [
91 (gtk.Action('Options', '_Options', None, None), [
94 (gtk.Action('Help', '_Help', None, None), [
96 HOTKEYS_WINDOW_DISPLAY,
100 class Toolbar(gtk.Toolbar):
101 """The gtk toolbar with actions added from the toolbar list."""
105 Parse the list of action names in the toolbar list.
106 Look up the action for each name in the action list and add it to the toolbar.
108 gtk.Toolbar.__init__(self)
109 self.set_style(gtk.TOOLBAR_ICONS)
110 for action_name in TOOLBAR_LIST:
111 if action_name: #add a tool item
112 action = get_action_from_name(action_name)
113 self.add(action.create_tool_item())
114 #this reset of the tooltip property is required (after creating the tool item) for the tooltip to show
115 action.set_property('tooltip', action.get_property('tooltip'))
116 else: self.add(gtk.SeparatorToolItem())
118 class MenuBar(gtk.MenuBar):
119 """The gtk menu bar with actions added from the menu bar list."""
123 Parse the list of submenus from the menubar list.
124 For each submenu, get a list of action names.
125 Look up the action for each name in the action list and add it to the submenu.
126 Add the submenu to the menu bar.
128 gtk.MenuBar.__init__(self)
129 for main_action,action_names in MENU_BAR_LIST:
130 #create the main menu item
131 main_menu_item = main_action.create_menu_item()
132 self.append(main_menu_item)
134 main_menu = gtk.Menu()
135 main_menu_item.set_submenu(main_menu)
136 for action_name in action_names:
137 if action_name: #append a menu item
138 action = get_action_from_name(action_name)
139 main_menu.append(action.create_menu_item())
140 else: main_menu.append(gtk.SeparatorMenuItem())
141 main_menu.show_all() #this show all is required for the separators to show