diff options
author | Daniel Drake <dsd@laptop.org> | 2012-03-06 21:03:15 (GMT) |
---|---|---|
committer | Daniel Drake <dsd@laptop.org> | 2012-03-07 15:03:39 (GMT) |
commit | 6ce463585c3f3a639392e51cb26d789c2fde6516 (patch) | |
tree | c482d4b1f6ceaa820dafca7aaa6e2c988e43626a | |
parent | 2b1ab59827d425527e5777fc592ef5307de262e0 (diff) |
icon: use GDK for pixbuf-to-cairo conversion
We currently use some strange code inside hippo to paint a pixbuf onto
a cairo surface. This can be more effectively done within GDK.
This solves a Sugar crash-on-startup on Fedora 17, where this hippo
code is crashing, and uses the same underlying mechanism as
sugar-toolkit-gtk3.
Also use cairo.Context.set_source_rgb() for setting the background
colour, which avoids the requirement to encapsulate the cairo context
at an early stage (which would make the rest of this patch a little
more complicated).
Signed-off-by: Daniel Drake <dsd@laptop.org>
Acked-by: Simon Schampijer <simon@schampijer.de>
-rw-r--r-- | src/sugar/graphics/icon.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/sugar/graphics/icon.py b/src/sugar/graphics/icon.py index 62a79f6..3f540d7 100644 --- a/src/sugar/graphics/icon.py +++ b/src/sugar/graphics/icon.py @@ -182,9 +182,9 @@ class _IconBuffer(object): if not sensitive: pixbuf = self._get_insensitive_pixbuf(pixbuf, widget) - surface = hippo.cairo_surface_from_gdk_pixbuf(pixbuf) - context.set_source_surface(surface, 0, 0) - context.paint() + gdkcontext = gtk.gdk.CairoContext(context) + gdkcontext.set_source_pixbuf(pixbuf, 0, 0) + gdkcontext.paint() def _get_size(self, icon_width, icon_height, padding): if self.width is not None and self.height is not None: @@ -280,8 +280,9 @@ class _IconBuffer(object): surface = cairo.ImageSurface(cairo.FORMAT_RGB24, int(width), int(height)) context = cairo.Context(surface) - context = gtk.gdk.CairoContext(context) - context.set_source_color(self.background_color) + context.set_source_rgb(self.background_color.red, + self.background_color.blue, + self.background_color.green) context.paint() context.scale(float(width) / (icon_width + padding * 2), @@ -295,16 +296,15 @@ class _IconBuffer(object): else: pixbuf = handle.get_pixbuf() pixbuf = self._get_insensitive_pixbuf(pixbuf, widget) - - pixbuf_surface = hippo.cairo_surface_from_gdk_pixbuf(pixbuf) - context.set_source_surface(pixbuf_surface, 0, 0) - context.paint() + gdkcontext = gtk.gdk.CairoContext(context) + gdkcontext.set_source_pixbuf(pixbuf, 0, 0) + gdkcontext.paint() else: if not sensitive: pixbuf = self._get_insensitive_pixbuf(pixbuf, widget) - pixbuf_surface = hippo.cairo_surface_from_gdk_pixbuf(pixbuf) - context.set_source_surface(pixbuf_surface, 0, 0) - context.paint() + gdkcontext = gtk.gdk.CairoContext(context) + gdkcontext.set_source_pixbuf(pixbuf, 0, 0) + gdkcontext.paint() if self.badge_name: context.restore() |