[recipes] Add an empty ingredients list to new recipes



commit 582441392a8448ea29a6d4047150cb3a3e2735f8
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Mar 15 14:16:15 2017 -0400

    Add an empty ingredients list to new recipes
    
    This was the desired initial appearance of the page.
    It was lost at some point, bring it back.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779109

 src/gr-edit-page.c |   46 +++++++++++++++++++++++++---------------------
 1 files changed, 25 insertions(+), 21 deletions(-)
---
diff --git a/src/gr-edit-page.c b/src/gr-edit-page.c
index b6678eb..f2d2d34 100644
--- a/src/gr-edit-page.c
+++ b/src/gr-edit-page.c
@@ -1857,27 +1857,31 @@ populate_ingredients (GrEditPage *page,
         page->segments = NULL;
         page->active_row = NULL;
 
-        ingredients = gr_ingredients_list_new (text);
-        segs = gr_ingredients_list_get_segments (ingredients);
-        for (j = 0; segs[j]; j++) {
-                GtkWidget *list;
-                g_auto(GStrv) ings = NULL;
-
-                list = add_ingredients_segment (page, segs[j]);
-                ings = gr_ingredients_list_get_ingredients (ingredients, segs[j]);
-                for (i = 0; ings[i]; i++) {
-                        g_autofree char *s = NULL;
-                        g_auto(GStrv) strv = NULL;
-                        const char *amount;
-                        const char *unit;
-                        GtkWidget *row;
-
-                        s = gr_ingredients_list_scale_unit (ingredients, segs[j], ings[i], 1, 1);
-                        strv = g_strsplit (s, " ", 2);
-                        amount = strv[0];
-                        unit = strv[1] ? strv[1] : "";
-                        row = add_ingredient_row (page, list, page->group);
-                        update_ingredient_row (row, amount, unit, ings[i]);
+        if (strcmp (text, "") == 0)
+                add_list (NULL, page);
+        else {
+                ingredients = gr_ingredients_list_new (text);
+                segs = gr_ingredients_list_get_segments (ingredients);
+                for (j = 0; segs[j]; j++) {
+                        GtkWidget *list;
+                        g_auto(GStrv) ings = NULL;
+
+                        list = add_ingredients_segment (page, segs[j]);
+                        ings = gr_ingredients_list_get_ingredients (ingredients, segs[j]);
+                        for (i = 0; ings[i]; i++) {
+                                g_autofree char *s = NULL;
+                                g_auto(GStrv) strv = NULL;
+                                const char *amount;
+                                const char *unit;
+                                GtkWidget *row;
+
+                                s = gr_ingredients_list_scale_unit (ingredients, segs[j], ings[i], 1, 1);
+                                strv = g_strsplit (s, " ", 2);
+                                amount = strv[0];
+                                unit = strv[1] ? strv[1] : "";
+                                row = add_ingredient_row (page, list, page->group);
+                                update_ingredient_row (row, amount, unit, ings[i]);
+                        }
                 }
         }
 


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