[recipes] Add all cuisines to the cuisines page



commit 5e455c9988b4c1655493379772906502a0498bc3
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Mar 28 22:29:14 2017 +0100

    Add all cuisines to the cuisines page
    
    We have an expander here now, so we can just show all the
    cuisines that are present in the store. Use the store api
    that we added for this purpose.

 src/gr-cuisines-page.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-cuisines-page.c b/src/gr-cuisines-page.c
index b0b5723..23cb827 100644
--- a/src/gr-cuisines-page.c
+++ b/src/gr-cuisines-page.c
@@ -145,10 +145,15 @@ populate_cuisines (GrCuisinesPage *page)
         int i, j;
         GrRecipeStore *store;
         int tiles;
+        g_autoptr(GHashTable) seen = NULL;
+        g_autofree char **names = NULL;
+        guint len;
 
         container_remove_all (GTK_CONTAINER (page->cuisines_box));
         container_remove_all (GTK_CONTAINER (page->cuisines_box2));
 
+        seen = g_hash_table_new (g_str_hash, g_str_equal);
+
         store = gr_recipe_store_get ();
 
         all_cuisines = gr_cuisine_get_names (&length);
@@ -174,6 +179,7 @@ populate_cuisines (GrCuisinesPage *page)
         gtk_widget_show (tile);
         gtk_widget_set_halign (tile, GTK_ALIGN_FILL);
         gtk_grid_attach (GTK_GRID (page->cuisines_box), tile, 0, 0, 2, 1);
+        g_hash_table_add (seen, page->featured);
 
         tiles = 0;
         for (i = 0; i < length; i++) {
@@ -196,6 +202,28 @@ populate_cuisines (GrCuisinesPage *page)
                         gtk_container_add (GTK_CONTAINER (page->cuisines_box2), tile);
                 }
                 tiles++;
+
+                g_hash_table_add (seen, cuisines[i]);
+        }
+
+        names = gr_recipe_store_get_all_cuisines (store, &len);
+        for (i = 0; i < len; i++) {
+               g_autofree char *tmp = NULL;
+               const char *title;
+
+                tmp = g_strstrip (g_strdup (names[i]));
+                if (strcmp (tmp, "") == 0)
+                        continue;
+
+                if (g_hash_table_contains (seen, tmp))
+                        continue;
+
+                gr_cuisine_get_data (tmp, &title, NULL, NULL);
+
+                tile = gr_category_tile_new_with_label (tmp, title);
+                gtk_widget_show (tile);
+                g_signal_connect (tile, "clicked", G_CALLBACK (cuisine_clicked), page);
+                gtk_container_add (GTK_CONTAINER (page->cuisines_box2), tile);
         }
 }
 


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