Goto current song

There is no a button to scroll to the currently playing song.
This commit is contained in:
Bryan Schumaker 2010-11-28 13:53:38 -05:00
parent 3ce9240655
commit f8ad68abe5
4 changed files with 27 additions and 0 deletions

View File

@ -28,6 +28,9 @@ class Page(gtk.VBox):
def reset(self):
self.content.reset()
def goto(self):
self.content.goto()
def visible(self):
self.pack_start(page_header, False, False)
self.pack_start(self.content, True, True)
@ -101,3 +104,8 @@ def cur_page_reset():
cur_num = body.get_current_page()
page = body.get_nth_page(cur_num)
page.reset()
def cur_page_goto():
cur_num = body.get_current_page()
page = body.get_nth_page(cur_num)
page.goto()

View File

@ -110,6 +110,13 @@ class ExportButton(Button):
from libsaria.path import backup
backup.backup()
class GotoButton(Button):
def __init__(self):
Button.__init__(self, gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON)
def clicked(self, button):
from ocarina import body
body.cur_page_goto()
class RandomButton(gtk.ToggleButton):
def __init__(self):
gtk.ToggleButton.__init__(self)

View File

@ -25,6 +25,7 @@ def init():
bar_add(entry.FilterEntry(), True, True)
bar_add(button.OpenButton())
bar_add(button.GotoButton())
bar_add(button.ExportButton())
bar_add(button.ClearButton())
bar_add(button.RandomButton())

View File

@ -89,6 +89,16 @@ class ListView(gtk.TreeView):
self.set_model(self.filter_model)
self.thaw_child_notify()
def goto(self):
id = sources.cur_lib_id
for index, row in enumerate(self.filter_model):
if row[0] == id:
path = index - 10
if path < 0:
path = 0
self.scroll_to_cell(path, None, True, 0, 0)
self.set_cursor_on_cell(index, None, None, False)
def query_tooltip(self, widget, x, y, keyboard, tip):
row = self.get_dest_row_at_pos(x,y)
if row == None:
@ -133,6 +143,7 @@ class Source(gtk.ScrolledWindow):
self.filter = filter
self.reset = reset
self.clear = self.list.clear
self.goto = self.list.goto
self.for_each_selected = self.list.for_each_selected
def fill(self, walk_func):