[recipes] Save ingredients on focus-out
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Save ingredients on focus-out
- Date: Tue, 16 May 2017 02:49:07 +0000 (UTC)
commit 439ed3179c407cbf1af0ed21a0eaa037c043892e
Author: Matthias Clasen <mclasen redhat com>
Date: Mon May 15 22:14:40 2017 -0400
Save ingredients on focus-out
This ensures that we save and drop the entry regardless
where the focus goes next.
http://bugzilla.gnome.org/show_bug.cgi?id=782657
src/gr-ingredients-viewer-row.c | 25 ++++++++++++++-----------
src/gr-ingredients-viewer-row.ui | 7 ++++---
2 files changed, 18 insertions(+), 14 deletions(-)
---
diff --git a/src/gr-ingredients-viewer-row.c b/src/gr-ingredients-viewer-row.c
index 69554db..fea3432 100644
--- a/src/gr-ingredients-viewer-row.c
+++ b/src/gr-ingredients-viewer-row.c
@@ -217,9 +217,9 @@ gr_ingredients_viewer_row_set_editable (GrIngredientsViewerRow *row,
setup_editable_row (row);
}
-static void save_row (GrIngredientsViewerRow *row);
static gboolean save_unit (GrIngredientsViewerRow *row);
-static void save_ingredient (GrIngredientsViewerRow *row);
+static gboolean save_ingredient (GrIngredientsViewerRow *row);
+static void save_row (GrIngredientsViewerRow *row);
static void
gr_ingredients_viewer_row_set_active (GrIngredientsViewerRow *row,
@@ -285,13 +285,13 @@ edit_ingredient (GrIngredientsViewerRow *row)
viewer = GR_INGREDIENTS_VIEWER (gtk_widget_get_ancestor (GTK_WIDGET (row),
GR_TYPE_INGREDIENTS_VIEWER));
if (row->editable) {
+ save_unit (row);
+
set_active_row (viewer, GTK_WIDGET (row));
- if (save_unit (row)) {
- gtk_entry_set_text (GTK_ENTRY (row->ingredient_entry), row->ingredient);
- gtk_stack_set_visible_child_name (GTK_STACK (row->ingredient_stack),
"ingredient_entry");
- gtk_widget_grab_focus (row->ingredient_entry);
- g_signal_emit (row, signals[EDIT], 0);
- }
+ gtk_entry_set_text (GTK_ENTRY (row->ingredient_entry), row->ingredient);
+ gtk_stack_set_visible_child_name (GTK_STACK (row->ingredient_stack), "ingredient_entry");
+ gtk_widget_grab_focus (row->ingredient_entry);
+ g_signal_emit (row, signals[EDIT], 0);
}
}
@@ -409,10 +409,10 @@ save_unit (GrIngredientsViewerRow *row)
gtk_stack_set_visible_child (GTK_STACK (row->unit_stack), row->unit_event_box);
}
- return TRUE;
+ return GDK_EVENT_PROPAGATE;
}
-static void
+static gboolean
save_ingredient (GrIngredientsViewerRow *row)
{
GtkWidget *visible;
@@ -423,6 +423,8 @@ save_ingredient (GrIngredientsViewerRow *row)
update_ingredient (row);
gtk_stack_set_visible_child (GTK_STACK (row->ingredient_stack), row->ingredient_event_box);
}
+
+ return GDK_EVENT_PROPAGATE;
}
static void
@@ -551,9 +553,10 @@ gr_ingredients_viewer_row_class_init (GrIngredientsViewerRowClass *klass)
gtk_widget_class_bind_template_callback (widget_class, emit_delete);
gtk_widget_class_bind_template_callback (widget_class, edit_unit);
+ gtk_widget_class_bind_template_callback (widget_class, save_unit);
gtk_widget_class_bind_template_callback (widget_class, edit_unit_or_focus_out);
gtk_widget_class_bind_template_callback (widget_class, edit_ingredient);
- gtk_widget_class_bind_template_callback (widget_class, save_row);
+ gtk_widget_class_bind_template_callback (widget_class, save_ingredient);
gtk_widget_class_bind_template_callback (widget_class, entry_key_press);
gtk_widget_class_bind_template_callback (widget_class, drag_key_press);
gtk_widget_class_bind_template_callback (widget_class, unit_text_changed);
diff --git a/src/gr-ingredients-viewer-row.ui b/src/gr-ingredients-viewer-row.ui
index 805856c..503681f 100644
--- a/src/gr-ingredients-viewer-row.ui
+++ b/src/gr-ingredients-viewer-row.ui
@@ -53,8 +53,9 @@
<property name="width-chars">10</property>
<property name="margin-top">4</property>
<property name="margin-bottom">4</property>
- <signal name="activate" handler="save_row" swapped="yes"/>
+ <signal name="activate" handler="save_unit" swapped="yes"/>
<signal name="key-press-event" handler="entry_key_press" swapped="yes"/>
+ <signal name="focus-out-event" handler="save_unit" swapped="yes"/>
<signal name="notify::text" handler="unit_text_changed" swapped="yes"/>
</object>
<packing>
@@ -91,8 +92,9 @@
<property name="placeholder-text" translatable="yes">Ingredient</property>
<property name="margin-top">4</property>
<property name="margin-bottom">4</property>
- <signal name="activate" handler="save_row" swapped="yes"/>
+ <signal name="activate" handler="save_ingredient" swapped="yes"/>
<signal name="key-press-event" handler="entry_key_press" swapped="yes"/>
+ <signal name="focus-out-event" handler="save_ingredient" swapped="yes"/>
</object>
<packing>
<property name="name">ingredient_entry</property>
@@ -127,7 +129,6 @@
<property name="visible">1</property>
<property name="relief">none</property>
<signal name="clicked" handler="emit_delete" swapped="yes"/>
- <signal name="focus-in-event" handler="save_row" swapped="yes" after="yes"/>
<style>
<class name="image-button"/>
<class name="circular"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]