[Sugar-devel] [PATCH sugar 1/7] SugarEventIcon: Add a hippo-free implementation of the CanvasIcon
Simon Schampijer
simon at schampijer.de
Tue Aug 7 03:41:07 EDT 2012
On 08/06/2012 03:53 PM, Benjamin Berg wrote:
> 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
diff --git a/src/jarabe/view/eventicon.py b/src/jarabe/view/eventicon.py
index 4166798..0432c34 100644
--- a/src/jarabe/view/eventicon.py
+++ b/src/jarabe/view/eventicon.py
@@ -94,16 +94,13 @@ class EventIcon(gtk.EventBox):
self._alpha = 1.0
gtk.EventBox.__init__(self)
+ self.set_visible_window(False)
for key, value in kwargs.iteritems():
self.set_property(key, value)
self._palette_invoker = CursorInvoker()
self._palette_invoker.attach(self)
- # 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())
-
self.connect('destroy', self.__destroy_cb)
def do_expose_event(self, event):
@@ -111,8 +108,8 @@ class EventIcon(gtk.EventBox):
if surface:
allocation = self.get_allocation()
- x = (allocation.width - surface.get_width()) / 2
- y = (allocation.height - surface.get_height()) / 2
+ x = allocation.x + (allocation.width - surface.get_width()) / 2
+ y = allocation.y + (allocation.height -
surface.get_height()) / 2
cr = self.window.cairo_create()
cr.set_source_surface(surface, x, y)
This will work now. As Benjamin stated the one needs to add
allocation.x/y in expose, the current code works fine if the event box
has a visible window, because then allocation.x and allocation.y are 0
by definition. Attached is the updated patch as well.
Regards,
Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-SugarEventIcon-Add-a-hippo-free-implementation-of-th.patch
Type: text/x-patch
Size: 10946 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20120807/0883a2f6/attachment.bin>
More information about the Sugar-devel
mailing list