diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-10-02 16:58:53 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-10-02 16:58:53 -0700 |
commit | 3e1b3c5c7fe6242319e8f4f994a1ca472fbed4ad (patch) | |
tree | 6779ed69ea263912560e9467dee8a0bfce26e51b | |
parent | ed157e4288d10cd5e42cce8afe4498bcefc15b6a (diff) | |
download | subsurface-3e1b3c5c7fe6242319e8f4f994a1ca472fbed4ad.tar.gz |
Make the cylinder 'delete' action actually delete the cylinder info
It used to just update the cylinder list widget data, not the actual
dive information.
It still needs an "accept or cancel" dialog, I suspect.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | equipment.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/equipment.c b/equipment.c index 7c70c6bf2..d237b1b32 100644 --- a/equipment.c +++ b/equipment.c @@ -524,10 +524,12 @@ static void add_cb(GtkButton *button, gpointer data) static void del_cb(GtkButton *button, gpointer data) { - int index; + int index, nr; GtkTreeIter iter; GtkListStore *model = cylinder_list.model; GtkTreeSelection *selection; + struct dive *dive; + cylinder_t *cyl; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cylinder_list.tree_view)); @@ -536,6 +538,13 @@ static void del_cb(GtkButton *button, gpointer data) return; gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CYL_INDEX, &index, -1); + + dive = current_dive; + if (!dive) + return; + cyl = dive->cylinder + index; + nr = cylinder_list.max_index - index - 1; + if (gtk_list_store_remove(model, &iter)) { do { gtk_list_store_set(model, &iter, CYL_INDEX, index, -1); @@ -544,6 +553,12 @@ static void del_cb(GtkButton *button, gpointer data) } cylinder_list.max_index--; + memmove(cyl, cyl+1, nr*sizeof(*cyl)); + memset(cyl+nr, 0, sizeof(*cyl)); + + mark_divelist_changed(TRUE); + flush_divelist(dive); + gtk_widget_set_sensitive(cylinder_list.edit, 0); gtk_widget_set_sensitive(cylinder_list.del, 0); gtk_widget_set_sensitive(cylinder_list.add, 1); |