]> git.tdb.fi Git - ext/subsurface.git/log
ext/subsurface.git
11 years agoFix profile and average depth for freedives master
Mikko Rasa [Wed, 29 Aug 2012 16:10:26 +0000 (19:10 +0300)]
Fix profile and average depth for freedives

Freedives can easily exceed the assumed ascent/descent rate, which
results in wacky dive profiles.  Add a check to make the ascent and
descent fit within the duration of the dive.

11 years agoMerge branch 'freediving-tweaks' of git://github.com/mguentner/subsurface
Linus Torvalds [Tue, 28 Aug 2012 20:20:23 +0000 (13:20 -0700)]
Merge branch 'freediving-tweaks' of git://github.com/mguentner/subsurface

Merge freediving tweaks (zoom in on short dives etc) from Maximilian
Güntner.

Trivial conflicts in display.h due to unrelated printing stuff just
happening to be added nearby.

* 'freediving-tweaks' of git://github.com/mguentner/subsurface:
  moved zoomed_plot to display.h
  plot the time with a fixed padding (leading zero)
  updated/corrected comment
  added "Zoom" button and improved scaling
  fixed indentation
  use increments that make sense for 600 seconds
  Plot shorter (apnea) dives with a reasonable scale

11 years agoMerge git://git.tdb.fi/ext/subsurface
Linus Torvalds [Tue, 28 Aug 2012 20:16:57 +0000 (13:16 -0700)]
Merge git://git.tdb.fi/ext/subsurface

Pull a few buglet fixes from Mikko Rasa.

Some trivial conflicts due to changes in the dive selection logic, and
using the new "for_each_dive()" helper.

* git://git.tdb.fi/ext/subsurface:
  Check if multi-dive editing is actually needed
  Fix an off-by-one error in buffer allocation

11 years agoWork on the printing of the dives, first attempt to print as table.
Pierre-Yves Chibon [Tue, 28 Aug 2012 13:50:00 +0000 (15:50 +0200)]
Work on the printing of the dives, first attempt to print as table.

With this commit, the user can choose between two printing modes:
- pretty print (with or without the dive profile)
- table print (which is nothing less than a table formating containing the
information)

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
11 years agoRemove include not present in new libdivecomputer.
Pierre-Yves Chibon [Tue, 28 Aug 2012 09:27:04 +0000 (11:27 +0200)]
Remove include not present in new libdivecomputer.

The include of libdivecomputer/utils.h breaks the compilation
of subsurface as it is no longer present in the latest version
of libdivecomputer.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
11 years agomake the font size the same when printing on win32/linux
Lubomir I. Ivanov [Mon, 27 Aug 2012 22:37:56 +0000 (01:37 +0300)]
make the font size the same when printing on win32/linux

Setting the cairo transformation units (..?) to GTK_UNIT_POINTS makes
the font size the same on windows as on linux, when printing.  Otherwise
the text is unreadable ie way too small.

It now looks like
    http://i47.tinypic.com/154ks2d.png

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoMerge branch 'trips' of git://git.hohndel.org/subsurface
Linus Torvalds [Mon, 27 Aug 2012 22:36:27 +0000 (15:36 -0700)]
Merge branch 'trips' of git://git.hohndel.org/subsurface

Merge the initial 'track trips explicitly' code from Dirk Hohndel.

Fix up trivial conflicts in save-xml.c due to the new 'is_attribute'
flag.

* 'trips' of git://git.hohndel.org/subsurface:
  Fix an issue with trips that have dives from multiple input files
  Some simple test dives for the trips code
  First cut of explicit trip tracking

11 years agoFix an issue with trips that have dives from multiple input files
Dirk Hohndel [Mon, 27 Aug 2012 22:29:40 +0000 (15:29 -0700)]
Fix an issue with trips that have dives from multiple input files

The existing code didn't handle the case of different trips for the same
date coming from different sources. It also got confused if the first dive
processed (which is, chronologically, the last dive) happened to be a
"NOTRIP" dive.

This commit adds a bit of debugging infrastructure for the trip handling,
too.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoUpdate for new libdivecomputer interfaces
Linus Torvalds [Mon, 27 Aug 2012 22:06:58 +0000 (15:06 -0700)]
Update for new libdivecomputer interfaces

For this you need to get the current libdivecomputer tree, reconfigure,
build and install it first.  But this cleans up some of the silly error
handling too, and has just a single "dc_device_close()" call etc, rather
than duplicating that (and the new dc_context_free()).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoSome simple test dives for the trips code
Dirk Hohndel [Mon, 27 Aug 2012 21:34:21 +0000 (14:34 -0700)]
Some simple test dives for the trips code

Playing with these shows that there are still some issues with handling
multiple files correctly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoFirst cut of explicit trip tracking
Dirk Hohndel [Wed, 22 Aug 2012 05:04:24 +0000 (22:04 -0700)]
First cut of explicit trip tracking

This code establishes the explicit trip data structures and loads and
saves them in the XML data. No attempts are made to edit / modify the
trips, yet.

Loading XML files without trip data creates the trips based on timing as
before. Saving out the same, unmodified data will create 'trip' entries in
the XML file with a 'number' that reflects the number of dives in that
trip. The trip tag also stores the beginning time of the first dive in the
trip and the location of the trip (which we display in the summary entries
in the UI).

The logic allows for dives that aren't part of a dive trip. All other
dives simply belong to the "previous" dive trip - i.e. the dive trip with
the latest start time that is earlier or equal to the start time of this
dive.

This logic significantly simplifies the tracking of trips compared to
other approaches that I have tried.

The automatic grouping into trips now is an option that defaults to off
(as it makes changes to the XML file - and people who don't want this
feature shouldn't have trips added to their XML files that they then need
to manually remove).

For now you have to select this option, then exit the program and start it
again. Still to do is to trigger the trip generation at run time.

We also need a way to mark dives as not part of trips and to allow options
to combine trips, split trips, edit trip location data, etc.

The code has only had some limited testing when opening multiple files.

The code is known to fail if a location name contains unquoted special
characters like an "'".

This commit also fixes a visual inconsistency in the preferences dialog
where the font selector button didn't have a frame around it that told you
what this option was about.

Inspired-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoOnly quote the quote characters in xml attributes
Linus Torvalds [Mon, 27 Aug 2012 20:19:06 +0000 (13:19 -0700)]
Only quote the quote characters in xml attributes

The quoting of single and double quotes is only necessary for
attributes, and is irritating for other fields in that it makes the
fields almost unreadable in the xml file.  Single quotes in particular
are common, and turning "it's" into "it&apos;s" is just not reasonable
for dive notes etc.

So add a flag to whether the xml quoting is for an attribute or not, and
take that into account.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoMerge branch 'quoting' of git://git.hohndel.org/subsurface
Linus Torvalds [Mon, 27 Aug 2012 20:07:47 +0000 (13:07 -0700)]
Merge branch 'quoting' of git://git.hohndel.org/subsurface

Pull xml quoting fix from Dirk Hohndel.

* 'quoting' of git://git.hohndel.org/subsurface:
  Add single and double quotes to escaped characters in XML output

11 years agoAdd single and double quotes to escaped characters in XML output
Dirk Hohndel [Mon, 27 Aug 2012 16:38:23 +0000 (09:38 -0700)]
Add single and double quotes to escaped characters in XML output

We already escape '<', '>', and '&'. This adds the remaining two special
entities in XML: '\'' and '\"'.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoStart re-working the print UI to allow printing tables with no profiles.
Pierre-Yves Chibon [Mon, 27 Aug 2012 15:01:00 +0000 (17:01 +0200)]
Start re-working the print UI to allow printing tables with no profiles.

With this commit we add a checkbox in the "Dive details" tab of the print
window. This checkbox allows to print the dives profile or not.

If you don't print the dives profile, you get 15 dives on the page (instead
of 6 with the profiles).

Future work should include:
- Ability to choose what is printed
- Table layout vs the current one (if no dives profile)
- Ability to choose the number of dives per page (play with the font size for this)

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
11 years agoMight as well free current_file
Dirk Hohndel [Sun, 26 Aug 2012 22:35:48 +0000 (15:35 -0700)]
Might as well free current_file

In commit fd2debc1e730 ("replaced stdndup() with the inlined equivalent")
Lubomir freed the memory from one of my two strdups but not the other.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoDo some whitespace cleanup
Linus Torvalds [Sun, 26 Aug 2012 21:41:05 +0000 (14:41 -0700)]
Do some whitespace cleanup

The previous commit was a patch from Lubomir, which also had some
whitespace fixes (to go with some new whitespace bugs to replace them)
in it.

I removed the whitespace changes from that patch (don't mix whitespace
fixes with other fixes, unless they are on the same lines!) but decided
to look for other whitespace issues, and this is the result.

I left the non-C files alone, some of the spec and script files also
have whitespace at the end of lines etc.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoreplaced stdndup() with the inlined equivalent
Lubomir I. Ivanov [Sun, 26 Aug 2012 21:20:48 +0000 (00:20 +0300)]
replaced stdndup() with the inlined equivalent

don't kill the OS incompatibility messenger.

1)
http://stackoverflow.com/questions/6062822/whats-wrong-with-strndup
stdndup() is POSIX 2008, but apparently not available on OSX and Windows
it could be made potentially application global (e.g. a local "stdndup.h")

2)
free() memory at pointer "current_dir", once we are done.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agofile.c: open a file in binary mode in readfile()
Lubomir I. Ivanov [Fri, 24 Aug 2012 22:39:00 +0000 (01:39 +0300)]
file.c: open a file in binary mode in readfile()

O_TEXT is the default mode for fctrl's open() and on windows created
files, line endings are counted by fstat() as CR+LF adding an extra
byte for each line. the result from this is that, while the file still
can be read into a buffer, the read() return (ret) has a different
size compared to the previously allocated buffer, breaking at:

if (ret == mem->size)

a solution is to open() the file in O_BINARY mode, which should
technically suppress the EOL translation.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
[ Fixed to work under real operating systems that don't need this crap.
  "Here's a nickel, kid, go and buy a real OS".  - Linus ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoFix broken default filename for save-as
Dirk Hohndel [Sun, 26 Aug 2012 19:51:18 +0000 (12:51 -0700)]
Fix broken default filename for save-as

The existing code set the filename to the full path of the last input file
and didn't set the path at all. Instead we now split the existing filename
into its path and file component and set up the choser accordingly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoIgnore Nitrox/He seetings when editing cylinders for multiple dives
Dirk Hohndel [Sun, 26 Aug 2012 19:25:51 +0000 (12:25 -0700)]
Ignore Nitrox/He seetings when editing cylinders for multiple dives

When figuring out which cylinders to change in a multi-dive edit, we
already ignored the beginning and end pressures. But it turns out to make
more sense to also ignore the Nitrox / Helium settings.

Imagine you do a number of dives - for some reason your dive computer
records the wrong cylinder size in the downloaded logfile (like my uemis
does all the time). Dives will likely have different Nitrox percentage,
but you should still be able to simply fix the cylinder size for all dives
at once.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agomoved zoomed_plot to display.h
Maximilian Güntner [Wed, 22 Aug 2012 00:34:29 +0000 (02:34 +0200)]
moved zoomed_plot to display.h

Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
11 years agoplot the time with a fixed padding (leading zero)
Maximilian Güntner [Tue, 21 Aug 2012 23:23:54 +0000 (01:23 +0200)]
plot the time with a fixed padding (leading zero)

Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
11 years agoMerge branch 'master' into freediving-tweaks
Maximilian Güntner [Tue, 21 Aug 2012 23:15:41 +0000 (01:15 +0200)]
Merge branch 'master' into freediving-tweaks

Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
11 years agoAdd helper 'for_each_dive()' dive iterator
Linus Torvalds [Tue, 21 Aug 2012 22:51:34 +0000 (15:51 -0700)]
Add helper 'for_each_dive()' dive iterator

It's an easy thing to do, but the for-loop ends up being pretty ugly, so
hide it behind the macro.

It would be even prettier with one of the (few) useful C99 features:
local for-loop variables.  However, gcc needs special command line
options, and other compilers may not do it at all. So instead of doing

   #define for_each_dive(_x) \
      for (int _i = 0; ((_x) = get_dive(_i)) != NULL; _i++)

we require that the user declare the index iterator too, and the use
syntax becomes

   for_each_dive(idx, dive) {
... use idx/dive here ...
   }

And hey, maybe somebody actually will want to use the index, so maybe
that's not all bad.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoFix single-dive editing oddity
Linus Torvalds [Tue, 21 Aug 2012 22:37:38 +0000 (15:37 -0700)]
Fix single-dive editing oddity

The multi-dive case does fine, but the single-dive case (used when
adding a dive, for example) was somewhat confused between the dive index
(which is the location in the dive array) and the dive number.

Fix this by just passing the dive pointer instead (where NULL means to
use the current dive selection).

Reported-by: Jacco van Koll <jacco.van.koll@gmail.com>
Root-caused-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoCheck if multi-dive editing is actually needed
Mikko Rasa [Tue, 21 Aug 2012 21:35:08 +0000 (00:35 +0300)]
Check if multi-dive editing is actually needed

Context menu callbacks always invoke edit_multi_dive_info(-1) instead of
edit_dive_info.  Since -1 means "all selected", it was impossible to edit
dive notes through the context menus.  This commit makes the function
check if multiple dives are actually selected.

Signed-off-by: Mikko Rasa <tdb@tdb.fi>
11 years agoFix an off-by-one error in buffer allocation
Mikko Rasa [Tue, 21 Aug 2012 21:26:58 +0000 (00:26 +0300)]
Fix an off-by-one error in buffer allocation

Signed-off-by: Mikko Rasa <tdb@tdb.fi>
11 years agoAdd a "Dive details" widget to the print dialog
Linus Torvalds [Mon, 20 Aug 2012 19:55:10 +0000 (12:55 -0700)]
Add a "Dive details" widget to the print dialog

Ok, so the widget doesn't actually *do* anything, but this is where you
would add dive printing settings for things like "print list" vs "print
profiles" etc.

Printing just a dense dive table (no profiles etc) is being discussed on
the list, maybe starting the scaffolding will inspire somebody to do
something about it ...

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoImprove group selection semantics
Linus Torvalds [Mon, 20 Aug 2012 13:45:56 +0000 (06:45 -0700)]
Improve group selection semantics

Now that the last commit tried to avoid changing the child selections if
the selected group partially matched, we should always [un]select all
children when we actually decide to change something.

Before, it would try to minimize selection damage by stopping
[un]selecting when it hit a child that already matched the selection,
but since we minimize damage differently, the all-or-nothing approach is
better, and gets us sane behavior when the group is collapsed.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoAvoid changing selection status when collapsing/expanding groups
Linus Torvalds [Mon, 20 Aug 2012 13:27:04 +0000 (06:27 -0700)]
Avoid changing selection status when collapsing/expanding groups

This tries to avoid the problem mentioned in commit972669d6363c ("Rework
dive selection logic"), where a selection of dives hidden by collapsing
the group gets forgotten about by gtk.  It does so by always marking the
group selected when it is collapsed with any selected children.

We also avoid selecting new children when a group is selected that
already has at least *some* children selected already.  This way we do
minimal damage to existing selections when working with dive group
selections.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoRework dive selection logic
Linus Torvalds [Mon, 20 Aug 2012 12:48:07 +0000 (05:48 -0700)]
Rework dive selection logic

This completely changes how we keep track of selected dives: instead of
having an array listing the selection ("selectiontracker") or trusting
the gtk selection information, just save the information about whether a
dive is selected in the dive itself.

That makes it trivial to keep track of the state of selection across
group collapse/expand events, or when changing the tree view model.  It
also ends up simplifying the code and logic in other ways.

HOWEVER, it does currently (re-)introduce an annoying oddity with gtk:
if you collapse a dive trip that has individual selections, gtk will
forget those selections ("out of sight, out of mind"), and when you do
*new* selections, the old hidden ones remain.

So there's some games required to make gtk do sane things.  We may need
to either explicitly drop selections when collapsing trips, or make sure
the group entry gets selected when collapsing a group that has
selections in it. Or something.

There may be other issues introduced by this too.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agodivelist: add 'Expand all' and 'Collapse all' menu items
Linus Torvalds [Sun, 19 Aug 2012 03:06:04 +0000 (20:06 -0700)]
divelist: add 'Expand all' and 'Collapse all' menu items

This adds the ability to expand/collapse all the dive groupings in the
divelist from the divelist right-click context menu.

Should we perhaps add it to the top 'Dive' menu too?

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoChange default behavior for Stats to show selected dives
Dirk Hohndel [Sun, 19 Aug 2012 01:08:54 +0000 (18:08 -0700)]
Change default behavior for Stats to show selected dives

Previously when only one dive was selected, the Stats notebook page would show
the statistics for all dive. That creates a very illogical behavior when
clicking on the different dive groups in the dive list. The stats page would
always show how many dives where in a group when the group was selected, except
when there was only one dive in the group, in which case the statistics for all
the dives were shown.

With this change we also show the statistics for the selected dives, even if it
is just one. If you want the statistics for all dives, simply select them all
(Ctrl-A or Command-A on a Mac).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoFix default size for scrollable notebook
Dirk Hohndel [Sun, 19 Aug 2012 01:06:32 +0000 (18:06 -0700)]
Fix default size for scrollable notebook

Linus change in commit bcb9f67819bc ("Make the notebook portion (dive
notes/equipment/info) a scrollable window") created a really ugly default where
the notebook Dive Notes always ended up with a vertical scrollbar. This picks a
much saner default layout for the panes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoMake the notebook portion (dive notes/equipment/info) a scrollable window
Linus Torvalds [Sat, 18 Aug 2012 21:37:43 +0000 (14:37 -0700)]
Make the notebook portion (dive notes/equipment/info) a scrollable window

This makes things start up with the wrong size, which is somewhat
annoying, but by doing so avoids a bigger annoyance, namely that the
three panes move around when moving between dives.

In particular, if the initial dive didn't have much of an equipment
list, the initial size allocated for the notebook is fairly small and
determined mainly by the size of the the Dive Notes page.  However, when
you then scroll around in the dive list, you might hit a dive with lots
of equipment, and suddenly the panes dividing the different parts of the
subsurface application window will jump around to make room.

That's horribly annoying, and actually makes things like double-clicking
dives in the dive list not work right, because the first click will
select it, and cause the dive to move around (so the second click will
hit a totally different dive).

Now, making the notebook be in a scrollable window means that if the
size of the notebook changes, it might get a scrollbar, but the panes
themselves do not move around.

The initial sizing of that thing being wrong is annoying, though.  We
need to figure out a separate solution to that.

[ Side note: currently it uses GTK_POLICY_NEVER for the horizontal
  scroll-bar, just to avoid the horizontal size also starting out wrong,
  which is *really* nasty.  If we can solve the initial size issue, we
  should make the horizontal scroll-bar be GTK_POLICY_AUTOMATIC too. ]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoSelect better (?) default date for adding new dive
Linus Torvalds [Sat, 18 Aug 2012 18:47:29 +0000 (11:47 -0700)]
Select better (?) default date for adding new dive

We now pick one hour after the end of the currently selected dive as the
default starting time for the new dive to be added.  If multiple dives
(or no dives) are selected, we default to current time as before.

The "one hour after the end" is just a random (but not unreasonable)
assumption for the surface time if you add multiple dives.

Suggested-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoImprove divelist group header information
Linus Torvalds [Sat, 18 Aug 2012 18:41:11 +0000 (11:41 -0700)]
Improve divelist group header information

This shows the number of dives in the grup in the divelist header field,
and also picks the location from the first dive that *had* a location,
so that if any dive in the group has a valid location, the group will
have a location.

It also makes double-clicking a dive group expand/collapse that group.

Requested-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoAdd weight and suit support for JDiveLog import
Miika Turkia [Sat, 18 Aug 2012 16:33:40 +0000 (19:33 +0300)]
Add weight and suit support for JDiveLog import

Use the suit and weightsystem support of Subsurface when importing
divelogs from JDiveLog. (They were previously included in the notes
field as support for these fields was missing from Subsurface.)

After import the weightsystem is undefined and weight unit is the
default of Subsurface. Unfortunately the weight field in JDiveLog is
text field and might contain pounds and kilograms mixed in seemingly
random order. Thus 2 pounds of weight might be transformed to 2 kg.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoFix uninitialized pointer crash for "Save As"
Linus Torvalds [Sat, 18 Aug 2012 16:48:15 +0000 (09:48 -0700)]
Fix uninitialized pointer crash for "Save As"

The "filename" variable was only initialized when the user accepted the
name, so cancelling the file save would randomly use an uninitialized
pointer.

Reported-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoMake fill_missing_tank_pressures robust against missing cylinder info
Linus Torvalds [Sat, 18 Aug 2012 16:05:51 +0000 (09:05 -0700)]
Make fill_missing_tank_pressures robust against missing cylinder info

The code iterates over a list that can be NULL, but happily dereferenced
it anyway.  Oops.

This function really should be split up and commented more.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoMake fixup_divep robust against insane dive times
Linus Torvalds [Sat, 18 Aug 2012 16:02:27 +0000 (09:02 -0700)]
Make fixup_divep robust against insane dive times

This fixes the case of the dive duration being zero, or being shorter
than the assumed ascent/descent time.

Reported-by: Lutz Vieweg <lvml@5t9.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoCorrect multi-edit equipment update logic
Dirk Hohndel [Sat, 18 Aug 2012 15:28:52 +0000 (08:28 -0700)]
Correct multi-edit equipment update logic

I lied in the commit message for commit 0468535524a3 ("When editing multiple
files, don't override existing equipment entries"); the changes there did
not parallel the logic for the string entries. Now I think it does.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoFix crash when editing weight system info
Dirk Hohndel [Sat, 18 Aug 2012 13:24:49 +0000 (06:24 -0700)]
Fix crash when editing weight system info

I missed one instance where a callback function needed to be passed the widget
index w_idx in the signal_connect function. It got passed a pointer to the
model instead which of course blew up when trying to dereference the array with
that "index".

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoImport Divesuit information from DivingLog XML file
Dirk Hohndel [Sat, 18 Aug 2012 03:22:37 +0000 (20:22 -0700)]
Import Divesuit information from DivingLog XML file

Trivial two-liner patch

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoMinor Macos menu entry modification fix
Dirk Hohndel [Sat, 18 Aug 2012 02:52:49 +0000 (19:52 -0700)]
Minor Macos menu entry modification fix

We have removed a menu separator from the gtk gui and that was still
referenced in the Macos code. And just in case, we are now testing
for the widget for the other separator to be non-NULL before
destroying it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoWhen editing multiple files, don't override existing equipment entries
Dirk Hohndel [Sat, 18 Aug 2012 02:52:04 +0000 (19:52 -0700)]
When editing multiple files, don't override existing equipment entries

This parallels the logic used for all the string entries.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoMerge branch 'fixes' of git://git.hohndel.org/subsurface
Linus Torvalds [Fri, 17 Aug 2012 23:14:20 +0000 (16:14 -0700)]
Merge branch 'fixes' of git://git.hohndel.org/subsurface

Pull dive selection fixes from Dirk Hohndel.

This hopefully fixes the common cases.  Dirk is cursing gtk.  We may
need some gtk selection guru to explain things.

* 'fixes' of git://git.hohndel.org/subsurface:
  Another selection fix
  More fiddling with the selection

11 years agoAnother selection fix
Dirk Hohndel [Fri, 17 Aug 2012 22:03:57 +0000 (15:03 -0700)]
Another selection fix

The corner cases are getting more and more artificial. Without this patch,
the following can happen:
Select one or more dives in an (expanded) dive trip. Now collapse that
trip with the little triangle. Select a different trip. The previously
selected dive(s) are still part of the selection (as you can see, for
example, in the statistics tab).

With this patch the scenario above works as intended (all the dives in the
new trip are selected), but we have another corner case:
Just as before, select one or more dives in an expanded dive trip.
Collapse that trip and ctrl-click on another trip. Now you lose the
originally selected dives.

Frankly, if you ctrl-click to add more dives to your selection - just
don't collapse the trips the dives are in?

As this new corner case seems even more artificial than the previous one,
I consider this patch an improvement. But fundamentally I am just battling
all the ways in which gtk's selection handling is messed up. When I get
the selection call back I cannot tell if this is a new selection or an
incremental selection (i.e., a shift-click or ctrl-click).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoMore fiddling with the selection
Dirk Hohndel [Fri, 17 Aug 2012 21:23:38 +0000 (14:23 -0700)]
More fiddling with the selection

As expected, this is pretty subtle to get right. But with this change the
code becomes simpler and more straight forward, I think. If the dives in a
group are collapsed, we don't even try to make gtk keep track of their
selection status - we explicitly do so ourselves. This avoids the
artificial expand / collapse around our attempt to force gtk to allow us
to select children that are hidden. But if a dive is expanded, then we
trust gtk to get things right.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoMerge branch 'misc-fixes' of git://github.com/DataBeaver/subsurface
Linus Torvalds [Fri, 17 Aug 2012 17:57:24 +0000 (10:57 -0700)]
Merge branch 'misc-fixes' of git://github.com/DataBeaver/subsurface

Pull miscellaneous fixes, mostly UI stuff from Mikko Rasa.

Both this and the pull from Pierre-Yves Chibon created a "Save As" menu
entry and logic.  As a result, there were a fair number of conflicts,
but I tried to make the end result somewhat reasonable.  I might have
missed some semantic conflict, though.

Series-acked-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
* 'misc-fixes' of git://github.com/DataBeaver/subsurface:
  Add a separate "Save as" entry to the menu
  Changes to menu icons
  Improved depth info for dives without samples
  Divide the panes evenly in view_three

11 years agoMerge branch 'change_quit2' of http://ambre.pingoured.fr/cgit/subsurface
Linus Torvalds [Fri, 17 Aug 2012 17:28:19 +0000 (10:28 -0700)]
Merge branch 'change_quit2' of http://ambre.pingoured.fr/cgit/subsurface

Pull patches to change behavior on exit from Pierre-Yves Chibon.

Pierry-Yves explains:
 "When someone opens a file, change something in it and try to quit, the
  program asked whether the data should be saved.

  If 'Ok' then it shows the save-window and the user can choose to save
  the file or rename it.

  My habits in such case would be that since I opened a specific file, I
  want to save to that specific file, therefore, when I press 'Ok', I
  want it to save automatically to the file I opened.

  So I have been working on changes that do:
   - When a file has been opened by the user, save to this same file if
     the user is 'Ok' while closing.
   - Add a 'Cancel' option to the pop-up window that offers to save the
     file while closing.
   - Add a 'Save As' entry in the file menu."

* 'change_quit2' of http://ambre.pingoured.fr/cgit/subsurface:
  Add a 'Save As' entry in the menu.
  Allow to cancel while trying to quit and the data was changed.
  When the file has been opened rely on it to save.

11 years agoFix string handling in get_combo_box_entry_text
Dirk Hohndel [Fri, 17 Aug 2012 16:36:04 +0000 (09:36 -0700)]
Fix string handling in get_combo_box_entry_text

Linus' code dropped the const qualifier from the start rating. While
fixing this I stared some more at get_combo_box_entry_text and realized
that the existing code could potentially change the "old" pointer and then
pass it to free(). Tsk-tsk-tsk.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agomulti-dive editing: don't change fields that weren't changed for the master dive
Linus Torvalds [Fri, 17 Aug 2012 14:39:50 +0000 (07:39 -0700)]
multi-dive editing: don't change fields that weren't changed for the master dive

Commit 2f773b97e042 ("multi-dive editing: don't change already set data
for other dives") didn't get the multi-dive editing quite right: even if
one of the dives in the list of changed dives has an empty field, we
should *not* fill it with the edit data unless that edit data was
actually changed.

So compare the new data with the original master data, and if they
match, do nothing.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoAdd a 'Save As' entry in the menu.
Pierre-Yves Chibon [Tue, 17 Jul 2012 14:49:27 +0000 (16:49 +0200)]
Add a 'Save As' entry in the menu.

Add a "Save As" entry in the "File" menu allowing the user to specify the file in which to save
the data. This is useful as we no longer offer this option through the "Save" entry while the data
had been opened from an existing file.

Signed-off-by: Pierre-Yves Chibon
11 years agoAllow to cancel while trying to quit and the data was changed.
Pierre-Yves Chibon [Tue, 17 Jul 2012 14:09:29 +0000 (16:09 +0200)]
Allow to cancel while trying to quit and the data was changed.

So far, when trying to quit while the data was changed the offer
was "Save" or "Don't save". Now, you can also "Cancel" which will
bring you back to the main window.

This allows you to re-save the data in another file.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
11 years agoWhen the file has been opened rely on it to save.
Pierre-Yves Chibon [Tue, 17 Jul 2012 14:05:40 +0000 (16:05 +0200)]
When the file has been opened rely on it to save.

When a file is opened, we keep it in memory and when you try to
quit while the data has been changed, propose to save back to
this same file.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
11 years agoRemove repetitions of "Show" in Preferences dialog
Henrik Brautaset Aronsen [Fri, 17 Aug 2012 06:56:03 +0000 (08:56 +0200)]
Remove repetitions of "Show" in Preferences dialog

Instead of having "Show Temp", "Show Cyl", etc in the Preferences dialog,
rename the group as "Show Columns" and remove "Show " from all the
checkboxes.  The dialog is tighter/nicer this way.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
11 years agoMerge branch 'tree2' of git://git.hohndel.org/subsurface
Linus Torvalds [Fri, 17 Aug 2012 03:39:49 +0000 (20:39 -0700)]
Merge branch 'tree2' of git://git.hohndel.org/subsurface

Pull selection tracking fixes from Dirk Hohndel:
 "I just gave up on gtk tracking our selection.  Way too much pain.  The
  implementation below has seen some testing with the debugging code
  enabled and seems to work - but it needs more banging onto it, I'm
  sure.

  Ideally I'd like to leave the debug code in, ask people on the mailing
  list to play with it and report any inconsistencies.  After that I'll
  be happy to remove it again."

* 'tree2' of git://git.hohndel.org/subsurface:
  Stop relying on gtk to track which dives are selected

11 years agomulti-dive editing: don't change already set data for other dives
Linus Torvalds [Fri, 17 Aug 2012 03:30:32 +0000 (20:30 -0700)]
multi-dive editing: don't change already set data for other dives

When editing multiple dives at the same time, don't change fields that
have already been set for a dive, unless the old field contents match
the currently selected ("master") dive.

So when you edit multiple dives, you can set the dive master or buddy
(or suit etc) for all of them in one go, but if one of them already has
that field set, it won't be modified just because you set the other
ones.

Acked-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoStop relying on gtk to track which dives are selected
Dirk Hohndel [Thu, 16 Aug 2012 23:31:53 +0000 (16:31 -0700)]
Stop relying on gtk to track which dives are selected

We spend way too much effort trying to get gtk to manage the dives that
are selected. The straw that broke the camel's back is that gtk forces us
to expand any nodes that we want to select - so selecting a summary entry
for a dive trip forced us to expand all the dives in the dive trip. Which
as Linus pointed out really sucked from a user experience.

So instead we now completeley ignore gtk's weird idea of what is selected
and what isn't and simply track things ourselves. We still need to play
some games with gtk to make sure that the correct rows are SHOWN as
selected, but still, the overall code seems much cleaner.

This commit contains a bunch of debugging code that is ifdef'ed out -
this is extremely useful to make sure I didn't mess anything up, but
eventually I'll want to remove that again as it just looks ugly in the
code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoFix right click edit in Dive Notes area for multiple dives
Dirk Hohndel [Thu, 16 Aug 2012 19:48:29 +0000 (12:48 -0700)]
Fix right click edit in Dive Notes area for multiple dives

This fixes the bug that triggered the SIGSEGV that Linus worked around
earlier. I had forgotten to update this call path to the
edit_multi_dive_info function.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoAvoid SIGSEGV when editing multiple dives
Linus Torvalds [Thu, 16 Aug 2012 18:03:39 +0000 (11:03 -0700)]
Avoid SIGSEGV when editing multiple dives

The multi-dive editing is broken if you right-click on the dive
text-fields (instead of the divelist).  This just avoids the SIGSEGV, it
doesn't really fix the editing.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoMerge branch 'tree2' of git://git.hohndel.org/subsurface
Linus Torvalds [Thu, 16 Aug 2012 17:46:30 +0000 (10:46 -0700)]
Merge branch 'tree2' of git://git.hohndel.org/subsurface

Pull dive-trip grouping from Dirk Hohndel:
 "This turned into an updated pull request for the tree2 branch where I
  implemented the date based grouping - but is actually a very different
  topic: this adds the ability to edit multiple dives (and fixes some
  issues with the dive editing overall).  The reason for that is that it
  reuses some of the infrastructure that I implemented in the tree2
  branch for tracking the selected dives.  More details in the commit
  messages."

* 'tree2' of git://git.hohndel.org/subsurface:
  Switch from date based to dive trip based grouping
  Redo dive editing
  Fix selecting and unselecting summary items
  Apply sort functions to the correct model, don't select summary entries
  Maintain selected rows when switching between list model and tree model
  Create duplicate list model so sorting by columns works again
  Improve tree model implementation
  Allow date based grouping

11 years agoMerge branch 'suit' of git://git.hohndel.org/subsurface
Linus Torvalds [Thu, 16 Aug 2012 17:28:10 +0000 (10:28 -0700)]
Merge branch 'suit' of git://git.hohndel.org/subsurface

Pull exposure suit tracking from Dirk Hohndel.

* 'suit' of git://git.hohndel.org/subsurface:
  Add exposure protection tracking

11 years agoSwitch from date based to dive trip based grouping
Dirk Hohndel [Thu, 16 Aug 2012 11:27:03 +0000 (04:27 -0700)]
Switch from date based to dive trip based grouping

Linus HATED the date based grouping - too much wasted space visually
("three levels of grouping are way too much") and asked for dive trip
based grouping instead.

This is a quick change to do just that, with an assumption that no
dive in 3 days means it's a new trip.

This also changes the summary entry to display a location for the trip,
for now we pick the location of the (chronologically) first dive of the
trip.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoRedo dive editing
Dirk Hohndel [Wed, 15 Aug 2012 22:21:34 +0000 (15:21 -0700)]
Redo dive editing

This commit addresses two issues:

We now can add / edit / delete equipment from the edit dive dialog

We now can edit multiple dives at once

The latter feature has some interesting design constraints:
It picks the 'selected_dive' as the one to start the edit from - so if
this dive already has some information filled in, that information needs
to be overwritten before it is stored in all of the dives. Similarly, only
changes to the cylinders or weightsystems are recorded. Also, the notes
field is not editable in the multi dive edit mode (as that didn't seem
useful).

The workflow seems to work best if using the multi-edit right after
importing new dives from a dive computer. The user then can select all the
new dives and only needs to edit things like location, divemaster, buddy,
weights, etc. once.

This commit will create some obvious conflicts with the commit that adds
exposure protection tracking. It was implemented on top of the tree_view
changes as it reuses some of the infrastructure for tracking the selected
dives.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoAdd exposure protection tracking
Dirk Hohndel [Tue, 14 Aug 2012 23:07:25 +0000 (16:07 -0700)]
Add exposure protection tracking

For simplicity and shortness, throughout subsurface exposure protection is
simply referred to as "suit".

Add the fields to the data structures, add the column to the dive_list
and the preferences dialog (once again with it being turned invisible by
default). Support loading and saving of the suit information.

Display the suit information in the Dive Info pane (this may be a bit
controversial as people could argue this should be in the Equipment pane)
and allow editing of the suit info, with our usual support for completion
and drop down lists to pick from.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoFixed another memory leak
Dirk Hohndel [Tue, 14 Aug 2012 21:52:14 +0000 (14:52 -0700)]
Fixed another memory leak

We need to free the string that gtk_tree_mode_get returns to us.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoFixed a small memory leak in divelist.c
Lubomir I. Ivanov [Wed, 1 Aug 2012 19:19:44 +0000 (22:19 +0300)]
Fixed a small memory leak in divelist.c

In fill_one_dive(), cylinder and location strings are obtained via
get_string(), which needs to allocated a litte bit of memory.

After passing the two pointers ('cylinder' and 'location') as arguments
to gtk_list_store_set() it is safe to release them.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
11 years agoFix selecting and unselecting summary items
Dirk Hohndel [Tue, 14 Aug 2012 04:11:09 +0000 (21:11 -0700)]
Fix selecting and unselecting summary items

The dive list now seems to behave intuitively.

In order to do this we had to intercept the select function in addition to
having a selection-changed callback. That way we can simulate the
multi-level selection and unselection that was missing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoApply sort functions to the correct model, don't select summary entries
Dirk Hohndel [Mon, 13 Aug 2012 22:07:38 +0000 (15:07 -0700)]
Apply sort functions to the correct model, don't select summary entries

We only set up the column specific sort functions for the default (tree)
model, which caused us to not sort correctly in the list model.

This commit also somewhat cleans up the handling of selecting summary
lines in the tree model, which includes the very first selection made at
program start (which happens to be the very last dive).

But it still doesn't work the way I expect it to work (i.e., the correct
row is not highlighted). Fundamentally I would prefer clicks on the
summary lines to instead select (or as ctrl-click, possibly deselect) all
the dives under that summary entry. Still TODO.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoMaintain selected rows when switching between list model and tree model
Dirk Hohndel [Mon, 13 Aug 2012 21:53:07 +0000 (14:53 -0700)]
Maintain selected rows when switching between list model and tree model

We keep track of the DIVE_INDEX of all selected dives and simply re-select
those dives after changing model (date based sort or sort by other
column).

There are a few TODOs left. We lose the sort direction (ascending /
descending) when switching models. We also don't correctly deal with the
user selecting summary rows in the tree model.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoCreate duplicate list model so sorting by columns works again
Dirk Hohndel [Mon, 13 Aug 2012 21:42:55 +0000 (14:42 -0700)]
Create duplicate list model so sorting by columns works again

One major downside of the switch to a tree model is that sorting by
columns other than date was broken - it would sort the entries within each
date which is not all that useful.

After playing with some Gtk trickery that would allow us to filter out
those rows it quickly became clear that the much easier solution is to
simply maintain TWO models (and therefore two storages). This causes some
overhead and requires some careful tracking of all changes, but it turned
out to be rather straight forward to do.

dive_list now has three model related members:
 model     - current model displayed (which is one of the following two)
 treemodel - the tree model
 listmodel - the list model

One side effect is that the callbacks no longer can pass the model around
(as this could have changed since the callback was registered), but that
seems only a minor drawback and was easily addressed.

The implementation in this commit still has a couple of obvious flaws:
when switching back from the list model to the tree model all the
expansion state of the rows is lost and we end up with just a list of the
different years visible. Also, selections aren't maintained when switching
models.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoImprove tree model implementation
Dirk Hohndel [Mon, 13 Aug 2012 20:09:40 +0000 (13:09 -0700)]
Improve tree model implementation

We now support three hierarchy levels: day, month, and year. Each
indicated by a negative DIVE_INDEX for -1 to -3. This allows a nice
compact overview when doing date based sorting (the default).

As indicated in the previous commit, things still go wrong with sorting by
other columns as the entries are only sorted within each day, not globally
across the whole dive list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoAllow date based grouping
Dirk Hohndel [Wed, 8 Aug 2012 16:35:38 +0000 (09:35 -0700)]
Allow date based grouping

This is the very first rough cut. It switches things over to a tree model
so we can have date based summary nodes.

It uses a DIVE_INDEX of -1 for summary nodes to easily tell them apart
from actual dives. All the data functions are changed so the summary
nodes only show the date they cover.

The commit also adds a couple of debug functions to be able to easily peek
into the model from the debugger.

Lots of things left to do. There is no longer a first dive selected when
starting subsurface. Sorting by columns other than date is messed up. We
almost certainly want month and year summary entries as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoDon't print a total weight of 0 in the weight column
Dirk Hohndel [Fri, 10 Aug 2012 20:43:16 +0000 (13:43 -0700)]
Don't print a total weight of 0 in the weight column

For consistency with the rest of the dive_list we should interpret "no
weight systems recorded" as "no information" and therefore print nothing
instead of printing a total weight of "0" for these dives.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoAdd total weight column to divelist
Dirk Hohndel [Tue, 7 Aug 2012 18:24:40 +0000 (11:24 -0700)]
Add total weight column to divelist

This adds the total weight carried on the dive in different weight systems
to the divelist. The column is by default not shown, which can be changed
in the preferences. The column is sortable.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoFill the list of weightsystems from data in existing dives
Dirk Hohndel [Mon, 6 Aug 2012 21:03:24 +0000 (14:03 -0700)]
Fill the list of weightsystems from data in existing dives

This was simply an omission in the current implementation. All the
plumbing was there but never got hooked up with the fixup_dive function as
intended.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoRemove weightsystem entry with no description
Dirk Hohndel [Mon, 6 Aug 2012 20:56:46 +0000 (13:56 -0700)]
Remove weightsystem entry with no description

This existed in the initial implementation to deal with an implementation
problem that was long since resolved. So now it just created just an ugly
empty line in the drop down menu for weightsystems.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoRemember the last weight used per weightsystem
Dirk Hohndel [Mon, 6 Aug 2012 19:55:55 +0000 (12:55 -0700)]
Remember the last weight used per weightsystem

With this change, if the user adds a new weightsystem to a dive, on
subsequent edits the weight amount for this weightsystem no longer
defaults to 0 but to the last weight that was used with this weightsystem.

So when the program imports a set of dives from the divecomputer and the
user starts editing them, once they enter the weight for the "integrated"
weightsystem the first time, for each of the consecutive dives that same
weight is the default once "integrated" is selected - which usually will
be the correct amount.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
11 years agoAdd a separate "Save as" entry to the menu
Mikko Rasa [Tue, 31 Jul 2012 17:55:41 +0000 (20:55 +0300)]
Add a separate "Save as" entry to the menu

The "Save" entry will now automatically save over the last used file.  If
no filename has been set, then that entry will also prompt the user for a
filename.

The filename is set when saving as well, so the next save will use the
same filename.

Signed-off-by: Mikko Rasa <tdb@tdb.fi>
11 years agoChanges to menu icons
Mikko Rasa [Sun, 29 Jul 2012 10:15:04 +0000 (13:15 +0300)]
Changes to menu icons

It's customary for menu bars to not have icons.

Some items were lacking icons when there's perfectly good stock icons
available.  I was a bit torn between the "new" and "add" icons for the
"add dive" item, since what it really does is create a new dive, but
the "add" icon is an uninteresting sheet of paper in the default icon
theme so I decided to use the "add" icon.

Signed-off-by: Mikko Rasa <tdb@tdb.fi>
11 years agoImproved depth info for dives without samples
Mikko Rasa [Sun, 29 Jul 2012 09:52:51 +0000 (12:52 +0300)]
Improved depth info for dives without samples

This calculates a mean depth for the dive with a fixed ascent/descent
rate and an assumption that all of the bottom time is at the maximum
depth.  It's not much, but it allows some derived values such as SAC to
make more sense.

The depth profile for such dives is now also generated with the same
assumptions instead of putting the samples at fixed percentages of the
dive duration.

Signed-off-by: Mikko Rasa <tdb@tdb.fi>
11 years agoDivide the panes evenly in view_three
Mikko Rasa [Sun, 29 Jul 2012 09:13:36 +0000 (12:13 +0300)]
Divide the panes evenly in view_three

There was a note by Linus that he doesn't know how to get the size, so
I'm fixing that.

Signed-off-by: Mikko Rasa <tdb@tdb.fi>
11 years agofile.c: Fix a file descriptor leak in readfile()
Andrew Clayton [Thu, 12 Jul 2012 22:28:47 +0000 (23:28 +0100)]
file.c: Fix a file descriptor leak in readfile()

In file.c::readfile() the file was being opened once at fd declaration
time and then again a few lines later and only being closed once. Remove
the open() at fd declaration time leaving the later one where the fd check
is done.

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoUpdate for libdivecomputer pkg-config include file changes
Linus Torvalds [Tue, 10 Jul 2012 19:33:44 +0000 (12:33 -0700)]
Update for libdivecomputer pkg-config include file changes

Subsurface doesn't compile on OS X any more, because libdivecomputer
changed the way the header inclusion works: the include path from
pkg-config no longer includes the final "libdivecomputer" component, and
instead of doing

  #include <header.h>

for libdivecomputer headers, we're now supposed to do

  #include <libdivecomputer/header.h>

instead. Which is cleaner anyway.

The reason this only bit us on OS X is that I never trusted pkg-config
that much for non-system libraries on Linux (maybe it works, maybe it
doesn't, I've seen it go both ways), so on Linux we just used our own
version of the include path, and thus weren't affected by the
libdivecomputer config change.

Clean up the includes while at it - we no longer need (or want) the
device-specific header files, since we just use the generic functions.

Reported-by: Grischa Toedt <toedt@embl.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoFix a couple of possible divide-by-zero conditions in statistics
Linus Torvalds [Sun, 1 Jul 2012 03:12:11 +0000 (20:12 -0700)]
Fix a couple of possible divide-by-zero conditions in statistics

Several people reported the average time problem, but there's another
one lurking there too: if the dive duration is zero, you get bogus
average depth information too (but because that one was a floating point
divide, and by default they are unsignalling on x86, it didn't crash, it
just resulted in bogus results).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoMake the 'Add Dive' dialog at least slightly less butt-ugly
Linus Torvalds [Thu, 28 Jun 2012 01:56:41 +0000 (18:56 -0700)]
Make the 'Add Dive' dialog at least slightly less butt-ugly

I still suspect that using spinbuttons for the time handling is the
wrong way, and I'm a bit surprised the Calendar widget doesn't have a
mode where you can see/set the time too.

But this makes things at least minimally prettier, and initializes the
time entries to the current time (which is obviously not what anybody
really wants, but looks a lot better than defaulting to "midnight" or
some other random time that *also* won't be what anybody actually
wants).

I think this might be something we can live with, although I hope
somebody with good taste comes along and say "don't use spinbuttons, do
this: xyzzy" and makes things look better yet.

Also, I have this suspicion that I should put the time/depth/duration
stuff to the right of the calendar.  Most displays are wider than they
are tall, so tall and skinny dialogs are bad especially if you have
limited vertical pixels.  I still have flashbacks to my netbook-using
days, hating applictions that did that.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoMake it possible to do "Add Dive" from just the main dive menu
Linus Torvalds [Thu, 28 Jun 2012 01:09:26 +0000 (18:09 -0700)]
Make it possible to do "Add Dive" from just the main dive menu

No need for right-clicks.  It's inconvenient on lots of laptops etc, so
allow just using the Dive menu as an alternative.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoAdd depth entry to new dive edit dialog
Linus Torvalds [Wed, 27 Jun 2012 21:29:29 +0000 (14:29 -0700)]
Add depth entry to new dive edit dialog

Christ, if you look up "Ugly dialog" on Wikipedia, I think it has a
picture of this "New dive" thing.  Or it should have.

But it kind of works.  Although with only a "max depth" entry, you can't
currently set average depths etc, so SAC-rates etc cannot be calculated
for these kinds of dives.

And the dive numbering is wrong.  We do auto-number new dives that get
added at the end, but we do it as we add them, so when you *edit* the
dive information (before it has been added) the dive number shows up as
"#0".

So there's certainly room for improvement here.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoRough "Add new dive" infrastructure in the divelist
Linus Torvalds [Wed, 27 Jun 2012 20:11:54 +0000 (13:11 -0700)]
Rough "Add new dive" infrastructure in the divelist

Do a right-click to get a menu with the "Add dive" entry.  Should do
delete too, but that's for later.

What's also apparently for later is to make this *useful*.  It's the
butt-ugliest time entry field ever, and there's no way to set depth for
the dive either.  So this is more of a RFC than anything truly useful.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoUpdate to new sane libdivecomputer interfaces
Linus Torvalds [Fri, 22 Jun 2012 20:37:39 +0000 (13:37 -0700)]
Update to new sane libdivecomputer interfaces

This does mean that you have to build subsurface against a new version
of libdivecomputer, and that version is likely going to have various
slightly incompatible changes.  But the new interfaces allow for easily
adding new supported dive computers without subsurface having to be
updated for each new vendor and model, so some slight pain is definitely
worth it this time.

I'm not even going to try to have some backwards-compatible version
here, the libdivecomputer interface changes are so extensive.  Native
enumeration of devices is just the smallest part of it: the constants
and types that libdivecomputer uses now have much nicer names that all
start with DC_ or dc_, so you don't get the kinds of name clashes we had
with "gasmix_t" etc.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoFix cochran CSV pressure data import
Linus Torvalds [Wed, 20 Jun 2012 05:41:44 +0000 (22:41 -0700)]
Fix cochran CSV pressure data import

The cochran CSV pressure data is actually in units of '4 psi', not in
just psi.  That seems to be the resolution cochran internally keeps
things in, and unlike the depth reading there's no conversion to
standard units in the export (for depth, the quarter-foot depth
resolution is converted to tenths of feet when exporting).

Yeah, none of this makes any sense to me either, but I knew it was the
case.  I had just forgotten that factor-of-four when I did the importer.

With this fix, I get the same subsurface data (modulo some rounding
differences particularly for temperature) whether I go through David
McNett's UDDF converter, or just import the CSV data directly.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agocochran: add support for importing the exported CSV files
Linus Torvalds [Wed, 20 Jun 2012 03:07:42 +0000 (20:07 -0700)]
cochran: add support for importing the exported CSV files

The Cochran Analyst software can export the basic dive information as
CSV files (comma-separated values).

Individual CSV files contain just one particular type of information:
depth, temperature or cylinder pressure, which is rather inconvenient.
However, the way subsurface works, you can just import these CSV files
all as individual dives, and then subsurface will automatically merge
the dives with the same date and time - and in the process it will also
merge all the samples.

So it turns out that we don't really need any special handling.  You can
literally just do

     subsurface <list-your-cochran-export-files-here>

and you're all done.

Of course, the CSV files really *are* pretty useless, since they don't
contain all the nice information about where the dive took place etc.
So you literally just get the dive profile.  But that's better than
getting nothing at all.

I'd love to actually be able to parse the real native Cochran Analyst
software CAN files, but in the meantime this is at least a starting
point.  And if I'm ever able to parse those nasty CAN-files, this makes
comparisons with the exports much easier.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoAdd a few more conversion helper functions to dive.h
Linus Torvalds [Wed, 20 Jun 2012 03:06:59 +0000 (20:06 -0700)]
Add a few more conversion helper functions to dive.h

Convert feet to mm, psi to mbar, and F to mkelvin.  We do this elsewhere
too, but I'm going to need it for the Cochran CSV files, so let's do the
helpers now.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoUpdate cochran depth precision: it's in 3-inch increments
Linus Torvalds [Tue, 19 Jun 2012 19:13:50 +0000 (12:13 -0700)]
Update cochran depth precision: it's in 3-inch increments

The Cochran CSV depth exports are indeed in tenths of feet, but the
decimal is always 0, 3, 5 or 8.  Where the 3 and 8 are obviously 0.25
and 0.75 rounded up to one decimal place.

So Cochran does seem to be very much about imperial units, with depth
and cylinder pressure scaled by four (depth in quarter-foot increments,
pressume in 4-psi increments)

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoAdd some more cochran data parsing code/comments
Linus Torvalds [Mon, 18 Jun 2012 23:52:41 +0000 (16:52 -0700)]
Add some more cochran data parsing code/comments

The code is pretty useless, the comments perhaps equally so.  I'm trying
to figure out what the data pattern is for the cochran CAN files.  There
definitely *is* a pattern, but it actually seems to be different for the
files of different people - and it's not obvious in any case.

There probably are multiple versions of the format, and there might be
things like "David has a high-pressure sensor, and Alex does not" going
on too.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoAdd tankpressure parsing for UDDF files
Linus Torvalds [Mon, 18 Jun 2012 19:45:09 +0000 (12:45 -0700)]
Add tankpressure parsing for UDDF files

David McNett sent me some example Cochran CAN file data, along with his
UDDF exports of same.  I still have absolutely no idea how to decode the
CAN files (although the subsurface decrypting code seems to correctly
decrypt the data, and I see binary patters rather than just noise), but
at least I can make sure we parse the UDDF portion better.

See also

  https://github.com/nugget/cochran2uddf

for David's tool to convert the Cochran CSV exports into UDDF.

Data-source: David McNett <nugget@macnugget.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoupdated/corrected comment
Maximilian Güntner [Mon, 11 Jun 2012 01:11:13 +0000 (03:11 +0200)]
updated/corrected comment

Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>