Plugins: quod_dbus_cover.py

File quod_dbus_cover.py, 1.5 kB (added by sandi.newton@gmail.com, 1 year ago)

DBUS plugin for AWN

Line 
1 # Album Cover Plugin code changed for awn pleasure
2 # Shameless Modified By: sandic
3 # TODO: Reset icon to default when quodlibet quits(there seems to be no handler for that,or may be I didnt go through plugins/event.py properly)
4 # TODO: Progress icon over album art
5 # Original Copyright 2005 Joe Wreschnig
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 2 as
9 # published by the Free Software Foundation
10 #
11 # $Id$
12 import config
13 import shutil
14 #import gtk be needed for xid
15 import dbus
16 from plugins.events import EventPlugin
17 awn = ''
18 out = "/tmp/current.cover"
19 class PictureSaver(EventPlugin):
20     PLUGIN_ID = "AWN Album Art Display"
21     PLUGIN_NAME = _("AWN Album Art Display")
22     PLUGIN_DESC = "The cover image is shown in AWN's quodlibet icon"
23     PLUGIN_VERSION = "0.1"
24     def __init__(self):
25         global awn
26         bus_obj = dbus.SessionBus().get_object("com.google.code.Awn", "/com/google/code/Awn")
27         awn = dbus.Interface(bus_obj, "com.google.code.Awn")
28     def plugin_on_song_started(self, song):
29         global awn
30         if song is None:
31                 awn.UnsetTaskIconByName("quodlibet")
32         else:
33             cover = song.find_cover()
34             if cover is None:
35                 awn.UnsetTaskIconByName("quodlibet")
36             else:
37                 f = file(out, "wb")
38                 f.write(cover.read())
39                 f.close()
40                 awn.SetTaskIconByName("quodlibet", out)
41     def disabled(self):
42         global awn
43         awn.UnsetTaskIconByName("quodlibet")
44     def destroy(self):
45         global awn
46         awn.UnsetTaskIconByName("quodlibet")