[gnome-software/1409-add-available-for-fedora-section-to-the-explore-page: 123/128] gs-plugin: Add gs_plugin_add_distro_featured() function
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1409-add-available-for-fedora-section-to-the-explore-page: 123/128] gs-plugin: Add gs_plugin_add_distro_featured() function
- Date: Thu, 23 Sep 2021 16:45:57 +0000 (UTC)
commit 70697adf3315f542f59c42540ac9833ec1ee7242
Author: Milan Crha <mcrha redhat com>
Date: Wed Sep 8 15:51:47 2021 +0200
gs-plugin: Add gs_plugin_add_distro_featured() function
It's similar to gs_plugin_add_featured(), but it expects applications
featured by the distribution itself. The list will be used to populated
distro-featured section of the overview page.
lib/gs-plugin-loader.c | 6 ++++++
lib/gs-plugin-types.h | 2 ++
lib/gs-plugin-vfuncs.h | 29 +++++++++++++++++++++++++++++
lib/gs-plugin.c | 6 ++++++
4 files changed, 43 insertions(+)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 4d5240c32..1e56d0328 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -702,6 +702,7 @@ gs_plugin_loader_call_vfunc (GsPluginLoaderHelper *helper,
case GS_PLUGIN_ACTION_GET_INSTALLED:
case GS_PLUGIN_ACTION_GET_POPULAR:
case GS_PLUGIN_ACTION_GET_FEATURED:
+ case GS_PLUGIN_ACTION_GET_DISTRO_FEATURED:
{
GsPluginResultsFunc plugin_func = func;
ret = plugin_func (plugin, list, cancellable, &error_local);
@@ -3552,6 +3553,10 @@ gs_plugin_loader_process_thread_cb (GTask *task,
gs_app_list_filter (list, gs_plugin_loader_get_app_is_compatible, plugin_loader);
}
break;
+ case GS_PLUGIN_ACTION_GET_DISTRO_FEATURED:
+ gs_app_list_filter (list, gs_plugin_loader_app_is_valid, helper);
+ gs_app_list_filter (list, gs_plugin_loader_get_app_is_compatible, plugin_loader);
+ break;
case GS_PLUGIN_ACTION_GET_UPDATES:
gs_app_list_filter (list, gs_plugin_loader_app_is_valid_updatable, helper);
break;
@@ -3904,6 +3909,7 @@ gs_plugin_loader_job_process_async (GsPluginLoader *plugin_loader,
case GS_PLUGIN_ACTION_GET_ALTERNATES:
case GS_PLUGIN_ACTION_GET_CATEGORY_APPS:
case GS_PLUGIN_ACTION_GET_FEATURED:
+ case GS_PLUGIN_ACTION_GET_DISTRO_FEATURED:
case GS_PLUGIN_ACTION_GET_INSTALLED:
case GS_PLUGIN_ACTION_GET_POPULAR:
case GS_PLUGIN_ACTION_GET_RECENT:
diff --git a/lib/gs-plugin-types.h b/lib/gs-plugin-types.h
index 4674ad228..bf661bfcc 100644
--- a/lib/gs-plugin-types.h
+++ b/lib/gs-plugin-types.h
@@ -225,6 +225,7 @@ typedef enum {
* @GS_PLUGIN_ACTION_REMOVE_REPO: Remove a repository (Since: 41)
* @GS_PLUGIN_ACTION_ENABLE_REPO: Enable a repository (Since: 41)
* @GS_PLUGIN_ACTION_DISABLE_REPO: Disable a repository (Since: 41)
+ * @GS_PLUGIN_ACTION_GET_DISTRO_FEATURED: Get the list of featured applications by the distribution
(Since:42)
*
* The plugin action.
**/
@@ -267,6 +268,7 @@ typedef enum {
GS_PLUGIN_ACTION_REMOVE_REPO,
GS_PLUGIN_ACTION_ENABLE_REPO,
GS_PLUGIN_ACTION_DISABLE_REPO,
+ GS_PLUGIN_ACTION_GET_DISTRO_FEATURED,
GS_PLUGIN_ACTION_LAST /*< skip >*/
} GsPluginAction;
diff --git a/lib/gs-plugin-vfuncs.h b/lib/gs-plugin-vfuncs.h
index 23b7829db..ad07e675d 100644
--- a/lib/gs-plugin-vfuncs.h
+++ b/lib/gs-plugin-vfuncs.h
@@ -381,6 +381,35 @@ gboolean gs_plugin_add_featured (GsPlugin *plugin,
GCancellable *cancellable,
GError **error);
+/**
+ * gs_plugin_add_distro_featured:
+ * @plugin: a #GsPlugin
+ * @list: a #GsAppList
+ * @cancellable: a #GCancellable, or %NULL
+ * @error: a #GError, or %NULL
+ *
+ * Get applications that should be featured in a distro-specific section on the
+ * overview page.
+ * This is expected to be a curated list of applications that are high quality
+ * and feature-complete.
+ *
+ * The returned list of popular applications are randomized in a way so that
+ * the same application is featured for the entire calendar day.
+ *
+ * NOTE: The UI code may expect that applications have additional metadata set on
+ * results, for instance <code>GnomeSoftware::DistroFeatured</code>.
+ *
+ * Plugins are expected to add new apps using gs_app_list_add().
+ *
+ * Returns: %TRUE for success or if not relevant
+ *
+ * Since: 42
+ **/
+gboolean gs_plugin_add_distro_featured (GsPlugin *plugin,
+ GsAppList *list,
+ GCancellable *cancellable,
+ GError **error);
+
/**
* gs_plugin_refine:
* @plugin: a #GsPlugin
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index 186bf3159..9f9ff19b8 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -1618,6 +1618,8 @@ gs_plugin_action_to_function_name (GsPluginAction action)
return "gs_plugin_add_installed";
if (action == GS_PLUGIN_ACTION_GET_FEATURED)
return "gs_plugin_add_featured";
+ if (action == GS_PLUGIN_ACTION_GET_DISTRO_FEATURED)
+ return "gs_plugin_add_distro_featured";
if (action == GS_PLUGIN_ACTION_GET_UPDATES_HISTORICAL)
return "gs_plugin_add_updates_historical";
if (action == GS_PLUGIN_ACTION_GET_UPDATES)
@@ -1706,6 +1708,8 @@ gs_plugin_action_to_string (GsPluginAction action)
return "get-popular";
if (action == GS_PLUGIN_ACTION_GET_FEATURED)
return "get-featured";
+ if (action == GS_PLUGIN_ACTION_GET_DISTRO_FEATURED)
+ return "get-distro-featured";
if (action == GS_PLUGIN_ACTION_SEARCH)
return "search";
if (action == GS_PLUGIN_ACTION_SEARCH_FILES)
@@ -1796,6 +1800,8 @@ gs_plugin_action_from_string (const gchar *action)
return GS_PLUGIN_ACTION_GET_POPULAR;
if (g_strcmp0 (action, "get-featured") == 0)
return GS_PLUGIN_ACTION_GET_FEATURED;
+ if (g_strcmp0 (action, "get-distro-featured") == 0)
+ return GS_PLUGIN_ACTION_GET_DISTRO_FEATURED;
if (g_strcmp0 (action, "search") == 0)
return GS_PLUGIN_ACTION_SEARCH;
if (g_strcmp0 (action, "search-files") == 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]