From 377c1a496da9cb04f689a19b20cf1bb43207acf3 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Tue, 1 Feb 2011 21:06:35 -0500 Subject: [PATCH] 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. --- ocarina/body.py | 16 +++++++++------- ocarina/source.py | 2 -- plugins/web_radio.py | 4 +--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/ocarina/body.py b/ocarina/body.py index 7dfa5026..1b531aee 100644 --- a/ocarina/body.py +++ b/ocarina/body.py @@ -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) diff --git a/ocarina/source.py b/ocarina/source.py index 3cc979eb..5a17b53d 100644 --- a/ocarina/source.py +++ b/ocarina/source.py @@ -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): diff --git a/plugins/web_radio.py b/plugins/web_radio.py index d7569846..0d7f2247 100644 --- a/plugins/web_radio.py +++ b/plugins/web_radio.py @@ -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")