[recipes] Populate cuisine combobox with all the cuisines



commit 22248bf80af8d4a9e8111e601e6ee52843684447
Author: Ekta Nandwani <mailnandwaniekta gmail com>
Date:   Wed Mar 29 00:44:25 2017 +0530

    Populate cuisine combobox with all the cuisines
    
    Uses gr_recipe_store_get_all_cuisines api to get the cuisines from a hashtable
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779618

 src/gr-edit-page.c |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/src/gr-edit-page.c b/src/gr-edit-page.c
index 3b583bd..1e786e8 100644
--- a/src/gr-edit-page.c
+++ b/src/gr-edit-page.c
@@ -366,17 +366,24 @@ edit_page_finalize (GObject *object)
 static void
 populate_cuisine_combo (GrEditPage *page)
 {
-        const char **names;
+        g_autofree char **names = NULL;
+        guint length;
         const char *title;
-        int length;
         int i;
+        GrRecipeStore *store;
 
-        names = gr_cuisine_get_names (&length);
-        for (i = 0; i < length; i++) {
-                gr_cuisine_get_data (names[i], &title, NULL, NULL);
-                gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (page->cuisine_combo),
-                                           names[i],
-                                           title);
+        store = gr_recipe_store_get ();
+        names = gr_recipe_store_get_all_cuisines (store, &length);
+        gtk_combo_box_text_remove_all (GTK_COMBO_BOX_TEXT (page->cuisine_combo));
+
+        for (i = 0; i < length; ++i) {
+                char *temp_cuisine_name;
+                temp_cuisine_name = g_strstrip (g_strdup (names[i]));
+                if (strcmp (temp_cuisine_name, "") != 0) {
+                        gr_cuisine_get_data (temp_cuisine_name, &title, NULL, NULL);
+                        gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (page->cuisine_combo),
+                                                                       temp_cuisine_name, title);
+                }
         }
 }
 
@@ -2305,7 +2312,7 @@ gr_edit_page_save (GrEditPage *page)
                 if (ret)
                         g_set_object (&page->recipe, recipe);
         }
-
+        populate_cuisine_combo (page);
         if (ret) {
                 gr_image_viewer_persist_changes (GR_IMAGE_VIEWER (page->images));
 


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