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
24 ######################################################################################################
26 ######################################################################################################
27 APPLICATION_INITIALIZE = 'app init'
28 APPLICATION_QUIT = 'app quit'
29 PARAM_MODIFY = 'param modify'
30 BLOCK_MOVE = 'block move'
31 BLOCK_ROTATE_LEFT = 'block rotate left'
32 BLOCK_ROTATE_RIGHT = 'block rotate right'
33 BLOCK_PARAM_MODIFY = 'block param modify'
34 BLOCK_INC_TYPE = 'block increment type'
35 BLOCK_DEC_TYPE = 'block decrement type'
36 BLOCK_ENABLE = 'block enable'
37 BLOCK_DISABLE = 'block disable'
38 BLOCK_CUT = 'block cut'
39 BLOCK_COPY = 'block copy'
40 BLOCK_PASTE = 'block paste'
41 PORT_CONTROLLER_INC = 'port controller increment'
42 PORT_CONTROLLER_DEC = 'port controller decrement'
43 ELEMENT_CREATE = 'element create'
44 ELEMENT_DELETE = 'element delete'
45 ELEMENT_SELECT = 'element select'
46 NOTHING_SELECT = 'nothing select'
47 FLOW_GRAPH_OPEN = 'flow graph open'
48 FLOW_GRAPH_UNDO = 'flow graph undo'
49 FLOW_GRAPH_REDO = 'flow graph redo'
50 FLOW_GRAPH_SAVE = 'flow graph save'
51 FLOW_GRAPH_SAVE_AS = 'flow graph save as'
52 FLOW_GRAPH_CLOSE = 'flow graph close'
53 FLOW_GRAPH_NEW = 'flow graph new'
54 FLOW_GRAPH_GEN = 'flow graph gen'
55 FLOW_GRAPH_EXEC = 'flow graph exec'
56 FLOW_GRAPH_KILL = 'flow graph kill'
57 FLOW_GRAPH_SCREEN_CAPTURE = 'flow graph screen capture'
58 ABOUT_WINDOW_DISPLAY = 'about window display'
60 ######################################################################################################
62 ######################################################################################################
64 #action name: (key name, mask)
65 FLOW_GRAPH_NEW: ('n', gtk.gdk.CONTROL_MASK),
66 FLOW_GRAPH_OPEN: ('o', gtk.gdk.CONTROL_MASK),
67 FLOW_GRAPH_SAVE: ('s', gtk.gdk.CONTROL_MASK),
68 FLOW_GRAPH_CLOSE: ('w', gtk.gdk.CONTROL_MASK),
69 APPLICATION_QUIT: ('q', gtk.gdk.CONTROL_MASK),
70 FLOW_GRAPH_UNDO: ('z', gtk.gdk.CONTROL_MASK),
71 FLOW_GRAPH_REDO: ('y', gtk.gdk.CONTROL_MASK),
72 ELEMENT_DELETE: ('Delete', 0),
73 BLOCK_ROTATE_LEFT: ('Left', 0),
74 BLOCK_ROTATE_RIGHT: ('Right', 0),
75 BLOCK_PARAM_MODIFY: ('Return', 0),
76 BLOCK_ENABLE: ('e', 0),
77 BLOCK_DISABLE: ('d', 0),
78 BLOCK_CUT: ('x', gtk.gdk.CONTROL_MASK),
79 BLOCK_COPY: ('c', gtk.gdk.CONTROL_MASK),
80 BLOCK_PASTE: ('v', gtk.gdk.CONTROL_MASK),
81 FLOW_GRAPH_GEN: ('F5', 0),
82 FLOW_GRAPH_EXEC: ('F6', 0),
83 FLOW_GRAPH_KILL: ('F7', 0),
84 FLOW_GRAPH_SCREEN_CAPTURE: ('Print', 0),
87 ######################################################################################################
89 ######################################################################################################
91 gtk.Action(FLOW_GRAPH_NEW, '_New', 'Create a new flow graph', 'gtk-new'),
92 gtk.Action(FLOW_GRAPH_OPEN, '_Open', 'Open an existing flow graph', 'gtk-open'),
93 gtk.Action(FLOW_GRAPH_SAVE, '_Save', 'Save the current flow graph', 'gtk-save'),
94 gtk.Action(FLOW_GRAPH_SAVE_AS, 'Save _As', 'Save the current flow graph as...', 'gtk-save-as'),
95 gtk.Action(FLOW_GRAPH_CLOSE, '_Close', 'Close the current flow graph', 'gtk-close'),
96 gtk.Action(APPLICATION_QUIT, '_Quit', 'Quit program', 'gtk-quit'),
97 gtk.Action(FLOW_GRAPH_UNDO, '_Undo', 'Undo a change to the flow graph', 'gtk-undo'),
98 gtk.Action(FLOW_GRAPH_REDO, '_Redo', 'Redo a change to the flow graph', 'gtk-redo'),
99 gtk.Action(ELEMENT_DELETE, '_Delete', 'Delete the selected blocks', 'gtk-delete'),
100 gtk.Action(BLOCK_ROTATE_LEFT, 'Rotate _Left', 'Rotate the selected blocks 90 degrees', 'gtk-go-back'),
101 gtk.Action(BLOCK_ROTATE_RIGHT, 'Rotate _Right', 'Rotate the selected blocks -90 degrees', 'gtk-go-forward'),
102 gtk.Action(BLOCK_PARAM_MODIFY, '_Properties', 'Modify params for the selected block', 'gtk-properties'),
103 gtk.Action(BLOCK_ENABLE, 'E_nable', 'Enable the selected blocks', 'gtk-connect'),
104 gtk.Action(BLOCK_DISABLE, 'D_isable', 'Disable the selected blocks', 'gtk-disconnect'),
105 gtk.Action(BLOCK_CUT, 'Cu_t', 'Cut', 'gtk-cut'),
106 gtk.Action(BLOCK_COPY, '_Copy', 'Copy', 'gtk-copy'),
107 gtk.Action(BLOCK_PASTE, '_Paste', 'Paste', 'gtk-paste'),
108 gtk.Action(ABOUT_WINDOW_DISPLAY, '_About', 'About this program', 'gtk-about'),
109 gtk.Action(FLOW_GRAPH_GEN, '_Generate', 'Generate the flow graph', 'gtk-convert'),
110 gtk.Action(FLOW_GRAPH_EXEC, '_Execute', 'Execute the flow graph', 'gtk-execute'),
111 gtk.Action(FLOW_GRAPH_KILL, '_Kill', 'Kill the flow graph', 'gtk-stop'),
112 gtk.Action(FLOW_GRAPH_SCREEN_CAPTURE, 'S_creen Capture', 'Create a screen capture of the flow graph', 'gtk-print'),
114 def get_all_actions(): return _actions_list
116 _actions_dict = dict((action.get_name(), action) for action in _actions_list)
117 def get_action_from_name(action_name):
119 Retrieve the action from the action list.
120 Search the list and find an action with said name.
121 @param action_name the action name(string)
122 @throw KeyError bad action name
123 @return a gtk action object
125 if _actions_dict.has_key(action_name): return _actions_dict[action_name]
126 raise KeyError('Action Name: "%s" does not exist'%action_name)
128 _accel_group = gtk.AccelGroup()
129 def get_accel_group(): return _accel_group
131 #load the actions key map
132 #set the accelerator group, and accelerator path
133 #register the key and mod with the accelerator path
134 for action_name, (key_name, mod) in _actions_key_map.iteritems():
135 get_action_from_name(action_name).set_accel_group(get_accel_group())
136 get_action_from_name(action_name).set_accel_path('<main>/'+action_name)
137 gtk.accel_map_add_entry('<main>/'+action_name, gtk.gdk.keyval_from_name(key_name),mod)