[Xfce4-commits] <midori:master> Have katze_item_get_image update the image on icon changes
Christian Dywan
noreply at xfce.org
Sun Dec 16 19:52:02 CET 2012
Updating branch refs/heads/master
to 0898d6a4e9a0e460fdfe5a1b212787d567a2ecff (commit)
from 6f9898fe6ebbf5a5fb280755503640e987df5716 (commit)
commit 0898d6a4e9a0e460fdfe5a1b212787d567a2ecff
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun Dec 16 19:39:09 2012 +0100
Have katze_item_get_image update the image on icon changes
katze/katze-item.c | 42 ++++++++++++++++++++++++++++++++++++++++++
midori/webkitgtk-3.0.vapi | 2 ++
2 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/katze/katze-item.c b/katze/katze-item.c
index 9365b18..821e79c 100644
--- a/katze/katze-item.c
+++ b/katze/katze-item.c
@@ -458,6 +458,38 @@ katze_item_get_pixbuf (KatzeItem* item,
return NULL;
}
+#if WEBKIT_CHECK_VERSION (1, 3, 13)
+static void
+#if WEBKIT_CHECK_VERSION (1, 8, 0)
+katze_item_icon_loaded_cb (WebKitFaviconDatabase* database,
+#elif WEBKIT_CHECK_VERSION (1, 3, 13)
+katze_item_icon_loaded_cb (WebKitFaviconDatabase* database,
+ WebKitWebFrame* web_frame,
+#endif
+ const gchar* frame_uri,
+ GtkWidget* image)
+{
+ KatzeItem* item = g_object_get_data (G_OBJECT (image), "KatzeItem");
+ GdkPixbuf* pixbuf = katze_item_get_pixbuf (item, image);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
+ g_object_unref (pixbuf);
+}
+#endif
+
+static void
+katze_item_image_destroyed_cb (GtkWidget* image,
+ KatzeItem* item)
+{
+ #if WEBKIT_CHECK_VERSION (1, 8, 0)
+ g_signal_handlers_disconnect_by_func (webkit_get_favicon_database (),
+ katze_item_icon_loaded_cb, image);
+ #elif WEBKIT_CHECK_VERSION (1, 3, 13)
+ g_signal_handlers_disconnect_by_func (webkit_get_icon_database (),
+ katze_item_icon_loaded_cb, image);
+ #endif
+ g_object_unref (item);
+}
+
/**
* katze_item_get_image:
* @item: a #KatzeItem
@@ -481,9 +513,19 @@ katze_item_get_image (KatzeItem* item,
pixbuf = katze_item_get_pixbuf (item, widget);
image = gtk_image_new_from_pixbuf (pixbuf);
+ g_object_set_data (G_OBJECT (image), "KatzeItem", g_object_ref (item));
+ g_signal_connect (image, "destroy",
+ G_CALLBACK (katze_item_image_destroyed_cb), item);
gtk_widget_show (image);
if (pixbuf != NULL)
g_object_unref (pixbuf);
+ #if WEBKIT_CHECK_VERSION (1, 8, 0)
+ g_signal_connect (webkit_get_favicon_database (), "icon-loaded",
+ G_CALLBACK (katze_item_icon_loaded_cb), image);
+ #elif WEBKIT_CHECK_VERSION (1, 3, 13)
+ g_signal_connect (webkit_get_icon_database (), "icon-loaded",
+ G_CALLBACK (katze_item_icon_loaded_cb), image);
+ #endif
return image;
}
diff --git a/midori/webkitgtk-3.0.vapi b/midori/webkitgtk-3.0.vapi
index 1e29ad4..6461a20 100644
--- a/midori/webkitgtk-3.0.vapi
+++ b/midori/webkitgtk-3.0.vapi
@@ -4,12 +4,14 @@
namespace WebKit {
[CCode (cheader_filename = "webkit/webkit.h")]
public class FaviconDatabase : GLib.Object {
+ public signal void icon_loaded (string frame_uri);
public Gdk.Pixbuf? try_get_favicon_pixbuf (string page_uri, uint width, uint height);
public void set_path (string? path);
public void clear ();
}
[CCode (cheader_filename = "webkit/webkit.h")]
public class IconDatabase : GLib.Object {
+ public signal void icon_loaded (WebKit.WebFrame web_frame, string frame_uri);
public Gdk.Pixbuf? get_icon_pixbuf (string page_uri);
public void set_path (string? path);
public void clear ();
More information about the Xfce4-commits
mailing list