From 5b5a232b43c470bca4361c2301debd574db773f3 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Wed, 20 Apr 2011 19:44:45 -0400 Subject: [PATCH] ocarina: Add more callbacks This should make the code more readable and useable --- ocarina/callbacks.py | 9 +++++++++ ocarina/components/button.py | 30 ------------------------------ ocarina/queue.py | 1 - 3 files changed, 9 insertions(+), 31 deletions(-) diff --git a/ocarina/callbacks.py b/ocarina/callbacks.py index 5922d4f5..40e70906 100644 --- a/ocarina/callbacks.py +++ b/ocarina/callbacks.py @@ -1,6 +1,7 @@ # Bryan Schumaker (4 / 20 / 2011) import libsaria +import queue from ocarina.body import footer invite = libsaria.event.invite @@ -12,3 +13,11 @@ invite("POSTPLAY", on_play) def on_pause(*args): footer.on_pause() invite("POSTPAUSE", on_pause) + +def on_stop(*args): + footer.on_pause() +invite("POSTSTOP", on_stop) + +def on_next(*args): + queue.refresh() +invite("POSTNEXT", on_next) diff --git a/ocarina/components/button.py b/ocarina/components/button.py index 9851997d..ef9b511e 100644 --- a/ocarina/components/button.py +++ b/ocarina/components/button.py @@ -30,36 +30,6 @@ class Button(gtk.Button): def hide(self, *args): gtk.Button.hide(self) -class PlayButton(Button): - def __init__(self): - Button.__init__(self, gtk.STOCK_MEDIA_PLAY, "Play") - invite("POSTPLAY", self.hide) - invite("POSTPAUSE", self.show) - invite("POSTSTOP", self.show) - def clicked(self, button): - LS.controls.play() - def hide(self, playing): - if playing == True: - Button.hide(self) - def show(self, paused): - if paused == True: - Button.show(self) - -class PauseButton(Button): - def __init__(self): - Button.__init__(self, gtk.STOCK_MEDIA_PAUSE, "Pause", show=False) - invite("POSTPLAY", self.show) - invite("POSTPAUSE", self.hide) - invite("POSTSTOP", self.hide) - def clicked(self, button): - LS.controls.pause() - def hide(self, paused): - if paused == True: - Button.hide(self) - def show(self, playing): - if playing == True: - Button.show(self) - class OpenButton(Button): def __init__(self): Button.__init__(self, gtk.STOCK_OPEN, "Open Anything") diff --git a/ocarina/queue.py b/ocarina/queue.py index f207b186..826c259d 100644 --- a/ocarina/queue.py +++ b/ocarina/queue.py @@ -64,7 +64,6 @@ queue_page.set_right_click(show_menu) #queue_page.init(filter, is_visible, right_click, play_id, reset) #menu.add_queue_menu_item("Remove from queue", rm_selected_from_queue) #queue_page.fill(queue.walk, True) - #ocarina.libsaria.event.invite("POSTNEXT", refresh) #def reset(): #queue_page.clear()