[gnome-software: 8/20] doc: Port gs_plugin_add_search() vfunc to GsPluginJobListApps
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 8/20] doc: Port gs_plugin_add_search() vfunc to GsPluginJobListApps
- Date: Mon, 11 Jul 2022 08:41:48 +0000 (UTC)
commit e8f78a0378096ece369ad437a5fd6eff3aad2c88
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri Jul 1 16:38:17 2022 +0100
doc: Port gs_plugin_add_search() vfunc to GsPluginJobListApps
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
doc/api/gnome-software-docs.xml | 51 +++++++++++++++++++++++++++++++++--------
1 file changed, 42 insertions(+), 9 deletions(-)
---
diff --git a/doc/api/gnome-software-docs.xml b/doc/api/gnome-software-docs.xml
index d324d08a5..1d2d3eff7 100644
--- a/doc/api/gnome-software-docs.xml
+++ b/doc/api/gnome-software-docs.xml
@@ -98,26 +98,59 @@ gs_plugin_sample_init (GsPluginSample *self)
gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_BEFORE, "appstream");
}
-gboolean
-gs_plugin_add_search (GsPlugin *plugin,
- gchar **values,
- GsAppList *list,
- GCancellable *cancellable,
- GError **error)
+static void
+gs_plugin_sample_list_apps_async (GsPlugin *plugin,
+ GsAppQuery *query,
+ GsPluginListAppsFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
- for (gsize i = 0; values[i] != NULL; i++) {
- if (g_strcmp0 (values[i], "fotoshop") == 0) {
+ GsPluginSample *self = GS_PLUGIN_SAMPLE (plugin);
+ g_autoptr(GTask) task = NULL;
+ const gchar * const *keywords;
+ g_autoptr(GsAppList) list = gs_app_list_new ();
+
+ task = gs_plugin_list_apps_data_new_task (plugin, query, flags,
+ cancellable, callback, user_data);
+ g_task_set_source_tag (task, gs_plugin_sample_list_apps_async);
+
+ if (query == NULL ||
+ gs_app_query_get_keywords (query) == NULL ||
+ gs_app_query_get_n_properties_set (query) != 1) {
+ g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ "Unsupported query");
+ return;
+ }
+
+ keywords = gs_app_query_get_keywords (query);
+
+ for (gsize i = 0; keywords[i] != NULL; i++) {
+ if (g_str_equal (keywords[i], "fotoshop")) {
g_autoptr(GsApp) app = gs_app_new ("gimp.desktop");
gs_app_add_quirk (app, GS_APP_QUIRK_IS_WILDCARD);
gs_app_list_add (list, app);
}
}
- return TRUE;
+
+ g_task_return_pointer (task, g_steal_pointer (&list), g_object_unref);
+}
+
+static GsAppList *
+gs_plugin_sample_list_apps_finish (GsPlugin *plugin,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_task_propagate_pointer (G_TASK (result), error);
}
static void
gs_plugin_sample_class_init (GsPluginSampleClass *klass)
{
+ GsPluginClass *plugin_class = GS_PLUGIN_CLASS (klass);
+
+ plugin_class->list_apps_async = gs_plugin_sample_list_apps_async;
+ plugin_class->list_apps_finish = gs_plugin_sample_list_apps_finish;
}
GType
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]