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 """ Create an AboutDialog filled with WiFi Radar information.
49 gtk
.AboutDialog
.__init
__(self
)
50 self
.set_authors(["Ahmad Baitalmal <ahmad@baitalmal.com>",
51 "Brian Elliott Finley <brian@thefinleys.com>",
52 "Sean Robinson <seankrobinson@gmail.com>", "",
53 "Contributors", "Douglas Breault", "Nicolas Brouard",
54 "Jon Collette", "David Decotigny", "Simon Gerber",
55 "Joey Hurst", "Anari Jalakas", "Ante Karamatic",
56 "Richard Monk", "Kevin Otte", "Nathanael Rebsch",
57 "Andrea Scarpino", "Prokhor Shuchalov", "Patrick Winnertz"])
58 self
.set_comments("WiFi connection manager")
59 self
.set_copyright("Copyright 2004-2014 by various authors "
60 "and contributors\nCurrent Maintainer: "
61 "Sean Robinson <seankrobinson@gmail.com>")
62 self
.set_documenters(["Gary Case"])
64 This program is free software; you can redistribute it and/or modify
65 it under the terms of the GNU General Public License as published by
66 the Free Software Foundation; either version 2 of the License, or
67 (at your option) any later version.
69 This program is distributed in the hope that it will be useful,
70 but WITHOUT ANY WARRANTY; without even the implied warranty of
71 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72 GNU General Public License for more details.
74 You should have received a copy of the GNU General Public License
75 along with this program; if not, write to the Free Software
76 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"""
77 self
.set_license(license
)
78 self
.icon
= gtk
.gdk
.pixbuf_new_from_file("pixmaps/wifi-radar.png")
79 self
.set_logo(self
.icon
)
80 self
.set_name("WiFi Radar")
81 self
.set_version(misc
.WIFI_RADAR_VERSION
)
82 self
.set_website("http://wifi-radar.tuxfamily.org/")
85 class ErrorDialog(gtk
.MessageDialog
, object):
86 """ Simple dialog to report an error to the user.
88 def __init__(self
, parent
, message
):
89 """ Manage the complete life-cycle of an error message dialog.
91 gtk
.MessageDialog
.__init
__(self
, parent
,
92 gtk
.DIALOG_DESTROY_WITH_PARENT | gtk
.DIALOG_MODAL
,
93 gtk
.MESSAGE_ERROR
, gtk
.BUTTONS_OK
, message
)
98 class FileBrowseButton(gtk
.Button
, object):
99 """ Button to allow user to choose a file and put value into specified gtk.Entry.
101 def __init__(self
, parent
, entry
):
102 """ Create a button to simulate a File/Open.
104 gtk
.Button
.__init
__(self
, "Browse", None)
106 self
.browser_dialog
= gtk
.FileChooserDialog(None, parent
,
107 gtk
.FILE_CHOOSER_ACTION_OPEN
,
108 (gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
,
109 gtk
.STOCK_OPEN
, gtk
.RESPONSE_OK
), None)
110 self
.connect("clicked", self
.browse_files
)
112 def browse_files(self
, widget
=None):
113 """ Show a file chooser dialog, get the user selection, and update
114 the text entry value associated with the :class:`FileBrowseButton`.
115 :data:`widget` is the widget sending the signal, but it is
118 self
.browser_dialog
.set_filename(self
.entry
.get_text())
119 self
.browser_dialog
.run()
120 filename
= self
.browser_dialog
.get_filename()
122 self
.entry
.set_text(filename
)
123 self
.browser_dialog
.destroy()
126 class StatusWindow(gtk
.Dialog
, object):
127 """ A simple class for putting up a "Please wait" dialog so the user
128 doesn't think we've forgotten about them. Implements the status
129 interface. Status interface requires show(), update_message(message),
132 def __init__(self
, parent
):
133 """ Create a new StatusWindow under :data:`parent`, the ancestor
134 widget of the instance of :class:`StatusWindow`.
136 gtk
.Dialog
.__init
__(self
, "Working", parent
,
137 gtk
.DIALOG_MODAL | gtk
.DIALOG_DESTROY_WITH_PARENT
)
138 self
.icon
= gtk
.gdk
.pixbuf_new_from_file("pixmaps/wifi-radar.png")
139 self
.set_icon(self
.icon
)
140 self
.label
= gtk
.Label("Please wait...")
141 self
.bar
= gtk
.ProgressBar()
142 self
.vbox
.pack_start(self
.label
)
143 self
.vbox
.pack_start(self
.bar
)
144 self
.cancel_button
= self
.add_button(gtk
.STOCK_CANCEL
, gtk
.BUTTONS_CANCEL
)
147 def update_message(self
, message
):
148 """ Change the :data:`message` string displayed to the user.
150 self
.label
.set_text(message
)
152 def update_window(self
):
153 """ Update the :class:`StatusWindow` progress bar. Always return True
154 so a timer will reschedule this method.
160 """ Display and operate the StatusWindow.
165 """ Show all the widgets of the StatusWindow.
168 self
.timer
= gobject
.timeout_add(250, self
.update_window
)
172 """ Hide all the widgets of the StatusWindow.
175 gobject
.source_remove(self
.timer
)
181 """ Remove the StatusWindow.
184 gobject
.source_remove(self
.timer
)
187 # Make so we can be imported
188 if __name__
== "__main__":