[gnome-software] Rotate hardcoded featured apps



commit 48775a499a4f1ae630340271968025f310a1bcc7
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Aug 30 14:59:39 2013 -0400

    Rotate hardcoded featured apps
    
    The three apps were chosen by Allan Day and Ryan Lerch. For
    3.10, we're just going to hardcode gimp, gnome-weather and
    gnome-sudoku as featured apps, and put them on a 3 day
    rotation. After 3.10, we will look at getting this data
    online.

 src/plugins/gs-plugin-hardcoded-featured.c |   42 +++++++++++++++++----------
 1 files changed, 26 insertions(+), 16 deletions(-)
---
diff --git a/src/plugins/gs-plugin-hardcoded-featured.c b/src/plugins/gs-plugin-hardcoded-featured.c
index 1eb7814..5bffad8 100644
--- a/src/plugins/gs-plugin-hardcoded-featured.c
+++ b/src/plugins/gs-plugin-hardcoded-featured.c
@@ -55,25 +55,35 @@ gs_plugin_add_featured (GsPlugin *plugin,
        GdkPixbuf *pixbuf;
        GsApp *app;
        guint i;
+        GDateTime *date;
        const gchar *apps[] = {
-               "firefox",
-               NULL };
+                "gimp",
+                "gnome-weather",
+                "gnome-sudoku",
+               NULL
+        };
 
-       /* just add each one */
-       for (i = 0; apps[i] != NULL; i++) {
-               app = gs_app_new (apps[i]);
-               gs_plugin_add_app (list, app);
-               path = g_strdup_printf ("%s/gnome-software/featured-%s.png",
-                                       DATADIR, apps[i]);
-               pixbuf = gdk_pixbuf_new_from_file_at_scale (path, -1, -1, TRUE, error);
-               g_free (path);
-               if (pixbuf == NULL) {
-                       ret = FALSE;
-                       goto out;
-               }
-               gs_app_set_featured_pixbuf (app, pixbuf);
-               g_object_unref (pixbuf);
+        /* In lieu of a random number generator, just
+         * rotate the featured apps, giving each app
+         * 3 days apiece.
+         */
+        date = g_date_time_new_now_utc ();
+        i = g_date_time_get_day_of_year (date);
+        g_date_time_unref (date);
+        i = (i % (G_N_ELEMENTS (apps) * 3)) / 3;
+
+        app = gs_app_new (apps[i]);
+       gs_plugin_add_app (list, app);
+       path = g_strdup_printf ("%s/gnome-software/featured-%s.png",
+                               DATADIR, apps[i]);
+       pixbuf = gdk_pixbuf_new_from_file_at_scale (path, -1, -1, TRUE, error);
+       g_free (path);
+       if (pixbuf == NULL) {
+               ret = FALSE;
+               goto out;
        }
+       gs_app_set_featured_pixbuf (app, pixbuf);
+       g_object_unref (pixbuf);
 out:
        return ret;
 }


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