diff --git a/libsaria/music/__init__.py b/libsaria/music/__init__.py index 9f1703f0..26044204 100644 --- a/libsaria/music/__init__.py +++ b/libsaria/music/__init__.py @@ -52,6 +52,11 @@ def stop(): return call("STOP", audio.stop) +def seek(prcnt): + global audio + return call("SEEK", audio.seek, prcnt) + + def get_progress(): global audio dur = audio.duration() diff --git a/ocarina.py b/ocarina.py index 137d94ab..8abd4ca0 100755 --- a/ocarina.py +++ b/ocarina.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2 # Bryan Schumaker (8/13/2010) import datetime diff --git a/ocarina/info.py b/ocarina/info.py index b350ea77..f74c6cf5 100644 --- a/ocarina/info.py +++ b/ocarina/info.py @@ -6,6 +6,7 @@ libsaria = ocarina.libsaria button = None entry = None pbar = None +label = None lib_get_cur_id = libsaria.collection.lib_get_cur_id lib_get_attr = libsaria.collection.lib_get_attr @@ -50,7 +51,9 @@ class InfoBar(Bar): self.title = gtk.Label("Ocarina 4.1") self.title.show() + self.pack(self.title, True, True) + self.pack(label.TimeLabel()) self.pack(button.PlayButton()) self.pack(button.PauseButton()) self.pack(button.StopButton()) @@ -73,6 +76,7 @@ class InfoTab(gtk.Notebook): hbox = gtk.HBox() hbox.show() + hbox.pack_start(label.TimeLabel()) hbox.pack_start(pbar.PBar(), True, True) hbox.pack_start(button.PlayButton()) hbox.pack_start(button.PauseButton()) @@ -115,10 +119,12 @@ def init(): global button global entry global pbar + global label import button import entry import pbar + import label info = TwoWayPane() filter = FilterBar() diff --git a/ocarina/pbar.py b/ocarina/pbar.py index ff0fbfaf..86db9162 100644 --- a/ocarina/pbar.py +++ b/ocarina/pbar.py @@ -4,37 +4,36 @@ import ocarina gtk = ocarina.gtk gobject = ocarina.gobject update = None -get_time = None +seek = None def set_fns(): global update global get_time + global seek update = ocarina.libsaria.music.get_progress - get_time = ocarina.libsaria.music.get_time + seek = ocarina.libsaria.music.seek ocarina.libsaria.event.invite("POSTSTART", set_fns) -#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) + adj = gtk.Adjustment(0.0, 0.0, 100.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_size_request(200, 20) + self.set_draw_value(False) self.set_range(0, 101) - self.connect("format-value", self.format_value) + self.set_update_policy(gtk.UPDATE_DISCONTINUOUS) + self.connect("value-changed", self.value_changed) gobject.timeout_add(500, self.update) self.show() - def format_value(self, scale, value): - return get_time() - def update(self): global update self.set_value(update() * 100) return True + + def value_changed(self, scale): + global seek + value = scale.get_value() + seek(value / 100.0) diff --git a/plugins/web_radio.py b/plugins/web_radio.py index dc1bd29c..7f521051 100644 --- a/plugins/web_radio.py +++ b/plugins/web_radio.py @@ -33,10 +33,6 @@ def start(): global children import webkit - #google = WebPage("http://www.google.com") - #children.append("Google") - #ocarina.add_tab("Google", google) - pandora = WebPage("http://www.pandora.com") children.append("Pandora") ocarina.add_tab("Pandora", pandora)