[gnome-software] Specify the max number of results when getting search results
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Specify the max number of results when getting search results
- Date: Wed, 19 Apr 2017 21:22:21 +0000 (UTC)
commit a591934c59c0e8329c8de01356ace8112dc69f28
Author: Richard Hughes <richard hughsie com>
Date: Wed Apr 19 19:56:46 2017 +0100
Specify the max number of results when getting search results
lib/gs-cmd.c | 2 +-
lib/gs-plugin-loader-sync.c | 2 ++
lib/gs-plugin-loader-sync.h | 1 +
lib/gs-plugin-loader.c | 3 +++
lib/gs-plugin-loader.h | 1 +
plugins/core/gs-self-test.c | 2 +-
plugins/dummy/gs-self-test.c | 2 +-
plugins/flatpak/gs-self-test.c | 12 ++++++------
plugins/modalias/gs-self-test.c | 2 +-
src/gs-search-page.c | 3 +++
src/gs-shell-search-provider.c | 3 +++
11 files changed, 23 insertions(+), 10 deletions(-)
---
diff --git a/lib/gs-cmd.c b/lib/gs-cmd.c
index 225422c..8e8e19f 100644
--- a/lib/gs-cmd.c
+++ b/lib/gs-cmd.c
@@ -307,7 +307,7 @@ main (int argc, char **argv)
if (list != NULL)
g_object_unref (list);
list = gs_plugin_loader_search (plugin_loader,
- argv[2],
+ argv[2], 0,
refine_flags,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
diff --git a/lib/gs-plugin-loader-sync.c b/lib/gs-plugin-loader-sync.c
index 0951c63..cabc784 100644
--- a/lib/gs-plugin-loader-sync.c
+++ b/lib/gs-plugin-loader-sync.c
@@ -111,6 +111,7 @@ gs_plugin_loader_search_finish_sync (GsPluginLoader *plugin_loader,
GsAppList *
gs_plugin_loader_search (GsPluginLoader *plugin_loader,
const gchar *value,
+ guint max_results,
GsPluginRefineFlags refine_flags,
GsPluginFailureFlags failure_flags,
GCancellable *cancellable,
@@ -128,6 +129,7 @@ gs_plugin_loader_search (GsPluginLoader *plugin_loader,
/* run async method */
gs_plugin_loader_search_async (plugin_loader,
value,
+ max_results,
refine_flags,
failure_flags,
cancellable,
diff --git a/lib/gs-plugin-loader-sync.h b/lib/gs-plugin-loader-sync.h
index 687a406..a97e8eb 100644
--- a/lib/gs-plugin-loader-sync.h
+++ b/lib/gs-plugin-loader-sync.h
@@ -35,6 +35,7 @@ GsAppList *gs_plugin_loader_get_installed (GsPluginLoader *plugin_loader,
GError **error);
GsAppList *gs_plugin_loader_search (GsPluginLoader *plugin_loader,
const gchar *value,
+ guint max_results,
GsPluginRefineFlags refine_flags,
GsPluginFailureFlags failure_flags,
GCancellable *cancellable,
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 9a04970..1ad4263 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -192,6 +192,7 @@ typedef struct {
GsAuth *auth;
GsPluginAction action;
gboolean anything_ran;
+ guint max_results;
} GsPluginLoaderJob;
static GsPluginLoaderJob *
@@ -2129,6 +2130,7 @@ gs_plugin_loader_search_thread_cb (GTask *task,
void
gs_plugin_loader_search_async (GsPluginLoader *plugin_loader,
const gchar *value,
+ guint max_results,
GsPluginRefineFlags refine_flags,
GsPluginFailureFlags failure_flags,
GCancellable *cancellable,
@@ -2146,6 +2148,7 @@ gs_plugin_loader_search_async (GsPluginLoader *plugin_loader,
job->refine_flags = refine_flags;
job->failure_flags = failure_flags;
job->list = gs_app_list_new ();
+ job->max_results = max_results;
job->value = g_strdup (value);
job->values = as_utils_search_tokenize (job->value);
job->action = GS_PLUGIN_ACTION_SEARCH;
diff --git a/lib/gs-plugin-loader.h b/lib/gs-plugin-loader.h
index db8b95c..5db5db1 100644
--- a/lib/gs-plugin-loader.h
+++ b/lib/gs-plugin-loader.h
@@ -136,6 +136,7 @@ GsAppList *gs_plugin_loader_get_category_apps_finish (GsPluginLoader *plugin_loa
GError **error);
void gs_plugin_loader_search_async (GsPluginLoader *plugin_loader,
const gchar *value,
+ guint max_results,
GsPluginRefineFlags refine_flags,
GsPluginFailureFlags failure_flags,
GCancellable *cancellable,
diff --git a/plugins/core/gs-self-test.c b/plugins/core/gs-self-test.c
index 2a37afa..8d7d2e5 100644
--- a/plugins/core/gs-self-test.c
+++ b/plugins/core/gs-self-test.c
@@ -104,7 +104,7 @@ gs_plugins_core_search_repo_name_func (GsPluginLoader *plugin_loader)
/* get search result based on addon keyword */
list = gs_plugin_loader_search (plugin_loader,
- "yellow",
+ "yellow", 0,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
diff --git a/plugins/dummy/gs-self-test.c b/plugins/dummy/gs-self-test.c
index c0a56ba..a26fe12 100644
--- a/plugins/dummy/gs-self-test.c
+++ b/plugins/dummy/gs-self-test.c
@@ -355,7 +355,7 @@ gs_plugins_dummy_search_func (GsPluginLoader *plugin_loader)
/* get search result based on addon keyword */
list = gs_plugin_loader_search (plugin_loader,
- "spell",
+ "spell", 0,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
diff --git a/plugins/flatpak/gs-self-test.c b/plugins/flatpak/gs-self-test.c
index 1bb9ba1..b1b8804 100644
--- a/plugins/flatpak/gs-self-test.c
+++ b/plugins/flatpak/gs-self-test.c
@@ -251,7 +251,7 @@ gs_plugins_flatpak_app_with_runtime_func (GsPluginLoader *plugin_loader)
/* find available application */
list = gs_plugin_loader_search (plugin_loader,
- "Bingo",
+ "Bingo", 0,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_HOSTNAME |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_PERMISSIONS |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION |
@@ -468,7 +468,7 @@ gs_plugins_flatpak_app_missing_runtime_func (GsPluginLoader *plugin_loader)
/* find available application */
list = gs_plugin_loader_search (plugin_loader,
- "Bingo",
+ "Bingo", 0,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
@@ -763,7 +763,7 @@ gs_plugins_flatpak_ref_func (GsPluginLoader *plugin_loader)
/* find available application */
list = gs_plugin_loader_search (plugin_loader,
- "runtime",
+ "runtime", 0,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
@@ -852,7 +852,7 @@ gs_plugins_flatpak_ref_func (GsPluginLoader *plugin_loader)
/* search for the application */
search1 = gs_plugin_loader_search (plugin_loader,
- "chiron",
+ "chiron", 0,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
@@ -903,7 +903,7 @@ gs_plugins_flatpak_ref_func (GsPluginLoader *plugin_loader)
/* there should be no matches now */
search2 = gs_plugin_loader_search (plugin_loader,
- "chiron",
+ "chiron", 0,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
@@ -997,7 +997,7 @@ gs_plugins_flatpak_app_update_func (GsPluginLoader *plugin_loader)
/* find available application */
list = gs_plugin_loader_search (plugin_loader,
- "Bingo",
+ "Bingo", 0,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
diff --git a/plugins/modalias/gs-self-test.c b/plugins/modalias/gs-self-test.c
index 3c9adb9..9304931 100644
--- a/plugins/modalias/gs-self-test.c
+++ b/plugins/modalias/gs-self-test.c
@@ -35,7 +35,7 @@ gs_plugins_modalias_func (GsPluginLoader *plugin_loader)
/* get search result based on addon keyword */
list = gs_plugin_loader_search (plugin_loader,
- "colorhug2",
+ "colorhug2", 0,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
diff --git a/src/gs-search-page.c b/src/gs-search-page.c
index b2dd5a7..241b82a 100644
--- a/src/gs-search-page.c
+++ b/src/gs-search-page.c
@@ -28,6 +28,8 @@
#include "gs-common.h"
#include "gs-app-row.h"
+#define GS_SEARCH_PAGE_MAX_RESULTS 50
+
struct _GsSearchPage
{
GsPage parent_instance;
@@ -189,6 +191,7 @@ gs_search_page_load (GsSearchPage *self)
gs_plugin_loader_search_async (self->plugin_loader,
self->value,
+ GS_SEARCH_PAGE_MAX_RESULTS,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE |
diff --git a/src/gs-shell-search-provider.c b/src/gs-shell-search-provider.c
index 46e1c8f..6a31a12 100644
--- a/src/gs-shell-search-provider.c
+++ b/src/gs-shell-search-provider.c
@@ -29,6 +29,8 @@
#include "gs-shell-search-provider-generated.h"
#include "gs-shell-search-provider.h"
+#define GS_SHELL_SEARCH_PROVIDER_MAX_RESULTS 20
+
typedef struct {
GsShellSearchProvider *provider;
GDBusMethodInvocation *invocation;
@@ -131,6 +133,7 @@ execute_search (GsShellSearchProvider *self,
self->cancellable = g_cancellable_new ();
gs_plugin_loader_search_async (self->plugin_loader,
string,
+ GS_SHELL_SEARCH_PROVIDER_MAX_RESULTS,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
GS_PLUGIN_FAILURE_FLAGS_NONE,
self->cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]