Commit graph

190 commits

Author SHA1 Message Date
Dirk Hohndel
3835faa8fb Merge branch 'defaultfile'
By now the default file code seems quite matured, so in preparation for
2.0 we'll bring it back into master.

I made a few small clean-ups during the merge, but the merge itself is
very much straight forward.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17 21:44:28 -04:00
Dirk Hohndel
2cadc70e3d Simplify code in file_open as we now only open one file
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-17 21:03:30 -04:00
Dirk Hohndel
46d91acdff Don't close existing data file in file_open if user cancels
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-17 21:03:30 -04:00
Dirk Hohndel
7148dea827 Once again improve existing filename handling
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-17 21:03:30 -04:00
Dirk Hohndel
cc42debb88 Mark divelist unchanged after closing the datafile
This seems rather obvious - I'm surprised I didn't notice it earlier.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17 21:03:30 -04:00
Dirk Hohndel
eddea0e5e3 Put creation of the file selector box filter into helper function
This avoids duplication of code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17 21:03:29 -04:00
Dirk Hohndel
ca696dd0cd Reimplement the GtkFileChooserButton for import
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-17 21:03:29 -04:00
Dirk Hohndel
dea8d47b69 The Open menu entry should open just one file
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-17 21:03:29 -04:00
Dirk Hohndel
b2727ecfda Move Import menu entry back to File menu
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-17 21:03:29 -04:00
Dirk Hohndel
d3bf8af7fe File Open now closes the previous file, first
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-17 21:03:09 -04:00
Dirk Hohndel
65d9d48845 Display current filename in windows title
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-17 21:03:03 -04:00
Dirk Hohndel
9f5d9bd94f Use glib file and pathname functions
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-13 11:22:09 -07:00
Dirk Hohndel
3d4be85f35 Prevent the preferences dialog from getting focus with file selector open
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-13 10:53:30 -07:00
Dirk Hohndel
c74f58786d Fix memory leaks and one potential NULL dereference
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-13 10:46:09 -07:00
Lubomir I. Ivanov
5dbf10a6d6 various small fixes to the defaultfile model
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-12 15:13:09 -07:00
Dirk Hohndel
1ae4b80027 Make sure Subsurface receives Quit / Command-Q callback on Mac
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-12 09:18:56 -07:00
Lubomir I. Ivanov
be941e00b2 Inline g_list_free_full for better compatibility
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-11 12:08:39 -07:00
Dirk Hohndel
2a9679dac6 Use glibio functions for mkdir
Suggested-by: Jef Driesen <jefdriesen@telenet.be>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-11 12:08:07 -07:00
Lubomir I. Ivanov
0fceb1c907 Better compatibility with older GTK and Cairo
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>
2012-09-11 07:59:53 -07:00
Miika Turkia
ae33b5ef52 Display yearly/monthly statistics
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>
2012-09-11 07:29:06 -07:00
Lubomir I. Ivanov
50eac41129 Use GTK_UNIT_INCH when printing to provide consistency across OS
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>
2012-09-11 07:26:38 -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
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
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
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
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
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
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
e315abf645 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>
2012-08-27 14:32:24 -07:00
Dirk Hohndel
b693bb3fb9 Might as well free current_file
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-26 15:36:40 -07:00
Linus Torvalds
9380f78c82 Do some whitespace cleanup
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-26 14:41:05 -07:00
Lubomir I. Ivanov
9d10574694 replaced stdndup() with the inlined equivalent
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-26 14:37:28 -07:00
Dirk Hohndel
415383d65e Fix broken default filename for save-as
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-26 12:51:18 -07:00
Maximilian Güntner
03eb488dd2 moved zoomed_plot to display.h
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2012-08-22 02:34:29 +02:00
Maximilian Güntner
0c0ec7e4f6 Merge branch 'master' into freediving-tweaks
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2012-08-22 01:15:41 +02:00
Mikko Rasa
c6be2404da Fix an off-by-one error in buffer allocation
Signed-off-by: Mikko Rasa <tdb@tdb.fi>
2012-08-22 00:43:52 +03:00
Dirk Hohndel
ed1ce8ebc8 Fix default size for scrollable notebook
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>
2012-08-18 18:06:32 -07:00
Linus Torvalds
ed6356f7d9 Make the notebook portion (dive notes/equipment/info) a scrollable window
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>
2012-08-18 14:37:43 -07:00
Linus Torvalds
76fc14f1b4 Fix uninitialized pointer crash for "Save As"
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>
2012-08-18 09:48:15 -07:00
Linus Torvalds
d0e27c6c53 Merge branch 'misc-fixes' of git://github.com/DataBeaver/subsurface
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
2012-08-17 10:57:24 -07:00
Pierre-Yves Chibon
9cb3685030 Add a 'Save As' entry in the menu.
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
2012-08-17 16:39:28 +02:00
Pierre-Yves Chibon
1a76951159 Allow to cancel while trying to quit and the data was changed.
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>
2012-08-17 16:39:28 +02:00
Pierre-Yves Chibon
76298c64e3 When the file has been opened rely on it to save.
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>
2012-08-17 16:39:28 +02:00
Henrik Brautaset Aronsen
9451617760 Remove repetitions of "Show" in Preferences dialog
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>
2012-08-17 08:56:40 +02:00
Linus Torvalds
9b72217f79 Merge branch 'tree2' of git://git.hohndel.org/subsurface
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
2012-08-16 10:46:30 -07:00
Dirk Hohndel
621761233b Redo dive editing
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>
2012-08-15 15:32:36 -07:00
Dirk Hohndel
e8ec3df371 Add exposure protection tracking
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>
2012-08-14 17:16:00 -07:00
Dirk Hohndel
19621bf481 Add total weight column to divelist
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>
2012-08-07 11:24:40 -07:00
Mikko Rasa
549708c6ea Add a separate "Save as" entry to the menu
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>
2012-07-31 21:12:24 +03:00
Mikko Rasa
d8c8ada6c7 Changes to menu icons
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>
2012-07-31 21:12:21 +03:00
Mikko Rasa
618a20ba5f Divide the panes evenly in view_three
There was a note by Linus that he doesn't know how to get the size, so
I'm fixing that.

Signed-off-by: Mikko Rasa <tdb@tdb.fi>
2012-07-31 21:11:58 +03:00
Linus Torvalds
162b36f4a5 Make it possible to do "Add Dive" from just the main dive menu
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>
2012-06-27 18:09:26 -07:00
Linus Torvalds
d4b0ce1c86 Update to new sane libdivecomputer interfaces
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>
2012-06-22 13:37:39 -07:00
Maximilian Güntner
7acd075bd5 added "Zoom" button and improved scaling
It should be possible to have a certain limit where we
stop zooming so that short dives are visible as such
at first glance. Therefore a "Zoom" button has been
added to the "Log" menu along with a shortcut (Ctrl + "0").
The user can now zoom/unzoom the plot and is still able to
quickly distinguish short dives from normal ones when
browsing the log.

Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2012-06-11 02:45:36 +02:00
Terrance Stanfield
697435b249 Save dive computer device name.
It is really annoying to have to type the device name each time you need
to import a dive from your computer, if you are not using the default
device name. This will save the device name in the configuration file and
matches the logic currently used to save the dive computer name in the
configuration file.

Signed-off-by: Terrance Stanfield <t@hollowcranium.com>
2012-05-29 23:54:09 -05:00
Linus Torvalds
e7a70b6ae8 Show dive import text updates in the progress bar
Instead of using printf() to print the string updates ("Parsing sample
data" etc), introduce a function to show those strings in the graphical
progress bar itself.

Subsurface hasn't been a text-mode application in a long time ;)

This partially fixes the second todo entry from commit b0ba22a068
("Show dive import error messages in the import dialog") and generally
makes for a more helpful import - at least for the largely error-free
cases.

Sadly, the messages that really come from within libdivecomputer itself
(like "suunto_vyper2.c:193: Failed to receive the answer.") when things
go really wrong are not caught.  libdivecomputer does have a notion of a
logfile (set with "message_set_logfile()"), but that ends up being
really inconvenient.

Maybe we could use some pipe setup or something. Oh well.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-05-02 17:42:58 -07:00
Linus Torvalds
26b90cbfa8 Change the Dive computer import button from "Ok" to "Retry" on error
This was a todo item in commit b0ba22a068 ("Show dive import error
messages in the import dialog") which made the import dialog able to
retry the import on errors.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-05-02 13:45:52 -07:00
Linus Torvalds
11db04b350 Move the "Import" function from the File menu to the Log menu
Sure, you can import a file too, but it really makes more sense to have
the actions related to importing new logs under "Log", I think.  I don't
think of it as a file operation.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-05-02 12:56:01 -07:00
Linus Torvalds
b0ba22a068 Show dive import error messages in the import dialog
.. not in the main window.  And leave the import dialog open, so that
you can either try doing it again, or cancel.  This makes it much easier
to re-try a failed dive import, and actually makes the failure more
obvious too.

Todo:

 - make the "Ok" button change to "Retry" when an error happens

 - try to see if we can catch the actual status update messages from
   libdivecomputer and show them too in the import dialog.  Right now
   they are printed out to stderr by the library.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-05-02 12:49:03 -07:00
Linus Torvalds
c8f3dc3594 Remember the default dive computer setting
Always having to re-select the same dive computer got really annoying
when I had trouble importing the dives.  Let's not force the user to do
that, since we could just remember the last dive computer used, and
default to that one.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-05-02 10:26:34 -07:00
Linus Torvalds
725e4582d9 Don't close config file when changing preferences
On Linux and MacOS the subsurface_close_conf() doesn't really close the
config file (it flushes writes on MacOS), but on Windows it does
actually close the registry hkey.

Which is bad, if you change the settings multiple times - we assume that
the config file is open the whole time.

So add a "subsurface_flush_conf()" function, and call *that* when
changing configuration parameters.  And call the close function only at
the very end.

Alternatively, maybe we should just open the config file separately
every time. I don't much care, maybe somebody else does.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-05-02 10:03:48 -07:00
Linus Torvalds
81fddfa67e Merge branch 'weight' of git://subsurface.hohndel.org/subsurface
Pull weight management from Dirk Hohndel:
 "This is the fifth or sixth version of this code, I'm begining to lose
  track.  I still struggle with the balance between code duplication and
  unnecessary indirectness and complexity.  Maybe I'm just not finding
  the right level of abstraction.  Maybe I'm just trying too hard.

  The code here is reasonably well tested.  Works for me :-)

  It can import DivingLog xml files with weight systems and correctly
  parses those.  It obviously can read and write weight systems in its
  own file format.  It adds a KG/lbs unit default (and correctly stores
  that).

  The thing I still worry about is the code in equipment.c.  You'll see
  that I tried to abstract things in a way that weight systems and
  cylinders share quite a bit of code - but there's more very similar
  code that isn't shared as my attempts to do so turned into ugly and
  hard to read code.  It always felt like trying to write C++ in C..."

* 'weight' of git://subsurface.hohndel.org/subsurface:
  Add weight system tracking

Fix up some trivial conflicts due to various renaming of globals and
simplification in function interfaces.
2012-03-23 21:07:53 -07:00
Dirk Hohndel
854bd0269c Add weight system tracking
- supports multiple weight systems per dive
- supports multiple weight system types
- supports import of weight as tracked by DivingLog

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-03-24 11:44:27 +09:00
Miika Turkia
9933ccd7cf Show statistics of selected dives
If at least 2 dives are selected, show statistics of these dives on
Overall Stats. Otherwise, show the statistics of all dives. Temperature
is also added to the shown statistics.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>

Minor change to avoid adding statistics.h (moved the global variable and
external function declaration to display-gtk.h).
Another minor change to the text displayed for the "Stats" notebook page.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-03-16 12:12:19 -07:00
Linus Torvalds
4d10bc017a Split up file reading from 'parse-xml.c' into 'file.c'
We're going to eventually import non-xml files too, so let's begin
splitting the logic up.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-01-26 13:00:45 -08:00
Dirk Hohndel
788ebc0500 Create separate single dive and total stats pages
No additional statistics added, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-15 14:29:08 -08:00
Dirk Hohndel
c544226334 Avoiding some potentially confusing name space clashes
We have local variables or function arguments with the same names as
function static variables (or in one case, function arguments).

While all the current code was correct, it could potentially cause
confusion when chasing bugs or reviewing patches. This should make things
clearer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-05 08:55:18 -08:00
Dirk Hohndel
513df18f50 Even more Mac-i-ness
Move the About and Preferences menu item to the App menu.
Switch the accelerator key to be Meta (i.e., Command) instead of Control

This required a bit of restructuring of the code, but it's all for a good
cause.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-03 07:25:35 -08:00
Dirk Hohndel
53ecd2025d Adding the right header file for R_OK on Windows
Dang, I should have compile tested this on Windows before the last
commit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-03 07:25:26 -08:00
Dirk Hohndel
7b5874ead7 Only set the window icon if the icon file exists
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-02 20:15:24 -08:00
Dirk Hohndel
43530d397b Correctly free the GSList in file_open
Passing a value that is known to be NULL to g_slist_free seems like the
wrong approach...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-02 20:13:45 -08:00
Dirk Hohndel
605e063203 Turn subsurface into a real Mac application
To do this a few things needed to move into the os specific files, but the
overall change is fairly small and the difference on the Mac is amazing.

Subsurface now becomes a Mac app with Mac toolbar and useful default
fonts.

Changed the CFBundleIdentifier to be the reverse DNS of the subsurface
site (sadly, 'torvalds' is not yet a TLD).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-01 14:01:38 -08:00
Dirk Hohndel
565736a471 Make icon file name OS helper function
This way we can load the correct icon on the Mac without ugly hacks in the
OS independent code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-28 15:57:36 -08:00
Dirk Hohndel
0a9e5aa735 Return is not a function
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-14 20:53:25 -08:00
Dirk Hohndel
4b77a5def6 Add reasonable default device names for divecomputer import
So far we hard coded /dev/ttyUSB0 - which is a good starting point in
Linux but not so useful on Windows or MacOS. This was now moved into one
of our OS helper functions with (somewhat) reasonable defaults.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-13 20:34:56 -08:00
Dirk Hohndel
001f6d05dc More intuitive label for "not saving" when exiting
Right now the options are "Save" and "Cancel". I wrote that code and it
always bugged me - "Cancel" could mean that I want to cancel the the whole
operation, i.e. that I don't want to quit after all. Showing "Save" and
"No" seems much more logical.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-13 15:02:17 -08:00
Linus Torvalds
f078bc04e1 Make the cylinder table columns unsortable
They were never intended to be sortable, but using common code with the
dive list picked up that "sort by index" thing by mistake.

If we really want to be able to sort cylinders by O2 percentage (which
really doesn't seem to make much sense, considering that you usually
have just one or two cylinders) we will need to also handle the case of
editing the (differently sorted) cylinder table.  Which we don't do now.

Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-12-11 11:40:17 -08:00
Linus Torvalds
1cb9fc7fb4 Make view action shortcuts be ctrl-[1-4] instead of Fn keys
Suggested by Henrik Aronsen, and seems much more natural.  Especially
with lots of keyboards having function keys oddly mapped.

Suggested-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-12-07 08:08:29 -08:00
Linus Torvalds
7721036fab Add shorthand actions for showing just one of the panes
Currently just tied to F1-F4 (for divelist, profile, info, and "all
three" respectively), which is just crazy.  But using "ctrl-P" for
"Profile" isn't sane either, that's the standard printer keyboard
shortcut.  So what would be good keyboard shortcuts for these things?

I also wonder how I can get gtk to shut up about the fact that a pane
becomes too small for the contents of that pane? We very much want to do
that, and it's very intentional.  Gtk does the right thing apart from
the whining (and apart from the visually ugly part of a widget that
doesn't fit, but making it pretty doesn't really seem possible).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-12-06 13:00:01 -08:00
Henrik Brautaset Aronsen
fc6fec59ba Define all colors in one place
The profile colors were defined all over the place, so I put them all in one spot.  I'm unsure if this is the best solution to that problem, but I guess it's a step in the right direction.

Signed-Off-By: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
2011-11-28 18:19:50 +01:00
Linus Torvalds
0d879f8fbe Remove stale notebook drag-and-drop support
It doesn't make sense with the new three-pane layout, and I don't think
we're reviving it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-25 21:50:38 -08:00
Dirk Hohndel
671f6544ac Split reading/writing preferences into OS specific files
This adds tested code for Linux and Mac OS, implementing the api that
Linus suggested.

The Windows code was moved into its own file, but hasn't even been compile
tested, yet.

In order to have just one interface to set or get a preference value we
encode TRUE as (void *) 1 and FALSE as NULL. This works consistently on
all platforms and regardless of whether we have 32 or 64 bit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-24 10:12:40 -08:00
Dirk Hohndel
cf6e0e7ca1 Preference handling on Mac
This cleans up the platform conditional handling and gets rid of gconf on the Mac.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-22 12:20:36 -08:00
Linus Torvalds
c36bf636bd Experimental hard-coded three-pane layout
I'm not happy with it, but it looks good and works better than the
alternatives I've looked at so far.

So why not happy? It's not configurable, and gtk really doesn't do a
great job with the case of notebook widgets that are shrunk to be
smaller than the contents (the cut-off gets ugly, and is outside the
notebook page!)

But committing as a way to keep track of this, and let Dirk use it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-19 12:54:58 -08:00
Dirk Hohndel
f89aec94e2 Fix drag and drop error
Linus noted an odd "CRITICAL" warning when ripping off a page of the
notebook and then dropping it within the same notebook.

Turns out we need to simply accept a drop on ourselves and gtk does the
rest correctly.

I also fixed the fact that we incorrectly declared the callback as 'void'.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-02 14:35:47 -07:00
Linus Torvalds
55352a051c Merge branch 'add-info-stats-page' of git://github.com/dirkhh/subsurface
* 'add-info-stats-page' of git://github.com/dirkhh/subsurface:
  Add Info & Stats page to the notebook
  Even more places with pressure and volume conversions
  Further cleanup of pressure and volume conversions
  Use unit functions to get column headers, add unit function for pressure
  More consistency improvements
  Add new helper function to get temperature and unit
2011-11-02 12:39:55 -07:00
Dirk Hohndel
619ab9e828 Add Info & Stats page to the notebook
This provides the relevant information for the currently selected dive
plus a bunch of statistics over all dives in the dive_table.

The visual design has lots of room for improvement
- right now the different fields change size
- it might be nice to have a more modern look for the entries
- the O2/He field is odd - for most divers the He value will
  always be 0, so maybe we should only show He if there's at least one
  dive that uses He? Also, we simply do a comma separated list of gases
  for all the tanks used

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-02 12:27:12 -07:00
Linus Torvalds
e4bfb65972 Fix 'init_ui()' so that it can change argc/argv
That's what gtk_init() does with gtk-specific arguments.  IOW, if you do
things like

   subsurface --g-fatal-warnings dives.xml

to get a real abort on gtk warnings, gtk_init needs to be able to
actually change argc/argv.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-01 17:09:15 -07:00
Lubomir I. Ivanov
43601f6546 Using RegQueryValueEx instead of RegGetValue
Provides compatibility with winxp-32bit in gtk-gui.c,
since RegGetValue is only available on the 64bit build of the OS.

Fixed whitespace issues, fixed obvious typo (this patch clearly wasn't
even compile tested)

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-31 21:18:53 -07:00
Dirk Hohndel
7f0c866f48 Get icons working correctly under Windows
With this we are able to include both a separate .ico file that the
program can load at runtime and a .res file (that is created from the .rc
file, both in the packaging/windows directory) that is linked into the
executable and makes the Windows Explorer show the correct icon for
subsurface.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-29 09:14:15 -07:00
Dirk Hohndel
2101f37c1b Use Registry on Windows to store preferences
No change at all to non-Windows builds.

Everything seems to work with preferences - but only tested on Win7

Remaining issue: displaying an icon (or the logo in the About dialog)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-28 18:46:53 -07:00
Dirk Hohndel
bf7d70fe8b Don't use gconf on Windows
So far this just removes the gconf code - so no preferences for Windows.

It also removes the unsused gconf references in main.c

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-27 22:10:35 -07:00
Dirk Hohndel
036fccd34a Rearrange the event filter dialog
Create a table with four rows of toggle events and resize it as needed.
This may not create the most beautiful layout, but it works.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-25 05:21:59 -07:00
Dirk Hohndel
98efa0794a Add menu item and dialog to select which events to display
Right now they are displayed in one hbox which doesn't work if you have
many events - but the code itself works and correctly toggles the events
on and off.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-25 02:51:16 -07:00
Dirk Hohndel
8c0c6bad59 Fix oversight in preference implementation
Not being careful enough doing copy and paste and then making manual
changes... this inconsistency caused subsurface to always store the
opposite of what you wanted in the preferences for SAC and O2%.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-23 14:23:58 -07:00
Dirk Hohndel
bf13c14d16 Make columns for temperature, cylinder, and nitrox optional
Just like SAC and OTU these can now be turned on and off through the
preferences.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-23 13:36:37 -07:00