summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan-Michael Brummer <jan.brummer@tabos.org>2022-03-20 22:32:36 +0100
committerMarge Bot <marge-bot@gnome.org>2022-03-23 15:32:34 +0000
commit89a0ffa71afed31a82310d25b66ec6f722825ffe (patch)
treeca94f44e9feb64f2ae9a01913673fb19bd94cc0c /src
parent3f5d2bebd20f776bcbcf45d2cb33d2b3357a91b4 (diff)
downloadepiphany-89a0ffa71afed31a82310d25b66ec6f722825ffe.tar.gz
Add favicons to history dialog
Fixes: https://gitlab.gnome.org/GNOME/epiphany/-/issues/1682 Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1093>
Diffstat (limited to 'src')
-rw-r--r--src/ephy-history-dialog.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/ephy-history-dialog.c b/src/ephy-history-dialog.c
index 64bf10e76..bbcf34af7 100644
--- a/src/ephy-history-dialog.c
+++ b/src/ephy-history-dialog.c
@@ -3,7 +3,7 @@
* Copyright © 2003, 2004 Marco Pesenti Gritti <mpeseng@tin.it>
* Copyright © 2003, 2004 Christian Persch
* Copyright © 2012 Igalia S.L
- * Copyright © 2018 Jan-Michael Brummer
+ * Copyright © 2018-2022 Jan-Michael Brummer
* Copyright © 2019 Purism SPC
*
* This file is part of Epiphany.
@@ -26,6 +26,8 @@
#include "ephy-history-dialog.h"
#include "ephy-debug.h"
+#include "ephy-embed-prefs.h"
+#include "ephy-favicon-helpers.h"
#include "ephy-gui.h"
#include "ephy-prefs.h"
#include "ephy-settings.h"
@@ -417,11 +419,37 @@ row_check_button_toggled (GtkCheckButton *check_button,
set_is_selection_empty (self, n_rows == 0);
}
+static void
+ephy_history_dialog_row_favicon_loaded_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ g_autoptr (GtkWidget) icon = user_data;
+ WebKitFaviconDatabase *database = WEBKIT_FAVICON_DATABASE (source);
+ cairo_surface_t *icon_surface;
+ g_autoptr (GdkPixbuf) favicon = NULL;
+ g_autoptr (GError) error = NULL;
+
+ icon_surface = webkit_favicon_database_get_favicon_finish (database, result, &error);
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ return;
+
+ if (icon_surface) {
+ favicon = ephy_pixbuf_get_from_surface_scaled (icon_surface, FAVICON_SIZE, FAVICON_SIZE);
+ cairo_surface_destroy (icon_surface);
+ }
+
+ if (favicon && icon)
+ gtk_image_set_from_pixbuf (GTK_IMAGE (icon), favicon);
+}
+
static GtkWidget *
create_row (EphyHistoryDialog *self,
EphyHistoryURL *url)
{
EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+ WebKitFaviconDatabase *database;
+ GtkWidget *icon;
GtkWidget *date;
GtkWidget *row;
GtkWidget *separator;
@@ -435,6 +463,17 @@ create_row (EphyHistoryDialog *self,
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), TRUE);
gtk_widget_set_tooltip_text (row, url->url);
+ /* Fav Icon */
+ icon = gtk_image_new ();
+ hdy_action_row_add_prefix (HDY_ACTION_ROW (row), icon);
+
+ database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
+ webkit_favicon_database_get_favicon (database,
+ url->url,
+ self->cancellable,
+ (GAsyncReadyCallback)ephy_history_dialog_row_favicon_loaded_cb,
+ g_object_ref (icon));
+
/* Date */
date = gtk_label_new (ephy_time_helpers_utf_friendly_time (url->last_visit_time / 1000000));
gtk_label_set_ellipsize (GTK_LABEL (date), PANGO_ELLIPSIZE_END);