ocarina/ocarina/body/__init__.py
Bryan Schumaker 3b50c4071c ocarina: goto current song
I do this when the goto button is pressed and also when the song
changes.
2011-05-01 12:12:13 -04:00

85 lines
1.9 KiB
Python

# Bryan Schumaker (11/24/2010)
import gtk
from page import OcarinaPage
body = gtk.Notebook()
body.show()
body.set_tab_pos(gtk.POS_LEFT)
page_num = body.page_num
def add_page(content, page_name):
label = gtk.Label(page_name)
label.set_angle(90)
page = OcarinaPage(content, label)
body.append_page(page, label)
body.set_tab_label_packing(page, True, True, gtk.PACK_START)
n = body.get_n_pages()
if n == 1:
page.visible()
elif n == 2:
body.connect("switch-page", switch_page)
return page
def remove_page(page):
page.invisible()
page.rm_content()
body.remove_page(page_num(page))
def current_page():
cur_num = body.get_current_page()
return body.get_nth_page(cur_num)
def switch_to_page(page):
body.set_current_page(page_num(page))
def switch_page(notebook, page, pagenum):
cur_pg = current_page()
next_pg = body.get_nth_page(pagenum)
cur_pg.invisible()
next_pg.visible()
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
#get_pref = prefs.get_pref
#set_pref = prefs.set_pref
#def init_page(page_name):
#page = prefs.init_pref("ocarina.body.page", page_name)
#child = contents.get(page, None)
#if child == None:
#child = contents.get(page_name)
#num = body.page_num(child)
#body.set_current_page(num)
#child.visible()
#body.connect("switch-page", switch_page)
#def switch_page(notebook, page, pagenum):
#cur_num = body.get_current_page()
#child = body.get_nth_page(cur_num)
#next_pg = body.get_nth_page(pagenum)
#next = None
#for name, item in contents.iteritems():
#if item == next_pg:
#next = name
#set_pref("ocarina.body.page", next)
#child.invisible()
#next_pg.visible()
#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()