aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWilliam Jon McCann <william.jon.mccann@gmail.com>2013-02-26 05:03:08 +0800
committerWilliam Jon McCann <william.jon.mccann@gmail.com>2013-03-02 22:14:08 +0800
commit8a00f5c726c9b1fbe3dbe346957d0d2dbaee008b (patch)
treeceabf4ee5595cb34b3e1d5f292453692a263f9f2 /src
parent81cbba2fe0acce1de3d78749415fe6eb2374fd71 (diff)
downloadgsoc2013-epiphany-8a00f5c726c9b1fbe3dbe346957d0d2dbaee008b.tar.gz
gsoc2013-epiphany-8a00f5c726c9b1fbe3dbe346957d0d2dbaee008b.tar.zst
gsoc2013-epiphany-8a00f5c726c9b1fbe3dbe346957d0d2dbaee008b.zip
Fallback to favicon instead of page snapshot
https://bugzilla.gnome.org/show_bug.cgi?id=694703
Diffstat (limited to 'src')
-rw-r--r--src/window-commands.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/src/window-commands.c b/src/window-commands.c
index 8d774e3fb..c60f4df52 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -66,6 +66,7 @@
#endif
#define DEFAULT_ICON_SIZE 144
+#define FAVICON_SIZE 16
void
window_cmd_file_print (GtkAction *action,
@@ -508,20 +509,34 @@ frame_pixbuf (GdkPixbuf *pixbuf,
}
static void
-take_page_snapshot_and_set_image (EphyApplicationDialogData *data)
+set_image_from_favicon (EphyApplicationDialogData *data)
{
- GdkPixbuf *snapshot;
- GdkPixbuf *framed;
- int x, y, w, h;
+ GdkPixbuf *icon = NULL;
+
+#ifdef HAVE_WEBKIT2
+ {
+ cairo_surface_t *icon_surface = webkit_web_view_get_favicon (WEBKIT_WEB_VIEW (data->view));
+ if (icon_surface)
+ icon = ephy_pixbuf_get_from_surface_scaled (icon_surface, 0, 0);
+ }
+#else
+ {
+ const char *page_uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (data->view));
+ if (page_uri)
+ icon = webkit_favicon_database_try_get_favicon_pixbuf (webkit_get_favicon_database (),
+ page_uri,
+ FAVICON_SIZE, FAVICON_SIZE);
+ }
+#endif
- x = y = 0;
- w = h = DEFAULT_ICON_SIZE;
+ if (icon != NULL) {
+ GdkPixbuf *framed;
- snapshot = ephy_web_view_get_snapshot (data->view, x, y, w, h);
- framed = frame_pixbuf (snapshot, NULL, w, h);
- g_object_unref (snapshot);
- gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), framed);
- g_object_unref (framed);
+ framed = frame_pixbuf (icon, NULL, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
+ g_object_unref (icon);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), framed);
+ g_object_unref (framed);
+ }
}
static void
@@ -564,7 +579,7 @@ download_failed_cb (WebKitDownload *download,
g_signal_handlers_disconnect_by_func (download, download_finished_cb, data);
/* Something happened, default to a page snapshot. */
- take_page_snapshot_and_set_image (data);
+ set_image_from_favicon (data);
}
#else
static void
@@ -588,7 +603,7 @@ download_status_changed_cb (WebKitDownload *download,
case WEBKIT_DOWNLOAD_STATUS_ERROR:
case WEBKIT_DOWNLOAD_STATUS_CANCELLED:
/* Something happened, default to a page snapshot. */
- take_page_snapshot_and_set_image (data);
+ set_image_from_favicon (data);
break;
default:
break;
@@ -660,7 +675,7 @@ fill_default_application_image (EphyApplicationDialogData *data)
else
{
gtk_widget_show (data->image);
- take_page_snapshot_and_set_image (data);
+ set_image_from_favicon (data);
}
}