From 3ed0b10aab97566c67b33882bbba9440fd701062 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Wed, 3 Nov 2010 22:04:51 -0400 Subject: [PATCH] Only change play button when playing If no song is playing and the play button is clicked we shouldn't switch to the pause button. This could confuse users. --- libsaria/music/audio.py | 8 ++++++-- ocarina/button.py | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/libsaria/music/audio.py b/libsaria/music/audio.py index 9256a69e..04f994f7 100644 --- a/libsaria/music/audio.py +++ b/libsaria/music/audio.py @@ -127,24 +127,28 @@ def play_locked(): global gst global player player.set_state(gst.STATE_PLAYING) + return get_state_locked() == gst.STATE_PLAYING def play(): global lock lock.acquire() - play_locked() + ret = play_locked() lock.release() + return ret def pause_locked(): global gst global player player.set_state(gst.STATE_PAUSED) + return get_state_locked() == gst.STATE_PAUSED def pause(): global lock lock.acquire() - pause_locked() + ret = pause_locked() lock.release() + return ret def stop_locked(): pause_locked() diff --git a/ocarina/button.py b/ocarina/button.py index ddebfcc8..903cb6c4 100644 --- a/ocarina/button.py +++ b/ocarina/button.py @@ -17,7 +17,7 @@ class Button(gtk.Button): self.set_relief(gtk.RELIEF_NONE) self.click_id = self.connect("clicked", self.clicked) if show == True: - self.show() + Button.show(self) self.set_alignment(0,0) def clicked(self, button): @@ -38,7 +38,12 @@ class PlayButton(Button): LS.event.invite("POSTSTOP", self.show) def clicked(self, button): LS.music.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): @@ -48,6 +53,12 @@ class PauseButton(Button): LS.event.invite("POSTSTOP", self.hide) def clicked(self, button): LS.music.pause() + def hide(self, paused): + if paused == True: + Button.hide(self) + def show(self, playing): + if playing == True: + Button.show(self) class StopButton(Button):