diff --git a/sugar/graphics/palette.py b/sugar/graphics/palette.py index f474783f..7c3e6f55 100644 --- a/sugar/graphics/palette.py +++ b/sugar/graphics/palette.py @@ -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)): diff --git a/sugar/graphics/toolbutton.py b/sugar/graphics/toolbutton.py index 8a06c2f7..f624caf1 100644 --- a/sugar/graphics/toolbutton.py +++ b/sugar/graphics/toolbutton.py @@ -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()