diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-03-17 18:07:59 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-03-17 20:04:25 -0700 |
commit | 8a5792d473bb30a6f5cbfd2168c4427c16436031 (patch) | |
tree | 58ec7fcb24aec27de5c7b4d2511478ed6550c1b1 /gtk-gui.c | |
parent | bfa37c3cac22949323bb6a5dfb23557638d20757 (diff) | |
download | subsurface-8a5792d473bb30a6f5cbfd2168c4427c16436031.tar.gz |
Manually add gas changes to a dive
Create a little widget that lists all the gases / tanks we know about and
allow the user to pick one of them.
Turns out that add_event only added events at the end of the list - but we
treat that list as chronologically sorted. So I fixed that little
mis-feature as well.
This does raise the question whether we need the inverse operation
(removing a gas change). And if there are other things that we should be
able to manually edit, now that we have the infrastructure for this neat
little context menu...
See #60 -- this doesn't address all of the issues mentioned there, but at
least deals with the 'headline' of the feature request...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r-- | gtk-gui.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -1962,7 +1962,16 @@ static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer static void add_gas_change_cb(GtkWidget *menuitem, gpointer data) { double *x = data; - printf("x = %d:%02u\n", FRACTION(x_to_time(*x), 60)); + int when = x_to_time(*x); + int cylnr = select_cylinder(current_dive, when); + if (cylnr >= 0) { + cylinder_t *cyl = ¤t_dive->cylinder[cylnr]; + int value = cyl->gasmix.o2.permille / 10 | ((cyl->gasmix.he.permille / 10) << 16); + add_event(current_dc, when, 25, 0, value, "gaschange"); + mark_divelist_changed(TRUE); + report_dives(FALSE, FALSE); + dive_list_update_dives(); + } } static void popup_profile_menu(GtkWidget *widget, GdkEventButton *event) |