[gnome-software/1409-add-available-for-fedora-section-to-the-explore-page: 124/128] gs-appstream: Add gs_appstream_add_distro_featured()




commit 6b5530344c18ee8fcca218e78f752ba47f604a28
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 8 15:54:09 2021 +0200

    gs-appstream: Add gs_appstream_add_distro_featured()
    
    To be used by the implementations of the gs_plugin_add_distro_featured().

 lib/gs-appstream.c | 37 ++++++++++++++++++++++++++++---------
 lib/gs-appstream.h |  4 ++++
 2 files changed, 32 insertions(+), 9 deletions(-)
---
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index b049e7fb8..3cf841e90 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -1606,20 +1606,18 @@ gs_appstream_add_alternates (XbSilo *silo,
        return TRUE;
 }
 
-gboolean
-gs_appstream_add_featured (XbSilo *silo,
-                          GsAppList *list,
-                          GCancellable *cancellable,
-                          GError **error)
+static gboolean
+gs_appstream_add_featured_with_query (XbSilo *silo,
+                                     const gchar *query,
+                                     GsAppList *list,
+                                     GCancellable *cancellable,
+                                     GError **error)
 {
        g_autoptr(GError) error_local = NULL;
        g_autoptr(GPtrArray) array = NULL;
 
        /* find out how many packages are in each category */
-       array = xb_silo_query (silo,
-                              "components/component/custom/value[@key='GnomeSoftware::FeatureTile']/../..|"
-                              
"components/component/custom/value[@key='GnomeSoftware::FeatureTile-css']/../..",
-                              0, &error_local);
+       array = xb_silo_query (silo, query, 0, &error_local);
        if (array == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
                        return TRUE;
@@ -1643,6 +1641,27 @@ gs_appstream_add_featured (XbSilo *silo,
        return TRUE;
 }
 
+gboolean
+gs_appstream_add_featured (XbSilo *silo,
+                          GsAppList *list,
+                          GCancellable *cancellable,
+                          GError **error)
+{
+       const gchar *query = "components/component/custom/value[@key='GnomeSoftware::FeatureTile']/../..|"
+                            "components/component/custom/value[@key='GnomeSoftware::FeatureTile-css']/../..";
+       return gs_appstream_add_featured_with_query (silo, query, list, cancellable, error);
+}
+
+gboolean
+gs_appstream_add_distro_featured (XbSilo *silo,
+                                 GsAppList *list,
+                                 GCancellable *cancellable,
+                                 GError **error)
+{
+       const gchar *query = "components/component/custom/value[@key='GnomeSoftware::DistroFeatured']/../..";
+       return gs_appstream_add_featured_with_query (silo, query, list, cancellable, error);
+}
+
 gboolean
 gs_appstream_url_to_app (GsPlugin *plugin,
                         XbSilo *silo,
diff --git a/lib/gs-appstream.h b/lib/gs-appstream.h
index 5bddf9136..f7086627d 100644
--- a/lib/gs-appstream.h
+++ b/lib/gs-appstream.h
@@ -46,6 +46,10 @@ gboolean      gs_appstream_add_featured              (XbSilo         *silo,
                                                         GsAppList      *list,
                                                         GCancellable   *cancellable,
                                                         GError         **error);
+gboolean        gs_appstream_add_distro_featured       (XbSilo         *silo,
+                                                        GsAppList      *list,
+                                                        GCancellable   *cancellable,
+                                                        GError         **error);
 gboolean        gs_appstream_add_alternates            (XbSilo         *silo,
                                                         GsApp          *app,
                                                         GsAppList      *list,


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