[recipes] Don't show an empty shopping list
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Don't show an empty shopping list
- Date: Sat, 4 Mar 2017 17:02:00 +0000 (UTC)
commit ad46df49438b9778f9df86ac2ea52ee7070b5003
Author: Ekta Nandwani <mailnandwaniekta gmail com>
Date: Sat Mar 4 11:08:44 2017 +0530
Don't show an empty shopping list
Leave the shopping page and go back to the home page
when the last recipe is removed from the shopping list.
This matches the behavior of the "Clear List" button.
https://bugzilla.gnome.org/show_bug.cgi?id=779532
src/gr-shopping-page.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/gr-shopping-page.c b/src/gr-shopping-page.c
index b1e5411..ab0caaa 100644
--- a/src/gr-shopping-page.c
+++ b/src/gr-shopping-page.c
@@ -110,11 +110,12 @@ recount_recipes (GrShoppingPage *page)
GList *children;
int count;
g_autofree char *tmp = NULL;
-
+ GtkWidget *window;
+
children = gtk_container_get_children (GTK_CONTAINER (page->recipe_list));
count = g_list_length (children);
g_list_free (children);
-
+
g_free (page->title);
page->title = g_strdup_printf (ngettext ("Buy Ingredients (%d recipe)",
"Buy Ingredients (%d recipes)", page->recipe_count),
@@ -125,6 +126,10 @@ recount_recipes (GrShoppingPage *page)
"%d Recipes marked for preparation", count),
count);
gtk_label_set_label (GTK_LABEL (page->recipe_count_label), tmp);
+ if (count == 0) {
+ window = gtk_widget_get_ancestor (GTK_WIDGET (page), GTK_TYPE_APPLICATION_WINDOW);
+ gr_window_go_back (GR_WINDOW (window));
+ }
}
typedef struct {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]