2 # -*- coding: utf-8 -*-
4 # gui/g2/__init__.py - collection of classes for main UI with PyGTK
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
44 from wifiradar
.config
import make_section_name
45 import wifiradar
.connections
as connections
46 from wifiradar
.misc
import _
, PipeError
, get_new_profile
47 from wifiradar
.pubsub
import Message
49 from . import profile
as profile_ed
50 from . import transients
53 logger
= logging
.getLogger(__name__
)
56 # Create a bunch of icons from files in the package.
57 known_profile_icon
= gtk
.gdk
.pixbuf_new_from_file('pixmaps/known_profile.png')
58 unknown_profile_icon
= gtk
.gdk
.pixbuf_new_from_file('pixmaps/unknown_profile.png')
59 signal_none_pb
= gtk
.gdk
.pixbuf_new_from_file('pixmaps/signal_none.xpm')
60 signal_low_pb
= gtk
.gdk
.pixbuf_new_from_file('pixmaps/signal_low.xpm')
61 signal_barely_pb
= gtk
.gdk
.pixbuf_new_from_file('pixmaps/signal_barely.xpm')
62 signal_ok_pb
= gtk
.gdk
.pixbuf_new_from_file('pixmaps/signal_ok.xpm')
63 signal_best_pb
= gtk
.gdk
.pixbuf_new_from_file('pixmaps/signal_best.xpm')
65 def pixbuf_from_known(known
):
66 """ Return a :class:`gtk.gdk.Pixbuf` icon to represent :data:`known`.
67 Any true :data:`known` value returns the icon showing previous
71 return known_profile_icon
72 return unknown_profile_icon
74 def pixbuf_from_signal(signal
):
75 """ Return a :class:`gtk.gdk.Pixbuf` icon to indicate the :data:`signal`
76 level. :data:`signal` is as reported by iwlist (may be arbitrary
77 scale in 0-100 or -X dBm)
80 # Shift signal up by 80 to convert dBm scale to arbitrary scale.
89 return signal_barely_pb
96 """ Function to boot-strap the UI. :data:`ui_pipe` is one half of a
97 :class:`multiprocessing.Pipe` which will be given to the main UI
98 element for intra-app communication.
100 gtk
.gdk
.threads_init()
101 ui
= RadarWindow(ui_pipe
)
107 class RadarWindow(gtk
.Dialog
, object):
108 def __init__(self
, msg_pipe
):
109 """ Create a new RadarWindow wanting to communicate through
110 :data:`msg_pipe`, a :class:`multiprocessing.Connection`.
112 gtk
.Dialog
.__init
__(self
, 'WiFi Radar', None, gtk
.DIALOG_MODAL
)
113 self
.msg_pipe
= msg_pipe
115 self
.icon
= gtk
.gdk
.pixbuf_new_from_file('pixmaps/wifi-radar.png')
117 self
.set_icon(self
.icon
)
118 self
.set_border_width(10)
119 self
.set_size_request(550, 300)
120 self
.connect('delete_event', self
.delete_event
)
121 # let's create all our widgets
122 self
.current_network
= gtk
.Label()
123 self
.current_network
.set_property('justify', gtk
.JUSTIFY_CENTER
)
124 self
.current_network
.show()
125 self
.close_button
= gtk
.Button(_('Close'), gtk
.STOCK_CLOSE
)
126 self
.close_button
.show()
127 self
.close_button
.connect('clicked', self
.delete_event
, None)
128 self
.about_button
= gtk
.Button(_('About'), gtk
.STOCK_ABOUT
)
129 self
.about_button
.show()
130 self
.about_button
.connect('clicked', self
.show_about_info
, None)
131 self
.preferences_button
= gtk
.Button(_('Preferences'), gtk
.STOCK_PREFERENCES
)
132 self
.preferences_button
.show()
133 self
.preferences_button
.connect('clicked', self
.request_preferences_edit
)
134 # essid bssid known_icon known available wep_icon signal_level mode protocol channel
135 self
.pstore
= gtk
.ListStore(str, str, gtk
.gdk
.Pixbuf
, bool, bool, str, gtk
.gdk
.Pixbuf
, str, str, str)
136 self
.plist
= gtk
.TreeView(self
.pstore
)
137 # The icons column, known and encryption
138 self
.pix_cell
= gtk
.CellRendererPixbuf()
139 self
.wep_cell
= gtk
.CellRendererPixbuf()
140 self
.icons_cell
= gtk
.CellRendererText()
141 self
.icons_col
= gtk
.TreeViewColumn()
142 self
.icons_col
.pack_start(self
.pix_cell
, False)
143 self
.icons_col
.pack_start(self
.wep_cell
, False)
144 self
.icons_col
.add_attribute(self
.pix_cell
, 'pixbuf', 2)
145 self
.icons_col
.add_attribute(self
.wep_cell
, 'stock-id', 5)
146 self
.plist
.append_column(self
.icons_col
)
148 self
.ap_cell
= gtk
.CellRendererText()
149 self
.ap_col
= gtk
.TreeViewColumn(_('Access Point'))
150 self
.ap_col
.pack_start(self
.ap_cell
, True)
151 self
.ap_col
.set_cell_data_func(self
.ap_cell
, self
._set
_ap
_col
_value
)
152 self
.plist
.append_column(self
.ap_col
)
154 self
.sig_cell
= gtk
.CellRendererPixbuf()
155 self
.signal_col
= gtk
.TreeViewColumn(_('Signal'))
156 self
.signal_col
.pack_start(self
.sig_cell
, True)
157 self
.signal_col
.add_attribute(self
.sig_cell
, 'pixbuf', 6)
158 self
.plist
.append_column(self
.signal_col
)
160 self
.mode_cell
= gtk
.CellRendererText()
161 self
.mode_col
= gtk
.TreeViewColumn(_('Mode'))
162 self
.mode_col
.pack_start(self
.mode_cell
, True)
163 self
.mode_col
.add_attribute(self
.mode_cell
, 'text', 7)
164 self
.plist
.append_column(self
.mode_col
)
165 # The protocol column
166 self
.prot_cell
= gtk
.CellRendererText()
167 self
.protocol_col
= gtk
.TreeViewColumn('802.11')
168 self
.protocol_col
.pack_start(self
.prot_cell
, True)
169 self
.protocol_col
.add_attribute(self
.prot_cell
, 'text', 8)
170 self
.plist
.append_column(self
.protocol_col
)
172 self
.channel_cell
= gtk
.CellRendererText()
173 self
.channel_col
= gtk
.TreeViewColumn(_('Channel'))
174 self
.channel_col
.pack_start(self
.channel_cell
, True)
175 self
.channel_col
.add_attribute(self
.channel_cell
, 'text', 9)
176 self
.plist
.append_column(self
.channel_col
)
178 self
.plist
.set_reorderable(True)
179 # detect d-n-d of AP in round-about way, since rows-reordered does not work as advertised
180 self
.pstore
.connect('row-deleted', self
.update_auto_profile_order
)
181 # enable/disable buttons based on the selected network
182 self
.selected_network
= self
.plist
.get_selection()
183 self
.selected_network
.connect('changed', self
.on_network_selection
, None)
184 # the list scroll bar
185 sb
= gtk
.ScrolledWindow()
186 sb
.set_policy(gtk
.POLICY_AUTOMATIC
, gtk
.POLICY_AUTOMATIC
)
189 self
.new_button
= gtk
.Button(_('_New'))
190 self
.new_button
.connect('clicked', self
.create_new_profile
)
191 self
.new_button
.show()
192 # Add Configure button
193 self
.edit_button
= gtk
.Button(_('C_onfigure'))
194 self
.edit_button
.connect('clicked', self
.request_profile_edit
)
195 self
.edit_button
.show()
196 self
.edit_button
.set_sensitive(False)
198 self
.delete_button
= gtk
.Button(_('_Delete'))
199 self
.delete_button
.connect('clicked', self
.request_profile_delete
)
200 self
.delete_button
.show()
201 self
.delete_button
.set_sensitive(False)
203 self
.connect_button
= gtk
.Button(_('Co_nnect'))
204 self
.connect_button
.connect('clicked', self
.connect_profile
, None)
205 # Add Disconnect button
206 self
.disconnect_button
= gtk
.Button(_('D_isconnect'))
207 self
.disconnect_button
.connect('clicked', self
.disconnect_profile
, None)
208 # lets add our widgets
209 rows
= gtk
.VBox(False, 3)
210 net_list
= gtk
.HBox(False, 0)
211 listcols
= gtk
.HBox(False, 0)
212 prows
= gtk
.VBox(False, 0)
215 net_list
.pack_start(sb
, True, True, 0)
218 rows
.pack_start(net_list
, True, True, 0)
219 rows
.pack_start(self
.current_network
, False, True, 0)
221 listcols
.pack_start(rows
, True, True, 0)
222 listcols
.pack_start(prows
, False, False, 5)
224 prows
.pack_start(self
.new_button
, False, False, 2)
225 prows
.pack_start(self
.edit_button
, False, False, 2)
226 prows
.pack_start(self
.delete_button
, False, False, 2)
227 prows
.pack_end(self
.connect_button
, False, False, 2)
228 prows
.pack_end(self
.disconnect_button
, False, False, 2)
230 self
.action_area
.pack_start(self
.about_button
)
231 self
.action_area
.pack_start(self
.preferences_button
)
232 self
.action_area
.pack_start(self
.close_button
)
237 self
.vbox
.add(listcols
)
238 self
.vbox
.set_spacing(3)
241 # Now, immediately hide these two. The proper one will be
242 # displayed later, based on interface state. -BEF-
243 self
.disconnect_button
.hide()
244 self
.connect_button
.hide()
245 self
.connect_button
.set_sensitive(False)
247 # set up status window for later use
248 self
.status_window
= transients
.StatusWindow(self
)
249 self
.status_window
.cancel_button
.connect('clicked', self
.disconnect_profile
, 'cancel')
252 # Check for incoming messages every 25 ms, a.k.a. 40 Hz.
253 glib
.timeout_add(25, self
.run
)
256 """ Watch for incoming messages.
258 if self
.msg_pipe
.poll():
260 msg
= self
.msg_pipe
.recv()
261 except (EOFError, IOError) as e
:
262 # This is bad, really bad.
263 logger
.critical(_('read on closed Pipe ({PIPE}), '
264 'failing...').format(PIPE
=self
.msg_pipe
))
267 self
._check
_message
(msg
)
268 # Update the UI before returning.
269 self
.update_network_info()
270 self
.update_connect_buttons()
273 def _check_message(self
, msg
):
274 """ Process incoming messages.
276 if msg
.topic
== 'EXIT':
278 elif msg
.topic
== 'CONFIG-UPDATE':
279 # Replace configuration manager with the one in msg.details.
280 self
.config
= msg
.details
281 elif msg
.topic
== 'PROFILE-EDIT':
283 self
.edit_profile(msg
.details
)
284 elif msg
.topic
== 'PROFILE-UPDATE':
286 self
.update_profile(msg
.details
)
287 elif msg
.topic
== 'PROFILE-UNLIST':
289 self
.delete_profile(msg
.details
)
290 elif msg
.topic
== 'PROFILE-MOVE':
291 new_position
, profile
= msg
.details
293 if profile
['roaming']:
294 old_position
= self
.get_row_by_ap(profile
['essid'])
296 old_position
= self
.get_row_by_ap(profile
['essid'],
298 self
.pstore
.move_before(old_position
, self
.pstore
[new_position
].iter)
299 elif msg
.topic
== 'PREFS-EDIT':
301 self
.edit_preferences(msg
.details
)
302 elif msg
.topic
== 'ERROR':
304 transients
.ErrorDialog(self
, msg
.details
)
306 logger
.warning(_('unrecognized Message: "{MSG}"').format(MSG
=msg
))
308 def destroy(self
, widget
=None):
309 """ Quit the Gtk event loop. :data:`widget` is the widget
310 sending the signal, but it is ignored.
312 if self
.status_window
:
313 self
.status_window
.destroy()
316 def delete_event(self
, widget
=None, data
=None):
317 """ Shutdown the application. :data:`widget` is the widget sending
318 the signal and :data:`data` is a list of arbitrary arguments,
319 both are ignored. Always returns False to not propigate the
320 signal which called :func:`delete_event`.
322 self
._running
= False
323 self
.msg_pipe
.send(Message('EXIT', ''))
324 self
.msg_pipe
.close()
326 # process GTK events so that window hides more quickly
327 if sys
.modules
.has_key('gtk'):
328 while gtk
.events_pending():
329 gtk
.main_iteration(False)
333 def update_network_info(self
, profile
=None, ip
=None):
334 """ Update the current ip and essid shown to the user.
336 if (profile
is None) and (ip
is None):
337 self
.current_network
.set_text(_('Not Connected.'))
339 self
.current_network
.set_text(_('Connected to {PROFILE}\n'
340 'IP Address {IP}').format(PROFILE
=profile
, IP
=ip
))
342 def update_connect_buttons(self
, connected
=False):
343 """ Set the state of connect/disconnect buttons to reflect the
344 current connected state.
347 self
.connect_button
.hide()
348 self
.disconnect_button
.show()
350 self
.disconnect_button
.hide()
351 self
.connect_button
.show()
353 def _set_ap_col_value(self
, column
, cell
, model
, iter):
354 """ Set the text attribute of :data:`column` to the first two
355 :data:`model` values joined by a newline. This is for
356 displaying the :data:`essid` and :data:`bssid` in a single
359 essid
= model
.get_value(iter, 0)
360 bssid
= model
.get_value(iter, 1)
361 cell
.set_property('text', '\n'.join([essid
, bssid
]))
363 def get_row_by_ap(self
, essid
, bssid
=_(' Multiple APs')):
364 """ Returns a :class:`gtk.TreeIter` for the row which holds
365 :data:`essid` and :data:`bssid`.
367 :data:`bssid` is optional. If not given, :func:`get_row_by_ap`
368 will try to match a roaming profile with the given :data:`essid`.
370 If no match is found, it returns None.
372 for row
in self
.pstore
:
373 if (row
[0] == essid
) and (row
[1] == bssid
):
377 def on_network_selection(self
, widget
=None, data
=None):
378 """ Enable/disable buttons based on the selected network.
379 :data:`widget` is the widget sending the signal and :data:`data`
380 is a list of arbitrary arguments, both are ignored.
382 store
, selected_iter
= self
.selected_network
.get_selected()
383 if selected_iter
is None:
384 # No row is selected, disable all buttons except New.
385 # This occurs after a drag-and-drop.
386 self
.edit_button
.set_sensitive(False)
387 self
.delete_button
.set_sensitive(False)
388 self
.connect_button
.set_sensitive(False)
390 # One row is selected, so enable or disable buttons.
391 self
.connect_button
.set_sensitive(True)
392 if store
.get_value(selected_iter
, 3):
394 self
.edit_button
.set_sensitive(True)
395 self
.delete_button
.set_sensitive(True)
398 self
.edit_button
.set_sensitive(True)
399 self
.delete_button
.set_sensitive(False)
401 def show_about_info(self
, widget
=None, data
=None):
402 """ Handle the life-cycle of the About dialog. :data:`widget` is
403 the widget sending the signal and :data:`data` is a list of
404 arbitrary arguments, both are ignored.
406 about
= transients
.AboutDialog()
410 def request_preferences_edit(self
, widget
=None, data
=None):
411 """ Respond to a request to edit the application preferences.
412 :data:`widget` is the widget sending the signal and :data:`data`
413 is a list of arbitrary arguments, both are ignored.
415 self
.msg_pipe
.send(Message('PREFS-EDIT-REQUEST', ''))
417 def edit_preferences(self
, config
):
418 """ Allow the user to edit :data:`config`.
420 prefs_editor
= prefs
.PreferencesEditor(self
, config
)
421 response
, config_copy
= prefs_editor
.run()
422 if response
== gtk
.RESPONSE_APPLY
:
423 self
.msg_pipe
.send(Message('PREFS-UPDATE', config_copy
))
424 prefs_editor
.destroy()
426 def update_profile(self
, profile
):
427 """ Updates the display of :data:`profile`.
429 if profile
['roaming']:
430 prow_iter
= self
.get_row_by_ap(profile
['essid'])
432 prow_iter
= self
.get_row_by_ap(profile
['essid'], profile
['bssid'])
434 if prow_iter
is None:
435 # the AP is not in the list of APs on the screen
436 self
._add
_profile
(profile
)
438 # the AP is in the list of APs on the screen
439 self
._update
_row
(profile
, prow_iter
)
441 def _add_profile(self
, profile
):
442 """ Add :data:`profile` to the list of APs shown to the user.
444 if profile
['roaming']:
445 profile
['bssid'] = _(' Multiple APs')
448 if profile
['encrypted']:
449 wep
= gtk
.STOCK_DIALOG_AUTHENTICATION
451 self
.pstore
.append([profile
['essid'], profile
['bssid'],
452 known_profile_icon
, profile
['known'], profile
['available'],
453 wep
, signal_none_pb
, profile
['mode'], profile
['protocol'],
456 def _update_row(self
, profile
, row_iter
):
457 """ Change the values displayed in :data:`row_iter` (a
458 :class:`gtk.TreeIter`) using :data:`profile`.
461 if profile
['encrypted']:
462 wep
= gtk
.STOCK_DIALOG_AUTHENTICATION
463 # Update the Gtk objects.
464 self
.pstore
.set_value(row_iter
, 2, pixbuf_from_known(profile
['known']))
465 self
.pstore
.set_value(row_iter
, 3, profile
['known'])
466 self
.pstore
.set_value(row_iter
, 4, profile
['available'])
467 self
.pstore
.set_value(row_iter
, 5, wep
)
468 self
.pstore
.set_value(row_iter
, 6, pixbuf_from_signal(profile
['signal']))
469 self
.pstore
.set_value(row_iter
, 7, profile
['mode'])
470 self
.pstore
.set_value(row_iter
, 8, profile
['protocol'])
471 self
.pstore
.set_value(row_iter
, 9, profile
['channel'])
473 def create_new_profile(self
, widget
=None, profile
=None, data
=None):
474 """ Respond to a user request to create a new AP profile.
475 :data:`widget` is the widget sending the signal. :data:profile`
476 is an AP profile to use as the basis for the new profile. It
477 is likely empty or mostly empty. :data:`data` is a list of
478 arbitrary arguments. :data:`widget` and "data"`data` are both
481 The order of parameters is important. Because when this method
482 is called from a signal handler, :data:`widget` is always the
486 profile
= get_new_profile()
488 profile_editor
= profile_ed
.ProfileEditor(self
, profile
)
490 edited_profile
= profile_editor
.run()
492 self
.msg_pipe
.send(Message('ERROR', _('Cannot save empty ESSID')))
495 self
.msg_pipe
.send(Message('PROFILE-EDITED', (edited_profile
, profile
)))
497 profile_editor
.destroy()
499 def request_profile_edit(self
, widget
=None, data
=None):
500 """ Respond to a request to edit an AP profile. :data:`widget`
501 is the widget sending the signal and :data:`data` is a list
502 of arbitrary arguments, both are ignored.
504 store
, selected_iter
= self
.plist
.get_selection().get_selected()
505 if selected_iter
is not None:
506 essid
= self
.pstore
.get_value(selected_iter
, 0)
507 bssid
= self
.pstore
.get_value(selected_iter
, 1)
508 if bssid
== _(' Multiple APs'):
509 # AP list says this is a roaming profile
511 self
.msg_pipe
.send(Message('PROFILE-EDIT-REQUEST', (essid
, bssid
)))
513 def edit_profile(self
, profile
):
514 """ Allow the user to edit :data:`profile`.
516 profile_editor
= profile_ed
.ProfileEditor(self
, profile
)
517 edited_profile
= profile_editor
.run()
518 profile_editor
.destroy()
520 if edited_profile
is not None:
521 # Replace old profile.
522 self
.msg_pipe
.send(Message('PROFILE-EDITED',
523 (edited_profile
, profile
)))
525 def request_profile_delete(self
, widget
=None, data
=None):
526 """ Respond to a request to delete an AP profile (i.e. make the
527 profile unknown). Trying to delete an AP which is not configured
528 is a NOOP. Check with the user before deleting the profile.
529 :data:`widget` is the widget sending the signal and :data:`data`
530 is a list of arbitrary arguments, both are ignored.
532 store
, selected_iter
= self
.plist
.get_selection().get_selected()
533 if selected_iter
is not None:
534 if store
.get_value(selected_iter
, 3):
535 # The selected AP is configured (a.k.a. 'known').
536 essid
= self
.pstore
.get_value(selected_iter
, 0)
537 bssid
= self
.pstore
.get_value(selected_iter
, 1)
538 if bssid
== _(' Multiple APs'):
539 # AP list says this is a roaming profile
543 profile_name
= '{ESSID} ({BSSID})'.format(ESSID
=essid
,
546 dialog
= gtk
.MessageDialog(self
,
547 gtk
.DIALOG_DESTROY_WITH_PARENT | gtk
.DIALOG_MODAL
,
548 gtk
.MESSAGE_QUESTION
, gtk
.BUTTONS_YES_NO
,
549 _('Are you sure you want to delete the '
550 '{NAME} profile?').format(NAME
=profile_name
))
552 result
= dialog
.run()
556 if result
== gtk
.RESPONSE_YES
:
557 apname
= make_section_name(essid
, bssid
)
558 self
.msg_pipe
.send(Message('PROFILE-REMOVE', apname
))
560 def delete_profile(self
, profile
):
561 """ Remove :data:`profile` from the list of APs shown to the user.
563 if profile
['roaming']:
564 prow_iter
= self
.get_row_by_ap(profile
['essid'])
566 prow_iter
= self
.get_row_by_ap(profile
['essid'], profile
['bssid'])
567 if prow_iter
is not None:
568 self
.pstore
.remove(prow_iter
)
570 def connect_profile(self
, widget
, profile
, data
=None):
571 """ Respond to a request to connect to an AP.
575 'widget' -- gtk.Widget - The widget sending the event.
577 'profile' -- dictionary - The AP profile to which to connect.
579 'data' -- tuple - list of arbitrary arguments (not used)
585 store
, selected_iter
= self
.plist
.get_selection().get_selected()
586 if selected_iter
is None:
588 essid
= self
.pstore
.get_value(selected_iter
, 0)
589 bssid
= self
.pstore
.get_value(selected_iter
, 1)
590 known
= store
.get_value(selected_iter
, 3)
592 dlg
= gtk
.MessageDialog(self
,
593 gtk
.DIALOG_DESTROY_WITH_PARENT | gtk
.DIALOG_MODAL
,
594 gtk
.MESSAGE_QUESTION
, gtk
.BUTTONS_YES_NO
,
595 _('This network does not have a profile configured.\n\n'
596 'Would you like to create one now?'))
600 if res
== gtk
.RESPONSE_NO
:
602 profile
= get_new_profile()
603 profile
['essid'] = essid
604 profile
['bssid'] = bssid
605 if not self
.create_new_profile(widget
, profile
, data
):
608 # Check for roaming profile.
609 ap_name
= make_section_name(essid
, '')
610 profile
= self
.config
.get_profile(ap_name
)
612 # Check for normal profile.
613 ap_name
= make_section_name(essid
, bssid
)
614 profile
= self
.config
.get_profile(ap_name
)
616 # No configured profile
618 profile
['bssid'] = self
.access_points
[ap_name
]['bssid']
619 profile
['channel'] = self
.access_points
[ap_name
]['channel']
620 self
.msg_pipe
.send(Message('CONNECT', profile
))
622 def disconnect_profile(self
, widget
=None, data
=None):
623 """ Respond to a request to disconnect by sending a message to
624 ConnectionManager. :data:`widget` is the widget sending the
625 signal and :data:`data` is a list of arbitrary arguments, both
628 self
.msg_pipe
.send(Message('DISCONNECT', ''))
630 self
.status_window
.update_message(_('Canceling connection...'))
631 if sys
.modules
.has_key('gtk'):
632 while gtk
.events_pending():
633 gtk
.main_iteration(False)
635 def profile_order_updater(self
, model
, path
, iter, auto_profile_order
):
638 if model
.get_value(iter, 3) is True:
639 essid
= self
.pstore
.get_value(iter, 0)
640 bssid
= self
.pstore
.get_value(iter, 1)
641 if bssid
== _(' Multiple APs'):
643 apname
= make_section_name(essid
, bssid
)
644 auto_profile_order
.append(apname
)
646 def update_auto_profile_order(self
, widget
=None, data
=None, data2
=None):
647 """ Update the config file auto profile order from the on-screen
648 order. :data:`widget` is the widget sending the signal and
649 :data:`data` and :data:`data2` is a list of arbitrary arguments,
652 # recreate the auto_profile_order
653 auto_profile_order
= []
654 self
.pstore
.foreach(self
.profile_order_updater
, auto_profile_order
)
655 self
.msg_pipe
.send(Message('PROFILE-ORDER-UPDATE', auto_profile_order
))
658 # Make so we can be imported
659 if __name__
== '__main__':