diff options
author | Sergio Villar Senin <svillar@igalia.com> | 2012-03-08 01:28:02 +0800 |
---|---|---|
committer | Xan Lopez <xan@igalia.com> | 2012-03-20 18:55:11 +0800 |
commit | 6119b95ca4c0c2d4d78b27422dfb6ba9203bab56 (patch) | |
tree | 498151645cb0e38ba8854f738d749e04b39bb58c /src/bookmarks | |
parent | bc0e3b41f8c21fa0b4bd0cd89e305b0fee049b6a (diff) | |
download | gsoc2013-epiphany-6119b95ca4c0c2d4d78b27422dfb6ba9203bab56.tar.gz gsoc2013-epiphany-6119b95ca4c0c2d4d78b27422dfb6ba9203bab56.tar.zst gsoc2013-epiphany-6119b95ca4c0c2d4d78b27422dfb6ba9203bab56.zip |
Replace EphyFaviconCache by WebKit's icon database cache
https://bugzilla.gnome.org/show_bug.cgi?id=648653
Diffstat (limited to 'src/bookmarks')
-rw-r--r-- | src/bookmarks/ephy-bookmark-action.c | 44 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks-editor.c | 44 |
2 files changed, 51 insertions, 37 deletions
diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c index 814fadd7e..7aa30010b 100644 --- a/src/bookmarks/ephy-bookmark-action.c +++ b/src/bookmarks/ephy-bookmark-action.c @@ -26,7 +26,7 @@ #include "ephy-bookmarks.h" #include "ephy-debug.h" #include "ephy-dnd.h" -#include "ephy-favicon-cache.h" +#include "ephy-embed-prefs.h" #include "ephy-gui.h" #include "ephy-shell.h" #include "ephy-string.h" @@ -67,20 +67,22 @@ typedef struct G_DEFINE_TYPE (EphyBookmarkAction, ephy_bookmark_action, EPHY_TYPE_LINK_ACTION) static void -favicon_cache_changed_cb (EphyFaviconCache *cache, - const char *icon_address, - EphyBookmarkAction *action) +favicon_loaded_cb (WebKitFaviconDatabase *database, + const char *page_address, + EphyBookmarkAction *action) { const char *icon; + char *icon_address; g_return_if_fail (action->priv->node != NULL); icon = ephy_node_get_property_string (action->priv->node, EPHY_NODE_BMK_PROP_ICON); - - if (icon != NULL && strcmp (icon, icon_address) == 0) + icon_address = webkit_favicon_database_get_favicon_uri (database, page_address); + + if (g_strcmp0 (icon, icon_address) == 0) { - g_signal_handler_disconnect (cache, action->priv->cache_handler); + g_signal_handler_disconnect (database, action->priv->cache_handler); action->priv->cache_handler = 0; g_object_notify (G_OBJECT (action), "icon"); @@ -93,28 +95,27 @@ ephy_bookmark_action_sync_icon (GtkAction *action, GtkWidget *proxy) { EphyBookmarkAction *bma = EPHY_BOOKMARK_ACTION (action); - const char *icon_location; - EphyFaviconCache *cache; + const char *page_location; + WebKitFaviconDatabase *database; GdkPixbuf *pixbuf = NULL; g_return_if_fail (bma->priv->node != NULL); - icon_location = ephy_node_get_property_string (bma->priv->node, - EPHY_NODE_BMK_PROP_ICON); + page_location = ephy_node_get_property_string (bma->priv->node, + EPHY_NODE_BMK_PROP_LOCATION); - cache = EPHY_FAVICON_CACHE (ephy_embed_shell_get_favicon_cache - (ephy_embed_shell_get_default ())); - - if (icon_location && *icon_location) + database = webkit_get_favicon_database (); + if (page_location && *page_location) { - pixbuf = ephy_favicon_cache_get (cache, icon_location); + pixbuf = webkit_favicon_database_try_get_favicon_pixbuf (database, page_location, + FAVICON_SIZE, FAVICON_SIZE); if (pixbuf == NULL && bma->priv->cache_handler == 0) { bma->priv->cache_handler = g_signal_connect_object - (cache, "changed", - G_CALLBACK (favicon_cache_changed_cb), + (database, "icon-loaded", + G_CALLBACK (favicon_loaded_cb), action, 0); } } @@ -370,14 +371,11 @@ ephy_bookmark_action_dispose (GObject *object) { EphyBookmarkAction *action = (EphyBookmarkAction *) object; EphyBookmarkActionPrivate *priv = action->priv; - GObject *cache; if (priv->cache_handler != 0) { - cache = ephy_embed_shell_get_favicon_cache - (ephy_embed_shell_get_default ()); - - g_signal_handler_disconnect (cache, priv->cache_handler); + WebKitFaviconDatabase *database = webkit_get_favicon_database (); + g_signal_handler_disconnect (database, priv->cache_handler); priv->cache_handler = 0; } diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c index c64d1db48..b30b542b6 100644 --- a/src/bookmarks/ephy-bookmarks-editor.c +++ b/src/bookmarks/ephy-bookmarks-editor.c @@ -26,7 +26,7 @@ #include "ephy-bookmarks-ui.h" #include "ephy-debug.h" #include "ephy-dnd.h" -#include "ephy-favicon-cache.h" +#include "ephy-embed-prefs.h" #include "ephy-file-chooser.h" #include "ephy-file-helpers.h" #include "ephy-gui.h" @@ -1461,26 +1461,42 @@ node_dropped_cb (EphyNodeView *view, } static void +icon_loaded_cb (WebKitFaviconDatabase *database, GAsyncResult *result, GValue *value) +{ + GdkPixbuf *favicon = webkit_favicon_database_get_favicon_pixbuf_finish (database, result, NULL); + if (!favicon) + return; + + g_value_take_object (value, favicon); +} + +static void provide_favicon (EphyNode *node, GValue *value, gpointer user_data) { - EphyFaviconCache *cache; - const char *icon_location; - GdkPixbuf *pixbuf = NULL; + const char *page_location; + GdkPixbuf *favicon = NULL; - cache = EPHY_FAVICON_CACHE - (ephy_embed_shell_get_favicon_cache (EPHY_EMBED_SHELL (ephy_shell))); - icon_location = ephy_node_get_property_string - (node, EPHY_NODE_BMK_PROP_ICON); + page_location = ephy_node_get_property_string + (node, EPHY_NODE_BMK_PROP_LOCATION); - LOG ("Get favicon for %s", icon_location ? icon_location : "None"); + LOG ("Get favicon for %s", page_location ? page_location : "None"); - if (icon_location) - { - pixbuf = ephy_favicon_cache_get (cache, icon_location); - } + if (page_location) + { + WebKitFaviconDatabase *database = webkit_get_favicon_database (); + + /* Try with the sync version first as this method will be frequently called. */ + favicon = webkit_favicon_database_try_get_favicon_pixbuf (database, page_location, + FAVICON_SIZE, FAVICON_SIZE); + + if (!favicon && webkit_favicon_database_get_favicon_uri (database, page_location)) + webkit_favicon_database_get_favicon_pixbuf (database, page_location, + FAVICON_SIZE, FAVICON_SIZE, NULL, + (GAsyncReadyCallback) icon_loaded_cb, value); + } g_value_init (value, GDK_TYPE_PIXBUF); - g_value_take_object (value, pixbuf); + g_value_take_object (value, favicon); } static void |