diff --git a/ocarina/body/__init__.py b/ocarina/body/__init__.py index 92ea730f..728ea4ba 100644 --- a/ocarina/body/__init__.py +++ b/ocarina/body/__init__.py @@ -45,6 +45,9 @@ def cur_page_filter(text): def cur_page_goto(): current_page().goto() +def cur_page_clear(): + current_page().clear() + #import ocarina #Label = gtk.Label #prefs = ocarina.libsaria.prefs diff --git a/ocarina/body/button.py b/ocarina/body/button.py index 822efbe7..c7fed5a5 100644 --- a/ocarina/body/button.py +++ b/ocarina/body/button.py @@ -54,3 +54,6 @@ def next_button(show): def goto_button(goto_func, show): return make_button(gtk.STOCK_JUMP_TO, goto_func, "Go To Current Song", show) + +def clear_button(clear_func, show): + return make_button(gtk.STOCK_CLEAR, clear_func, "Clear Current Source", show) diff --git a/ocarina/body/header/__init__.py b/ocarina/body/header/__init__.py index 44d3b654..fc00e889 100644 --- a/ocarina/body/header/__init__.py +++ b/ocarina/body/header/__init__.py @@ -16,12 +16,17 @@ def goto_func(): from ocarina import body body.cur_page_goto() +def clear_func(): + from ocarina import body + body.cur_page_clear() + def add_button(name, button): globals()[name] = button header_body.pack_start(button, False, False) header_body.pack_start(entry.entry) -add_button("GOTO", button.goto_button(goto_func, True)) +add_button( "GOTO", button.goto_button(goto_func, True)) +add_button("CLEAR", button.clear_button(clear_func, True)) #import ocarina #from ocarina.components import button diff --git a/ocarina/body/page.py b/ocarina/body/page.py index 012cb7db..07004709 100644 --- a/ocarina/body/page.py +++ b/ocarina/body/page.py @@ -37,22 +37,11 @@ class OcarinaPage(gtk.Table): def filter(self, text): pass - def goto(self, text): + def goto(self): pass - #self.content = content - #self.attrs = content.__dict__ - #self.vis_func = self.attrs.get("visible", None) - #self.invis_func = self.attrs.get("invisible", None) - #self.add_header = add_header - #self.add_footer = add_footer - #self.show() - - #def reset(self): - #self.content.reset() - - #def goto(self): - #self.content.goto() + def clear(self): + pass #def visible(self): #if self.add_header == True: diff --git a/ocarina/components/button.py b/ocarina/components/button.py index ef9b511e..2a462e14 100644 --- a/ocarina/components/button.py +++ b/ocarina/components/button.py @@ -62,13 +62,6 @@ class ExportButton(Button): from libsaria.path import export export.export() -class GotoButton(Button): - def __init__(self): - Button.__init__(self, gtk.STOCK_JUMP_TO, "Go To Current Song") - def clicked(self, button): - from ocarina import body - body.cur_page_goto() - class UpdateButton(Button): def __init__(self): Button.__init__(self, gtk.STOCK_REFRESH, "Update Library") diff --git a/ocarina/library.py b/ocarina/library.py index 87212149..4844b5cc 100644 --- a/ocarina/library.py +++ b/ocarina/library.py @@ -18,6 +18,10 @@ def fill_library(): 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) @@ -30,6 +34,16 @@ 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), diff --git a/ocarina/playlist.py b/ocarina/playlist.py index aca8cd4a..30b013fd 100644 --- a/ocarina/playlist.py +++ b/ocarina/playlist.py @@ -32,6 +32,13 @@ def filter(text): set_label_text() PLAYLIST_PAGE.filter = filter +def clear(): + playlist_page.clear() + playlist.reset() + playlist.save() + refresh() +PLAYLIST_PAGE.clear = clear + def add_to_playlist(menu): ids = menu.source.get_selected_ids() playlist.add_ids(ids) diff --git a/ocarina/queue.py b/ocarina/queue.py index f4fdd53c..dadf6103 100644 --- a/ocarina/queue.py +++ b/ocarina/queue.py @@ -39,6 +39,12 @@ def filter(text): set_label_text() QUEUE_PAGE.filter = filter +def clear(): + queue_page.clear() + queue.reset() + refresh() +QUEUE_PAGE.clear = clear + def add_to_queue(menu): ids = menu.source.get_selected_ids() queue.add_ids(ids) @@ -66,10 +72,6 @@ queue_page.set_right_click(show_menu) #menu.add_queue_menu_item("Remove from queue", rm_selected_from_queue) #queue_page.fill(queue.walk, True) -#def reset(): - #queue_page.clear() - #queue.reset() - #def play_id(id): #queue.play_id(id) #refresh()