[gnome-software: 1/11] lib: Add new GsPluginJobListCategories job
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 1/11] lib: Add new GsPluginJobListCategories job
- Date: Mon, 18 Jul 2022 09:57:06 +0000 (UTC)
commit 3c57490427a470c656fecd9cbaeb35318473ded4
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu Jul 14 14:49:35 2022 +0100
lib: Add new GsPluginJobListCategories job
This will eventually replace the `gs_plugin_add_categories()` vfunc and
the `gs_plugin_loader_get_categories_async()` method. It combines
listing categories with refining them.
Refining a category is a generalisation of the existing
`gs_plugin_add_categories()` vfunc. Despite its name, the existing vfunc
only calculates how many apps there are in each category and calls
`gs_category_increment_size()` accordingly. The new
`refine_categories_async()` vfunc will do the same, but should be more
easily expandable to refine other properties of a category in future, if
needed. It also reuses existing terminology so the API is more
consistent and thus a bit easier to learn.
The new job is not used yet, but following commits will add
implementations of its vfunc and port call sites to use it.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
doc/api/gnome-software-docs.xml | 1 +
lib/gnome-software.h | 1 +
lib/gs-plugin-helpers.c | 68 +++++++
lib/gs-plugin-helpers.h | 16 ++
lib/gs-plugin-job-list-categories.c | 347 ++++++++++++++++++++++++++++++++++++
lib/gs-plugin-job-list-categories.h | 29 +++
lib/gs-plugin-loader.c | 3 +-
lib/gs-plugin-types.h | 14 ++
lib/gs-plugin.h | 19 ++
lib/meson.build | 2 +
10 files changed, 499 insertions(+), 1 deletion(-)
---
diff --git a/doc/api/gnome-software-docs.xml b/doc/api/gnome-software-docs.xml
index 1d2d3eff7..aa1627952 100644
--- a/doc/api/gnome-software-docs.xml
+++ b/doc/api/gnome-software-docs.xml
@@ -760,6 +760,7 @@ gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
<xi:include href="xml/gs-plugin-event.xml"/>
<xi:include href="xml/gs-plugin-helpers.xml"/>
<xi:include href="xml/gs-plugin-job-list-apps.xml"/>
+ <xi:include href="xml/gs-plugin-job-list-categories.xml"/>
<xi:include href="xml/gs-plugin-job-list-distro-upgrades.xml"/>
<xi:include href="xml/gs-plugin-job-refine.xml"/>
<xi:include href="xml/gs-plugin-job-refresh-metadata.xml"/>
diff --git a/lib/gnome-software.h b/lib/gnome-software.h
index 12d8af5de..b57e2572e 100644
--- a/lib/gnome-software.h
+++ b/lib/gnome-software.h
@@ -30,6 +30,7 @@
#include <gs-plugin-helpers.h>
#include <gs-plugin-job.h>
#include <gs-plugin-job-list-apps.h>
+#include <gs-plugin-job-list-categories.h>
#include <gs-plugin-job-list-distro-upgrades.h>
#include <gs-plugin-job-manage-repository.h>
#include <gs-plugin-job-refine.h>
diff --git a/lib/gs-plugin-helpers.c b/lib/gs-plugin-helpers.c
index 5711cf985..40c8a614b 100644
--- a/lib/gs-plugin-helpers.c
+++ b/lib/gs-plugin-helpers.c
@@ -268,3 +268,71 @@ gs_plugin_manage_repository_data_free (GsPluginManageRepositoryData *data)
g_clear_object (&data->repository);
g_free (data);
}
+
+/**
+ * gs_plugin_refine_categories_data_new:
+ * @list: (element-type GsCategory): list of #GsCategory objects to refine
+ * @flags: refine flags
+ *
+ * Context data for a call to #GsPluginClass.refine_categories_async.
+ *
+ * Returns: (transfer full): context data structure
+ * Since: 43
+ */
+GsPluginRefineCategoriesData *
+gs_plugin_refine_categories_data_new (GPtrArray *list,
+ GsPluginRefineCategoriesFlags flags)
+{
+ g_autoptr(GsPluginRefineCategoriesData) data = g_new0 (GsPluginRefineCategoriesData, 1);
+ data->list = g_ptr_array_ref (list);
+ data->flags = flags;
+
+ return g_steal_pointer (&data);
+}
+
+/**
+ * gs_plugin_refine_categories_data_new_task:
+ * @source_object: task source object
+ * @list: (element-type GsCategory): list of #GsCategory objects to refine
+ * @flags: refine flags
+ * @cancellable: (nullable): a #GCancellable, or %NULL
+ * @callback: function to call once asynchronous operation is finished
+ * @user_data: data to pass to @callback
+ *
+ * Create a #GTask for a refine categories operation with the given arguments.
+ * The task data will be set to a #GsPluginRefineCategoriesData containing the
+ * given context.
+ *
+ * This is essentially a combination of gs_plugin_refine_categories_data_new(),
+ * g_task_new() and g_task_set_task_data().
+ *
+ * Returns: (transfer full): new #GTask with the given context data
+ * Since: 43
+ */
+GTask *
+gs_plugin_refine_categories_data_new_task (gpointer source_object,
+ GPtrArray *list,
+ GsPluginRefineCategoriesFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_autoptr(GTask) task = g_task_new (source_object, cancellable, callback, user_data);
+ g_task_set_task_data (task, gs_plugin_refine_categories_data_new (list, flags), (GDestroyNotify)
gs_plugin_refine_categories_data_free);
+ return g_steal_pointer (&task);
+}
+
+/**
+ * gs_plugin_refine_categories_data_free:
+ * @data: (transfer full): a #GsPluginRefineCategoriesData
+ *
+ * Free the given @data.
+ *
+ * Since: 43
+ */
+void
+gs_plugin_refine_categories_data_free (GsPluginRefineCategoriesData *data)
+{
+ g_clear_pointer (&data->list, g_ptr_array_unref);
+ g_free (data);
+}
diff --git a/lib/gs-plugin-helpers.h b/lib/gs-plugin-helpers.h
index 78c0697ca..b4a19f3b4 100644
--- a/lib/gs-plugin-helpers.h
+++ b/lib/gs-plugin-helpers.h
@@ -77,4 +77,20 @@ GTask * gs_plugin_manage_repository_data_new_task (gpointer
source_object,
void gs_plugin_manage_repository_data_free (GsPluginManageRepositoryData *data);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GsPluginManageRepositoryData, gs_plugin_manage_repository_data_free)
+typedef struct {
+ GPtrArray *list; /* (element-type GsCategory) (owned) (not nullable) */
+ GsPluginRefineCategoriesFlags flags;
+} GsPluginRefineCategoriesData;
+
+GsPluginRefineCategoriesData *gs_plugin_refine_categories_data_new (GPtrArray *list,
+ GsPluginRefineCategoriesFlags flags);
+GTask *gs_plugin_refine_categories_data_new_task (gpointer source_object,
+ GPtrArray *list,
+ GsPluginRefineCategoriesFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+void gs_plugin_refine_categories_data_free (GsPluginRefineCategoriesData *data);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (GsPluginRefineCategoriesData, gs_plugin_refine_categories_data_free)
+
G_END_DECLS
diff --git a/lib/gs-plugin-job-list-categories.c b/lib/gs-plugin-job-list-categories.c
new file mode 100644
index 000000000..f2d164433
--- /dev/null
+++ b/lib/gs-plugin-job-list-categories.c
@@ -0,0 +1,347 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ * vi:set noexpandtab tabstop=8 shiftwidth=8:
+ *
+ * Copyright (C) 2022 Endless OS Foundation LLC
+ *
+ * Author: Philip Withnall <pwithnall endlessos org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+/**
+ * SECTION:gs-plugin-job-list-categories
+ * @short_description: A plugin job to list categories
+ *
+ * #GsPluginJobListCategories is a #GsPluginJob representing an operation to
+ * list categories.
+ *
+ * All results will be refined using the given set of refine flags, similarly to
+ * how #GsPluginJobRefine refines apps.
+ *
+ * This class is a wrapper around #GsPluginClass.refine_categories_async,
+ * calling it for all loaded plugins on the list of categories exposed by a
+ * #GsCategoryManager.
+ *
+ * Retrieve the resulting #GPtrArray of #GsCategory objects using
+ * gs_plugin_job_list_categories_get_result_list().
+ *
+ * See also: #GsPluginClass.refine_categories_async
+ * Since: 43
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "gs-category.h"
+#include "gs-category-private.h"
+#include "gs-enums.h"
+#include "gs-plugin-job.h"
+#include "gs-plugin-job-list-categories.h"
+#include "gs-plugin-job-private.h"
+#include "gs-plugin-private.h"
+#include "gs-plugin-types.h"
+#include "gs-utils.h"
+
+struct _GsPluginJobListCategories
+{
+ GsPluginJob parent;
+
+ /* Input arguments. */
+ GsPluginRefineCategoriesFlags flags;
+
+ /* In-progress data. */
+ GPtrArray *category_list; /* (element-type GsCategory) (owned) (nullable) */
+ GError *saved_error; /* (owned) (nullable) */
+ guint n_pending_ops;
+
+ /* Results. */
+ GPtrArray *result_list; /* (element-type GsCategory) (owned) (nullable) */
+};
+
+G_DEFINE_TYPE (GsPluginJobListCategories, gs_plugin_job_list_categories, GS_TYPE_PLUGIN_JOB)
+
+typedef enum {
+ PROP_FLAGS = 1,
+} GsPluginJobListCategoriesProperty;
+
+static GParamSpec *props[PROP_FLAGS + 1] = { NULL, };
+
+static void
+gs_plugin_job_list_categories_dispose (GObject *object)
+{
+ GsPluginJobListCategories *self = GS_PLUGIN_JOB_LIST_CATEGORIES (object);
+
+ g_assert (self->category_list == NULL);
+ g_assert (self->saved_error == NULL);
+ g_assert (self->n_pending_ops == 0);
+
+ g_clear_pointer (&self->result_list, g_ptr_array_unref);
+
+ G_OBJECT_CLASS (gs_plugin_job_list_categories_parent_class)->dispose (object);
+}
+
+static void
+gs_plugin_job_list_categories_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GsPluginJobListCategories *self = GS_PLUGIN_JOB_LIST_CATEGORIES (object);
+
+ switch ((GsPluginJobListCategoriesProperty) prop_id) {
+ case PROP_FLAGS:
+ g_value_set_flags (value, self->flags);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gs_plugin_job_list_categories_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GsPluginJobListCategories *self = GS_PLUGIN_JOB_LIST_CATEGORIES (object);
+
+ switch ((GsPluginJobListCategoriesProperty) prop_id) {
+ case PROP_FLAGS:
+ /* Construct only. */
+ g_assert (self->flags == 0);
+ self->flags = g_value_get_flags (value);
+ g_object_notify_by_pspec (object, props[prop_id]);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void plugin_refine_categories_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data);
+static void finish_op (GTask *task,
+ GError *error);
+
+static void
+gs_plugin_job_list_categories_run_async (GsPluginJob *job,
+ GsPluginLoader *plugin_loader,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GsPluginJobListCategories *self = GS_PLUGIN_JOB_LIST_CATEGORIES (job);
+ g_autoptr(GTask) task = NULL;
+ GPtrArray *plugins; /* (element-type GsPlugin) */
+ gboolean anything_ran = FALSE;
+ GsCategory * const *categories = NULL;
+ gsize n_categories;
+
+ task = g_task_new (job, cancellable, callback, user_data);
+ g_task_set_source_tag (task, gs_plugin_job_list_categories_run_async);
+ g_task_set_task_data (task, g_object_ref (plugin_loader), (GDestroyNotify) g_object_unref);
+
+ /* get the categories */
+ categories = gs_category_manager_get_categories (gs_plugin_loader_get_category_manager
(plugin_loader), &n_categories);
+ self->category_list = g_ptr_array_new_full (n_categories, (GDestroyNotify) g_object_unref);
+
+ for (gsize i = 0; i < n_categories; i++)
+ g_ptr_array_add (self->category_list, g_object_ref (categories[i]));
+
+ /* run each plugin, keeping a counter of pending operations which is
+ * initialised to 1 until all the operations are started */
+ self->n_pending_ops = 1;
+ plugins = gs_plugin_loader_get_plugins (plugin_loader);
+
+ for (guint i = 0; i < plugins->len; i++) {
+ GsPlugin *plugin = g_ptr_array_index (plugins, i);
+ GsPluginClass *plugin_class = GS_PLUGIN_GET_CLASS (plugin);
+
+ if (!gs_plugin_get_enabled (plugin))
+ continue;
+ if (plugin_class->refine_categories_async == NULL)
+ continue;
+
+ /* at least one plugin supports this vfunc */
+ anything_ran = TRUE;
+
+ /* run the plugin */
+ self->n_pending_ops++;
+ plugin_class->refine_categories_async (plugin, self->category_list, self->flags, cancellable,
plugin_refine_categories_cb, g_object_ref (task));
+ }
+
+ if (!anything_ran)
+ g_debug ("no plugin could handle listing categories");
+
+ finish_op (task, NULL);
+}
+
+static void
+plugin_refine_categories_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GsPlugin *plugin = GS_PLUGIN (source_object);
+ GsPluginClass *plugin_class = GS_PLUGIN_GET_CLASS (plugin);
+ g_autoptr(GTask) task = G_TASK (user_data);
+ g_autoptr(GError) local_error = NULL;
+
+ if (!plugin_class->refine_categories_finish (plugin, result, &local_error)) {
+ finish_op (task, g_steal_pointer (&local_error));
+ return;
+ }
+
+ gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
+
+ finish_op (task, g_steal_pointer (&local_error));
+}
+
+static gint
+category_sort_cb (gconstpointer a,
+ gconstpointer b)
+{
+ GsCategory *category_a = GS_CATEGORY (*(GsCategory **) a);
+ GsCategory *category_b = GS_CATEGORY (*(GsCategory **) b);
+ gint score_a = gs_category_get_score (category_a);
+ gint score_b = gs_category_get_score (category_b);
+
+ if (score_a != score_b)
+ return score_b - score_a;
+ return gs_utils_sort_strcmp (gs_category_get_name (category_a),
+ gs_category_get_name (category_b));
+}
+
+/* @error is (transfer full) if non-%NULL */
+static void
+finish_op (GTask *task,
+ GError *error)
+{
+ GsPluginJobListCategories *self = g_task_get_source_object (task);
+ g_autoptr(GPtrArray) category_list = NULL;
+ g_autoptr(GError) error_owned = g_steal_pointer (&error);
+ g_autofree gchar *job_debug = NULL;
+
+ if (error_owned != NULL && self->saved_error == NULL)
+ self->saved_error = g_steal_pointer (&error_owned);
+ else if (error_owned != NULL)
+ g_debug ("Additional error while listing categories: %s", error_owned->message);
+
+ g_assert (self->n_pending_ops > 0);
+ self->n_pending_ops--;
+
+ if (self->n_pending_ops > 0)
+ return;
+
+ /* Get the results of the parallel ops. */
+ category_list = g_steal_pointer (&self->category_list);
+
+ if (self->saved_error != NULL) {
+ g_task_return_error (task, g_steal_pointer (&self->saved_error));
+ return;
+ }
+
+ /* sort by name */
+ g_ptr_array_sort (category_list, category_sort_cb);
+ for (guint i = 0; i < category_list->len; i++) {
+ GsCategory *category = GS_CATEGORY (g_ptr_array_index (category_list, i));
+ gs_category_sort_children (category);
+ }
+
+ /* show elapsed time */
+ job_debug = gs_plugin_job_to_string (GS_PLUGIN_JOB (self));
+ g_debug ("%s", job_debug);
+
+ /* Check the intermediate working values are all cleared. */
+ g_assert (self->category_list == NULL);
+ g_assert (self->saved_error == NULL);
+ g_assert (self->n_pending_ops == 0);
+
+ /* success */
+ self->result_list = g_ptr_array_ref (category_list);
+ g_task_return_boolean (task, TRUE);
+}
+
+static gboolean
+gs_plugin_job_list_categories_run_finish (GsPluginJob *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_task_propagate_boolean (G_TASK (result), error);
+}
+
+static void
+gs_plugin_job_list_categories_class_init (GsPluginJobListCategoriesClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GsPluginJobClass *job_class = GS_PLUGIN_JOB_CLASS (klass);
+
+ object_class->dispose = gs_plugin_job_list_categories_dispose;
+ object_class->get_property = gs_plugin_job_list_categories_get_property;
+ object_class->set_property = gs_plugin_job_list_categories_set_property;
+
+ job_class->run_async = gs_plugin_job_list_categories_run_async;
+ job_class->run_finish = gs_plugin_job_list_categories_run_finish;
+
+ /**
+ * GsPluginJobListCategories:flags:
+ *
+ * Flags to specify how the operation should run.
+ *
+ * Since: 43
+ */
+ props[PROP_FLAGS] =
+ g_param_spec_flags ("flags", "Flags",
+ "Flags to specify how the operation should run.",
+ GS_TYPE_PLUGIN_REFINE_CATEGORIES_FLAGS,
+ GS_PLUGIN_REFINE_CATEGORIES_FLAGS_NONE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+
+ g_object_class_install_properties (object_class, G_N_ELEMENTS (props), props);
+}
+
+static void
+gs_plugin_job_list_categories_init (GsPluginJobListCategories *self)
+{
+}
+
+/**
+ * gs_plugin_job_list_categories_new:
+ * @flags: flags affecting how the operation runs
+ *
+ * Create a new #GsPluginJobListCategories for listing categories.
+ *
+ * Returns: (transfer full): a new #GsPluginJobListCategories
+ * Since: 43
+ */
+GsPluginJob *
+gs_plugin_job_list_categories_new (GsPluginRefineCategoriesFlags flags)
+{
+ return g_object_new (GS_TYPE_PLUGIN_JOB_LIST_CATEGORIES,
+ "flags", flags,
+ NULL);
+}
+
+/**
+ * gs_plugin_job_list_categories_get_result_list:
+ * @self: a #GsPluginJobListCategories
+ *
+ * Get the full list of categories.
+ *
+ * If this is called before the job is complete, %NULL will be returned.
+ *
+ * Returns: (transfer none) (nullable) (element-type GsCategory): the job
+ * results, or %NULL on error or if called before the job has completed
+ * Since: 43
+ */
+GPtrArray *
+gs_plugin_job_list_categories_get_result_list (GsPluginJobListCategories *self)
+{
+ g_return_val_if_fail (GS_IS_PLUGIN_JOB_LIST_CATEGORIES (self), NULL);
+
+ return self->result_list;
+}
diff --git a/lib/gs-plugin-job-list-categories.h b/lib/gs-plugin-job-list-categories.h
new file mode 100644
index 000000000..49857f3bd
--- /dev/null
+++ b/lib/gs-plugin-job-list-categories.h
@@ -0,0 +1,29 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ * vi:set noexpandtab tabstop=8 shiftwidth=8:
+ *
+ * Copyright (C) 2022 Endless OS Foundation LLC
+ *
+ * Author: Philip Withnall <pwithnall endlessos org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#pragma once
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gio/gio.h>
+
+#include "gs-plugin-job.h"
+
+G_BEGIN_DECLS
+
+#define GS_TYPE_PLUGIN_JOB_LIST_CATEGORIES (gs_plugin_job_list_categories_get_type ())
+
+G_DECLARE_FINAL_TYPE (GsPluginJobListCategories, gs_plugin_job_list_categories, GS,
PLUGIN_JOB_LIST_CATEGORIES, GsPluginJob)
+
+GsPluginJob *gs_plugin_job_list_categories_new (GsPluginRefineCategoriesFlags flags);
+
+GPtrArray *gs_plugin_job_list_categories_get_result_list (GsPluginJobListCategories *self);
+
+G_END_DECLS
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 47a6d7336..8cbe7a885 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -3709,7 +3709,8 @@ run_job_cb (GObject *source_object,
* job_process_async() does. */
g_task_return_pointer (task, gs_app_list_new (), g_object_unref);
return;
- } else if (GS_IS_PLUGIN_JOB_MANAGE_REPOSITORY (plugin_job)) {
+ } else if (GS_IS_PLUGIN_JOB_MANAGE_REPOSITORY (plugin_job) ||
+ GS_IS_PLUGIN_JOB_LIST_CATEGORIES (plugin_job)) {
/* FIXME: The gs_plugin_loader_job_action_finish() expects a #GsAppList
* pointer on success, thus return it. */
g_task_return_pointer (task, gs_app_list_new (), g_object_unref);
diff --git a/lib/gs-plugin-types.h b/lib/gs-plugin-types.h
index dde60d098..5198733c9 100644
--- a/lib/gs-plugin-types.h
+++ b/lib/gs-plugin-types.h
@@ -184,6 +184,20 @@ typedef enum {
GS_PLUGIN_LIST_APPS_FLAGS_INTERACTIVE = 1 << 0,
} GsPluginListAppsFlags;
+/**
+ * GsPluginRefineCategoriesFlags:
+ * @GS_PLUGIN_REFINE_CATEGORIES_FLAGS_NONE: No flags set.
+ * @GS_PLUGIN_REFINE_CATEGORIES_FLAGS_INTERACTIVE: User initiated the job.
+ *
+ * Flags for an operation to refine categories.
+ *
+ * Since: 43
+ */
+typedef enum {
+ GS_PLUGIN_REFINE_CATEGORIES_FLAGS_NONE = 0,
+ GS_PLUGIN_REFINE_CATEGORIES_FLAGS_INTERACTIVE = 1 << 0,
+} GsPluginRefineCategoriesFlags;
+
/**
* GsPluginRefreshMetadataFlags:
* @GS_PLUGIN_REFRESH_METADATA_FLAGS_NONE: No flags set.
diff --git a/lib/gs-plugin.h b/lib/gs-plugin.h
index df36fc25c..6bfc286c3 100644
--- a/lib/gs-plugin.h
+++ b/lib/gs-plugin.h
@@ -79,6 +79,15 @@ G_DECLARE_DERIVABLE_TYPE (GsPlugin, gs_plugin, GS, PLUGIN, GObject)
* @disable_repository_finish: (nullable): Finish method for
* @disable_repository_async. Must be implemented if
* @disable_repository_async is implemented.
+ * @refine_categories_async: (nullable): Refining looks up and adds data to
+ * #GsCategorys. The categories to refine are provided in a list, and the
+ * flags specify what data to look up and add. Refining certain kinds of data
+ * can be very expensive (for example, requiring network requests), which is
+ * why it’s not all loaded by default. By refining multiple categories at
+ * once, data requests can be batched by the plugin where possible. (Since: 43)
+ * @refine_categories_finish: (nullable): Finish method for
+ * @refine_categories_async. Must be implemented if @refine_categories_async
+ * is implemented. (Since: 43)
*
* The class structure for a #GsPlugin. Virtual methods here should be
* implemented by plugin implementations derived from #GsPlugin to provide their
@@ -201,6 +210,16 @@ struct _GsPluginClass
GAsyncResult *result,
GError **error);
+ void (*refine_categories_async) (GsPlugin *plugin,
+ GPtrArray *list,
+ GsPluginRefineCategoriesFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ gboolean (*refine_categories_finish) (GsPlugin *plugin,
+ GAsyncResult *result,
+ GError **error);
+
gpointer padding[23];
};
diff --git a/lib/meson.build b/lib/meson.build
index 779c09a1d..d591bca3d 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -25,6 +25,7 @@ libgnomesoftware_public_headers = [
'gs-plugin-helpers.h',
'gs-plugin-job.h',
'gs-plugin-job-list-apps.h',
+ 'gs-plugin-job-list-categories.h',
'gs-plugin-job-list-distro-upgrades.h',
'gs-plugin-job-manage-repository.h',
'gs-plugin-job-refine.h',
@@ -107,6 +108,7 @@ libgnomesoftware = library(
'gs-plugin-helpers.c',
'gs-plugin-job.c',
'gs-plugin-job-list-apps.c',
+ 'gs-plugin-job-list-categories.c',
'gs-plugin-job-list-distro-upgrades.c',
'gs-plugin-job-manage-repository.c',
'gs-plugin-job-refine.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]