cwebkitgtk

webkit_web_view_get_favicon always returns null and notify::favicon never fires


I'm trying two different ways to get the favicon of the current website (which is https://google.com) that's loaded in my webview:

1: webkit_web_view_get_favicon(webview) where webview is WebKitWebView *.

2:

void favicon_callback(WebKitFaviconDatabase *self, gchar *page_uri, gchar *favicon_uri,
          gpointer user_data) {
  printf("what: %s %s\n", page_uri, favicon_uri);
}
g_signal_connect(webview, "notify::favicon", G_CALLBACK(favicon_callback), NULL);

First one returns null going a minute or more after the page has loaded. The documentation says this is expected until the favicon loads. It never does, but in any case, I try the callback to watch for it to load. But the callback never fires.

What am I doing wrong?


Solution

  • Without a [mre] I can only give an advice.

    You need to call webkit_web_context_set_favicon_database_directory() in webkit2gtk-4 API or webkit_website_data_manager_set_favicons_enabled() in webkitgtk-6.0 API to enable the favicon storage and the event.