Commit graph

120 commits

Author SHA1 Message Date
Lubomir I. Ivanov
2af818bf91 Fixed some memory leaks in windows.c and main.c
windows.c:subsurface_gettext_domainpath():
- memory at pointer returned from g_win32_getlocale() should be released

main.c:setup_system_prefs()
- it seems all calls to <os_file>:system_default_filename()
return a pre-allocated buffer, therefore we don't need to call strdup()
on the result itself.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 11:38:51 -08:00
Dirk Hohndel
ebcbe5aedd Finish removing accesses to first divecomputer instead of dive
This adds watertemp and airtemp to the dive, populates them in fixup and
uses them elsewhere in the code.

WARNING: as a sideeffect we now edit the airtemp in the dive, but we never
display this in the DIve Info notebook (as that always displays the data
from the specific selected divecomputer). This is likely to cause
confusion. It's consistent behavior, but... odd. This brings back the
desire to have a view of "best data available" for a dive, in addition to
the "per divecomputer" view. This would also allow us to consolidate the
different pressure graphs we may be getting from different divecomputers
(consider the case where you dive with multiple air integrated computers
that are connected to different tanks - now we could have one profile with
all the correct tank pressure plots overlayed - and the best available (or
edited) data in the corresponding Dive Info notebook.

This commit also fixes a few remaining accesses to the first divecomputer
that fell through the cracks earlier and does a couple of other related
cleanups.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 07:41:15 -08:00
Dirk Hohndel
635c28923d Better algorithm to merge gps locations & locations names from webservice
This no longer abuses the dive merging code (which would leave stray
"dives" behind if a gps fix couldn't be merged with any of the dives) and
instead parses the gps fixes into a second table and then walks that table
and tries to find matching dives.

The code tries to be reasonably smart about this. If we have
auto-generated GPS fixes at regular intervals, we look for a fix that is
during a dive (that's likely when the boat where the phone is staying dry
is more or less above the diver having fun). And if we have named entries
(so the user typed in a location name) we try to match them in order to
the dives that happened "that day" (where "that day" is about 6h before
and after the timestamp of the gps fix).

This commit also renames dive_has_location() to dive_has_gps_location() as
the difference between if(!dive->location) and if(dives_has_location) is a
bit too subtle...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-31 14:29:02 +11:00
Dirk Hohndel
e3a8ed5183 Massive cleanup
Mostly coding style and whitespace changes plus making lots of functions
static that have no need to be extern. This also helped find a bit of code
that is actually no longer used.

This should have absolutely no functional impact - all changes should be
purely cosmetic. But it removes a bunch of lines of code and makes the
rest easier to read.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-30 08:31:53 +11:00
Dirk Hohndel
29ae8cb131 Don't set a default filename when called with multiple filenames
The behavior is just too illogical - it's too easy to unintentionally
overwrite a file this way. The default filename is set if we have exactly
one filename on the command line or if we we open the default file.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 20:01:18 -08:00
Linus Torvalds
7c26432186 Don't mark divelist changed for automated merges after all
The intention was good, and this was added in commit 4982389ca7 ("Fix
setting of the dive_table.preexisting logic"), but it turns out to not
be that great idea after all.

So the thinking is that merging two dives clearly changes the dive list,
and it really does.  At the same time, because it's an automated merge,
if you re-read the old XML file, you'll get it done again, so saving the
changes doesn't really *matter*.

And it turns out to be somewhat annoying with test dives: we have

 - dives/test23.xml:
    <dive number='23' tripflag='INTRIP' date='2011-12-02' time='6:00:00' duration='30:00 min'>
 - dives/test25.xml:
    <dive number='26' date='2011-12-02' time='6:00:00' duration='30:00 min'>

that merge automatically if you run subsurface on all the test dives
together.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 19:53:54 -08:00
Dirk Hohndel
100c400809 Merge branch 'webservice-import'
Update maxdepth / duration that have moved into the divecomputer
structure.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 12:05:16 -08:00
Linus Torvalds
4982389ca7 Fix setting of the dive_table.preexisting logic
The 'preexisting' value is used for downloading dives: we want to add
new dives but, but then compare those new dives against the
preexisting ones before we start sorting things and possibly merging
them.

However, the value was only updated sporadically, resulting in it
having stale information in it.  Which would cause problems
particularly if you deleted dives, so that the preexisting value would
point past the actual existing values!

So just update it unconditionally in dive_list_update_dives(), which
anything that changes the dive list is supposed to call in order to
display the changes anyway.

Also, just for safety, when removing a dive, put NULL in the last dive
table location.  Nobody should ever access past the end anyway (this
is enforced by 'get_dive()') but there are places that access the dive
list table directly, and the libdivecomputer download was one of
those.  No reason to leave stale dive pointers possibly around for
uses like that.

Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23 13:37:02 -08:00
Linus Torvalds
b6c9301e58 Move more dive computer filled data to the divecomputer structure
This moves the fields 'duration', 'surfacetime', 'maxdepth',
'meandepth', 'airtemp', 'watertemp', 'salinity' and 'surface_pressure'
to the per-divecomputer data structure.  They are filled in by the dive
computer, and normally not edited.

NOTE! All actual *use* of this data was then changed from dive->field to
dive->dc.field programmatically with a shell-script and sed, and the
result then edited for details.  So while the XML save and restore code
has been updated, all the displaying etc will currently always just show
the first dive computer entry.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23 12:55:33 -08:00
Dirk Hohndel
c521aec884 Import and merge GPS data from the webservice
Dive locations marked (and named) via the companion app are downloaded
from the webservice, parsed and merged with the existing dives.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23 11:53:42 -08:00
Dirk Hohndel
23ce727e62 Add support for MOD, EAD, AND and EADD in the mouse over display
- MOD: Maximum Operation Depth based on a configurable limit
- EAD: Equivalent Air Depth considering N2 and (!) O2 narcotic
- END: Equivalent Nitrogen (Narcotic) Depth considering just N2 narcotic
       (ignoring O2)
- EADD: Equivalent Air Density Depth

Please note that some people and even diving organisations have opposite
definitions for EAD and END. Considering A stands for Air, lets choose the
above. And considering N for Nitrogen it also fits in this scheme.

This patch moves N2_IN_AIR from deco.c to dive.h as this is already used
in several places and might be useful for future use also. It also
respecifies N2_IN_AIR to a more correct value of 78,084%, the former one
also included all other gases than oxygen appearing in air. If someone
needs to use the former value it would be more correct to use 1-O2_IN_AIR
instead.

Signed-off-by: Jan Schubert / Jan.Schubert@GMX.li
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-13 16:26:35 -08:00
Linus Torvalds
6a10700ca5 Add default filename and divelist font to prefs structure
.. and add the usual logic to not save the default values.

This also simplifies the initial system-specific setup of both of these:
since we have defaults for all the preferences that get set up at
startup, we can just initialize those defaults to the system-specific
fonts then and there.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-11 17:46:00 -08:00
Linus Torvalds
21f38190d3 Make the default preferences explicit
This makes it explicit what the default preferences are, so that we can
more easily avoid unnecessarily saving default settings.  It also makes
imperial metrics the default for the US (Burma and Liberia always get
forgotten!)

Right now we tend to be somewhat confused about defaults.  We do have
them, but then even if something has a default value, we tend to write
it out to the config file.  Which is not just unnecessary, but makes it
really hard to see after-the-fact whether the user actually wanted that
*specific* value, or whether they just wanted the default behavior.

So this prepares for having explicit configuration for when we want
something different than the defaults.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-10 20:30:45 -08:00
Linus Torvalds
868a2cc090 Split up preference data structure definition into 'pref.h'
.. and rename the badly named 'output_units/input_units' variables.

We used to have this confusing thing where we had two different units
(input vs output) that *look* like they are mirror images, but in fact
"output_units" was the user units, and "input_units" are the XML parsing
units.

So this renames them to be clearer.  "output_units" is now just "units"
(it's the units a user would ever see), and "input_units" is now
"xml_parsing_units" and set by the XML file parsers to reflect the units
of the parsed file.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-10 20:30:32 -08:00
Dirk Hohndel
50aa6d1afa Imrpove the nickname handling
We now store the model information together with the deviceid and nickname
in order to be able to check if we have a record for any dive computer
with the same model (as that now triggers our nickname dialog).

This changes the format of the config entries for nicknames - the best
solution might be to just delete those and start again.

What is still missing is the code to store the nicknames in the XML file.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-22 20:14:34 -08:00
Dirk Hohndel
8d2abc05f6 Remove nickname from divecomputer data structure
Having it there with the model information seemed to make sense but on
second thought it's the wrong spot to keep that information, especially
since we were storing it in the XML file in every single dive.

This change removes the nickname member from the divecomputer and makes
the rest of the code reasonably self consistent. It does not add much of
the new code for the new design to handle nicknames.

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

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

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-13 21:33:30 -10:00
Dirk Hohndel
0141b69d0a When starting with an empty data file and downloading dives, number them
We have been very careful not to mess with the numbering that a user may
intend - but one obvious case where we should automatically number the
dives appears to be the first time download from a dive computer. Right
now all dives show up with number '0' and that's just really ugly and a
bad experience for a first time user.

With this change if a user starts with an empty data file and downloads
dives from a computer for the first time, Subsurface will give them
numbers starting with '1'.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-05 09:34:00 -08:00
Dirk Hohndel
fe4f13f184 Add special download modes to force updates from the divecomputer
This will hopefully not be something we need often, but if we improve
support for a divecomputer (either in libdivecomputer or in our native
Uemis code or even in the way we handle (and potentially discard) events),
then it is extremely useful to be able to say "re-download things
from the divecomputer and for things that were not edited in Subsurface,
don't try to merge the data (which gives BAD results if for example you
fixed a bug in the depth calculation in libdivecomputer) but instead
simply take the samples, the events and some of the other unedited data
straight from the download".

This commit implements just that - a "force download" checkbox in the
download dialog that makes us reimport all dives from the dive computer,
even the ones we already have, and an "always prefer downloaded dive"
checkbox that then tells Subsurface not to merge but simply to take the
data from the downloaded dive - without overwriting the things we have
already edited in Subsurface (like location, buddy, equipment, etc).

This, as a precaution, refuses to merge dives that don't have identical
start times. So if you have edited the date / time of a dive or if you
have previously merged your dive with a different dive computer (and
therefore modified samples and events) you are out of luck.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11 14:29:26 +01:00
Linus Torvalds
8514ec8723 Support merging of two adjacent dives
This introduces the notion of merging two disjoint dives: you can select
two dives from the dive list, and if the selection is exactly two dives,
and they are adjacent (and share the same dive trip), we support the
notion of merging the dives into one dive.

The most common reason for this is an extended surface event, which made
the dive computer decide that the dive was ended, but maybe you were
just waiting for a buddy or a student at the surface, and you want to
stitch together two dives into one.

There are still details to be sorted out: my Suunto dive computers don't
actually do surface samples at the beginning or end of the dive, so when
you stitch two dives together, the profile ends up being this odd "a
couple of feet under water between the two parts of the dive" thing.

But that's an independent thing from the actual merging logic, and I'll
work on that separately.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11 10:48:14 +01:00
Linus Torvalds
cda1b73bf6 Prepare to merge non-overlapping dives
This just re-organizes the dive merging code so that we expose a new
"merge_dives(a, b, offset)" function that merges two dives together into
one with the samples (and events) of 'b' at the specified offset after
'a'.

We'll want to use this if a dive computer has decided that the dive
ended (due to a pause at the surface), but we really want to just turn
the two computer dives into one long one with an extended surface swim.

No functional changes, but some independent cleanups due to the trip
simplifications.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11 10:48:09 +01:00
Linus Torvalds
7f515eb7e5 Fix dive trip merging logic
We used to have very spotty logic for picking the dive trip when
merging two dives. It turns out that that spotty logic almost never
really matters, because in practice you'll never hit the situation of
merging two dives with different dive trips, but it *can* happen.

In particular, it happens when you use multiple dive computers, and
end up loading the dives from one computer on top of the dives of your
other computer. If the clocks of the dive computers was set
sufficiently close to each other, the dive merging logic will kick in
and you may now have slightly different times for the dives that get
merged, and the trip merging logic got *really* confused.

The trip management also depends on the trip dates being updated
correctly when the dives associated with a trip are updated (whether
added or removed), and the trip merging code did none of that.

This fixes it all up. Hopefully correctly.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-09 21:46:56 +01:00
Dirk Hohndel
d5ac38d9ed Allow debug output to go either to log file or to stderr
This makes it easier to debug things in a debugger, but the infrastructure
to send out debug builds where an end user can send in a useful logfile is
still in place.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-25 20:12:44 -07:00
Dirk Hohndel
0fc3a446e9 Don't enable equipment notebook buttons if there is no dive
The buttons didn't actually do anything when clicked, but this still
was inconsistent behavior.

Reported-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-18 20:45:26 -07:00
Dirk Hohndel
834825f406 Find translation files on Linux after Subsurface was installed
So far we only looked in the a local subdirectory, but once Subsurface has
been installed, we don't need to change the search path for translation
files anymore.

Fixes #2

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-18 14:30:45 -07:00
Dirk Hohndel
f97f75f961 Set locale under Windows
This is mostly a quick hack to be able to test localization under Windows.
It seems to work fine under Windows 7

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-15 16:32:11 -07:00
Dirk Hohndel
9b9e36886c Forgot to localize names of months and weekdays
We marked the strings for translation, but then didn't actually call the
translation function on them.

Our dates are still not truely localized as we have hand written code for
the date / time handling that constructs the dates according to US fashion
as [Weekday], [Month] [Day of Month], [Year] [hh:mm]

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-15 14:37:59 -07:00
Henrik Brautaset Aronsen
ef039c9d32 Support for gettext in MacOSX application bundle
The MacOSX applications bundle needs to be told where to bind the
text domain from.

Also copy the gettext .mo files in the install-macosx target.

[Dirk Hohndel: minor change in main(): move the path declaration to
               the beginning of the function]

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-15 09:36:30 -07:00
Dirk Hohndel
99846da77f Conversion to gettext to allow localization
This is just the first step - convert the string literals, try to catch
all the places where this isn't possible and the program needs to convert
string constants at runtime (those are the N_ macros).

Add a very rough first German localization so I can at least test what I
have done. Seriously, I have never used a localized OS, so I am certain
that I have many of the 'standard' translations wrong. Someone please take
over :-)

Major issues with this:

- right now it hardcodes the search path for the message catalog to be
  ./locale - that's of course bogus, but it works well while doing initial
  testing. Once the tooling support is there we just should use the OS
  default.

- even though de_DE defaults to ISO-8859-15 (or ISO-8859-1 - the internets
  can't seem to agree) I went with UTF-8 as that is what Gtk appears to
  want to use internally. ISO-8859-15 encoded .mo files create funny
  looking artefacts instead of Umlaute.

- no support at all in the Makefile - I was hoping someone with more
  experience in how to best set this up would contribute a good set of
  Makefile rules - likely this will help fix the first issue in that it
  will also install the .mo file(s) in the correct place(s)

  For now simply run

  msgfmt -c -o subsurface.mo deutsch.po

  to create the subsurface.mo file and then move it to
  ./locale/de_DE.UTF-8/LC_MESSAGES/subsurface.mo

  If you make changes to the sources and need to add new strings to be
  translated, this is what seems to work (again, should be tooled through
  the Makefile):

  xgettext -o subsurface-new.pot -s -k_ -kN_ --add-comments="++GETTEXT" *.c
  msgmerge -s -U po/deutsch.po subsurface-new.pot

  If you do this PLEASE do one commit that just has the new msgid as
  changes in line numbers create a TON of diff-noise. Do changes to
  translations in a SEPARATE commit.

- no testing at all on Windows or Mac
  It builds on Windows :-)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-11 10:03:03 +09:00
Dirk Hohndel
a2afe41280 A file that we import should never become the default file we save to
Only files that are opened should be considered r/w. Files that are
imported should be treated as if they were r/o.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-09 21:50:16 +09:00
Lubomir I. Ivanov
f928be5061 Provide a method to use unicode command line arguments on Windows
For unicode command line characters Windows uses UTF-16, while Glib
and GTK use UTF-8. To solve that we retrieve the command line
via __wgetmainargs() and use g_utf16_to_utf8() to convert each argument.

The used method should support wildcards passed as arguments
(e.g. *.xml).

Two new, OS abstracted functions appear in linux.c (NOP), macos.c (NOP),
windows.c:

subsurface_command_line_init(...)
subsurface_command_line_exit(...)

which are being called in main()

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-04 03:12:19 -07:00
Dirk Hohndel
24c6197c10 Fix a number of obvious memory leaks
Just the result of cppcheck and valgrind...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-29 20:58:26 -07:00
Dirk Hohndel
5305fb152b Add the ability to create a log file for debugging output
Especially when asking non-developers for help debugging a problem it can
be extremely useful to have debugging output not go to the console but to
a log file instead.

This just adds the infrastructure to create (and close) such a file. No
changes to the debug output are made.

All this is of course #ifdef'ed out.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-26 08:34:39 -07:00
Lubomir I. Ivanov
7226a48a8c Call xmlCleanupParser only once - when we are done with libxml
Calling xmlCleanupParser in parse-xml.c:parse_xml_buffer()
caused massive memory corruption mostly affecting gtk's FileChooser
dialogs and the application menu.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-18 18:57:52 -04:00
Dirk Hohndel
d7465129bb Make sure dive info is displayed correctly at start
Commit cdae2869d1dd ("Show the datafile name even with no dives") was a
little too aggressive in making sure that we show the correct window title
- we only should call show_dive_info(NULL) if there is indeed no dive in
the dive table - otherwise we display empty dive info at program start.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17 21:03:30 -04:00
Dirk Hohndel
fa2f1b6eb0 Fix potential crash when importing dives
If the last of the preexisting dives gets merged with a new dive we end up
dereferencing a freed pointer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17 21:03:30 -04:00
Dirk Hohndel
0d637c2fa9 Show the datafile name even with no dives
That's especially useful if starting without a filename and without an
existing default file - this way it's clear that Subsurface still
considers itself synced with the default file.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17 21:03:30 -04:00
Dirk Hohndel
b4d55c8b59 Change the definition of "dive table changed"
We only ask to save changes if the dive table was changed. Yet we didn't
consider the dive table changed if it was initially empty. So starting
with an empty file and making changes we were quitting without saving.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-10 14:44:48 -07:00
Dirk Hohndel
78c5aa9f07 Change behavior for the existing filename
Previously we always picked the last file that was openend as the file
name to save to. That seems counterintuitive when importing files or when
opening multiple files. Especially if Subsurface was executed without a
file on the command line and we are using the default file.

Now we only remember a file name if it was the first one to ever be
openend or if it was used in save-as.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-10 12:27:00 -07:00
Dirk Hohndel
b73f29fea3 First cut of adding a default file name
The default file name is OS specific and tries to follow the customs on
each of the OSs. It can be configured through the preferences dialog.

On MacOS we get a strange warning which appears to be a well documented
Gtk bug on MacOS.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-09 17:38:01 -07:00
Linus Torvalds
9380f78c82 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>
2012-08-26 14:41:05 -07:00
Dirk Hohndel
621761233b 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>
2012-08-15 15:32:36 -07:00
Linus Torvalds
725e4582d9 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>
2012-05-02 10:03:48 -07:00
Linus Torvalds
4d10bc017a 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>
2012-01-26 13:00:45 -08:00
Dirk Hohndel
c544226334 Avoiding some potentially confusing name space clashes
We have local variables or function arguments with the same names as
function static variables (or in one case, function arguments).

While all the current code was correct, it could potentially cause
confusion when chasing bugs or reviewing patches. This should make things
clearer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-05 08:55:18 -08:00
Linus Torvalds
1efcf4538b Make double-clicking on the dive list bring up the dive editor
Now that the dive info window is read-only, we need to edit the dives
some other way.  We bring up a dive info edit dialog when you
double-click on the dive list entry for that dive.

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

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-19 10:11:56 -05:00
Linus Torvalds
55352a051c Merge branch 'add-info-stats-page' of git://github.com/dirkhh/subsurface
* 'add-info-stats-page' of git://github.com/dirkhh/subsurface:
  Add Info & Stats page to the notebook
  Even more places with pressure and volume conversions
  Further cleanup of pressure and volume conversions
  Use unit functions to get column headers, add unit function for pressure
  More consistency improvements
  Add new helper function to get temperature and unit
2011-11-02 12:39:55 -07:00
Dirk Hohndel
619ab9e828 Add Info & Stats page to the notebook
This provides the relevant information for the currently selected dive
plus a bunch of statistics over all dives in the dive_table.

The visual design has lots of room for improvement
- right now the different fields change size
- it might be nice to have a more modern look for the entries
- the O2/He field is odd - for most divers the He value will
  always be 0, so maybe we should only show He if there's at least one
  dive that uses He? Also, we simply do a comma separated list of gases
  for all the tanks used

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-02 12:27:12 -07:00
Linus Torvalds
e4bfb65972 Fix 'init_ui()' so that it can change argc/argv
That's what gtk_init() does with gtk-specific arguments.  IOW, if you do
things like

   subsurface --g-fatal-warnings dives.xml

to get a real abort on gtk warnings, gtk_init needs to be able to
actually change argc/argv.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-01 17:09:15 -07:00
Henrik Brautaset Aronsen
f231ab0943 Ignore process serial number argument when run as native MacOSX app
The subsurface binary is invoked with a -psn_x_xxxxxx argument when started from
a native MacOSX app bundle.

Signed-Off-By: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
2011-10-31 09:49:04 +01:00