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
23 from Constants import MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT
24 from .. platforms.base.Constants import PACKAGE, VERSION
27 class TextDisplay(gtk.TextView):
28 """A non editable gtk text view."""
30 def __init__(self, text=''):
32 TextDisplay constructor.
33 @param text the text to display (string)
35 text_buffer = gtk.TextBuffer()
36 text_buffer.set_text(text)
37 self.set_text = text_buffer.set_text
38 self.insert = lambda line: text_buffer.insert(text_buffer.get_end_iter(), line)
39 gtk.TextView.__init__(self, text_buffer)
40 self.set_editable(False)
41 self.set_cursor_visible(False)
42 self.set_wrap_mode(gtk.WRAP_WORD_CHAR)
44 class PreferencesDialog(gtk.Dialog):
45 """A dialog box to display the preferences."""
48 """PreferencesDialog constructor."""
49 gtk.Dialog.__init__(self, buttons=('gtk-close', gtk.RESPONSE_CLOSE))
50 self.set_title("Preferences")
51 self.set_size_request(MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT)
52 notebook = gtk.Notebook()
53 for title,desc,params in Preferences.get_preferences():
55 vbox.pack_start(gtk.Label(''), False) #blank label for spacing
56 for param in params: vbox.pack_start(param.get_input_object(), False)
57 desc = desc.strip('\n')
58 if desc: vbox.pack_start(TextDisplay(desc), False, padding=5)
59 notebook.append_page(vbox, gtk.Label(title))
60 self.vbox.pack_start(notebook, True)
65 def MessageDialogHelper(type, buttons, title=None, markup=None):
67 Create a modal message dialog and run it.
68 @param type the type of message: gtk.MESSAGE_INFO, gtk.MESSAGE_WARNING, gtk.MESSAGE_QUESTION or gtk.MESSAGE_ERROR
69 @param buttons the predefined set of buttons to use:
70 gtk.BUTTONS_NONE, gtk.BUTTONS_OK, gtk.BUTTONS_CLOSE, gtk.BUTTONS_CANCEL, gtk.BUTTONS_YES_NO, gtk.BUTTONS_OK_CANCEL
71 @param tittle the title of the window (string)
72 @param markup the message text with pango markup
73 @return the gtk response from run()
75 message_dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, type, buttons)
76 if title != None: message_dialog.set_title(title)
77 if markup != None: message_dialog.set_markup(markup)
78 response = message_dialog.run()
79 message_dialog.destroy()
82 class AboutDialog(gtk.AboutDialog):
83 """A cute little about dialog."""
86 """AboutDialog constructor."""
87 gtk.AboutDialog.__init__(self)
88 self.set_name(PACKAGE)
89 self.set_version(VERSION)
90 self.set_license(__doc__)
91 self.set_copyright(__doc__.strip().splitlines()[0])
92 self.set_website('http://gnuradio.org/trac/wiki/GNURadioCompanion')
93 self.set_comments("""\
94 Thank you to all those from the mailing list who tested GNU Radio Companion and offered advice.
97 A. Brinton Cooper -> starting the project
98 Patrick Mulligan -> starting the project
99 CER Technology Fellowship Grant -> initial funding
100 William R. Kenan Jr. Fund -> usrp & computers
101 Patrick Strasser -> the GRC icon
102 Achilleas Anastasopoulos -> trellis support