Dialogs.py

Go to the documentation of this file.
00001 """
00002 Copyright 2007 Free Software Foundation, Inc.
00003 This file is part of GNU Radio
00004 
00005 GNU Radio Companion is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 GNU Radio Companion is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00018 """
00019 ##@package grc.gui.Dialogs
00020 #Misc dialogs.
00021 #@author Josh Blum
00022 
00023 import pygtk
00024 pygtk.require('2.0')
00025 import gtk
00026 from grc.Constants import *
00027 from grc import Preferences
00028 
00029 class TextDisplay(gtk.TextView):
00030         """A non editable gtk text view."""
00031 
00032         def __init__(self, text=''):
00033                 """!
00034                 TextDisplay constructor.
00035                 @param text the text to display (string)
00036                 """
00037                 text_buffer = gtk.TextBuffer()
00038                 text_buffer.set_text(text)
00039                 self.set_text = text_buffer.set_text
00040                 self.insert = lambda line: text_buffer.insert(text_buffer.get_end_iter(), line)
00041                 gtk.TextView.__init__(self, text_buffer)
00042                 self.set_editable(False)
00043                 self.set_cursor_visible(False)
00044                 self.set_wrap_mode(gtk.WRAP_WORD_CHAR)
00045 
00046 ######################################################################################################
00047 class PreferencesDialog(gtk.Dialog):
00048         """A dialog box to display the preferences."""
00049 
00050         def __init__(self):
00051                 """PreferencesDialog constructor."""
00052                 gtk.Dialog.__init__(self, buttons=('gtk-close', gtk.RESPONSE_CLOSE))
00053                 self.set_title("Preferences")
00054                 self.set_size_request(MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT)
00055                 notebook = gtk.Notebook()
00056                 for title,desc,params in Preferences.get_preferences():
00057                         vbox = gtk.VBox()
00058                         vbox.pack_start(gtk.Label(''), False) #blank label for spacing
00059                         for param in params: vbox.pack_start(param.get_input_object(), False)
00060                         desc = desc.strip('\n')
00061                         if desc: vbox.pack_start(TextDisplay(desc), False, padding=5)
00062                         notebook.append_page(vbox, gtk.Label(title))
00063                 self.vbox.pack_start(notebook, True)
00064                 self.show_all()
00065                 self.run()
00066                 self.destroy()
00067 
00068 ######################################################################################################
00069 def MessageDialogHelper(type, buttons, title=None, markup=None):
00070         """!
00071         Create a modal message dialog and run it.
00072         @param type the type of message: gtk.MESSAGE_INFO, gtk.MESSAGE_WARNING, gtk.MESSAGE_QUESTION or gtk.MESSAGE_ERROR
00073         @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
00074         @param tittle the title of the window (string)
00075         @param markup the message text with pango markup
00076         @return the gtk response from run()
00077         """
00078         message_dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, type, buttons)
00079         if title != None: message_dialog.set_title(title)
00080         if markup != None: message_dialog.set_markup(markup)
00081         response = message_dialog.run()
00082         message_dialog.destroy()
00083         return response
00084 
00085 ######################################################################################################
00086 class AboutDialog(gtk.AboutDialog):
00087         """A cute little about dialog."""
00088 
00089         def __init__(self):
00090                 """AboutDialog constructor."""
00091                 gtk.AboutDialog.__init__(self)
00092                 self.set_version(VERSION)
00093                 self.set_name(MAIN_WINDOW_PREFIX)
00094                 self.set_license(__doc__)
00095                 self.set_copyright('Copyright 2007 Free Software Foundation, Inc.')
00096                 self.set_website('http://gnuradio.org/trac/wiki/GNURadioCompanion')
00097                 self.set_comments("""\
00098 Thank you to all those from the mailing list who tested GNU Radio Companion and offered advice.
00099 --
00100 Special Thanks:
00101 A. Brinton Cooper -> starting the project
00102 CER Technology Fellowship Grant -> initial funding
00103 William R. Kenan Jr. Fund -> usrp & computers
00104 Patrick Strasser -> the GRC icon
00105 Achilleas Anastasopoulos -> trellis support
00106 --""")
00107                 self.run()
00108                 self.destroy()
00109 
00110 ######################################################################################################
00111 class HotKeysDialog(gtk.Dialog):
00112         """Display each action with the associated hotkey."""
00113 
00114         def __init__(self):
00115                 """HotKeysDialog constructor."""
00116                 gtk.Dialog.__init__(self, buttons=('gtk-close', gtk.RESPONSE_CLOSE))
00117                 self.set_title('Hot Keys')
00118                 markup = ''
00119                 for action, hotkey in (
00120                         ('New Flow Graph', 'Ctrl + n'),
00121                         ('Open Flow Graph', 'Ctrl + o'),
00122                         ('Save Flow Graph', 'Ctrl + s'),
00123                         ('Close Flow Graph', 'Ctrl + q'),
00124                         ('Cut Block', 'Ctrl + x'),
00125                         ('Copy Block', 'Ctrl + c'),
00126                         ('Paste Block', 'Ctrl + v'),
00127                         ('Undo Change', 'Ctrl + z'),
00128                         ('Redo Change', 'Ctrl + y'),
00129                         ('Delete Block', 'Delete'),
00130                         ('Modify Parameters', 'Enter'),
00131                         ('Rotate Block', 'Right'),
00132                         ('Rotate Block', 'Left'),
00133                         ('Enable Block', 'e'),
00134                         ('Disable Block', 'd'),
00135                         ('Modify Data Type', 'Up'),
00136                         ('Modify Data Type', 'Down'),
00137                         ('Add a Port', '+'),
00138                         ('Remove a Port', '-'),
00139                         ('Flow Graph Generate', 'F5'),
00140                         ('Flow Graph Execute', 'F6'),
00141                         ('Flow Graph Kill', 'F7'),
00142                         ('Screen Shot', 'PrintScreen'),
00143                 ): markup = '%s\n<b>%s:</b>%s'%(markup, action, hotkey.rjust(25-len(action), ' '))
00144                 label = gtk.Label()
00145                 label.set_markup('<tt>%s</tt>\n'%markup) #append newline
00146                 self.vbox.pack_start(label, False)
00147                 self.show_all()
00148                 self.run()
00149                 self.destroy()

Generated on Sat Aug 23 02:00:11 2008 for GNU Radio Companion by  doxygen 1.5.4