summaryrefslogtreecommitdiffstats
path: root/divelist.c
diff options
context:
space:
mode:
Diffstat (limited to 'divelist.c')
-rw-r--r--divelist.c45
1 files changed, 37 insertions, 8 deletions
diff --git a/divelist.c b/divelist.c
index d8c760db9..e50039110 100644
--- a/divelist.c
+++ b/divelist.c
@@ -646,18 +646,18 @@ static int calculate_otu(struct dive *dive, struct divecomputer *dc)
for (i = 1; i < dc->samples; i++) {
int t;
- double po2;
+ int po2;
struct sample *sample = dc->sample + i;
struct sample *psample = sample - 1;
t = sample->time.seconds - psample->time.seconds;
if (sample->po2) {
- po2 = sample->po2 / 1000.0;
+ po2 = sample->po2;
} else {
int o2 = active_o2(dive, dc, sample->time);
- po2 = o2 / 1000.0 * depth_to_mbar(sample->depth.mm, dive) / 1000.0;
+ po2 = o2 / 1000.0 * depth_to_mbar(sample->depth.mm, dive);
}
- if (po2 >= 0.5)
- otu += pow(po2 - 0.5, 0.83) * t / 30.0;
+ if (po2 >= 500)
+ otu += pow((po2 - 500) / 1000.0, 0.83) * t / 30.0;
}
return otu + 0.5;
}
@@ -741,7 +741,7 @@ static void add_dive_to_deco(struct dive *dive)
for (j = t0; j < t1; j++) {
int depth = interpolate(psample->depth.mm, sample->depth.mm, j - t0, t1 - t0);
(void) add_segment(depth_to_mbar(depth, dive) / 1000.0,
- &dive->cylinder[sample->sensor].gasmix, 1, sample->po2 / 1000.0, dive);
+ &dive->cylinder[sample->sensor].gasmix, 1, sample->po2, dive);
}
}
}
@@ -802,7 +802,7 @@ double init_decompression(struct dive *dive)
if (pdive->when > lasttime) {
surface_time = pdive->when - lasttime;
lasttime = pdive->when + pdive->dc.duration.seconds;
- tissue_tolerance = add_segment(surface_pressure, &air, surface_time, 0.0, dive);
+ tissue_tolerance = add_segment(surface_pressure, &air, surface_time, 0, dive);
#if DECO_CALC_DEBUG & 2
printf("after surface intervall of %d:%02u\n", FRACTION(surface_time,60));
dump_tissues();
@@ -813,7 +813,7 @@ double init_decompression(struct dive *dive)
if (lasttime && dive->when > lasttime) {
surface_time = dive->when - lasttime;
surface_pressure = (dive->dc.surface_pressure.mbar ? dive->dc.surface_pressure.mbar : SURFACE_PRESSURE) / 1000;
- tissue_tolerance = add_segment(surface_pressure, &air, surface_time, 0.0, dive);
+ tissue_tolerance = add_segment(surface_pressure, &air, surface_time, 0, dive);
#if DECO_CALC_DEBUG & 2
printf("after surface intervall of %d:%02u\n", FRACTION(surface_time,60));
dump_tissues();
@@ -1621,6 +1621,31 @@ gboolean icon_click_cb(GtkWidget *w, GdkEventButton *event, gpointer data)
return FALSE;
}
+static void save_as_cb(GtkWidget *menuitem, struct dive *dive)
+{
+ GtkWidget *dialog;
+ char *filename = NULL;
+
+ dialog = gtk_file_chooser_dialog_new(_("Save File As"),
+ GTK_WINDOW(main_window),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+ }
+ gtk_widget_destroy(dialog);
+
+ if (filename){
+ set_filename(filename, TRUE);
+ save_dives_logic(filename, TRUE);
+ g_free(filename);
+ }
+}
+
static void expand_all_cb(GtkWidget *menuitem, GtkTreeView *tree_view)
{
gtk_tree_view_expand_all(tree_view);
@@ -2409,6 +2434,10 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int
deletelabel = _(deleteplurallabel);
editlabel = _(editplurallabel);
}
+ menuitem = gtk_menu_item_new_with_label(_("Save as"));
+ g_signal_connect(menuitem, "activate", G_CALLBACK(save_as_cb), dive);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+
menuitem = gtk_menu_item_new_with_label(deletelabel);
g_signal_connect(menuitem, "activate", G_CALLBACK(delete_selected_dives_cb), path);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);