return decimals;
}
-static int convert_volume_pressure(int ml, int mbar, double *v, double *p)
+static void convert_volume_pressure(int ml, int mbar, double *v, double *p)
{
- int decimals = 1;
double volume, pressure;
volume = ml / 1000.0;
if (output_units.pressure == PSI) {
pressure = mbar_to_PSI(mbar);
- decimals = 0;
} else
pressure = mbar / 1000.0;
}
*v = volume;
*p = pressure;
- return decimals;
}
static int convert_weight(int grams, double *m)
o2 = cyl->gasmix.o2.permille / 10.0;
he = cyl->gasmix.he.permille / 10.0;
if (!o2)
- o2 = 21.0;
+ o2 = AIR_PERMILLE / 10.0;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(cylinder->o2), o2);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(cylinder->he), he);
}
return !ws->weight.grams && !ws->description;
}
-static void set_one_cylinder(int index, void *_data, GtkListStore *model, GtkTreeIter *iter)
+static void set_one_cylinder(void *_data, GtkListStore *model, GtkTreeIter *iter)
{
cylinder_t *cyl = _data;
unsigned int start, end;
-1);
}
-static void set_one_weightsystem(int index, void *_data, GtkListStore *model, GtkTreeIter *iter)
+static void set_one_weightsystem(void *_data, GtkListStore *model, GtkTreeIter *iter)
{
weightsystem_t *ws = _data;
struct equipment_list *equipment_list,
void*(*ptr_function)(struct dive*, int),
int(*none_function)(void *),
- void(*set_one_function)(int, void*, GtkListStore*, GtkTreeIter *))
+ void(*set_one_function)(void*, GtkListStore*, GtkTreeIter *))
{
int i, used;
void *data;
for (i = 0; i < used; i++) {
data = ptr_function(dive, i);
gtk_list_store_append(model, &iter);
- set_one_function(i, data, model, &iter);
+ set_one_function(data, model, &iter);
}
}
{ "AL100", .cuft = 100, .psi = 3300 },
/* Somewhat common LP steel cylinders */
- { "LP85", .cuft = 85, 2640 },
- { "LP95", .cuft = 95, 2640 },
- { "LP108", .cuft = 108, 2640 },
- { "LP121", .cuft = 121, 2640 },
+ { "LP85", .cuft = 85, .psi = 2640 },
+ { "LP95", .cuft = 95, .psi = 2640 },
+ { "LP108", .cuft = 108, .psi = 2640 },
+ { "LP121", .cuft = 121, .psi = 2640 },
/* Somewhat common HP steel cylinders */
{ "HP65", .cuft = 65, .psi = 3442 },
GtkTreeIter iter;
struct tank_info *info = tank_info;
- while (info->name) {
+ for (info = tank_info ; info->name; info++) {
int ml = info->ml;
int cuft = info->cuft;
int psi = info->psi;
int mbar;
double bar = info->bar;
+ if (psi && bar)
+ goto bad_tank_info;
+ if (ml && cuft)
+ goto bad_tank_info;
+ if (cuft && !psi)
+ goto bad_tank_info;
+
/* Is it in cuft and psi? */
- if (psi) {
+ if (psi)
bar = psi_to_bar(psi);
- if (cuft) {
- double airvolume = cuft_to_l(cuft) * 1000.0;
- double atm = bar_to_atm(bar);
+ if (cuft) {
+ double airvolume = cuft_to_l(cuft) * 1000.0;
+ double atm = bar_to_atm(bar);
- ml = airvolume / atm + 0.5;
- }
+ ml = airvolume / atm + 0.5;
}
mbar = bar * 1000 + 0.5;
1, ml,
2, mbar,
-1);
- info++;
+ continue;
+
+bad_tank_info:
+ fprintf(stderr, "Bad tank info for '%s'\n", info->name);
}
}
if (!edit_cylinder_dialog(index, &cyl))
return;
- set_one_cylinder(index, &cyl, model, &iter);
+ set_one_cylinder(&cyl, model, &iter);
repaint_dive();
}
return;
gtk_list_store_append(model, &iter);
- set_one_cylinder(index, &cyl, model, &iter);
+ set_one_cylinder(&cyl, model, &iter);
selection = gtk_tree_view_get_selection(tree_view);
gtk_tree_selection_select_iter(selection, &iter);
if (!edit_weightsystem_dialog(index, &ws))
return;
- set_one_weightsystem(index, &ws, model, &iter);
+ set_one_weightsystem(&ws, model, &iter);
repaint_dive();
}
return;
gtk_list_store_append(model, &iter);
- set_one_weightsystem(index, &ws, model, &iter);
+ set_one_weightsystem(&ws, model, &iter);
selection = gtk_tree_view_get_selection(tree_view);
gtk_tree_selection_select_iter(selection, &iter);
edit_cb(NULL, tree_view);
}
+static void ws_row_activated_cb(GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ GtkTreeModel *model)
+{
+ ws_edit_cb(NULL, tree_view);
+}
+
GtkWidget *cylinder_list_widget(void)
{
GtkListStore *model = cylinder_list.model;
tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
gtk_widget_set_can_focus(tree_view, FALSE);
- g_signal_connect(tree_view, "row-activated", G_CALLBACK(row_activated_cb), model);
+ g_signal_connect(tree_view, "row-activated", G_CALLBACK(ws_row_activated_cb), model);
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE);