63 lines
1.3 KiB
Python
63 lines
1.3 KiB
Python
# 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_n(n):
|
|
body.set_current_page(n)
|
|
|
|
def switch_to_page(page):
|
|
switch_to_page_n(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 hide_page(page):
|
|
n = page_num(page)
|
|
if n > 0:
|
|
switch_to_page_n(n - 1)
|
|
page.hide()
|
|
|
|
def show_page(page, switch = False):
|
|
page.show()
|
|
if switch == True:
|
|
switch_to_page(page)
|
|
|
|
def cur_page_goto():
|
|
current_page().goto()
|
|
shortcuts.register_shortcut("g", cur_page_goto)
|
|
|
|
def cur_page_clear():
|
|
current_page().clear()
|