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>
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>
* 'minor-fixes' of git://github.com/dirkhh/subsurface:
Fix "Keep window size for new notebook pages" to not set minimum size
Make the first filename on the command line the default filename
Turns out I used the wrong function to keep the size of notebook pages
that were ripped off. Using gtk_widget_set_size_request on the new
notebook creates a hard minimum size for this window.
Instead we should use gtk_window_set_default_size on the new window that
is the parent of the notebook. This has the desired effect of creating the
new window with the same size as the one the page was ripped off from -
without making that the minimum size for this window.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
From a usecase point of view - if we call with multiple file names then
most likely it's
subsurface MyDives.xml new_dive1.xml new_dive2.xml
and therefore the existing "database" is the first filename, not the last
one (as the current implementation assumes).
Frankly, this is a bit arbitrary - but this one seems to make more sense.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
At this point we don't do anything with this - the commit just provides
the infrastructure changes so that this becomes possible. Subsurface
behaves the same if exactly one dive is selected and simply keeps the last
selected dive if zero or more than one dives are selected.
The goal is to be able to select multiple dives and then do actions on
them. For example pick a tank used for all of them. Or edit the location
or (yet to be implemented) other equipment data like weight carried.
And also to be able to merge multiple dives.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I clearly had never tried this with a dive that used the "just air"
setting the uemis. With this fix the cylinder data for that one tank is
read correctly.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This isn't right if you switch back to the same cylinder multiple times,
but for the first time it kind of works - just take the beginning
cylinder pressure if we have one.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Too much cut-and-paste, as Dirk points out. With multiple cylinders,
we're not necessarily going to start at time zero.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
We used to set a fixed size instead of just copying the size that the
existing notebook has - which didn't really feel right when resizing and
then ripping of a page.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We would save it in the xml file, but then not actually read it back
properly. Oops. Not that we actually have any multi-tank dives yet, so
it doesn't matter. Yet.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
It doesn't actually do multiple cylinders correctly yet, but it should
be a nice framework for it. And accidentally (not) it also ends up
drawing the final line for the end pressure of a single-cylinder dive
that has been fixed up by hand too.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
If we have en explicit end pressure in the dive information, we should
not change it just because we also have some samples. The sample data
may not be complete (read: "Linus wireless connection dropped during the
dive again, and he fixed up the end pressure manually afterwards").
The beginning pressure already works correctly, because it will only use
the sample data for the first sample if no pressure existed before.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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>
This allows us the specifiy libdivecomputer's cflags (and also the
library, static or dynamic) outside of the Makefile
Signed-off-by: Martin Gysel <me@bearsh.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
make DESRDIR a prefix of everything according my understanding
of the GNU standards. This is also useful(/needed) for installing
in Gentoo. Declare BINDIR for bin/program directory.
Signed-off-by: Martin Gysel <me@bearsh.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Commit bd8948386d ("Since we don't want configure, use gnumake to find
libdivecomputer") was totally broken. Sure, using GNU make features is
fine. But then hiding in that commit is the fact that it also changed
it to use "-ldivecomputer" instead of just linking with the static
libdivecomputer archive.
And that's just a really bad idea. Dynamic linking is useful for things
like libc, where it allows sharing of the code pages across all the
programs using it. For something like libdivecomputer it's just a *bad*
idea, and doesn't even work. The libdivecomputer interfaces aren't
stable enough to make it a good idea even if it *did* work, and the
libdivecomputer "make install" phase doesn't do the proper ldconfig etc
setup anyway.
Static linking is just simpler and better. It also means that the
binary will work even if you move it around to another machine - since
libdivecomputer isn't exactly a "standard library"..
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
I'm trying to get subsurface to get closer to becoming a "regular desktop
application"; so far this is based on the recommendations and guidelines
on OpenSUSE and Fedora.
The icon is now named subsurface.svg and make install installs it in the
correct location. At runtime subsurface first checks if an icon is
installed and if it is it uses that - otherwise it falls back to the old
code that tries to read the svg file from the current directory.
We also install a subsurface.desktop file
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Using '%f' limits the precision to 6 decimals, which may well be
perfectly ok. But at least in theory you *could* have higher precision,
and gps units will report it, so don't mindlessly limit us to what %f
shows.
This arbitrarily uses '%.12g' instead. %g will drop excess zeroes at
the end, so it actually results in the same (or shorter) ascii
representation unless you have the extra precision.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Remove casts from/to void*. They are unneeded in C, can hide problems
in the future, and are far too C++ish. Furthermore, they were
inconsistent with the rest of the code and even with regards to
themselves (at least in terms of whether or not to have space after the
cast).
In this case, we temporarily lose const specifiers in libdivecomputer.c
due to the unneeded cast, so it seems better to avoid the cast at all,
so you get warned about a const->non-const cast if you ever change it to
do something like this.
The casts in gtk-gui.c are just useless semantically, although they
might be useful as a hint to the reader that the void pointers are char
arrays.
Signed-off-by: Julian Andres Klode <jak@jak-linux.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
If we choose a file in the import dialog then this should imply clicking
OK in that dialog - no reason for a two step process.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
That's a gtk limitation.
So you have to import XML files one at a time. If this is too big of a
restriction then we need to redesign the import dialog.
Sgned-off-by: Dirk Hohndel <dirk@hohndel.org>
Minor logical flaw that breaks the model.
When the --import parameter is found we need to mark that the FOLLOWING
dives are imported, not the ones loaded so far.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Open (or adding a file name on the command line) means that this is just
one of the files that you consider part of your dive history. So dives
don't get automagically numbered and the dive_list is not considered
"changed" just because another file was opened.
Import (or adding a file on the command line after --import) means that
you are importing the content of this file to your dive history. So if the
imported file has un-numbered dives that are newer than everything else,
those get correctly renumbered. And importing marks the dive_list as
changed.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This option indicates that all files that come AFTER it on the command
line are being added to our divelist. The dives in these files should
receive numbers (assuming they are un-numbered and are all newer then the
dives in the files before the --import option, and assuming those dives
are numbered).
This also marks the dive_list changed after the new dives are added.
Using this option gives us a reasonable user experience in the case where
a user has one file with all their dives and wants to add newer dives
after this (after extracting them from a dive computer - as in the case of
a uemis owner where there is no direct import from the dive computer,
yet). Something like
subsurface MyDives.xml --import NewDives.SDA
It also doesn't break Linus' vision where the user has many files on the
command line which don't imply a changed dive_list.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The behavior is not yet consistent when calling with multiple file names
on the command line (as we don't add number to the later ones in this
case), but at least it catches the case if you manually renumber the dives
or if you import new dives that get added at the end - which are the two
most typical cases.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If renumbering a list of dives, default the start number to the existing
first dive number. That way, if you do need to renumber (overlapping
import or whatever), but your at least had your really old dives already
numbered, we start off with a sane default.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
When importing (or reading xml from files) new dives, we now renumber
them based on preexisting dive data, *if* such re-numbering is obvious.
NOTE! In order to be "obvious", there can be no overlap between old and
new dives: all the new dives have to come at the end. That's what
happens with a normal libdivecomputer import, since we cut the import
short when we find a preexisting dive.
But if any of the new dives overlap the old dives in any way, or already
have been numbered separately, the automatic renumbering is not done,
and you need to do a manual renumber.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
All the callers were always calling report_dives first, followed by
dive_list_update_dives(). And there really was no reason to have the
callers call two separate functions for the "I've added new dives" case.
So just call dive_list_update_dives() directly from report_dives(), and
remove it from the callers.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Depending on the tool used to import a dive from the uemis Zurich we end
up with different time stamps for the dive - just by a few seconds, but
the existing code insisted on an exact match.
We now allow for up to 60 seconds in difference and still consider two
dives as the same.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We draw a little red triangle (of hardcoded size - not sure if this SHOULD
scale with the size of the plot... I like it better if it doesn't) to the
left of an event.
We then maintain an array of rectangles that each circumscribe one of
those event triangles and if the mouse pointer enters one of these
rectangles then we display (after a short delay) a tooltip with the event
text.
Manually creating these rectangles, maintaining the coordinate offset,
checking if we are inside one of these rectangles and then showing a
tooltip... this all seems like there should be gtk functions to do this by
default... but if there are then I failed to find them. So instead I
manually implemented the necessary logic.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Previously we passed in width and height and the routine itself decided to
keep 5% margin around each edge - oddly doing this with double precision,
even though this is all integer coordinates.
Instead we are now passing in a drawing_area. We are kind of abusing the
cairo_rectangle_int_t data type here - but it seemed silly to redefine a
new data type for this.
Width and height give the size of the TOTAL drawing area (as before).
x and y give the offset from the edges - so the EFFECTIVE drawing area is
width-2x and height-2y
This is in preparation for adding tooltips - those need to know the
coordinate offsets from the edges - so having this hard coded inside the
plot function didn't make sense anymore.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
* 'uemis-integration' of git://github.com/dirkhh/subsurface:
Much nicer implementation of uemis sample parsing - and add events, too
Add working pressure to uemis tank data
This is something I wanted to do for a while. Every uemis sample is simply
a packed structure with no padding. Instead of grabbing random bytes from
the middle of an unstructured data blob let's just define the structure
and access its members.
And while we do that, add support for the more useful uemis events as
well.
A couple of the warnings are disabled by default (compile time flag) as
they are just crazy - any normal dive will give you dozens and dozens of
speed warnings. Same goes for the PO2 green warning (I haven't looked but
this seems to trigger on a PO2 over 1.0 or something). Completely useless
and just hides actually useful info.
I still want to redo the way we visualize events in general - just
printing the text ontop of the profile really is suboptimal. Especially as
the uemis really seems to love to repeat several of the warnings quite
frequently.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
* 'uemis-integration' of git://github.com/dirkhh/subsurface:
Remove the ability to 'Import' .SDA files
Integrate loading of uemis SDA files into the regular xml parsing
First steps towards integrating SDA files into the default XML loading
Turns out they use 202.6bar as default working pressure. WTF?
Also I had misunderstood the way I should record the pressure internally
(which happened to work since I didn't set the working pressure). This is
now fixed as well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Turns out they use 202.6bar as default working pressure. WTF?
Also I had misunderstood the way I should record the pressure internally
(which happened to work since I didn't set the working pressure). This is
now fixed as well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>