From cd6786a14f6617e808bea3ebe70fe54d2d1df5fd Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Tue, 12 Jul 2011 21:24:04 +0000 Subject: setting proper cairo context for badge display --- diff --git a/src/sugar/graphics/icon.py b/src/sugar/graphics/icon.py index d7a7b65..50bfc78 100644 --- a/src/sugar/graphics/icon.py +++ b/src/sugar/graphics/icon.py @@ -1,4 +1,5 @@ # Copyright (C) 2006-2007 Red Hat, Inc. +# Copyright (C) 2011 Walter Bender # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -182,8 +183,9 @@ class _IconBuffer(object): if not sensitive: pixbuf = self._get_insensitive_pixbuf(pixbuf, widget) - surface = pixbuf.cairo_create() - context.set_source_surface(surface, 0, 0) + + context = gtk.gdk.CairoContext(context) + context.set_source_pixbuf(pixbuf) context.paint() def _get_size(self, icon_width, icon_height, padding): @@ -299,15 +301,14 @@ class _IconBuffer(object): else: pixbuf = handle.get_pixbuf() pixbuf = self._get_insensitive_pixbuf(pixbuf, widget) - - pixbuf_surface = pixbuf.cairo_create() - context.set_source_surface(pixbuf_surface, 0, 0) + context = gtk.gdk.CairoContext(context) + context.set_source_pixbuf(pixbuf) context.paint() else: if not sensitive: pixbuf = self._get_insensitive_pixbuf(pixbuf, widget) - pixbuf_surface = pixbuf.cairo_create() - context.set_source_surface(pixbuf_surface, 0, 0) + context = gtk.gdk.CairoContext(context) + context.set_source_pixbuf(pixbuf) context.paint() if self.badge_name: @@ -546,7 +547,7 @@ class CanvasIcon(gtk.EventBox): gtk.EventBox.__init__(self) self.set_visible_window(False) - + vbox = gtk.VBox() self.add(vbox) vbox.show() @@ -665,7 +666,7 @@ class CanvasIcon(gtk.EventBox): """ if self._icon._buffer.icon_name != value: self._icon._buffer.icon_name = value - self.emit_paint_needed(0, 0, -1, -1) + self.do_expose_event(None) def get_icon_name(self): """ @@ -962,7 +963,8 @@ class CanvasIcon(gtk.EventBox): cr.set_source_surface(surface, x, y) cr.paint() - def do_get_content_width_request(self): + def get_width_request(self): + # def do_get_content_width_request(self): """ Parameters ---------- @@ -983,7 +985,8 @@ class CanvasIcon(gtk.EventBox): return size, size - def do_get_content_height_request(self, for_width): + def get_height_request(self, for_width): + # def do_get_content_height_request(self, for_width): surface = self._icon._buffer.get_surface() if surface: size = surface.get_height() -- cgit v0.9.1