Remember the last weight used per weightsystem
With this change, if the user adds a new weightsystem to a dive, on subsequent edits the weight amount for this weightsystem no longer defaults to 0 but to the last weight that was used with this weightsystem. So when the program imports a set of dives from the divecomputer and the user starts editing them, once they enter the weight for the "integrated" weightsystem the first time, for each of the consecutive dives that same weight is the default once "integrated" is selected - which usually will be the correct amount. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
18
equipment.c
18
equipment.c
@@ -308,13 +308,15 @@ static GtkTreeIter *add_weightsystem_type(const char *desc, int weight, GtkTreeI
|
|||||||
model = GTK_TREE_MODEL(weightsystem_model);
|
model = GTK_TREE_MODEL(weightsystem_model);
|
||||||
gtk_tree_model_foreach(model, match_desc, (void *)desc);
|
gtk_tree_model_foreach(model, match_desc, (void *)desc);
|
||||||
|
|
||||||
if (!found_match) {
|
if (found_match) {
|
||||||
GtkListStore *store = GTK_LIST_STORE(model);
|
gtk_list_store_set(GTK_LIST_STORE(model), found_match,
|
||||||
|
WS_WEIGHT, weight,
|
||||||
gtk_list_store_append(store, iter);
|
-1);
|
||||||
gtk_list_store_set(store, iter,
|
} else {
|
||||||
0, desc,
|
gtk_list_store_append(GTK_LIST_STORE(model), iter);
|
||||||
1, weight,
|
gtk_list_store_set(GTK_LIST_STORE(model), iter,
|
||||||
|
WS_DESC, desc,
|
||||||
|
WS_WEIGHT, weight,
|
||||||
-1);
|
-1);
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
@@ -623,6 +625,7 @@ static void record_weightsystem_changes(weightsystem_t *ws, struct ws_widget *we
|
|||||||
GtkComboBox *box;
|
GtkComboBox *box;
|
||||||
int grams;
|
int grams;
|
||||||
double value;
|
double value;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
|
||||||
/* Ignore uninitialized cylinder widgets */
|
/* Ignore uninitialized cylinder widgets */
|
||||||
box = weightsystem_widget->description;
|
box = weightsystem_widget->description;
|
||||||
@@ -638,6 +641,7 @@ static void record_weightsystem_changes(weightsystem_t *ws, struct ws_widget *we
|
|||||||
grams = value * 1000;
|
grams = value * 1000;
|
||||||
ws->weight.grams = grams;
|
ws->weight.grams = grams;
|
||||||
ws->description = desc;
|
ws->description = desc;
|
||||||
|
add_weightsystem_type(desc, grams, &iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user