Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/util/gtkcompat.py
diff options
context:
space:
mode:
Diffstat (limited to 'util/gtkcompat.py')
-rw-r--r--util/gtkcompat.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/util/gtkcompat.py b/util/gtkcompat.py
index c188a13..87622b8 100644
--- a/util/gtkcompat.py
+++ b/util/gtkcompat.py
@@ -29,6 +29,7 @@ except ValueError, ImportError:
import gconf
import pango as Pango
import pangocairo as PangoCairo
+ import cairo
Gdk = Gtk.gdk
Rectangle = Gdk.Rectangle
@@ -42,6 +43,16 @@ except ValueError, ImportError:
Gdk.cairo_set_source_pixbuf = \
lambda cr, img, x, y: cr.set_source_pixbuf(img, x, y)
+ def gdk_pixbuf_get_from_surface(surface, x, y, w, h):
+ pixmap = Gdk.Pixmap(None, w, h, 24)
+ cr = pixmap.cairo_create()
+ cr.set_source_surface(surface, -x, -y)
+ cr.rectangle(0,0,w,h);
+ cr.set_operator(cairo.OPERATOR_SOURCE)
+ cr.fill()
+ cmap = Gdk.colormap_get_system()
+ return Gdk.pixbuf_get_from_drawable(None, pixmap, cmap, 0, 0, 0, 0, w, h)
+ Gdk.pixbuf_get_from_surface = gdk_pixbuf_get_from_surface
class GdkEventMask:
EXPOSURE_MASK = Gdk.EXPOSURE_MASK