new preferences
[debian/gnuradio] / grc / src / gui / Dialogs.py
1 """
2 Copyright 2008 Free Software Foundation, Inc.
3 This file is part of GNU Radio
4
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.
9
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.
14
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
18 """
19
20 import pygtk
21 pygtk.require('2.0')
22 import gtk
23 from Constants import MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT
24 from .. platforms.base.Constants import PACKAGE, VERSION
25 import Preferences
26
27 class TextDisplay(gtk.TextView):
28         """A non editable gtk text view."""
29
30         def __init__(self, text=''):
31                 """
32                 TextDisplay constructor.
33                 @param text the text to display (string)
34                 """
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)
43
44 def MessageDialogHelper(type, buttons, title=None, markup=None):
45         """
46         Create a modal message dialog and run it.
47         @param type the type of message: gtk.MESSAGE_INFO, gtk.MESSAGE_WARNING, gtk.MESSAGE_QUESTION or gtk.MESSAGE_ERROR
48         @param buttons the predefined set of buttons to use:
49                 gtk.BUTTONS_NONE, gtk.BUTTONS_OK, gtk.BUTTONS_CLOSE, gtk.BUTTONS_CANCEL, gtk.BUTTONS_YES_NO, gtk.BUTTONS_OK_CANCEL
50         @param tittle the title of the window (string)
51         @param markup the message text with pango markup
52         @return the gtk response from run()
53         """
54         message_dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, type, buttons)
55         if title != None: message_dialog.set_title(title)
56         if markup != None: message_dialog.set_markup(markup)
57         response = message_dialog.run()
58         message_dialog.destroy()
59         return response
60
61 class AboutDialog(gtk.AboutDialog):
62         """A cute little about dialog."""
63
64         def __init__(self):
65                 """AboutDialog constructor."""
66                 gtk.AboutDialog.__init__(self)
67                 self.set_name(PACKAGE)
68                 self.set_version(VERSION)
69                 self.set_license(__doc__)
70                 self.set_copyright(__doc__.strip().splitlines()[0])
71                 self.set_website('http://gnuradio.org/trac/wiki/GNURadioCompanion')
72                 self.set_comments("""\
73 Thank you to all those from the mailing list who tested GNU Radio Companion and offered advice.
74 -----
75 Special Thanks:
76 A. Brinton Cooper -> starting the project
77 Patrick Mulligan -> starting the project
78 CER Technology Fellowship Grant -> initial funding
79 William R. Kenan Jr. Fund -> usrp & computers
80 Patrick Strasser -> the GRC icon
81 Achilleas Anastasopoulos -> trellis support
82 -----""")
83                 self.run()
84                 self.destroy()