[gnome-software/1409-add-available-for-fedora-section-to-the-explore-page: 186/187] flatpak: Implement gs_plugin_add_distro_featured()




commit 41567ea7015eddcb71ad3a024b24b1f467114f61
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 8 15:58:09 2021 +0200

    flatpak: Implement gs_plugin_add_distro_featured()

 plugins/flatpak/gs-flatpak.c        | 21 +++++++++++++++++++++
 plugins/flatpak/gs-flatpak.h        |  4 ++++
 plugins/flatpak/gs-plugin-flatpak.c | 15 +++++++++++++++
 3 files changed, 40 insertions(+)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index bd87d57ed..a576b0720 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -3765,6 +3765,27 @@ gs_flatpak_add_featured (GsFlatpak *self,
        return TRUE;
 }
 
+gboolean
+gs_flatpak_add_distro_featured (GsFlatpak *self,
+                               GsAppList *list,
+                               GCancellable *cancellable,
+                               GError **error)
+{
+       g_autoptr(GsAppList) list_tmp = gs_app_list_new ();
+       g_autoptr(GRWLockReaderLocker) locker = NULL;
+
+       if (!gs_flatpak_rescan_app_data (self, cancellable, error))
+               return FALSE;
+
+       locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+       if (!gs_appstream_add_distro_featured (self->silo, list_tmp, cancellable, error))
+               return FALSE;
+
+       gs_app_list_add_list (list, list_tmp);
+
+       return TRUE;
+}
+
 gboolean
 gs_flatpak_add_alternates (GsFlatpak *self,
                           GsApp *app,
diff --git a/plugins/flatpak/gs-flatpak.h b/plugins/flatpak/gs-flatpak.h
index 348a49783..95a937d1f 100644
--- a/plugins/flatpak/gs-flatpak.h
+++ b/plugins/flatpak/gs-flatpak.h
@@ -120,6 +120,10 @@ gboolean   gs_flatpak_add_featured         (GsFlatpak              *self,
                                                 GsAppList              *list,
                                                 GCancellable           *cancellable,
                                                 GError                 **error);
+gboolean       gs_flatpak_add_distro_featured  (GsFlatpak              *self,
+                                                GsAppList              *list,
+                                                GCancellable           *cancellable,
+                                                GError                 **error);
 gboolean       gs_flatpak_add_alternates       (GsFlatpak              *self,
                                                 GsApp                  *app,
                                                 GsAppList              *list,
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index 29ba29700..ee2f874cf 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -1577,6 +1577,21 @@ gs_plugin_add_featured (GsPlugin *plugin,
        return TRUE;
 }
 
+gboolean
+gs_plugin_add_distro_featured (GsPlugin *plugin,
+                              GsAppList *list,
+                              GCancellable *cancellable,
+                              GError **error)
+{
+       GsPluginData *priv = gs_plugin_get_data (plugin);
+       for (guint i = 0; i < priv->flatpaks->len; i++) {
+               GsFlatpak *flatpak = g_ptr_array_index (priv->flatpaks, i);
+               if (!gs_flatpak_add_distro_featured (flatpak, list, cancellable, error))
+                       return FALSE;
+       }
+       return TRUE;
+}
+
 gboolean
 gs_plugin_add_recent (GsPlugin *plugin,
                      GsAppList *list,


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