[recipes] Make it possible to toggle the edit/delete buttons
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Make it possible to toggle the edit/delete buttons
- Date: Fri, 23 Dec 2016 15:38:11 +0000 (UTC)
commit 0123aa523d390ca225578fc090fe2db1419734e1
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Dec 22 20:35:32 2016 -0500
Make it possible to toggle the edit/delete buttons
This feels more natural. For good measure, we also remove
the buttons when a segment is added or removed, just so
we avoid getting into problems if the active row gets
indirectly removed.
src/gr-edit-page.c | 28 +++++++++++++++++++---------
1 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/src/gr-edit-page.c b/src/gr-edit-page.c
index ca073d6..9c7fcbf 100644
--- a/src/gr-edit-page.c
+++ b/src/gr-edit-page.c
@@ -266,21 +266,22 @@ edit_ingredient (GtkButton *button, GrEditPage *page)
}
static void
-ingredient_row_activated (GtkListBox *list,
- GtkListBoxRow *row,
- GrEditPage *page)
+set_active_row (GrEditPage *page,
+ GtkWidget *row)
{
GtkWidget *stack;
- if ((GtkWidget *)row == page->active_row)
- return;
-
if (page->active_row) {
stack = g_object_get_data (G_OBJECT (page->active_row), "buttons-stack");
gtk_stack_set_visible_child_name (GTK_STACK (stack), "empty");
}
- page->active_row = (GtkWidget *)row;
+ if (page->active_row == row) {
+ page->active_row = NULL;
+ return;
+ }
+
+ page->active_row = row;
if (page->active_row) {
stack = g_object_get_data (G_OBJECT (page->active_row), "buttons-stack");
@@ -289,6 +290,14 @@ ingredient_row_activated (GtkListBox *list,
}
static void
+ingredient_row_activated (GtkListBox *list,
+ GtkListBoxRow *row,
+ GrEditPage *page)
+{
+ set_active_row (page, GTK_WIDGET (row));
+}
+
+static void
update_ingredient_row (GtkWidget *row,
const char *amount,
const char *unit,
@@ -383,8 +392,6 @@ add_ingredient_row (GrEditPage *page,
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), TRUE);
- g_signal_connect (list, "row-activated", G_CALLBACK (ingredient_row_activated), page);
-
return row;
}
@@ -681,6 +688,7 @@ add_ingredients_segment (GrEditPage *page,
gtk_stack_add_named (GTK_STACK (stack), box, "entry");
list = gtk_list_box_new ();
+ g_signal_connect (list, "row-activated", G_CALLBACK (ingredient_row_activated), page);
g_object_set_data (G_OBJECT (segment), "list", list);
gtk_widget_show (list);
@@ -734,6 +742,7 @@ add_list (GtkButton *button, GrEditPage *page)
add_ingredients_segment (page, "");
update_segments (page);
+ set_active_row (page, NULL);
}
static void
@@ -747,6 +756,7 @@ remove_list (GtkButton *button, GrEditPage *page)
gtk_widget_destroy (segment);
update_segments (page);
+ set_active_row (page, NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]