From e28dcb4337d38401e0c4a86d6867ed5c795a94ae Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Fri, 1 May 2009 13:46:21 +0800 Subject: [PATCH 01/15] Initial notification support --- wicd/wicd-client.py | 60 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index 0c34f7e..d7d0b2e 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -43,6 +43,17 @@ import pango import atexit from dbus import DBusException +HAS_NOTIFY = True +try: + import pygtk + pygtk.require('2.0') + import pynotify + if not pynotify.init("Wicd"): + HAS_NOTIFY = False +except ImportError: + HAS_NOTIFY = False + + # Wicd specific imports from wicd import wpath from wicd import misc @@ -63,6 +74,8 @@ if not hasattr(gtk, "StatusIcon"): print 'Unable to load tray icon: Missing both egg.trayicon and gtk.StatusIcon modules.' ICON_AVAIL = False +print "Has notifications support", HAS_NOTIFY + misc.RenameProcess("wicd-client") if __name__ == '__main__': @@ -118,7 +131,7 @@ class TrayIcon(object): def is_embedded(self): if USE_EGG: - raise NotImplementedError + raise NotImplementedError() else: return self.tr.is_embedded() @@ -138,12 +151,30 @@ class TrayIcon(object): self.max_snd_gain = 10000 self.max_rcv_gain = 10000 self.animate = animate + + # keep track of the last state to provide appropriate + # notifications + self._last_bubble = None + self.last_state = None + self.should_notify = True + if DBUS_AVAIL: self.update_tray_icon() else: handle_no_dbus() self.set_not_connected_state() + def _show_notification(self, status_string): + if self.should_notify: + if not self._last_bubble: + self._last_bubble = pynotify.Notification("Network status", status_string) + self._last_bubble.show() + else: + self._last_bubble.update("Network status", status_string) + self._last_bubble.show() + + self.should_notify = False + @catchdbus def wired_profile_chooser(self): """ Launch the wired profile chooser. """ @@ -154,8 +185,10 @@ class TrayIcon(object): """ Sets the icon info for a wired state. """ wired_ip = info[0] self.tr.set_from_file(os.path.join(wpath.images, "wired.png")) - self.tr.set_tooltip(language['connected_to_wired'].replace('$A', - wired_ip)) + status_string = language['connected_to_wired'].replace('$A', + wired_ip) + self.tr.set_tooltip(status_string) + self._show_notification(status_string) @catchdbus def set_wireless_state(self, info): @@ -169,12 +202,14 @@ class TrayIcon(object): if wireless.GetWirelessProperty(cur_net_id, "encryption"): lock = "-lock" - - self.tr.set_tooltip(language['connected_to_wireless'] + status_string = (language['connected_to_wireless'] .replace('$A', self.network) .replace('$B', sig_string) - .replace('$C', str(wireless_ip))) + .replace('$C', str(wireless_ip))) + self.tr.set_tooltip(status_string) self.set_signal_image(int(strength), lock) + self._show_notification(status_string) + def set_connecting_state(self, info): """ Sets the icon info for a connecting state. """ @@ -182,9 +217,11 @@ class TrayIcon(object): cur_network = language['wired_network'] else: cur_network = info[1] - self.tr.set_tooltip(language['connecting'] + " to " + - cur_network + "...") + status_string = language['connecting'] + " to " + \ + cur_network + "..." + self.tr.set_tooltip(status_string) self.tr.set_from_file(os.path.join(wpath.images, "no-signal.png")) + self._show_notification(status_string) @catchdbus def set_not_connected_state(self, info=None): @@ -198,6 +235,7 @@ class TrayIcon(object): else: status = language['not_connected'] self.tr.set_tooltip(status) + self._show_notification(status) @catchdbus def update_tray_icon(self, state=None, info=None): @@ -206,6 +244,12 @@ class TrayIcon(object): if not state or not info: [state, info] = daemon.GetConnectionStatus() + + self._show_notification('hello!') + + self.should_notify = (self.last_state != state) and HAS_NOTIFY + + self.last_state = state if state == misc.WIRED: self.set_wired_state(info) From 7aa0027c3949a27c2d32657671b28d960f5de591 Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Fri, 1 May 2009 14:32:09 +0800 Subject: [PATCH 02/15] added support for enabling/disabling notifications --- data/wicd.glade | 273 +++++++++++++++++++++++++++----------------- wicd/prefs.py | 19 +++ wicd/wicd-client.py | 6 +- 3 files changed, 191 insertions(+), 107 deletions(-) diff --git a/data/wicd.glade b/data/wicd.glade index 0fe8d7a..9d39ce3 100644 --- a/data/wicd.glade +++ b/data/wicd.glade @@ -1,25 +1,23 @@ - - - + + + 450 400 True Wicd Network Manager - GTK_WIN_POS_CENTER + center 550 - GDK_GRAVITY_CENTER - - + center True True - GTK_TOOLBAR_BOTH_HORIZ - GTK_ICON_SIZE_MENU + both-horiz + 0 True @@ -31,8 +29,8 @@ True + gtk-network True - gtk-network True True @@ -40,31 +38,21 @@ True + Create an ad-hoc network True - Create an ad-hoc network True + True - - - True - gtk-add - - + Find a hidden network True Enter a hidden network to try to locate. - Find a hidden network True + True - - - True - network-wireless - - @@ -74,6 +62,9 @@ + + False + @@ -86,6 +77,7 @@ + False True @@ -99,6 +91,7 @@ + False True @@ -112,6 +105,7 @@ + False True @@ -125,6 +119,7 @@ + False True @@ -139,12 +134,14 @@ + False True False + 0 @@ -165,12 +162,12 @@ True False - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC + automatic + automatic True - GTK_SHADOW_NONE + none True @@ -198,15 +195,17 @@ 3 + 0 - True - Cancel the current connection attempt gtk-cancel + True + False + False + Cancel the current connection attempt True - 0 @@ -238,8 +237,8 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 5 Configure Scripts - GTK_WIN_POS_CENTER_ON_PARENT - GDK_WINDOW_TYPE_HINT_DIALOG + center-on-parent + dialog False @@ -259,6 +258,7 @@ False False + 0 @@ -272,6 +272,9 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Pre-connection Script: + + 0 + @@ -302,6 +305,9 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Post-connection Script: + + 0 + @@ -332,6 +338,9 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Disconnection Script: + + 0 + @@ -359,32 +368,41 @@ True - GTK_BUTTONBOX_END + end + gtk-cancel True True - gtk-cancel + False True - 0 + + False + False + 0 + + gtk-ok + 1 True True - gtk-ok + False True - 1 + False + False 1 False - GTK_PACK_END + end + 0 @@ -392,8 +410,8 @@ 5 - GTK_WIN_POS_CENTER_ON_PARENT - GDK_WINDOW_TYPE_HINT_DIALOG + center-on-parent + dialog False @@ -414,17 +432,17 @@ True True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC + automatic + automatic True - GTK_RESIZE_QUEUE - GTK_SHADOW_NONE + queue + none True - 18 + 20 2 4 4 @@ -433,14 +451,14 @@ True + Always switch to a wired connection when available True True + False True If selected, wicd will automatically connect to a wired network as soon as a cable is plugged in, even if a wireless connection is already active. - Always switch to a wired connection when available - 0 True @@ -490,10 +508,10 @@ is already active. 12 + Automatically reconnect on network connection loss True True - Automatically reconnect on network connection loss - 0 + False True @@ -525,10 +543,10 @@ is already active. 12 + Use last wired network profile True True - Use last wired network profile - 0 + False True True @@ -547,10 +565,10 @@ is already active. 12 + Prompt for wired network profile True True - Prompt for wired network profile - 0 + False True True pref_use_last_radio @@ -570,10 +588,10 @@ is already active. 12 + Use default wired network profile True True - Use default wired network profile - 0 + False True True pref_use_last_radio @@ -766,10 +784,10 @@ is already active. 12 + Use global DNS servers True True - Use global DNS servers - 0 + False True @@ -840,11 +858,11 @@ is already active. 24 + Always show wired interface True True + False If enabled, the wired network interface will always be displayed in the main window. This can be useful if your wired network card does not detect when the interface is connected to a cable. - Always show wired interface - 0 True @@ -856,6 +874,41 @@ is already active. + + + True + 0 + <b>Notifications</b> + True + + + 2 + 18 + 19 + + + + + + True + 12 + + + Display notifications about connection status + True + True + False + True + + + + + 2 + 19 + 20 + + + @@ -870,8 +923,8 @@ is already active. General Settings - tab False + tab @@ -885,13 +938,13 @@ is already active. True True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC + automatic + automatic True - GTK_RESIZE_QUEUE - GTK_SHADOW_NONE + queue + none True @@ -931,23 +984,24 @@ is already active. True + Automatic (recommended) True True - Automatic (recommended) - 0 + False True True False + 0 + ip True True - ip - 0 + False True True flush_auto_radio @@ -959,10 +1013,10 @@ is already active. + route True True - route - 0 + False True True flush_auto_radio @@ -990,23 +1044,24 @@ is already active. True + Automatic (recommended) True True - Automatic (recommended) - 0 + False True True False + 0 + ethtool True True - ethtool - 0 + False True True link_auto_radio @@ -1018,10 +1073,10 @@ is already active. + mii-tool True True - mii-tool - 0 + False True True link_auto_radio @@ -1049,24 +1104,25 @@ is already active. True + Automatic (recommended) True True - Automatic (recommended) - 0 + False True True dhclient_radio False + 0 + dhclient True True - dhclient - 0 + False True True @@ -1077,10 +1133,10 @@ is already active. + dhcpcd True True - dhcpcd - 0 + False True True dhclient_radio @@ -1092,10 +1148,10 @@ is already active. + pump True True - pump - 0 + False True True dhclient_radio @@ -1147,23 +1203,24 @@ is already active. True + Automatic (recommended) True True - Automatic (recommended) - 0 + False True True False + 0 + gksudo True True - gksudo - 0 + False True True sudo_auto_radio @@ -1175,10 +1232,10 @@ is already active. + kdesu True True - kdesu - 0 + False True True sudo_auto_radio @@ -1190,10 +1247,10 @@ is already active. + ktsuss True True - ktsuss - 0 + False True True sudo_auto_radio @@ -1228,9 +1285,9 @@ is already active. External Programs - tab 1 False + tab @@ -1270,6 +1327,7 @@ to read its description. False + 0 @@ -1316,10 +1374,10 @@ to read its description. 12 + Use dBm to measure signal strength True True - Use dBm to measure signal strength - 0 + False True @@ -1337,10 +1395,10 @@ to read its description. 12 + Enable debug mode True True - Enable debug mode - 0 + False True @@ -1477,9 +1535,9 @@ WPA supplicant driver. Advanced Settings - tab 2 False + tab @@ -1490,34 +1548,41 @@ WPA supplicant driver. True - GTK_BUTTONBOX_END + end + gtk-cancel True True True - gtk-cancel True - 0 + + False + False + 0 + + gtk-ok + 1 True True True - gtk-ok True - 1 + False + False 1 False - GTK_PACK_END + end + 0 diff --git a/wicd/prefs.py b/wicd/prefs.py index 30d7a5d..2c577ea 100644 --- a/wicd/prefs.py +++ b/wicd/prefs.py @@ -41,6 +41,8 @@ wired = None from translations import language +USER_SETTINGS_DIR = os.path.expanduser('~/.wicd/') + def setup_dbus(): global daemon, wireless, wired daemon = dbusmanager.get_interface('daemon') @@ -144,6 +146,11 @@ class PreferencesDialog(object): self.backendcombo.set_active(self.backends.index(cur_backend)) except ValueError: self.backendcombo.set_active(0) + + self.notificationscheckbox.set_active( + os.path.exists( + os.path.join(USER_SETTINGS_DIR, 'USE_NOTIFICATIONS') + )) self.wTree.get_widget("notebook2").set_current_page(0) @@ -224,6 +231,15 @@ class PreferencesDialog(object): [width, height] = self.dialog.get_size() daemon.WriteWindowSize(width, height, "pref") + + not_path = os.path.join(USER_SETTINGS_DIR, 'USE_NOTIFICATIONS') + if self.notificationscheckbox.get_active(): + if not os.path.exists(not_path): + open(not_path, 'w') + else: + if os.path.exists(not_path): + os.remove(not_path) + def set_label(self, glade_str, label): """ Sets the label for the given widget in wicd.glade. """ @@ -308,6 +324,9 @@ class PreferencesDialog(object): 'use_last_used_profile') + self.notificationscheckbox = setup_label("pref_use_libnotify", + 'display_notifications') + # DHCP Clients self.dhcpautoradio = setup_label("dhcp_auto_radio", "wicd_auto_config") self.dhclientradio = self.wTree.get_widget("dhclient_radio") diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index d7d0b2e..143d9e5 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -53,6 +53,8 @@ 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 @@ -245,9 +247,7 @@ class TrayIcon(object): if not state or not info: [state, info] = daemon.GetConnectionStatus() - self._show_notification('hello!') - - self.should_notify = (self.last_state != state) and HAS_NOTIFY + self.should_notify = (self.last_state != state) and HAS_NOTIFY and USE_NOTIFY self.last_state = state From 176be0b9d3a3bd28effad869dafc8b1f50b7f5f1 Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Sat, 2 May 2009 12:43:43 +0800 Subject: [PATCH 03/15] Reworded notifications and added new entries to translations.py --- wicd/translations.py | 4 +++- wicd/wicd-client.py | 17 ++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/wicd/translations.py b/wicd/translations.py index 327951c..b92bf44 100644 --- a/wicd/translations.py +++ b/wicd/translations.py @@ -226,4 +226,6 @@ language['raw_screen_arg'] = _('use urwid\'s raw screen controller') language['ok'] = _('OK') language['cancel'] = _('Cancel') - +language['disconnected'] = _('Disconnected') +language['connection_established'] = _('Connection established') +language['establishing_connection'] = _('Establishing connection...') diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index 143d9e5..da3b173 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -166,13 +166,13 @@ class TrayIcon(object): handle_no_dbus() self.set_not_connected_state() - def _show_notification(self, status_string): + def _show_notification(self, title, details): if self.should_notify: if not self._last_bubble: - self._last_bubble = pynotify.Notification("Network status", status_string) + self._last_bubble = pynotify.Notification(title, details) self._last_bubble.show() else: - self._last_bubble.update("Network status", status_string) + self._last_bubble.update(title, details) self._last_bubble.show() self.should_notify = False @@ -190,7 +190,8 @@ class TrayIcon(object): status_string = language['connected_to_wired'].replace('$A', wired_ip) self.tr.set_tooltip(status_string) - self._show_notification(status_string) + self._show_notification(language['wired_network'], + language['connection_established']) @catchdbus def set_wireless_state(self, info): @@ -210,7 +211,8 @@ class TrayIcon(object): .replace('$C', str(wireless_ip))) self.tr.set_tooltip(status_string) self.set_signal_image(int(strength), lock) - self._show_notification(status_string) + self._show_notification(self.network, + language['connection_established']) def set_connecting_state(self, info): @@ -223,7 +225,8 @@ class TrayIcon(object): cur_network + "..." self.tr.set_tooltip(status_string) self.tr.set_from_file(os.path.join(wpath.images, "no-signal.png")) - self._show_notification(status_string) + self._show_notification(cur_network, + language['establishing_connection']) @catchdbus def set_not_connected_state(self, info=None): @@ -237,7 +240,7 @@ class TrayIcon(object): else: status = language['not_connected'] self.tr.set_tooltip(status) - self._show_notification(status) + self._show_notification(language['disconnected'], None) @catchdbus def update_tray_icon(self, state=None, info=None): From 0563b9b4b2c902687e104d7b73376d0462a33c26 Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Sat, 2 May 2009 14:01:30 +0800 Subject: [PATCH 04/15] Disable the enable notification option if pynotify isn't installed --- wicd/prefs.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wicd/prefs.py b/wicd/prefs.py index 7a6d709..abfa6b0 100644 --- a/wicd/prefs.py +++ b/wicd/prefs.py @@ -148,6 +148,13 @@ class PreferencesDialog(object): os.path.exists( os.path.join(USER_SETTINGS_DIR, 'USE_NOTIFICATIONS') )) + + # if pynotify isn't installed disable the option + try: + import pynotify + except ImportError: + self.notificationscheckbox.set_active(False) + self.notificationscheckbox.set_sensitive(False) self.wTree.get_widget("notebook2").set_current_page(0) From c7745de68becb85bc3760cb080d10edad7d84d26 Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Sun, 3 May 2009 09:50:09 +0800 Subject: [PATCH 05/15] Fixed the libglade warnings when loading the GTK GUI --- data/wicd.glade | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/data/wicd.glade b/data/wicd.glade index 9d39ce3..c42ddb1 100644 --- a/data/wicd.glade +++ b/data/wicd.glade @@ -40,9 +40,14 @@ Create an ad-hoc network True - True - True + False + + + True + gtk-add + + @@ -50,9 +55,14 @@ Find a hidden network True Enter a hidden network to try to locate. - True - True + False + + + True + gtk-find + + From d8df1d1a36d802d96ffa12d93a501a4559d5e15e Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Sun, 3 May 2009 10:32:10 +0800 Subject: [PATCH 06/15] Added support for instantly enabling/disabling notifications when the preference is changed --- wicd/gui.py | 6 ++++-- wicd/prefs.py | 9 +++++++-- wicd/wicd-client.py | 13 ++++++++----- 3 files changed, 19 insertions(+), 9 deletions(-) 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: From a6c6ca1f1a1392a8e36094cf5abc6bb546f89517 Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Sun, 3 May 2009 17:20:02 +0800 Subject: [PATCH 07/15] Updated translations.py to include all translations from old translations.py --- wicd/translations.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wicd/translations.py b/wicd/translations.py index 7de3616..2047a30 100644 --- a/wicd/translations.py +++ b/wicd/translations.py @@ -55,7 +55,7 @@ def get_gettext(): _ = lang.gettext return _ -# Generated automatically on Sat, 02 May 2009 02:29:29 CDT +# Generated automatically on Sun, 03 May 2009 04:19:52 CDT _ = get_gettext() language = {} language['resetting_ip_address'] = _('''Resetting IP address...''') @@ -64,6 +64,7 @@ language['no_dhcp_offers'] = _('''Connection Failed: No DHCP offers received.''' language['more_help'] = _('''For more detailed help, consult the wicd-curses(8) man page.''') language['bad_pass'] = _('''Connection Failed: Bad password''') language['cannot_start_daemon'] = _('''Unable to connect to wicd daemon DBus interface. This typically means there was a problem starting the daemon. Check the wicd log for more information.''') +language['verifying_association'] = _('''Verifying access point association...''') language['wired_always_on'] = _('''Always show wired interface''') language['could_not_connect'] = _('''Could not connect to wicd's D-Bus interface. Check the wicd log for error messages.''') language['path_to_pac_file'] = _('''Path to PAC File''') @@ -212,3 +213,6 @@ language['display_notifications'] = _('''Display notifications about connection language['connection_established'] = _('''Connection established''') language['disconnected'] = _('''Disconnected''') language['establishing_connection'] = _('''Establishing connection...''') +language['association_failed'] = _('''Connection failed: Could not contact the wireless access point.''') +language['access_denied'] = _('''Unable to contact the wicd dameon due to an access denied error from DBus. Please check your DBus configuration.''') +language['script_settings'] = _('''Scripts''') From a6f486e4055e6b2ced25c5c49a33844e65b92b03 Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Sun, 3 May 2009 17:26:29 +0800 Subject: [PATCH 08/15] added images to wired network connection notifications --- wicd/wicd-client.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index 4399ca2..37b35be 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -168,13 +168,16 @@ class TrayIcon(object): handle_no_dbus() self.set_not_connected_state() - def _show_notification(self, title, details): + def _show_notification(self, title, details, image=None): if self.should_notify: if not self._last_bubble: - self._last_bubble = pynotify.Notification(title, details) + self._last_bubble = pynotify.Notification(title, details, + image) self._last_bubble.show() else: - self._last_bubble.update(title, details) + self._last_bubble.clear_actions() + self._last_bubble.clear_hints() + self._last_bubble.update(title, details, image) self._last_bubble.show() self.should_notify = False @@ -193,7 +196,8 @@ class TrayIcon(object): wired_ip) self.tr.set_tooltip(status_string) self._show_notification(language['wired_network'], - language['connection_established']) + language['connection_established'], + 'network-wired') @catchdbus def set_wireless_state(self, info): @@ -219,16 +223,24 @@ class TrayIcon(object): def set_connecting_state(self, info): """ Sets the icon info for a connecting state. """ + wired = False if info[0] == 'wired' and len(info) == 1: cur_network = language['wired_network'] + wired = True else: cur_network = info[1] status_string = language['connecting'] + " to " + \ cur_network + "..." self.tr.set_tooltip(status_string) self.tr.set_from_file(os.path.join(wpath.images, "no-signal.png")) - self._show_notification(cur_network, - language['establishing_connection']) + if wired: + self._show_notification(cur_network, + language['establishing_connection'], + 'network-wired') + else: + self._show_notification(cur_network, + language['establishing_connection']) + @catchdbus def set_not_connected_state(self, info=None): From 9ce1c5255bc52567803066c56a1f0a57f8fa3223 Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Sun, 3 May 2009 17:31:18 +0800 Subject: [PATCH 09/15] Added icons for wireless networks and disconnect states --- wicd/wicd-client.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index 37b35be..e692612 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -218,7 +218,8 @@ class TrayIcon(object): self.tr.set_tooltip(status_string) self.set_signal_image(int(strength), lock) self._show_notification(self.network, - language['connection_established']) + language['connection_established'], + 'network-wireless') def set_connecting_state(self, info): @@ -239,7 +240,8 @@ class TrayIcon(object): 'network-wired') else: self._show_notification(cur_network, - language['establishing_connection']) + language['establishing_connection'], + 'network-wireless') @catchdbus @@ -254,7 +256,7 @@ class TrayIcon(object): else: status = language['not_connected'] self.tr.set_tooltip(status) - self._show_notification(language['disconnected'], None) + self._show_notification(language['disconnected'], None, 'stop') @catchdbus def update_tray_icon(self, state=None, info=None): From 831d11e5967de173ee4f33a0bfce53a2cb5d22ea Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Sun, 3 May 2009 21:58:11 +0800 Subject: [PATCH 10/15] print wicd's version number on daemon start --- wicd/wicd-daemon.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py index 17f3e2d..e0230d9 100644 --- a/wicd/wicd-daemon.py +++ b/wicd/wicd-daemon.py @@ -1667,6 +1667,8 @@ def main(argv): print 'wicd initializing...' print '---------------------------' + print 'wicd is version', wpath.version, wpath.revision + # Open the DBUS session bus = dbus.SystemBus() wicd_bus = dbus.service.BusName('org.wicd.daemon', bus=bus) From 45b5c4718ca3d97f6c97842d1d5740196a0726e3 Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Tue, 5 May 2009 10:34:44 +0800 Subject: [PATCH 11/15] added support for disabling notifications in setup.py --- in/wicd=wpath.py.in | 1 + setup.py | 4 +++- wicd/prefs.py | 6 ++++++ wicd/wicd-client.py | 10 ++++++++-- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/in/wicd=wpath.py.in b/in/wicd=wpath.py.in index a4f17ef..d1fbbc1 100755 --- a/in/wicd=wpath.py.in +++ b/in/wicd=wpath.py.in @@ -71,6 +71,7 @@ no_install_kde = %NO_INSTALL_KDE% no_install_acpi = %NO_INSTALL_ACPI% no_install_docs = %NO_INSTALL_DOCS% no_install_ncurses = %NO_INSTALL_NCURSES% +no_use_notifications = %NO_USE_NOTIFICATIONS% def chdir(file): """Change directory to the location of the specified file. diff --git a/setup.py b/setup.py index 4ebc6aa..fdee577 100755 --- a/setup.py +++ b/setup.py @@ -92,7 +92,8 @@ class configure(Command): ('no-install-acpi', None, 'do not install the suspend.d and resume.d acpi scripts'), ('no-install-pmutils', None, 'do not install the pm-utils hooks'), ('no-install-docs', None, 'do not install the auxiliary documentation'), - ('no-install-ncurses', None, 'do not install the ncurses client') + ('no-install-ncurses', None, 'do not install the ncurses client'), + ('no-use-notifications', None, 'do not ever allow the use of libnotify notifications') ] def initialize_options(self): @@ -127,6 +128,7 @@ class configure(Command): self.no_install_pmutils = False self.no_install_docs = False self.no_install_ncurses = False + self.no_use_notifications = False # Determine the default init file location on several different distros diff --git a/wicd/prefs.py b/wicd/prefs.py index 0066a1b..a8da776 100644 --- a/wicd/prefs.py +++ b/wicd/prefs.py @@ -156,6 +156,12 @@ class PreferencesDialog(object): except ImportError: self.notificationscheckbox.set_active(False) self.notificationscheckbox.set_sensitive(False) + + # if notifications were disabled with the configure flag + if wpath.no_use_notifications: + self.notificationscheckbox.set_active(False) + self.notificationscheckbox.hide() + self.wTree.get_widget('label2').hide() self.wTree.get_widget("notebook2").set_current_page(0) diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index e692612..dc306de 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -75,6 +75,9 @@ if not hasattr(gtk, "StatusIcon"): print "Has notifications support", HAS_NOTIFY +if wpath.no_use_notifications: + print 'Notifications disabled during setup.py configure' + misc.RenameProcess("wicd-client") if __name__ == '__main__': @@ -266,8 +269,11 @@ class TrayIcon(object): if not state or not info: [state, info] = daemon.GetConnectionStatus() - self.should_notify = (self.last_state != state) and \ - HAS_NOTIFY and self.use_notify + # should this state change display a notification? + self.should_notify = not wpath.no_use_notifications and \ + (self.last_state != state) and \ + HAS_NOTIFY and \ + self.use_notify self.last_state = state From cd391b8ff551adffc895ecd812577aa83ce8640f Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Tue, 5 May 2009 12:00:22 +0800 Subject: [PATCH 12/15] updated CHANGES/NEWS --- CHANGES | 265 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ NEWS | 1 + 2 files changed, 266 insertions(+) diff --git a/CHANGES b/CHANGES index 7556ef8..437cb5d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,269 @@ ------------------------------------------------------------ +revno: 382 +committer: Adam Blackburn +branch nick: 1.6 +timestamp: Tue 2009-05-05 11:58:36 +0800 +message: + merged notifications branch + ------------------------------------------------------------ + revno: 371.1.13 + committer: Adam Blackburn + branch nick: libnotify-support-ng + timestamp: Tue 2009-05-05 10:34:44 +0800 + message: + added support for disabling notifications in setup.py + ------------------------------------------------------------ + revno: 371.1.12 + committer: Adam Blackburn + branch nick: libnotify-support-ng + timestamp: Tue 2009-05-05 10:17:10 +0800 + message: + merged latest 1.6 + ------------------------------------------------------------ + revno: 371.1.11 + committer: Adam Blackburn + branch nick: libnotify-support-ng + timestamp: Sun 2009-05-03 17:31:18 +0800 + message: + Added icons for wireless networks and disconnect states + ------------------------------------------------------------ + revno: 371.1.10 + committer: Adam Blackburn + branch nick: libnotify-support-ng + timestamp: Sun 2009-05-03 17:27:31 +0800 + message: + merge latest 1.6 + ------------------------------------------------------------ + revno: 371.1.9 + committer: Adam Blackburn + branch nick: libnotify-support-ng + timestamp: Sun 2009-05-03 17:26:29 +0800 + message: + added images to wired network connection notifications + ------------------------------------------------------------ + revno: 371.1.8 + committer: Adam Blackburn + branch nick: libnotify-support-ng + timestamp: Sun 2009-05-03 10:32:10 +0800 + message: + Added support for instantly enabling/disabling notifications when the preference is changed + ------------------------------------------------------------ + revno: 371.1.7 + committer: Adam Blackburn + branch nick: libnotify-support-ng + timestamp: Sun 2009-05-03 09:50:09 +0800 + message: + Fixed the libglade warnings when loading the GTK GUI + ------------------------------------------------------------ + revno: 371.1.6 + committer: Adam Blackburn + branch nick: libnotify-support-ng + timestamp: Sun 2009-05-03 09:33:32 +0800 + message: + Merge latest 1.6 + ------------------------------------------------------------ + revno: 371.1.5 + committer: Adam Blackburn + branch nick: libnotify-support-ng + timestamp: Sat 2009-05-02 14:01:30 +0800 + message: + Disable the enable notification option if pynotify isn't installed + ------------------------------------------------------------ + revno: 371.1.4 + committer: Adam Blackburn + branch nick: libnotify-support-ng + timestamp: Sat 2009-05-02 12:47:05 +0800 + message: + Merge latest 1.6 + ------------------------------------------------------------ + revno: 371.1.3 + committer: Adam Blackburn + branch nick: libnotify-support-ng + timestamp: Sat 2009-05-02 12:43:43 +0800 + message: + Reworded notifications and added new entries to translations.py + ------------------------------------------------------------ + revno: 371.1.2 + committer: Adam Blackburn + branch nick: libnotify-support-ng + timestamp: Fri 2009-05-01 14:32:09 +0800 + message: + added support for enabling/disabling notifications + ------------------------------------------------------------ + revno: 371.1.1 + committer: Adam Blackburn + branch nick: libnotify-support-ng + timestamp: Fri 2009-05-01 13:46:21 +0800 + message: + Initial notification support +------------------------------------------------------------ +revno: 381 +committer: Adam Blackburn +branch nick: 1.6 +timestamp: Sun 2009-05-03 22:00:24 +0800 +message: + print wicd's version number on daemon start + ------------------------------------------------------------ + revno: 379.1.1 + committer: Adam Blackburn + branch nick: 1.6 + timestamp: Sun 2009-05-03 17:20:02 +0800 + message: + Updated translations.py to include all translations from old translations.py +------------------------------------------------------------ +revno: 380 +committer: Adam Blackburn +branch nick: 1.6 +timestamp: Sun 2009-05-03 21:58:11 +0800 +message: + print wicd's version number on daemon start +------------------------------------------------------------ +revno: 379 +committer: Andrew Psaltis +branch nick: 1.6 +timestamp: Sat 2009-05-02 14:08:07 -0400 +message: + Merged bugfixes from r321 of experimental-nacl. + ------------------------------------------------------------ + revno: 202.2.30 + committer: Andrew Psaltis + branch nick: experimental-nacl + timestamp: Fri 2009-05-01 22:23:40 -0400 + message: + Merge r375 of mainline 1.6. + ------------------------------------------------------------ + revno: 202.2.29 + committer: Andrew Psaltis + branch nick: experimental-nacl + timestamp: Fri 2009-05-01 22:13:15 -0400 + message: + Some more bugfixes... + Fixed unencrypted network support in both UIs. + Fixed marking the Static IP checkbox in wicd-curses. + Made the checkboxes in the the network properties dialogs in wicd-curses act + like those in wicd-client. + Filter the urwid popen2 warning in wicd-curses. + ------------------------------------------------------------ + revno: 202.2.28 + committer: Andrew Psaltis + branch nick: experimental-nacl + timestamp: Fri 2009-05-01 13:02:44 -0400 + message: + Merged with r272 of mainline 1.6. +------------------------------------------------------------ +revno: 378 +committer: Adam Blackburn +branch nick: 1.6 +timestamp: Sat 2009-05-02 15:32:58 +0800 +message: + Updated INSTALL to use update_translations_py before get_translations +------------------------------------------------------------ +revno: 377 +committer: Adam Blackburn +branch nick: 1.6 +timestamp: Sat 2009-05-02 15:30:09 +0800 +message: + Added automatically generated translations.py +------------------------------------------------------------ +revno: 376 +committer: Adam Blackburn +branch nick: 1.6 +timestamp: Sat 2009-05-02 15:24:50 +0800 +message: + added support for automatically retrieving translations.py +------------------------------------------------------------ +revno: 375 +committer: Dan O'Reilly +branch nick: experimental +timestamp: Fri 2009-05-01 20:26:46 -0400 +message: + Fix bug where shared essid settings couldn't be disabled once they were turned on. +------------------------------------------------------------ +revno: 374 +committer: Dan O'Reilly +branch nick: experimental +timestamp: Fri 2009-05-01 20:20:40 -0400 +message: + Fix crash when saving settings for unencrypted networks. + Remove unneeded function in prefs.py +------------------------------------------------------------ +revno: 373 +committer: Adam Blackburn +branch nick: 1.6 +timestamp: Fri 2009-05-01 21:58:53 +0800 +message: + Merge 1.6-rworkman (thanks!) + ------------------------------------------------------------ + revno: 365.1.8 + committer: Robby Workman + branch nick: 1.6-rworkman + timestamp: Tue 2009-04-28 10:51:16 -0500 + message: + Tweaks to NEWS file. + ------------------------------------------------------------ + revno: 365.1.7 + committer: Robby Workman + branch nick: 1.6-rworkman + timestamp: Tue 2009-04-28 10:50:23 -0500 + message: + Merged mainline. This will require one more change to the NEWS file + to handle conflicts. + ------------------------------------------------------------ + revno: 365.1.6 + committer: Robby Workman + branch nick: 1.6-rworkman + timestamp: Sun 2009-04-26 21:38:10 -0500 + message: + Clarified some required versions in INSTALL + ------------------------------------------------------------ + revno: 365.1.5 + committer: Robby Workman + branch nick: 1.6-rworkman + timestamp: Sat 2009-04-25 23:17:33 -0500 + message: + Use set_icon_name() instead of set_icon_from_file() in gui.py ; this + allows gtk to use the themed icons (and presumably the correct size + and all that good stuff). + ------------------------------------------------------------ + revno: 365.1.4 + committer: Robby Workman + branch nick: 1.6-rworkman + timestamp: Sat 2009-04-25 22:55:12 -0500 + message: + Synced CHANGES file with mainline. + Minor tweaks to NEWS file (mostly formatting). + ------------------------------------------------------------ + revno: 365.1.3 + committer: Robby Workman + branch nick: 1.6-rworkman + timestamp: Wed 2009-04-22 19:53:08 -0500 + message: + Added NEWS file with major changes since 1.5.x. + Updated CHANGES file with 'bzr log' output as of r367. +------------------------------------------------------------ +revno: 372 +committer: Adam Blackburn +branch nick: 1.6 +timestamp: Fri 2009-05-01 13:41:13 +0800 +message: + Also catch AttributeErrors when guessing data types +------------------------------------------------------------ +revno: 371 +committer: Dan O'Reilly +branch nick: experimental +timestamp: Mon 2009-04-27 19:17:01 -0400 +message: + Correctly handle case where a key is all digits and starts with a '0'. + Remove some unused imports. + Simplfy code that checks for valid wpa_supplicant drivers. +------------------------------------------------------------ +revno: 370 +committer: Adam Blackburn +branch nick: 1.6 +timestamp: Sun 2009-04-26 08:03:59 +0900 +message: + Updated version numbers +------------------------------------------------------------ revno: 369 committer: Adam Blackburn branch nick: 1.6 diff --git a/NEWS b/NEWS index 536b3f1..e3b0eaf 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ Major Changes: - Reworked the Preferences menu to be more in line with GNOME standards - Added support for global scripts - Made it possible to have optional entries in encryption templates +- Added ability to show libnotify notifications on status change Minor Changes and Other Enchancements: - Better autoconnection behavior From 4317cb0cda3aab784fb7bee4839b01c5ad8086ed Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Tue, 5 May 2009 12:55:35 +0800 Subject: [PATCH 13/15] Added code to debug why pynotify fails --- wicd/wicd-client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index dc306de..b1115dc 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -49,8 +49,10 @@ try: pygtk.require('2.0') import pynotify if not pynotify.init("Wicd"): + print 'could not initalize pynotify' HAS_NOTIFY = False except ImportError: + print 'import failed HAS_NOTIFY = False # Wicd specific imports From e323bbaf7369d29568d392d7b284ac9b3512d19c Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Tue, 5 May 2009 12:56:09 +0800 Subject: [PATCH 14/15] Updated translations.py --- wicd/translations.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wicd/translations.py b/wicd/translations.py index 2047a30..e5e72f1 100644 --- a/wicd/translations.py +++ b/wicd/translations.py @@ -55,7 +55,7 @@ def get_gettext(): _ = lang.gettext return _ -# Generated automatically on Sun, 03 May 2009 04:19:52 CDT +# Generated automatically on Mon, 04 May 2009 23:56:04 CDT _ = get_gettext() language = {} language['resetting_ip_address'] = _('''Resetting IP address...''') @@ -215,4 +215,3 @@ language['disconnected'] = _('''Disconnected''') language['establishing_connection'] = _('''Establishing connection...''') language['association_failed'] = _('''Connection failed: Could not contact the wireless access point.''') language['access_denied'] = _('''Unable to contact the wicd dameon due to an access denied error from DBus. Please check your DBus configuration.''') -language['script_settings'] = _('''Scripts''') From d192f641825d115f9faf2f8c5a1aa67dd6e265e0 Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Wed, 6 May 2009 18:13:29 -0400 Subject: [PATCH 15/15] Fixed missing endquote in wicd-client.py. --- wicd/wicd-client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index b1115dc..7c9d100 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -52,7 +52,7 @@ try: print 'could not initalize pynotify' HAS_NOTIFY = False except ImportError: - print 'import failed + print 'import failed' HAS_NOTIFY = False # Wicd specific imports