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.
This commit is contained in:
Bryan Schumaker 2011-05-20 21:29:30 -04:00
parent 531ceb2c17
commit c3dbd8167d
3 changed files with 57 additions and 3 deletions

View File

@ -22,7 +22,7 @@ def quit(window, event):
import window
import playlist
import queue
import library
import oldlibrary
import callbacks
def run():

View File

@ -6,7 +6,7 @@ from ocarina import body
from ocarina.body import footer
from libsaria import callbacks
import playlist
import library
import oldlibrary
def on_play():
footer.on_play()
@ -39,7 +39,7 @@ def on_load_playlist():
callbacks.on_load_playlist = on_load_playlist
def on_load_library():
library.refresh()
oldlibrary.refresh()
callbacks.on_new_source = on_load_library
def on_queue_changed():

54
ocarina/oldlibrary.py Normal file
View File

@ -0,0 +1,54 @@
# 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)