[Sugar-devel] [PATCH] Add 'transient' property to Invoker #1742

Tomeu Vizoso tomeu.vizoso at collabora.co.uk
Mon Oct 11 05:34:37 EDT 2010


Meaning that the palette will be disposed when it pops down.
---
 src/sugar/graphics/palette.py       |    1 +
 src/sugar/graphics/palettewindow.py |   20 +++++++++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/sugar/graphics/palette.py b/src/sugar/graphics/palette.py
index d4632eb..d4f844c 100644
--- a/src/sugar/graphics/palette.py
+++ b/src/sugar/graphics/palette.py
@@ -158,6 +158,7 @@ class Palette(PaletteWindow):
         self.popdown(immediate=True)
         # Break the reference cycle. It looks like the gc is not able to free
         # it, possibly because gtk.Menu memory handling is very special.
+        self.menu.disconnect_by_func(self.__menu_item_inserted_cb)
         self.menu = None
 
     def __show_cb(self, widget):
diff --git a/src/sugar/graphics/palettewindow.py b/src/sugar/graphics/palettewindow.py
index 22131c2..3c74662 100644
--- a/src/sugar/graphics/palettewindow.py
+++ b/src/sugar/graphics/palettewindow.py
@@ -179,6 +179,7 @@ class PaletteWindow(gtk.Window):
 
     def __destroy_cb(self, palette):
         self.set_group_id(None)
+        self._mouse_detector.disconnect_by_func(self._mouse_slow_cb)
 
     def set_invoker(self, invoker):
         for hid in self._invoker_hids[:]:
@@ -457,6 +458,7 @@ class Invoker(gobject.GObject):
         self._cursor_x = -1
         self._cursor_y = -1
         self._palette = None
+        self._transient = False
 
     def attach(self, parent):
         self.parent = parent
@@ -639,18 +641,30 @@ class Invoker(gobject.GObject):
     def set_palette(self, palette):
         if self._palette is not None:
             self._palette.popdown(immediate=True)
-
-        if self._palette:
             self._palette.props.invoker = None
+            self._palette.destroy()
 
         self._palette = palette
 
-        if self._palette:
+        if self._palette is not None:
             self._palette.props.invoker = self
+            self._palette.connect('popdown', self.__palette_popdown_cb)
 
     palette = gobject.property(
         type=object, setter=set_palette, getter=get_palette)
 
+    def get_transient(self):
+        return self._transient
+
+    def set_transient(self, transient):
+        self._transient = transient
+
+    transient = gobject.property(type=object, setter=set_transient,
+                                 getter=get_transient)
+
+    def __palette_popdown_cb(self, palette):
+        if self.props.transient:
+            self.set_palette(None)
 
 class WidgetInvoker(Invoker):
 
-- 
1.7.2.3



More information about the Sugar-devel mailing list