ocarina/ocarina/playlist.py
Bryan Schumaker 43f37c93a7 ocarina: Do filtering in the listview
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.
2011-05-22 09:43:27 -04:00

56 lines
1.2 KiB
Python

# Bryan Schumaker (11/26/2010)
import libsaria
import sources
import body
playlist = libsaria.sources.playlist
playlist_page = sources.Source()
PLAYLIST_PAGE = body.add_page(playlist_page, "Playlist")
PLAYLIST_PAGE.goto = playlist_page.goto
def set_label_text():
PLAYLIST_PAGE.label.set_text("Playlist (%s)" % playlist.num_visible())
def fill_playlist():
attrs = ("id", "title", "lenstr", "artist", "album", "year")
songs = libsaria.sources.list_playlist(*attrs)
playlist_page.insert(songs)
set_label_text()
fill_playlist()
def refresh():
playlist_page.clear()
fill_playlist()
def refilter():
playlist_page.refilter()
playlist_page.goto()
set_label_text()
def clear():
playlist_page.clear()
playlist.reset()
refresh()
PLAYLIST_PAGE.clear = clear
def add_to_playlist(menu):
ids = menu.source.get_selected_ids()
playlist.add_ids(ids)
refresh()
def rm_from_playlist(menu):
ids = menu.source.get_selected_ids()
playlist.rm_ids(ids)
refresh()
import queue
menu_items = [
("Add to Queue", queue.add_to_queue),
("Remove from Playlist", rm_from_playlist),
]
def show_menu(event):
m = sources.Menu(playlist_page, menu_items)
m.show(event)
playlist_page.set_right_click(show_menu)