ocarina: Fill new library

I make the list of songs visible, I also update the number of songs.
Finally, I respond to the library_updated() callback when songs are
added / removed from the library.
This commit is contained in:
Bryan Schumaker 2011-05-21 08:20:44 -04:00
parent 254483dd5b
commit 2587ae0954
2 changed files with 21 additions and 0 deletions

View File

@ -6,6 +6,7 @@ from ocarina import body
from ocarina.body import footer
from libsaria import callbacks
import playlist
import library
import oldlibrary
def on_play():
@ -42,6 +43,10 @@ def on_load_library():
oldlibrary.refresh()
callbacks.on_new_source = on_load_library
def library_updated():
library.refresh()
callbacks.on_library_updated = library_updated
def on_queue_changed():
queue.refresh()
callbacks.on_queue_changed = on_queue_changed

View File

@ -1,8 +1,24 @@
# Bryan Schumaker (5 / 20 / 2011)
import libsaria
import sources
import body
library = libsaria.sources.library
lib_page = sources.Source()
LIB_PAGE = body.add_page(lib_page, "Library")
LIB_PAGE.goto = lib_page.goto
def set_label_text():
LIB_PAGE.label.set_text("Library (%s)" % library.num_visible())
def fill_library():
attrs = ("id", "title", "lenstr", "artist", "album", "year")
songs = libsaria.sources.list_library(*attrs)
lib_page.insert(songs)
set_label_text()
fill_library()
def refresh():
lib_page.clear()
fill_library()