68 lines
1.5 KiB
Python
68 lines
1.5 KiB
Python
# Bryan Schumaker (10 / 18 / 2010)
|
|
import ocarina
|
|
|
|
gtk = ocarina.gtk
|
|
gobject = ocarina.gobject
|
|
invite = ocarina.libsaria.event.invite
|
|
libsaria = ocarina.libsaria
|
|
|
|
#update = None
|
|
get_time = None
|
|
lib_get_attr = None
|
|
lib_find_id = None
|
|
|
|
def set_fns():
|
|
#global update
|
|
global get_time
|
|
global lib_get_attr
|
|
global lib_find_id
|
|
#update = ocarina.libsaria.music.get_progress
|
|
get_time = ocarina.libsaria.music.get_time
|
|
lib_get_attr = libsaria.collection.lib_get_attr
|
|
lib_find_id = libsaria.collection.lib_find_id
|
|
invite("POSTSTART", set_fns)
|
|
|
|
|
|
class TimeLabel(gtk.Label):
|
|
def __init__(self):
|
|
gtk.Label.__init__(self)
|
|
gobject.timeout_add(500, self.update)
|
|
self.show()
|
|
|
|
def update(self):
|
|
global get_time
|
|
self.set_text(get_time())
|
|
return True
|
|
|
|
class AttrLabel(gtk.Label):
|
|
def __init__(self, attr, other = None):
|
|
gtk.Label.__init__(self)
|
|
self.attr = attr
|
|
self.other = other
|
|
self.show()
|
|
invite("POSTLOAD", self.update)
|
|
|
|
def update(self, filepath):
|
|
global lib_find_id
|
|
global lib_get_attr
|
|
id = lib_find_id(filepath)
|
|
if id:
|
|
text = str(lib_get_attr(id, self.attr))
|
|
if self.other:
|
|
text = "%s %s" % (self.other, text)
|
|
self.set_text(text)
|
|
else:
|
|
self.set_text("")
|
|
|
|
class TitleLabel(AttrLabel):
|
|
def __init__(self):
|
|
AttrLabel.__init__(self, "title")
|
|
|
|
class ArtistLabel(AttrLabel):
|
|
def __init__(self):
|
|
AttrLabel.__init__(self, "artist", "by")
|
|
|
|
class AlbumLabel(AttrLabel):
|
|
def __init__(self):
|
|
AttrLabel.__init__(self, "album", "from")
|