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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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
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
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
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>
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>
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>
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>
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>
Linus change in commit bcb9f67819bc ("Make the notebook portion (dive
notes/equipment/info) a scrollable window") created a really ugly default where
the notebook Dive Notes always ended up with a vertical scrollbar. This picks a
much saner default layout for the panes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This makes things start up with the wrong size, which is somewhat
annoying, but by doing so avoids a bigger annoyance, namely that the
three panes move around when moving between dives.
In particular, if the initial dive didn't have much of an equipment
list, the initial size allocated for the notebook is fairly small and
determined mainly by the size of the the Dive Notes page. However, when
you then scroll around in the dive list, you might hit a dive with lots
of equipment, and suddenly the panes dividing the different parts of the
subsurface application window will jump around to make room.
That's horribly annoying, and actually makes things like double-clicking
dives in the dive list not work right, because the first click will
select it, and cause the dive to move around (so the second click will
hit a totally different dive).
Now, making the notebook be in a scrollable window means that if the
size of the notebook changes, it might get a scrollbar, but the panes
themselves do not move around.
The initial sizing of that thing being wrong is annoying, though. We
need to figure out a separate solution to that.
[ Side note: currently it uses GTK_POLICY_NEVER for the horizontal
scroll-bar, just to avoid the horizontal size also starting out wrong,
which is *really* nasty. If we can solve the initial size issue, we
should make the horizontal scroll-bar be GTK_POLICY_AUTOMATIC too. ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The "filename" variable was only initialized when the user accepted the
name, so cancelling the file save would randomly use an uninitialized
pointer.
Reported-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Pull miscellaneous fixes, mostly UI stuff from Mikko Rasa.
Both this and the pull from Pierre-Yves Chibon created a "Save As" menu
entry and logic. As a result, there were a fair number of conflicts,
but I tried to make the end result somewhat reasonable. I might have
missed some semantic conflict, though.
Series-acked-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
* 'misc-fixes' of git://github.com/DataBeaver/subsurface:
Add a separate "Save as" entry to the menu
Changes to menu icons
Improved depth info for dives without samples
Divide the panes evenly in view_three
Add a "Save As" entry in the "File" menu allowing the user to specify the file in which to save
the data. This is useful as we no longer offer this option through the "Save" entry while the data
had been opened from an existing file.
Signed-off-by: Pierre-Yves Chibon
So far, when trying to quit while the data was changed the offer
was "Save" or "Don't save". Now, you can also "Cancel" which will
bring you back to the main window.
This allows you to re-save the data in another file.
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
When a file is opened, we keep it in memory and when you try to
quit while the data has been changed, propose to save back to
this same file.
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Instead of having "Show Temp", "Show Cyl", etc in the Preferences dialog,
rename the group as "Show Columns" and remove "Show " from all the
checkboxes. The dialog is tighter/nicer this way.
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Pull dive-trip grouping from Dirk Hohndel:
"This turned into an updated pull request for the tree2 branch where I
implemented the date based grouping - but is actually a very different
topic: this adds the ability to edit multiple dives (and fixes some
issues with the dive editing overall). The reason for that is that it
reuses some of the infrastructure that I implemented in the tree2
branch for tracking the selected dives. More details in the commit
messages."
* 'tree2' of git://git.hohndel.org/subsurface:
Switch from date based to dive trip based grouping
Redo dive editing
Fix selecting and unselecting summary items
Apply sort functions to the correct model, don't select summary entries
Maintain selected rows when switching between list model and tree model
Create duplicate list model so sorting by columns works again
Improve tree model implementation
Allow date based grouping
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>
For simplicity and shortness, throughout subsurface exposure protection is
simply referred to as "suit".
Add the fields to the data structures, add the column to the dive_list
and the preferences dialog (once again with it being turned invisible by
default). Support loading and saving of the suit information.
Display the suit information in the Dive Info pane (this may be a bit
controversial as people could argue this should be in the Equipment pane)
and allow editing of the suit info, with our usual support for completion
and drop down lists to pick from.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds the total weight carried on the dive in different weight systems
to the divelist. The column is by default not shown, which can be changed
in the preferences. The column is sortable.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The "Save" entry will now automatically save over the last used file. If
no filename has been set, then that entry will also prompt the user for a
filename.
The filename is set when saving as well, so the next save will use the
same filename.
Signed-off-by: Mikko Rasa <tdb@tdb.fi>
It's customary for menu bars to not have icons.
Some items were lacking icons when there's perfectly good stock icons
available. I was a bit torn between the "new" and "add" icons for the
"add dive" item, since what it really does is create a new dive, but
the "add" icon is an uninteresting sheet of paper in the default icon
theme so I decided to use the "add" icon.
Signed-off-by: Mikko Rasa <tdb@tdb.fi>
No need for right-clicks. It's inconvenient on lots of laptops etc, so
allow just using the Dive menu as an alternative.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This does mean that you have to build subsurface against a new version
of libdivecomputer, and that version is likely going to have various
slightly incompatible changes. But the new interfaces allow for easily
adding new supported dive computers without subsurface having to be
updated for each new vendor and model, so some slight pain is definitely
worth it this time.
I'm not even going to try to have some backwards-compatible version
here, the libdivecomputer interface changes are so extensive. Native
enumeration of devices is just the smallest part of it: the constants
and types that libdivecomputer uses now have much nicer names that all
start with DC_ or dc_, so you don't get the kinds of name clashes we had
with "gasmix_t" etc.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>