]> git.tdb.fi Git - ext/subsurface.git/log
ext/subsurface.git
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 agoSave dive computer device name.
Terrance Stanfield [Wed, 30 May 2012 04:54:09 +0000 (23:54 -0500)]
Save dive computer device name.

It is really annoying to have to type the device name each time you need
to import a dive from your computer, if you are not using the default
device name. This will save the device name in the configuration file and
matches the logic currently used to save the dive computer name in the
configuration file.

Signed-off-by: Terrance Stanfield <t@hollowcranium.com>
11 years agoAllow overriding the default xslt path
Linus Torvalds [Sat, 12 May 2012 19:53:41 +0000 (12:53 -0700)]
Allow overriding the default xslt path

It's very annoying to have to do "make install" to test a new xslt file,
just because the default xslt path has the standard install path as the
first entry.

At the same time, we do want to default to just using the standard
install location first.

So to allow both testing, and having a nice sane default, just add
support for a SUBSURFACE_XSLT_PATH environment variable that overrides
the default one if it exists.

So then you can just do

   SUBSURFACE_XSLT_PATH=xslt ./subsurface

to run subsurface from inside the git tree itself, using the current
files in the git xslt subdirectory.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoSuunto SDE conversion: add boat name to notes if it exists
Linus Torvalds [Sat, 12 May 2012 19:28:40 +0000 (12:28 -0700)]
Suunto SDE conversion: add boat name to notes if it exists

This is, I think, the last piece of relevant information that I can find
in Szymon's SDE file.

Which is not to mean that we get all the conversions right, or that we
handle the more complex cases (still no multi-cylinder import, for
example). But it should be much better than it used to be.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoSuunto SDE updates, take 178: add weight and visibility info
Linus Torvalds [Sat, 12 May 2012 19:21:32 +0000 (12:21 -0700)]
Suunto SDE updates, take 178: add weight and visibility info

This converts the weight information into subsurface weights, and also
adds visibility info (if it exists) into the notes for the dive.

More fall-out from me looking at the nasty suunto xml files, now that I
have a few that actually have some info that isn't just from the
computer download.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoFix more Suunto SDM xml conversion problems
Linus Torvalds [Sat, 12 May 2012 19:01:38 +0000 (12:01 -0700)]
Fix more Suunto SDM xml conversion problems

Looking at the XML of the two dives Szymon Kosecki sent out to the
subsurface list, I notice that our cylinder size conversion was wrong.
It looks like CYLINDERUNITS is what determines whether the cylinder size
is in metric (0) or imperial (1) units.

Of course, if you gave a cylinder size in cuft and didn't give a working
pressure, subsurface will just ignore the size as the random crap it is.
We *could* default to a working pressure of 3000 psi, of course.

This also picks up the CYLINDERDESCRIPTION value, although neither of
Szymon's dives actually had any description.

I need more SDE xml files to figure out how multi-cylinder dives look
etc, but I think this gets most *simple* SDE files converted almost
correctly now.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoFix dive notes import from Suundo SDM
Linus Torvalds [Fri, 11 May 2012 21:13:45 +0000 (14:13 -0700)]
Fix dive notes import from Suundo SDM

The xslt translation didn't add the <notes> tag for the notes, so while
it did select the notes from the SDM file, that never made it into the
subsurface notes.

Also added weather info to the notes, mainly as an example.

There are probably other things we could do, but this fixes at least the
trivial test-case from Szymon Kosecki.

Reported-by: Szymon Kosecki <skosecki@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoFix subsurface.desktop category entry
Khalid El Fathi [Mon, 7 May 2012 17:08:51 +0000 (19:08 +0200)]
Fix subsurface.desktop category entry

This desktop entry lists a category that is not one of the registered
Main or Additional Categories in the FreeDesktop specification.

Refer to

   http://standards.freedesktop.org/menu-spec/1.0/apa.html

for details.

Signed-off-by: Khalid El Fathi <khalid@elfathi.fr>
Acked-By: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoFix subsurface manpage - missing description and parsing problem
Khalid El Fathi [Mon, 7 May 2012 17:08:39 +0000 (19:08 +0200)]
Fix subsurface manpage - missing description and parsing problem

It's missing a brief description.  The "NAME" section is parsed by
lexgrog and used to generate a database that's queried by commands like
apropos and whatis.  Replacement a hyphen by a minus sign.

Signed-off-by: Khalid El Fathi <khalid@elfathi.fr>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoset subsurface_flush_conf() to no-op in wondows.c
Lubomir I. Ivanov [Sat, 5 May 2012 16:30:39 +0000 (19:30 +0300)]
set subsurface_flush_conf() to no-op in wondows.c

flushing the entire registry is not required on windows. simply
closing the registry key when done would suffice.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agodivecomputer importing: show the date of the currently importing dive
Linus Torvalds [Thu, 3 May 2012 23:04:07 +0000 (16:04 -0700)]
divecomputer importing: show the date of the currently importing dive

I'm hoping most other dive computers are quicker to import from than the
Suunto I have, but mine can take minutes to import all the dives.  Sure,
we have that nice progress bar, so it shows that it's doing something,
but it's not really showing *what* it is doing.

So instead of showing just "Parsing dive X", let's show the date of the
dive.  That way, when it takes two minutes to import all the dives, at
least you can see "oh, it's going back to the dives of last year" and it
then feels like you have some good reason for the delay.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoShow dive import text updates in the progress bar
Linus Torvalds [Thu, 3 May 2012 00:40:39 +0000 (17:40 -0700)]
Show dive import text updates in the progress bar

Instead of using printf() to print the string updates ("Parsing sample
data" etc), introduce a function to show those strings in the graphical
progress bar itself.

Subsurface hasn't been a text-mode application in a long time ;)

This partially fixes the second todo entry from commit b0ba22a06879
("Show dive import error messages in the import dialog") and generally
makes for a more helpful import - at least for the largely error-free
cases.

Sadly, the messages that really come from within libdivecomputer itself
(like "suunto_vyper2.c:193: Failed to receive the answer.") when things
go really wrong are not caught.  libdivecomputer does have a notion of a
logfile (set with "message_set_logfile()"), but that ends up being
really inconvenient.

Maybe we could use some pipe setup or something. Oh well.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoChange the Dive computer import button from "Ok" to "Retry" on error
Linus Torvalds [Wed, 2 May 2012 20:45:52 +0000 (13:45 -0700)]
Change the Dive computer import button from "Ok" to "Retry" on error

This was a todo item in commit b0ba22a06879 ("Show dive import error
messages in the import dialog") which made the import dialog able to
retry the import on errors.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoMove the "Import" function from the File menu to the Log menu
Linus Torvalds [Wed, 2 May 2012 19:56:01 +0000 (12:56 -0700)]
Move the "Import" function from the File menu to the Log menu

Sure, you can import a file too, but it really makes more sense to have
the actions related to importing new logs under "Log", I think.  I don't
think of it as a file operation.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoShow dive import error messages in the import dialog
Linus Torvalds [Wed, 2 May 2012 19:49:03 +0000 (12:49 -0700)]
Show dive import error messages in the import dialog

.. not in the main window.  And leave the import dialog open, so that
you can either try doing it again, or cancel.  This makes it much easier
to re-try a failed dive import, and actually makes the failure more
obvious too.

Todo:

 - make the "Ok" button change to "Retry" when an error happens

 - try to see if we can catch the actual status update messages from
   libdivecomputer and show them too in the import dialog.  Right now
   they are printed out to stderr by the library.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoRemember the default dive computer setting
Linus Torvalds [Wed, 2 May 2012 17:26:34 +0000 (10:26 -0700)]
Remember the default dive computer setting

Always having to re-select the same dive computer got really annoying
when I had trouble importing the dives.  Let's not force the user to do
that, since we could just remember the last dive computer used, and
default to that one.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoDon't close config file when changing preferences
Linus Torvalds [Wed, 2 May 2012 17:03:48 +0000 (10:03 -0700)]
Don't close config file when changing preferences

On Linux and MacOS the subsurface_close_conf() doesn't really close the
config file (it flushes writes on MacOS), but on Windows it does
actually close the registry hkey.

Which is bad, if you change the settings multiple times - we assume that
the config file is open the whole time.

So add a "subsurface_flush_conf()" function, and call *that* when
changing configuration parameters.  And call the close function only at
the very end.

Alternatively, maybe we should just open the config file separately
every time. I don't much care, maybe somebody else does.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 years agoMake subsurface compile with current libdivecomputer git tree
Linus Torvalds [Wed, 2 May 2012 16:36:55 +0000 (09:36 -0700)]
Make subsurface compile with current libdivecomputer git tree

libdivecomputer has the absolute worst interfaces to any library *ever*,
and randomly changes those crappy interfaces when it adds support for
new dive computers.

It would have been much better if the interface was just a "open this
device" with a device descriptor structure pointer, so that when Jef
adds support for new devices, the old descriptors still stay around and
work the same way - there's just a new descriptor structure that you
*can* use if you want.  Along with a data structure to name the devices
and their descriptors, this would actually mean that users could just
support pretty much any random device that LD supports.

But no, that's not how libdivecomputer works.  It has random enums and
crazy different ad-hoc interfaces for different dive computers.  Or,
like in this case, crazy different ad-hoc interfaces for the *same*old*
dive computer.

Right now, for example, the support for the new Heinrichs Weikamp "Frog"
computer added a flag to the interface for the old OSTC_2 support.
Breaking any libdivecomputer users even if you didn't need Frog support.

And is there a version number in the header files to check for? Yes,
there's a version number.  But no, it's not useful, since it doesn't
actually change with the interface changes.  This time, Jef actually did
change the version number (from 0.1.0 to 0.2.0) as part of new
development version, but there's no reason to believe that it will
change in the future  as the interfaces change - it never has before.

So it's actually safer - and easier to understand - to check for the
existence of the new header file inclusion mechanism.  A new version of
libdivecomputer that supports the HW Frog computer will include the
"ostc_frog.h" header file when you include the libdivecomputer device.h
file, and that will result in HW_FROG_H being defined.

So we can check whether libdivecomputer has the new interface and
supports the Frog by doing an "#ifdef HW_FROG_H" hack. Ugh.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoMake sure to update dive info when it is edited
Linus Torvalds [Wed, 25 Apr 2012 02:05:56 +0000 (19:05 -0700)]
Make sure to update dive info when it is edited

We used to not properly update the dive info until we switched to
another dive when we edited it.  This should fix it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoFix edit callback for weight system
Dirk Hohndel [Tue, 24 Apr 2012 02:54:11 +0000 (19:54 -0700)]
Fix edit callback for weight system

Linus found this embarrassing bug: double clicking on a weight system in
order to edit it launched the edit function for the first cylinder
instead. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agoRenumber dives when deleting a dive
Linus Torvalds [Tue, 3 Apr 2012 05:00:29 +0000 (22:00 -0700)]
Renumber dives when deleting a dive

... but only do it if the numbering of subsequent dives was consecutive
to begin with.

Note that we do accept unnumbered dives (and will stop the sequence
check if we find one), but in order to renumber dives on delete, we
require that starting with the dive we delete, the subsequent numbered
dives have to be a nice incrementing series.  If that is the case, then
we fix up that numbering as we delete the dive.

Put another way: if the dive numbering was an incrementing sequence
before the delete, then it will be a sane incrementing sequence after it
too.  But if you had missing dives before the delete, we will turn the
delete into just another missing dive.

The basic rule is that we never renumber any dives unless that
renumbering is "obviously correct".  It's better to leave old numbers
as-is (and expect that the user is going to do an explicit re-numbering
operation) than it is to change dive numbers in a sequence that we don't
understand.

I do suspect that we should possibly check the dive number "backwards"
too, but this doesn't do that.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAdd the ugliest 'delete dive' model ever
Linus Torvalds [Tue, 3 Apr 2012 02:19:01 +0000 (19:19 -0700)]
Add the ugliest 'delete dive' model ever

This interface works the same way the "edit dive" menu item does: it's a
text entry meny item on the dive text entries (ie buddy/divemaster/notes
sections).  Except you pick the "Delete" entry rather than the "Edit"
entry.

It kind of works, but it really is a pretty horrible interface.  I'll
need to add a top-level dive menu entry for just deleting all selected
dives instead.  And it would be good to be able to get a drop-down menu
from the divelist instead of having to do it from the dive text entries,
which is just insane.

But that requires gtk work.  I'm not quite ready to get back into that.
Thus the "exact same insane interface as the explicit 'Edit' mode".

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoFix reference tank information for LP steel tanks.
Linus Torvalds [Sun, 1 Apr 2012 22:38:52 +0000 (15:38 -0700)]
Fix reference tank information for LP steel tanks.

Commit f9bb3f79106b ("Clean up reference tank information table") had
cleaned up the tank info list so that you could sanely do tanks in
liters and with a working pressure in bar.

But the LP steel cylinders had somehow missed out on the ".psi =" part
of the equation, and as a result, what was supposed to be their working
pressure instead ended up being interpreted as their size in
milli-liters.

Oops.

Fix that, and also make the standard tank info filling code actually
verify the sanity of the reference tank table, so that if this happens
again, it will complain loudly instead of using nonsensical values.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoFix broken average SAC calculation
Miika Turkia [Fri, 30 Mar 2012 05:10:05 +0000 (08:10 +0300)]
Fix broken average SAC calculation

old_sac_time was always 0 when calculating average air consumption.
Thus the results were incorrect.  Move the counter to stats_t structure
as suggested by Linus.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAdded support for Mares Darwin, M1, M2, ... from latest libdivecomputer.
Björn Spruck [Sun, 25 Mar 2012 15:16:21 +0000 (17:16 +0200)]
Added support for Mares Darwin, M1, M2, ... from latest libdivecomputer.
Only M1 has been tested.
Darwin Air will most likely not work as an additional model flag seems to be needed.
This is not foreseen in current GUI.

12 years agoMerge branch 'weight' of git://subsurface.hohndel.org/subsurface
Linus Torvalds [Sat, 24 Mar 2012 04:07:53 +0000 (21:07 -0700)]
Merge branch 'weight' of git://subsurface.hohndel.org/subsurface

Pull weight management from Dirk Hohndel:
 "This is the fifth or sixth version of this code, I'm begining to lose
  track.  I still struggle with the balance between code duplication and
  unnecessary indirectness and complexity.  Maybe I'm just not finding
  the right level of abstraction.  Maybe I'm just trying too hard.

  The code here is reasonably well tested.  Works for me :-)

  It can import DivingLog xml files with weight systems and correctly
  parses those.  It obviously can read and write weight systems in its
  own file format.  It adds a KG/lbs unit default (and correctly stores
  that).

  The thing I still worry about is the code in equipment.c.  You'll see
  that I tried to abstract things in a way that weight systems and
  cylinders share quite a bit of code - but there's more very similar
  code that isn't shared as my attempts to do so turned into ugly and
  hard to read code.  It always felt like trying to write C++ in C..."

* 'weight' of git://subsurface.hohndel.org/subsurface:
  Add weight system tracking

Fix up some trivial conflicts due to various renaming of globals and
simplification in function interfaces.

12 years agoAdd weight system tracking
Dirk Hohndel [Sat, 24 Dec 2011 03:41:16 +0000 (19:41 -0800)]
Add weight system tracking

- supports multiple weight systems per dive
- supports multiple weight system types
- supports import of weight as tracked by DivingLog

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agouser-manual: fix a few annoying typos
Miklos Vajna [Thu, 22 Mar 2012 11:34:41 +0000 (12:34 +0100)]
user-manual: fix a few annoying typos

Signed-off-by: Miklos Vajna <vmiklos@vmiklos.hu>
12 years agoShow statistics of selected dives
Miika Turkia [Wed, 14 Mar 2012 17:01:34 +0000 (19:01 +0200)]
Show statistics of selected dives

If at least 2 dives are selected, show statistics of these dives on
Overall Stats. Otherwise, show the statistics of all dives. Temperature
is also added to the shown statistics.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Minor change to avoid adding statistics.h (moved the global variable and
external function declaration to display-gtk.h).
Another minor change to the text displayed for the "Stats" notebook page.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agoCochran: fix up dive data descrambling
Linus Torvalds [Sat, 28 Jan 2012 02:27:30 +0000 (18:27 -0800)]
Cochran: fix up dive data descrambling

This seems to do the dive data descrambling right for both files I have
access to.  Except it uses a hardcoded (different) offset for the two.
I have yet to figure out how to automatically detect the offset itself
properly, so you have to compile for the right file.

I'll figure it out, but I'm committing this as a reasonable point in the
process.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoFix up Cochran dive header decoding offset
Linus Torvalds [Sat, 28 Jan 2012 01:36:42 +0000 (17:36 -0800)]
Fix up Cochran dive header decoding offset

It turns out the odd "different CAN files have different header offsets"
came from the fact that the decode block was different lengths, and I
had not picked the correct place to start - and instead had found two
different places that were at different offsets due to the decode block
length differences.

This fixes that up, and it looks like the dive header is correctly
descrambled (but what the data *means* is unclear, although there is now
an ASCII date and time visible, so at least one part of it is pretty
obvious).

The actual dive data unscrambling is still different for the two
test-files I have to play with, I do not know why.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agocochran: do a partial header de-scramble
Linus Torvalds [Fri, 27 Jan 2012 23:11:34 +0000 (15:11 -0800)]
cochran: do a partial header de-scramble

This descrambles at least parts of the header data.  Some of it has the
same pattern of data 4kB apart, it may be that there is a dive hiding in
there too (ie what I currently call a "header" may in fact be a header
_plus_ a dive).

But the 4kB thing may well be an artifact of the crazy scrambling code
itself.  Who knows what kind of chunking the Cochran Analyst
"encryption" uses.

As with the dive data, there seems to be some offset differences between
different CAN files.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agocochran: do the full de-scramble for one case
Linus Torvalds [Fri, 27 Jan 2012 22:10:55 +0000 (14:10 -0800)]
cochran: do the full de-scramble for one case

So this descrambles all the dives in *one* of my cochran test files.  I
still don't know what the dive data *means*, but it's not a random
jumble of bytes any more: there are very clear patterns.

However, the magic offsets that work for that particular CAN file are
not generic, because they don't work for another.  So there is some
magic dynamic decoding that I don't know about.  There is probably more
decode information in the initial decode block, over and beyond just the
scrambling bytes.

(The scrambling array is 234 bytes starting at 0x40001, but the first
actual *dive* data starts at 0x45e03, so there's tons of unknown stuff
in the file even outside the dives themselves)

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoMake cochran debug output a bit easier to use directly
Linus Torvalds [Fri, 27 Jan 2012 22:02:50 +0000 (14:02 -0800)]
Make cochran debug output a bit easier to use directly

Just do the hex-dump in the program, and print all the results to
standard output.  Avoid the need to do 'od' by hand etc to see what
happens when you play with the decoder.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAdd some initial cochran CAN file parsing
Linus Torvalds [Fri, 27 Jan 2012 20:43:40 +0000 (12:43 -0800)]
Add some initial cochran CAN file parsing

It's broken, and currently only writes out a debug output file per dive.
I'm not sure I'll ever really be able to decode the mess that is the
Cochran ANalyst stuff, but I have a few test files, along with separate
depth info from a couple of the dives in question, so in case this ever
works I can at least validate it to some degree.

The file format is definitely very intentionally obscured, though.
Annoying.  It's not like the Cochran software is actually all that good
(it's really quite a horribly nasty Windows-only app, I'm told).

Cochran Analyst is very much not the reason why people would buy those
computers.  So Cochran making their computers harder to use with other
software is just stupid.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoImport: always open and read the file before checking the filename extension
Linus Torvalds [Fri, 27 Jan 2012 18:56:36 +0000 (10:56 -0800)]
Import: always open and read the file before checking the filename extension

Most of the parsers will want the content in memory, so keep them
simple.  The fact that the Suunto parser uses "libzip" that has to
re-open the file is annoying and causes us to re-open the file etc.

But it's the odd man out, so don't design the "open_by_filename()"
function around it.  Pretty much everybody else will want to avoid
having to cook up their own IO routines.

Also, when reading the file, NUL-terminate the buffer.  This allows us
to just treat text files as large strings if we want to, and doesn't
matter for binary files (we still pass in the length explicitly).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoFix typo ('suundo' instead of 'suunto')
Linus Torvalds [Fri, 27 Jan 2012 16:11:24 +0000 (08:11 -0800)]
Fix typo ('suundo' instead of 'suunto')

I apparently was so congested that it affected my typing too when I
wrote that, and then copy-paste meant that the use and declaration
matched despite the misspelling.

Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAdd "native" Suunto SDE zip file reading
Linus Torvalds [Fri, 27 Jan 2012 01:43:33 +0000 (17:43 -0800)]
Add "native" Suunto SDE zip file reading

You need to have libzip-devel installed, and pkg-config needs to know about it
for the build to pick up on it.

On at least Fedora, a simple "yum install libzip-devel" will make things
work, although you may need to force a rebuild of subsurface too (the
"file.o" file in particular - the Makefile doesn't track system
dependencies).

Then, you can just do

   subsurface my-dives.SDE

to read the data directly from the SDE file.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoSplit up file reading from 'parse-xml.c' into 'file.c'
Linus Torvalds [Thu, 26 Jan 2012 21:00:45 +0000 (13:00 -0800)]
Split up file reading from 'parse-xml.c' into 'file.c'

We're going to eventually import non-xml files too, so let's begin
splitting the logic up.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoMerge branch 'info-split' of git://git.hohndel.org/subsurface
Linus Torvalds [Wed, 18 Jan 2012 04:02:33 +0000 (20:02 -0800)]
Merge branch 'info-split' of git://git.hohndel.org/subsurface

* 'info-split' of git://git.hohndel.org/subsurface:
  Add statistics for longest, shortest, and shallowest dive
  Create separate single dive and total stats pages
  Separate out single dive statistics and total statistics