Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2012-03-06 21:03:15 (GMT)
committer Simon Schampijer <simon@schampijer.de>2012-03-19 10:26:11 (GMT)
commitb46fb00571b04b358214f6eef88fa7d603d4b9bd (patch)
treed28cda19c8ca0f02ad4e7f7ac96ad261bf18ca60
parentbab9c633c48744d6bcce7bc8cb3e77a6352367ed (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.py24
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()