[recipes] gr-recipe-store api to get and save all the cuisines
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] gr-recipe-store api to get and save all the cuisines
- Date: Tue, 28 Mar 2017 17:38:29 +0000 (UTC)
commit f5cb9608cccb4a71f52243d218c6f79c062cd494
Author: Ekta Nandwani <mailnandwaniekta gmail com>
Date: Mon Mar 20 14:43:21 2017 +0530
gr-recipe-store api to get and save all the cuisines
It checks if the cuisine is already present in the hashtable else inserts it
https://bugzilla.gnome.org/show_bug.cgi?id=779618
src/gr-recipe-store.c | 21 +++++++++++++++++++++
src/gr-recipe-store.h | 2 ++
2 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-recipe-store.c b/src/gr-recipe-store.c
index 58932c4..e62c5ad 100644
--- a/src/gr-recipe-store.c
+++ b/src/gr-recipe-store.c
@@ -1179,6 +1179,27 @@ gr_recipe_store_get_contributors (GrRecipeStore *self,
return (char **)g_hash_table_get_keys_as_array (chefs, length);
}
+char **
+gr_recipe_store_get_all_cuisines (GrRecipeStore *self,
+ guint *length )
+{
+ GHashTableIter iter;
+ GrRecipe *recipe;
+ g_autoptr (GHashTable) cuisines = NULL;
+
+ cuisines = g_hash_table_new (g_str_hash, g_str_equal);
+
+ g_hash_table_iter_init (&iter, self->recipes);
+ while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &recipe)) {
+ if(! (g_hash_table_contains (cuisines, gr_recipe_get_cuisine (recipe)))) {
+ g_hash_table_insert (cuisines,
+ (gpointer) (gr_recipe_get_cuisine (recipe)),
+ (gpointer) (gr_recipe_get_cuisine (recipe)));
+ }
+ }
+ return (char **) g_hash_table_get_keys_as_array (cuisines, length);
+}
+
const char *
gr_recipe_store_get_user_key (GrRecipeStore *self)
{
diff --git a/src/gr-recipe-store.h b/src/gr-recipe-store.h
index cde8700..f162583 100644
--- a/src/gr-recipe-store.h
+++ b/src/gr-recipe-store.h
@@ -117,6 +117,8 @@ gboolean gr_recipe_store_has_cuisine (GrRecipeStore *self,
const char *cuisine);
char ** gr_recipe_store_get_contributors (GrRecipeStore *self,
guint *length);
+char ** gr_recipe_store_get_all_cuisines (GrRecipeStore *store,
+ guint *length);
#define GR_TYPE_RECIPE_SEARCH (gr_recipe_search_get_type())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]