summaryrefslogtreecommitdiff
path: root/nephilim/plugins/Notify.py
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2009-03-07 11:38:26 +0100
committerAnton Khirnov <wyskas@gmail.com>2009-03-07 11:38:26 +0100
commitc351b5c9f9f93b95cfa57c9bf10a6807e7f1b5f7 (patch)
treeaadf0d4e4fc063834ed3ec1b2517abfae2450579 /nephilim/plugins/Notify.py
parent5443aedab5a1e4d54888a56720c0a9fcf6c98315 (diff)
mpclient: use Qt signals/slots for events.
Diffstat (limited to 'nephilim/plugins/Notify.py')
-rw-r--r--nephilim/plugins/Notify.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/nephilim/plugins/Notify.py b/nephilim/plugins/Notify.py
index 4326a32..7535f05 100644
--- a/nephilim/plugins/Notify.py
+++ b/nephilim/plugins/Notify.py
@@ -45,6 +45,8 @@ class winNotify(QtGui.QWidget):
font.setPixelSize(20)
self.setFont(font)
+ self.connect
+
def mousePressEvent(self, event):
self.hide()
@@ -82,18 +84,25 @@ class Notify(Plugin):
o=None
DEFAULTS = {'songformat' : '$track - $artist - $title ($album) [$length]',
'timer' : 3000}
- LISTENERS = {'onSongChange': 'onSongChange', 'onReady' : 'onReady',
- 'onDisconnect': 'onDisconnect', 'onStateChange' : 'onStateChange',
- 'onVolumeChange' : 'onVolumeChange'}
def _load(self):
self.o = winNotify(self)
+ self.connect(self.mpclient(), QtCore.SIGNAL('song_changed'), self.onSongChange)
+ self.connect(self.mpclient(), QtCore.SIGNAL('ready'), self.onReady)
+ self.connect(self.mpclient(), QtCore.SIGNAL('disconnected'), self.onDisconnect)
+ self.connect(self.mpclient(), QtCore.SIGNAL('state_changed'), self.onStateChange)
+ self.connect(self.mpclient(), QtCore.SIGNAL('volume_changed'),self.onVolumeChange)
def _unload(self):
self.o=None
+ self.disconnect(self.mpclient(), QtCore.SIGNAL('song_changed'), self.onSongChange)
+ self.disconnect(self.mpclient(), QtCore.SIGNAL('ready'), self.onReady)
+ self.disconnect(self.mpclient(), QtCore.SIGNAL('disconnected'), self.onDisconnect)
+ self.disconnect(self.mpclient(), QtCore.SIGNAL('state_changed'), self.onStateChange)
+ self.disconnect(self.mpclient(), QtCore.SIGNAL('volume_changed'),self.onVolumeChange)
def getInfo(self):
return "Show interesting events in a popup window."
- def onSongChange(self, params):
+ def onSongChange(self):
song = self.mpclient().current_song()
if not song:
return
@@ -102,17 +111,17 @@ class Notify(Plugin):
NOTIFY_PRIORITY_SONG)
self.settings().endGroup()
- def onReady(self, params):
+ def onReady(self):
self.o.show('%s loaded'%APPNAME, self.settings().value(self.name() + '/timer').toInt()[0])
- def onDisconnect(self, params):
+ def onDisconnect(self):
self.o.show('Disconnected!', self.settings().value(self.name() + '/timer').toInt()[0])
- def onStateChange(self, params):
- self.o.show(params['newState'], self.settings().value(self.name() + '/timer').toInt()[0])
+ def onStateChange(self, new_state):
+ self.o.show(new_state, self.settings().value(self.name() + '/timer').toInt()[0])
- def onVolumeChange(self, params):
- self.o.show('Volume: %i%%'%(params['newVolume']), self.settings().value(self.name() + '/timer').toInt()[0], priority = NOTIFY_PRIORITY_VOLUME)
+ def onVolumeChange(self, new_vol):
+ self.o.show('Volume: %i%%'%(new_vol), self.settings().value(self.name() + '/timer').toInt()[0], priority = NOTIFY_PRIORITY_VOLUME)
class SettingsWidgetNotify(Plugin.SettingsWidget):
format = None