[gnome-software: 3/14] flatpak: Make listing category apps asynchronous




commit 831312c2a1ef2aa45a5278f7da277a48ac41aace
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed May 4 14:42:13 2022 +0100

    flatpak: Make listing category apps asynchronous
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #1472

 plugins/flatpak/gs-plugin-flatpak.c | 37 +++++++++++--------------------------
 1 file changed, 11 insertions(+), 26 deletions(-)
---
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index 90369d210..4062146f2 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -1837,30 +1837,6 @@ gs_plugin_add_categories (GsPlugin *plugin,
        return TRUE;
 }
 
-gboolean
-gs_plugin_add_category_apps (GsPlugin *plugin,
-                            GsCategory *category,
-                            GsAppList *list,
-                            GCancellable *cancellable,
-                            GError **error)
-{
-       GsPluginFlatpak *self = GS_PLUGIN_FLATPAK (plugin);
-       gboolean interactive = gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE);
-
-       for (guint i = 0; i < self->installations->len; i++) {
-               GsFlatpak *flatpak = g_ptr_array_index (self->installations, i);
-               if (!gs_flatpak_add_category_apps (flatpak,
-                                                  category,
-                                                  list,
-                                                  interactive,
-                                                  cancellable,
-                                                  error)) {
-                       return FALSE;
-               }
-       }
-       return TRUE;
-}
-
 gboolean
 gs_plugin_add_alternates (GsPlugin *plugin,
                          GsApp *app,
@@ -1936,6 +1912,7 @@ list_apps_thread_cb (GTask        *task,
        gboolean interactive = (data->flags & GS_PLUGIN_LIST_APPS_FLAGS_INTERACTIVE);
        GDateTime *released_since = NULL;
        GsAppQueryTristate is_curated = GS_APP_QUERY_TRISTATE_UNSET;
+       GsCategory *category = NULL;
        guint64 age_secs = 0;
        g_autoptr(GError) local_error = NULL;
 
@@ -1944,6 +1921,7 @@ list_apps_thread_cb (GTask        *task,
        if (data->query != NULL) {
                released_since = gs_app_query_get_released_since (data->query);
                is_curated = gs_app_query_get_is_curated (data->query);
+               category = gs_app_query_get_category (data->query);
        }
 
        if (released_since != NULL) {
@@ -1951,9 +1929,10 @@ list_apps_thread_cb (GTask        *task,
                age_secs = g_date_time_difference (now, released_since) / G_TIME_SPAN_SECOND;
        }
 
-       /* Currently only support released-since or is-curated queries (but not both).
+       /* Currently only support released-since, is-curated and category queries (but only one at once).
         * Also don’t currently support is-curated==GS_APP_QUERY_TRISTATE_FALSE. */
-       if ((released_since == NULL) == (is_curated == GS_APP_QUERY_TRISTATE_UNSET) ||
+       if ((released_since == NULL && is_curated == GS_APP_QUERY_TRISTATE_UNSET && category == NULL) ||
+           gs_app_query_get_n_properties_set (data->query) != 1 ||
            is_curated == GS_APP_QUERY_TRISTATE_FALSE) {
                g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
                                         "Unsupported query");
@@ -1974,6 +1953,12 @@ list_apps_thread_cb (GTask        *task,
                        g_task_return_error (task, g_steal_pointer (&local_error));
                        return;
                }
+
+               if (category != NULL &&
+                   !gs_flatpak_add_category_apps (flatpak, category, list, interactive, cancellable, 
&local_error)) {
+                       g_task_return_error (task, g_steal_pointer (&local_error));
+                       return;
+               }
        }
 
        g_task_return_pointer (task, g_steal_pointer (&list), g_object_unref);


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