More attribute labels

Year, count, length, and length2 labels have been created.  The length2
label adds a "/" before displaying the length of the current song.
This commit is contained in:
Bryan Schumaker 2010-10-23 15:35:16 -04:00
parent af8eb41589
commit f982fab96a
4 changed files with 43 additions and 30 deletions

View File

@ -71,7 +71,10 @@ def get_progress():
def get_time():
global audio
global tdelta
pos = audio.position() / 1000
pos = audio.position()
if pos == 0:
return ""
pos /= 1000
time = str(tdelta(microseconds=pos))
time = time.rsplit('.', 1)[0]
time = time.split(':', 1)[1]

View File

@ -58,6 +58,7 @@ class InfoBar(Bar):
self.pack(self.title, True, True)
self.pack(label.TimeLabel())
self.pack(label.LengthLabel2())
self.pack(button.PlayButton())
self.pack(button.PauseButton())
self.pack(button.StopButton())
@ -102,32 +103,23 @@ class InfoTab(gtk.Notebook):
self.cur_page = page_num
class NowPlaying(gtk.Table):
class NowPlaying(gtk.HBox):
def __init__(self):
gtk.Table.__init__(self, 3, 2, False)
self.artist = gtk.Label("")
self.album = gtk.Label("")
self.title = gtk.Label("")
#self.attach(gtk.Label("Artist"), 0, 1, 0, 1, gtk.SHRINK, 5, 5)
#self.attach(gtk.Label("Album"), 0, 1, 1, 2, gtk.SHRINK, 5, 5)
#self.attach(gtk.Label("Title"), 0, 1, 2, 3, gtk.SHRINK, 5, 5)
self.attach(label.ArtistLabel(), 1, 2, 0, 1, gtk.SHRINK|gtk.EXPAND|gtk.FILL, 5, 5)
self.attach(label.AlbumLabel(), 1, 2, 1, 2, gtk.SHRINK|gtk.EXPAND|gtk.FILL, 5, 5)
self.attach(label.TitleLabel(), 1, 2, 2, 3, gtk.SHRINK|gtk.EXPAND|gtk.FILL, 5, 5)
gtk.HBox.__init__(self, True)
self.artist.set_ellipsize(pango.ELLIPSIZE_END)
self.album.set_ellipsize(pango.ELLIPSIZE_END)
self.title.set_ellipsize(pango.ELLIPSIZE_END)
tags = gtk.VBox()
tags.pack_start(label.TitleLabel())
tags.pack_start(label.ArtistLabel())
tags.pack_start(label.AlbumLabel())
self.pack_start(tags, True, True)
attrs = gtk.VBox()
attrs.pack_start(label.YearLabel())
attrs.pack_start(label.LengthLabel())
attrs.pack_start(label.CountLabel())
self.pack_start(attrs)
self.show_all()
#libsaria.event.invite("POSTLOAD", self.change_labels)
#def change_labels(self, filepath):
# id = libsaria.collection.lib_find_id(filepath)
# if id:
# self.title.set_text(lib_get_attr(id, "title"))
# self.artist.set_text(lib_get_attr(id, "artist"))
# self.album.set_text(lib_get_attr(id, "album"))
class TwoWayPane(InfoBar):

View File

@ -31,15 +31,17 @@ class TimeLabel(gtk.Label):
def update(self):
global get_time
self.set_text(get_time())
self.set_text(get_time() + " ")
return True
class AttrLabel(gtk.Label):
class AttrLabel(gtk.Alignment):
def __init__(self, attr, other = None):
gtk.Label.__init__(self)
gtk.Alignment.__init__(self, 0, 0.5, 0, 0)
self.label = gtk.Label()
self.attr = attr
self.other = other
self.show()
self.add(self.label)
self.show_all()
invite("POSTLOAD", self.update)
def update(self, filepath):
@ -50,9 +52,9 @@ class AttrLabel(gtk.Label):
text = str(lib_get_attr(id, self.attr))
if self.other:
text = "%s %s" % (self.other, text)
self.set_text(text)
self.label.set_text(text)
else:
self.set_text("")
self.label.set_text("")
class TitleLabel(AttrLabel):
def __init__(self):
@ -65,3 +67,19 @@ class ArtistLabel(AttrLabel):
class AlbumLabel(AttrLabel):
def __init__(self):
AttrLabel.__init__(self, "album", "from")
class YearLabel(AttrLabel):
def __init__(self):
AttrLabel.__init__(self, "year", "Year:")
class CountLabel(AttrLabel):
def __init__(self):
AttrLabel.__init__(self, "playcount", "Play count:")
class LengthLabel(AttrLabel):
def __init__(self):
AttrLabel.__init__(self, "lenstr", "Length:")
class LengthLabel2(AttrLabel):
def __init__(self):
AttrLabel.__init__(self, "lenstr", "/")

View File

@ -20,7 +20,7 @@ class PBar(gtk.HScale):
adj = gtk.Adjustment(0.0, 0.0, 100.0, 0.1, 1.0, 1.0)
gtk.HScale.__init__(self, adj)
self.set_size_request(200, 20)
self.set_size_request(150, 20)
self.set_draw_value(False)
self.set_range(0, 101)
self.set_update_policy(gtk.UPDATE_DISCONTINUOUS)