diff --git a/ocarina/body/__init__.py b/ocarina/body/__init__.py index 40417f71..92ea730f 100644 --- a/ocarina/body/__init__.py +++ b/ocarina/body/__init__.py @@ -42,6 +42,9 @@ def switch_page(notebook, page, pagenum): def cur_page_filter(text): current_page().filter(text) +def cur_page_goto(): + current_page().goto() + #import ocarina #Label = gtk.Label #prefs = ocarina.libsaria.prefs diff --git a/ocarina/body/button.py b/ocarina/body/button.py index 19393250..822efbe7 100644 --- a/ocarina/body/button.py +++ b/ocarina/body/button.py @@ -51,3 +51,6 @@ def stop_button(show): def next_button(show): return make_button(gtk.STOCK_MEDIA_NEXT, controls.next, "Next", show) + +def goto_button(goto_func, show): + return make_button(gtk.STOCK_JUMP_TO, goto_func, "Go To Current Song", show) diff --git a/ocarina/body/header/__init__.py b/ocarina/body/header/__init__.py index 53f75482..44d3b654 100644 --- a/ocarina/body/header/__init__.py +++ b/ocarina/body/header/__init__.py @@ -1,7 +1,7 @@ # Bryan Schumaker (11/25/2010) import gtk -from ocarina.body.button import make_button +from ocarina.body import button import entry header = gtk.VBox() @@ -12,7 +12,16 @@ header.pack_start(header_body) header.pack_start(header_sep) header.show_all() +def goto_func(): + from ocarina import body + body.cur_page_goto() + +def add_button(name, button): + globals()[name] = button + header_body.pack_start(button, False, False) + header_body.pack_start(entry.entry) +add_button("GOTO", button.goto_button(goto_func, True)) #import ocarina #from ocarina.components import button diff --git a/ocarina/body/page.py b/ocarina/body/page.py index d2b198d5..012cb7db 100644 --- a/ocarina/body/page.py +++ b/ocarina/body/page.py @@ -37,6 +37,9 @@ class OcarinaPage(gtk.Table): def filter(self, text): pass + def goto(self, text): + pass + #self.content = content #self.attrs = content.__dict__ #self.vis_func = self.attrs.get("visible", None) diff --git a/ocarina/callbacks.py b/ocarina/callbacks.py index c674ff42..166c6c6a 100644 --- a/ocarina/callbacks.py +++ b/ocarina/callbacks.py @@ -2,6 +2,7 @@ import libsaria import queue +from ocarina import body from ocarina.body import footer invite = libsaria.event.invite @@ -21,4 +22,5 @@ invite("POSTSTOP", on_stop) def on_load(*args): footer.on_load() queue.refresh() + body.cur_page_goto() invite("POSTLOAD", on_load) diff --git a/ocarina/library.py b/ocarina/library.py index d06af8f7..87212149 100644 --- a/ocarina/library.py +++ b/ocarina/library.py @@ -7,6 +7,7 @@ import body library = libsaria.sources.library lib_page = sources.Source() LIB_PAGE = body.add_page(lib_page, "Library") +LIB_PAGE.goto = lib_page.goto def set_label_text(): LIB_PAGE.label.set_text("Library (%s)" % library.num_visible()) diff --git a/ocarina/playlist.py b/ocarina/playlist.py index 21edf942..aca8cd4a 100644 --- a/ocarina/playlist.py +++ b/ocarina/playlist.py @@ -7,6 +7,7 @@ import body playlist = libsaria.sources.playlist playlist_page = sources.Source() PLAYLIST_PAGE = body.add_page(playlist_page, "Playlist") +PLAYLIST_PAGE.goto = playlist_page.goto def set_label_text(): PLAYLIST_PAGE.label.set_text("Playlist (%s)" % playlist.num_visible()) diff --git a/ocarina/queue.py b/ocarina/queue.py index 826c259d..f4fdd53c 100644 --- a/ocarina/queue.py +++ b/ocarina/queue.py @@ -7,6 +7,7 @@ import body queue = libsaria.sources.queue queue_page = sources.Source() QUEUE_PAGE = body.add_page(queue_page, "Queue") +QUEUE_PAGE.goto = queue_page.goto def set_label_text(): QUEUE_PAGE.label.set_text("Queue (%s)" % queue.num_visible()) diff --git a/ocarina/sources/__init__.py b/ocarina/sources/__init__.py index 55ff05af..777fe33b 100644 --- a/ocarina/sources/__init__.py +++ b/ocarina/sources/__init__.py @@ -23,3 +23,4 @@ class Source(gtk.ScrolledWindow): self.refilter = self.listview.refilter self.insert = self.listview.insert_rows self.clear = self.listview.clear + self.goto = self.listview.goto diff --git a/ocarina/sources/listview.py b/ocarina/sources/listview.py index 7d082b10..80dc7711 100644 --- a/ocarina/sources/listview.py +++ b/ocarina/sources/listview.py @@ -99,25 +99,25 @@ class ListView(gtk.TreeView): self.filter_model.refilter() self.thaw() - #def goto(self, *args): - #id = sources.get_attrs("id") - #if id == -1: # Bad id - #return - #vis = self.get_visible_rect() - #if vis[3] == 0: # The widget hasn't been realized yet - #return - #for index, row in enumerate(self.filter_model): - #if row[0] == id: - #col = self.get_column(0) - #row_vis = self.get_cell_area(index, col) - #if row_vis[3] > 0: - #n = vis[3] / row_vis[3] - #path = index - (n / 2) - #if path < 0: - #path = 0 - #self.scroll_to_cell(path, None, True, 0, 0) - #self.set_cursor_on_cell(index, None, None, False) - #return + def goto(self, *args): + id = libsaria.sources.get_attrs("id") + if id == -1: # Bad id + return + vis = self.get_visible_rect() + if vis[3] == 0: # The widget hasn't been realized yet + return + for index, row in enumerate(self.filter_model): + if row[0] == id: + col = self.get_column(0) + row_vis = self.get_cell_area(index, col) + if row_vis[3] > 0: + n = vis[3] / row_vis[3] + path = index - (n / 2) + if path < 0: + path = 0 + self.scroll_to_cell(path, None, True, 0, 0) + self.set_cursor_on_cell(index, None, None, False) + return #def query_tooltip(self, widget, x, y, keyboard, tip): #row = self.get_dest_row_at_pos(x,y)