[gnome-software/1649-support-appstream-merging] gs-plugin-appstream: Use a GPtrArray for desktop files dirs



commit 2a07fbc869fe7f610253099db8a34caab1e435d8
Author: Milan Crha <mcrha redhat com>
Date:   Thu Mar 31 12:02:22 2022 +0200

    gs-plugin-appstream: Use a GPtrArray for desktop files dirs
    
    This will be used in a future commit. It also follows the pattern
    used by appdata and appstream data paths.

 plugins/core/gs-plugin-appstream.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index 62170ae0c..18583f108 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -561,6 +561,12 @@ gs_plugin_appstream_check_silo (GsPluginAppstream  *self,
                xb_builder_source_add_fixup (source, fixup2);
                xb_builder_import_source (builder, source);
        } else {
+               g_autoptr(GPtrArray) parent_desktop = g_ptr_array_new ();
+
+               g_ptr_array_add (parent_desktop, (gpointer) DATADIR "/applications");
+               if (g_strcmp0 (DATADIR, "/usr/share") != 0)
+                       g_ptr_array_add (parent_desktop, (gpointer) "/usr/share/applications");
+
                /* add search paths */
                parent_appstream = gs_appstream_get_appstream_data_dirs ();
                gs_add_appstream_metainfo_location (parent_appdata, DATADIR);
@@ -585,16 +591,10 @@ gs_plugin_appstream_check_silo (GsPluginAppstream  *self,
                                                               cancellable, error))
                                return FALSE;
                }
-               if (!gs_appstream_load_desktop_files (builder,
-                                                     DATADIR "/applications",
-                                                     cancellable, error)) {
-                       return FALSE;
-               }
-               if (g_strcmp0 (DATADIR, "/usr/share") != 0 &&
-                   !gs_appstream_load_desktop_files (builder,
-                                                     "/usr/share/applications",
-                                                     cancellable, error)) {
-                       return FALSE;
+               for (guint i = 0; i < parent_desktop->len; i++) {
+                       const gchar *dir = g_ptr_array_index (parent_desktop, i);
+                       if (!gs_appstream_load_desktop_files (builder, dir, cancellable, error))
+                               return FALSE;
                }
        }
 


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