[epiphany] overview: add favicon to page thumbnails



commit 328b7139da58ec115e6ef3295fa417eded4e9dc0
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Thu Aug 22 11:45:19 2013 +0300

    overview: add favicon to page thumbnails

 embed/ephy-web-view.c             |    3 ++-
 lib/ephy-snapshot-service.c       |   21 +++++++++++++++++++--
 lib/ephy-snapshot-service.h       |    3 ++-
 lib/widgets/ephy-overview-store.c |    5 +++--
 lib/widgets/ephy-overview-store.h |    3 ++-
 5 files changed, 28 insertions(+), 7 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index a384a0d..f39546b 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 bc1bd2e..797665a 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 dacf21a..ec34c6b 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 074ec8b..b63a176 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 5732cab..49303bc 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
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]