aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2013-08-22 16:45:19 +0800
committerClaudio Saavedra <csaavedra@igalia.com>2013-08-22 18:23:29 +0800
commit328b7139da58ec115e6ef3295fa417eded4e9dc0 (patch)
tree07f378c10759f92455d61cf1f395757b7bae30b5
parente5d3e6bc678fdd588bafae9fa41bfb88e8e1d8d3 (diff)
downloadgsoc2013-epiphany-328b7139da58ec115e6ef3295fa417eded4e9dc0.tar
gsoc2013-epiphany-328b7139da58ec115e6ef3295fa417eded4e9dc0.tar.gz
gsoc2013-epiphany-328b7139da58ec115e6ef3295fa417eded4e9dc0.tar.bz2
gsoc2013-epiphany-328b7139da58ec115e6ef3295fa417eded4e9dc0.tar.lz
gsoc2013-epiphany-328b7139da58ec115e6ef3295fa417eded4e9dc0.tar.xz
gsoc2013-epiphany-328b7139da58ec115e6ef3295fa417eded4e9dc0.tar.zst
gsoc2013-epiphany-328b7139da58ec115e6ef3295fa417eded4e9dc0.zip
overview: add favicon to page thumbnails
-rw-r--r--embed/ephy-web-view.c3
-rw-r--r--lib/ephy-snapshot-service.c21
-rw-r--r--lib/ephy-snapshot-service.h3
-rw-r--r--lib/widgets/ephy-overview-store.c5
-rw-r--r--lib/widgets/ephy-overview-store.h3
5 files changed, 28 insertions, 7 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index a384a0d50..f39546b9d 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -1499,7 +1499,8 @@ on_snapshot_ready (WebKitWebView *webview,
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_path_free (path);
- ephy_overview_store_set_snapshot (EPHY_OVERVIEW_STORE (model), &iter, surface);
+ ephy_overview_store_set_snapshot (EPHY_OVERVIEW_STORE (model), &iter, surface,
+ webkit_web_view_get_favicon (webview));
cairo_surface_destroy (surface);
}
diff --git a/lib/ephy-snapshot-service.c b/lib/ephy-snapshot-service.c
index bc1bd2eb8..797665af6 100644
--- a/lib/ephy-snapshot-service.c
+++ b/lib/ephy-snapshot-service.c
@@ -21,6 +21,8 @@
#include "config.h"
#include "ephy-snapshot-service.h"
+#include "ephy-favicon-helpers.h"
+
#ifndef GNOME_DESKTOP_USE_UNSTABLE_API
#define GNOME_DESKTOP_USE_UNSTABLE_API
#endif
@@ -170,7 +172,8 @@ save_snapshot (cairo_surface_t *surface,
EphySnapshotService *service;
data = (SnapshotAsyncData *)g_simple_async_result_get_op_res_gpointer (result);
- data->snapshot = ephy_snapshot_service_crop_snapshot (surface);
+ data->snapshot = ephy_snapshot_service_prepare_snapshot (surface,
+ webkit_web_view_get_favicon (data->web_view));
service = (EphySnapshotService *)g_async_result_get_source_object (G_ASYNC_RESULT (result));
ephy_snapshot_service_save_snapshot_async (service, data->snapshot,
@@ -613,7 +616,8 @@ ephy_snapshot_service_save_snapshot_finish (EphySnapshotService *service,
}
GdkPixbuf *
-ephy_snapshot_service_crop_snapshot (cairo_surface_t *surface)
+ephy_snapshot_service_prepare_snapshot (cairo_surface_t *surface,
+ cairo_surface_t *favicon)
{
GdkPixbuf *snapshot, *scaled;
int orig_width, orig_height;
@@ -656,5 +660,18 @@ ephy_snapshot_service_crop_snapshot (cairo_surface_t *surface)
g_object_unref (snapshot);
+ if (favicon) {
+ GdkPixbuf* fav_pixbuf;
+ int favicon_size = 16;
+ int x_offset = 6;
+ int y_offset = gdk_pixbuf_get_height (scaled) - favicon_size - x_offset;
+ fav_pixbuf = ephy_pixbuf_get_from_surface_scaled (favicon, favicon_size, favicon_size);
+ gdk_pixbuf_composite (fav_pixbuf, scaled,
+ x_offset, y_offset, favicon_size, favicon_size,
+ x_offset, y_offset, 1, 1,
+ GDK_INTERP_NEAREST, 255);
+ g_object_unref (fav_pixbuf);
+ }
+
return scaled;
}
diff --git a/lib/ephy-snapshot-service.h b/lib/ephy-snapshot-service.h
index dacf21a63..ec34c6b31 100644
--- a/lib/ephy-snapshot-service.h
+++ b/lib/ephy-snapshot-service.h
@@ -107,7 +107,8 @@ gboolean ephy_snapshot_service_save_snapshot_finish (EphySnap
GAsyncResult *result,
GError **error);
-GdkPixbuf *ephy_snapshot_service_crop_snapshot (cairo_surface_t *surface);
+GdkPixbuf *ephy_snapshot_service_prepare_snapshot (cairo_surface_t *surface,
+ cairo_surface_t *favicon);
G_END_DECLS
diff --git a/lib/widgets/ephy-overview-store.c b/lib/widgets/ephy-overview-store.c
index 074ec8bf1..b63a17685 100644
--- a/lib/widgets/ephy-overview-store.c
+++ b/lib/widgets/ephy-overview-store.c
@@ -248,7 +248,8 @@ on_snapshot_saved_cb (EphySnapshotService *service,
void
ephy_overview_store_set_snapshot (EphyOverviewStore *store,
GtkTreeIter *iter,
- cairo_surface_t *snapshot)
+ cairo_surface_t *snapshot,
+ cairo_surface_t *favicon)
{
GdkPixbuf *pixbuf;
char *url;
@@ -257,7 +258,7 @@ ephy_overview_store_set_snapshot (EphyOverviewStore *store,
int mtime;
mtime = time (NULL);
- pixbuf = ephy_snapshot_service_crop_snapshot (snapshot);
+ pixbuf = ephy_snapshot_service_prepare_snapshot (snapshot, favicon);
ephy_overview_store_set_snapshot_internal (store, iter, pixbuf, mtime);
gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
EPHY_OVERVIEW_STORE_URI, &url,
diff --git a/lib/widgets/ephy-overview-store.h b/lib/widgets/ephy-overview-store.h
index 5732cabc1..49303bc68 100644
--- a/lib/widgets/ephy-overview-store.h
+++ b/lib/widgets/ephy-overview-store.h
@@ -104,7 +104,8 @@ gboolean ephy_overview_store_find_url (EphyOverviewStore *store,
void ephy_overview_store_set_snapshot (EphyOverviewStore *store,
GtkTreeIter *iter,
- cairo_surface_t *snapshot);
+ cairo_surface_t *snapshot,
+ cairo_surface_t *favicon);
G_END_DECLS