[gnome-software: 17/24] gs-plugin-loader: Remove default sort function for ACTION_GET_RECENT




commit 8aa3bfeec7a1d4dc3ec883e2586a6ae48a63fee7
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Apr 13 23:37:34 2022 +0100

    gs-plugin-loader: Remove default sort function for ACTION_GET_RECENT
    
    Move it to the individual call sites for this job; sorting is something
    quite specific to each call site, so a single default sorting function
    is not going to be widely useful.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #1472

 lib/gs-cmd.c           | 11 +++++++++++
 lib/gs-plugin-loader.c | 16 ----------------
 2 files changed, 11 insertions(+), 16 deletions(-)
---
diff --git a/lib/gs-cmd.c b/lib/gs-cmd.c
index dc4b7e640..2068414ab 100644
--- a/lib/gs-cmd.c
+++ b/lib/gs-cmd.c
@@ -285,6 +285,16 @@ gs_cmd_self_free (GsCmdSelf *self)
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GsCmdSelf, gs_cmd_self_free)
 
+static gint
+app_sort_kind_cb (GsApp *app1, GsApp *app2, gpointer user_data)
+{
+       if (gs_app_get_kind (app1) == AS_COMPONENT_KIND_DESKTOP_APP)
+               return -1;
+       if (gs_app_get_kind (app2) == AS_COMPONENT_KIND_DESKTOP_APP)
+               return 1;
+       return 0;
+}
+
 int
 main (int argc, char **argv)
 {
@@ -630,6 +640,7 @@ main (int argc, char **argv)
                                                         "max-results", self->max_results,
                                                         "interactive", self->interactive,
                                                         NULL);
+                       gs_plugin_job_set_sort_func (plugin_job, app_sort_kind_cb, NULL);
                        list = gs_plugin_loader_job_process (self->plugin_loader, plugin_job,
                                                             NULL, &error);
                        if (list == NULL) {
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 6afd57fca..b9db3d3b4 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -1133,16 +1133,6 @@ gs_plugin_loader_featured_debug (GsApp *app, gpointer user_data)
        return FALSE;
 }
 
-static gint
-gs_plugin_loader_app_sort_kind_cb (GsApp *app1, GsApp *app2, gpointer user_data)
-{
-       if (gs_app_get_kind (app1) == AS_COMPONENT_KIND_DESKTOP_APP)
-               return -1;
-       if (gs_app_get_kind (app2) == AS_COMPONENT_KIND_DESKTOP_APP)
-               return 1;
-       return 0;
-}
-
 static gint
 gs_plugin_loader_app_sort_match_value_cb (GsApp *app1, GsApp *app2, gpointer user_data)
 {
@@ -4148,12 +4138,6 @@ job_process_cb (GTask *task)
                                                     gs_plugin_loader_app_sort_match_value_cb, NULL);
                }
                break;
-       case GS_PLUGIN_ACTION_GET_RECENT:
-               if (gs_plugin_job_get_sort_func (plugin_job, NULL) == NULL) {
-                       gs_plugin_job_set_sort_func (plugin_job,
-                                                    gs_plugin_loader_app_sort_kind_cb, NULL);
-               }
-               break;
        case GS_PLUGIN_ACTION_GET_CATEGORY_APPS:
                if (gs_plugin_job_get_sort_func (plugin_job, NULL) == NULL) {
                        gs_plugin_job_set_sort_func (plugin_job,


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