[gnome-software] Rotate hardcoded popular apps



commit 1682fab8f64e0d50609181ba763191e9987560c9
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Aug 30 15:39:48 2013 -0400

    Rotate hardcoded popular apps
    
    For 3.10, we're just going to hardcode a list of eighteen
    popular applications. These were chosen by Allan Day and
    Ryan Lerch. We put them on a 3 day rotation, and scramble
    them a  bit to make things more interesting. After 3.10,
    we will look at getting this data online.

 src/plugins/gs-plugin-hardcoded-popular.c |   48 +++++++++++++++++++++++-----
 1 files changed, 39 insertions(+), 9 deletions(-)
---
diff --git a/src/plugins/gs-plugin-hardcoded-popular.c b/src/plugins/gs-plugin-hardcoded-popular.c
index 3037156..b5cd09a 100644
--- a/src/plugins/gs-plugin-hardcoded-popular.c
+++ b/src/plugins/gs-plugin-hardcoded-popular.c
@@ -51,18 +51,48 @@ gs_plugin_add_popular (GsPlugin *plugin,
                       GError **error)
 {
        GsApp *app;
-       guint i;
        const gchar *apps[] = {
                "transmission-gtk",
-               "cheese",
-               "inkscape",
-               "sound-juicer",
-               "gedit",
-               "gnome-boxes",
-               NULL };
+                "inkscape",
+                "scribus",
+                "simple-scan",
+                "tomboy",
+                "gtg",
+                "stellarium",
+                "gnome-maps",
+                "calibre",
+                "hotot-gtk",
+                "musique",
+                "aisleriot",
+                "shutter",
+                "gnucash",
+                "iagno",
+                "thunderbird",
+                "geary",
+                "pdfshuffler"
+        };
+        gint primes[] = {
+                 2,  3,  5,  7, 11, 13, 17, 19, 23, 29,
+                31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
+                73, 79, 83
+        };
+        GDateTime *date;
+        gboolean hit[G_N_ELEMENTS (apps)];
+        const gint n = G_N_ELEMENTS (apps);
+        gint d, i, k;
+
+        date = g_date_time_new_now_utc ();
+        d = (((gint)g_date_time_get_day_of_year (date)) % (G_N_ELEMENTS (primes) * 3)) / 3;
+        g_date_time_unref (date);
+
+        for (i = 0; i < n; i++) hit[i] = 0;
+
+        i = d % n;
+        for (k = 0; k < n; k++) {
+                i = (i + primes[d]) % n;
+                while (hit[i]) i = (i + 1) % n;
+                hit[i] = 1;
 
-       /* just add each one */
-       for (i = 0; apps[i] != NULL; i++) {
                app = gs_app_new (apps[i]);
                gs_plugin_add_app (list, app);
        }


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