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