Two things I disliked in Miika's code in commit cbb5bd125b03:
Having an integer variable named "something_iter" with all the GtkTreeIter
around was really confusing.
And having the yearly_iter as a global variable instead of cleanly passing
it around really seemed suboptimal.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This will update the yearly statistics window (if open) whenever there
are changes to the dive list.
I also added a check not to open multiple statistics windows.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Reworded commit message
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While most of this problem was fixed in commit 18b3dca431a4 ("Fix a long
standing bug when editing dives"), it turns out that I missed a couple of
the equipment callbacks.
In the corner case of having an empty divelist (where therefore
current_dive == NULL) manually adding a dive and trying to add equipment
(cylinder or weightsystem) to it would crash subsurface as we were trying
to dereference current_dive.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is just fixing an embarrassing oversight. Now we should prompt the
user about saving the file whenever something changes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The idea is based on Lubomir's code but the implementation is radically
different. Instead of having the preferences dialog be referenced by a
global variable we simply look up the appropriate ancestor of the current
widget.
Inspired-by: "Lubomir I. Ivanov" <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Always make sure to clear the memory allocated at the "existing_filename"
pointer when setting it to a new address or NULL.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Lifted these changes from a larger commit. The other changes I'll
reimplement in the next commit.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
VIProductVersion requires to have the version number in x.x.x.x format
so I added a separate constant SUBSURFACE_VIPRODUCTVERSION for that
purpose. Also renamed VERSION to SUBSURFACE_VERSION for consistency.
As Lubomir suggested on the mailing list, the installer will now delete
any DLL files found in the target folder to prevent buildup of old
versions of libraries when upgrading subsurface.
Signed-Off-By: Ivan Habunek <ivan.habunek@gmail.com>
Cleaned up whitespace issues
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Forgot to add "Uninstall.exe" to the uninstaller section, so the file and
the installation folder weren't being deleted on uninstall.
Signed-Off-By: Ivan Habunek <ivan.habunek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Also bumped version number to 1.2 (current release).
Signed-Off-By: Ivan Habunek <ivan.habunek@gmail.com>
More whitespace cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The existing windows installer looks very archaic and offers very few
configuration options. This script offers the following benefits:
* A modern appearence using NSIS Modern UI 2.0
* Shows the GPL license before install
* User can choose the target install folder
* Stores chosen installation folder in registry
* When installing a newer version on top of existing one, the existing
installation folder is offered by default
* It is possible to opt out of creating start menu shortcuts
Additional bug fixes:
* Added iconv.dll which was missing from the installer
* Replaced all path separators with backwars slashes, so that the script
works on both linux and windows
Signed-Off-By: Ivan Habunek <ivan.habunek@gmail.com>
Cleaned up whitespace
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
1) For safety reasons we no longer remove the default directory after
creating it. This prevents an access error (on windows) and also a couple
of small exploits that could have been possible, resulting in undefined
behaviour.
2) Once "default_filename" is allocated keep it until the value has to change.
The value is finaly released once the program is ready to close.
3) When picking a new default file, grab the new string directly from the
GSList.
4) When storing the new default file from the preferences dialog, make sure
we also update "existing_filename" if needed.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Fixed some whitespace issues, made commit message and one of the comments
in the code somewhat clearer.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
As usual, things work slightly different on Mac. Quartz delivers some (but not
all) accelerator notifications differently. Command-Q and Subsurface->Quit now
work on Mac as well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We are not allowed to free a string that we get back from the config APIs. So
strdup it instead to be compatible with Linux in that respect.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Calling edit from the context menu creates a combined editing widget that
contains both dive info and equipment. When editing cylinders or
weightsystems from that widget and confirming those edits with OK those
changes were already committed to the current_dive - regardless on which
dive the user clicked. Worse, even when the user clicked Cancel in the
edit widget, any changes to the equipment stayed in effect.
This had especially confusing consequences when editing multiple dives.
As a workaround this commit adds a global edit_dive variable. This fake
dive is edited by the secondary editing widgets and if the user accepts
changes with OK then they are copied over to the current dive (or all
selected dives in multi dive editing mode).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Replaced g_list_free_full with the inlined alternave:
g_list_foreach(dive_trip_list, (GFunc)free, NULL);
g_list_free(dive_trip_list);
once again my version on debian 6.0.x has libraries up-to-date yet outdated.
i guess i have to suggest against API which has the "Since <some ver>"
text and <some ver> is fairly recent on documentation webpages.
Signed-off-by: "Lubomir I. Ivanov" <neolit123@gmail.com>
I took only one hunk from the patch that Lubomir sent - the rest I
implemented differently in the previous commit.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
divelist.c:
Replaced "gtk_tree_path_get_indices_with_depth()" with the coupled alternative:
int depth = gtk_tree_path_get_depth(path);
int *indices = gtk_tree_path_get_indices(path);
for compatibility GTK+ < 2.22
*:
Replaced all usage of "cairo_rectangle_int_t" with "cairo_rectangle_t"
for compatibility with Cairo < 1.10.
Both modification make building Subsurface possible on a fairly recent Debian
distribution, which reports to have the version of the abovementioned
libraries "up-to-date", yet they are slightly outdated.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Display yearly statistics in a statistics window with option to expand
the viewing on monthly level. The amount of dives along with basic
information like duration, depth, water temperature and air consumption
is displayed in yearly and monthly level. Thus you are able to compare
e.g. development of air consumption or diving activity from year to
year.
Using already existing macro for splitting seconds into minutes:seconds.
Moving repetitive code to a function (couldn't think of the suggested
clever macro, but this should pretty much do the trick).
Now the statistics are updated every time the process_all_dives function
is called. It might make sense to actually verify the structures need to
be re-allocated, but such optimization is currently not implemented.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Combined two commits.
Minor cleanups for white space and boolean values.
Significant changes to use the correct units for volumes vs. depths and to
avoid unneccesary lookups of the model storage based on the tree.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Tests have shown that the most multi-platform way to do printing with GTK is
to use GTK_UNIT_INCH (or GTK_UNIT_MM) with GtkPrintOperation. Tested on
Linux, OSX, Windows.
However this requires the appropriate scaling for Pango and Cairo to be done,
with separate plotting logic for printing and drawing on the screen. To achieve
that, profile.c:plot() now accepts a scaling parameter from type
"scale_mode_t" defined in "display.h".
Also due to new scale, small decimal numbers (such as 6.12345) cannot be well
stored in "cairo_rectangle_int_t" therefore it is replaced with
"cairo_rectangle_t", which uses doubles to provide Cairo with a drawing
area.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Minor whitespace cleanup.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
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>
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>
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
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>
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
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>
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>
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>
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
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
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>