windows tweaks to prevent error on win32

This commit is contained in:
Marcos Pinto 2007-10-18 23:15:52 +00:00
parent c70721aeac
commit 589c007386

View File

@ -32,6 +32,7 @@ def enable(core, interface):
### The Plugin ### ### The Plugin ###
import deluge import deluge
import deluge.common
import gtk import gtk
class TorrentNotification: class TorrentNotification:
@ -48,11 +49,18 @@ class TorrentNotification:
# Create an options file and try to load existing Values # Create an options file and try to load existing Values
self.config_file = deluge.common.CONFIG_DIR + "/notification.conf" self.config_file = deluge.common.CONFIG_DIR + "/notification.conf"
self.config = deluge.pref.Preferences(self.config_file, False, if deluge.common.windows_check():
defaults={'enable_tray_blink' : True, self.config = deluge.pref.Preferences(self.config_file, False,
'enable_notification' : True, defaults={'enable_tray_blink' : True,
'enable_sound' : False, 'enable_notification' : False,
'sound_path' : os.path.expanduser("~/")}) 'enable_sound' : False,
'sound_path' : os.path.expanduser("~")})
else:
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: try:
self.config.load() self.config.load()
except IOError: except IOError:
@ -88,10 +96,8 @@ class TorrentNotification:
self.interface.tray_icon.set_blinking(True) self.interface.tray_icon.set_blinking(True)
def show_notification(self, event): def show_notification(self, event):
import platform if not deluge.common.windows_check():
if platform.system() != "Windows":
import pynotify import pynotify
file_info = self.interface.manager.get_torrent_file_info(event['unique_ID']) file_info = self.interface.manager.get_torrent_file_info(event['unique_ID'])
filelist = "" filelist = ""
for file in file_info[:10]: for file in file_info[:10]:
@ -133,8 +139,7 @@ class TorrentNotification:
self.glade.get_widget("sound_path_button").set_sensitive(value) self.glade.get_widget("sound_path_button").set_sensitive(value)
def play_sound(self): def play_sound(self):
import platform if not deluge.common.windows_check():
if platform.system() != "Windows":
import pygame import pygame
import os.path import os.path
import sys import sys