ocarina/ocarina/body/__init__.py

52 lines
1.1 KiB
Python
Raw Normal View History

# Bryan Schumaker (11/24/2010)
import gtk
from page import OcarinaPage
from ocarina import shortcuts
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()
shortcuts.register_shortcut("g", cur_page_goto)
def cur_page_clear():
current_page().clear()