Commit graph

13838 commits

Author SHA1 Message Date
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
3b907d8479 Fix silly folder permission bug
I forgot to give the user execute permission on the folder that subsurface
might create to store the datafile in.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-10 14:39:07 -07:00
Dirk Hohndel
a8fd77865c Implement Close menu option that allows closing the data file
This requires some helper routines that allow us to clear out all the
widgets.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-10 14:32:55 -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
38d49bf041 Improve trip assignment for new dives
When first trying to deal with this I opted to go with a two pass appoach
which seemed easy as it used existing infrastructure, but turned out to
run into a couple of odd corner cases that would have been really ugly to
deal with.

So I threw this code away and am instead doing this in a single pass,
carefully checking as we go if there is an appropriate trip we can use.
To me the new code is much easier to read and seems much cleaner.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-10 11:04:58 -07:00
Linus Torvalds
3febfb74fa Merge branch 'ui-work' of git://git.hohndel.org/subsurface
Pull small UI updates from Dirk Hohndel:
 "Not sure if you like the change to the About screen.  :-)

  The other one is simply a small improvement for people importing xml
  files from the UI - it gets them an at least somewhat sane starting
  directory to work from."

* 'ui-work' of git://git.hohndel.org/subsurface:
  Set default path for file import to the last path opened
  Update the About screen
2012-09-11 00:57:15 +08: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
f51066fe40 Merge branch 'trip3' of git://git.hohndel.org/subsurface
Pull more trip handling fixes from Dirk Hohndel.

And the "delete dive" functionality too.

* 'trip3' of git://git.hohndel.org/subsurface:
  Implement delete dive option
  Make "create trip above" also add on selected dives
  Handle new dives correctly if trips exist
  Merge one or more dives with the trip above
2012-09-07 15:38:32 -07:00
Dirk Hohndel
d0867a79d4 Implement delete dive option
With this we can delete a dive from the context menu.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-07 13:09:29 -07:00
Dirk Hohndel
42bff28e47 Make "create trip above" also add on selected dives
This makes things more consistent with the merge with trip above option -
if multiple dives are selected then the consecutive set of selected top
level dives below the dive on which a user right-clicked are all added to
the newly created trip.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-07 10:58:36 -07:00
Dirk Hohndel
b49b081bb9 Handle new dives correctly if trips exist
There is an interesting issue when adding new dives into a dive list with
existing trips. Since fill_dive_list walks the list backwards and trips
are determined by the timestamp of the first dive in a trip, it is
non-trivial to know when a dive is added if it should be part of an
existing trip or not. Let's say when we see the dive we can also see a
trip entry that starts four days earlier. Without looking forward in the
list of dives we cannot tell if this is a multi-day trip that this dive
would fit into, or if there is a break of more than tree days (our current
trip threshold).

Instead this commit adds a second scan of the dives in chronological order
that does the right thing for new dives.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-07 10:12:31 -07:00
Dirk Hohndel
109dab56eb Set default path for file import to the last path opened
This may not be the path the import files are in, but it's better than the
current default of 'nothing'.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-06 14:31:38 -07:00
Dirk Hohndel
8c7c11c644 Update the About screen
Add the current year and the second main author, err, me.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-06 14:27:34 -07:00
Linus Torvalds
b681294631 Merge branch 'print_selection' of http://ambre.pingoured.fr/cgit/subsurface
Pull print selection checkbox update from Pierre-Yves Chibon.

Instead of implicitly always printing selected dives if there are more
than one, this makes it print them if the checkbox is selected.

* 'print_selection' of http://ambre.pingoured.fr/cgit/subsurface:
  Add the 'Print only selection' checkbox in the print options
2012-09-06 12:48:02 -07:00
Linus Torvalds
252c28f8f2 Merge branch 'trip3' of git://git.hohndel.org/subsurface
Pull trip manipulation branch from Dirk Hohndel:
 "I have added yet more of the requested features.

  I am not aware of any outstanding bugs or crashes (except for the Gtk
  problem that causes the import to crash for some people on Ubuntu and
  MacOS - but as I mentioned earlier, that bug has been around as long
  as the import file selector box)."

* 'trip3' of git://git.hohndel.org/subsurface:
  Avoid duplicate dive_trip entries
  More trip manipulations: remove selected dives from trip
  Add ability to merge trip with trip below
  Use the infrastructure for moving dives in more places
  Correct the trip related test dives
  Fix crash when removing the first dive of a trip
  Correctly initialize the toggle state of the autogroup menu entry
  Fix copy_tree_node to no longer overwrite dive duration
  Add autogen menu command
  Fix a crash when changing sort column
  Use truth values with gboolean
  Allow modification and edits of trips
  Clean up macros and auxiliary functions
  Store time_t as long value
2012-09-06 12:44:55 -07:00
Dirk Hohndel
6ddf0e1d22 Merge one or more dives with the trip above
Yet another trip manipulation function. The dive we are on (or that dive
and the selected dives below it) are merged into the trip directly above.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-06 12:43:57 -07:00
Dirk Hohndel
4679f4fbbc Avoid duplicate dive_trip entries
When inserting a trip into the dive_trip_list we already check for
duplicate trips, but we still kept the additional dive_trip around.

With this change we instead replace it with the existing one.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-05 13:54:22 -07:00
Dirk Hohndel
6d0af91398 More trip manipulations: remove selected dives from trip
There are a few obvious trip manipulations on multiple dives that haven't
been implemented, yet. This commit handles the case when we have multiple
dives selected and right click on one of them. It now removes all of those
dives from their trips (instead of just the one that we clicked on).

Still todo is the inverse operation. Select a group of consecutive dives
and turn them into a trip.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-05 13:31:56 -07:00
Dirk Hohndel
b9d74580d0 Add ability to merge trip with trip below
Miika suggested this - we should be able to merge with the trip below and
not just the trip above (oh, and call them "above/below" instead of
"previous").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-03 20:51:09 -07:00
Dirk Hohndel
70d254ab84 Use the infrastructure for moving dives in more places
Instead of using our generic helper function the code in
remove_from_trip_cb tried to implement the special case - and got it
wrong. This fixes yet another crash that Henrik found.

Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-03 20:46:09 -07:00
Linus Torvalds
d20428973a Make xml (and CSV) parsing use 'g_ascii_strtod()' rather than 'strtod()'
GTK messes up the standard C library locales by default (instead of just
taking locale information into account internally).  Which breaks
'strtod()' and 'printf()' etc.  Since they screwed that up, they then
added helper functions for undoing that braindamage.  Use it.

I'd like to blame the GTK people, but the standard C libary people bear
*some* responsibility for this.  One of the reasons why people do not
use "setlocale()" in many normal programs is exactly because it messes
up core libc functionality - with number conversion being the main
thing.

Doing things like converting numbers in a locale-specific manner is
something people do want to do, but not *always*.  So the C library
locale code should always had defaulted to C locale, with some *extra*
marker (like a printf/scanf modifier) to say "print/scan in the current
locale".

Because many things absoilutely need to be non-localized.  You don't
want your internal file format to magically change just because you want
to show things to the user in France, for example.

Reported-by: Ivan Habunek <ivan.habunek@gmail.com>
Root-caused-by: Jef Driesen <jefdriesen@telenet.be>
Cc: Dirk Hohndel <dirk@hohndel.org>
Cc: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-03 11:49:38 -07:00
Dirk Hohndel
2a1d7a510c Correct the trip related test dives
They still had the old "date only" format, but the code now relies on date
and time being both set.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-03 10:31:25 -07:00
Dirk Hohndel
1f252fedd1 Fix crash when removing the first dive of a trip
The update_trip_timestamp function can indeed get called with no children
present, just before that trip is then removed. So instead of adding
complicated special cases, this just bails out of the function.

Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-03 10:30:48 -07:00
Dirk Hohndel
8b021de8d9 Correctly initialize the toggle state of the autogroup menu entry
If we move to Linus' tri-state variable we need to separate those two
items, anyway. But for now this fixes the obvious bug.

Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-03 08:09:56 -07:00
Dirk Hohndel
f4f5536bad Fix copy_tree_node to no longer overwrite dive duration
Cut and paste error when creating this function.

Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-03 08:09:45 -07:00
Pierre-Yves Chibon
fd29a68a13 Add the 'Print only selection' checkbox in the print options
With this commit, if few dives are selected by default it will
only print the selected dives but in the option panel there is
a checkbox that allows to print all dives and not only the
selection.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2012-09-03 10:20:56 +02:00
Dirk Hohndel
f6e8903a52 Add autogen menu command
This adds the ability to auto create trips from the menu. It's a toggle
entry (and while at it, we made the zoom toggle a toggle entry as well).
We can therfore switch back and forth between auto generated trips.

There is one bug. Assume you have no trips. You manually create a trip
from some dives out of a group of trips that autogen would turn into a
trip. Now you turn on autogen and this trip gets expanded with all the
dives that would normally be grouped together. If you turn off autogen
again, all those dives are still part of the remaining (initially manually
created) trip. Working around this issue seemed a lot more work than the
likelihood of anyone running into it seemed worth.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-02 21:50:43 -07:00
Dirk Hohndel
22ff8df880 Fix a crash when changing sort column
We were using the tree model to check the selection, even though the
active model is the list model after switching to a different sort column.

To make things clearer I renamed the access macros to be more consistent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-02 21:46:48 -07:00
Linus Torvalds
9b1f9cfd3a Merge branch 'separator-line' of git://github.com/henrik242/subsurface
Apparently on OS X the separator line is all alone at the end.

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

* 'separator-line' of git://github.com/henrik242/subsurface:
  Remove separator line in MacOSX File menu
2012-09-02 11:39:02 -07:00
Dirk Hohndel
ea2900a34a Use truth values with gboolean
Just a little cosmetic oversight

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-02 11:17:31 -07:00
Dirk Hohndel
c3debc10fd Allow modification and edits of trips
Now that we can load and store trips we needed to add the capability to
manipulate those trips as well.

This commit allows us remove a dive from a trip via a right click
operation on the dive list.

The commit also adds code to split a trip into two, to merge two trips and
to create a new trip out of a top level dive.

To make all that useful this commit changes the right-click on the dive
list to identify and act on the record we are actually on (instead of
acting on the selection).

The right-click menu ("context menu") changes depending which divelist
entry the mouse pointer is on - so different operations are offered,
depending on where you are.

We also add simplistic editing of location and notes for a trip (but the
notes are never displayed so far).

To make our lives easier this commit adds a link from the dive to the dive
trip it is part of. This allowed to hugely simplify the auto trip
generation algorithm (among other things). The downside of this change is
that there are now three different ways in which we express the
relationship of dives and trips: in the dive_trip_list, in the tree_model,
and with these pointers.  Somehow this screams that I should rethink my
data structures...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-01 21:29:05 -07:00
Dirk Hohndel
a5f894d1d3 Clean up macros and auxiliary functions
In preparation for the next stage of the trips handling this commit makes
the macros used to access trips (and some frequently used variables for
the tree and list models) more consistent.

This also changes the way we display un-grouped dives in the dive list,
i.e. dives that are not part of a dive trip. Their dive number is now
printed bold.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-01 20:45:34 -07:00
Dirk Hohndel
ca16f438ac Store time_t as long value
The tree_storage only provided enough space for an int for DIVE_DATE. But
at least on 64bit Linux, an int is 32bit yet a time_t is 64bit. Until 2038
this only causes issues in some odd situations, after 2038 this would be
an obvious bug.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-01 20:41:03 -07:00
Linus Torvalds
6a210e573d Add support for printing only the selected dives
Right now we just implicitly decide "print only selected dives" when
there is more than one dive selected (and then print all dives if only
one dive is selected).

We probably should have an checkbutton in the dive details page for the
choice.  But I wanted to avoid the pain that is gtk as far as possible
for the initial implementation.  The code is ready to be changed to just
use a checkbutton instead.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-30 09:30:59 -07:00
Linus Torvalds
348afc3f57 Merge branch 'print_table' of http://ambre.pingoured.fr/cgit/subsurface
Pull table printing improvements from Pierre-Yves Chibon:
 "I cleaned up the print options as asked so that we only have the
  choice between the "pretty-print" and the "table-print".

  The table layout has been improved."

* 'print_table' of http://ambre.pingoured.fr/cgit/subsurface:
  Remove the pretty-print without dive profile option.
  Have a nice table formating with choosing the 'Table print' option.
  Invert the print 'dive profile' option.
  Deactivate 'Show profiles' if 'table print' is checked.
2012-08-30 09:15:50 -07:00
Linus Torvalds
d93830a6eb Merge branch 'divetrip-nr' of git://git.hohndel.org/subsurface
Pull divetrip nr cleanup from Dirk Hohndel:
 "We don't need to manually track this - gtk gives us this number
  without any problems."

* 'divetrip-nr' of git://git.hohndel.org/subsurface:
  Stop tracking the number of dives in a dive trip
2012-08-30 09:14:51 -07:00
Pierre-Yves Chibon
e7abde4868 Remove the pretty-print without dive profile option.
Until now we had the choice between:
- pretty-print 
  - with dive profiles
  - without dive profiles
- table-print

This commit remove the pretty-print without dive profiles, leaving the choice to
either pretty-print or table-print.



Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2012-08-30 09:23:17 +02:00
Dirk Hohndel
688ac57c7b Stop tracking the number of dives in a dive trip
Gtk tracks this for us as the number of children of the treeview node.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-29 22:01:06 -07:00
Mikko Rasa
d6b50e30e4 Fix profile and average depth for freedives
Freedives can easily exceed the assumed ascent/descent rate, which
results in wacky dive profiles.  Add a check to make the ascent and
descent fit within the duration of the dive.
2012-08-29 19:12:18 +03:00
Pierre-Yves Chibon
823f266eea Have a nice table formating with choosing the 'Table print' option.
With this commit we finally have a nice table output when we want to print the
list of dives with minimal information.


Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2012-08-29 18:02:47 +02:00
Pierre-Yves Chibon
c4eeda1ef7 Invert the print 'dive profile' option.
With this change, instead of asking to print the dive profile,
you ask to not print them. So the checkbox in the print options
changes from 'Show profiles' to 'No dive profiles'.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2012-08-29 10:44:34 +02:00
Pierre-Yves Chibon
eef0e9e699 Deactivate 'Show profiles' if 'table print' is checked.
This bug was reported by Henrik Brautaset Aronsen, it was happening
when:
"""you select table print, perform the print and then open the print
dialogue again""". In such case the 'Show profiles' button was
activated while the 'Print table' type was selected.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2012-08-29 10:05:53 +02:00
Linus Torvalds
9d46581913 Merge branch 'freediving-tweaks' of git://github.com/mguentner/subsurface
Merge freediving tweaks (zoom in on short dives etc) from Maximilian
Güntner.

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

* 'freediving-tweaks' of git://github.com/mguentner/subsurface:
  moved zoomed_plot to display.h
  plot the time with a fixed padding (leading zero)
  updated/corrected comment
  added "Zoom" button and improved scaling
  fixed indentation
  use increments that make sense for 600 seconds
  Plot shorter (apnea) dives with a reasonable scale
2012-08-28 13:20:23 -07:00
Linus Torvalds
e4955f9be1 Merge git://git.tdb.fi/ext/subsurface
Pull a few buglet fixes from Mikko Rasa.

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

* git://git.tdb.fi/ext/subsurface:
  Check if multi-dive editing is actually needed
  Fix an off-by-one error in buffer allocation
2012-08-28 13:16:57 -07:00
Pierre-Yves Chibon
490e98dadf Work on the printing of the dives, first attempt to print as table.
With this commit, the user can choose between two printing modes:
- pretty print (with or without the dive profile)
- table print (which is nothing less than a table formating containing the
information)

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2012-08-28 18:07:13 +02:00
Pierre-Yves Chibon
57af78bda0 Remove include not present in new libdivecomputer.
The include of libdivecomputer/utils.h breaks the compilation
of subsurface as it is no longer present in the latest version
of libdivecomputer.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2012-08-28 11:27:31 +02:00
Lubomir I. Ivanov
4daa61756e make the font size the same when printing on win32/linux
Setting the cairo transformation units (..?) to GTK_UNIT_POINTS makes
the font size the same on windows as on linux, when printing.  Otherwise
the text is unreadable ie way too small.

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

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-27 15:48:39 -07:00
Linus Torvalds
c89f88378a Merge branch 'trips' of git://git.hohndel.org/subsurface
Merge the initial 'track trips explicitly' code from Dirk Hohndel.

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

* 'trips' of git://git.hohndel.org/subsurface:
  Fix an issue with trips that have dives from multiple input files
  Some simple test dives for the trips code
  First cut of explicit trip tracking
2012-08-27 15:36:27 -07:00
Dirk Hohndel
9cf961249e Fix an issue with trips that have dives from multiple input files
The existing code didn't handle the case of different trips for the same
date coming from different sources. It also got confused if the first dive
processed (which is, chronologically, the last dive) happened to be a
"NOTRIP" dive.

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

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-27 15:29:40 -07:00
Linus Torvalds
a44d0049f6 Update for new libdivecomputer interfaces
For this you need to get the current libdivecomputer tree, reconfigure,
build and install it first.  But this cleans up some of the silly error
handling too, and has just a single "dc_device_close()" call etc, rather
than duplicating that (and the new dc_context_free()).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-27 15:06:58 -07:00