summaryrefslogtreecommitdiffstats
path: root/equipment.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-20 09:53:45 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-20 09:59:09 -0700
commiteee34232dbbd24b7b3db9e44672e240db2db50e9 (patch)
tree596d597d998c18c3c669e42441e1a22e616ec9f8 /equipment.c
parente1faf417a57ca7de4c39cb03697dc70181b6a4c1 (diff)
downloadsubsurface-eee34232dbbd24b7b3db9e44672e240db2db50e9.tar.gz
Add "Apply"/"Cancel" buttons to dive equipment page
It's too damn easy to make mistakes and not even notice them (odd gtk widget selection and keyboard input), or just start editing a cylinder thing and realize it was wrong. So instead of always saving the equipment information implicitly, add explicit "Apply" and "Cancel" buttons that save the information (or re-load it from the dive data structure) So now you need to press an extra button for your changes to *really* take effect. It can be a bit annoying, but it's better than the silent accidental equipment change that could happen before. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'equipment.c')
-rw-r--r--equipment.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/equipment.c b/equipment.c
index 7e52f980a..5d277fe1a 100644
--- a/equipment.c
+++ b/equipment.c
@@ -225,10 +225,30 @@ static void record_cylinder_changes(cylinder_t *cyl, struct cylinder_widget *cyl
void flush_dive_equipment_changes(struct dive *dive)
{
+ /* We do nothing: we require the "Ok" button press */
+}
+
+static void apply_cb(GtkButton *button, gpointer data)
+{
int i;
+ struct dive *dive = current_dive;
+
+ if (!dive)
+ return;
for (i = 0; i < MAX_CYLINDERS; i++)
record_cylinder_changes(dive->cylinder+i, gtk_cylinder+i);
+ flush_divelist(&dive_list, dive);
+}
+
+static void cancel_cb(GtkButton *button, gpointer data)
+{
+ struct dive *dive = current_dive;
+
+ if (!dive)
+ return;
+
+ show_dive_equipment(current_dive);
}
/*
@@ -370,7 +390,8 @@ static GtkListStore *create_tank_size_model(void)
GtkWidget *equipment_widget(void)
{
int i;
- GtkWidget *vbox;
+ GtkWidget *vbox, *hbox;
+ GtkWidget *apply, *cancel;
GtkListStore *model;
vbox = gtk_vbox_new(FALSE, 3);
@@ -387,5 +408,16 @@ GtkWidget *equipment_widget(void)
gtk_box_pack_start(GTK_BOX(vbox), cylinder->hbox, FALSE, TRUE, 0);
}
+ hbox = gtk_hbox_new(TRUE, 3);
+ gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, FALSE, 0);
+
+ apply = gtk_button_new_from_stock(GTK_STOCK_APPLY);
+ cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+ gtk_box_pack_start(GTK_BOX(hbox), apply, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), cancel, FALSE, FALSE, 0);
+
+ g_signal_connect(apply, "clicked", G_CALLBACK(apply_cb), dive_list.model);
+ g_signal_connect(cancel, "clicked", G_CALLBACK(cancel_cb), dive_list.model);
+
return vbox;
}