parent
d690904b3b
commit
5c22f959c3
111
ocarina/tabs.py
111
ocarina/tabs.py
|
@ -1,111 +0,0 @@
|
|||
# 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 filter(self, text):
|
||||
if hasattr(self.content, "filter"):
|
||||
self.content.filter(text)
|
||||
|
||||
def reset(self):
|
||||
if hasattr(self.content, "reset"):
|
||||
self.content.reset()
|
||||
|
||||
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
|
||||
|
||||
def get_current_page():
|
||||
global tabs
|
||||
global cur_page
|
||||
return tabs.get_nth_page(cur_page)
|
||||
|
||||
def reset_current_page():
|
||||
get_current_page().reset()
|
||||
|
||||
|
||||
def filter(text = None):
|
||||
#global cur_page
|
||||
p = tabs.get_nth_page(cur_page)
|
||||
p.filter(text)
|
Loading…
Reference in New Issue