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 <seankrobinson@gmail.com>
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 the Free Software
30 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37 import wifiradar
.misc
as misc
40 logger
= logging
.getLogger(__name__
)
43 class AboutDialog(gtk
.AboutDialog
, object):
44 """ Manage a GTK About Dialog.
47 """ Subclass GTK AboutDialog
57 gtk
.AboutDialog
.__init
__(self
)
58 self
.set_authors(["Ahmad Baitalmal <ahmad@baitalmal.com>",
59 "Brian Elliott Finley <brian@thefinleys.com>",
60 "Sean Robinson <seankrobinson@gmail.com>", "",
61 "Contributors", "Douglas Breault", "Nicolas Brouard",
62 "Jon Collette", "David Decotigny", "Simon Gerber",
63 "Joey Hurst", "Anari Jalakas", "Ante Karamatic",
64 "Richard Monk", "Kevin Otte", "Nathanael Rebsch",
65 "Andrea Scarpino", "Prokhor Shuchalov", "Patrick Winnertz"])
66 self
.set_comments("WiFi connection manager")
67 self
.set_copyright("Copyright 2004-2014 by various authors " + \
68 "and contributors\nCurrent Maintainer: " + \
69 "Sean Robinson <seankrobinson@gmail.com>")
70 self
.set_documenters(["Gary Case"])
72 This program is free software; you can redistribute it and/or modify
73 it under the terms of the GNU General Public License as published by
74 the Free Software Foundation; either version 2 of the License, or
75 (at your option) any later version.
77 This program is distributed in the hope that it will be useful,
78 but WITHOUT ANY WARRANTY; without even the implied warranty of
79 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80 GNU General Public License for more details.
82 You should have received a copy of the GNU General Public License
83 along with this program; if not, write to the Free Software
84 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"""
85 self
.set_license(license
)
86 self
.icon
= gtk
.gdk
.pixbuf_new_from_file("pixmaps/wifi-radar.png")
87 self
.set_logo(self
.icon
)
88 self
.set_name("WiFi Radar")
89 self
.set_version(misc
.WIFI_RADAR_VERSION
)
90 self
.set_website("http://wifi-radar.tuxfamily.org/")
93 class ErrorDialog(gtk
.MessageDialog
, object):
94 """ Simple dialog to report an error to the user.
96 def __init__(self
, parent
, message
):
97 """ Manage the complete life-cycle of an error message dialog.
99 gtk
.MessageDialog
.__init
__(self
, parent
,
100 gtk
.DIALOG_DESTROY_WITH_PARENT | gtk
.DIALOG_MODAL
,
101 gtk
.MESSAGE_ERROR
, gtk
.BUTTONS_OK
, message
)
106 class FileBrowseButton(gtk
.Button
, object):
107 """ Button to allow user to choose a file and put value into specified gtk.Entry.
109 def __init__(self
, parent
, entry
):
110 """ Create a button to simulate a File/Open
114 'parent' -- gtk.Object -- Usually, the calling window.
116 'entry' -- gtk.Entry -- The text entry to update with user selection.
120 FileBrowseButton instance
122 gtk
.Button
.__init
__(self
, "Browse", None)
124 self
.browser_dialog
= gtk
.FileChooserDialog(None, parent
,
125 gtk
.FILE_CHOOSER_ACTION_OPEN
,
126 (gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
,
127 gtk
.STOCK_OPEN
, gtk
.RESPONSE_OK
), None)
128 self
.connect("clicked", self
.browse_files
)
130 def browse_files(self
, widget
=None):
131 """ Show filechooser dialog and get user selection
135 'widget' -- gtk.Widget -- The widget sending the event.
146 self
.browser_dialog
.set_filename(self
.entry
.get_text())
147 self
.browser_dialog
.run()
148 filename
= self
.browser_dialog
.get_filename()
150 self
.entry
.set_text(filename
)
151 self
.browser_dialog
.destroy()
154 class StatusWindow(gtk
.Dialog
, object):
155 """ A simple class for putting up a "Please wait" dialog so the user
156 doesn't think we've forgotten about them. Implements the status interface.
158 def __init__(self
, parent
):
159 """ Create a new StatusWindow.
163 'parent' -- gtk.Object - Usually, the calling window.
167 StatusWindow instance
171 Sample implementation of status interface. Status interface
172 requires .show(), .update_message(message), and .hide() methods.
174 gtk
.Dialog
.__init
__(self
, "Working", parent
,
175 gtk
.DIALOG_MODAL | gtk
.DIALOG_DESTROY_WITH_PARENT
)
176 self
.icon
= gtk
.gdk
.pixbuf_new_from_file("pixmaps/wifi-radar.png")
177 self
.set_icon(self
.icon
)
178 self
.lbl
= gtk
.Label("Please wait...")
179 self
.bar
= gtk
.ProgressBar()
180 self
.vbox
.pack_start(self
.lbl
)
181 self
.vbox
.pack_start(self
.bar
)
182 self
.cancel_button
= self
.add_button(gtk
.STOCK_CANCEL
, gtk
.BUTTONS_CANCEL
)
185 def update_message(self
, message
):
186 """ Change the message displayed to the user.
190 'message' -- string - The message to show to the user.
196 self
.lbl
.set_text(message
)
198 def update_window(self
):
199 """ Update the StatusWindow progress bar.
207 True -- always return True
213 """ Display and operate the StatusWindow.
226 """ Show all the widgets of the StatusWindow.
237 self
.timer
= gobject
.timeout_add(250, self
.update_window
)
241 """ Hide all the widgets of the StatusWindow.
252 gobject
.source_remove(self
.timer
)
258 """ Remove the StatusWindow.
269 gobject
.source_remove(self
.timer
)
272 # Make so we can be imported
273 if __name__
== "__main__":