[gnome-software/wip/rancell/featured-snap: 1/3] work on featured snap code



commit d12017a19f849e0c680647f05c5ca5a78e87597f
Author: Robert Ancell <robert ancell canonical com>
Date:   Wed Jul 26 10:28:29 2017 +1200

    work on featured snap code

 plugins/core/gs-plugin-hardcoded-featured.c |    2 +-
 plugins/snap/gs-plugin-snap.c               |   43 ++++++++++++++++++++++++++-
 src/gs-overview-page.c                      |    4 +-
 3 files changed, 45 insertions(+), 4 deletions(-)
---
diff --git a/plugins/core/gs-plugin-hardcoded-featured.c b/plugins/core/gs-plugin-hardcoded-featured.c
index 23efa94..7d3bbd5 100644
--- a/plugins/core/gs-plugin-hardcoded-featured.c
+++ b/plugins/core/gs-plugin-hardcoded-featured.c
@@ -59,7 +59,7 @@ gs_plugin_add_featured (GsPlugin *plugin,
        guint i;
 
        /* we've already got enough featured apps */
-       if (gs_app_list_length (list) >= 5)
+       if (gs_app_list_length (list) > 0)
                return TRUE;
 
        /* just add all */
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index 9c6a18b..bd52822 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -63,6 +63,7 @@ gs_plugin_initialize (GsPlugin *plugin)
        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-featured");
        gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_BEFORE, "hardcoded-popular");
 
        /* set name of MetaInfo file */
@@ -302,6 +303,45 @@ gs_plugin_destroy (GsPlugin *plugin)
 }
 
 gboolean
+gs_plugin_add_featured (GsPlugin *plugin,
+                       GsAppList *list,
+                       GCancellable *cancellable,
+                       GError **error)
+{
+       g_autoptr(GPtrArray) snaps = NULL;
+       SnapdSnap *snap;
+       g_autoptr(GsApp) app = NULL;
+       g_autofree gchar *css = NULL;
+
+       snaps = find_snaps (plugin, SNAPD_FIND_FLAGS_NONE, "featured", NULL, cancellable, error);
+       if (snaps == NULL)
+               return FALSE;
+
+       if (snaps->len == 0)
+               return TRUE;
+
+       /* use first snap as the featured app */
+       snap = snaps->pdata[0];
+       app = snap_to_app (plugin, snap);
+       css = g_strdup_printf ("border-color: #000000;\n"
+                              "text-shadow: 0 1px 1px rgba(0,0,0,0.5);\n"
+                              "color: #ffffff;\n"
+                              "outline-offset: 0;\n"
+                              "outline-color: alpha(#ffffff, 0.75);\n"
+                              "outline-style: dashed;\n"
+                              "outline-offset: 2px;\n"
+                              "background:"
+                              " #000000"
+                              " url('%s')"
+                              " left center / auto no-repeat;",
+                              snapd_snap_get_icon (snap));
+       gs_app_set_metadata (app, "GnomeSoftware::FeatureTile-css", css);
+       gs_app_list_add (list, app);
+
+       return TRUE;
+}
+
+gboolean
 gs_plugin_add_popular (GsPlugin *plugin,
                       GsAppList *list,
                       GCancellable *cancellable,
@@ -314,7 +354,8 @@ gs_plugin_add_popular (GsPlugin *plugin,
        if (snaps == NULL)
                return FALSE;
 
-       for (i = 0; i < snaps->len; i++) {
+       /* skip first snap - it is used as the featured app */
+       for (i = 1; i < snaps->len; i++) {
                SnapdSnap *snap = snaps->pdata[i];
                gs_app_list_add (list, snap_to_app (plugin, snap));
        }
diff --git a/src/gs-overview-page.c b/src/gs-overview-page.c
index d0ad617..1c0a9a7 100644
--- a/src/gs-overview-page.c
+++ b/src/gs-overview-page.c
@@ -175,8 +175,8 @@ gs_overview_page_get_popular_cb (GObject *source_object,
                goto out;
        }
        /* Don't show apps from the category that's currently featured as the category of the day */
-       gs_app_list_filter (list, filter_category, priv->category_of_day);
-       gs_app_list_randomize (list);
+       //gs_app_list_filter (list, filter_category, priv->category_of_day);
+       //gs_app_list_randomize (list);
 
        gs_container_remove_all (GTK_CONTAINER (priv->box_popular));
 


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