[gnome-software/1483-input-sources-use-symbolic-icons] gs-appstream: Skip default icons added by appstream-glib



commit f433b14c009fc3abd7e8e4c552d83e62b937ae86
Author: Milan Crha <mcrha redhat com>
Date:   Tue Sep 27 18:29:57 2022 +0200

    gs-appstream: Skip default icons added by appstream-glib
    
    The firmware, input methods and codecs can have preselected icons
    chosen by appstream-glib, which do not match those builtin in
    the gnome-software, thus ignore them and prefer the internal icons.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1483

 lib/gs-appstream.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index 193a3dbfb..8bb8e05f6 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -264,9 +264,18 @@ traverse_component_icons (GsApp *app,
                          XbNode *component,
                          GPtrArray *icons)
 {
+       const gchar *skip_icon = NULL;
+
        if (!icons)
                return;
 
+       if (gs_app_get_kind (app) == AS_COMPONENT_KIND_FIRMWARE)
+               skip_icon = "application-x-executable";
+       else if (gs_app_get_kind (app) == AS_COMPONENT_KIND_INPUT_METHOD)
+               skip_icon = "system-run-symbolic";
+       else if (gs_app_get_kind (app) == AS_COMPONENT_KIND_CODEC)
+               skip_icon = "application-x-addon";
+
        /* This code deliberately does *not* check that the icon files or theme
         * icons exist, as that would mean doing disk I/O for all the apps in
         * the appstream file, regardless of whether the calling code is
@@ -283,6 +292,12 @@ traverse_component_icons (GsApp *app,
                        continue;
                }
 
+               if (icon_kind == AS_ICON_KIND_STOCK && skip_icon != NULL &&
+                   g_strcmp0 (skip_icon, xb_node_get_text (icon_node)) == 0) {
+                       g_debug ("skipping icon ā€˜%sā€™ for app '%s'", skip_icon, gs_app_get_unique_id (app));
+                       continue;
+               }
+
                icon = gs_appstream_new_icon (component, icon_node, icon_kind, 0);
                app_add_icon (app, icon);
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]