<html>
<head>
<meta name="generator" content="Windows Mail 17.5.9600.20498">
<style data-externalstyle="true"><!--
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
}
p.MsoNormal, li.MsoNormal, div.MsoNormal {
margin:0in;
margin-bottom:.0001pt;
}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst,
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle,
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
line-height:115%;
}
--></style></head>
<body dir="ltr">
<div data-externalstyle="false" dir="ltr" style="font-family: 'Calibri', 'Segoe UI', 'Meiryo', 'Microsoft YaHei UI', 'Microsoft JhengHei UI', 'Malgun Gothic', 'sans-serif';font-size:12pt;"><div>hi,</div><div><br></div><div>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.</div><div><br></div><div>Please note that in order to run this code you need to provide a uri argument to webkit_web_view_load_uri.</div><div><br></div><div>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.</div><div><br></div><div>thanks.</div><div><br></div><div>#include <webkit2/webkit2.h><br>#include <gtk/gtk.h></div><div><br></div><div>static void <br>snapshot_chain_cb(WebKitWebView *web_view,<br> GAsyncResult* res,<br> gpointer data)<br>{<br> GError * err = NULL ;<br> cairo_surface_t *surface = webkit_web_view_get_snapshot_finish(WEBKIT_WEB_VIEW(web_view),res,&err);<br> if ( err )<br> {<br> printf("We have a problem.Specifically:%s\n",err->message);<br> }<br>}</div><div><br></div><div>static void <br>cbfunc(WebKitWebView *webview,<br> WebKitLoadEvent load_status,<br> gpointer data)<br>{<br> if ( load_status != WEBKIT_LOAD_FINISHED )<br> return ;</div><div><br></div><div> webkit_web_view_get_snapshot(webview,<br> WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT,<br> WEBKIT_SNAPSHOT_OPTIONS_INCLUDE_SELECTION_HIGHLIGHTING,<br> NULL,<br> (GAsyncReadyCallback)snapshot_chain_cb,<br> NULL);<br>}</div><div><br></div><div>int main(int argc,char* argv[])<br>{<br> gtk_init(&argc,&argv);<br> GtkWidget* webview = webkit_web_view_new();<br> GtkWidget* mainwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);<br> GtkWidget* scrollable = gtk_scrolled_window_new(NULL,NULL);<br> gtk_container_add(GTK_CONTAINER(mainwindow),scrollable);<br> gtk_container_add(GTK_CONTAINER(scrollable),webview);</div><div><br></div><div> webkit_web_view_load_uri(WEBKIT_WEB_VIEW(webview),"");</div><div><br></div><div> g_signal_connect(webview,"load-changed",G_CALLBACK(cbfunc),NULL);<br> gtk_main();<br> return 0;<br>}<br></div></div>
</body>
</html>