ocarina/ocarina/oldlibrary.py
Bryan Schumaker c3dbd8167d ocarina: Rename library.py -> oldlibrary.py
This reflects my recent libsaria change.  I'm keeping around my old
library code for now.  The new library will gradually be introduced
through several patches ending with the removal of the old library.
2011-05-20 21:29:30 -04:00

55 lines
1.1 KiB
Python

# Bryan Schumaker (11/26/2010)
import libsaria
import sources
import body
library = libsaria.sources.oldlibrary
lib_page = sources.Source()
LIB_PAGE = body.add_page(lib_page, "Old Library")
LIB_PAGE.goto = lib_page.goto
def set_label_text():
LIB_PAGE.label.set_text("Old 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)