Commit graph

128 commits

Author SHA1 Message Date
Lubomir I. Ivanov
17191f17ce Translate the units in the 'Weight System' dialog
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-18 14:49:14 -07:00
Dirk Hohndel
f1569a206e Improve translations
- fix two missing strings in equipment.c (thanks to Tommi Saviranta for
  pointing this out)

- add context for the translations of the Yearly/monthly statistics. The code
  for this ended up being incredibly ugly, but the gettext infrastructure
  really clashed with the way this is implemented. What I have now at least
  works (tested with the German translation)

- merge the new strings into all the po files. The non-German translations need
  to be updated. Make sure you remove the "# , fuzzy" lines or the current
  Makefile will ignore those additions.

- some minor cleanup of the po files (many listed the wrong language, all of
  them copied my incorrect use of PACKAGE (instead of saying "Subsurface").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-14 20:47:00 -07:00
Dirk Hohndel
99846da77f Conversion to gettext to allow localization
This is just the first step - convert the string literals, try to catch
all the places where this isn't possible and the program needs to convert
string constants at runtime (those are the N_ macros).

Add a very rough first German localization so I can at least test what I
have done. Seriously, I have never used a localized OS, so I am certain
that I have many of the 'standard' translations wrong. Someone please take
over :-)

Major issues with this:

- right now it hardcodes the search path for the message catalog to be
  ./locale - that's of course bogus, but it works well while doing initial
  testing. Once the tooling support is there we just should use the OS
  default.

- even though de_DE defaults to ISO-8859-15 (or ISO-8859-1 - the internets
  can't seem to agree) I went with UTF-8 as that is what Gtk appears to
  want to use internally. ISO-8859-15 encoded .mo files create funny
  looking artefacts instead of Umlaute.

- no support at all in the Makefile - I was hoping someone with more
  experience in how to best set this up would contribute a good set of
  Makefile rules - likely this will help fix the first issue in that it
  will also install the .mo file(s) in the correct place(s)

  For now simply run

  msgfmt -c -o subsurface.mo deutsch.po

  to create the subsurface.mo file and then move it to
  ./locale/de_DE.UTF-8/LC_MESSAGES/subsurface.mo

  If you make changes to the sources and need to add new strings to be
  translated, this is what seems to work (again, should be tooled through
  the Makefile):

  xgettext -o subsurface-new.pot -s -k_ -kN_ --add-comments="++GETTEXT" *.c
  msgmerge -s -U po/deutsch.po subsurface-new.pot

  If you do this PLEASE do one commit that just has the new msgid as
  changes in line numbers create a TON of diff-noise. Do changes to
  translations in a SEPARATE commit.

- no testing at all on Windows or Mac
  It builds on Windows :-)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-11 10:03:03 +09:00
Lubomir I. Ivanov
0559a6a783 Fixed some small memory leaks
Looks like a GtkEntryCompletion object created with
gtk_entry_completion_new() should be unreferenced after usage
(e.g. post gtk_entry_set_completion())

In info.c:get_combo_box_entry_text(), moved the free(..) line outside,
so that we can free regardless.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-01 14:06:46 -07:00
Lubomir I. Ivanov
45d6d6ac71 Keep the "Add/Edit Cylinder & Weight" dialogs on top
This is the same issue as 882cb159a4 (although now we
don't have "Import XML Files" within a dialog). It applies when
in the "Dive info" dialog.

There is some sort of a GTK bug on Ubuntu 12.04 with GTK 2.24.10 that
prevents us from using the gtk_window_set_accept_focus() and similar
API to make the window behind fully inactive.

The proposed portable solution is to completely disable the background
window (NOTE: unless its the main window), disabling child controls
(gtk_widget_set_sensitive) and making the top window "transient for" or
putting it on top (gtk_window_set_transient_for).

Still we do not want to hide the background window titlebar with
gtk_window_set_decorated(), which makes it still clickable.
Make this change to older code in gtk-gui.c as well.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2012-09-30 03:47:10 +03:00
Linus Torvalds
6ae67f96f8 Update cylinder info properly
The "cylinders_equal()/copy_cylinders()" functions were buggered, and
only checked (and copied) the cylinder type.  That was on purpose, since
you do want to be able to change the type of a cylinder without changing
the gasmix of the cylinder.

HOWEVER, the reverse is also true: you may want to change the gasmix of
a cylinder without changing the type.

So it's not that the type of the cylinder is special - it's that the
type and the gasmix should be considered separately.

Do that properly for the equipment editing case.

Reported-by: Ďoďo <dodo.sk@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-24 12:03:58 -07:00
Linus Torvalds
c4c636fb4f Fix missing save of (almost empty) cylinder information
If we have no explicit cylinder info at all (it's normal air, no size or
working pressure information, and no beginning/end pressure information),
we don't save the cylinders in question because that would be redundant.

Such non-saved cylinders may still show up in the equipment list because
there may be implicit mention of them elsewhere, notably due to sample
data, so not saving them is the right thing to do - there is nothing to
save.

However, we missed one case: if there were other cylinders that *did* have
explicit information in it following such an uninteresting cylinder, we do
need to save the cylinder information for the useless case - if only in
order to be able to save the non-useless information for subsequent
cylinders.

This patch does that. Now, if you had an air-filled cylinder with no
information as your first cylinder, and a 51% nitrox as your second one,
it will save that information as

  <cylinder />
  <cylinder o2='51.0%' />

rather than dropping the cylinder information entirely.

This bug has been there for a long time, and was hidden by the fact that
normally you'd fill in cylinder descriptions etc after importing new
dives. It also used to be that we saved the cylinder beginning/end
pressure even if that was generated from the sample data, so if you
imported from a air-integrated computer and had samples for that cylinder,
we used to save it even though it was technically redundant.

We stopped saving redundant air sample information in commit 0089dd8819
("Don't save cylinder start/end pressures unless set by hand").

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Removed start and end in save_cylinder_info(). These two variables are no
longer used.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-21 21:01:42 -07:00
Dirk Hohndel
d14932058f Fix some of the problems reported by cppcheck
Thanks to Christian for running the static code analysis tool against
subsurface...

There were some false positives, a few style issues that I'll ignore for
now, and two actual potential bugs.

First: Don't check unsigned variables for < 0

This has been around for a while and we are lucky that while technically a
bug it still works as expected. Passing a negative idx simply turns it
into a very large unsigned integer which then fails the > dive_table.nr
test. So it still gets a NULL returned. A bug? Yes. Critical? No.

Mismatched allocation and free

This is an actual bug that potentially could cause issues. We allocate
memory with malloc and free it with g_free. Not good.

Reported-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-18 20:25:45 -04:00
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
b150c4fd41 Make sure all parts of the edit dialogs are using current_dive / edit_dive
While most of this problem was fixed in commit 18b3dca431a4 ("Fix a long
standing bug when editing dives"), it turns out that I missed a couple of
the equipment callbacks.

In the corner case of having an empty divelist (where therefore
current_dive == NULL) manually adding a dive and trying to add equipment
(cylinder or weightsystem) to it would crash subsurface as we were trying
to dereference current_dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-13 20:41:21 -07:00
Dirk Hohndel
41d3a11ee3 Fix a long standing bug when editing dives
Calling edit from the context menu creates a combined editing widget that
contains both dive info and equipment. When editing cylinders or
weightsystems from that widget and confirming those edits with OK those
changes were already committed to the current_dive - regardless on which
dive the user clicked. Worse, even when the user clicked Cancel in the
edit widget, any changes to the equipment stayed in effect.

This had especially confusing consequences when editing multiple dives.

As a workaround this commit adds a global edit_dive variable. This fake
dive is edited by the secondary editing widgets and if the user accepts
changes with OK then they are copied over to the current dive (or all
selected dives in multi dive editing mode).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-11 13:37:06 -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
21fd73515f Ignore Nitrox/He seetings when editing cylinders for multiple dives
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-26 12:29:58 -07:00
Dirk Hohndel
c26c370c2b Correct multi-edit equipment update logic
I lied in the commit message for commit 0468535524a3 ("When editing multiple
files, don't override existing equipment entries"); the changes there did
not parallel the logic for the string entries. Now I think it does.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-18 08:28:52 -07:00
Dirk Hohndel
5487606fda Fix crash when editing weight system info
I missed one instance where a callback function needed to be passed the widget
index w_idx in the signal_connect function. It got passed a pointer to the
model instead which of course blew up when trying to dereference the array with
that "index".

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-18 06:24:49 -07: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
4912951e97 Remove weightsystem entry with no description
This existed in the initial implementation to deal with an implementation
problem that was long since resolved. So now it just created just an ugly
empty line in the drop down menu for weightsystems.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-06 13:56:46 -07:00
Dirk Hohndel
8cdf1ab59f Remember the last weight used per weightsystem
With this change, if the user adds a new weightsystem to a dive, on
subsequent edits the weight amount for this weightsystem no longer
defaults to 0 but to the last weight that was used with this weightsystem.

So when the program imports a set of dives from the divecomputer and the
user starts editing them, once they enter the weight for the "integrated"
weightsystem the first time, for each of the consecutive dives that same
weight is the default once "integrated" is selected - which usually will
be the correct amount.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-06 13:03:20 -07:00
Dirk Hohndel
698892329a Fix edit callback for weight system
Linus found this embarrassing bug: double clicking on a weight system in
order to edit it launched the edit function for the first cylinder
instead. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-04-23 19:54:11 -07:00
Linus Torvalds
3a7d577ff1 Fix reference tank information for LP steel tanks.
Commit f9bb3f7910 ("Clean up reference tank information table") had
cleaned up the tank info list so that you could sanely do tanks in
liters and with a working pressure in bar.

But the LP steel cylinders had somehow missed out on the ".psi =" part
of the equation, and as a result, what was supposed to be their working
pressure instead ended up being interpreted as their size in
milli-liters.

Oops.

Fix that, and also make the standard tank info filling code actually
verify the sanity of the reference tank table, so that if this happens
again, it will complain loudly instead of using nonsensical values.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-04-01 15:38:52 -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
Dirk Hohndel
3d75c73f36 More removal of unused arguments
Just trying to clean up the code a bit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-05 08:16:50 -08:00
Henrik Brautaset Aronsen
16b6df559f Define O2 permille for air in one spot
Having the O2 permille defined once is more readable.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
2011-12-31 17:15:59 +01:00
Dirk Hohndel
4dfbb7394f Remove unused return value
We never use the number of decimals that this function returns. So we
might as well not return them to begin with.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-26 16:46:06 -08:00
Linus Torvalds
10c74eb31d Add the "Common European Cylinders" as per Henrik
This is Henrik's list of common metric sized cylinders, although my
experience differs from this one.  In Cyprus, I was diving double 12L
cylinders, but they were 200 bar, not the 232 bar ones Henrik has on the
list.

Also, I really think we should just have a checkbox for "double" instead
of naming them explicitly like this.  Henrik does have the 12L 200 bar
ones in his singles list.

But as a stop-gap, I'm just taking the values from Henrik's patch, but
converted to the new cleaned-up reference tank model setup.

Based-on-patch-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-12-11 12:03:55 -08:00
Linus Torvalds
f9bb3f7910 Clean up reference tank information table
This makes the reference tanks ("struct tank_info") use a saner format
which specifies explicitly whether the size is in ml or cubic feet, and
whether the pressure is in psi or bar.

So instead of having magic rules ("size is in cuft if < 1000, otherwise
mliter"), just set the size explicitly:

	{ "11.1 l", .ml = 11100 },
	{ "AL80",  .cuft =  80, .psi = 3000 },

and then the code can just convert to standard measurements without any
odd rules, and the initialization table becomes self-explanatory too.

This is in preparation for doing the metric tanks with pressure: Henrik
Aronsen sent a really ugly patch using the previous setup, I just
couldn't stand the additional hackery.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-12-11 11:54: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
50d026230f Allow editing of Helium values in cylinder info
Henrik Aronsen points out that we've not made it possible to edit the He
percentages for trimix diving.  It's easy enough to do, I just didn't
have any dives that needed it myself.  So here goes.

Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-12-11 11:09:37 -08:00
Linus Torvalds
9b1ea2ae6d Use common helper function for the "no cylinder info" case
Miika fixed the statistics code that didn't properly check for the "no
cylinder info" case - this cleans it up and just uses the helper
function in equipment.c.

Rename the helper to be slightly better named while at it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-12-09 09:52:59 -08:00
Linus Torvalds
9f500ec8dc Add the cylinder list to the dive info edit dialog
This way, when you have a new dive that you just imported from your dive
computer, you can just double-click on the dive and fill out all the
relevant information: location, notes, buddies and cylinder info.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-19 11:47:04 -08:00
Linus Torvalds
1efcf4538b Make double-clicking on the dive list bring up the dive editor
Now that the dive info window is read-only, we need to edit the dives
some other way.  We bring up a dive info edit dialog when you
double-click on the dive list entry for that dive.

I do want to have an "edit" button or keyboard shortcut or something
too, though.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-19 10:11:56 -05:00
Linus Torvalds
842b05415f Make all the normal widgets uneditable and non-focusing
We always keep the focus on the dive list, so that the random gtk focus
handling doesn't suddenly randomly make us edit the combo boxes when the
cursor up/down keys start changing them instead of the dive list.

This means that dive location, notes and buddy/divemaster aren't
editable at all any more, but I'll fix that by making a separate dive
edit popup window.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-18 11:13:02 -02:00
Dirk Hohndel
4891fa812f Fix minor coding standard issues introduced by my last commit
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-13 15:51:34 -02:00
Dirk Hohndel
97a1dd6830 Make sure SAC and OTU get recalculated after cylinder info was changed
Also fixed minor coding style issues (prevent useless code from being
executed).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-13 15:29:07 -02:00
Linus Torvalds
c51b105526 Add "enable" button for manual pressure setting
This grays out the pressure settings in the cylinder editing widget if
the pressure data has been taken from the samples.  You can still
manually override the data, but you now need to enable that manual
override explicitly.

This makes the semantics of editing start/end pressures of dives with
pressure sample data a bit more intuitive, I think.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-09 08:57:06 -08:00
Linus Torvalds
8e6bdc4f94 Keep the start/end spinbuttons as GtkWidget
For graying things out, we want a widget, not a spinbutton.  Although
I'm sure we could just cast things back and forth.  But let's be
consistent with what we do, and only ever cast from GtkWidget to
GtkSpinButton, and have the same logic as for the "o2" widget that also
needs to be explicitly enabled.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-09 08:37:49 -08:00
Linus Torvalds
04b076cf40 equipment: clean up cylinder pressure spinbutton setup
This is just in case I end up doing the graying out of implicit pressure
information: I wanted to clean things up a bit first.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-09 08:33:13 -08:00
Linus Torvalds
049b895d9b Show the newly split pressures correctly in the equipment page too
NOTE! When *editing* the cylinder data, the only thing shown is the
non-sample pressure.  So the cylinder editing widget will show zero for
start/end pressure for a dive that has pressure saples without any
manually set pressure data.

This is intentional, so that you can clearly see that this is not a set
value.  But it may be that we should gray out the spinputton and have an
"edit value" checkbox or something to make it really obvious.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-09 08:21:48 -08:00
Linus Torvalds
2b26b6433f If we don't have cylinder working pressure, we sill want to show the volume
.. although in that case we can only ever show the volume in liters, and
cannot do a conversion to cubic feet even if the user has set imperial
units.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-09 07:59:28 -08:00
Dirk Hohndel
485b02937d Even more places with pressure and volume conversions
Amazing at how many spots we are re-implementing the wheel.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-01 21:34:06 -07:00
Dirk Hohndel
5698057951 Further cleanup of pressure and volume conversions
I'm amazed at how many spots we were doing conversions - some of them
subtly different than others.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-01 21:00:46 -07:00
Linus Torvalds
bf33bf879f Add 'activate' callback for the cylinder completion
This makes us fill in the size/pressure data for a cylinder even if we
just type the name (rather than pick an entry from the list)

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-23 09:45:35 +03:00
Linus Torvalds
0b4814a95d Add a completion for the cylinder type entry combo box
This allows us to start typing the cylinder description and we'll get a
matching list that we can select.  This is similar to selecting one from
the model, and works in addition to the explicit selection.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-22 19:39:03 +03:00
Linus Torvalds
f9cb526c96 Add cylinder data to cylinder model as we record each dive
This way the cylinder model list will contain all the different
cylinders that we have ever seen, rather than only containing the models
that we have *edited*.

That makes it much more practical to add new dives with the same
cylinders that we've used before, because now those cylinders will show
up as cylinder models even if we haven't looked and edited the old dives
first.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-22 18:12:30 +03:00
Linus Torvalds
567c945714 Fix the reading of the cylinder start/end pressure from cylinder models
The cylinder model doesn't contain the start/end pressures, they just
contain the cylinder type information.  So trying to read the start and
end pressure from the cylinder model change callback is totally bogus.

We need to set the start/end pressures from the cylinder info when we
create the cylinder widget, and not touch them when the type changes.
So split up the "set_cylinder_spinbuttons()" function in two: one that
sets the type information, and one that sets the start/end pressure.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-22 17:22:13 +03:00
Linus Torvalds
a9709a5e07 Repaint dive after equipment change only after updating the cylinder info
Repainting the dive will end up touching the cylinder list store, so we
should finish setting the cylinder info before we repaint it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-21 16:14:45 +03:00
Linus Torvalds
41084817ea Repaint the dive after equipment changes
Those changes may have changed cylinder sizes and beginning/end
pressures, so the dive profile and SAC rate may be different.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-21 15:55:52 +03:00
Linus Torvalds
2b3d39f6fc Add start/end pressure to cylinder edit dialog
This finally allows you to set the start/end pressures by hand.

HOWEVER! Right now, if we have samples with pressures, those samples
will always end up overriding anything you set manually.  Which can be
very annoying if your wireless air integration fails halfway through.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-17 11:12:11 -07:00
Linus Torvalds
776355cf10 Remove cylinder index from cylinder list model
Instead of having to keep the index up-to-date as we edit entries
around, just figure out the entry index from the model itself.  Gtk
seems to make it unnecessarily hard, but what else is new?

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-02 19:14:00 -07:00
Linus Torvalds
23c2b43c10 Make cylinders editable with a double-click
You can still just select them and click the "Edit" button too, but now
you can double-click them (or select them and press "enter") for editing
too.

It seems to be the natural interface.

Also, remove the index column (that was there for debugging), and add
grid lines.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-02 19:03:46 -07:00
Linus Torvalds
d51f40bdcf Change calling convention of 'edit_cylinder_info'
Instead of passing it the model and iterator (which requires that we
create the new entry for an 'add' event even if we then cancel the
operation), just make the caller do the final cylinder list update.

This way we can make 'add' work more sanely: if you cancel the add, we
now do not create an empty cylinder entry at the end.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-02 17:16:50 -07:00
Linus Torvalds
3e1b3c5c7f Make the cylinder 'delete' action actually delete the cylinder info
It used to just update the cylinder list widget data, not the actual
dive information.

It still needs an "accept or cancel" dialog, I suspect.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-02 16:58:53 -07:00
Linus Torvalds
ed157e4288 First cut at working cylinder editing dialog
This currently only does the same old things we used to do (so still no
start/end pressure or trimix support), but despite that this is already
more flexible than the old model:

 - we can now add new cylinders, rather than just edit the information of
   the first two cylinders of the dive

 - because the cylinder editing is being done in a edit dialog, it is
   now much more reasonable to use multiple lines and expand all the
   things we can edit.

But to actually make this fully fledged, we'll need to add all the other
info to the cylinder edit dialog, and probably add a confirmation dialog
for the "delete cylinder" case too.

Oh, and right now deleting a cylinder doesn't mark the dive info changed.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-02 16:41:17 -07:00
Linus Torvalds
3c7218287b Start hooking up the cylinder editing widget
We don't actually fill the widget info correctly yet, nor do we take the
actual size from the changes, but this starts to hook things up.

Soon.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-02 16:16:08 -07:00
Linus Torvalds
c49d2439e8 Add the ability to add new cylinders
This is totally useless since you cannot actually *edit* the resulting
new dive yet, but we'll get there.  And this already conceptually shows
a capability that we didn't use to have with the old interface.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-02 13:42:51 -07:00
Linus Torvalds
fa86f973a3 cylinder list: set edit/delete button sensitivity
They are only sensitive when there is a cylinder selected.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-02 13:27:03 -07:00
Linus Torvalds
9afcee3b17 Start re-organizing the cylinder entry in equipment.c
This leaves the actual editing code unconnected, so now you can only see
the cylinder information, not actually edit it.  However, with the big
re-organization I really do want to have this as a half-way point where
I have created the new cylinder tree-view.

I now need to connect the "add/edit" buttons to dialogs that then use
the editing widgets - so I've left that widget code around, because I'll
be able to reuse a lot of it.  Not all, but the cylinder type model code
in particular will be re-used pretty much as-is.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-02 13:13:27 -07:00
Dirk Hohndel
56a24917cb Allow larger tanks (change maximum from 200 to 300 cuft)
We don't handle doubles any different than single tanks - so while
200 cuft was a sane maximum size for a tank, once you dive with
doubles this logic fails.

We may or may not decide to implement special handling for doubles at some
point, but for now simply allow for tanks all the way up to double-150.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-29 17:42:58 -07:00
Dirk Hohndel
189bec0c6b Tracking changes to tanks is trivial
That's the one I should have started with.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-21 11:29:13 -07:00
Dirk Hohndel
682135838f Separate out the UI from the program logic
The following are UI toolkit specific:
gtk-gui.c   - overall layout, main window of the UI
divelist.c  - list of dives subsurface maintains
equipment.c - equipment / tank information for each dive
info.c      - detailed dive info
print.c     - printing

The rest is independent of the UI:
main.c i    - program frame
dive.c i    - creates and maintaines the internal dive list structure
libdivecomputer.c
uemis.c
parse-xml.c
save-xml.c  - interface with dive computers and the XML files
profile.c   - creates the data for the profile and draws it using cairo

This commit should contain NO functional changes, just moving code around
and a couple of minor abstractions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-20 12:48:56 -07:00
Linus Torvalds
9cf8d98711 Make 'struct DiveList' entirely internal to divelist.c
Passing it around is just annoying, and we only ever have one.  Let's
not burden all the users with the silly thing.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20 10:06:24 -07:00
Linus Torvalds
eee34232db Add "Apply"/"Cancel" buttons to dive equipment page
It's too damn easy to make mistakes and not even notice them (odd gtk
widget selection and keyboard input), or just start editing a cylinder
thing and realize it was wrong.

So instead of always saving the equipment information implicitly, add
explicit "Apply" and "Cancel" buttons that save the information (or
re-load it from the dive data structure)

So now you need to press an extra button for your changes to *really*
take effect.  It can be a bit annoying, but it's better than the silent
accidental equipment change that could happen before.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20 09:59:09 -07:00
Linus Torvalds
c7b9387d4b Separate the notion of creating the cylinder widgets from showing them
Now we always create the MAX_CYLINDER sets of cylinder widgets.  But we
don't actually pack them into the frame - that's a separate phase.

Right now we still do the stupid "always just pack two cylinders" thing,
but the idea is that we can pack just as many as the dive needs on a
per-dive basis.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-13 13:50:03 -07:00
Linus Torvalds
a92811351b Make multiple cylinders actually work
This just always shows two cylinders, which is obviously bogus, but it's
a good test-case for the multi-cylinder case.

I need to figure out how to dynamically show the right number of
cylinders, but that also involves the notion of adding a cylinder in
order to fill out information that didn't use to exist.

That's lower priority - now the infrastructure seems to be there.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-13 13:25:06 -07:00
Linus Torvalds
a4c9cc110f More work on abstracting the gtk cylinder widget thing
Ok, now we have an array of them, and most of the time we pass the right
pointer back and forth.

There's still a couple of places that hardcode "gtk_cylinder[0]" as the
data, but by now they are mostly things that should iterate over all the
cylinders.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-13 13:15:31 -07:00
Linus Torvalds
b19b76ecfa Start abstracting out the cylinder equipment widgets
Create a "struct cylinder_widget" so that when we handle multiple
cylinders, we can match them up with the actual cylinder data;

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-13 12:58:53 -07:00
Linus Torvalds
cb2f70f631 Always pack the widgets into boxes, not frames
Let's try to be consistent about this.  Make the parent of each widget
be a box.  Maybe the frames come with boxes, but since I have no clue
about gtk, I'm going to just always create them by hand.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-13 11:59:37 -07:00
Linus Torvalds
5a47bdc9c4 Add a checkbox for nitrox settings
Grey out the nitrox value unless the user explicitly checks the checkbox.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-13 11:47:20 -07:00
Linus Torvalds
c96e2d1767 Pack all the equipment widgets into boxes
We really do want to "pack" them, rather than use up the whole size.  I
think.

I may end up playing around more with this.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-11 15:49:50 -07:00
Linus Torvalds
d1b30212ff Add more static cylinder types - and pick them up from the dive log
This adds a few more predefined cylinder types to the static list, but
perhaps more importantly, if we try to show a cylinder description that
we haven't seen before, we automatically add that description to the
list as well.

This way, if people have their own cylinder types, our cylinder
management will automatically figure them out and make it easy to enter
them.

NOTE! It might be best to add the new cylinder description at dive log
load time, rather than at 'show' time.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-10 17:14:07 -07:00
Linus Torvalds
1fe687a16c Add new cylinder models to the cylinder model store
We also need to actually fill the model store with the cylinder models
we have in our dive lists to begin with.

This makes it all *trivial* to add a new cylinder model: just use a new
description, fill in the size and working pressure, and you're done.
The type automatically gets filled in, unless that description already
existed (in which case we leave it alone).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-10 16:27:19 -07:00
Linus Torvalds
c43e1ad21b Let people manage their cylinders in cuft and psi
If the output units are set to cuft and psi, then we should show the
cylinder size and pressure properly.

NOTE! In the absense of pressure data, we *always* show the cylinder
volume in liter.  There's no way to convert it to imperial units, since
the imperial units are not in physical size, but in air volume
normalized to surface pressure..

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-10 15:27:23 -07:00
Linus Torvalds
e48cebc2d8 Actually connect the cylinder configuration with the dive
It seems to be sufficiently useful to be worth updating the dive
information now.

This still doesn't handle multiple cylinders in any way.  I need to
think about the interface for that.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-10 11:09:39 -07:00
Linus Torvalds
ed8561bf59 Getting closer to a usable cylinder management interface
Not quite there yet, though. And never mind multiple cylinders..

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-09 21:39:54 -07:00
Linus Torvalds
8f12eed9e0 First (broken) try at actually tracking cylinder types
This doesn't actually change the cylinder type info in the dive, because
it's too broken for that.  Instead it prints out what it would change
things to.

The gtk2 notion of text input focus is *really* odd.  Why is the
cylinder type sometimes selected, and sometimes not?

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-09 19:46:53 -07:00
Linus Torvalds
067506038a Rename 'cylinder.c' as 'equipment.c'
Make it about general equipment management, and start hooking up
functions to show new equipment information when changing dives (and to
flush changes to equipment information for the previously active dive).

Nothing is hooked up yet, and it's now showing just one (really big)
cylinder choice, so this is all broken.  But it should make it possible
to at least get somewhere some day.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-09 17:10:17 -07:00
Renamed from cylinders.c (Browse further)