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:
parent
254483dd5b
commit
2587ae0954
|
@ -6,6 +6,7 @@ from ocarina import body
|
||||||
from ocarina.body import footer
|
from ocarina.body import footer
|
||||||
from libsaria import callbacks
|
from libsaria import callbacks
|
||||||
import playlist
|
import playlist
|
||||||
|
import library
|
||||||
import oldlibrary
|
import oldlibrary
|
||||||
|
|
||||||
def on_play():
|
def on_play():
|
||||||
|
@ -42,6 +43,10 @@ def on_load_library():
|
||||||
oldlibrary.refresh()
|
oldlibrary.refresh()
|
||||||
callbacks.on_new_source = on_load_library
|
callbacks.on_new_source = on_load_library
|
||||||
|
|
||||||
|
def library_updated():
|
||||||
|
library.refresh()
|
||||||
|
callbacks.on_library_updated = library_updated
|
||||||
|
|
||||||
def on_queue_changed():
|
def on_queue_changed():
|
||||||
queue.refresh()
|
queue.refresh()
|
||||||
callbacks.on_queue_changed = on_queue_changed
|
callbacks.on_queue_changed = on_queue_changed
|
||||||
|
|
|
@ -1,8 +1,24 @@
|
||||||
# Bryan Schumaker (5 / 20 / 2011)
|
# Bryan Schumaker (5 / 20 / 2011)
|
||||||
|
|
||||||
|
import libsaria
|
||||||
import sources
|
import sources
|
||||||
import body
|
import body
|
||||||
|
|
||||||
|
library = libsaria.sources.library
|
||||||
lib_page = sources.Source()
|
lib_page = sources.Source()
|
||||||
LIB_PAGE = body.add_page(lib_page, "Library")
|
LIB_PAGE = body.add_page(lib_page, "Library")
|
||||||
LIB_PAGE.goto = lib_page.goto
|
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()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user