[gnome-software/1409-add-available-for-fedora-section-to-the-explore-page: 8/13] gs-app-query: Add 'deployment-featured' property




commit 7c86aacaf09613d0dc53f3c6bc0eb1b7c7d9ba4f
Author: Milan Crha <mcrha redhat com>
Date:   Fri May 6 11:38:33 2022 +0200

    gs-app-query: Add 'deployment-featured' property

 lib/gs-app-query.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/gs-app-query.h |  2 ++
 2 files changed, 66 insertions(+)
---
diff --git a/lib/gs-app-query.c b/lib/gs-app-query.c
index 21448b56d..01ce24394 100644
--- a/lib/gs-app-query.c
+++ b/lib/gs-app-query.c
@@ -77,6 +77,9 @@ struct _GsAppQuery
        GsAppQueryTristate is_featured;
        GsCategory *category;  /* (nullable) (owned) */
        GsAppQueryTristate is_installed;
+
+       /* This is guaranteed to either be %NULL, or a non-empty array */
+       gchar **deployment_featured;  /* (owned) (nullable) (array zero-terminated=1) */
 };
 
 G_DEFINE_TYPE (GsAppQuery, gs_app_query, G_TYPE_OBJECT)
@@ -91,6 +94,7 @@ typedef enum {
        PROP_FILTER_FUNC,
        PROP_FILTER_USER_DATA,
        PROP_FILTER_USER_DATA_NOTIFY,
+       PROP_DEPLOYMENT_FEATURED,
        PROP_PROVIDES_FILES,
        PROP_RELEASED_SINCE,
        PROP_IS_CURATED,
@@ -137,6 +141,9 @@ gs_app_query_get_property (GObject    *object,
        case PROP_FILTER_USER_DATA_NOTIFY:
                g_value_set_pointer (value, self->filter_user_data_notify);
                break;
+       case PROP_DEPLOYMENT_FEATURED:
+               g_value_set_boxed (value, self->deployment_featured);
+               break;
        case PROP_PROVIDES_FILES:
                g_value_set_boxed (value, self->provides_files);
                break;
@@ -214,6 +221,16 @@ gs_app_query_set_property (GObject      *object,
                /* Construct only. */
                g_assert (self->filter_user_data_notify == NULL);
                self->filter_user_data_notify = g_value_get_pointer (value);
+               break;
+       case PROP_DEPLOYMENT_FEATURED:
+               /* Construct only. */
+               g_assert (self->deployment_featured == NULL);
+               self->deployment_featured = g_value_dup_boxed (value);
+
+               /* Squash empty arrays to %NULL. */
+               if (self->deployment_featured != NULL && self->deployment_featured[0] == NULL)
+                       g_clear_pointer (&self->deployment_featured, g_strfreev);
+
                break;
        case PROP_PROVIDES_FILES:
                /* Construct only. */
@@ -281,6 +298,7 @@ gs_app_query_finalize (GObject *object)
 {
        GsAppQuery *self = GS_APP_QUERY (object);
 
+       g_clear_pointer (&self->deployment_featured, g_strfreev);
        g_clear_pointer (&self->provides_files, g_strfreev);
        g_clear_pointer (&self->released_since, g_date_time_unref);
 
@@ -433,6 +451,29 @@ gs_app_query_class_init (GsAppQueryClass *klass)
                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
                                      G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 
+       /**
+        * GsAppQuery:deployment-featured: (nullable)
+        *
+        * A list of `GnomeSoftware::DeploymentFeatured` app keys.
+        *
+        * Search for applications that should be featured in a deployment-specific
+        * section on the overview page.
+        * This is expected to be a curated list of applications that are high quality
+        * and feature-complete. Only apps matching at least one of the keys in this
+        * list are returned.
+        *
+        * This may be %NULL to not filter on it. An empty array is
+        * considered equivalent to %NULL.
+        *
+        * Since: 43
+        */
+       props[PROP_DEPLOYMENT_FEATURED] =
+               g_param_spec_boxed ("deployment-featured", "Deployment Featured",
+                                   "A list of `GnomeSoftware::DeploymentFeatured` app keys.",
+                                   G_TYPE_STRV,
+                                   G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+                                   G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+
        /**
         * GsAppQuery:provides-files: (nullable)
         *
@@ -719,6 +760,8 @@ gs_app_query_get_n_properties_set (GsAppQuery *self)
                n++;
        if (self->is_installed != GS_APP_QUERY_TRISTATE_UNSET)
                n++;
+       if (self->deployment_featured != NULL)
+               n++;
 
        return n;
 }
@@ -836,3 +879,24 @@ gs_app_query_get_is_installed (GsAppQuery *self)
 
        return self->is_installed;
 }
+
+/**
+ * gs_app_query_get_deployment_featured:
+ * @self: a #GsAppQuery
+ *
+ * Get the value of #GsAppQuery:deployment-featured.
+ *
+ * Returns: (nullable): a list of `GnomeSoftware::DeploymentFeatured` app keys,
+ *   which the apps have set in a custom key, or %NULL to not filter on this
+ * Since: 43
+ */
+const gchar * const *
+gs_app_query_get_deployment_featured (GsAppQuery *self)
+{
+       g_return_val_if_fail (GS_IS_APP_QUERY (self), NULL);
+
+       /* Always return %NULL or a non-empty array */
+       g_assert (self->deployment_featured == NULL || self->deployment_featured[0] != NULL);
+
+       return (const gchar * const *) self->deployment_featured;
+}
diff --git a/lib/gs-app-query.h b/lib/gs-app-query.h
index 02c138f8c..db135bd2d 100644
--- a/lib/gs-app-query.h
+++ b/lib/gs-app-query.h
@@ -64,5 +64,7 @@ GsAppQueryTristate     gs_app_query_get_is_curated     (GsAppQuery *self);
 GsAppQueryTristate      gs_app_query_get_is_featured    (GsAppQuery *self);
 GsCategory             *gs_app_query_get_category       (GsAppQuery *self);
 GsAppQueryTristate      gs_app_query_get_is_installed   (GsAppQuery *self);
+const gchar * const    *gs_app_query_get_deployment_featured
+                                                        (GsAppQuery *self);
 
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]