From 6385c1f3420fbc362e0493c7fd98b3a61139fc83 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Mon, 18 Apr 2011 20:55:01 -0400 Subject: [PATCH] Ocarina: Begin rewriting header I show the entry, and I call a filter function for the current page. --- ocarina/body/__init__.py | 8 ++--- ocarina/body/button.py | 33 ++++++++++++++++++++ ocarina/body/header.py | 39 ------------------------ ocarina/body/header/__init__.py | 53 +++++++++++++++++++++++++++++++++ ocarina/body/header/entry.py | 11 +++++++ ocarina/body/page.py | 10 +++++-- 6 files changed, 107 insertions(+), 47 deletions(-) create mode 100644 ocarina/body/button.py delete mode 100644 ocarina/body/header.py create mode 100644 ocarina/body/header/__init__.py create mode 100644 ocarina/body/header/entry.py diff --git a/ocarina/body/__init__.py b/ocarina/body/__init__.py index 158274b0..40417f71 100644 --- a/ocarina/body/__init__.py +++ b/ocarina/body/__init__.py @@ -39,6 +39,9 @@ def switch_page(notebook, page, pagenum): cur_pg.invisible() next_pg.visible() +def cur_page_filter(text): + current_page().filter(text) + #import ocarina #Label = gtk.Label #prefs = ocarina.libsaria.prefs @@ -67,11 +70,6 @@ def switch_page(notebook, page, pagenum): #child.invisible() #next_pg.visible() -#def cur_page_filter(text): - #cur_num = body.get_current_page() - #page = body.get_nth_page(cur_num) - #page.filter(text) - #def cur_page_reset(): #cur_num = body.get_current_page() #page = body.get_nth_page(cur_num) diff --git a/ocarina/body/button.py b/ocarina/body/button.py new file mode 100644 index 00000000..4bb31039 --- /dev/null +++ b/ocarina/body/button.py @@ -0,0 +1,33 @@ +# Bryan Schumaker (2 / 20 / 2011) + +import gtk + +SIZE = gtk.ICON_SIZE_MENU + +def on_click(button, func): + func() + +def stock_image(stock_item): + img = gtk.image_new_from_stock(stock_item, SIZE) + img.show() + return img + +def make_text(text): + lbl = gtk.Label(text) + lbl.show() + return lbl + +def default_button(func, show): + b = gtk.Button() + b.set_relief(gtk.RELIEF_NONE) + b.connect("clicked", on_click, func) + if show == True: + b.show() + return b + +def make_button(stock_item, func, show): + b = default_button(func, show) + img = stock_image(stock_item) + b.add(img) + return b + diff --git a/ocarina/body/header.py b/ocarina/body/header.py deleted file mode 100644 index d9495fbf..00000000 --- a/ocarina/body/header.py +++ /dev/null @@ -1,39 +0,0 @@ -# Bryan Schumaker (11/25/2010) - -import ocarina -from ocarina.components import button -from ocarina.components import entry - -gtk = ocarina.gtk -header = None -bar = None - - -def bar_add(widget, expand = False, fill = False): - bar.pack_start(widget, expand, fill) - -def init(): - global header - global bar - - header = gtk.VBox() - bar = gtk.HBox() - sep = gtk.HSeparator() - vsep = gtk.VSeparator() - vsep.show() - header.pack_start(bar) - header.pack_start(sep) - header.show_all() - - bar_add(entry.FilterEntry(), True, True) - bar_add(button.OpenButton()) - bar_add(button.SaveButton()) - bar_add(button.ExportButton()) - bar_add(button.SettingsButton()) - bar_add(vsep) - bar_add(button.UpdateButton()) - bar_add(button.ClearButton()) - bar_add(button.GotoButton()) - bar_add(button.RandomButton()) - bar_add(button.VolumeButton()) -init() diff --git a/ocarina/body/header/__init__.py b/ocarina/body/header/__init__.py new file mode 100644 index 00000000..53f75482 --- /dev/null +++ b/ocarina/body/header/__init__.py @@ -0,0 +1,53 @@ +# Bryan Schumaker (11/25/2010) + +import gtk +from ocarina.body.button import make_button +import entry + +header = gtk.VBox() +header_body = gtk.HBox() +header_sep = gtk.HSeparator() + +header.pack_start(header_body) +header.pack_start(header_sep) +header.show_all() + +header_body.pack_start(entry.entry) + +#import ocarina +#from ocarina.components import button +#from ocarina.components import entry + +#gtk = ocarina.gtk +#header = None +#bar = None + + +#def bar_add(widget, expand = False, fill = False): + #bar.pack_start(widget, expand, fill) + +#def init(): + #global header + #global bar + + #header = gtk.VBox() + #bar = gtk.HBox() + #sep = gtk.HSeparator() + #vsep = gtk.VSeparator() + #vsep.show() + #header.pack_start(bar) + #header.pack_start(sep) + #header.show_all() + + #bar_add(entry.FilterEntry(), True, True) + #bar_add(button.OpenButton()) + #bar_add(button.SaveButton()) + #bar_add(button.ExportButton()) + #bar_add(button.SettingsButton()) + #bar_add(vsep) + #bar_add(button.UpdateButton()) + #bar_add(button.ClearButton()) + #bar_add(button.GotoButton()) + #bar_add(button.RandomButton()) + #bar_add(button.VolumeButton()) +#init() diff --git a/ocarina/body/header/entry.py b/ocarina/body/header/entry.py new file mode 100644 index 00000000..1666ac2b --- /dev/null +++ b/ocarina/body/header/entry.py @@ -0,0 +1,11 @@ +# Bryan Schumaker (4 / 18 / 2011) + +import gtk +import ocarina + +entry = gtk.Entry() +entry.show() + +def do_filter(entry): + ocarina.body.cur_page_filter(entry.get_text()) +entry.connect("changed", do_filter) diff --git a/ocarina/body/page.py b/ocarina/body/page.py index 2da9b636..e3b2ebe8 100644 --- a/ocarina/body/page.py +++ b/ocarina/body/page.py @@ -1,7 +1,7 @@ # Bryan Schumaker (4 / 17 / 2011) import gtk -#import header +import header #import footer SHRINK = gtk.SHRINK GROW = gtk.FILL | gtk.EXPAND @@ -16,10 +16,11 @@ class OcarinaPage(gtk.Table): self.show() def visible(self): - pass + self.attach_top(header.header) def invisible(self): - pass + if header.header.get_parent() == self: + self.remove(header.header) def attach_top(self, content): self.attach(content, 0, 1, 0, 1, GROW, SHRINK) @@ -30,6 +31,9 @@ class OcarinaPage(gtk.Table): def attach_bottom(self, content): self.attach(content, 0, 1, 2, 3, GROW, SHRINK) + def filter(self, text): + pass + #self.content = content #self.attrs = content.__dict__ #self.vis_func = self.attrs.get("visible", None)