summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2023-04-08 11:50:29 +0100
committerCorey Berla <corey@berla.me>2023-04-08 09:57:49 -0400
commitb643a00b23f70b5c619c554dae1242bc26cdef75 (patch)
treed26e3127b141fd7efc3d1d37bd774d08efbc129a
parent4c2f31515f74b2140cadbbab429227546d7b392e (diff)
downloadnautilus-b643a00b23f70b5c619c554dae1242bc26cdef75.tar.gz
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 (cherry picked from commit 032d7d001a6d26a91c5ef32894613522d153d112)
-rw-r--r--src/nautilus-grid-cell.c8
-rw-r--r--src/nautilus-name-cell.c8
2 files changed, 14 insertions, 2 deletions
diff --git a/src/nautilus-grid-cell.c b/src/nautilus-grid-cell.c
index 7d31c4db2..a24da0dd9 100644
--- a/src/nautilus-grid-cell.c
+++ b/src/nautilus-grid-cell.c
@@ -118,7 +118,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 f7e0a27de..69b4cce21 100644
--- a/src/nautilus-name-cell.c
+++ b/src/nautilus-name-cell.c
@@ -197,7 +197,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",