[gnome-software: 7/15] dummy: Make listing popular/curated apps asynchronous
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 7/15] dummy: Make listing popular/curated apps asynchronous
- Date: Mon, 9 May 2022 13:09:05 +0000 (UTC)
commit 8b663fba239d68fbaff33f1ba21d1048bcb27824
Author: Philip Withnall <pwithnall endlessos org>
Date: Wed May 4 11:49:30 2022 +0100
dummy: Make listing popular/curated apps asynchronous
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
plugins/dummy/gs-plugin-dummy.c | 85 ++++++++++++++++++++---------------------
1 file changed, 41 insertions(+), 44 deletions(-)
---
diff --git a/plugins/dummy/gs-plugin-dummy.c b/plugins/dummy/gs-plugin-dummy.c
index 0fb31ab4b..792ae5e2f 100644
--- a/plugins/dummy/gs-plugin-dummy.c
+++ b/plugins/dummy/gs-plugin-dummy.c
@@ -588,47 +588,6 @@ gs_plugin_dummy_list_installed_apps_finish (GsPlugin *plugin,
return g_task_propagate_pointer (G_TASK (result), error);
}
-gboolean
-gs_plugin_add_popular (GsPlugin *plugin,
- GsAppList *list,
- GCancellable *cancellable,
- GError **error)
-{
- g_autoptr(GsApp) app1 = NULL;
- g_autoptr(GsApp) app2 = NULL;
- g_auto(GStrv) apps = NULL;
-
- if (g_getenv ("GNOME_SOFTWARE_POPULAR") != NULL) {
- apps = g_strsplit (g_getenv ("GNOME_SOFTWARE_POPULAR"), ",", 0);
- }
-
- if (apps != NULL && g_strv_length (apps) > 0) {
- for (gsize i = 0; apps[i] != NULL; i++) {
- g_autoptr(GsApp) app = gs_app_new (apps[i]);
- gs_app_add_quirk (app, GS_APP_QUIRK_IS_WILDCARD);
- gs_app_list_add (list, app);
- }
-
- return TRUE;
- }
-
- /* add wildcard */
- app1 = gs_app_new ("zeus.desktop");
- gs_app_add_quirk (app1, GS_APP_QUIRK_IS_WILDCARD);
- gs_app_set_metadata (app1, "GnomeSoftware::Creator",
- gs_plugin_get_name (plugin));
- gs_app_list_add (list, app1);
-
- /* add again, this time with a prefix so it gets deduplicated */
- app2 = gs_app_new ("zeus.desktop");
- gs_app_set_scope (app2, AS_COMPONENT_SCOPE_USER);
- gs_app_set_bundle_kind (app2, AS_BUNDLE_KIND_SNAP);
- gs_app_set_metadata (app2, "GnomeSoftware::Creator",
- gs_plugin_get_name (plugin));
- gs_app_list_add (list, app2);
- return TRUE;
-}
-
gboolean
gs_plugin_app_remove (GsPlugin *plugin,
GsApp *app,
@@ -909,15 +868,20 @@ gs_plugin_dummy_list_apps_async (GsPlugin *plugin,
g_autoptr(GTask) task = NULL;
g_autoptr(GsAppList) list = gs_app_list_new ();
GDateTime *released_since = NULL;
+ GsAppQueryTristate is_curated = GS_APP_QUERY_TRISTATE_UNSET;
task = g_task_new (plugin, cancellable, callback, user_data);
g_task_set_source_tag (task, gs_plugin_dummy_list_apps_async);
- if (query != NULL)
+ if (query != NULL) {
released_since = gs_app_query_get_released_since (query);
+ is_curated = gs_app_query_get_is_curated (query);
+ }
- /* Currently only support released-since queries. */
- if (released_since == NULL) {
+ /* Currently only support released-since or is-curated queries (but not both).
+ * Also don’t currently support is-curated==GS_APP_QUERY_TRISTATE_FALSE. */
+ if ((released_since == NULL) == (is_curated == GS_APP_QUERY_TRISTATE_UNSET) ||
+ is_curated == GS_APP_QUERY_TRISTATE_FALSE) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"Unsupported query");
return;
@@ -938,6 +902,39 @@ gs_plugin_dummy_list_apps_async (GsPlugin *plugin,
gs_app_list_add (list, app);
}
+ if (is_curated != GS_APP_QUERY_TRISTATE_UNSET) {
+ g_autoptr(GsApp) app1 = NULL;
+ g_autoptr(GsApp) app2 = NULL;
+ g_auto(GStrv) apps = NULL;
+
+ if (g_getenv ("GNOME_SOFTWARE_POPULAR") != NULL) {
+ apps = g_strsplit (g_getenv ("GNOME_SOFTWARE_POPULAR"), ",", 0);
+ }
+
+ if (apps != NULL && g_strv_length (apps) > 0) {
+ for (gsize i = 0; apps[i] != NULL; i++) {
+ g_autoptr(GsApp) app = gs_app_new (apps[i]);
+ gs_app_add_quirk (app, GS_APP_QUIRK_IS_WILDCARD);
+ gs_app_list_add (list, app);
+ }
+ } else {
+ /* add wildcard */
+ app1 = gs_app_new ("zeus.desktop");
+ gs_app_add_quirk (app1, GS_APP_QUIRK_IS_WILDCARD);
+ gs_app_set_metadata (app1, "GnomeSoftware::Creator",
+ gs_plugin_get_name (plugin));
+ gs_app_list_add (list, app1);
+
+ /* add again, this time with a prefix so it gets deduplicated */
+ app2 = gs_app_new ("zeus.desktop");
+ gs_app_set_scope (app2, AS_COMPONENT_SCOPE_USER);
+ gs_app_set_bundle_kind (app2, AS_BUNDLE_KIND_SNAP);
+ gs_app_set_metadata (app2, "GnomeSoftware::Creator",
+ gs_plugin_get_name (plugin));
+ gs_app_list_add (list, app2);
+ }
+ }
+
g_task_return_pointer (task, g_steal_pointer (&list), (GDestroyNotify) g_object_unref);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]