From 22a72e66bd80d33921239152aefa60fa8d769910 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Wed, 3 Nov 2010 21:41:36 -0400 Subject: [PATCH 1/5] Added launcher bin/ocarina will be symlinked to /usr/bin/ocarina, and used to launch ocarina. --- bin/ocarina | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 bin/ocarina 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 $* From e67c8257c9e8d824d155439157819829d447bb01 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Wed, 3 Nov 2010 21:46:41 -0400 Subject: [PATCH 2/5] Makefile improvements The makefile now installs, uninstalls and updates an installed version of ocarina. The default "all" will run the program. --- Makefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 From 3ed0b10aab97566c67b33882bbba9440fd701062 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Wed, 3 Nov 2010 22:04:51 -0400 Subject: [PATCH 3/5] 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): From 5839190bb4e4ae41b4ef04be5309cf5bd22f216b Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Wed, 3 Nov 2010 22:15:03 -0400 Subject: [PATCH 4/5] Image.set_height() should return True or False If set_height() returns False, we know something went wrong and that we should try again using the default image. --- ocarina/image.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/ocarina/image.py b/ocarina/image.py index 951ed9d3..129786a1 100644 --- a/ocarina/image.py +++ b/ocarina/image.py @@ -15,18 +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) - 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): @@ -42,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) From aa098080ffd362f9ed083b985926e0795902c43f Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Wed, 3 Nov 2010 22:30:40 -0400 Subject: [PATCH 5/5] wm_tweaks icon changing Grab the gdk lock before changing the icon. For some reason changing the title already gets the lock, but changing the icon doesn't. --- plugins/wm_tweaks.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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: