[Xfce4-commits] <midori:master> Implement midori_view_web_view_get_snapshot for GTK+ 3
Christian Dywan
noreply at xfce.org
Mon Nov 21 03:14:04 CET 2011
Updating branch refs/heads/master
to 59b3d9319c1da08863479bec79aa5eb568c2d2a5 (commit)
from c60a9d220a731abc37b80cfded22acb4655a48a5 (commit)
commit 59b3d9319c1da08863479bec79aa5eb568c2d2a5
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun Nov 20 22:36:55 2011 +0100
Implement midori_view_web_view_get_snapshot for GTK+ 3
midori/midori-view.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 5cdeb4d..1c2ef62 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -5217,22 +5217,23 @@ midori_view_web_view_get_snapshot (GtkWidget* web_view,
gint width,
gint height)
{
- GdkWindow* window;
GtkAllocation allocation;
gboolean fast;
gint x, y, w, h;
GdkRectangle rect;
#if !GTK_CHECK_VERSION (3, 0, 0)
+ GdkWindow* window;
GdkPixmap* pixmap;
GdkEvent event;
gboolean result;
GdkColormap* colormap;
+ #else
+ cairo_surface_t* surface;
+ cairo_t* cr;
#endif
GdkPixbuf* pixbuf;
g_return_val_if_fail (WEBKIT_IS_WEB_VIEW (web_view), NULL);
- window = gtk_widget_get_window (web_view);
- g_return_val_if_fail (window != NULL, NULL);
gtk_widget_get_allocation (web_view, &allocation);
x = allocation.x;
@@ -5254,9 +5255,14 @@ midori_view_web_view_get_snapshot (GtkWidget* web_view,
}
#if GTK_CHECK_VERSION (3, 0, 0)
- cairo_t* cr = gdk_cairo_create (window);
+ surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
+ allocation.width, allocation.height);
+ cr = cairo_create (surface);
+ cairo_rectangle (cr, x, y, width, height);
+ cairo_clip (cr);
gtk_widget_draw (web_view, cr);
- pixbuf = NULL; /* TODO */
+ pixbuf = gdk_pixbuf_get_from_surface (surface, x, y, width, height);
+ cairo_surface_destroy (surface);
cairo_destroy (cr);
#else
rect.x = x;
@@ -5264,6 +5270,9 @@ midori_view_web_view_get_snapshot (GtkWidget* web_view,
rect.width = w;
rect.height = h;
+ window = gtk_widget_get_window (web_view);
+ g_return_val_if_fail (window != NULL, NULL);
+
pixmap = gdk_pixmap_new (window, w, h, gdk_drawable_get_depth (window));
event.expose.type = GDK_EXPOSE;
event.expose.window = pixmap;
More information about the Xfce4-commits
mailing list