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>
This commit is contained in:
Dirk Hohndel 2013-03-17 18:07:59 -07:00
parent bfa37c3cac
commit 8a5792d473
6 changed files with 91 additions and 5 deletions

12
dive.h
View file

@ -471,6 +471,7 @@ extern struct dive_table dive_table;
extern int selected_dive;
#define current_dive (get_dive(selected_dive))
#define current_dc (get_dive_dc(current_dive, dc_number))
static inline struct dive *get_gps_location(int nr, struct dive_table *table)
{
@ -486,6 +487,16 @@ static inline struct dive *get_dive(int nr)
return dive_table.dives[nr];
}
static inline struct divecomputer *get_dive_dc(struct dive *dive, int nr)
{
struct divecomputer *dc = NULL;
if (nr >= 0)
dc = &dive->dc;
while (nr-- > 0)
dc = dc->next;
return dc;
}
/*
* Iterate over each dive, with the first parameter being the index
* iterator variable, and the second one being the dive one.
@ -670,6 +681,7 @@ void add_duration_to_nth_dp(struct diveplan *diveplan, int idx, int duration, gb
void add_depth_to_nth_dp(struct diveplan *diveplan, int idx, int depth);
void add_gas_to_nth_dp(struct diveplan *diveplan, int idx, int o2, int he);
void free_dps(struct divedatapoint *dp);
void get_gas_string(int o2, int he, char *buf, int len);
#ifdef DEBUGFILE
extern char *debugfilename;