Index: gtk/gtkwidget.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.c,v
retrieving revision 1.412.2.1
diff -u -p -r1.412.2.1 gtkwidget.c
--- gtk/gtkwidget.c	22 Sep 2005 14:48:10 -0000	1.412.2.1
+++ gtk/gtkwidget.c	13 Oct 2005 20:59:04 -0000
@@ -7781,6 +7809,51 @@ gtk_widget_set_no_show_all (GtkWidget *w
   
   g_object_notify (G_OBJECT (widget), "no-show-all");
 }
+
+/**
+ * gtk_widget_get_snapshot:
+ * @widget: a #GtkWidget
+ * 
+ * Creates a #GdkPixmap of the contents of the widget and its
+ * children. Works even if the widget is obscured.
+ * 
+ * Return value: #GdkPixmap of the widget
+ * Since: 2.10
+ **/
+GdkPixmap *
+gtk_widget_get_snapshot (GtkWidget *widget)
+{
+  GdkPixmap *pixmap;
+  int x, y;
+
+  if (!GTK_WIDGET_REALIZED (widget))
+    gtk_widget_realize (widget);
+
+  pixmap = gdk_pixmap_new (widget->window,
+			   widget->allocation.width,
+			   widget->allocation.height,
+			   gdk_drawable_get_depth (widget->window));
+
+  x = widget->allocation.x;
+  y = widget->allocation.y;
+
+  /* GtkWindow allocation->x/y can be changed by gtk_widget_set_uposition, ignore it */
+  if (GTK_IS_WINDOW (widget))
+    x = y = 0;
+  
+  gdk_window_redirect_to_drawable (widget->window,
+				   pixmap,
+				   x, y,
+				   0, 0,
+				   widget->allocation.width,
+				   widget->allocation.height);
+  gtk_widget_queue_draw (widget);
+  gdk_window_process_updates (widget->window, TRUE);
+  gdk_window_remove_redirection (widget->window);
+  
+  return pixmap;
+}
+
 
 #define __GTK_WIDGET_C__
 #include "gtkaliasdef.c"
Index: gtk/gtkwidget.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.h,v
retrieving revision 1.157
diff -u -p -r1.157 gtkwidget.h
--- gtk/gtkwidget.h	26 Jul 2005 15:02:23 -0000	1.157
+++ gtk/gtkwidget.h	13 Oct 2005 20:59:04 -0000
@@ -599,6 +602,7 @@ GdkWindow *   gtk_widget_get_root_window
 GtkSettings*  gtk_widget_get_settings    (GtkWidget *widget);
 GtkClipboard *gtk_widget_get_clipboard   (GtkWidget *widget,
 					  GdkAtom    selection);
+GdkPixmap *   gtk_widget_get_snapshot    (GtkWidget *widget);
 
 #ifndef GTK_DISABLE_DEPRECATED
 #define gtk_widget_set_visual(widget,visual)  ((void) 0)
