[epiphany] Port EphyCompletionModel to WebKit2GTK+ favicons API.
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Port EphyCompletionModel to WebKit2GTK+ favicons API.
- Date: Tue, 4 Dec 2012 12:33:47 +0000 (UTC)
commit 5162cc396cb35293bf10dad3ba9e193f4bc43ec7
Author: Mario Sanchez Prada <msanchez gnome org>
Date: Tue Dec 4 13:32:12 2012 +0100
Port EphyCompletionModel to WebKit2GTK+ favicons API.
https://bugzilla.gnome.org/show_bug.cgi?id=679370
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 373fd0c..87980c7 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
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]