90 lines
1.9 KiB
Python
90 lines
1.9 KiB
Python
# Bryan Schumaker (8/13/2010)
|
|
|
|
import ocarina
|
|
|
|
libsaria = ocarina.libsaria
|
|
gtk = ocarina.gtk
|
|
Label = gtk.Label
|
|
|
|
tabs = None
|
|
contents = dict()
|
|
cur_page = 0
|
|
|
|
bottom = None
|
|
top = None
|
|
|
|
|
|
class TabPage(gtk.VBox):
|
|
def __init__(self, content):
|
|
gtk.VBox.__init__(self)
|
|
self.content = content
|
|
self.show()
|
|
|
|
def visible(self):
|
|
global bottom
|
|
global top
|
|
if top is not None:
|
|
self.pack_start(top, False, False)
|
|
if self.content is not None:
|
|
self.pack_start(self.content, True, True)
|
|
if bottom is not None:
|
|
self.pack_start(bottom, False, False)
|
|
if hasattr(self.content, "visible"):
|
|
self.content.visible()
|
|
|
|
def invisible(self):
|
|
global bottom
|
|
global top
|
|
if top is not None and top.get_parent() is not None:
|
|
self.remove(top)
|
|
if self.content is not None and self.content.get_parent() is not None:
|
|
self.remove(self.content)
|
|
if bottom is not None and bottom.get_parent() is not None:
|
|
self.remove(bottom)
|
|
if hasattr(self.content, "invisible"):
|
|
self.content.invisible()
|
|
|
|
|
|
def init():
|
|
import info
|
|
global bottom
|
|
global top
|
|
info.init()
|
|
bottom = info.get_info()
|
|
top = info.get_filter()
|
|
global tabs
|
|
tabs = gtk.Notebook()
|
|
tabs.set_tab_pos(gtk.POS_LEFT)
|
|
tabs.connect("switch-page", switch_page)
|
|
tabs.show()
|
|
|
|
def append_page(content, text):
|
|
global Label
|
|
global contents
|
|
global tabs
|
|
label = Label(text)
|
|
label.set_angle(90)
|
|
page = TabPage(content)
|
|
contents[text] = page
|
|
tabs.append_page(page, label)
|
|
tabs.set_tab_label_packing(page, True, True, gtk.PACK_START)
|
|
|
|
def remove_page(text):
|
|
global contents
|
|
global tabs
|
|
page = contents.get(text, None)
|
|
if page == None:
|
|
return
|
|
n = tabs.page_num(page)
|
|
if n > 0:
|
|
tabs.remove_page( n)
|
|
del contents[text]
|
|
|
|
def switch_page(notebook, page, page_num):
|
|
global cur_page
|
|
old = notebook.get_nth_page(cur_page)
|
|
new = notebook.get_nth_page(page_num)
|
|
old.invisible()
|
|
new.visible()
|
|
cur_page = page_num
|