Esempio n. 1
0
static void onSnapshotReady(WebKitWebView* web_view, GAsyncResult* res, WebViewTest* test)
{
    GOwnPtr<GError> error;
    test->m_surface = webkit_web_view_get_snapshot_finish(web_view, res, &error.outPtr());
    g_assert(!test->m_surface || !error.get());
    if (error)
        g_assert_error(error.get(), WEBKIT_SNAPSHOT_ERROR, WEBKIT_SNAPSHOT_ERROR_FAILED_TO_CREATE);
    test->quitMainLoop();
}
Esempio n. 2
0
void get_snapshot_finish(GObject *object,
                                     GAsyncResult *result,
                                     gpointer data)
{
    WebKitWebView * webview = (WebKitWebView*)data;
    GError* error = NULL;
	cairo_surface_t* surface = webkit_web_view_get_snapshot_finish(webview, result, &error);
	cairo_surface_write_to_png(surface, "/tmp/webkitgtk_test.png");

}
Esempio n. 3
0
static void png_finished(GObject *object, GAsyncResult *result, gpointer user_data) {
    WebKitWebView *web_view = WEBKIT_WEB_VIEW(object);
    GError *error = NULL;
    cairo_surface_t *surface = webkit_web_view_get_snapshot_finish(web_view, result, &error);
    if (surface == NULL) {
        errx(1, "error creating snapshot: %s", error->message);
    }
    cairo_surface_write_to_png(surface, png_file);
    cairo_surface_destroy(surface);
    done();
}
Esempio n. 4
0
static void
snapshot_ready (GObject      *source_object,
                GAsyncResult *result,
                gpointer      user_data)
{
  WebKitWebView   *view = WEBKIT_WEB_VIEW (source_object);
  cairo_surface_t *surface;

  surface = webkit_web_view_get_snapshot_finish (view, result,
                                                 &webpagevals.error);

  if (surface)
    {
      gint   width;
      gint   height;
      gint32 layer;

      width  = cairo_image_surface_get_width (surface);
      height = cairo_image_surface_get_height (surface);

      webpagevals.image = gimp_image_new (width, height, GIMP_RGB);

      gimp_image_undo_disable (webpagevals.image);
      layer = gimp_layer_new_from_surface (webpagevals.image, _("Webpage"),
                                           surface,
                                           0.25, 1.0);
      gimp_image_insert_layer (webpagevals.image, layer, -1, 0);
      gimp_image_undo_enable (webpagevals.image);

      cairo_surface_destroy (surface);
    }

  gimp_progress_update (1.0);

  gtk_main_quit ();
}