[webkit-gtk] Access web view in g_signal_callback

Chunyang Xu xuchunyang56 at gmail.com
Mon Aug 18 21:49:33 PDT 2014


Hi,

2014-08-19 12:35 GMT+08:00 Dub <dubcanada at gmail.com>:
> Hello,
>
> I am using GTK 3.12 and GTK WebKit 2 and I have a g_signal_callback that I
> want to change the HTML content of the web view on click basically.
>
> So I have a
>
> struct data {
>     WebKitWebView *web_view;
> };
>
> And I start the webview and add it too my window
>
> data.web_view = (WebKitWebView *) webkit_web_view_new();
> GtkWidget *web_window = gtk_scrolled_window_new(NULL, NULL);
> gtk_container_add(GTK_CONTAINER(web_window), GTK_WIDGET(notes.web_view));
>

"Note that WebKitWebView is scrollable by itself, so you don't need to
embed it in a GtkScrolledWindow."

http://webkitgtk.org/reference/webkit2gtk/unstable/WebKitWebView.html#WebKitWebView.description


> And then I have a signal
>
> g_signal_connect(blah, "blah", G_CALLBACK(function), &data);
>
> And a function
>
> void function(struct data *blah) {
>     webkit_web_view_load_html(blah->web_view, html, NULL);
> }
>
> And everything but the callback works, when I press the button I get
>
> ** CRITICAL **: void webkit_web_view_load_html(WebKitWebView*, const gchar*,
> const gchar*): assertion 'WEBKIT_IS_WEB_VIEW(webView)' failed
>
> But the passed in value is the webview, I've also tried not using a struct
> and it still isn't working.
>
> Any ideas on what could be wrong? Do I need to wait for it too load or do
> something else? I see the HTML (it's only <h1>Hello</h1> so it shouldn't
> take long) before I press the button.
>
> _______________________________________________
> webkit-gtk mailing list
> webkit-gtk at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-gtk
>


More information about the webkit-gtk mailing list