From 8ae1f9aad8e96c683c55988b317562c37634737e Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Mon, 17 Sep 2007 23:42:17 +0200 Subject: [PATCH] Fix that several palettes are not hooked up to the same button #3293 --- NEWS | 1 + sugar/graphics/icon.py | 2 ++ sugar/graphics/palette.py | 11 +++++++++-- sugar/graphics/radiotoolbutton.py | 2 ++ sugar/graphics/toggletoolbutton.py | 2 ++ sugar/graphics/toolbutton.py | 4 +++- sugar/graphics/tray.py | 2 ++ 7 files changed, 21 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 3d99f7a8..2f52186f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ +* #3293 Fix that several palettes are not hooked up to the same button (erikos) * #3514 Remove invite when the activiy disappear from the mesh. (cassidy) * #3003 Make image drags on the clipboard work consistently. (marco) diff --git a/sugar/graphics/icon.py b/sugar/graphics/icon.py index 1598e4bd..cbff3f91 100644 --- a/sugar/graphics/icon.py +++ b/sugar/graphics/icon.py @@ -480,6 +480,8 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): return self._palette def set_palette(self, palette): + if self._palette is not None: + self._palette.props.invoker = None self._palette = palette if not self._palette.props.invoker: self._palette.props.invoker = CanvasInvoker(self) diff --git a/sugar/graphics/palette.py b/sugar/graphics/palette.py index 8f2a4041..acc14f74 100644 --- a/sugar/graphics/palette.py +++ b/sugar/graphics/palette.py @@ -192,9 +192,16 @@ class Palette(gtk.Window): def do_set_property(self, pspec, value): if pspec.name == 'invoker': + if self._invoker is not None: + self._invoker.disconnect(self._enter_invoker_hid) + self._invoker.disconnect(self._leave_invoker_hid) + self._invoker = value - self._invoker.connect('mouse-enter', self._invoker_mouse_enter_cb) - self._invoker.connect('mouse-leave', self._invoker_mouse_leave_cb) + if value is not None: + self._enter_invoker_hid = self._invoker.connect( + 'mouse-enter', self._invoker_mouse_enter_cb) + self._leave_invoker_hid = self._invoker.connect( + 'mouse-leave', self._invoker_mouse_leave_cb) else: raise AssertionError diff --git a/sugar/graphics/radiotoolbutton.py b/sugar/graphics/radiotoolbutton.py index 80afb49d..8a1399a0 100644 --- a/sugar/graphics/radiotoolbutton.py +++ b/sugar/graphics/radiotoolbutton.py @@ -41,6 +41,8 @@ class RadioToolButton(gtk.RadioToolButton): return self._palette def set_palette(self, palette): + if self._palette is not None: + self._palette.props.invoker = None self._palette = palette self._palette.props.invoker = ToolInvoker(self.child) diff --git a/sugar/graphics/toggletoolbutton.py b/sugar/graphics/toggletoolbutton.py index 5f446011..2c97fa38 100644 --- a/sugar/graphics/toggletoolbutton.py +++ b/sugar/graphics/toggletoolbutton.py @@ -37,6 +37,8 @@ class ToggleToolButton(gtk.ToggleToolButton): return self._palette def set_palette(self, palette): + if self._palette is not None: + self._palette.props.invoker = None self._palette = palette self._palette.props.invoker = ToolInvoker(self.child) diff --git a/sugar/graphics/toolbutton.py b/sugar/graphics/toolbutton.py index e06afe95..8a0005e3 100644 --- a/sugar/graphics/toolbutton.py +++ b/sugar/graphics/toolbutton.py @@ -41,12 +41,14 @@ class ToolButton(gtk.ToolButton): return self._palette def set_palette(self, palette): + if self._palette is not None: + self._palette.props.invoker = None self._palette = palette self._palette.props.invoker = ToolInvoker(self.child) def set_tooltip(self, text): self.set_palette(Palette(text)) - + def do_expose_event(self, event): if self._palette and self._palette.is_up(): invoker = self._palette.props.invoker diff --git a/sugar/graphics/tray.py b/sugar/graphics/tray.py index af2e7eb7..b779ac9b 100644 --- a/sugar/graphics/tray.py +++ b/sugar/graphics/tray.py @@ -216,6 +216,8 @@ class _IconWidget(gtk.EventBox): gtk.EventBox.do_expose_event(self, event) def set_palette(self, palette): + if self._palette is not None: + self._palette.props.invoker = None self._palette = palette self._palette.props.invoker = ToolInvoker(self)