diff --git a/Makefile b/Makefile index 16c4e674..80506a78 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,16 @@ +all: + python2 ocarina.py clean: rm `find . | grep .pyc` + +install: + cd /opt/ && git clone http://lavos.homelinux.com/~bjschuma/git/ocarina.git + cd /usr/bin && ln -s /opt/ocarina/bin/ocarina . + +uninstall: + rm -rIf /opt/ocarina + rm -f /usr/bin/ocarina +update: + cd /opt/ocarina && git pull diff --git a/bin/ocarina b/bin/ocarina new file mode 100755 index 00000000..9a90fd06 --- /dev/null +++ b/bin/ocarina @@ -0,0 +1,2 @@ +#!/bin/bash +cd /opt/ocarina && `which python2` ocarina.py $* 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 9ef16e6a..18a6a5cc 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): diff --git a/ocarina/image.py b/ocarina/image.py index 5ff7b292..129786a1 100644 --- a/ocarina/image.py +++ b/ocarina/image.py @@ -15,19 +15,22 @@ class Image(gtk.Image): def set_height(self, new_h): buf = self.get_pixbuf() if buf == None: - return + return False w = buf.get_width() h = buf.get_height() if h == new_h: - return + return False if h == 0: h = 1 new_w = (float(w) / float(h)) * new_h - if new_w > 0 and new_h > 0: - buf = buf.scale_simple(int(new_w), int(new_h), gtk.gdk.INTERP_HYPER) - if buf != None: - self.set_from_pixbuf(buf) + if new_w <= 0 or new_h <= 0: + return False + buf = buf.scale_simple(int(new_w), int(new_h), gtk.gdk.INTERP_HYPER) + if buf == None: + return False + self.set_from_pixbuf(buf) + return True class AlbumArt(Image): def __init__(self): @@ -43,14 +46,16 @@ class AlbumArt(Image): def set(self, file=None): gdk.threads_enter() - if file != None: + for i in xrange(2): self.file = file - self.set_from_file(self.file) - self.set_height(64) + self.set_from_file(self.file) + if self.set_height(64) == True: + break + file = "images/ocarina.png" gdk.threads_leave() def set_height(self, new_h): size = self.size_request() if size[1] == new_h: return - Image.set_height(self, new_h) + return Image.set_height(self, new_h) diff --git a/plugins/wm_tweaks.py b/plugins/wm_tweaks.py index 42dbabb6..8fbcf1c2 100644 --- a/plugins/wm_tweaks.py +++ b/plugins/wm_tweaks.py @@ -1,6 +1,7 @@ # Bryan Schumaker (10/30/2010) import ocarina +gdk = ocarina.gdk libsaria = ocarina.libsaria lib_find_id = libsaria.collection.lib_find_id lib_get_attr = libsaria.collection.lib_get_attr @@ -8,10 +9,11 @@ invite = libsaria.event.invite def tweak_icon(file): - if file != None: - ocarina.set_window_icon(file) - else: - ocarina.set_window_icon("images/ocarina.png") + if file == None: + file = "images/ocarina.png" + gdk.threads_enter() + ocarina.set_window_icon(file) + gdk.threads_leave() def tweak_title(filepath): if filepath != None: