ocarina: goto current song

I do this when the goto button is pressed and also when the song
changes.
This commit is contained in:
Bryan Schumaker 2011-04-20 21:07:00 -04:00
parent bce7651be5
commit 3b50c4071c
10 changed files with 44 additions and 20 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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())

View File

@ -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())

View File

@ -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())

View File

@ -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

View File

@ -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)