[gnome-software: 9/20] gs-cmd: Port ACTION_SEARCH to use GsPluginJobListApps
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 9/20] gs-cmd: Port ACTION_SEARCH to use GsPluginJobListApps
- Date: Mon, 11 Jul 2022 08:41:48 +0000 (UTC)
commit 45de85f191e8f9d83b8eed52d83103fb69cc06b8
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri Jul 1 18:06:19 2022 +0100
gs-cmd: Port ACTION_SEARCH to use GsPluginJobListApps
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
lib/gs-cmd.c | 42 ++++++++++++++++++++++++++++++------------
1 file changed, 30 insertions(+), 12 deletions(-)
---
diff --git a/lib/gs-cmd.c b/lib/gs-cmd.c
index 793bda209..f0e8c580d 100644
--- a/lib/gs-cmd.c
+++ b/lib/gs-cmd.c
@@ -202,21 +202,29 @@ gs_cmd_action_exec (GsCmdSelf *self, GsPluginAction action, const gchar *name, G
g_autoptr(GsApp) app = NULL;
g_autoptr(GsAppList) list = NULL;
g_autoptr(GsAppList) list_filtered = NULL;
+ g_autoptr(GsAppQuery) query = NULL;
g_autoptr(GsPluginJob) plugin_job2 = NULL;
g_autoptr(GsPluginJob) plugin_job = NULL;
gboolean show_installed = TRUE;
+ const gchar * const keywords[] = { name, NULL };
+ GsPluginListAppsFlags flags = GS_PLUGIN_LIST_APPS_FLAGS_NONE;
/* ensure set */
self->refine_flags |= GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON;
self->refine_flags |= GS_PLUGIN_REFINE_FLAGS_REQUIRE_SETUP_ACTION;
/* do search */
- plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_SEARCH,
- "search", name,
- "refine-flags", self->refine_flags,
- "max-results", self->max_results,
- "interactive", self->interactive,
- NULL);
+ query = gs_app_query_new ("keywords", keywords,
+ "refine-flags", self->refine_flags,
+ "max-results", self->max_results,
+ "dedupe-flags", GS_PLUGIN_JOB_DEDUPE_FLAGS_DEFAULT,
+ "sort-func", gs_utils_app_sort_match_value,
+ NULL);
+
+ if (self->interactive)
+ flags |= GS_PLUGIN_LIST_APPS_FLAGS_INTERACTIVE;
+
+ plugin_job = gs_plugin_job_list_apps_new (query, flags);
list = gs_plugin_loader_job_process (self->plugin_loader, plugin_job, NULL, error);
if (list == NULL)
return FALSE;
@@ -437,15 +445,25 @@ main (int argc, char **argv)
}
} else if (argc == 3 && g_strcmp0 (argv[1], "search") == 0) {
for (i = 0; i < repeat; i++) {
+ g_autoptr(GsAppQuery) query = NULL;
g_autoptr(GsPluginJob) plugin_job = NULL;
+ GsPluginListAppsFlags flags = GS_PLUGIN_LIST_APPS_FLAGS_NONE;
+ const gchar *keywords[2] = { argv[2], NULL };
+
if (list != NULL)
g_object_unref (list);
- plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_SEARCH,
- "search", argv[2],
- "refine-flags", self->refine_flags,
- "max-results", self->max_results,
- "interactive", self->interactive,
- NULL);
+
+ query = gs_app_query_new ("keywords", keywords,
+ "refine-flags", self->refine_flags,
+ "max-results", self->max_results,
+ "dedupe-flags", GS_PLUGIN_JOB_DEDUPE_FLAGS_DEFAULT,
+ "sort-func", gs_utils_app_sort_match_value,
+ NULL);
+
+ if (self->interactive)
+ flags |= GS_PLUGIN_LIST_APPS_FLAGS_INTERACTIVE;
+
+ plugin_job = gs_plugin_job_list_apps_new (query, flags);
list = gs_plugin_loader_job_process (self->plugin_loader, plugin_job, NULL, &error);
if (list == NULL) {
ret = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]