ocarina: Set header / footer visibility when adding page

This allows me to store the visible settings in the Page() class, rather
than having to store it with the rest of the content.
This commit is contained in:
Bryan Schumaker 2011-02-01 21:06:35 -05:00
parent c185524d62
commit 377c1a496d
3 changed files with 10 additions and 12 deletions

View File

@ -14,12 +14,14 @@ page_header = None
page_footer = None
class Page(gtk.VBox):
def __init__(self, content):
def __init__(self, content, add_header, add_footer):
gtk.VBox.__init__(self)
self.content = content
self.attrs = content.__dict__
self.vis_func = self.attrs.get("visible", None)
self.invis_func = self.attrs.get("invisible", None)
self.add_header = add_header
self.add_footer = add_footer
self.show()
def filter(self, text):
@ -32,19 +34,19 @@ class Page(gtk.VBox):
self.content.goto()
def visible(self):
if self.content.header == True:
if self.add_header == True:
self.pack_start(page_header, False, False)
self.pack_start(self.content, True, True)
if self.content.footer == True:
if self.add_footer == True:
self.pack_start(page_footer, False, False)
if self.vis_func:
self.vis_func()
def invisible(self):
if self.content.header == True:
if self.add_header == True:
self.remove(page_header)
self.remove(self.content)
if self.content.footer == True:
if self.add_footer == True:
self.remove(page_footer)
if self.invis_func:
self.invis_func()
@ -74,10 +76,10 @@ def init_page(page_name):
child.visible()
body.connect("switch-page", switch_page)
def add_page(name, content):
def add_page(name, content, add_header=True, add_footer=True):
label = Label(name)
label.set_angle(90)
page = Page(content)
page = Page(content, add_header, add_footer)
contents[name] = page
body.append_page(page, label)
body.set_tab_label_packing(page, True, True, gtk.PACK_START)

View File

@ -151,8 +151,6 @@ class Source(gtk.ScrolledWindow):
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.list = None
self.filter = None
self.header = True
self.footer = True
self.show()
def init(self, filter, is_visible, right_click, play_id, reset):

View File

@ -27,11 +27,9 @@ radio = path.join(html, "web_radio.html")
web.open(radio)
page.show_all()
page.header = False
page.footer = False
def start():
body.add_page("Web Radio", page)
body.add_page("Web Radio", page, False, False)
def stop():
body.remove_page("Web Radio")