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




commit 3c4734a3233adf2532bf6dce20ad870b0c0d4137
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 0c49146cb..9d60bdf84 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -570,6 +570,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);
@@ -594,16 +600,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]