diff options
author | Mario Sanchez Prada <msanchez@gnome.org> | 2012-12-04 20:32:12 +0800 |
---|---|---|
committer | Mario Sanchez Prada <msanchez@gnome.org> | 2012-12-04 20:05:48 +0800 |
commit | 5162cc396cb35293bf10dad3ba9e193f4bc43ec7 (patch) | |
tree | fd38d09ed3fbd4cb135cc9a5daa9a1a09b2c72bf /src | |
parent | 24ec29a91bf161c84270ec2b3ad66dfaa3731738 (diff) | |
download | gsoc2013-epiphany-5162cc396cb35293bf10dad3ba9e193f4bc43ec7.tar gsoc2013-epiphany-5162cc396cb35293bf10dad3ba9e193f4bc43ec7.tar.gz gsoc2013-epiphany-5162cc396cb35293bf10dad3ba9e193f4bc43ec7.tar.bz2 gsoc2013-epiphany-5162cc396cb35293bf10dad3ba9e193f4bc43ec7.tar.lz gsoc2013-epiphany-5162cc396cb35293bf10dad3ba9e193f4bc43ec7.tar.xz gsoc2013-epiphany-5162cc396cb35293bf10dad3ba9e193f4bc43ec7.tar.zst gsoc2013-epiphany-5162cc396cb35293bf10dad3ba9e193f4bc43ec7.zip |
Port EphyCompletionModel to WebKit2GTK+ favicons API.
https://bugzilla.gnome.org/show_bug.cgi?id=679370
Diffstat (limited to 'src')
-rw-r--r-- | src/ephy-completion-model.c | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/src/ephy-completion-model.c b/src/ephy-completion-model.c index 373fd0c42..87980c71b 100644 --- a/src/ephy-completion-model.c +++ b/src/ephy-completion-model.c @@ -23,6 +23,7 @@ #include "ephy-embed-prefs.h" #include "ephy-embed-shell.h" +#include "ephy-favicon-helpers.h" #include "ephy-history-service.h" #include "ephy-shell.h" @@ -166,22 +167,29 @@ typedef struct { gboolean is_bookmark; } PotentialRow; -#ifdef HAVE_WEBKIT2 -/* TODO: Favicons */ -#else typedef struct { GtkListStore *model; GtkTreeRowReference *row_reference; } IconLoadData; - static void icon_loaded_cb (GObject *source, GAsyncResult *result, gpointer user_data) { GtkTreeIter iter; GtkTreePath *path; IconLoadData *data = (IconLoadData *) user_data; - GdkPixbuf *favicon = webkit_favicon_database_get_favicon_pixbuf_finish (webkit_get_favicon_database (), result, NULL); + WebKitFaviconDatabase *database = WEBKIT_FAVICON_DATABASE (source); + GdkPixbuf *favicon = NULL; + +#ifdef HAVE_WEBKIT2 + cairo_surface_t *icon_surface = webkit_favicon_database_get_favicon_finish (database, result, NULL); + if (icon_surface) { + favicon = ephy_pixbuf_get_from_surface_scaled (icon_surface, FAVICON_SIZE, FAVICON_SIZE); + cairo_surface_destroy (icon_surface); + } +#else + favicon = webkit_favicon_database_get_favicon_pixbuf_finish (database, result, NULL); +#endif if (favicon) { /* The completion model might have changed its contents */ @@ -198,19 +206,20 @@ icon_loaded_cb (GObject *source, GAsyncResult *result, gpointer user_data) gtk_tree_row_reference_free (data->row_reference); g_slice_free (IconLoadData, data); } -#endif static void set_row_in_model (EphyCompletionModel *model, int position, PotentialRow *row) { GtkTreeIter iter; - GdkPixbuf *favicon; GtkTreePath *path; -#ifdef HAVE_WEBKIT2 - /* TODO: Favicons */ -#else IconLoadData *data; - WebKitFaviconDatabase* database = webkit_get_favicon_database (); + WebKitFaviconDatabase* database; + +#ifndef HAVE_WEBKIT2 + GdkPixbuf *favicon; + database = webkit_get_favicon_database (); +#else + database = webkit_web_context_get_favicon_database (webkit_web_context_get_default ()); #endif gtk_list_store_insert_with_values (GTK_LIST_STORE (model), &iter, position, @@ -222,9 +231,7 @@ set_row_in_model (EphyCompletionModel *model, int position, PotentialRow *row) EPHY_COMPLETION_RELEVANCE_COL, row->relevance, -1); -#ifdef HAVE_WEBKIT2 - /* TODO: Favicons */ -#else +#ifndef HAVE_WEBKIT2 /* We try first with the try_get_favicon_pixbuf() because if the icon is in the DB it's faster than the async version. */ favicon = webkit_favicon_database_try_get_favicon_pixbuf (database, row->location, @@ -234,6 +241,7 @@ set_row_in_model (EphyCompletionModel *model, int position, PotentialRow *row) g_object_unref (favicon); return; } +#endif data = g_slice_new (IconLoadData); data->model = GTK_LIST_STORE (g_object_ref(model)); @@ -241,9 +249,13 @@ set_row_in_model (EphyCompletionModel *model, int position, PotentialRow *row) data->row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), path); gtk_tree_path_free (path); +#ifdef HAVE_WEBKIT2 + webkit_favicon_database_get_favicon (database, row->location, + NULL, icon_loaded_cb, data); +#else webkit_favicon_database_get_favicon_pixbuf (database, row->location, - FAVICON_SIZE, FAVICON_SIZE, NULL, - icon_loaded_cb, data); + FAVICON_SIZE, FAVICON_SIZE, + NULL, icon_loaded_cb, data); #endif } |