diff options
author | António Fernandes <antoniof@gnome.org> | 2023-04-08 11:50:29 +0100 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2023-04-08 11:50:29 +0100 |
commit | 032d7d001a6d26a91c5ef32894613522d153d112 (patch) | |
tree | 6fe9a6e1886078be66ccc7be5653fe698672c6cf | |
parent | f7ccb4e731a337a757d234e5a738a549282ac6b5 (diff) | |
download | nautilus-032d7d001a6d26a91c5ef32894613522d153d112.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
-rw-r--r-- | src/nautilus-grid-cell.c | 8 | ||||
-rw-r--r-- | 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", |