[recipes] Improve details on the edit page
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Improve details on the edit page
- Date: Sat, 17 Dec 2016 13:50:55 +0000 (UTC)
commit b863c64a2ed298d6c29c5f9525f82578b47c670b
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Dec 17 08:50:05 2016 -0500
Improve details on the edit page
Show the author of the recipe, and adjust the label for the
name entry to reflect whether this is a new recipe or not.
src/gr-edit-page.c | 28 +++++++++++++++++++++++++++-
src/gr-edit-page.ui | 36 ++++++++++++++++++++++++------------
2 files changed, 51 insertions(+), 13 deletions(-)
---
diff --git a/src/gr-edit-page.c b/src/gr-edit-page.c
index d1c5090..999c79b 100644
--- a/src/gr-edit-page.c
+++ b/src/gr-edit-page.c
@@ -52,6 +52,7 @@ struct _GrEditPage
GtkWidget *error_revealer;
GtkWidget *error_label;
+ GtkWidget *name_label;
GtkWidget *name_entry;
GtkWidget *cuisine_combo;
GtkWidget *category_combo;
@@ -78,6 +79,7 @@ struct _GrEditPage
GtkWidget *new_ingredient_unit;
GtkWidget *new_ingredient_add_button;
GtkWidget *remove_ingredient_button;
+ GtkWidget *author_label;
GtkSizeGroup *group;
@@ -333,6 +335,7 @@ gr_edit_page_class_init (GrEditPageClass *klass)
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrEditPage, error_revealer);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrEditPage, error_label);
+ gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrEditPage, name_label);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrEditPage, name_entry);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrEditPage, cuisine_combo);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrEditPage, category_combo);
@@ -358,6 +361,7 @@ gr_edit_page_class_init (GrEditPageClass *klass)
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrEditPage, new_ingredient_amount);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrEditPage, new_ingredient_unit);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrEditPage,
remove_ingredient_button);
+ gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrEditPage, author_label);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), dismiss_error);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), add_image);
@@ -465,6 +469,7 @@ gr_edit_page_clear (GrEditPage *page)
{
GArray *images;
+ gtk_label_set_label (GTK_LABEL (page->name_label), _("Name your recipe"));
gtk_entry_set_text (GTK_ENTRY (page->name_entry), "");
set_combo_value (GTK_COMBO_BOX (page->cuisine_combo), "");
set_combo_value (GTK_COMBO_BOX (page->category_combo), "");
@@ -480,6 +485,7 @@ gr_edit_page_clear (GrEditPage *page)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (page->vegan_check), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (page->vegetarian_check), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (page->milk_free_check), FALSE);
+ gtk_widget_hide (page->author_label);
images = gr_rotated_image_array_new ();
g_object_set (page->images, "images", images, NULL);
@@ -517,6 +523,7 @@ gr_edit_page_edit (GrEditPage *page,
const char *season;
const char *prep_time;
const char *cook_time;
+ const char *author;
int serves;
int spiciness;
const char *instructions;
@@ -524,6 +531,10 @@ gr_edit_page_edit (GrEditPage *page,
g_autoptr(GdkPixbuf) pixbuf = NULL;
GrDiets diets;
g_autoptr(GArray) images = NULL;
+ g_autoptr(GrChef) chef = NULL;
+ GrRecipeStore *store;
+
+ store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
name = gr_recipe_get_name (recipe);
serves = gr_recipe_get_serves (recipe);
@@ -535,9 +546,14 @@ gr_edit_page_edit (GrEditPage *page,
cook_time = gr_recipe_get_cook_time (recipe);
diets = gr_recipe_get_diets (recipe);
instructions = gr_recipe_get_instructions (recipe);
+ author = gr_recipe_get_author (recipe);
g_object_get (recipe, "images", &images, NULL);
+ chef = gr_recipe_store_get_chef (store, author ? author : "");
+
+ gtk_label_set_label (GTK_LABEL (page->name_label), _("Name"));
+
gtk_entry_set_text (GTK_ENTRY (page->name_entry), name);
set_combo_value (GTK_COMBO_BOX (page->cuisine_combo), cuisine);
set_combo_value (GTK_COMBO_BOX (page->category_combo), category);
@@ -558,6 +574,16 @@ gr_edit_page_edit (GrEditPage *page,
g_object_set (page->images, "images", images, NULL);
+ if (chef) {
+ g_autofree char *tmp = NULL;
+ tmp = g_strdup_printf (_("Recipe by %s"), gr_chef_get_name (chef));
+ gtk_label_set_label (GTK_LABEL (page->author_label), tmp);
+ gtk_widget_show (page->author_label);
+ }
+ else {
+ gtk_widget_hide (page->author_label);
+ }
+
g_set_object (&page->recipe, recipe);
}
@@ -573,7 +599,6 @@ account_response (GDBusConnection *connection,
GrEditPage *page = user_data;
guint32 response;
GVariant *options;
- GrRecipeStore *store;
g_autoptr(GrChef) chef = NULL;
g_autoptr(GError) error = NULL;
@@ -585,6 +610,7 @@ account_response (GDBusConnection *connection,
const char *name;
const char *uri;
g_autofree char *path = NULL;
+ GrRecipeStore *store;
store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
chef = gr_recipe_store_get_chef (store, gr_recipe_store_get_user_key (store));
diff --git a/src/gr-edit-page.ui b/src/gr-edit-page.ui
index f686592..68becd5 100644
--- a/src/gr-edit-page.ui
+++ b/src/gr-edit-page.ui
@@ -496,12 +496,12 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">-1</property>
+ <property name="top-attach">0</property>
<property name="width">2</property>
</packing>
</child>
<child>
- <object class="GtkLabel">
+ <object class="GtkLabel" id="name_label">
<property name="visible">1</property>
<property name="use-underline">1</property>
<property name="mnemonic-widget">name_entry</property>
@@ -512,7 +512,7 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">0</property>
+ <property name="top-attach">1</property>
</packing>
</child>
<child>
@@ -522,7 +522,7 @@
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">0</property>
+ <property name="top-attach">1</property>
</packing>
</child>
<child>
@@ -536,7 +536,7 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">1</property>
+ <property name="top-attach">2</property>
</packing>
</child>
<child>
@@ -547,7 +547,7 @@
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">1</property>
+ <property name="top-attach">2</property>
</packing>
</child>
<child>
@@ -561,7 +561,7 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">2</property>
+ <property name="top-attach">3</property>
</packing>
</child>
<child>
@@ -575,7 +575,7 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">3</property>
+ <property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -593,7 +593,7 @@
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">2</property>
+ <property name="top-attach">3</property>
</packing>
</child>
<child>
@@ -611,7 +611,7 @@
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">3</property>
+ <property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -623,7 +623,7 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">15</property>
+ <property name="top-attach">5</property>
<property name="width">2</property>
</packing>
</child>
@@ -645,7 +645,19 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">16</property>
+ <property name="top-attach">6</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="author_label">
+ <property name="visible">1</property>
+ <property name="xalign">0</property>
+ <property name="margin-top">20</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">7</property>
<property name="width">2</property>
</packing>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]