6d08dedba5
This function is similar to the add_to_playlist() function I recently added. The idea is to have the queue add things to itself, rather than having the playlist and library implement this function independently.
59 lines
1.3 KiB
Python
59 lines
1.3 KiB
Python
# Bryan Schumaker (11/26/2010)
|
|
|
|
import ocarina
|
|
from ocarina import body
|
|
from ocarina import source
|
|
import menu
|
|
|
|
gtk = ocarina.gtk
|
|
sources = ocarina.libsaria.sources
|
|
playlist = sources.playlist
|
|
visible = playlist.is_visible
|
|
|
|
plist_page = source.Source()
|
|
|
|
def init():
|
|
body.add_page("Playlist", plist_page)
|
|
sources.init_src(playlist.init_bg, filler)
|
|
|
|
def filler():
|
|
plist_page.init(filter, is_visible, right_click, playlist.play_id, reset)
|
|
menu.add_plist_menu_item("Add to queue", add_selected_to_queue)
|
|
menu.add_plist_menu_item("Remove from playlist", rm_selected_from_playlist)
|
|
ocarina.libsaria.event.invite("POSTLOADPLAYLIST", refresh)
|
|
plist_page.fill(playlist.walk, True)
|
|
|
|
def filter(text):
|
|
playlist.filter(text)
|
|
plist_page.refilter()
|
|
plist_page.goto()
|
|
|
|
def is_visible(list, iter):
|
|
return visible(list[iter][0])
|
|
|
|
def reset():
|
|
plist_page.clear()
|
|
playlist.reset()
|
|
playlist.save()
|
|
|
|
def refresh(*args):
|
|
plist_page.clear()
|
|
plist_page.fill(playlist.walk)
|
|
|
|
def right_click(button, time):
|
|
menu.make_plist_menu(button, time)
|
|
|
|
def rm_selected_from_playlist(menu):
|
|
plist_page.for_each_selected_id(playlist.rm_id)
|
|
playlist.save()
|
|
refresh()
|
|
|
|
def add_to_playlist(source_page):
|
|
source_page.for_each_selected_id(playlist.add_id)
|
|
playlist.save()
|
|
refresh()
|
|
|
|
def add_selected_to_queue(menu):
|
|
import queue
|
|
queue.add_to_queue(plist_page)
|