Ocarina: Begin rewriting header

I show the entry, and I call a filter function for the current page.
This commit is contained in:
Bryan Schumaker 2011-04-18 20:55:01 -04:00
parent d20d4c3fcd
commit 6385c1f342
6 changed files with 107 additions and 47 deletions

View File

@ -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)

33
ocarina/body/button.py Normal file
View File

@ -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

View File

@ -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()

View File

@ -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()

View File

@ -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)

View File

@ -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)