[gnome-software/wip/ubuntu-3-22: 24/25] snap: Only feature snaps



commit 573db8b8ce6401d38701fa3f368b68f92aa0a4cc
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 |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/gs-plugin-snap.c b/src/plugins/gs-plugin-snap.c
index e6b3d4c..4e148ae 100644
--- a/src/plugins/gs-plugin-snap.c
+++ b/src/plugins/gs-plugin-snap.c
@@ -56,11 +56,13 @@ gs_plugin_initialize (GsPlugin *plugin)
 
        gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "desktop-categories");
        gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "ubuntu-reviews");
+       gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "appstream");
        gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_BETTER_THAN, "packagekit");
        gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_BEFORE, "icons");
 
        /* Override hardcoded popular apps */
-       gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_BEFORE, "hardcoded-popular");
+       gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "hardcoded-popular");
+       gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "hardcoded-featured");
 }
 
 gboolean
@@ -270,6 +272,11 @@ is_banner_icon_image (const gchar *filename)
        return g_regex_match_simple ("^banner-icon(?:_[a-zA-Z0-9]{7})?\\.(?:png|jpg)$", filename, 0, 0);
 }
 
+remove_cb (GsApp *app, gpointer user_data)
+{
+       return FALSE;
+}
+
 gboolean
 gs_plugin_add_featured (GsPlugin *plugin,
                        GsAppList *list,
@@ -341,6 +348,8 @@ gs_plugin_add_featured (GsPlugin *plugin,
                               background_css->str);
        gs_app_set_metadata (app, "GnomeSoftware::FeatureTile-css", css);
 
+       /* replace any other featured apps with our one */
+       gs_app_list_filter (list, remove_cb, NULL);
        gs_app_list_add (list, app);
 
        return TRUE;
@@ -359,6 +368,9 @@ gs_plugin_add_popular (GsPlugin *plugin,
        if (snaps == NULL)
                return FALSE;
 
+       /* replace any other popular apps with our one */
+       gs_app_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]