Each source was doing the exact same thing for filtering now that I have a generic is_visible() function. There is no need for each source to implement this.
49 lines
964 B
Python
49 lines
964 B
Python
# 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()
|
|
|
|
def refilter():
|
|
lib_page.refilter()
|
|
set_label_text()
|
|
|
|
import playlist
|
|
import queue
|
|
|
|
def clear():
|
|
queue.clear()
|
|
playlist.clear()
|
|
library.reset()
|
|
lib_page.clear()
|
|
refresh()
|
|
LIB_PAGE.clear = clear
|
|
|
|
menu_items = [
|
|
("Add to Queue", queue.add_to_queue),
|
|
("Add to Playlist", playlist.add_to_playlist),
|
|
]
|
|
def show_menu(event):
|
|
m = sources.Menu(lib_page, menu_items)
|
|
m.show(event)
|
|
lib_page.set_right_click(show_menu)
|