Make all the normal widgets uneditable and non-focusing

We always keep the focus on the dive list, so that the random gtk focus
handling doesn't suddenly randomly make us edit the combo boxes when the
cursor up/down keys start changing them instead of the dive list.

This means that dive location, notes and buddy/divemaster aren't
editable at all any more, but I'll fix that by making a separate dive
edit popup window.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Make double-clicking on the dive list bring up the dive editor

Now that the dive info window is read-only, we need to edit the dives
some other way.  We bring up a dive info edit dialog when you
double-click on the dive list entry for that dive.

I do want to have an "edit" button or keyboard shortcut or something
too, though.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Add an 'edit' menu item to the dive info text fields

It just pops up the dive info edit box.  This way you can be in the dive
info tab, and not have to go to the dive list just to double-click on
the dive.

This thing still needs some polish, but it's now usable.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Add dive number and date to the dive info edit dialog

It's pretty basic information, and might be hidden behind the dialog
especially on a small screen.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Add the cylinder list to the dive info edit dialog

This way, when you have a new dive that you just imported from your dive
computer, you can just double-click on the dive and fill out all the
relevant information: location, notes, buddies and cylinder info.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Remove redundant linear sample tank pressure data

I've seen at least DivingLog do this. If you manually enter beginning and
end pressure for a tank it will either linearize the samples in between or
offer to simulate a dive (with constant SAC rate). At least the first case
is reasonably easy to detect. We throw out those samples and ensure that
we still have valid beginning and end pressure for that dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Be more consistent in our handling of rgb value tables

Use rgb_t for the sac colors, create a new set_source_rgb_struct function
and use that for the velocity values (in the depth plot) as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Improve tank pressure sac coloring

This changes the algorithm that picks the sac color to consider
+/- 1 l/min to be the same color (before the color changed every
time you crossed above or below the average which looked silly with
our synthetic "constant sac" values as those are discrete and oscilate
around the average.

This also changes the order in which things are drawn so so that the
pressure plot goes over the depth profile plot (so the red shading of the
dive no longer changes the color of the tank pressure plot).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Make pressure plot shading by sac rate consistent

Some parts of the existing code used the depth at the time of the sample
to calculate the sac rate - it makes much more sense to use the average
depth. But that requires us to loop over the entries and average the
individual sac rates per segment instead of just using the beginning and
end depth of the multi-segment interval we use for smoothing purposes.

This may seem like a subtle detail, but it does in fact matter when we
plot the synthetic tank pressure values that we create when we have no
tank pressure data in the samples.

Another detail we change here is to not artificially start with a forward
looking segment of the full SAC_WINDOW but instead just start with the
first two data points and then simply let the time window grow until it
hits SAC_WINDOW - at which point it becomes a sliding window.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Merge remote-tracking branch 'upstream/master'
Merge branch 'sacplot' of git://git.hohndel.org/subsurface

* 'sacplot' of git://git.hohndel.org/subsurface:
  Make pressure plot shading by sac rate consistent
  Improve tank pressure sac coloring
  Be more consistent in our handling of rgb value tables
  Remove redundant linear sample tank pressure data
Correctly plot the tank end pressure if it was set manually

While printing the last pressure in the calculated sequence may seem more
logical, given that the discrete series will create some amount of error
this simply looks wrong. Instead we pick the end pressure that was
manually set.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Experimental hard-coded three-pane layout

I'm not happy with it, but it looks good and works better than the
alternatives I've looked at so far.

So why not happy? It's not configurable, and gtk really doesn't do a
great job with the case of notebook widgets that are shrunk to be
smaller than the contents (the cut-off gets ugly, and is outside the
notebook page!)

But committing as a way to keep track of this, and let Dirk use it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Merge branch 'sacplot' of git://git.hohndel.org/subsurface

* 'sacplot' of git://git.hohndel.org/subsurface:
  Correctly plot the tank end pressure if it was set manually
Fix the Makefile '-c' location, add XML2CFLAGS

I was getting the following error:

   dive.h:8:25: fatal error: libxml/tree.h: No such file or directory
   compilation terminated.

So I updated the Makefile to fix that error and follow the standard in
the file.

Signed-off-by: Terrance Stanfield <t@hollowcranium.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Fix error when gaschange event is one second before next sample

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Merge branch 'sacplot' of git://git.hohndel.org/subsurface

* 'sacplot' of git://git.hohndel.org/subsurface:
  Fix error when gaschange event is one second before next sample
Revert "Correctly plot the tank end pressure if it was set manually"

This reverts commit abdee5b1b8a97c641bca9bc2ebac9555c3e2ea54.

There's no point in doing random hacks.  Instead, do the intermediate
pressure calculations with proper rounding instead of always truncating
to mbar.  With the math done correctly we have enough precision that the
end result of the pressure interpolation doesn't have the kind of errors
that caused Dirk to try to fix things up later.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Do proper rounding in interpolated pressure calculations

We do all the pressures in mbar, which has plenty of precision for
interpolated pressures - even when we then do our discrete integration
over many samples.

However, when we calculate those interpolated pressure points, we should
make sure that we round the result correctly, otherwise the consistent
rounding errors (from truncating the FP value into our integer mbar
values) will result in a final pressure that is noticeably off in ugly
ways (ie "end pressure set by hand to 750 mbar, but shown as 748").

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Merge branch 'multi-pane'

* multi-pane:
  Experimental hard-coded three-pane layout

Ok, so it's not perfect, but I've been using a version of this for the
last week or so by now, and every time I go back to the old layout I
just cringe.

So the three-pane window approach requires much more display area, and
probably wouldn't work wonderfully on low-resolution devices (ie 720x480
or even 1024x600).  So for anybody doing a cellphone port, you may need
to play around with the interface.  But this should be usable even on a
netbook, although not as good as on a device with more pixels.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>