[webkit-help] cannot create a snapshot of WebKitWebView

avishkar gupta avishkar_gupta at outlook.com
Fri Jun 13 11:47:33 PDT 2014


hi,


I have the following code which compiles and runs successfully,however no matter what uri I choose I always get the error “There was an error creating the snapshot”. I would please request you to point out the problem with this code.


Please note that in order to run this code you need to provide a uri argument to webkit_web_view_load_uri.


I would have not posted this here but I could not find any coding samples or additional documentation available on said topic, other than the API docs.


thanks.


#include <webkit2/webkit2.h>
#include <gtk/gtk.h>


static void 
snapshot_chain_cb(WebKitWebView *web_view,
      GAsyncResult* res,
      gpointer data)
{
 GError * err = NULL ;
 cairo_surface_t *surface = webkit_web_view_get_snapshot_finish(WEBKIT_WEB_VIEW(web_view),res,&err);
 if ( err )
 {
  printf("We have a problem.Specifically:%s\n",err->message);
 }
}


static void 
cbfunc(WebKitWebView *webview,
  WebKitLoadEvent load_status,
  gpointer data)
{
 if ( load_status != WEBKIT_LOAD_FINISHED )
  return ;


 webkit_web_view_get_snapshot(webview,
         WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT,
         WEBKIT_SNAPSHOT_OPTIONS_INCLUDE_SELECTION_HIGHLIGHTING,
         NULL,
         (GAsyncReadyCallback)snapshot_chain_cb,
         NULL);
}


int main(int argc,char* argv[])
{
 gtk_init(&argc,&argv);
 GtkWidget* webview = webkit_web_view_new();
 GtkWidget* mainwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 GtkWidget* scrollable = gtk_scrolled_window_new(NULL,NULL);
 gtk_container_add(GTK_CONTAINER(mainwindow),scrollable);
 gtk_container_add(GTK_CONTAINER(scrollable),webview);


 webkit_web_view_load_uri(WEBKIT_WEB_VIEW(webview),"");


 g_signal_connect(webview,"load-changed",G_CALLBACK(cbfunc),NULL);
 gtk_main();
 return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-help/attachments/20140613/102280cb/attachment.html>


More information about the webkit-help mailing list