diff --git a/plugins/TorrentNotification/__init__.py b/plugins/TorrentNotification/__init__.py index cd80e6adb..65ad0cf0c 100644 --- a/plugins/TorrentNotification/__init__.py +++ b/plugins/TorrentNotification/__init__.py @@ -88,22 +88,24 @@ class TorrentNotification: self.interface.tray_icon.set_blinking(True) def show_notification(self, event): - import pynotify + import platform + if platform.system() != "Windows": + import pynotify - file_info = self.interface.manager.get_torrent_file_info(event['unique_ID']) - filelist = "" - for file in file_info[:10]: - filelist += file['path'] + "\n" - if len(file_info) > 10: - filelist += '...' - - if pynotify.init("Deluge"): - n = pynotify.Notification(_("Torrent complete"), - _("Files") + ":\n" + filelist) - n.set_icon_from_pixbuf(deluge.common.get_logo(48)) - n.show() + file_info = self.interface.manager.get_torrent_file_info(event['unique_ID']) + filelist = "" + for file in file_info[:10]: + filelist += file['path'] + "\n" + if len(file_info) > 10: + filelist += '...' + + if pynotify.init("Deluge"): + n = pynotify.Notification(_("Torrent complete"), + _("Files") + ":\n" + filelist) + n.set_icon_from_pixbuf(deluge.common.get_logo(48)) + n.show() else: - print "there was a problem initializing the pynotify module" + pass def configure(self, window): import os.path @@ -131,18 +133,21 @@ class TorrentNotification: self.glade.get_widget("sound_path_button").set_sensitive(value) def play_sound(self): - import pygame - import os.path - import sys - pygame.init() - try: - name = self.config.get("sound_path") - except: - print "no file set" - return - try: - alert_sound = pygame.mixer.music - alert_sound.load(name) - alert_sound.play() - except pygame.error, message: - print 'Cannot load sound:' + import platform + if platform.system() != "Windows": + import pygame + import os.path + import sys + pygame.init() + try: + name = self.config.get("sound_path") + except: + print "no file set" + try: + alert_sound = pygame.mixer.music + alert_sound.load(name) + alert_sound.play() + except pygame.error, message: + print 'Cannot load sound:' + else: + pass diff --git a/plugins/TorrentNotification/notification_preferences.glade b/plugins/TorrentNotification/notification_preferences.glade index 2a76782aa..edb8ade42 100644 --- a/plugins/TorrentNotification/notification_preferences.glade +++ b/plugins/TorrentNotification/notification_preferences.glade @@ -21,30 +21,6 @@ True 3 - - - True - True - Enable popup notification (requires python-notify) - True - 0 - True - - - 1 - 2 - - - - - True - True - Enable blinking tray icon - True - 0 - True - - True @@ -53,7 +29,7 @@ True True - Enable event sound (requires pygame) + Enable event sound (requires pygame, not available on Win32) True 0 True @@ -76,6 +52,30 @@ 3 + + + True + True + Enable blinking tray icon + True + 0 + True + + + + + True + True + Enable popup notification (requires python-notify, not available on Win32) + True + 0 + True + + + 1 + 2 + + False