370
377
self.gui_win.exit()
374
class EggTrayIconGUI(TrayIconGUI):
375
""" Tray Icon for gtk < 2.10.
377
Uses the deprecated egg.trayicon module to implement the tray icon.
378
Since it relies on a deprecated module, this class is only used
379
for machines running versions of GTK < 2.10.
382
def __init__(self, use_tray=True):
383
"""Initializes the tray icon"""
384
TrayIcon.TrayIconGUI.__init__(self, use_tray)
385
self.use_tray = use_tray
387
self.toggle_wicd_gui()
390
self.tooltip = gtk.Tooltips()
391
self.eb = gtk.EventBox()
392
self.tray = egg.trayicon.TrayIcon("WicdTrayIcon")
393
self.pic = gtk.Image()
394
self.tooltip.set_tip(self.eb, "Initializing wicd...")
395
self.pic.set_from_file("images/no-signal.png")
397
self.eb.connect('button_press_event', self.tray_clicked)
398
self.eb.add(self.pic)
399
self.tray.add(self.eb)
402
def tray_clicked(self, widget, event):
403
""" Handles tray mouse click events. """
404
if event.button == 1:
405
self.toggle_wicd_gui()
406
elif event.button == 3:
407
self.menu.popup(None, None, None, event.button, event.time)
409
def set_from_file(self, val=None):
410
""" Calls set_from_file on the gtk.Image for the tray icon. """
411
if not self.use_tray: return
412
self.pic.set_from_file(val)
414
def set_tooltip(self, val):
415
""" Set the tooltip for this tray icon.
417
Sets the tooltip for the gtk.ToolTips associated with this
421
if not self.use_tray: return
422
self.tooltip.set_tip(self.eb, val)
425
class StatusTrayIconGUI(gtk.StatusIcon, TrayIconGUI):
426
""" Class for creating the wicd tray icon on gtk > 2.10.
428
Uses gtk.StatusIcon to implement a tray icon.
431
def __init__(self, use_tray=True):
432
TrayIcon.TrayIconGUI.__init__(self, use_tray)
433
self.use_tray = use_tray
435
self.toggle_wicd_gui()
438
gtk.StatusIcon.__init__(self)
440
self.current_icon_path = ''
441
self.set_visible(True)
442
self.connect('activate', self.on_activate)
443
self.connect('popup-menu', self.on_popup_menu)
444
self.set_from_file(wpath.images + "no-signal.png")
445
self.set_tooltip("Initializing wicd...")
447
def on_popup_menu(self, status, button, timestamp):
448
""" Opens the right click menu for the tray icon. """
449
self.menu.popup(None, None, None, button, timestamp)
451
def set_from_file(self, path = None):
452
""" Sets a new tray icon picture. """
453
if not self.use_tray: return
454
if path != self.current_icon_path:
455
self.current_icon_path = path
456
gtk.StatusIcon.set_from_file(self, path)
381
class EggTrayIconGUI(TrayIconGUI):
382
""" Tray Icon for gtk < 2.10.
384
Uses the deprecated egg.trayicon module to implement the tray icon.
385
Since it relies on a deprecated module, this class is only used
386
for machines running versions of GTK < 2.10.
389
def __init__(self, use_tray=True):
390
"""Initializes the tray icon"""
391
TrayIcon.TrayIconGUI.__init__(self, use_tray)
392
self.use_tray = use_tray
394
self.toggle_wicd_gui()
397
self.tooltip = gtk.Tooltips()
398
self.eb = gtk.EventBox()
399
self.tray = egg.trayicon.TrayIcon("WicdTrayIcon")
400
self.pic = gtk.Image()
401
self.tooltip.set_tip(self.eb, "Initializing wicd...")
402
self.pic.set_from_file("images/no-signal.png")
404
self.eb.connect('button_press_event', self.tray_clicked)
405
self.eb.add(self.pic)
406
self.tray.add(self.eb)
409
def tray_clicked(self, widget, event):
410
""" Handles tray mouse click events. """
411
if event.button == 1:
412
self.toggle_wicd_gui()
413
elif event.button == 3:
414
self.menu.popup(None, None, None, event.button, event.time)
416
def set_from_file(self, val=None):
417
""" Calls set_from_file on the gtk.Image for the tray icon. """
418
if not self.use_tray: return
419
self.pic.set_from_file(val)
421
def set_tooltip(self, val):
422
""" Set the tooltip for this tray icon.
424
Sets the tooltip for the gtk.ToolTips associated with this
428
if not self.use_tray: return
429
self.tooltip.set_tip(self.eb, val)
431
if hasattr(gtk, "StatusIcon"):
432
class StatusTrayIconGUI(gtk.StatusIcon, TrayIconGUI):
433
""" Class for creating the wicd tray icon on gtk > 2.10.
435
Uses gtk.StatusIcon to implement a tray icon.
438
def __init__(self, use_tray=True):
439
TrayIcon.TrayIconGUI.__init__(self, use_tray)
440
self.use_tray = use_tray
442
self.toggle_wicd_gui()
445
gtk.StatusIcon.__init__(self)
447
self.current_icon_path = ''
448
self.set_visible(True)
449
self.connect('activate', self.on_activate)
450
self.connect('popup-menu', self.on_popup_menu)
451
self.set_from_file(wpath.images + "no-signal.png")
452
self.set_tooltip("Initializing wicd...")
454
def on_popup_menu(self, status, button, timestamp):
455
""" Opens the right click menu for the tray icon. """
456
self.menu.popup(None, None, None, button, timestamp)
458
def set_from_file(self, path = None):
459
""" Sets a new tray icon picture. """
460
if not self.use_tray: return
461
if path != self.current_icon_path:
462
self.current_icon_path = path
463
gtk.StatusIcon.set_from_file(self, path)
460
468
""" Print usage information. """
463
471
wireless (and wired) connection daemon front-end.