+void
+changed_favicon(GObject *obj, GParamSpec *pspec, gpointer data)
+{
+ struct Client *c = (struct Client *)data;
+ cairo_surface_t *f;
+ int w, h, w_should, h_should;
+ GdkPixbuf *pb, *pb_scaled;
+
+ f = webkit_web_view_get_favicon(WEBKIT_WEB_VIEW(c->web_view));
+ if (f == NULL)
+ {
+ gtk_image_set_from_icon_name(GTK_IMAGE(c->tabicon), "text-html",
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
+ }
+ else
+ {
+ w = cairo_image_surface_get_width(f);
+ h = cairo_image_surface_get_height(f);
+ pb = gdk_pixbuf_get_from_surface(f, 0, 0, w, h);
+ if (pb != NULL)
+ {
+ w_should = 16 * gtk_widget_get_scale_factor(c->tabicon);
+ h_should = 16 * gtk_widget_get_scale_factor(c->tabicon);
+ pb_scaled = gdk_pixbuf_scale_simple(pb, w_should, h_should,
+ GDK_INTERP_BILINEAR);
+ gtk_image_set_from_pixbuf(GTK_IMAGE(c->tabicon), pb_scaled);
+
+ g_object_unref(pb_scaled);
+ g_object_unref(pb);
+ }
+ }
+}
+