2 Copyright 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 class TextDisplay(gtk.TextView):
26 """A non editable gtk text view."""
28 def __init__(self, text=''):
30 TextDisplay constructor.
31 @param text the text to display (string)
33 text_buffer = gtk.TextBuffer()
34 text_buffer.set_text(text)
35 self.set_text = text_buffer.set_text
36 self.insert = lambda line: text_buffer.insert(text_buffer.get_end_iter(), line)
37 gtk.TextView.__init__(self, text_buffer)
38 self.set_editable(False)
39 self.set_cursor_visible(False)
40 self.set_wrap_mode(gtk.WRAP_WORD_CHAR)
42 def MessageDialogHelper(type, buttons, title=None, markup=None):
44 Create a modal message dialog and run it.
45 @param type the type of message: gtk.MESSAGE_INFO, gtk.MESSAGE_WARNING, gtk.MESSAGE_QUESTION or gtk.MESSAGE_ERROR
46 @param buttons the predefined set of buttons to use:
47 gtk.BUTTONS_NONE, gtk.BUTTONS_OK, gtk.BUTTONS_CLOSE, gtk.BUTTONS_CANCEL, gtk.BUTTONS_YES_NO, gtk.BUTTONS_OK_CANCEL
48 @param tittle the title of the window (string)
49 @param markup the message text with pango markup
50 @return the gtk response from run()
52 message_dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, type, buttons)
53 if title: message_dialog.set_title(title)
54 if markup: message_dialog.set_markup(markup)
55 response = message_dialog.run()
56 message_dialog.destroy()
60 ERRORS_MARKUP_TMPL="""\
61 #for $i, $err_msg in enumerate($errors)
63 $encode($err_msg.replace('\t', ' '))
66 def ErrorsDialog(flowgraph): MessageDialogHelper(
67 type=gtk.MESSAGE_ERROR,
68 buttons=gtk.BUTTONS_CLOSE,
69 title='Flow Graph Errors',
70 markup=Utils.parse_template(ERRORS_MARKUP_TMPL, errors=flowgraph.get_error_messages()),
73 class AboutDialog(gtk.AboutDialog):
74 """A cute little about dialog."""
76 def __init__(self, platform):
77 """AboutDialog constructor."""
78 gtk.AboutDialog.__init__(self)
79 self.set_name(platform.get_name())
80 self.set_version(platform.get_version())
81 self.set_license(platform.get_license())
82 self.set_copyright(platform.get_license().splitlines()[0])
83 self.set_website(platform.get_website())
87 def HelpDialog(): MessageDialogHelper(
88 type=gtk.MESSAGE_INFO,
89 buttons=gtk.BUTTONS_CLOSE,
94 <u>Add block</u>: drag and drop or double click a block in the block selection window.
95 <u>Rotate block</u>: Select a block, press left/right on the keyboard.
96 <u>Change type</u>: Select a block, press up/down on the keyboard.
97 <u>Edit parameters</u>: double click on a block in the flow graph.
98 <u>Make connection</u>: click on the source port of one block, then click on the sink port of another block.
99 <u>Remove connection</u>: select the connection and press delete, or drag the connection.
101 * See the menu for other keyboard shortcuts.""")
103 COLORS_DIALOG_MARKUP_TMPL = """\
107 #set $max_len = max([len(color[0]) for color in $colors]) + 10
108 #for $title, $color_spec in $colors
109 <span background="$color_spec"><tt>$($encode($title).center($max_len))</tt></span>
114 def TypesDialog(platform): MessageDialogHelper(
115 type=gtk.MESSAGE_INFO,
116 buttons=gtk.BUTTONS_CLOSE,
118 markup=Utils.parse_template(COLORS_DIALOG_MARKUP_TMPL, colors=platform.get_colors()))