diff options
author | Anton Khirnov <wyskas@gmail.com> | 2009-03-15 20:34:31 +0100 |
---|---|---|
committer | Anton Khirnov <wyskas@gmail.com> | 2009-03-15 20:34:31 +0100 |
commit | e52d79148fe6019a8359c614f3e7adc67dc53ca9 (patch) | |
tree | 8ebbec2855ee7b642884630881fb8f5832c288c2 | |
parent | c85d62d9f9a479468827fd7f09ded2fa878a4188 (diff) |
Songinfo: new plugin for displaying simple song info.
-rw-r--r-- | nephilim/plugins/Songinfo.py | 44 | ||||
-rw-r--r-- | nephilim/plugins/__init__.py | 2 |
2 files changed, 45 insertions, 1 deletions
diff --git a/nephilim/plugins/Songinfo.py b/nephilim/plugins/Songinfo.py new file mode 100644 index 0000000..84ed8cc --- /dev/null +++ b/nephilim/plugins/Songinfo.py @@ -0,0 +1,44 @@ +from PyQt4 import QtGui, QtCore + +from ..plugin import Plugin + +class Songinfo(Plugin): + o = None + def _load(self): + self.o = SonginfoWidget(self) + + def _unload(self): + self.o = None + + def info(self): + return 'Provides information about a song.' + + def _get_dock_widget(self): + return self._create_dock(self.o) + + +class SonginfoWidget(QtGui.QWidget): + plugin = None + labels = {} + + def __init__(self, plugin): + QtGui.QWidget.__init__(self) + self.plugin = plugin + + self.setLayout(QtGui.QVBoxLayout()) + + for item in 'track', 'title', 'album', 'disc', 'artist', 'composer', 'date', 'genre', 'file': + self.labels[item] = QtGui.QLabel('<b>%s</b>:'%item) + self.labels[item].setWordWrap(True) + self.layout().addWidget(self.labels[item]) + + self.connect(self.plugin.mpclient(), QtCore.SIGNAL('song_changed'), self.on_song_change) + + def on_song_change(self): + song = self.plugin.mpclient().current_song() + if not song: + for item in self.labels: + self.labels[item].setText('<b>%s</b>:'%item) + + for item in self.labels: + self.labels[item].setText('<b>%s</b>: %s'%(item, unicode(song.tag(item)))) diff --git a/nephilim/plugins/__init__.py b/nephilim/plugins/__init__.py index 84aa2e5..0d33fce 100644 --- a/nephilim/plugins/__init__.py +++ b/nephilim/plugins/__init__.py @@ -2,7 +2,7 @@ import sys import logging __all__ = ['AlbumCover', 'Filebrowser', 'Library', 'Lyrics', 'Notify', 'PlayControl', - 'Playlist', 'Systray'] + 'Playlist', 'Songinfo', 'Systray'] class Plugins: _plugins = None |