From 462ad22c618eb8601842c3878ab2e742ef4e1110 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Thu, 30 Aug 2007 02:04:26 +0000 Subject: [PATCH] cleanup --- plugins/TorrentNotification/__init__.py | 25 +++---- .../notification_preferences.glade | 69 +++++++++---------- 2 files changed, 45 insertions(+), 49 deletions(-) diff --git a/plugins/TorrentNotification/__init__.py b/plugins/TorrentNotification/__init__.py index 259ea5c57..a6237b424 100644 --- a/plugins/TorrentNotification/__init__.py +++ b/plugins/TorrentNotification/__init__.py @@ -38,6 +38,7 @@ class TorrentNotification: def __init__(self, path, core, interface): print "Loading TorrentNotification plugin..." + import os.path self.path = path self.core = core self.interface = interface @@ -47,11 +48,14 @@ class TorrentNotification: # Create an options file and try to load existing Values self.config_file = deluge.common.CONFIG_DIR + "/notification.conf" - self.config = deluge.pref.Preferences(self.config_file, False) + self.config = deluge.pref.Preferences(self.config_file, False, + defaults={'enable_tray_blink' : True, + 'enable_notification' : True, + 'enable_sound' : False, + 'sound_path' : os.path.expanduser("~/")}) try: self.config.load() except IOError: - # File does not exist pass self.glade = gtk.glade.XML(path + "/notification_preferences.glade") @@ -102,18 +106,11 @@ class TorrentNotification: def configure(self, window): import os.path - try: - self.glade.get_widget("chk_tray_blink").set_active(self.config.get("enable_tray_blink")) - self.glade.get_widget("chk_notification").set_active(self.config.get("enable_notification")) - self.glade.get_widget("chk_sound").set_active(self.config.get("enable_sound")) - self.glade.get_widget("sound_path_button").set_sensitive(self.config.get("enable_sound")) - self.glade.get_widget("sound_path_button").set_filename(self.config.get("sound_path")) - except: - self.glade.get_widget("chk_tray_blink").set_active(False) - self.glade.get_widget("chk_notification").set_active(False) - self.glade.get_widget("chk_sound").set_active(False) - self.glade.get_widget("sound_path_button").set_filename(os.path.expanduser("~/")) - self.glade.get_widget("sound_path_button").set_sensitive(False) + self.glade.get_widget("chk_tray_blink").set_active(self.config.get("enable_tray_blink")) + self.glade.get_widget("chk_notification").set_active(self.config.get("enable_notification")) + self.glade.get_widget("chk_sound").set_active(self.config.get("enable_sound")) + self.glade.get_widget("sound_path_button").set_sensitive(self.config.get("enable_sound")) + self.glade.get_widget("sound_path_button").set_filename(self.config.get("sound_path")) self.dialog.set_transient_for(window) self.dialog.show() diff --git a/plugins/TorrentNotification/notification_preferences.glade b/plugins/TorrentNotification/notification_preferences.glade index 775ead519..2a76782aa 100644 --- a/plugins/TorrentNotification/notification_preferences.glade +++ b/plugins/TorrentNotification/notification_preferences.glade @@ -7,8 +7,8 @@ Torrent Notification Preferences 400 150 - GDK_WINDOW_TYPE_HINT_NORMAL True + GDK_WINDOW_TYPE_HINT_NORMAL True True False @@ -17,42 +17,10 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK 2 - - - True - 2 - - - True - True - Enable event sound (requires pygame) - True - 0 - True - - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - 1 - - - - - False - False - 1 - - True - 2 + 3 True @@ -77,11 +45,42 @@ True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + True + Enable event sound (requires pygame) + True + 0 + True + + + + + + True + False + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + + + + + 2 + 3 + + False False - 2 + 1