[recipes] Simplify an API
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Simplify an API
- Date: Thu, 11 May 2017 03:28:59 +0000 (UTC)
commit 4aa238cc26ce08978eb7c1d55e62b5ff86175cf8
Author: Matthias Clasen <mclasen redhat com>
Date: Wed May 10 23:28:17 2017 -0400
Simplify an API
gr_window_show_diet does not need a separate title
argument, since we can find the title from the diet.
Update all callers.
src/gr-app.c | 10 +++++-----
src/gr-recipes-page.c | 4 +---
src/gr-window.c | 3 +--
src/gr-window.h | 1 -
4 files changed, 7 insertions(+), 11 deletions(-)
---
diff --git a/src/gr-app.c b/src/gr-app.c
index 2565baf..e0fa852 100644
--- a/src/gr-app.c
+++ b/src/gr-app.c
@@ -189,15 +189,15 @@ category_activated (GSimpleAction *action,
else if (g_strcmp0 (category, "new") == 0)
gr_window_show_new (win);
else if (g_strcmp0 (category, "gluten-free") == 0)
- gr_window_show_diet (win, gr_diet_get_label (GR_DIET_GLUTEN_FREE), GR_DIET_GLUTEN_FREE);
+ gr_window_show_diet (win, GR_DIET_GLUTEN_FREE);
else if (g_strcmp0 (category, "nut-free") == 0)
- gr_window_show_diet (win, gr_diet_get_label (GR_DIET_NUT_FREE), GR_DIET_NUT_FREE);
+ gr_window_show_diet (win, GR_DIET_NUT_FREE);
else if (g_strcmp0 (category, "vegan") == 0)
- gr_window_show_diet (win, gr_diet_get_label (GR_DIET_VEGAN), GR_DIET_VEGAN);
+ gr_window_show_diet (win, GR_DIET_VEGAN);
else if (g_strcmp0 (category, "vegetarian") == 0)
- gr_window_show_diet (win, gr_diet_get_label (GR_DIET_VEGETARIAN), GR_DIET_VEGETARIAN);
+ gr_window_show_diet (win, GR_DIET_VEGETARIAN);
else if (g_strcmp0 (category, "milk-free") == 0)
- gr_window_show_diet (win, gr_diet_get_label (GR_DIET_MILK_FREE), GR_DIET_MILK_FREE);
+ gr_window_show_diet (win, GR_DIET_MILK_FREE);
else
g_print (_("Supported categories: %s\n"),
"mine, favorites, all, "
diff --git a/src/gr-recipes-page.c b/src/gr-recipes-page.c
index 1c9476d..2f644b5 100644
--- a/src/gr-recipes-page.c
+++ b/src/gr-recipes-page.c
@@ -192,16 +192,14 @@ category_clicked (GrCategoryTile *tile,
GtkWidget *window;
GrDiets diet;
const char *name;
- const char *label;
window = gtk_widget_get_ancestor (GTK_WIDGET (tile), GR_TYPE_WINDOW);
diet = gr_category_tile_get_diet (tile);
name = gr_category_tile_get_category (tile);
- label = gr_category_tile_get_label (tile);
if (diet)
- gr_window_show_diet (GR_WINDOW (window), label, diet);
+ gr_window_show_diet (GR_WINDOW (window), diet);
else if (strcmp (name, "favorites") == 0)
gr_window_show_favorites (GR_WINDOW (window));
else if (strcmp (name, "mine") == 0)
diff --git a/src/gr-window.c b/src/gr-window.c
index c9d0e90..6ded71b 100644
--- a/src/gr-window.c
+++ b/src/gr-window.c
@@ -1206,14 +1206,13 @@ gr_window_save_all (GrWindow *window)
void
gr_window_show_diet (GrWindow *window,
- const char *title,
GrDiets diet)
{
save_back_entry (window);
gr_list_page_populate_from_diet (GR_LIST_PAGE (window->list_page), diet);
- gtk_header_bar_set_title (GTK_HEADER_BAR (window->header), title);
+ gtk_header_bar_set_title (GTK_HEADER_BAR (window->header), gr_diet_get_label (diet));
gtk_stack_set_visible_child_name (GTK_STACK (window->header_start_stack), "back");
gtk_stack_set_visible_child_name (GTK_STACK (window->header_title_stack), "title");
diff --git a/src/gr-window.h b/src/gr-window.h
index e56c56c..4bd2640 100644
--- a/src/gr-window.h
+++ b/src/gr-window.h
@@ -45,7 +45,6 @@ void gr_window_edit_recipe (GrWindow *window,
void gr_window_show_search (GrWindow *window,
const char *terms);
void gr_window_show_diet (GrWindow *window,
- const char *title,
GrDiets diet);
void gr_window_show_chef (GrWindow *window,
GrChef *chef);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]