summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
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-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-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>
2012-08-29Stop tracking the number of dives in a dive tripGravatar Dirk Hohndel
Gtk tracks this for us as the number of children of the treeview node. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-29Fix profile and average depth for freedivesGravatar Mikko Rasa
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-29Have a nice table formating with choosing the 'Table print' option.Gravatar Pierre-Yves Chibon
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-29Invert the print 'dive profile' option.Gravatar Pierre-Yves Chibon
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-29Deactivate 'Show profiles' if 'table print' is checked.Gravatar Pierre-Yves Chibon
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-28Merge branch 'freediving-tweaks' of git://github.com/mguentner/subsurfaceGravatar Linus Torvalds
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-28Merge git://git.tdb.fi/ext/subsurfaceGravatar Linus Torvalds
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-28Work on the printing of the dives, first attempt to print as table.Gravatar Pierre-Yves Chibon
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-28Remove include not present in new libdivecomputer.Gravatar Pierre-Yves Chibon
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-27make the font size the same when printing on win32/linuxGravatar Lubomir I. Ivanov
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-27Merge branch 'trips' of git://git.hohndel.org/subsurfaceGravatar Linus Torvalds
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-27Fix an issue with trips that have dives from multiple input filesGravatar Dirk Hohndel
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-27Update for new libdivecomputer interfacesGravatar Linus Torvalds
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-27Some simple test dives for the trips codeGravatar Dirk Hohndel
Playing with these shows that there are still some issues with handling multiple files correctly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-27First cut of explicit trip trackingGravatar Dirk Hohndel
This code establishes the explicit trip data structures and loads and saves them in the XML data. No attempts are made to edit / modify the trips, yet. Loading XML files without trip data creates the trips based on timing as before. Saving out the same, unmodified data will create 'trip' entries in the XML file with a 'number' that reflects the number of dives in that trip. The trip tag also stores the beginning time of the first dive in the trip and the location of the trip (which we display in the summary entries in the UI). The logic allows for dives that aren't part of a dive trip. All other dives simply belong to the "previous" dive trip - i.e. the dive trip with the latest start time that is earlier or equal to the start time of this dive. This logic significantly simplifies the tracking of trips compared to other approaches that I have tried. The automatic grouping into trips now is an option that defaults to off (as it makes changes to the XML file - and people who don't want this feature shouldn't have trips added to their XML files that they then need to manually remove). For now you have to select this option, then exit the program and start it again. Still to do is to trigger the trip generation at run time. We also need a way to mark dives as not part of trips and to allow options to combine trips, split trips, edit trip location data, etc. The code has only had some limited testing when opening multiple files. The code is known to fail if a location name contains unquoted special characters like an "'". This commit also fixes a visual inconsistency in the preferences dialog where the font selector button didn't have a frame around it that told you what this option was about. Inspired-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-27Only quote the quote characters in xml attributesGravatar Linus Torvalds
The quoting of single and double quotes is only necessary for attributes, and is irritating for other fields in that it makes the fields almost unreadable in the xml file. Single quotes in particular are common, and turning "it's" into "it&apos;s" is just not reasonable for dive notes etc. So add a flag to whether the xml quoting is for an attribute or not, and take that into account. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-27Merge branch 'quoting' of git://git.hohndel.org/subsurfaceGravatar Linus Torvalds
Pull xml quoting fix from Dirk Hohndel. * 'quoting' of git://git.hohndel.org/subsurface: Add single and double quotes to escaped characters in XML output
2012-08-27Add single and double quotes to escaped characters in XML outputGravatar Dirk Hohndel
We already escape '<', '>', and '&'. This adds the remaining two special entities in XML: '\'' and '\"'. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-27Start re-working the print UI to allow printing tables with no profiles.Gravatar Pierre-Yves Chibon
With this commit we add a checkbox in the "Dive details" tab of the print window. This checkbox allows to print the dives profile or not. If you don't print the dives profile, you get 15 dives on the page (instead of 6 with the profiles). Future work should include: - Ability to choose what is printed - Table layout vs the current one (if no dives profile) - Ability to choose the number of dives per page (play with the font size for this) Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr> Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2012-08-26Might as well free current_fileGravatar Dirk Hohndel
In commit fd2debc1e730 ("replaced stdndup() with the inlined equivalent") Lubomir freed the memory from one of my two strdups but not the other. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-26Do some whitespace cleanupGravatar Linus Torvalds
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-26replaced stdndup() with the inlined equivalentGravatar Lubomir I. Ivanov
don't kill the OS incompatibility messenger. 1) http://stackoverflow.com/questions/6062822/whats-wrong-with-strndup stdndup() is POSIX 2008, but apparently not available on OSX and Windows it could be made potentially application global (e.g. a local "stdndup.h") 2) free() memory at pointer "current_dir", once we are done. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-26file.c: open a file in binary mode in readfile()Gravatar Lubomir I. Ivanov
O_TEXT is the default mode for fctrl's open() and on windows created files, line endings are counted by fstat() as CR+LF adding an extra byte for each line. the result from this is that, while the file still can be read into a buffer, the read() return (ret) has a different size compared to the previously allocated buffer, breaking at: if (ret == mem->size) a solution is to open() the file in O_BINARY mode, which should technically suppress the EOL translation. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> [ Fixed to work under real operating systems that don't need this crap. "Here's a nickel, kid, go and buy a real OS". - Linus ] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-26Fix broken default filename for save-asGravatar Dirk Hohndel
The existing code set the filename to the full path of the last input file and didn't set the path at all. Instead we now split the existing filename into its path and file component and set up the choser accordingly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-26Ignore Nitrox/He seetings when editing cylinders for multiple divesGravatar Dirk Hohndel
When figuring out which cylinders to change in a multi-dive edit, we already ignored the beginning and end pressures. But it turns out to make more sense to also ignore the Nitrox / Helium settings. Imagine you do a number of dives - for some reason your dive computer records the wrong cylinder size in the downloaded logfile (like my uemis does all the time). Dives will likely have different Nitrox percentage, but you should still be able to simply fix the cylinder size for all dives at once. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-22moved zoomed_plot to display.hGravatar Maximilian Güntner
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2012-08-22plot the time with a fixed padding (leading zero)Gravatar Maximilian Güntner
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2012-08-22Merge branch 'master' into freediving-tweaksGravatar Maximilian Güntner
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2012-08-21Add helper 'for_each_dive()' dive iteratorGravatar Linus Torvalds
It's an easy thing to do, but the for-loop ends up being pretty ugly, so hide it behind the macro. It would be even prettier with one of the (few) useful C99 features: local for-loop variables. However, gcc needs special command line options, and other compilers may not do it at all. So instead of doing #define for_each_dive(_x) \ for (int _i = 0; ((_x) = get_dive(_i)) != NULL; _i++) we require that the user declare the index iterator too, and the use syntax becomes for_each_dive(idx, dive) { ... use idx/dive here ... } And hey, maybe somebody actually will want to use the index, so maybe that's not all bad. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-21Fix single-dive editing oddityGravatar Linus Torvalds
The multi-dive case does fine, but the single-dive case (used when adding a dive, for example) was somewhat confused between the dive index (which is the location in the dive array) and the dive number. Fix this by just passing the dive pointer instead (where NULL means to use the current dive selection). Reported-by: Jacco van Koll <jacco.van.koll@gmail.com> Root-caused-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-22Check if multi-dive editing is actually neededGravatar Mikko Rasa
Context menu callbacks always invoke edit_multi_dive_info(-1) instead of edit_dive_info. Since -1 means "all selected", it was impossible to edit dive notes through the context menus. This commit makes the function check if multiple dives are actually selected. Signed-off-by: Mikko Rasa <tdb@tdb.fi>
2012-08-22Fix an off-by-one error in buffer allocationGravatar Mikko Rasa
Signed-off-by: Mikko Rasa <tdb@tdb.fi>
2012-08-20Add a "Dive details" widget to the print dialogGravatar Linus Torvalds
Ok, so the widget doesn't actually *do* anything, but this is where you would add dive printing settings for things like "print list" vs "print profiles" etc. Printing just a dense dive table (no profiles etc) is being discussed on the list, maybe starting the scaffolding will inspire somebody to do something about it ... Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-20Improve group selection semanticsGravatar Linus Torvalds
Now that the last commit tried to avoid changing the child selections if the selected group partially matched, we should always [un]select all children when we actually decide to change something. Before, it would try to minimize selection damage by stopping [un]selecting when it hit a child that already matched the selection, but since we minimize damage differently, the all-or-nothing approach is better, and gets us sane behavior when the group is collapsed. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-20Avoid changing selection status when collapsing/expanding groupsGravatar Linus Torvalds
This tries to avoid the problem mentioned in commit972669d6363c ("Rework dive selection logic"), where a selection of dives hidden by collapsing the group gets forgotten about by gtk. It does so by always marking the group selected when it is collapsed with any selected children. We also avoid selecting new children when a group is selected that already has at least *some* children selected already. This way we do minimal damage to existing selections when working with dive group selections. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-20Rework dive selection logicGravatar Linus Torvalds
This completely changes how we keep track of selected dives: instead of having an array listing the selection ("selectiontracker") or trusting the gtk selection information, just save the information about whether a dive is selected in the dive itself. That makes it trivial to keep track of the state of selection across group collapse/expand events, or when changing the tree view model. It also ends up simplifying the code and logic in other ways. HOWEVER, it does currently (re-)introduce an annoying oddity with gtk: if you collapse a dive trip that has individual selections, gtk will forget those selections ("out of sight, out of mind"), and when you do *new* selections, the old hidden ones remain. So there's some games required to make gtk do sane things. We may need to either explicitly drop selections when collapsing trips, or make sure the group entry gets selected when collapsing a group that has selections in it. Or something. There may be other issues introduced by this too. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>