2 Copyright 2008 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.Dialogs
26 from grc.Constants import *
27 from grc import Preferences
29 class TextDisplay(gtk.TextView):
30 """A non editable gtk text view."""
32 def __init__(self, text=''):
34 TextDisplay constructor.
35 @param text the text to display (string)
37 text_buffer = gtk.TextBuffer()
38 text_buffer.set_text(text)
39 self.set_text = text_buffer.set_text
40 self.insert = lambda line: text_buffer.insert(text_buffer.get_end_iter(), line)
41 gtk.TextView.__init__(self, text_buffer)
42 self.set_editable(False)
43 self.set_cursor_visible(False)
44 self.set_wrap_mode(gtk.WRAP_WORD_CHAR)
46 ######################################################################################################
47 class PreferencesDialog(gtk.Dialog):
48 """A dialog box to display the preferences."""
51 """PreferencesDialog constructor."""
52 gtk.Dialog.__init__(self, buttons=('gtk-close', gtk.RESPONSE_CLOSE))
53 self.set_title("Preferences")
54 self.set_size_request(MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT)
55 notebook = gtk.Notebook()
56 for title,desc,params in Preferences.get_preferences():
58 vbox.pack_start(gtk.Label(''), False) #blank label for spacing
59 for param in params: vbox.pack_start(param.get_input_object(), False)
60 desc = desc.strip('\n')
61 if desc: vbox.pack_start(TextDisplay(desc), False, padding=5)
62 notebook.append_page(vbox, gtk.Label(title))
63 self.vbox.pack_start(notebook, True)
68 ######################################################################################################
69 def MessageDialogHelper(type, buttons, title=None, markup=None):
71 Create a modal message dialog and run it.
72 @param type the type of message: gtk.MESSAGE_INFO, gtk.MESSAGE_WARNING, gtk.MESSAGE_QUESTION or gtk.MESSAGE_ERROR
73 @param buttons the predefined set of buttons to use: gtk.BUTTONS_NONE, gtk.BUTTONS_OK, gtk.BUTTONS_CLOSE, gtk.BUTTONS_CANCEL, gtk.BUTTONS_YES_NO, gtk.BUTTONS_OK_CANCEL
74 @param tittle the title of the window (string)
75 @param markup the message text with pango markup
76 @return the gtk response from run()
78 message_dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, type, buttons)
79 if title != None: message_dialog.set_title(title)
80 if markup != None: message_dialog.set_markup(markup)
81 response = message_dialog.run()
82 message_dialog.destroy()
85 ######################################################################################################
86 class AboutDialog(gtk.AboutDialog):
87 """A cute little about dialog."""
90 """AboutDialog constructor."""
91 gtk.AboutDialog.__init__(self)
92 self.set_version(VERSION)
93 self.set_name(MAIN_WINDOW_PREFIX)
94 self.set_license(__doc__)
95 self.set_copyright('Copyright 2008 Free Software Foundation, Inc.')
96 self.set_website('http://gnuradio.org/trac/wiki/GNURadioCompanion')
97 self.set_comments("""\
98 Thank you to all those from the mailing list who tested GNU Radio Companion and offered advice.
101 A. Brinton Cooper -> starting the project
102 CER Technology Fellowship Grant -> initial funding
103 William R. Kenan Jr. Fund -> usrp & computers
104 Patrick Strasser -> the GRC icon
105 Achilleas Anastasopoulos -> trellis support
110 ######################################################################################################
111 class HotKeysDialog(gtk.Dialog):
112 """Display each action with the associated hotkey."""
115 """HotKeysDialog constructor."""
116 gtk.Dialog.__init__(self, buttons=('gtk-close', gtk.RESPONSE_CLOSE))
117 self.set_title('Hot Keys')
119 for action, hotkey in (
120 ('New Flow Graph', 'Ctrl + n'),
121 ('Open Flow Graph', 'Ctrl + o'),
122 ('Save Flow Graph', 'Ctrl + s'),
123 ('Close Flow Graph', 'Ctrl + q'),
124 ('Cut Block', 'Ctrl + x'),
125 ('Copy Block', 'Ctrl + c'),
126 ('Paste Block', 'Ctrl + v'),
127 ('Undo Change', 'Ctrl + z'),
128 ('Redo Change', 'Ctrl + y'),
129 ('Delete Block', 'Delete'),
130 ('Modify Parameters', 'Enter'),
131 ('Rotate Block', 'Right'),
132 ('Rotate Block', 'Left'),
133 ('Enable Block', 'e'),
134 ('Disable Block', 'd'),
135 ('Modify Data Type', 'Up'),
136 ('Modify Data Type', 'Down'),
138 ('Remove a Port', '-'),
139 ('Flow Graph Generate', 'F5'),
140 ('Flow Graph Execute', 'F6'),
141 ('Flow Graph Kill', 'F7'),
142 ('Screen Shot', 'PrintScreen'),
143 ): markup = '%s\n<b>%s:</b>%s'%(markup, action, hotkey.rjust(25-len(action), ' '))
145 label.set_markup('<tt>%s</tt>\n'%markup) #append newline
146 self.vbox.pack_start(label, False)