[recipes/more-cuisines: 4/4] about dialog: Don't hardcode the recipe authors



commit d44a8e6be464d178ed0372d36f8a8654819405e2
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Mar 5 11:09:12 2017 -0500

    about dialog: Don't hardcode the recipe authors
    
    We can get this information from the recipe database.
    Doing so is a small step towards decoupling the recipe
    and chef data from the application, so they can eventually
    be updated independently.
    
    Since the list returned from the database is unordered,
    we now sort the list of recipe contributors alphabetically.

 src/gr-about-dialog.c |   40 +++++++++++++++++++++-------------------
 1 files changed, 21 insertions(+), 19 deletions(-)
---
diff --git a/src/gr-about-dialog.c b/src/gr-about-dialog.c
index a8d21e9..27541e8 100644
--- a/src/gr-about-dialog.c
+++ b/src/gr-about-dialog.c
@@ -26,6 +26,8 @@
 
 #include "gr-about-dialog.h"
 #include "gr-utils.h"
+#include "gr-recipe-store.h"
+#include "gr-app.h"
 
 #include <stdlib.h>
 
@@ -807,6 +809,17 @@ G_GNUC_END_IGNORE_DEPRECATIONS
         }
 }
 
+static int
+compare_strings (gconstpointer a,
+                 gconstpointer b,
+                 gpointer      data)
+{
+        const char * const *sa = a;
+        const char * const *sb = b;
+
+        return strcmp (*sa, *sb);
+}
+
 GrAboutDialog *
 gr_about_dialog_new (void)
 {
@@ -824,27 +837,12 @@ gr_about_dialog_new (void)
                 "Maithili Bhide",
                 NULL
         };
-        const char *recipe_authors[] = {
-                "Ray Strode",
-                "Bastian Ilsø",
-                "Frederik Fyksen",
-                "Matthias Clasen",
-                "Allan Day",
-                "Erusan",
-                "Link Dupont",
-                "Tuomas Kuosmanen",
-                "Matthew Leeds",
-                "Alexandre Franke",
-                "Adrià Arrufat",
-                "Emmanuele Bassi",
-                "Adelia",
-                "Sylvia",
-                "Georges Basile Stavracas Neto",
-                NULL
-        };
+        g_autofree char **recipe_authors = NULL;
+        guint length;
         g_autoptr(GdkPixbuf) logo = NULL;
         const char *p;
         const char *version;
+        GrRecipeStore *store;
 
         logo = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
                                          "org.gnome.Recipes",
@@ -871,8 +869,12 @@ gr_about_dialog_new (void)
                               "website-label", _("Learn more about Recipes"),
                               NULL);
 
+        store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
+        recipe_authors = gr_recipe_store_get_contributors (store, &length);
+        g_qsort_with_data (recipe_authors, length, sizeof (char *), compare_strings, NULL);
         gtk_about_dialog_add_credit_section (GTK_ABOUT_DIALOG (about),
-                                             _("Recipes by"), recipe_authors);
+                                             _("Recipes by"), (const char **)recipe_authors);
+
         add_built_logo (about);
         add_system_tab (about);
 


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