[Sugar-devel] [PATCH sugar 1/7] SugarEventIcon: Add a hippo-free implementation of the CanvasIcon

Benjamin Berg benzea at sugarlabs.org
Mon Aug 6 09:53:12 EDT 2012


On Mon, 2012-08-06 at 15:49 +0200, Sascha Silbe wrote:
> Benjamin Berg <benzea at sugarlabs.org> writes:
> >> +        # HACK to supress the grey background around the icon
> >> +        # won't be needed in GTK3
> >> +        self.modify_bg(gtk.STATE_NORMAL, style.COLOR_WHITE.get_gdk_color())
> >
> > Not really too bad, but I am pretty sure that
> > gtk.EventBox.set_visible_window(False) should work fine here.
> 
> Doesn't look that way to me:

Oh, thanks for the screenshot. That is kinda obvious. One needs to add
allocation.x and allocation.y to the coordinates if you don't have a
visible window.

So:

+    def do_expose_event(self, event):
+        surface = self._buffer.get_surface()
+        if surface:
+            allocation = self.get_allocation()
+
+            x = (allocation.width - surface.get_width()) / 2
+            y = (allocation.height - surface.get_height()) / 2
+
+            cr = self.window.cairo_create()
+            cr.set_source_surface(surface, x, y)
+            if self._alpha == 1.0:
+                cr.paint()
+            else:
+                cr.paint_with_alpha(self._alpha)


Also change the x/y calculation to add allocation.x and allocation.y
respectively. Then things should work fine.

Benjamin



More information about the Sugar-devel mailing list