Hide palettes on iconbutton/toolbutton clicked

This commit is contained in:
Eduardo Silva 2007-07-08 10:29:43 -04:00
parent a2c0e52c20
commit c7d730e1ac
3 changed files with 16 additions and 2 deletions

View File

@ -48,6 +48,7 @@ class IconButton(CanvasIcon, hippo.CanvasItem):
self.props.stroke_color = color.BUTTON_NORMAL
self._set_size(STANDARD_SIZE)
self.connect('activated', self._icon_clicked_cb)
def _set_size(self, size):
if size == SMALL_SIZE:
@ -85,3 +86,7 @@ class IconButton(CanvasIcon, hippo.CanvasItem):
else:
self.props.background_color = \
color.BUTTON_BACKGROUND_NORMAL.get_int()
def _icon_clicked_cb(self, button):
if self._palette:
self._palette.popdown(True)

View File

@ -259,10 +259,14 @@ class Palette(gobject.GObject):
self._popup_anim.start()
self._secondary_anim.start()
def popdown(self):
def popdown(self, inmediate=False):
self._secondary_anim.stop()
self._popup_anim.stop()
self._popdown_anim.start()
if not inmediate:
self._popdown_anim.start()
else:
self._hide()
def invoker_mouse_enter(self):
self.popup()

View File

@ -28,6 +28,7 @@ class ToolButton(gtk.ToolButton):
gtk.ToolButton.__init__(self)
self._palette = None
self.set_icon(icon_name)
self.connect('clicked', self._button_clicked_cb)
def set_icon(self, icon_name):
icon = Icon(icon_name)
@ -44,4 +45,8 @@ class ToolButton(gtk.ToolButton):
def set_tooltip(self, text):
self.set_palette(Palette(text))
def _button_clicked_cb(self, widget):
if self._palette:
self._palette.popdown(True)
palette = property(get_palette, set_palette)