ocarina: Pass attributes throughout the gui
This avoids repeated calls to the get_attrs() function at every step.
This commit is contained in:
parent
2c341085b4
commit
5fcb590f53
|
@ -61,9 +61,9 @@ def on_pause():
|
|||
tiny.on_pause()
|
||||
detailed.on_pause()
|
||||
|
||||
def on_load():
|
||||
tiny.on_load()
|
||||
detailed.on_load()
|
||||
def on_load(attrs):
|
||||
tiny.on_load(attrs)
|
||||
detailed.on_load(attrs)
|
||||
|
||||
def on_like(like):
|
||||
detailed.nowplaying.on_like(like)
|
||||
|
|
|
@ -73,6 +73,5 @@ def on_pause():
|
|||
PAUSE.hide()
|
||||
|
||||
load_attrs = ("title", "artist", "album", "year", "lenstr", "count", "like")
|
||||
def on_load():
|
||||
attrs = libsaria.sources.get_attrs(*load_attrs)
|
||||
nowplaying.on_load(*attrs)
|
||||
def on_load(attrs):
|
||||
nowplaying.on_load(attrs)
|
||||
|
|
|
@ -67,12 +67,12 @@ def on_like(like):
|
|||
button.toggle_call_unconnected(DISLIKE, _on_like1, like)
|
||||
button.toggle_call_unconnected(LIKE, _on_like0, like)
|
||||
|
||||
def on_load(title, artist, album, year, lenstr, count, like):
|
||||
TITLE.set_text(title)
|
||||
ARTIST.set_text("by %s" % artist)
|
||||
ALBUM.set_text("from %s" % album)
|
||||
YEAR.set_text("Year: %s" % year)
|
||||
LENGTH.set_text("Length: %s" % lenstr)
|
||||
COUNT.set_text("Play count: %s" % count)
|
||||
def on_load(attrs):
|
||||
TITLE.set_text(attrs["title"])
|
||||
ARTIST.set_text("by %s" % attrs["artist"])
|
||||
ALBUM.set_text("from %s" % attrs["album"])
|
||||
YEAR.set_text("Year: %s" % attrs["year"])
|
||||
LENGTH.set_text("Length: %s" % attrs["lenstr"])
|
||||
COUNT.set_text("Play count: %s" % attrs["count"])
|
||||
set_art("images/ocarina.png")
|
||||
on_like(like)
|
||||
on_like(attrs["like"])
|
||||
|
|
|
@ -59,9 +59,7 @@ def on_pause():
|
|||
PLAY.show()
|
||||
PAUSE.hide()
|
||||
|
||||
load_attrs = ("title", "artist", "lenstr")
|
||||
def on_load():
|
||||
title, artist, lenstr = libsaria.sources.get_attrs(*load_attrs)
|
||||
now_playing.set_text("%s by %s" % (title, artist))
|
||||
duration.set_text(" / %s" % lenstr)
|
||||
def on_load(attrs):
|
||||
now_playing.set_text("%s by %s" % (attrs["title"], attrs["artist"]))
|
||||
duration.set_text(" / %s" % attrs["lenstr"])
|
||||
set_art("images/ocarina.png")
|
||||
|
|
|
@ -76,7 +76,7 @@ class Image(gtk.EventBox):
|
|||
def clicked(self, widget, event):
|
||||
if event.button != 1:
|
||||
return
|
||||
id = sources.get_attrs("id")
|
||||
id = sources.get_cur_id()
|
||||
if id == -1:
|
||||
return
|
||||
path = fsselect.select_file("Select an image")
|
||||
|
|
|
@ -17,7 +17,7 @@ def on_pause():
|
|||
callbacks.on_pause = on_pause
|
||||
|
||||
def on_load(file, attrs):
|
||||
footer.on_load()
|
||||
footer.on_load(attrs)
|
||||
queue.refresh()
|
||||
body.cur_page_goto()
|
||||
libsaria.path.lastfm.get_artwork(file)
|
||||
|
@ -28,7 +28,7 @@ def on_like(like):
|
|||
callbacks.on_like = on_like
|
||||
|
||||
def on_get_art(path, id):
|
||||
cur_id = libsaria.sources.get_attrs("id")
|
||||
cur_id = libsaria.sources.get_cur_id()
|
||||
if [id] != cur_id:
|
||||
path = "images/ocarina.png"
|
||||
footer.set_art(path)
|
||||
|
|
|
@ -95,7 +95,7 @@ class ListView(gtk.TreeView):
|
|||
self.thaw()
|
||||
|
||||
def goto(self, *args):
|
||||
id = libsaria.sources.get_attrs("id")[0]
|
||||
id = libsaria.sources.get_cur_id()
|
||||
if id == -1: # Bad id
|
||||
return
|
||||
vis = self.get_visible_rect()
|
||||
|
|
Loading…
Reference in New Issue