2010-11-26 23:31:12 -05:00
|
|
|
# Bryan Schumaker (11/26/2010)
|
|
|
|
|
2011-04-18 22:29:26 -04:00
|
|
|
import libsaria
|
2011-04-18 20:39:07 -04:00
|
|
|
import sources
|
|
|
|
import body
|
|
|
|
|
2011-04-18 22:29:26 -04:00
|
|
|
playlist = libsaria.sources.playlist
|
2011-04-18 20:39:07 -04:00
|
|
|
playlist_page = sources.Source()
|
|
|
|
PLAYLIST_PAGE = body.add_page(playlist_page, "Playlist")
|
2011-04-20 21:07:00 -04:00
|
|
|
PLAYLIST_PAGE.goto = playlist_page.goto
|
2011-04-18 20:39:07 -04:00
|
|
|
|
2011-04-18 22:29:26 -04:00
|
|
|
def set_label_text():
|
|
|
|
PLAYLIST_PAGE.label.set_text("Playlist (%s)" % playlist.num_visible())
|
|
|
|
|
|
|
|
def fill_playlist():
|
2011-05-25 23:01:17 -04:00
|
|
|
songs = libsaria.sources.list_playlist(*sources.column.attrs)
|
2011-04-18 22:29:26 -04:00
|
|
|
playlist_page.insert(songs)
|
|
|
|
set_label_text()
|
|
|
|
fill_playlist()
|
|
|
|
|
2011-04-18 22:34:15 -04:00
|
|
|
def refresh():
|
|
|
|
playlist_page.clear()
|
|
|
|
fill_playlist()
|
|
|
|
|
2011-05-22 09:25:47 -04:00
|
|
|
def refilter():
|
2011-04-18 22:29:26 -04:00
|
|
|
playlist_page.refilter()
|
2011-04-21 08:28:27 -04:00
|
|
|
playlist_page.goto()
|
2011-04-18 22:29:26 -04:00
|
|
|
set_label_text()
|
|
|
|
|
2011-04-20 22:07:05 -04:00
|
|
|
def clear():
|
|
|
|
playlist_page.clear()
|
|
|
|
playlist.reset()
|
|
|
|
refresh()
|
|
|
|
PLAYLIST_PAGE.clear = clear
|
|
|
|
|
2011-04-18 22:34:15 -04:00
|
|
|
def add_to_playlist(menu):
|
|
|
|
ids = menu.source.get_selected_ids()
|
|
|
|
playlist.add_ids(ids)
|
|
|
|
refresh()
|
|
|
|
|
2011-04-18 22:38:47 -04:00
|
|
|
def rm_from_playlist(menu):
|
|
|
|
ids = menu.source.get_selected_ids()
|
|
|
|
playlist.rm_ids(ids)
|
|
|
|
refresh()
|
2011-04-18 20:39:07 -04:00
|
|
|
|
2011-04-18 22:38:47 -04:00
|
|
|
import queue
|
|
|
|
menu_items = [
|
2011-04-18 23:01:59 -04:00
|
|
|
("Add to Queue", queue.add_to_queue),
|
2011-04-18 22:38:47 -04:00
|
|
|
("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)
|