[gnome-software/wip/ubuntu-3-20: 32/34] snap: Only feature snaps



commit 072a793657870c37d3d5a7326ee630af355dea4e
Author: Robert Ancell <robert ancell canonical com>
Date:   Wed Aug 9 15:43:02 2017 +1200

    snap: Only feature snaps
    
    Run after the other plugins that populate featured/popular apps and remove
    them when we set ours.

 src/plugins/gs-plugin-snap.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gs-plugin-snap.c b/src/plugins/gs-plugin-snap.c
index f160df7..1af7db0 100644
--- a/src/plugins/gs-plugin-snap.c
+++ b/src/plugins/gs-plugin-snap.c
@@ -38,6 +38,16 @@ gs_plugin_get_name (void)
        return "snap";
 }
 
+const gchar **
+gs_plugin_order_after (GsPlugin *plugin)
+{
+       static const gchar *deps[] = {
+               "appstream",            /* Override hardcoded popular apps */
+               "hardcoded-featured",   /* Override hardcoded popular apps */
+               NULL };
+       return deps;
+}
+
 void
 gs_plugin_initialize (GsPlugin *plugin)
 {
@@ -197,6 +207,12 @@ is_banner_icon_image (const gchar *filename)
        return g_regex_match_simple ("^banner-icon(?:_[a-zA-Z0-9]{7})?\\.(?:png|jpg)$", filename, 0, 0);
 }
 
+static gboolean
+remove_cb (GsApp *app, gpointer user_data)
+{
+       return FALSE;
+}
+
 gboolean
 gs_plugin_add_featured (GsPlugin *plugin,
                        GList **list,
@@ -262,6 +278,8 @@ gs_plugin_add_featured (GsPlugin *plugin,
        gs_app_set_metadata (app, "Featured::stroke-color", "#000000");
        gs_app_set_metadata (app, "Featured::text-shadow", "0 1px 1px rgba(255,255,255,0.5)");
 
+       /* replace any other featured apps with our one */
+       gs_plugin_list_filter (list, remove_cb, NULL);
        gs_plugin_add_app (list, app);
 
        return TRUE;
@@ -280,6 +298,9 @@ gs_plugin_add_popular (GsPlugin *plugin,
        if (snaps == NULL)
                return FALSE;
 
+       /* replace any other popular apps with our one */
+       gs_plugin_list_filter (list, remove_cb, NULL);
+
        /* skip first snap - it is used as the featured app */
        for (i = 1; i < json_array_get_length (snaps); i++) {
                JsonObject *snap = json_array_get_object_element (snaps, i);


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