From eb7932fad290d1ff4fcc13296c620ae098ed5932 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Mon, 11 Oct 2010 20:48:43 -0400 Subject: [PATCH] Added the beginnings of a progress bar --- libsaria/music/audio.py | 7 +++++-- ocarina/button.py | 6 ++++++ ocarina/info.py | 7 +++++++ ocarina/pbar.py | 24 ++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 ocarina/pbar.py diff --git a/libsaria/music/audio.py b/libsaria/music/audio.py index 6f9a7a08..71149a6a 100644 --- a/libsaria/music/audio.py +++ b/libsaria/music/audio.py @@ -93,8 +93,11 @@ def seek(prcnt): global player global time global gst - spot = duration() * prcnt - player.seek_simple(time, gst.SEEK_FLAG_FLUSH, spot) + try: + spot = duration() * prcnt + player.seek_simple(time, gst.SEEK_FLAG_FLUSH, spot) + except: + pass def volume(prcnt): diff --git a/ocarina/button.py b/ocarina/button.py index 9e30811a..57f87a53 100644 --- a/ocarina/button.py +++ b/ocarina/button.py @@ -48,6 +48,12 @@ class PauseButton(Button): LS.music.pause() +class StopButton(Button): + def __init__(self): + Button.__init__(self, gtk.STOCK_MEDIA_STOP) + def clicked(self, button): + LS.music.stop() + class OpenButton(Button): def __init__(self): Button.__init__(self, gtk.STOCK_OPEN) diff --git a/ocarina/info.py b/ocarina/info.py index b13618ce..a578b39f 100644 --- a/ocarina/info.py +++ b/ocarina/info.py @@ -5,6 +5,7 @@ gtk = ocarina.gtk libsaria = ocarina.libsaria button = None entry = None +pbar = None lib_get_cur_id = libsaria.collection.lib_get_cur_id lib_get_attr = libsaria.collection.lib_get_attr @@ -52,6 +53,7 @@ class InfoBar(Bar): self.pack(self.title, True, True) self.pack(button.PlayButton()) self.pack(button.PauseButton()) + self.pack(button.StopButton()) self.pack(button.UpButton(up_button)) libsaria.event.invite("POSTLOAD", self.change_title) @@ -69,8 +71,11 @@ class InfoTab(gtk.Notebook): hbox = gtk.HBox() hbox.show() + + hbox.pack_start(pbar.PBar(), True, True) hbox.pack_start(button.PlayButton()) hbox.pack_start(button.PauseButton()) + hbox.pack_start(button.StopButton()) hbox.pack_start(button.DownButton(down_button)) self.set_action_widget(hbox, gtk.PACK_END) @@ -108,9 +113,11 @@ def init(): global filter global button global entry + global pbar import button import entry + import pbar info = TwoWayPane() filter = FilterBar() diff --git a/ocarina/pbar.py b/ocarina/pbar.py new file mode 100644 index 00000000..52bcce71 --- /dev/null +++ b/ocarina/pbar.py @@ -0,0 +1,24 @@ +# Bryan Schumaker (10/11/2010) + +import ocarina +gtk = ocarina.gtk + +#class PBar(gtk.ProgressBar): +# def __init__(self): +# gtk.ProgressBar.__init__(self) +# self.set_size_request(300, 20) +# self.show() +# print self.size_request() + +class PBar(gtk.HScale): + def __init__(self): + adj = gtk.Adjustment(0.0, 0.0, 101.0, 0.1, 1.0, 1.0) + gtk.HScale.__init__(self, adj) + self.set_size_request(300, 20) + self.set_value_pos(gtk.POS_LEFT) + self.set_range(0, 101) + self.connect("format-value", self.format_value) + self.show() + + def format_value(self, scale, value): + return "00:00"