First stab at plotting a pO2 graph

So far this is done unconditionally. This already starts some of the
infrastructure for other gases, but so far only O2 is handled.
We also need a pressure scale on the right to make this useful - or we
need to do peek / trough pressure prints like we do for temperature and
depth.

Finally, I think I want to move the plot further down, maybe make the
whole plot area taller if we are plotting partial gas pressures as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Change preferences into a notebook and add second page for tec settings

Not sure this is the best naming scheme (General Settings / Tec Settings)
but it's a start.

The idea is to have the settings that a recreational diver might care
about on the first page, and all the other stuff on the second one. Let's
see how this works out long term. For now I moved OTU over and added
toggles for the different partial pressure graphs (only the pO2 one is
implemented so far).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add vertical space to depth plot if we are showing partial pressure graphs

Fairly simplistic change that modifies the way we calculate the "maxdepth"
for a particular dive as that is used to scale the plot vertically.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix the pO2 calculation when diving with air

So few of my dives are on air that at first I didn't notice - but for
those dives we set the o2 permille to 0 - which of course causes incorrect
(and extremely deadly) pO2 of 0...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add pHe and pN2 plotting

Adjust the color for pN2 to the standard for this gas (black). We keep pO2
green (even though the ISO 32 color for that would be white). pHe is
marked in brown (which is the matching standard color).

Calculate correct partial pressures for the synthetic plot info points at
the beginning and end of the dive.

Minor fine tuning to the positioning / scaling of the temperature plot
when partial pressures are plotted.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Plot text values for partial pressure graphs

The algorithms attempt to identify "interesting" points where the user
might want to know the value of the graph.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Spanish translation fixes.

Signed-off-by: Pablo Garcia Castro <freixido@gmail.com
Signed-Off-By: Matthias Kaehlcke <matthias@kaehlcke.net>
Signed-off-by: Jose Angel Tortosa Delfa <angeltordel@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix broken MacOSX build

Dirk's commit 2de6f796354ad029e9e786027210fcf1b02868e2 had a typo.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Repair broken Add Dive menu item

Lubomir's commit aec904b612cbee57f8bb5c3289a120b69c9ade24 broke the Add
Dive menu item:  The Edit Dive dialogue didn't show up after the initial
dialogue.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Trim the device name in the download dialog, if necessary

On Windows, device names can end up being <drive-letter> (<drive-label>).
In such a case we are only interested in the <drive-letter> part, when
passing this value to libdivecomputer.

This patch provides a method to trim all text in parentheses and also
any leading and trailing whitespace.

An important addition is enabling back the user to enter a device
manually even it's absent in the combo box list. This device is
then stored and retrieved as the default device, but not stored
in the device list (dc_device_selector()).

As a side effect this change prevents the download dialog closing,
when a user-entered device is not one of the found devices via
subsurface_fill_device_list().

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Prevent UI errors while the the import thread is running

While the import thread is running it is possible to:
1) click the [x] button of the "download dialog".
To prevent that, we attach a "delete-event" signal to no-op function.

2) to interact with the main window, once the "accept" event is triggered.
To prevent that, we make sure that the window is set back to "modal".

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix incorrect variable reuse bug in preferences dialog

This was introduced in commit ee803ef5d85b "Change preferences into a
notebook and add second page for tec settings"

In order to be able to get the new default XML file name back from the
button, we need to keep that variable around and not overwrite it with
more buttons for the tec preferences page.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fine tune the vertical spacing of the graphs

Whatever I pick here, there will be dives where the different graphs end
up interfering with each other. I don't think there isn't an easy, generic
solution for this (but I can envision awesome non-easy solutions - they
just don't seem to be worth the effort).

But for most dives that I played with this seems to work pretty well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Be smarter about printing gas partial pressure text

We always want to print absolute maxima and minima - but not when multiple
consecutive data points all have the same value (this happens, for
example, when printing a pHe plot on non-helium dives - or when the dive
profile includes a brief surface intervall which causes all the partial
pressures to be at their minimum).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Don't print mean depth across the whole profile area

I can't remember why we initially did this instead of ending the
horizontal red line whith the last data point of the pressure profile. But
especially nuw with more graphs shown the one line that extends past the
end of the dive looked really silly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Remove pN2 debug printout and add disabled code for partial pressure scale

The pN2 print shouldn't have been committed, but I don't want to try and
rewrite all the commit history. Oh well.

The pressure scale I am ambivalent about. It seems that it should be
useful - but that would require guide lines that coincide with the values
which would really throw off the visual for me. So I added the code, but
left it disabled.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Merge branch 'po2'

Plotting pO2 / pN2 / PHe