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:
parent
c185524d62
commit
377c1a496d
|
@ -14,12 +14,14 @@ page_header = None
|
||||||
page_footer = None
|
page_footer = None
|
||||||
|
|
||||||
class Page(gtk.VBox):
|
class Page(gtk.VBox):
|
||||||
def __init__(self, content):
|
def __init__(self, content, add_header, add_footer):
|
||||||
gtk.VBox.__init__(self)
|
gtk.VBox.__init__(self)
|
||||||
self.content = content
|
self.content = content
|
||||||
self.attrs = content.__dict__
|
self.attrs = content.__dict__
|
||||||
self.vis_func = self.attrs.get("visible", None)
|
self.vis_func = self.attrs.get("visible", None)
|
||||||
self.invis_func = self.attrs.get("invisible", None)
|
self.invis_func = self.attrs.get("invisible", None)
|
||||||
|
self.add_header = add_header
|
||||||
|
self.add_footer = add_footer
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def filter(self, text):
|
def filter(self, text):
|
||||||
|
@ -32,19 +34,19 @@ class Page(gtk.VBox):
|
||||||
self.content.goto()
|
self.content.goto()
|
||||||
|
|
||||||
def visible(self):
|
def visible(self):
|
||||||
if self.content.header == True:
|
if self.add_header == True:
|
||||||
self.pack_start(page_header, False, False)
|
self.pack_start(page_header, False, False)
|
||||||
self.pack_start(self.content, True, True)
|
self.pack_start(self.content, True, True)
|
||||||
if self.content.footer == True:
|
if self.add_footer == True:
|
||||||
self.pack_start(page_footer, False, False)
|
self.pack_start(page_footer, False, False)
|
||||||
if self.vis_func:
|
if self.vis_func:
|
||||||
self.vis_func()
|
self.vis_func()
|
||||||
|
|
||||||
def invisible(self):
|
def invisible(self):
|
||||||
if self.content.header == True:
|
if self.add_header == True:
|
||||||
self.remove(page_header)
|
self.remove(page_header)
|
||||||
self.remove(self.content)
|
self.remove(self.content)
|
||||||
if self.content.footer == True:
|
if self.add_footer == True:
|
||||||
self.remove(page_footer)
|
self.remove(page_footer)
|
||||||
if self.invis_func:
|
if self.invis_func:
|
||||||
self.invis_func()
|
self.invis_func()
|
||||||
|
@ -74,10 +76,10 @@ def init_page(page_name):
|
||||||
child.visible()
|
child.visible()
|
||||||
body.connect("switch-page", switch_page)
|
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 = Label(name)
|
||||||
label.set_angle(90)
|
label.set_angle(90)
|
||||||
page = Page(content)
|
page = Page(content, add_header, add_footer)
|
||||||
contents[name] = page
|
contents[name] = page
|
||||||
body.append_page(page, label)
|
body.append_page(page, label)
|
||||||
body.set_tab_label_packing(page, True, True, gtk.PACK_START)
|
body.set_tab_label_packing(page, True, True, gtk.PACK_START)
|
||||||
|
|
|
@ -151,8 +151,6 @@ class Source(gtk.ScrolledWindow):
|
||||||
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||||
self.list = None
|
self.list = None
|
||||||
self.filter = None
|
self.filter = None
|
||||||
self.header = True
|
|
||||||
self.footer = True
|
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def init(self, filter, is_visible, right_click, play_id, reset):
|
def init(self, filter, is_visible, right_click, play_id, reset):
|
||||||
|
|
|
@ -27,11 +27,9 @@ radio = path.join(html, "web_radio.html")
|
||||||
web.open(radio)
|
web.open(radio)
|
||||||
|
|
||||||
page.show_all()
|
page.show_all()
|
||||||
page.header = False
|
|
||||||
page.footer = False
|
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
body.add_page("Web Radio", page)
|
body.add_page("Web Radio", page, False, False)
|
||||||
|
|
||||||
def stop():
|
def stop():
|
||||||
body.remove_page("Web Radio")
|
body.remove_page("Web Radio")
|
||||||
|
|
Loading…
Reference in New Issue