2 # -*- coding: utf-8 -*-
4 # gui/g2/transients.py - supporting dialogs for PyGTK UI
6 # Part of WiFi Radar: A utility for managing WiFi profiles on GNU/Linux.
8 # Copyright (C) 2004-2005 Ahmad Baitalmal <ahmad@baitalmal.com>
9 # Copyright (C) 2005 Nicolas Brouard <nicolas.brouard@mandrake.org>
10 # Copyright (C) 2005-2009 Brian Elliott Finley <brian@thefinleys.com>
11 # Copyright (C) 2006 David Decotigny <com.d2@free.fr>
12 # Copyright (C) 2006 Simon Gerber <gesimu@gmail.com>
13 # Copyright (C) 2006-2007 Joey Hurst <jhurst@lucubrate.org>
14 # Copyright (C) 2012 Anari Jalakas <anari.jalakas@gmail.com>
15 # Copyright (C) 2006, 2009 Ante Karamatic <ivoks@ubuntu.com>
16 # Copyright (C) 2009-2010,2014 Sean Robinson <robinson@tuxfamily.org>
17 # Copyright (C) 2010 Prokhor Shuchalov <p@shuchalov.ru>
19 # This program is free software; you can redistribute it and/or modify
20 # it under the terms of the GNU General Public License as published by
21 # the Free Software Foundation; version 2 of the License.
23 # This program is distributed in the hope that it will be useful,
24 # but WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 # GNU General Public License in LICENSE.GPL for more details.
28 # You should have received a copy of the GNU General Public License
29 # along with this program; if not, write to:
30 # Free Software Foundation, Inc.
31 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
35 from __future__
import unicode_literals
41 from wifiradar
.misc
import _
, WIFI_RADAR_VERSION
44 logger
= logging
.getLogger(__name__
)
47 class AboutDialog(gtk
.AboutDialog
, object):
48 """ Manage a GTK About Dialog.
51 """ Create an AboutDialog filled with WiFi Radar information.
53 gtk
.AboutDialog
.__init
__(self
)
54 self
.set_authors(['Ahmad Baitalmal <ahmad@baitalmal.com>',
55 'Brian Elliott Finley <brian@thefinleys.com>',
56 'Sean Robinson <robinson@tuxfamily.org>', '',
57 'Contributors', 'Douglas Breault', 'Nicolas Brouard',
58 'Jon Collette', 'David Decotigny', 'Simon Gerber',
59 'Joey Hurst', 'Anari Jalakas', 'Ante Karamatic',
60 'Richard Monk', 'Kevin Otte', 'Nathanael Rebsch',
61 'Andrea Scarpino', 'Prokhor Shuchalov', 'Patrick Winnertz'])
62 self
.set_comments(_('WiFi connection manager'))
63 self
.set_copyright(_('Copyright 2004-2014 by various authors '
64 'and contributors\nCurrent Maintainer: '
65 'Sean Robinson <robinson@tuxfamily.org>'))
66 self
.set_documenters(['Gary Case'])
68 This program is free software; you can redistribute it and/or modify
69 it under the terms of the GNU General Public License as published by
70 the Free Software Foundation; either version 2 of the License, or
71 (at your option) any later version.
73 This program is distributed in the hope that it will be useful,
74 but WITHOUT ANY WARRANTY; without even the implied warranty of
75 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
76 GNU General Public License for more details.
78 You should have received a copy of the GNU General Public License
79 along with this program; if not, write to:
80 Free Software Foundation, Inc.
81 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA""")
82 self
.set_license(license
)
83 self
.icon
= gtk
.gdk
.pixbuf_new_from_file('pixmaps/wifi-radar.png')
84 self
.set_logo(self
.icon
)
85 self
.set_name('WiFi Radar')
86 self
.set_version(WIFI_RADAR_VERSION
)
87 self
.set_website('http://wifi-radar.tuxfamily.org/')
90 class ErrorDialog(gtk
.MessageDialog
, object):
91 """ Simple dialog to report an error to the user.
93 def __init__(self
, parent
, message
):
94 """ Manage the complete life-cycle of an error message dialog.
96 gtk
.MessageDialog
.__init
__(self
, parent
,
97 gtk
.DIALOG_DESTROY_WITH_PARENT | gtk
.DIALOG_MODAL
,
98 gtk
.MESSAGE_ERROR
, gtk
.BUTTONS_OK
, message
)
103 class FileBrowseButton(gtk
.Button
, object):
104 """ Button to allow user to choose a file and put value into specified gtk.Entry.
106 def __init__(self
, parent
, entry
):
107 """ Create a button to simulate a File/Open.
109 gtk
.Button
.__init
__(self
, _('Browse'), None)
111 self
.browser_dialog
= gtk
.FileChooserDialog(None, parent
,
112 gtk
.FILE_CHOOSER_ACTION_OPEN
,
113 (gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
,
114 gtk
.STOCK_OPEN
, gtk
.RESPONSE_OK
), None)
115 self
.connect('clicked', self
.browse_files
)
117 def browse_files(self
, widget
=None):
118 """ Show a file chooser dialog, get the user selection, and update
119 the text entry value associated with the :class:`FileBrowseButton`.
120 :data:`widget` is the widget sending the signal, but it is
123 self
.browser_dialog
.set_filename(self
.entry
.get_text())
124 self
.browser_dialog
.run()
125 filename
= self
.browser_dialog
.get_filename()
127 self
.entry
.set_text(filename
)
128 self
.browser_dialog
.destroy()
131 class StatusWindow(gtk
.Dialog
, object):
132 """ A simple class for putting up a "Please wait" dialog so the user
133 doesn't think we've forgotten about them. Implements the status
134 interface. Status interface requires show(), update_message(message),
137 def __init__(self
, parent
):
138 """ Create a new StatusWindow under :data:`parent`, the ancestor
139 widget of the instance of :class:`StatusWindow`.
141 gtk
.Dialog
.__init
__(self
, _('Working'), parent
,
142 gtk
.DIALOG_MODAL | gtk
.DIALOG_DESTROY_WITH_PARENT
)
143 self
.icon
= gtk
.gdk
.pixbuf_new_from_file('pixmaps/wifi-radar.png')
144 self
.set_icon(self
.icon
)
145 self
.label
= gtk
.Label(_('Please wait...'))
146 self
.bar
= gtk
.ProgressBar()
147 self
.vbox
.pack_start(self
.label
)
148 self
.vbox
.pack_start(self
.bar
)
149 self
.cancel_button
= self
.add_button(gtk
.STOCK_CANCEL
, gtk
.BUTTONS_CANCEL
)
152 def update_message(self
, message
):
153 """ Change the :data:`message` string displayed to the user.
155 self
.label
.set_text(message
)
157 def update_window(self
):
158 """ Update the :class:`StatusWindow` progress bar. Always return True
159 so a timer will reschedule this method.
165 """ Display and operate the StatusWindow.
170 """ Show all the widgets of the StatusWindow.
173 self
.timer
= gobject
.timeout_add(250, self
.update_window
)
177 """ Hide all the widgets of the StatusWindow.
180 gobject
.source_remove(self
.timer
)
186 """ Remove the StatusWindow.
189 gobject
.source_remove(self
.timer
)
192 # Make so we can be imported
193 if __name__
== '__main__':