From 032d7d001a6d26a91c5ef32894613522d153d112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Fernandes?= Date: Sat, 8 Apr 2023 11:50:29 +0100 Subject: grid-cell, name-cell: Allow displaying unthemed emblems nautilus-dropbox and probably other such extensions use emblems to indicate sync status. If these icons are installed as unthemed icons, then we don't display them at all. This is because the way we are checking that an icon exists ignores the unthemed icons completely, which is arguably a GTK bug (https://gitlab.gnome.org/GNOME/gtk/-/issues/5709) While the GTK inconsistency is not addressed, let's use a workaround to check more effectively whether an icon exits. Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2789 --- src/nautilus-grid-cell.c | 8 +++++++- src/nautilus-name-cell.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/nautilus-grid-cell.c b/src/nautilus-grid-cell.c index 59b5a33c1..c95f0e5a4 100644 --- a/src/nautilus-grid-cell.c +++ b/src/nautilus-grid-cell.c @@ -116,7 +116,13 @@ update_emblems (NautilusGridCell *self) emblems = nautilus_file_get_emblem_icons (file); for (GList *l = emblems; l != NULL; l = l->next) { - if (!gtk_icon_theme_has_gicon (theme, l->data)) + g_autoptr (GtkIconPaintable) icon_paintable = NULL; + + /* Workaround for gtk_icon_theme_has_gicon() ignoring unthemed icons. + * See: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2789 and + * https://gitlab.gnome.org/GNOME/gtk/-/issues/5709 */ + icon_paintable = gtk_icon_theme_lookup_by_gicon (theme, l->data, 16, 1, 0, 0); + if (g_strcmp0 (gtk_icon_paintable_get_icon_name (icon_paintable), "image-missing") == 0) { g_autofree gchar *icon_string = g_icon_to_string (l->data); g_warning ("Failed to add emblem. ā€œ%sā€ not found in the icon theme", diff --git a/src/nautilus-name-cell.c b/src/nautilus-name-cell.c index bdcfcc2c7..b4ad20e52 100644 --- a/src/nautilus-name-cell.c +++ b/src/nautilus-name-cell.c @@ -201,7 +201,13 @@ update_emblems (NautilusNameCell *self) emblems = nautilus_file_get_emblem_icons (file); for (GList *l = emblems; l != NULL; l = l->next) { - if (!gtk_icon_theme_has_gicon (theme, l->data)) + g_autoptr (GtkIconPaintable) icon_paintable = NULL; + + /* Workaround for gtk_icon_theme_has_gicon() ignoring unthemed icons. + * See: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2789 and + * https://gitlab.gnome.org/GNOME/gtk/-/issues/5709 */ + icon_paintable = gtk_icon_theme_lookup_by_gicon (theme, l->data, 16, 1, 0, 0); + if (g_strcmp0 (gtk_icon_paintable_get_icon_name (icon_paintable), "image-missing") == 0) { g_autofree gchar *icon_string = g_icon_to_string (l->data); g_warning ("Failed to add emblem. ā€œ%sā€ not found in the icon theme", -- cgit v1.2.1