aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/widgets/ephy-hosts-store.c56
-rw-r--r--lib/widgets/ephy-hosts-store.h1
-rw-r--r--lib/widgets/ephy-hosts-view.c22
3 files changed, 74 insertions, 5 deletions
diff --git a/lib/widgets/ephy-hosts-store.c b/lib/widgets/ephy-hosts-store.c
index b5a9e6af4..38e9b9c55 100644
--- a/lib/widgets/ephy-hosts-store.c
+++ b/lib/widgets/ephy-hosts-store.c
@@ -21,6 +21,7 @@
#include "config.h"
+#include "ephy-embed-prefs.h"
#include "ephy-hosts-store.h"
#include <glib/gi18n.h>
@@ -41,6 +42,7 @@ ephy_hosts_store_init (EphyHostsStore *self)
types[EPHY_HOSTS_STORE_COLUMN_TITLE] = G_TYPE_STRING;
types[EPHY_HOSTS_STORE_COLUMN_ADDRESS] = G_TYPE_STRING;
types[EPHY_HOSTS_STORE_COLUMN_VISIT_COUNT] = G_TYPE_INT;
+ types[EPHY_HOSTS_STORE_COLUMN_FAVICON] = GDK_TYPE_PIXBUF;
gtk_list_store_set_column_types (GTK_LIST_STORE (self),
EPHY_HOSTS_STORE_N_COLUMNS,
@@ -57,22 +59,74 @@ ephy_hosts_store_new (void)
NULL);
}
+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);
+
+ if (favicon) {
+ /* The completion model might have changed its contents */
+ if (gtk_tree_row_reference_valid (data->row_reference)) {
+ path = gtk_tree_row_reference_get_path (data->row_reference);
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (data->model), &iter, path);
+ gtk_tree_path_free (path);
+ gtk_list_store_set (data->model, &iter,
+ EPHY_HOSTS_STORE_COLUMN_FAVICON, favicon, -1);
+ }
+ g_object_unref (favicon);
+ }
+
+ g_object_unref (data->model);
+ gtk_tree_row_reference_free (data->row_reference);
+ g_slice_free (IconLoadData, data);
+}
+
void
ephy_hosts_store_add_hosts (EphyHostsStore *store,
GList *hosts)
{
EphyHistoryHost *host;
+ GtkTreeIter treeiter;
+ GtkTreePath *path;
GList *iter;
+ GdkPixbuf *favicon;
+ IconLoadData *data;
+ WebKitFaviconDatabase *database = webkit_get_favicon_database ();
for (iter = hosts; iter != NULL; iter = iter->next) {
host = (EphyHistoryHost *)iter->data;
+ favicon = webkit_favicon_database_try_get_favicon_pixbuf (database, host->url,
+ FAVICON_SIZE, FAVICON_SIZE);
gtk_list_store_insert_with_values (GTK_LIST_STORE (store),
- NULL, -1,
+ &treeiter, -1,
EPHY_HOSTS_STORE_COLUMN_ID, host->id,
EPHY_HOSTS_STORE_COLUMN_TITLE, host->title,
EPHY_HOSTS_STORE_COLUMN_ADDRESS, host->url,
EPHY_HOSTS_STORE_COLUMN_VISIT_COUNT, host->visit_count,
+ EPHY_HOSTS_STORE_COLUMN_FAVICON, favicon,
-1);
+ if (favicon)
+ g_object_unref (favicon);
+ else {
+ data = g_slice_new (IconLoadData);
+ data->model = GTK_LIST_STORE (g_object_ref (store));
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &treeiter);
+ data->row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (store), path);
+ gtk_tree_path_free (path);
+
+ webkit_favicon_database_get_favicon_pixbuf (database, host->url,
+ FAVICON_SIZE, FAVICON_SIZE, NULL,
+ icon_loaded_cb, data);
+ }
}
}
diff --git a/lib/widgets/ephy-hosts-store.h b/lib/widgets/ephy-hosts-store.h
index 40502e8a0..98886fec8 100644
--- a/lib/widgets/ephy-hosts-store.h
+++ b/lib/widgets/ephy-hosts-store.h
@@ -44,6 +44,7 @@ typedef enum {
EPHY_HOSTS_STORE_COLUMN_TITLE,
EPHY_HOSTS_STORE_COLUMN_ADDRESS,
EPHY_HOSTS_STORE_COLUMN_VISIT_COUNT,
+ EPHY_HOSTS_STORE_COLUMN_FAVICON,
EPHY_HOSTS_STORE_N_COLUMNS
} EphyHostsStoreColumn;
diff --git a/lib/widgets/ephy-hosts-view.c b/lib/widgets/ephy-hosts-view.c
index e59d89c60..a3595a20e 100644
--- a/lib/widgets/ephy-hosts-view.c
+++ b/lib/widgets/ephy-hosts-view.c
@@ -22,6 +22,7 @@
#include "config.h"
#include "ephy-hosts-view.h"
+#include "ephy-embed-prefs.h"
#include "ephy-gui.h"
#include "ephy-hosts-store.h"
@@ -38,12 +39,25 @@ ephy_hosts_view_class_init (EphyHostsViewClass *klass)
static void
ephy_hosts_view_init (EphyHostsView *self)
{
+ GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
- column = gtk_tree_view_column_new_with_attributes (_("Sites"),
- gtk_cell_renderer_text_new (),
- "text", EPHY_HOSTS_STORE_COLUMN_TITLE,
- NULL);
+ column = g_object_new (GTK_TYPE_TREE_VIEW_COLUMN,
+ "title", _("Sites"),
+ NULL);
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "pixbuf", EPHY_HOSTS_STORE_COLUMN_FAVICON,
+ NULL);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "text", EPHY_HOSTS_STORE_COLUMN_TITLE,
+ NULL);
+
gtk_tree_view_append_column (GTK_TREE_VIEW (self), column);
}