mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add depth entry to new dive edit dialog
Christ, if you look up "Ugly dialog" on Wikipedia, I think it has a picture of this "New dive" thing. Or it should have. But it kind of works. Although with only a "max depth" entry, you can't currently set average depths etc, so SAC-rates etc cannot be calculated for these kinds of dives. And the dive numbering is wrong. We do auto-number new dives that get added at the end, but we do it as we add them, so when you *edit* the dive information (before it has been added) the dive number shows up as "#0". So there's certainly room for improvement here. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
e3bdfc2dc3
commit
a2c2c7e1a8
1 changed files with 25 additions and 1 deletions
26
info.c
26
info.c
|
@ -426,11 +426,12 @@ static time_t dive_time_widget(struct dive *dive)
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *cal, *hbox, *vbox;
|
GtkWidget *cal, *hbox, *vbox;
|
||||||
GtkWidget *h, *m;
|
GtkWidget *h, *m;
|
||||||
GtkWidget *duration;
|
GtkWidget *duration, *depth;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
guint yval, mval, dval;
|
guint yval, mval, dval;
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
int success;
|
int success;
|
||||||
|
double depthinterval, val;
|
||||||
|
|
||||||
dialog = gtk_dialog_new_with_buttons("Date and Time",
|
dialog = gtk_dialog_new_with_buttons("Date and Time",
|
||||||
GTK_WINDOW(main_window),
|
GTK_WINDOW(main_window),
|
||||||
|
@ -469,6 +470,22 @@ static time_t dive_time_widget(struct dive *dive)
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), duration, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(hbox), duration, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
/* Depth box */
|
||||||
|
hbox = gtk_hbox_new(0, 3);
|
||||||
|
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
|
||||||
|
|
||||||
|
if (output_units.length == FEET) {
|
||||||
|
depthinterval = 1.0;
|
||||||
|
} else {
|
||||||
|
depthinterval = 0.1;
|
||||||
|
}
|
||||||
|
depth = gtk_spin_button_new_with_range (0.0, 1000.0, depthinterval);
|
||||||
|
|
||||||
|
label = gtk_label_new("Depth: ");
|
||||||
|
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start(GTK_BOX(hbox), depth, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
/* All done, show it and wait for editing */
|
||||||
gtk_widget_show_all(dialog);
|
gtk_widget_show_all(dialog);
|
||||||
success = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
|
success = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
@ -485,6 +502,13 @@ static time_t dive_time_widget(struct dive *dive)
|
||||||
tm.tm_hour = gtk_spin_button_get_value(GTK_SPIN_BUTTON(h));
|
tm.tm_hour = gtk_spin_button_get_value(GTK_SPIN_BUTTON(h));
|
||||||
tm.tm_min = gtk_spin_button_get_value(GTK_SPIN_BUTTON(m));
|
tm.tm_min = gtk_spin_button_get_value(GTK_SPIN_BUTTON(m));
|
||||||
|
|
||||||
|
val = gtk_spin_button_get_value(GTK_SPIN_BUTTON(depth));
|
||||||
|
if (output_units.length == FEET) {
|
||||||
|
dive->maxdepth.mm = feet_to_mm(val);
|
||||||
|
} else {
|
||||||
|
dive->maxdepth.mm = val * 1000 + 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
dive->duration.seconds = gtk_spin_button_get_value(GTK_SPIN_BUTTON(duration))*60;
|
dive->duration.seconds = gtk_spin_button_get_value(GTK_SPIN_BUTTON(duration))*60;
|
||||||
|
|
||||||
gtk_widget_destroy(dialog);
|
gtk_widget_destroy(dialog);
|
||||||
|
|
Loading…
Add table
Reference in a new issue