Use WebKitFaviconDatabase as of WebKit 1.8.0

Fixes: https://bugs.launchpad.net/midori/+bug/902456
This commit is contained in:
Christian Dywan 2012-05-13 01:33:23 +02:00
parent cb40b36c0e
commit 94c6fca20f
3 changed files with 31 additions and 1 deletions

View file

@ -15,6 +15,8 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include <webkit/webkit.h>
/** /**
* SECTION:katze-item * SECTION:katze-item
* @short_description: A useful item * @short_description: A useful item
@ -442,6 +444,12 @@ katze_item_get_image (KatzeItem* item)
if (KATZE_ITEM_IS_FOLDER (item)) if (KATZE_ITEM_IS_FOLDER (item))
image = gtk_image_new_from_stock (GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU); 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"))) else if ((pixbuf = g_object_get_data (G_OBJECT (item), "pixbuf")))
image = gtk_image_new_from_pixbuf (pixbuf); image = gtk_image_new_from_pixbuf (pixbuf);
else if ((icon = katze_item_get_icon (item)) && !strchr (icon, '/')) else if ((icon = katze_item_get_icon (item)) && !strchr (icon, '/'))

View file

@ -981,6 +981,13 @@ midori_load_soup_session (gpointer settings)
G_CALLBACK (soup_session_settings_notify_first_party_cb), session); G_CALLBACK (soup_session_settings_notify_first_party_cb), session);
#endif #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_signal_connect (session, "request-queued",
G_CALLBACK (midori_soup_session_settings_accept_language_cb), settings); G_CALLBACK (midori_soup_session_settings_accept_language_cb), settings);
@ -1794,6 +1801,9 @@ midori_clear_page_icons_cb (void)
"webkit", "icondatabase", NULL); "webkit", "icondatabase", NULL);
sokoke_remove_path (cache, TRUE); sokoke_remove_path (cache, TRUE);
g_free (cache); g_free (cache);
#if WEBKIT_CHECK_VERSION (1, 8, 0)
webkit_favicon_database_clear (webkit_get_favicon_database ());
#endif
} }
static void static void

View file

@ -802,6 +802,7 @@ free_parts:
g_strfreev (parts); g_strfreev (parts);
} }
#if !WEBKIT_CHECK_VERSION (1, 8, 0)
static gboolean static gboolean
katze_net_icon_status_cb (KatzeNetRequest* request, katze_net_icon_status_cb (KatzeNetRequest* request,
MidoriView* view) 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); pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf, icon_width, icon_height, GDK_INTERP_BILINEAR);
midori_view_apply_icon (view, pixbuf_scaled, view->icon_uri); midori_view_apply_icon (view, pixbuf_scaled, view->icon_uri);
} }
#endif
static void static void
_midori_web_view_load_icon (MidoriView* view) _midori_web_view_load_icon (MidoriView* view)
{ {
GdkPixbuf* pixbuf = NULL; GdkPixbuf* pixbuf = NULL;
gint icon_width, icon_height; gint icon_width, icon_height;
GdkPixbuf* pixbuf_scaled;
GtkSettings* settings; 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)) if (!midori_uri_is_http (view->icon_uri))
katze_assign (view->icon_uri, NULL); katze_assign (view->icon_uri, NULL);
@ -932,6 +943,7 @@ _midori_web_view_load_icon (MidoriView* view)
pixbuf = pixbuf_scaled; pixbuf = pixbuf_scaled;
midori_view_apply_icon (view, pixbuf, view->icon_uri); midori_view_apply_icon (view, pixbuf, view->icon_uri);
} }
#endif
} }
static void static void