[recipes] store: Add apis to get shopping list
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] store: Add apis to get shopping list
- Date: Tue, 14 Mar 2017 03:31:07 +0000 (UTC)
commit b8a2d9b0304d6ee7597ca73d7827463d0f76b518
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Mar 13 23:27:20 2017 -0400
store: Add apis to get shopping list
It is better to get these lists from the store, than
pulling them out of the widgetry on the shopping page.
src/gr-recipe-store.c | 34 ++++++++++++++++++++++++++++++++++
src/gr-recipe-store.h | 15 +++++++++------
2 files changed, 43 insertions(+), 6 deletions(-)
---
diff --git a/src/gr-recipe-store.c b/src/gr-recipe-store.c
index a7109e2..66ea116 100644
--- a/src/gr-recipe-store.c
+++ b/src/gr-recipe-store.c
@@ -1567,6 +1567,34 @@ gr_recipe_store_is_in_shopping (GrRecipeStore *self,
return g_variant_dict_contains (self->shopping_list, id);
}
+GList *
+gr_recipe_store_get_shopping_list (GrRecipeStore *self)
+{
+ g_autoptr(GVariant) dict = NULL;
+ char *key;
+ GVariant *value;
+ GList *list = NULL;
+ GVariantIter iter;
+
+ dict = g_variant_ref_sink (g_variant_dict_end (self->shopping_list));
+ g_variant_iter_init (&iter, dict);
+ while (g_variant_iter_next (&iter, "{sv}", &key, &value)) {
+ GrRecipe *recipe;
+
+ recipe = g_hash_table_lookup (self->recipes, key);
+
+ list = g_list_append (list, g_object_ref (recipe));
+
+ g_variant_unref (value);
+ g_free (key);
+ }
+
+ g_variant_dict_unref (self->shopping_list);
+ self->shopping_list = g_variant_dict_new (dict);
+
+ return list;
+}
+
int
gr_recipe_store_get_shopping_serves (GrRecipeStore *self,
GrRecipe *recipe)
@@ -1614,6 +1642,12 @@ gr_recipe_store_readd_shopping_ingredient (GrRecipeStore *self,
save_shopping (self);
}
+const char **
+gr_recipe_store_get_removed_shopping_ingredients (GrRecipeStore *self)
+{
+ return (const char **)self->shopping_removed;
+}
+
GDateTime *
gr_recipe_store_last_shopping_change (GrRecipeStore *self)
{
diff --git a/src/gr-recipe-store.h b/src/gr-recipe-store.h
index 9f9cea7..cde8700 100644
--- a/src/gr-recipe-store.h
+++ b/src/gr-recipe-store.h
@@ -97,15 +97,18 @@ void gr_recipe_store_remove_from_shopping (GrRecipeStore *self,
void gr_recipe_store_clear_shopping_list (GrRecipeStore *self);
gboolean gr_recipe_store_is_in_shopping (GrRecipeStore *self,
GrRecipe *recipe);
-int gr_recipe_store_get_shopping_serves (GrRecipeStore *store,
+GList *gr_recipe_store_get_shopping_list (GrRecipeStore *self);
+int gr_recipe_store_get_shopping_serves (GrRecipeStore *self,
GrRecipe *recipe);
-gboolean gr_recipe_store_not_shopping_ingredient (GrRecipeStore *self,
- const char *ingredient);
+gboolean gr_recipe_store_not_shopping_ingredient (GrRecipeStore *self,
+ const char *ingredient);
void gr_recipe_store_remove_shopping_ingredient (GrRecipeStore *self,
- const char *ingredient);
-void gr_recipe_store_readd_shopping_ingredient (GrRecipeStore *self,
- const char *ingredient);
+ const char *ingredient);
+void gr_recipe_store_readd_shopping_ingredient (GrRecipeStore *self,
+ const char *ingredient);
+const char **gr_recipe_store_get_removed_shopping_ingredients (GrRecipeStore *self);
GDateTime *gr_recipe_store_last_shopping_change (GrRecipeStore *self);
+
gboolean gr_recipe_store_has_diet (GrRecipeStore *self,
GrDiets diet);
gboolean gr_recipe_store_has_chef (GrRecipeStore *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]