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




commit 9fef1bcac7d4fcb40631f14382b8ebb38caee93c
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 32a4de6d5..176d52b84 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -564,6 +564,12 @@ gs_plugin_appstream_check_silo (GsPluginAppstream  *self,
                /* Nothing to watch in the tests */
                parent_appstream = g_ptr_array_new_with_free_func (g_free);
        } 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);
@@ -588,16 +594,10 @@ gs_plugin_appstream_check_silo (GsPluginAppstream  *self,
                                                               cancellable, error))
                                return FALSE;
                }
-               if (!gs_appstream_load_desktop_files (builder,
-                                                     DATADIR "/applications",
-                                                     NULL, cancellable, error)) {
-                       return FALSE;
-               }
-               if (g_strcmp0 (DATADIR, "/usr/share") != 0 &&
-                   !gs_appstream_load_desktop_files (builder,
-                                                     "/usr/share/applications",
-                                                     NULL, 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, NULL, cancellable, error))
+                               return FALSE;
                }
        }
 


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