Implement midori_view_web_view_get_snapshot for GTK+ 3
This commit is contained in:
parent
c60a9d220a
commit
59b3d9319c
1 changed files with 14 additions and 5 deletions
|
@ -5217,22 +5217,23 @@ midori_view_web_view_get_snapshot (GtkWidget* web_view,
|
||||||
gint width,
|
gint width,
|
||||||
gint height)
|
gint height)
|
||||||
{
|
{
|
||||||
GdkWindow* window;
|
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
gboolean fast;
|
gboolean fast;
|
||||||
gint x, y, w, h;
|
gint x, y, w, h;
|
||||||
GdkRectangle rect;
|
GdkRectangle rect;
|
||||||
#if !GTK_CHECK_VERSION (3, 0, 0)
|
#if !GTK_CHECK_VERSION (3, 0, 0)
|
||||||
|
GdkWindow* window;
|
||||||
GdkPixmap* pixmap;
|
GdkPixmap* pixmap;
|
||||||
GdkEvent event;
|
GdkEvent event;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
GdkColormap* colormap;
|
GdkColormap* colormap;
|
||||||
|
#else
|
||||||
|
cairo_surface_t* surface;
|
||||||
|
cairo_t* cr;
|
||||||
#endif
|
#endif
|
||||||
GdkPixbuf* pixbuf;
|
GdkPixbuf* pixbuf;
|
||||||
|
|
||||||
g_return_val_if_fail (WEBKIT_IS_WEB_VIEW (web_view), NULL);
|
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);
|
gtk_widget_get_allocation (web_view, &allocation);
|
||||||
x = allocation.x;
|
x = allocation.x;
|
||||||
|
@ -5254,9 +5255,14 @@ midori_view_web_view_get_snapshot (GtkWidget* web_view,
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
#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);
|
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);
|
cairo_destroy (cr);
|
||||||
#else
|
#else
|
||||||
rect.x = x;
|
rect.x = x;
|
||||||
|
@ -5264,6 +5270,9 @@ midori_view_web_view_get_snapshot (GtkWidget* web_view,
|
||||||
rect.width = w;
|
rect.width = w;
|
||||||
rect.height = h;
|
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));
|
pixmap = gdk_pixmap_new (window, w, h, gdk_drawable_get_depth (window));
|
||||||
event.expose.type = GDK_EXPOSE;
|
event.expose.type = GDK_EXPOSE;
|
||||||
event.expose.window = pixmap;
|
event.expose.window = pixmap;
|
||||||
|
|
Loading…
Reference in a new issue