Make Search and Clear buttons use less places

This commit is contained in:
Cédric Krier committed 2009-03-20 15:01:56 +01:00
1 parent d445d29dc0
commit 0eaea6dd7b
1 file changed
+33 -30
@@ -18,44 +18,47 @@ class ScreenContainer(object):
return self.vbox
def add_filter(self, widget, fnct, clear_fnct):
self.filter_vbox = gtk.VBox(spacing=1)
self.filter_vbox.set_border_width(1)
tooltips = gtk.Tooltips()
self.filter_vbox = gtk.VBox(spacing=0)
self.filter_vbox.set_border_width(0)
hbox = gtk.HBox(homogeneous=False, spacing=0)
label = gtk.Label(_('Search'))
label.set_alignment(0.0, 0.5)
label.show()
self.filter_vbox.pack_start(label, expand=True, fill=False)
hbox.pack_start(label, expand=True, fill=True)
but_find = gtk.Button()
tooltips.set_tip(but_find, _('Find'))
but_find.connect('clicked', fnct)
img_find = gtk.Image()
img_find.set_from_stock('tryton-find', gtk.ICON_SIZE_SMALL_TOOLBAR)
img_find.set_alignment(0.5, 0.5)
but_find.add(img_find)
but_find.set_relief(gtk.RELIEF_NONE)
hbox.pack_start(but_find, expand=False, fill=False)
but_clear = gtk.Button()
tooltips.set_tip(but_clear, _('Clear'))
but_clear.connect('clicked', clear_fnct)
img_clear = gtk.Image()
img_clear.set_from_stock('tryton-clear', gtk.ICON_SIZE_SMALL_TOOLBAR)
img_clear.set_alignment(0.5, 0.5)
but_clear.add(img_clear)
but_clear.set_relief(gtk.RELIEF_NONE)
hbox.pack_start(but_clear, expand=False, fill=False)
hbox.show_all()
self.filter_vbox.pack_start(hbox, expand=True, fill=False)
hseparator = gtk.HSeparator()
hseparator.show()
self.filter_vbox.pack_start(hseparator, expand=True, fill=False)
self.filter_vbox.pack_start(widget, expand=True, fill=True)
hbuttonbox = gtk.HButtonBox()
hbuttonbox.set_spacing(5)
hbuttonbox.set_layout(gtk.BUTTONBOX_END)
button_clear = gtk.Button()
hbox_clear = gtk.HBox()
img_clear = gtk.Image()
img_clear.set_from_stock('tryton-clear', gtk.ICON_SIZE_BUTTON)
hbox_clear.pack_start(img_clear)
label_clear = gtk.Label(_('Clear'))
hbox_clear.pack_start(label_clear)
button_clear.add(hbox_clear)
button_clear.connect('clicked', clear_fnct)
hbuttonbox.pack_start(button_clear, expand=False, fill=False)
self.button = gtk.Button()
hbox_find = gtk.HBox()
img_find = gtk.Image()
img_find.set_from_stock('tryton-find', gtk.ICON_SIZE_BUTTON)
hbox_find.pack_start(img_find)
label_find = gtk.Label(_('Find'))
hbox_find.pack_start(label_find)
self.button.add(hbox_find)
self.button.connect('clicked', fnct)
self.button.set_property('can_default', True)
hbuttonbox.pack_start(self.button, expand=False, fill=False)
hbuttonbox.show_all()
self.filter_vbox.pack_start(hbuttonbox, expand=False, fill=False)
self.vbox.pack_start(self.filter_vbox, expand=False, fill=True)
tooltips.enable()
def show_filter(self):
if self.filter_vbox:
self.filter_vbox.show()