[Xfce4-commits] <midori:master> Add 1.3.13 IconDatabase code path equivalent to 1.8.0

Christian Dywan noreply at xfce.org
Sun Dec 9 02:12:02 CET 2012


Updating branch refs/heads/master
         to b391161e3fae9bc5aa8337b820ffb64cbfc7b63d (commit)
       from a3602439a8c7eea844a80d3691f1d6ec038c820e (commit)

commit b391161e3fae9bc5aa8337b820ffb64cbfc7b63d
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Dec 9 02:10:11 2012 +0100

    Add 1.3.13 IconDatabase code path equivalent to 1.8.0
    
    Also ensure that themed icon size is used.

 katze/katze-net.c         |    2 +-
 katze/katze-net.h         |    2 +-
 katze/midori-paths.vala   |   20 ++++++++++++++++++--
 midori/midori-browser.c   |    2 +-
 midori/midori-view.c      |   24 ++++++++++++++++--------
 midori/webkitgtk-3.0.vapi |    8 ++++++++
 wscript                   |    2 ++
 7 files changed, 47 insertions(+), 13 deletions(-)

diff --git a/katze/katze-net.c b/katze/katze-net.c
index fc82510..75a9949 100644
--- a/katze/katze-net.c
+++ b/katze/katze-net.c
@@ -77,7 +77,7 @@ katze_net_priv_free (KatzeNetPriv* priv)
     g_slice_free (KatzeNetPriv, priv);
 }
 
-#if !WEBKIT_CHECK_VERSION (1, 8, 0)
+#if !WEBKIT_CHECK_VERSION (1, 3, 13)
 gchar*
 katze_net_get_cached_path (KatzeNet*    net,
                            const gchar* uri,
diff --git a/katze/katze-net.h b/katze/katze-net.h
index 87c0912..a6371fb 100644
--- a/katze/katze-net.h
+++ b/katze/katze-net.h
@@ -67,7 +67,7 @@ katze_net_load_uri                       (KatzeNet*          net,
                                           KatzeNetTransferCb transfer_cb,
                                           gpointer           user_data);
 
-#if !WEBKIT_CHECK_VERSION (1, 8, 0)
+#if !WEBKIT_CHECK_VERSION (1, 3, 13)
 gchar*
 katze_net_get_cached_path                (KatzeNet*          net,
                                           const gchar*       uri,
diff --git a/katze/midori-paths.vala b/katze/midori-paths.vala
index 2f62a90..cc475e8 100644
--- a/katze/midori-paths.vala
+++ b/katze/midori-paths.vala
@@ -119,6 +119,9 @@ namespace Midori {
 #if HAVE_WEBKIT_1_8_0
             if (user_data_dir != null)
                 WebKit.get_favicon_database ().set_path (Path.build_filename (user_data_dir, "webkit", "icondatabase"));
+#elif HAVE_WEBKIT_1_3_13
+            if (user_data_dir != null)
+                WebKit.get_icon_database ().set_path (Path.build_filename (user_data_dir, "webkit", "icondatabase"));
 #endif
             if (strcmp (Environment.get_variable ("MIDORI_DEBUG"), "paths") == 0) {
                 stdout.printf ("config: %s\ncache: %s\nuser_data: %s\ntmp: %s\n",
@@ -373,6 +376,8 @@ namespace Midori {
             assert (user_data_dir != null);
 #if HAVE_WEBKIT_1_8_0
             WebKit.get_favicon_database ().clear ();
+#elif HAVE_WEBKIT_1_3_13
+            WebKit.get_icon_database ().clear ();
 #endif
             /* FIXME: Exclude search engine icons */
             remove_path (Path.build_filename (cache_dir, "icons"));
@@ -383,11 +388,22 @@ namespace Midori {
             if (!Midori.URI.is_resource (uri))
                 return null;
 #if HAVE_WEBKIT_1_8_0
-            /* FIXME: Don't hard-code icon size */
+            int icon_width = 16, icon_height = 16;
+            if (widget != null)
+                Gtk.icon_size_lookup_for_settings (widget.get_settings (),
+                    Gtk.IconSize.MENU, out icon_width, out icon_height);
             Gdk.Pixbuf? pixbuf = WebKit.get_favicon_database ()
-                .try_get_favicon_pixbuf (uri, 16, 16);
+                .try_get_favicon_pixbuf (uri, icon_width, icon_height);
             if (pixbuf != null)
                 return pixbuf;
+#elif HAVE_WEBKIT_1_3_13
+            int icon_width = 16, icon_height = 16;
+            if (widget != null)
+                Gtk.icon_size_lookup_for_settings (widget.get_settings (),
+                    Gtk.IconSize.MENU, out icon_width, out icon_height);
+            Gdk.Pixbuf? pixbuf = WebKit.get_icon_database ().get_icon_pixbuf (uri);
+            if (pixbuf != null)
+                return pixbuf.scale_simple (icon_width, icon_height, Gdk.InterpType.BILINEAR);
 #endif
             return Katze.load_cached_icon (uri, widget);
         }
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 6102b03..96520c0 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -2415,7 +2415,7 @@ _action_add_desktop_shortcut_activate (GtkAction*     action,
     GKeyFile* keyfile = g_key_file_new ();
     gchar* filename = g_strdelimit (g_strconcat (app_name, ".desktop", NULL), "/", '_');
     gchar* app_dir = g_build_filename (g_get_user_data_dir (), "applications", filename, NULL);
-    #if WEBKIT_CHECK_VERSION (1, 8, 0)
+    #if WEBKIT_CHECK_VERSION (1, 3, 13)
     /* FIXME: midori_paths_get_icon */
     gchar* app_icon = g_strdup (STOCK_WEB_BROWSER);
     #else
diff --git a/midori/midori-view.c b/midori/midori-view.c
index a0d5a9d..653c93b 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -473,7 +473,7 @@ midori_view_unset_icon (MidoriView* view)
     midori_view_apply_icon (view, pixbuf, "stock://gtk-file");
 }
 
-#if !WEBKIT_CHECK_VERSION (1, 8, 0)
+#if !WEBKIT_CHECK_VERSION (1, 3, 13)
 static void
 katze_net_object_maybe_unref (gpointer object)
 {
@@ -560,11 +560,23 @@ katze_net_icon_transfer_cb (KatzeNetRequest*  request,
 static void
 _midori_web_view_load_icon (MidoriView* view)
 {
+    gint icon_width = 16, icon_height = 16;
+    GtkSettings* settings = gtk_widget_get_settings (view->web_view);
+    gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU, &icon_width, &icon_height);
     GdkPixbuf* pixbuf = NULL;
     #if WEBKIT_CHECK_VERSION (1, 8, 0)
     if ((pixbuf = webkit_web_view_try_get_favicon_pixbuf (
-        WEBKIT_WEB_VIEW (view->web_view), 16, 16)))
+        WEBKIT_WEB_VIEW (view->web_view), icon_width, icon_height)))
         midori_view_apply_icon (view, pixbuf, view->icon_uri);
+    #elif WEBKIT_CHECK_VERSION (1, 3, 13)
+    if ((pixbuf = webkit_web_view_get_icon_pixbuf (
+        WEBKIT_WEB_VIEW (view->web_view))))
+    {
+        GdkPixbuf* pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf,
+            icon_width, icon_height, GDK_INTERP_BILINEAR);
+        g_object_unref (pixbuf);
+        midori_view_apply_icon (view, pixbuf_scaled, view->icon_uri);
+    }
     #else
     GdkPixbuf* pixbuf_scaled;
     const gchar* uri = midori_tab_get_uri (MIDORI_TAB (view));
@@ -614,12 +626,8 @@ _midori_web_view_load_icon (MidoriView* view)
 
     if (pixbuf)
     {
-        gint icon_width, icon_height;
-        GtkSettings* settings = gtk_widget_get_settings (view->web_view);
-        gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU,
-                                           &icon_width, &icon_height);
-        pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf, icon_width,
-            icon_height, GDK_INTERP_BILINEAR);
+        pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf,
+            icon_width,  icon_height, GDK_INTERP_BILINEAR);
         g_object_unref (pixbuf);
         pixbuf = pixbuf_scaled;
         midori_view_apply_icon (view, pixbuf, view->icon_uri);
diff --git a/midori/webkitgtk-3.0.vapi b/midori/webkitgtk-3.0.vapi
index d856b82..1e29ad4 100644
--- a/midori/webkitgtk-3.0.vapi
+++ b/midori/webkitgtk-3.0.vapi
@@ -9,6 +9,12 @@ namespace WebKit {
 		public void clear ();
 	}
 	[CCode (cheader_filename = "webkit/webkit.h")]
+	public class IconDatabase : GLib.Object {
+		public Gdk.Pixbuf? get_icon_pixbuf (string page_uri);
+		public void set_path (string? path);
+		public void clear ();
+	}
+	[CCode (cheader_filename = "webkit/webkit.h")]
 	public class DOMDOMTokenList : GLib.Object {
 		[CCode (has_construct_function = false)]
 		protected DOMDOMTokenList ();
@@ -804,6 +810,8 @@ namespace WebKit {
 	[CCode (cheader_filename = "webkit/webkit.h")]
 	public static unowned WebKit.FaviconDatabase get_favicon_database ();
 	[CCode (cheader_filename = "webkit/webkit.h")]
+	public static unowned WebKit.IconDatabase get_icon_database ();
+	[CCode (cheader_filename = "webkit/webkit.h")]
 	public static unowned string get_web_database_directory_path ();
 	[CCode (cheader_filename = "webkit/webkit.h")]
 	public static unowned WebKit.WebPluginDatabase get_web_plugin_database ();
diff --git a/wscript b/wscript
index ee10a0b..b29fcf4 100644
--- a/wscript
+++ b/wscript
@@ -298,6 +298,8 @@ def configure (conf):
         conf.define ('HAVE_LIBSOUP_2_37_1', 1)
     if check_version (conf.env['WEBKIT_VERSION'], 1, 3, 8):
         conf.env.append_value ('VALAFLAGS', '-D HAVE_WEBKIT_1_3_8')
+    if check_version (conf.env['WEBKIT_VERSION'], 1, 3, 13):
+        conf.env.append_value ('VALAFLAGS', '-D HAVE_WEBKIT_1_3_13')
     if check_version (conf.env['WEBKIT_VERSION'], 1, 8, 0):
         conf.env.append_value ('VALAFLAGS', '-D HAVE_WEBKIT_1_8_0')
     check_pkg ('libxml-2.0', '2.6')


More information about the Xfce4-commits mailing list