0

I am working on a web browser for fun and ran into this problem.

This works:

#include <webkit/webkit.h>

void init() {
    GtkWidget *web_view = webkit_web_view_new();
    g_signal_connect(
      G_OBJECT(GTK_WIDGET(this->web_view)),
      "notify::progress",
      G_CALLBACK(LoadChangedProxy),
      NULL);
    webkit_web_view_load_uri(WEBKIT_WEB_VIEW(this->web_view), "http://google.com");
}

void LoadChangedProxy(GtkWidget *view, GParamSpec *pspec, gpointer p) {
   puts("LOADING");
}

In this case the callback is never called:

#include <webkit2/webkit2.h>

void init() {
    GtkWidget *web_view = webkit_web_view_new();
    g_signal_connect(
      G_OBJECT(GTK_WIDGET(this->web_view)),
      "notify::estimated-load-progress",
      G_CALLBACK(LoadChangedProxy),
      NULL);
    webkit_web_view_load_uri(WEBKIT_WEB_VIEW(this->web_view), "http://google.com");
}

void LoadChangedProxy(GtkWidget *view, GParamSpec *pspec, gpointer p) {
   puts("LOADING");
}

I was attempting to use webkitgtk2 initially and was really hitting my head against the wall. I switched to the older webkitgtk1 header and api and it magically started working. I have not idea what would cause this, additionally no errors are printed to stderr or stdout (eg. attempting to connect to a signal that an object does not have).

Any suggestions out there? There is surprisingly little documentation on g_signal_connect, from glib. All I know has come from looking at some gnome app source code.

Edit: I have found that using "notify::progress" signal identifier in the webkitgtk2 case, the callback works. However I then cannot use either webkit_web_view_get_progress() or webkit_web_view_get_estimated_load_progress() to read the progress value to display it.

Jussi Kukkonen
  • 13,857
  • 1
  • 37
  • 54
papodaca
  • 45
  • 4

1 Answers1

0

The symptoms are strange enough that I can only think of one explanation: you are still linking with webkit-gtk. With trivial code like this you didn't happen to hit linking problems but of course the new signals wouldn't be there either.

Jussi Kukkonen
  • 13,857
  • 1
  • 37
  • 54
  • 1
    But if the `estimated-load-progress` property isn't present, wouldn't GLib spit some error out at runtime saying so? @papodaca: do you see such a warning on stderr? – andlabs Jan 26 '15 at 08:26
  • 1
    @andlabs that would happen for a non-existent signal but I don't think there's a warning for unknown signal detail. – Jussi Kukkonen Jan 27 '15 at 22:38
  • @kju thanks; hm... I wonder if that should be changed in a future version of GLib (specifically for `notify` here; I've never built custom signals with details so IDK if that can be extended to other signals or not) :/ – andlabs Jan 27 '15 at 22:59