From 1cb42252b8a33e93fae99e673fa302acc8cf79a3 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 22 Nov 2009 08:14:09 +0000 Subject: [PATCH] Don't throw errors when de-registering notifications. If sound notifications is not possible or disabled, also disable the sound customization notebook page. --- .../notifications/notifications/common.py | 17 +++++---- .../notifications/data/config.glade | 8 ++--- .../notifications/notifications/gtkui.py | 36 +++++++++++++------ 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/deluge/plugins/notifications/notifications/common.py b/deluge/plugins/notifications/notifications/common.py index 674c37cce..7353e5a8e 100644 --- a/deluge/plugins/notifications/notifications/common.py +++ b/deluge/plugins/notifications/notifications/common.py @@ -107,15 +107,18 @@ class CustomNotifications(object): client.register_event_handler(eventtype, wrapper) def _deregister_custom_provider(self, kind, eventtype): - wrapper, handler = self.custom_notifications[kind][eventtype] try: - component.get("EventManager").deregister_event_handler( - eventtype, wrapper - ) + wrapper, handler = self.custom_notifications[kind][eventtype] + try: + component.get("EventManager").deregister_event_handler( + eventtype, wrapper + ) + except KeyError: + from deluge.ui.client import client + client.deregister_event_handler(eventtype, wrapper) + self.custom_notifications[kind].pop(eventtype) except KeyError: - from deluge.ui.client import client - client.deregister_event_handler(eventtype, wrapper) - self.custom_notifications[kind].pop(eventtype) + pass def _handled_eventtype(self, eventtype, handler): if eventtype not in known_events: diff --git a/deluge/plugins/notifications/notifications/data/config.glade b/deluge/plugins/notifications/notifications/data/config.glade index d4651af30..f1603505d 100644 --- a/deluge/plugins/notifications/notifications/data/config.glade +++ b/deluge/plugins/notifications/notifications/data/config.glade @@ -454,7 +454,7 @@ - + True Settings @@ -507,7 +507,7 @@ - + True Subscriptions @@ -518,7 +518,7 @@ - + True vertical @@ -588,7 +588,7 @@ - + True Sound Customization diff --git a/deluge/plugins/notifications/notifications/gtkui.py b/deluge/plugins/notifications/notifications/gtkui.py index 8ae65115c..ae8909f45 100644 --- a/deluge/plugins/notifications/notifications/gtkui.py +++ b/deluge/plugins/notifications/notifications/gtkui.py @@ -295,9 +295,17 @@ class GtkUI(GtkPluginBase, GtkUiNotifications): self.glade.get_widget("popup_enabled").set_property('sensitive', False) if not SOUND_AVAILABLE: +# for widget_name in ('sound_enabled', 'sound_path', 'sounds_page', +# 'sounds_page_label'): +# self.glade.get_widget(widget_name).set_property('sensitive', +# False) self.glade.get_widget("sound_enabled").set_property('sensitive', False) self.glade.get_widget('sound_path').set_property('sensitive', False) + self.glade.get_widget('sounds_page').set_property('sensitive', + False) + self.glade.get_widget('sounds_page_label').set_property('sensitive', + False) self.systray = component.get("SystemTray") if not hasattr(self.systray, 'tray'): @@ -654,23 +662,29 @@ class GtkUI(GtkPluginBase, GtkUiNotifications): log.debug("dialog should have been shown") def on_enabled_toggled(self, widget): - if widget.get_active(): - for widget in ('smtp_host', 'smtp_port', 'smtp_user', 'smtp_pass', - 'smtp_pass', 'smtp_tls', 'smtp_from', - 'smtp_recipients'): - self.glade.get_widget(widget).set_property('sensitive', True) - else: - for widget in ('smtp_host', 'smtp_port', 'smtp_user', 'smtp_pass', - 'smtp_pass', 'smtp_tls', 'smtp_from', - 'smtp_recipients'): - self.glade.get_widget(widget).set_property('sensitive', False) - + for widget_name in ('smtp_host', 'smtp_port', 'smtp_user', 'smtp_pass', + 'smtp_pass', 'smtp_tls', 'smtp_from', + 'smtp_recipients'): + self.glade.get_widget(widget_name).set_property('sensitive', + widget.get_active()) def on_sound_enabled_toggled(self, widget): if widget.get_active(): self.glade.get_widget('sound_path').set_property('sensitive', True) + self.glade.get_widget('sounds_page').set_property('sensitive', + True) + self.glade.get_widget('sounds_page_label').set_property('sensitive', + True) else: self.glade.get_widget('sound_path').set_property('sensitive', False) + self.glade.get_widget('sounds_page').set_property('sensitive', + False) + self.glade.get_widget('sounds_page_label').set_property('sensitive', + False) + +# for widget_name in ('sounds_path', 'sounds_page', 'sounds_page_label'): +# self.glade.get_widget(widget_name).set_property('sensitive', +# widget.get_active()) def _on_email_col_toggled(self, cell, path): self.subscriptions_model[path][SUB_NOT_EMAIL] = \