summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2012-09-17Simplify code in file_open as we now only open one fileGravatar Dirk Hohndel
This doesn't change functionality - it's just pointless to loop over a list that is known to have only one element. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Don't close existing data file in file_open if user cancelsGravatar Dirk Hohndel
This logic seems to make much more sense - if the user hits 'OK' then the old file is closed and the new one openened. Otherwise, leave things unchanged. Reported-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Once again improve existing filename handlingGravatar Dirk Hohndel
Several potential problems. - we could end up dereferencing exiting_filename when it was NULL - we could free the default_filename by mistake - subsurface_default_filename always needs to return a copy of it - closing the existing file before opening a new one repopulated the existing_filename with the default filename - preventing the opened file to become the new existing filename Also, make existing filename a const char * and make file_open have the same sensible default folder behavior as the other file related functions. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Fix potential crash when importing divesGravatar Dirk Hohndel
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-17Correctly deal with empty XML filesGravatar Dirk Hohndel
Previously we could end up with a bogus dive with all zero data in it. Adding dives/test24.xml to be able to test that we handle this case correctly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Show the datafile name even with no divesGravatar Dirk Hohndel
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-17Mark divelist unchanged after closing the datafileGravatar Dirk Hohndel
This seems rather obvious - I'm surprised I didn't notice it earlier. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Put creation of the file selector box filter into helper functionGravatar Dirk Hohndel
This avoids duplication of code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Reimplement the GtkFileChooserButton for importGravatar Dirk Hohndel
One of the limitations of GtkFileChooserButton is that it only allows one file to be chosen (so that it can display that file name in the button after the file chooser dialog finishes). Since in the import dialog we never want to show the button with the filename(s) filled in but want to directly execute the import once files have been selected, I reimplemented the button to simply open a multi file chooser when clicked and to then run the import function if one or more file names were selected. This does appear to require some more code but gets us a much more useful and consistent implementation. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17The Open menu entry should open just one fileGravatar Dirk Hohndel
The single file that is our new data file (and the file that we'll change if it was modified). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Move Import menu entry back to File menuGravatar Dirk Hohndel
This should make things more consistent, especially now that "Open" actually does just that and no longer behaves almost like "Import". The downside is that the import from a dive computer is now in the File menu as well and no longer in the Log menu, where Linus originally had moved it to in commit 3cace090989b. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17File Open now closes the previous file, firstGravatar Dirk Hohndel
This is a pretty significant semantic change - Open used to act more like Import; you added more dives to the divelist. With this change it instead acts more like the traditional File->Open in that it closes the previous file, first. The diff hides the minimalistic nature of the change - it seemed cleaner to move the file_open function around than to do a forward declaration of file_close. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Display current filename in windows titleGravatar Dirk Hohndel
This seems to make sense since we have a pretty strong concept of the "active file" that we are working on. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-15Don't show an error if we can't load the default fileGravatar Dirk Hohndel
The user may not have created it, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-13Use glib file and pathname functionsGravatar Dirk Hohndel
My silly reimplementation of these functions was broken on Windows, anyway. This is much cleaner. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-13Prevent the preferences dialog from getting focus with file selector openGravatar Dirk Hohndel
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>
2012-09-13Fix memory leaks and one potential NULL dereferenceGravatar Dirk Hohndel
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>
2012-09-12various small fixes to the defaultfile modelGravatar Lubomir I. Ivanov
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>
2012-09-12Make sure Subsurface receives Quit / Command-Q callback on MacGravatar Dirk Hohndel
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>
2012-09-11Fix memory handling error on MacOSGravatar Dirk Hohndel
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>
2012-09-11Inline g_list_free_full for better compatibilityGravatar Lubomir I. Ivanov
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>
2012-09-11Use glibio functions for mkdirGravatar Dirk Hohndel
Suggested-by: Jef Driesen <jefdriesen@telenet.be> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-10Change the definition of "dive table changed"Gravatar Dirk Hohndel
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-10Fix silly folder permission bugGravatar Dirk Hohndel
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-10Implement Close menu option that allows closing the data fileGravatar Dirk Hohndel
This requires some helper routines that allow us to clear out all the widgets. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-10Change behavior for the existing filenameGravatar Dirk Hohndel
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-09First cut of adding a default file nameGravatar Dirk Hohndel
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-06Merge branch 'print_selection' of http://ambre.pingoured.fr/cgit/subsurfaceGravatar Linus Torvalds
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-06Merge branch 'trip3' of git://git.hohndel.org/subsurfaceGravatar Linus Torvalds
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-05Avoid duplicate dive_trip entriesGravatar Dirk Hohndel
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-05More trip manipulations: remove selected dives from tripGravatar Dirk Hohndel
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-03Add ability to merge trip with trip belowGravatar Dirk Hohndel
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-03Use the infrastructure for moving dives in more placesGravatar Dirk Hohndel
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-03Make xml (and CSV) parsing use 'g_ascii_strtod()' rather than 'strtod()'Gravatar Linus Torvalds
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-03Correct the trip related test divesGravatar Dirk Hohndel
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-03Fix crash when removing the first dive of a tripGravatar Dirk Hohndel
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-03Correctly initialize the toggle state of the autogroup menu entryGravatar Dirk Hohndel
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-03Fix copy_tree_node to no longer overwrite dive durationGravatar Dirk Hohndel
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-03Add the 'Print only selection' checkbox in the print optionsGravatar Pierre-Yves Chibon
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-02Add autogen menu commandGravatar Dirk Hohndel
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-02Fix a crash when changing sort columnGravatar Dirk Hohndel
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-02Merge branch 'separator-line' of git://github.com/henrik242/subsurfaceGravatar Linus Torvalds
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-02Use truth values with gbooleanGravatar Dirk Hohndel
Just a little cosmetic oversight Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-01Allow modification and edits of tripsGravatar Dirk Hohndel
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-01Clean up macros and auxiliary functionsGravatar Dirk Hohndel
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-01Store time_t as long valueGravatar Dirk Hohndel
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-08-30Add support for printing only the selected divesGravatar Linus Torvalds
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-30Merge branch 'print_table' of http://ambre.pingoured.fr/cgit/subsurfaceGravatar Linus Torvalds
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-30Merge branch 'divetrip-nr' of git://git.hohndel.org/subsurfaceGravatar Linus Torvalds
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-30Remove the pretty-print without dive profile option.Gravatar Pierre-Yves Chibon
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>