mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-17 13:56:47 +00:00
tweaks so torrentnotification plugin doesnt crash win32 client
This commit is contained in:
parent
4c5a53b982
commit
120b3335b4
@ -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
|
||||
|
@ -21,30 +21,6 @@
|
||||
<widget class="GtkTable" id="table1">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">3</property>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="chk_notification">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Enable popup notification (requires python-notify)</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="chk_tray_blink">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Enable blinking tray icon</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
@ -53,7 +29,7 @@
|
||||
<widget class="GtkCheckButton" id="chk_sound">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Enable event sound (requires pygame)</property>
|
||||
<property name="label" translatable="yes">Enable event sound (requires pygame, not available on Win32)</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
@ -76,6 +52,30 @@
|
||||
<property name="bottom_attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="chk_tray_blink">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Enable blinking tray icon</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="chk_notification">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Enable popup notification (requires python-notify, not available on Win32)</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
Loading…
x
Reference in New Issue
Block a user