diff --git a/wicd/gui.py b/wicd/gui.py index e792579..3971c42 100644 --- a/wicd/gui.py +++ b/wicd/gui.py @@ -141,10 +141,12 @@ class WiredProfileChooser: class appGui(object): """ The main wicd GUI class. """ - def __init__(self, standalone=False): + def __init__(self, standalone=False, tray=None): """ Initializes everything needed for the GUI. """ setup_dbus() + self.tray = tray + gladefile = os.path.join(wpath.share, "wicd.glade") self.wTree = gtk.glade.XML(gladefile) self.window = self.wTree.get_widget("window1") @@ -305,7 +307,7 @@ class appGui(object): def settings_dialog(self, widget, event=None): """ Displays a general settings dialog. """ if not self.pref: - self.pref = PreferencesDialog(self.wTree) + self.pref = PreferencesDialog(self, self.wTree) else: self.pref.load_preferences_diag() if self.pref.run() == 1: diff --git a/wicd/prefs.py b/wicd/prefs.py index abfa6b0..0066a1b 100644 --- a/wicd/prefs.py +++ b/wicd/prefs.py @@ -51,8 +51,9 @@ def setup_dbus(): class PreferencesDialog(object): """ Class for handling the wicd preferences dialog window. """ - def __init__(self, wTree): + def __init__(self, parent, wTree): setup_dbus() + self.parent = parent self.wTree = wTree self.prep_settings_diag() self.load_preferences_diag() @@ -243,7 +244,11 @@ class PreferencesDialog(object): else: if os.path.exists(not_path): os.remove(not_path) - + # if this GUI was started by a tray icon, + # instantly change the notifications there + if self.parent.tray: + self.parent.tray.icon_info.use_notify = \ + self.notificationscheckbox.get_active() def set_label(self, glade_str, label): """ Sets the label for the given widget in wicd.glade. """ diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index da3b173..4399ca2 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -53,9 +53,6 @@ try: except ImportError: HAS_NOTIFY = False -USE_NOTIFY = os.path.exists(os.path.join(os.path.expanduser('~/.wicd'), - 'USE_NOTIFICATIONS')) - # Wicd specific imports from wicd import wpath from wicd import misc @@ -130,6 +127,7 @@ class TrayIcon(object): else: self.tr = self.StatusTrayIconGUI() self.icon_info = self.TrayConnectionInfo(self.tr, animate) + self.tr.icon_info = self.icon_info def is_embedded(self): if USE_EGG: @@ -160,6 +158,10 @@ class TrayIcon(object): self.last_state = None self.should_notify = True + self.use_notify = os.path.exists(os.path.join( + os.path.expanduser('~/.wicd'), + 'USE_NOTIFICATIONS')) + if DBUS_AVAIL: self.update_tray_icon() else: @@ -250,7 +252,8 @@ class TrayIcon(object): if not state or not info: [state, info] = daemon.GetConnectionStatus() - self.should_notify = (self.last_state != state) and HAS_NOTIFY and USE_NOTIFY + self.should_notify = (self.last_state != state) and \ + HAS_NOTIFY and self.use_notify self.last_state = state @@ -599,7 +602,7 @@ class TrayIcon(object): def toggle_wicd_gui(self): """ Toggles the wicd GUI. """ if not self.gui_win: - self.gui_win = gui.appGui() + self.gui_win = gui.appGui(tray=self) elif not self.gui_win.is_visible: self.gui_win.show_win() else: