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