[recipes] details: Don't preserve serves value
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] details: Don't preserve serves value
- Date: Tue, 20 Jun 2017 21:53:24 +0000 (UTC)
commit 426311e6b77b888c4baa250a89355d4676ff5d48
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jun 20 17:51:41 2017 -0400
details: Don't preserve serves value
As far as I can see, this was always erroneous. The only way
the recipe can change in the store is if we go to the edit page
and come back. In this case, preserving the serves value can
lead to confusing behavior, where we see ingredients amounts
change unexpectedly. So just don't do it.
src/gr-details-page.c | 23 +++--------------------
1 files changed, 3 insertions(+), 20 deletions(-)
---
diff --git a/src/gr-details-page.c b/src/gr-details-page.c
index d2f3493..31d0b1f 100644
--- a/src/gr-details-page.c
+++ b/src/gr-details-page.c
@@ -559,8 +559,6 @@ void
gr_details_page_set_recipe (GrDetailsPage *page,
GrRecipe *recipe)
{
- const char *id = NULL;
- const char *old_id = NULL;
const char *author;
const char *prep_time;
const char *cook_time;
@@ -568,7 +566,6 @@ gr_details_page_set_recipe (GrDetailsPage *page,
const char *meal;
const char *season;
int serves;
- int want_serves;
const char *ingredients;
const char *instructions;
const char *notes;
@@ -578,15 +575,9 @@ gr_details_page_set_recipe (GrDetailsPage *page,
g_autoptr(GrIngredientsList) ing = NULL;
GPtrArray *images;
gboolean favorite;
- gboolean same_recipe;
int index;
g_autofree char *processed = NULL;
- if (page->recipe)
- old_id = gr_recipe_get_id (page->recipe);
- id = gr_recipe_get_id (recipe);
- same_recipe = g_strcmp0 (old_id, id) == 0;
-
g_set_object (&page->recipe, recipe);
author = gr_recipe_get_author (recipe);
@@ -600,10 +591,7 @@ gr_details_page_set_recipe (GrDetailsPage *page,
notes = gr_recipe_get_translated_notes (recipe);
instructions = gr_recipe_get_translated_instructions (recipe);
description = gr_recipe_get_translated_description (recipe);
- if (same_recipe)
- g_object_get (page->recipe_image, "index", &index, NULL);
- else
- index = gr_recipe_get_default_image (recipe);
+ index = gr_recipe_get_default_image (recipe);
images = gr_recipe_get_images (recipe);
gr_image_viewer_set_images (GR_IMAGE_VIEWER (page->recipe_image), images, index);
@@ -613,12 +601,7 @@ gr_details_page_set_recipe (GrDetailsPage *page,
g_free (page->ing_text);
page->ing_text = g_strdup (ingredients);
- if (same_recipe)
- want_serves = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (page->serves_spin));
- else
- want_serves = serves;
-
- populate_ingredients (page, want_serves, serves);
+ populate_ingredients (page, serves, serves);
if (prep_time[0] == '\0') {
gtk_widget_hide (page->prep_time_label);
@@ -674,7 +657,7 @@ gr_details_page_set_recipe (GrDetailsPage *page,
gtk_label_set_label (GTK_LABEL (page->instructions_label), processed);
gtk_label_set_track_visited_links (GTK_LABEL (page->instructions_label), FALSE);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (page->serves_spin), want_serves);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (page->serves_spin), serves);
gtk_widget_set_sensitive (page->serves_spin, ing != NULL);
store = gr_recipe_store_get ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]