Commit graph

1294 commits

Author SHA1 Message Date
Linus Torvalds
d8fd8b2099 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>
2012-12-17 08:29:39 -10:00
Dirk Hohndel
a691a8e5a3 Improve visual appearance of horizontal marker lines
This changes two things to improve the appearance of the profile:
- the partial pressure scale is now in 0.5 increments if the total is <= 4
  and in 1.0 increments if it is > 4.
- the depth marker lines end slightly below the depth chart so that we no
  longer have overlap between the depth scale and the partial pressure
  scale.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16 22:05:11 -10:00
Lubomir I. Ivanov
33ae98c96f Attempt to free plot data entries in each call to create_plot_info()
In profile.c:create_plot_info(), store the last address in which
memory was allocated for the plot data entries in the static
variable "last_pi_entry". If "last_pi_entry" isn't a NULL
pointer in each call to create_plot_info(), free memory at that
address.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16 16:00:09 -10:00
Lubomir I. Ivanov
5c65ed2390 Clear associated tooltip texts when calling expose_event()
In gtk-gui.c:expose_event(), right before clearing the list of tooltips,
we also want to free memory for the associated texts for each one of them.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16 15:57:25 -10:00
Lubomir I. Ivanov
5c58e1f868 Fixed some memory leaks related to subsurface_get_conf()
In gtk-gui.c:init() we retrieve the configuration values
for PO2, PN2, PHE thresholds but have to also free the values
once done parsing with sscanf().

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16 15:57:11 -10:00
Lubomir I. Ivanov
28cc67c9a1 Fixed a couple of memory leaks related to the download dialog
In render_dc_vendor() and render_dc_product(), there is
no need to allocate memory for the texts that are about to
be added in the combo box trees. Most GTK widgets seem to make
copies of the passed text to them, using g_strdup() and
automatically release said memory when a widget is destroyed.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16 15:56:58 -10:00
Linus Torvalds
7b457d1b5c Properly remove redundant dive computer information
We had logic to remove duplicate dive computer information after merging
dives, but it didn't actually work.

Why? Because we had used the 'res' dive computer pointer to traverse the
list of dive computers, so it no longer actually pointed to the first
dive computer in the result list any more, and so the "remove redundant"
code only removed redundant dive computers from a limited and incomplete
list.

Oops.

Also, before checking the whole event and sample list, check if it's the
exact same dive computer using our new "match_one_dc()" helper function,
and don't even bother checking for sample details if it is.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16 15:48:32 -10:00
Linus Torvalds
459696c90c Use dive ID for matching dives during downloads
If we have a dive computer model and dive ID, use that to match newly
downloaded dives against the existing dives.

Otherwise fall back to "exact date match" again, like we've always done.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16 15:48:09 -10:00
Linus Torvalds
73defa9a52 Use dive computer model/ID when trying to merge dives
If we havd divecomputer model and dive ID information available, use
that to match existing dives when trying to merge them.

Otherwise fall back to the fuzzy time-based merging logic.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16 15:46:54 -10:00
Lubomir I. Ivanov
92c15238b6 Make sure that the user entered nickname is never truncated
If the sizes of the two char buffers in set_dc_nickname() (nickname)
and remember_dc() (buffer) are at least twice the size of the allowed
maximum number of characters (sizeof(gunichar) = 2) set by
gtk_entry_set_max_length() for the user nickname,
no truncation will accur then calling snprintf() and cleanedup_nickname()
on said buffers.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16 07:45:08 -10:00
Dirk Hohndel
2f9960f20b Deal with some trip issues when editing dive timestamps
The idea behind editing timestamps had of course been the typical "oops, I
forgot to set my time correctly" which shifts a dive (or a few of them) by
a few hours but keeps the overall order of dives the same).

But reasonable people might argue that they can envision a scenario where
more dramatic changes are being made. And we need to deal with the impact
this has on dive trips.

Here we handle a couple of simple cases:
- this is the only dive in a trip; just update the trip
  (this can still cause problems if the new time is in the middle of an
  existing trip).
- this dives moves before the start of the trip it is in; let's remove it
  from that trip (this response is a bit simplistic - but as I tried to
  say, I don't expect this to be a common use case; and removing it at
  least doesn't lead to entirely unexpected behavior).
- this dive moves past the end of this trip into the range of a different
  trip (in this case we remove the dive from the current trip and allow it
  to interrupt the trip it is moving into).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-15 21:01:29 -10:00
Lubomir I. Ivanov
be9d924cf8 Reserve enough memory when storing a DC's nickname
in gtk-gui.c:
The input text field in set_dc_nickname() has a limit of 68 unicode
characters, which are 136 bytes. In remember_dc(), to make sure
that this nickname, the deviceid (4 bytes) and also the extra
characters (",{}") always fit wihout truncation (from snprintf) in the
allocated stack buffer, we increase the size of the buffer to 256 bytes.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-15 19:53:07 -10:00
Dirk Hohndel
371ace39b5 Fix possible crash in nickname code
Silly typo, but this is the better solution, anyway.

Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>`
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-14 07:34:14 -10:00
Dirk Hohndel
713a4fcff6 Add the ability to set a nickname for a dive computer
We maintain a list of dive computers that we know about (by deviceid) and
their nicknames in our config. If the user downloads dive from a dive
computer that we haven't seen before, we give them the option to set a
nickname for that dive computer. That nickname is displayed in the profile
(and stored in the XML file, assuming it is not the same as the model).

This implementation attempts to make sure that it correctly deals with
utf8 nicknames.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-13 21:33:30 -10:00
Dirk Hohndel
aba65736eb Change the empty product model to be index 0
A vendor of -1 indicates that we should have no product selection in the
dive download dialog. Having the empty product model be the last made it
hard to keep the correct index for that empty model around (and we got it
wrong by default).

With this change the product models are offset by one, so the unset vendor
(-1) turns into index 0 which is where we now store the empty model.

Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-12 07:25:28 -08:00
Dirk Hohndel
597a3677e9 Ensure default dive computer strings can be freed
We don't want to directly use the strings returned to us from
libdivecomputer.

Fixes bug 34

Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-12 07:24:07 -08:00
Dirk Hohndel
969ab7f121 Add crypto library to Windows installer file
This dependency was brought in by commit 3e51d56f87a3 "Improve on
divecomputer data handling".

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-11 16:04:17 -08:00
Dirk Hohndel
0b69bd474d Only display a depth scale appropriate for the depth of the dive
Showing the depth scale all the way to the bottom of the profile plot
looks strange when there are partial pressure graphs down there. So
instead we only plot down to the next marker below the maximum depth of
the actual dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-11 15:58:37 -08:00
Dirk Hohndel
c26fa209e3 Show CNS value in the profile mouseover
If we have per-sample CNS values, then show them in the profile tooltip.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-11 13:40:49 -08:00
Dirk Hohndel
f0e471e0da Correctly merge cns, ndl and deco information
I keep forgetting to do that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-11 13:40:40 -08:00
Dirk Hohndel
afda6dac51 Fix minor indentation issue
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-11 13:40:07 -08:00
Dirk Hohndel
91577f11b5 Merge branch 'cns' into cns-merge
I foolishly changed visible_columns in both the (ill-named) cns branch and
master...

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

Conflicts:
	divelist.c
	gtk-gui.c
	profile.c
2012-12-11 13:09:48 -08:00
Dirk Hohndel
563af1daa7 Update to the new deco / ndl code in libdivecomputer
Early in the libdivecomputer 0.3 development cycle Jef and I implemented
deco and ndl as events. That wasn't a wise design choice and we agreed to
switch this to be instead new sample types which makes much more sense
(and is much more aligned with the way we are handling them inside
Subsurface). So this commit tracks the change in libdivecomputer. Since
this happened during the development cycle there isn't a way to detect
this at compile time - so you need to make sure you have a matching
version of libdivecomputer when compiling Subsurface.

To make this easier: this commit of Subsurface requires a libdivecomputer
version that includes the libdivecomputer commit d5d44c1e0ffd "Convert
decostop / ndl to samples".

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-11 13:05:08 -08:00
Linus Torvalds
c6ca263fb0 Calculate dive maxima/minima independent of dive computer
This splits the dive time, depth, pressure and temperature maxima and
minima setup from the per-dive-computer "create_plot_info()" function
into one setup function that walks _all_ the dive computers, so that we
have a global maxima and minima.

That way the graph scaling we set up will now fit the data from all dive
computers rather than just the particular one we are plotting.  So if
you switch back-and-forth between computers, the scale (which is defined
by the extremes) remains the same.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-11 11:04:18 -08:00
Dirk Hohndel
39f80a1e0f Display maximum CNS in the divelist
We either pick the CNS reported by the dive computer at the end of the
dive, or the maximum of that and the CNS values in the samples, if any.

As usual, this column in the dive list defaults to off and it is
controlled by a setting in the tec page of the preferences.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-10 21:18:48 -08:00
Dirk Hohndel
febcbd6325 Add the ability to edit the date/time of a dive
This can cause some fun unintended side effects - especially when the dive
is part of a trip and the new date/time moves this into a different trip.
Instead, trips get split and the overall result is consistent, but a bit
unexpected.

But since this is designed to help people right after a dive import in
case the clock on the dive computer was wrong, my guess is this won't ever
be a problem for actual users.

Fixes ticket 18

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-10 13:23:55 -08:00
Dirk Hohndel
286020a2d1 Fix incorrect index for dive computer list
I don't understand how this ever worked...

Fixes ticket 32

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-10 11:11:18 -08:00
Dirk Hohndel
0ae16899de Don't draw tooltips if no profile is displayed
This fixes ticket 33

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-10 11:02:33 -08:00
Dirk Hohndel
7cf1960336 Apply preference changes right away
This allows you to open the preference dialog, play with settings and see
their effect right away. Press OK and you keep them, press Cancel and you
are back to the previous state. As it should be.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-10 10:52:25 -08:00
Dirk Hohndel
92c0d8c516 Move global variables covered by Preferences into one structure
Now we can simply remember the state of all the preferences at the
beginning of preferences_dialog() and restore them if the user presses
'Cancel'.

Fixes #21

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-10 10:26:06 -08:00
Dirk Hohndel
54919c1c4e Rename on_delete function in statistics.c
We made the one in gtk-gui.c a global function and now had a clash with
the static one in statistics.c

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-09 16:16:35 -08:00
Salvador Cuñat
f9f1a5fe6b Add tank data to the print.
Add info of the used tanks, which isn't displayed by the
dive plot, with a new function.
The relative width and height are fixed in print(), so the function needs:
 - Modify the font size depending on the number of tanks.
 - As it uses translations, return to the original coords when ends.

Modify print() acordingly with the new function.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-09 16:14:51 -08:00
Salvador Cuñat
e1c8394d3e Separate show_dive_text() in two diferent functions.
Create a function show_dive_header() and show_dive_notes() as a first step
to introduce other infos in diferent funcs.

Modify print() acordingly to the new funcs.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-09 16:13:48 -08:00
Dirk Hohndel
c9a03db480 Consistent Quit behavior on the Mac
We were responding to the wrong Quit signal on MacOS. The one we picked
was the one that basically told us "it's too late to stop me, I'm
quitting". I switched this to the one asking "should I prevent the app
from quitting" and now we can indeed cancel the Quit, regardless which
method was used to close the app.

Also removes to unused variables.

Fixes #22

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-09 15:23:33 -08:00
Dirk Hohndel
9463e7895b Don't print partial pressure values in the profile
Instead provide a scale on the right in a highly transparent grey and rely
on the tooltip available with mouse-over to pinpoint the value at certain
spots with much better accuracy.

Fixes #30

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-09 14:36:56 -08:00
Dirk Hohndel
8dfc4dccc5 Don't print an initial gaschange event that just tells us the gas used
Some dive computers appear to tell us the gas used in a gaschange event
right at the beginning of the dive. We arbitrary have a cut-off that says
"a gas change in the first 30 seconds shouldn't get a marker".

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-08 21:23:45 -08:00
Dirk Hohndel
07b74007f1 Correct partial pressure calculations
Regardless what the dive computer tells us, don't believe that pO2 was
higher than the ambient pressure. This gives much more realistic values.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-08 21:23:45 -08:00
Dirk Hohndel
02844c3a10 Correctly parse the two different gas change events
This now takes the He percentage into account when matching tanks. Given
the encoding of fO2 and fHe in the GASCHANGE2 event, we can simply mask
and shift as if we have a GASCHANGE2 event and things will automatically
work correctly for the regular GASCHANGE event.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-08 21:23:27 -08:00
Dirk Hohndel
9bcd21bf67 Draw pO2 profile last
This way it sits on top of the other partial pressure plots and is a bit
easier to read.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-08 14:07:10 -08:00
Dirk Hohndel
ef3735eafb Make sure pO2 and cns are filled in all samples
This allows things to work for dive computers like the OSTC that give us
setpoint information in the sample, but not constant pO2 readings.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-08 14:02:31 -08:00
Dirk Hohndel
8185159566 Make changes to some of the preference immediately visible
This is just a small part of the solution to the bigger problem with the
preferences.

See ticket 21

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-08 13:58:27 -08:00
Dirk Hohndel
40d05ed768 Show two decimal digits in pO2, pN2 and pHe in the tooltip
Tec divers seem to like a little bit more precision - and the dive
computers certainly provide it (or we can calculate it).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-08 13:58:14 -08:00
Dirk Hohndel
3b425b4c13 Plot pO2 graph based on sample information, if available
This should give closed circuit divers with a supported dive computer
correct partial pressure plots.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07 21:05:21 -08:00
Dirk Hohndel
9d80e7bfe4 Add CNS and pO2 tracking in the samples
This adds the new members to the sample structure and fills them from
supported dive computers (Uemis SDA and OSTC / Shearwater Predator,
assuming you have libdivecomputer 0.3).

Save relvant values of this to the XML file and load it back. Handle the
new fields when merging dives.

At this stage we don't DO anything with this, all we do is extract them
from the dive computer, save them to the XML file and load them back.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07 21:03:39 -08:00
Dirk Hohndel
a72597189d Initialize helper structure to 0s
We check the pointers that are part of this structure for NULL before
accessing them - but that means we need to zero out the structure for this
to work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07 20:06:07 -08:00
Dirk Hohndel
dad93c425e Fix potential uninitialized read
When analyzing the buffer that is handed to the first_object_id function
we carefully check to make sure that we don't read past the end of the
input buffer but there was still one code path that could have us do just
that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07 20:02:14 -08:00
Dirk Hohndel
0fcdd011f5 Fix off by one error
We increment i twice - which causes us to access memory past the end of
the allocated array.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07 20:01:05 -08:00
Dirk Hohndel
407d4dd4aa Fix embarrassing cut and paste bugs
The previous commit 871d7ae0cdf5 "Add option to make ceiling visually
stand out more in the profile" contained not one but two stupid cut and
paste bugs. I cannot begin to explain how this could have worked when I
first tested it.

Reported-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07 12:55:11 -08:00
Dirk Hohndel
a0f28aa422 Add option to make ceiling visually stand out more in the profile
While having the background "come down" seemed like a good visualization
of the ceiling, some divers appear to prefer something more dramatic. This
adds an option to the Tec Settings to have the ceiling shown in red
instead of the default background color.

Suggested-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07 11:39:15 -08:00
Dirk Hohndel
982abb5596 Move partial pressure plots up slightly
This way they don't clash with the dive computer model information that
was added by commit a23ec27ca7bb "Add dive computer name to the dive
plot".

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07 10:49:02 -08:00