[Sugar-devel] [PATCH] EventIcon: Have a default create_palette method

Simon Schampijer simon at schampijer.de
Thu Jun 21 04:52:47 EDT 2012


The create_palette mechanism allows to create
palettes on demand and not for each icon upfront
whether it will be needed or not.

If you hover over an EventIcon and there is no
palette already associated with the Invoker, the Invoker
will call create_palette to see if it can be created
on demand. With this patch the EventIcon will return None
here (see as well CellRendererIcon or ToggleToolButton which
are having the same default behavior).
When subclassing EventIcon the create_palette method can
be overwritten and a Palette returned (see for example
the ActivityIcon in the HomeView).

Without this patch you can see tracebacks when hovering
over the EventIcon because the Invoker tries to call
create_palette.

Signed-off-by: Simon Schampijer <simon at laptop.org>
---
 src/sugar3/graphics/icon.py |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py
index 175d235..0c06bbc 100644
--- a/src/sugar3/graphics/icon.py
+++ b/src/sugar3/graphics/icon.py
@@ -594,6 +594,9 @@ class EventIcon(Gtk.EventBox):
     icon = GObject.property(
         type=object, getter=get_icon)
 
+    def create_palette(self):
+        return None
+
     def get_palette(self):
         return self._palette_invoker.palette
 
-- 
1.7.10.4



More information about the Sugar-devel mailing list