From 94c6fca20f40e21910ef42b9eaeb62859deca994 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 13 May 2012 01:33:23 +0200 Subject: [PATCH] Use WebKitFaviconDatabase as of WebKit 1.8.0 Fixes: https://bugs.launchpad.net/midori/+bug/902456 --- katze/katze-item.c | 8 ++++++++ midori/main.c | 10 ++++++++++ midori/midori-view.c | 14 +++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/katze/katze-item.c b/katze/katze-item.c index 7df2ea05..36446b77 100644 --- a/katze/katze-item.c +++ b/katze/katze-item.c @@ -15,6 +15,8 @@ #include +#include + /** * SECTION:katze-item * @short_description: A useful item @@ -442,6 +444,12 @@ katze_item_get_image (KatzeItem* item) if (KATZE_ITEM_IS_FOLDER (item)) image = gtk_image_new_from_stock (GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU); + #if WEBKIT_CHECK_VERSION (1, 8, 0) + /* FIXME: Don't hard-code icon size */ + else if ((pixbuf = webkit_favicon_database_try_get_favicon_pixbuf ( + webkit_get_favicon_database (), item->uri, 16, 16))) + image = gtk_image_new_from_pixbuf (pixbuf); + #endif else if ((pixbuf = g_object_get_data (G_OBJECT (item), "pixbuf"))) image = gtk_image_new_from_pixbuf (pixbuf); else if ((icon = katze_item_get_icon (item)) && !strchr (icon, '/')) diff --git a/midori/main.c b/midori/main.c index 588bac33..cb4e1c4d 100644 --- a/midori/main.c +++ b/midori/main.c @@ -981,6 +981,13 @@ midori_load_soup_session (gpointer settings) G_CALLBACK (soup_session_settings_notify_first_party_cb), session); #endif + #if WEBKIT_CHECK_VERSION (1, 8, 0) + gchar* cache = g_build_filename (g_get_user_data_dir (), + "webkit", "icondatabase", NULL); + webkit_favicon_database_set_path (webkit_get_favicon_database (), cache); + g_free (cache); + #endif + g_signal_connect (session, "request-queued", G_CALLBACK (midori_soup_session_settings_accept_language_cb), settings); @@ -1794,6 +1801,9 @@ midori_clear_page_icons_cb (void) "webkit", "icondatabase", NULL); sokoke_remove_path (cache, TRUE); g_free (cache); + #if WEBKIT_CHECK_VERSION (1, 8, 0) + webkit_favicon_database_clear (webkit_get_favicon_database ()); + #endif } static void diff --git a/midori/midori-view.c b/midori/midori-view.c index 00863f48..1ca8011a 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -802,6 +802,7 @@ free_parts: g_strfreev (parts); } +#if !WEBKIT_CHECK_VERSION (1, 8, 0) static gboolean katze_net_icon_status_cb (KatzeNetRequest* request, MidoriView* view) @@ -869,15 +870,25 @@ katze_net_icon_transfer_cb (KatzeNetRequest* request, pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf, icon_width, icon_height, GDK_INTERP_BILINEAR); midori_view_apply_icon (view, pixbuf_scaled, view->icon_uri); } +#endif static void _midori_web_view_load_icon (MidoriView* view) { GdkPixbuf* pixbuf = NULL; gint icon_width, icon_height; - GdkPixbuf* pixbuf_scaled; GtkSettings* settings; + #if WEBKIT_CHECK_VERSION (1, 8, 0) + settings = gtk_widget_get_settings (view->web_view); + gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU, + &icon_width, &icon_height); + if ((pixbuf = webkit_web_view_try_get_favicon_pixbuf ( + WEBKIT_WEB_VIEW (view->web_view), 16, 16))) + midori_view_apply_icon (view, pixbuf, view->icon_uri); + #else + GdkPixbuf* pixbuf_scaled; + if (!midori_uri_is_http (view->icon_uri)) katze_assign (view->icon_uri, NULL); @@ -932,6 +943,7 @@ _midori_web_view_load_icon (MidoriView* view) pixbuf = pixbuf_scaled; midori_view_apply_icon (view, pixbuf, view->icon_uri); } + #endif } static void