All pastes #718448 Raw Edit

Miscellany

public text v1 · immutable
#718448 ·published 2007-09-28 12:54 UTC
rendered paste body
diff --git a/sugar/graphics/window.py b/sugar/graphics/window.py
index 28fdb35..984bc62 100644
--- a/sugar/graphics/window.py
+++ b/sugar/graphics/window.py
@@ -54,6 +54,13 @@ class Window(gtk.Window):
         group.realize()
         window.window.set_group(group.window)
 
+    def _draw_on_pixmap(self, pixmap, window):
+        x, y, width, height, depth = window.get_geometry()
+        if depth > 0:
+            pixmap.draw_drawable(window.new_gc(), window, 0, 0, x, y, -1, -1)
+        for child in window.get_children():
+            self._draw_on_pixmap(pixmap, child)
+
     def get_canvas_screenshot(self):
         if not self.canvas:
             return None
@@ -61,8 +68,12 @@ class Window(gtk.Window):
         window = self.canvas.window
         width, height = window.get_size()
 
+        pixmap = gtk.gdk.Pixmap(window, width, height)
+        self._draw_on_pixmap(pixmap, window)
+
         screenshot = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, has_alpha=False,
                                     bits_per_sample=8, width=width, height=height)
-        screenshot.get_from_drawable(window, window.get_colormap(), 0, 0, 0, 0,
+        screenshot.get_from_drawable(pixmap, pixmap.get_colormap(), 0, 0, 0, 0,
                                      width, height)
         return screenshot
+