+ gtk_widget_set_sensitive(cylinder_list[w_idx].edit, 0);
+ gtk_widget_set_sensitive(cylinder_list[w_idx].del, 0);
+ gtk_widget_set_sensitive(cylinder_list[w_idx].add, 1);
+}
+
+static void ws_edit_cb(GtkButton *button, int w_idx)
+{
+ int index;
+ GtkTreeIter iter;
+ GtkListStore *model = weightsystem_list[w_idx].model;
+ GtkTreeView *tree_view = weightsystem_list[w_idx].tree_view;
+ GtkTreeSelection *selection;
+ weightsystem_t ws;
+
+ selection = gtk_tree_view_get_selection(tree_view);
+
+ /* Nothing selected? This shouldn't happen, since the button should be inactive */
+ if (!gtk_tree_selection_get_selected(selection, NULL, &iter))
+ return;
+
+ index = get_model_index(model, &iter);
+ if (!edit_weightsystem_dialog(index, &ws))
+ return;
+
+ set_one_weightsystem(&ws, model, &iter);
+ repaint_dive();
+}
+
+static void ws_add_cb(GtkButton *button, int w_idx)
+{
+ int index = weightsystem_list[w_idx].max_index;
+ GtkTreeIter iter;
+ GtkListStore *model = weightsystem_list[w_idx].model;
+ GtkTreeView *tree_view = weightsystem_list[w_idx].tree_view;
+ GtkTreeSelection *selection;
+ weightsystem_t ws;
+
+ if (!edit_weightsystem_dialog(index, &ws))
+ return;
+
+ gtk_list_store_append(model, &iter);
+ set_one_weightsystem(&ws, model, &iter);
+
+ selection = gtk_tree_view_get_selection(tree_view);
+ gtk_tree_selection_select_iter(selection, &iter);
+
+ weightsystem_list[w_idx].max_index++;
+ gtk_widget_set_sensitive(weightsystem_list[w_idx].add, weightsystem_list[w_idx].max_index < MAX_WEIGHTSYSTEMS);
+}
+
+static void ws_del_cb(GtkButton *button, int w_idx)
+{
+ int index, nr;
+ GtkTreeIter iter;
+ GtkListStore *model = weightsystem_list[w_idx].model;
+ GtkTreeView *tree_view = weightsystem_list[w_idx].tree_view;
+ GtkTreeSelection *selection;
+ struct dive *dive;
+ weightsystem_t *ws;
+
+ selection = gtk_tree_view_get_selection(tree_view);
+
+ /* Nothing selected? This shouldn't happen, since the button should be inactive */
+ if (!gtk_tree_selection_get_selected(selection, NULL, &iter))
+ return;
+
+ index = get_model_index(model, &iter);
+
+ dive = current_dive;
+ if (!dive)
+ return;
+ ws = dive->weightsystem + index;
+ nr = weightsystem_list[w_idx].max_index - index - 1;
+
+ gtk_list_store_remove(model, &iter);
+
+ weightsystem_list[w_idx].max_index--;
+ memmove(ws, ws+1, nr*sizeof(*ws));
+ memset(ws+nr, 0, sizeof(*ws));
+
+ mark_divelist_changed(TRUE);
+ flush_divelist(dive);
+
+ gtk_widget_set_sensitive(weightsystem_list[w_idx].edit, 0);
+ gtk_widget_set_sensitive(weightsystem_list[w_idx].del, 0);
+ gtk_widget_set_sensitive(weightsystem_list[w_idx].add, 1);