This clears whatever is on the current page and saves changes (in the case of the playlist and library)
71 lines
1.4 KiB
Python
71 lines
1.4 KiB
Python
# Bryan Schumaker (11/26/2010)
|
|
|
|
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():
|
|
songs = library.walk_library("id", "title", "lenstr", "artist", "album", "year")
|
|
lib_page.insert(songs)
|
|
set_label_text()
|
|
fill_library()
|
|
|
|
def refresh():
|
|
lib_page.clear()
|
|
fill_library()
|
|
|
|
def do_refilter(list, iter):
|
|
return library.is_visible(list[iter][0])
|
|
lib_page.set_filter_func(do_refilter)
|
|
|
|
def filter(text):
|
|
library.filter(text)
|
|
lib_page.refilter()
|
|
set_label_text()
|
|
LIB_PAGE.filter = filter
|
|
|
|
import playlist
|
|
import queue
|
|
|
|
def clear():
|
|
queue.clear()
|
|
playlist.clear()
|
|
lib_page.clear()
|
|
library.reset()
|
|
library.save()
|
|
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)
|
|
|
|
#def init():
|
|
#body.add_page("Library", lib_page)
|
|
#sources.init_src(library.init_bg, filler)
|
|
#libsaria.event.invite("POSTNEWSOURCE", refresh)
|
|
|
|
#def reset():
|
|
#import playlist
|
|
#playlist.reset()
|
|
#lib_page.clear()
|
|
#library.reset()
|
|
#library.save()
|
|
|
|
#def refresh(*args):
|
|
#lib_page.clear()
|
|
#lib_page.fill(library.walk)
|