Palette: tooltip fix

This commit is contained in:
Eduardo Silva 2007-06-05 22:43:42 -04:00
parent d849f573c5
commit f79d5a63db
2 changed files with 13 additions and 10 deletions

View File

@ -53,7 +53,6 @@ class Palette(gtk.Window):
self._alignment = ALIGNMENT_AUTOMATIC
self._palette_label = gtk.Label()
#self._palette_label.set_justify(gtk.JUSTIFY_LEFT)
self._palette_label.show()
vbox = gtk.VBox(False, 0)
@ -79,7 +78,7 @@ class Palette(gtk.Window):
vbox.pack_start(self._menu_bar, True, True, self._PADDING)
vbox.pack_start(self._content, True, True, self._PADDING)
vbox.pack_start(self._button_bar, True, True, self._PADDING)
vbox.show()
self.add(vbox)
@ -267,7 +266,7 @@ class Palette(gtk.Window):
# Enter, Return or Space: Select
keyval = event.keyval
state = event.state & gtk.accelerator_get_default_mod_mask()
if (keyval == keysyms.Escape or
((keyval == keysyms.Up or keyval == keysyms.KP_Up) and
state == gdk.MOD1_MASK)):

View File

@ -26,6 +26,7 @@ class ToolButton(gtk.ToolButton):
def __init__(self, icon_name=None):
gtk.ToolButton.__init__(self)
self._palette = None
self.set_icon(icon_name)
def set_icon(self, icon_name):
@ -36,14 +37,17 @@ class ToolButton(gtk.ToolButton):
def set_palette(self, palette):
self._palette = palette
self._palette.props.parent = self
self.child.connect('enter-notify-event', self._show_palette_timeout_cb, self._palette)
self.child.connect('enter-notify-event', self._show_palette_timeout_cb)
def set_tooltip(self, text):
self._palette_tt = Palette(is_tooltip=True)
self._palette_tt.set_primary_state(text)
self._palette_tt.props.parent = self
self.child.connect('enter-notify-event', self._show_palette_timeout_cb, self._palette_tt)
if self._palette:
self._palette.destroy()
def _show_palette_timeout_cb(self, widget, event, palette):
self._palette = Palette(is_tooltip=True)
self._palette.set_primary_state(text)
self._palette.props.parent = self
self.child.connect('enter-notify-event', self._show_palette_timeout_cb)
def _show_palette_timeout_cb(self, widget, event):
time.sleep(self._POPUP_PALETTE_DELAY)
palette.popup()
self._palette.popup()