diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-17 09:37:07 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-12-17 08:29:39 -1000 |
commit | d8fd8b2099a4c0ebbb642993333abdc670763301 (patch) | |
tree | ebd0f938abafa147995c19f9dd041b20d2e2197e /profile.c | |
parent | a691a8e5a35f2277d9a8c911696a4d0a394bb42e (diff) | |
download | subsurface-d8fd8b2099a4c0ebbb642993333abdc670763301.tar.gz |
Add a "View next dive computer" menu item
This adds the capability to actually view all your dive computers, by
adding a menu item under "Log"->"View"->"Next DC" to show the next dive
computer.
Realistically, if you actually commonly use this, you'd use the
accelerator shortcut. Which right now is Ctrl-C ("C for Computer"),
which is probably a horrible choice.
I really would want to have nice "next/prev dive" accelerators too,
because the cursor keys don't work very well with the gtk focus issues.
Being able to switch between dives would also make the "just the dive
profile, maam" view (ctrl-2) much more useful.
The prev/next dive in the profile view should probably be done with a
keyboard action callback, which also avoids some of the limitations of
accelerators (ie you can make any key do the action). Some gtk person,
please?
Anyway, this commit only does the dive computer choice thing, and only
using the accelerators.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r-- | profile.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -20,6 +20,7 @@ int selected_dive = 0; char zoomed_plot = 0; +char dc_number = 0; static double plot_scale = SCALE_SCREEN; static struct plot_data *last_pi_entry = NULL; @@ -1775,6 +1776,21 @@ static void plot_set_scale(scale_mode_t scale) } } +static struct divecomputer *select_dc(struct divecomputer *main) +{ + int i = dc_number; + struct divecomputer *dc = main; + + do { + if (--i < 0) + return dc; + } while ((dc = dc->next) != NULL); + + /* If we switched dives to one with fewer DC's, reset the dive computer counter */ + dc_number = 0; + return main; +} + void plot(struct graphics_context *gc, struct dive *dive, scale_mode_t scale) { struct plot_info *pi; @@ -1828,6 +1844,8 @@ void plot(struct graphics_context *gc, struct dive *dive, scale_mode_t scale) gc->maxx = (drawing_area->width - 2*drawing_area->x); gc->maxy = (drawing_area->height - 2*drawing_area->y); + dc = select_dc(dc); + /* This is per-dive-computer. Right now we just do the first one */ pi = create_plot_info(dive, dc, gc); |