actual planning
Yes, you can actually enter your segments now.
No, it's not wonderfully user-friendly. If you don't enter enough
segments to create a dive plan, it will just silently fail, for example.
And the <tab> key that should get you to the next editable segment
doesn't. And so on. But it kind of works.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This doesn't actually do the real work yet, but it creates all the
infrastructure to edit a tree model, and verify the contents for time,
depth and gas mix.
Now we just need the ability to add entries to the tree model (this adds
one fake one, just to test the editing), and then read out the final end
result and turn it into a plan.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is not doing anything (which is why there are so many unused variable
warnings). It's just a couple of entries lined up to give a visual
impression how some of this could look.
I am not a UI designer. And there are good reasons for that...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This comes with absolutely no gui - so the plan literally needs to be
compiled into Subsurface. Not exactly a feature, but this allowed me to
focus on the planning part instead of spending time on tedious UI work.
A new menu "Planner" with entry "Test Planner" calls into the hard-coded
function in planner.c. There a simple dive plan can be constructed with
calls to plan_add_segment(&diveplan, duration, depth at the end, fO2, pO2)
Calling plan(&diveplan) does the deco calculations and creates deco stops
that keep us below the ceiling (with the GFlow/high values currently
configured). The stop levels used are defined at the top of planner.c in
the stoplevels array - there is no need to do the traditional multiples of
3m or anything like that.
The dive including the ascents and deco stops all the way to the surface
is completed and then added as simulated dive to the end of the divelist
(I guess we could automatically select it later) and can be viewed.
This is crude but shows the direction we can go with this. Envision a nice
UI that allows you to simply enter the segments and pick the desired
stops.
What is missing is the ability to give the algorithm additional gases that
it can use during the deco phase - right now it simply keeps using the
last gas used in the diveplan.
All that said, there are clear bugs here - and sadly they seem to be in
the deco calculations, as with the example given the ceiling that is
calculated makes no sense. When displayed in smooth mode it has very
strange jumps up and down that I wouldn't expect. For example with GF
35/75 (the default) the deco ceiling when looking at the simulated dive
jumps from 16m back up to 13m around 14:10 into the dive. That seems very
odd.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The old implementation was broken in several ways.
For one thing the GF values are percentages, so they should normally be
0 < GF < 1 (well, some crazy people like to go above that).
With this most of the Bühlmann config constants were wrong.
Furthermore, after we adjust the pressure tolerance based on the gradient
factors, we need to convert this back into a depth (instead of passing
back the unmodified depth - oops).
Finally, this commit adds closed circuit support to the deco calculations.
Major progress and much more useful at this stage.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This seems like a strange way to capture the FOCUS_CHANGE event, but
manually trying to register a callback for it fails. Yet registering a
callback for every event and then filtering for FOCUS_CHANGE in the
callback works. Go figure.
But with this commit you can actually change the GF settings in the
preferences dialog and once you tab out of the entry field the change gets
immediately applied - nice to play with the effects of changing GF values.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There were some minor problems when moving the selection
cursor around:
1) If the selection was larger than 1, it was possible
for the selection to get "stuck" in the middle of the list.
This patch approaches this by always calling
gtk_tree_selection_unselect_all() before
gtk_tree_selection_select_iter(), or simply always making
sure we have one selected iterator when navigating with the keys.
2) When there was a single top level dive before the first trip
it wasn't possible to navigate trough the child dives of said
trip in both directions.
The patch attempts to fix this by having the hunks/checks:
if (idx < 0) {
(idx is of a trip) performed regardless of other conditions.
*** Note: testing was done by importing all test*.xml
dives with auto-group on.
[Dirk Hohndel: adjusted the patch to also fix on_key_press to only grab
the key if no modifier key is pressed; otherwise this
breaks shift-cursor-keys for selecting multiple dives.]
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There are a couple of issues with this commit:
GtkEntry should emit the 'changed' signal when it is modified (so that
changes in the preferences get applied right away) - but that doesn't
appear to be working consistently.
Also, this doesn't appear to affect the deco of any dives that I try it
with. So my guess is something is wrong with the underlying deco
algorithm. That's diappointing.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Usually dive computers show the ceiling in terms of the next deco stop -
and those are in 3m increments. This commit also adds the ability to chose
either the typical 3m increments or the smooth ceiling that the Bühlmann
algorithm actually calculates.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is on top of the deco information reported by the dive computer (in a
different color - currently ugly green). The user needs to enable this via
the Tec page of the preferences.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This function had a couple of bugs. Two different off by one errors and on
top of that it was matching only the deviceid instead of model and
deviceid.
So I simply rewrote it to match against the full pattern and take a much
more straight forward approach to replacing the entry for the divecomputer
under consideration. If the new nickname is entry this implementation
allocates one extra byte - but that didn't seem worth the extra code to
fix it.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
And include the compatibility header to build on newer versions.
Reported-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Having two spots to toggle autogroup had always been a clear sign of
insanity. The inconsistent ludicrous semantic of when we remembered the
state of autogroup was even worse.
This finally gets rid of that disaster and drops the autogroup setting
from the preferences and makes it instead a per file property. When you
save a file, it saves the state of the autogroup toggle. This seems much
more useful - you may have files where you want to create trips by
default. And others, where you don't.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When called from the parser the model string is freed right after passing
it to remember_dc. So we need to get our own copy.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Right now this isn't used but it will be needed for the yet to be written
UI to manage our divecomputer database.
This commit also fixes an oversight in the remember_dc function. Updates
to nicknames weren't committed to the config.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The existing code had the somewhat retarded Ctrl-C binding for displaying
the next divecomputer and no way to go back to the previous one. With this
commit we use our keyboard grab to map Left and Right to previous and next
divecomputer. Much nicer.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit steals the cursor up and down keys away from gtk so regardless
where gtk thinks the focus may be, we can still use the keys to change
between dives.
In the current UI design where all editing happens in separate windows
this works as expected, as we only grab the keys for the main window. If
we manage to re-enable in-place editing then we need to make sure that
this doesn't cause problems (as gtk uses up/down for the ability to change
drop down selections in combo boxes or values in spin buttons. So we must
make sure that we stop stealing these keys once we start editing something
(in which case simply switching to the next/prev dive wouldn't be a good
thing, anyway).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There is no point writing out divecomputer nicknames that do not exist
(or that match the dive computer model), so don't.
Also, make the function to do this static to save-xml.c, which is the
only user (I initially didn't _find_ the function to create the XML
string because it was illogically hidden in gtk-gui.c), and change the
calling convention to be more direct (pass in a string and return a
result, rather than modify a "pointer to string").
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Those only come from a number of development versions of Subsurface that
didn't include the deviceid in the divecomputer entry. There is no way of
telling different dive computers (of the same model) apart, so assigning a
nickname to such an entry then creates incorrect output when loading an
XML file from someone else (e.g. Linus and I both have a Uemis SDA and
both may have entries for our own SDA with deviceid 0; then the nickname
Subsurface shows for any Uemis SDA entry with a deviceid of 0 depends on
whether I last loaded his XML file or mine; that makes no sense).
This should only affect the develoers who stored XML files with one of the
development version of Subsurface that didn't store deviceids.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There was one code path where we didn't strdup the nickname - and this got
triggered when parsing XML files with divecomputerid entries for dive
computers that were already in the config. The nickname is then replaced
with the nickname from the parser - and that memory is later reused...
We should cleanup that nickname, anyway, and that also takes care of
making sure we have our own copy.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We only store the model/deviceid/nickname for those dive computers that
are mentioned in the XML file. This should make the XML files nicely
selfcontained.
This also changes the code to consistently use model & deviceid to
identify a dive computer. The deviceid is NOT guaranteed to be collision
free between different libdivecomputer backends...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Trying to simplify the API for nickname handling I went a bit too far. We
indeed need to different API calls, one that returns an entry in the
nicknamelist for the deviceid that we have. And one that looks if there is
an entry for a different deviceid but the same model that we have.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Now it is able to replace nicknames for existing entries (which will be
needed by the yet to be written UI).
This commit fixes a couple issues with the previous code:
- a potential SIGSEGV with malformed config entries
- missing closing parenthesis in the dialog box text
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The "Tec settings" dialog contains some strings with the
subscript "2" character, which have to be translated. While
the "2" is part of the string xgettext doesn't seem to recognize
such. To trick it we use a temporary buffer and c-format:
sprintf(utf8_buf, _("Show pO%s graph"), UTF8_SUBSCRIPT_2);
button = gtk_check_button_new_with_label(utf8_buf);
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
init_ui():
We add the char pointer "conf_copy" and free it afterwards, since
once "next_token" is changed it no longer points to the allocated heap
location the mapper returned.
[Dirk Hohndel: original patch rewritten to have better variable names and
to match the recent changes to this code]
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We now store the model information together with the deviceid and nickname
in order to be able to check if we have a record for any dive computer
with the same model (as that now triggers our nickname dialog).
This changes the format of the config entries for nicknames - the best
solution might be to just delete those and start again.
What is still missing is the code to store the nicknames in the XML file.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Having it there with the model information seemed to make sense but on
second thought it's the wrong spot to keep that information, especially
since we were storing it in the XML file in every single dive.
This change removes the nickname member from the divecomputer and makes
the rest of the code reasonably self consistent. It does not add much of
the new code for the new design to handle nicknames.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds the capability to actually view all your dive computers, by
adding a menu item under "Log"->"View"->"Next DC" to show the next dive
computer.
Realistically, if you actually commonly use this, you'd use the
accelerator shortcut. Which right now is Ctrl-C ("C for Computer"),
which is probably a horrible choice.
I really would want to have nice "next/prev dive" accelerators too,
because the cursor keys don't work very well with the gtk focus issues.
Being able to switch between dives would also make the "just the dive
profile, maam" view (ctrl-2) much more useful.
The prev/next dive in the profile view should probably be done with a
keyboard action callback, which also avoids some of the limitations of
accelerators (ie you can make any key do the action). Some gtk person,
please?
Anyway, this commit only does the dive computer choice thing, and only
using the accelerators.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In gtk-gui.c:expose_event(), right before clearing the list of tooltips,
we also want to free memory for the associated texts for each one of them.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In gtk-gui.c:init() we retrieve the configuration values
for PO2, PN2, PHE thresholds but have to also free the values
once done parsing with sscanf().
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In render_dc_vendor() and render_dc_product(), there is
no need to allocate memory for the texts that are about to
be added in the combo box trees. Most GTK widgets seem to make
copies of the passed text to them, using g_strdup() and
automatically release said memory when a widget is destroyed.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the sizes of the two char buffers in set_dc_nickname() (nickname)
and remember_dc() (buffer) are at least twice the size of the allowed
maximum number of characters (sizeof(gunichar) = 2) set by
gtk_entry_set_max_length() for the user nickname,
no truncation will accur then calling snprintf() and cleanedup_nickname()
on said buffers.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
in gtk-gui.c:
The input text field in set_dc_nickname() has a limit of 68 unicode
characters, which are 136 bytes. In remember_dc(), to make sure
that this nickname, the deviceid (4 bytes) and also the extra
characters (",{}") always fit wihout truncation (from snprintf) in the
allocated stack buffer, we increase the size of the buffer to 256 bytes.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Silly typo, but this is the better solution, anyway.
Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>`
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We maintain a list of dive computers that we know about (by deviceid) and
their nicknames in our config. If the user downloads dive from a dive
computer that we haven't seen before, we give them the option to set a
nickname for that dive computer. That nickname is displayed in the profile
(and stored in the XML file, assuming it is not the same as the model).
This implementation attempts to make sure that it correctly deals with
utf8 nicknames.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
A vendor of -1 indicates that we should have no product selection in the
dive download dialog. Having the empty product model be the last made it
hard to keep the correct index for that empty model around (and we got it
wrong by default).
With this change the product models are offset by one, so the unset vendor
(-1) turns into index 0 which is where we now store the empty model.
Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We don't want to directly use the strings returned to us from
libdivecomputer.
Fixes bug 34
Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I foolishly changed visible_columns in both the (ill-named) cns branch and
master...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Conflicts:
divelist.c
gtk-gui.c
profile.c
We either pick the CNS reported by the dive computer at the end of the
dive, or the maximum of that and the CNS values in the samples, if any.
As usual, this column in the dive list defaults to off and it is
controlled by a setting in the tec page of the preferences.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This allows you to open the preference dialog, play with settings and see
their effect right away. Press OK and you keep them, press Cancel and you
are back to the previous state. As it should be.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Now we can simply remember the state of all the preferences at the
beginning of preferences_dialog() and restore them if the user presses
'Cancel'.
Fixes#21
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We were responding to the wrong Quit signal on MacOS. The one we picked
was the one that basically told us "it's too late to stop me, I'm
quitting". I switched this to the one asking "should I prevent the app
from quitting" and now we can indeed cancel the Quit, regardless which
method was used to close the app.
Also removes to unused variables.
Fixes#22
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The previous commit 871d7ae0cdf5 "Add option to make ceiling visually
stand out more in the profile" contained not one but two stupid cut and
paste bugs. I cannot begin to explain how this could have worked when I
first tested it.
Reported-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While having the background "come down" seemed like a good visualization
of the ceiling, some divers appear to prefer something more dramatic. This
adds an option to the Tec Settings to have the ceiling shown in red
instead of the default background color.
Suggested-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of just taking the vendors and products for the supported
divecomputers in the order libdivecomputer provides them to us we sort
them as we add them to our list of lists. While doing this we also track
the longest product name and try to make sure that the combobox for the
product is set to a fixed width that's wider then the longest product
name.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The length of that combo box got increasingly insane as libdivecomputer
supported more and more models. To make this more scalable we now have two
combo boxes. One with just the vendors and a second one with the products
depending on the vendor selected.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit changes the code that was recently introduced to deal with
deco ceilings. Instead of handling these through events we now store the
ceiling (which in reality is the deepest deco stop with all known dive
computers) and the stop time at that ceiling in the samples.
This also adds support for NDL (non stop dive limit) which both dive
computers that appear to give us ceiling / deco information appear to
give us as well (when the diver isn't in deco).
If the mouse hovers over the profile we now add support for displaying the
NDL, the current deco obligation and (if we are able to tell from the
data) whether we are at a safety stop.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The downloader has been integrated into Subsurface for a while and with
the recent change to no longer have it create the old style SDA files as
intermediary format there is no need anymore to support that format in the
XML parser.
This deletes almost 300 lines of code. Yay!
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The initial downloader reused the XML parsing of SDA files that was
implemented early in order to support the information extracted from the
SDA with the java applet. But creating this intermediary XML file and
handing it off to the XML import function always seemed like an ugly way
to do things. This became even more obvious when adding more features to
the Uemis downloader.
This commit completely changes the downloader to instead create dives and
record them directly.
This also adds support for divespots (which are stored in a seperate
database that needs to be queried after the divelog and dive entries have
been combined - the Uemis firmware clearly was written by monkeys on
crack - oh wait: I'm trusting these same people to get the deco right?).
This commit leaves the SDA import capability in the XML parser intact.
I'll remove that later. Because of this it actually adds a few lines of
code, but the overall change will be a substantial code deletion.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Actually, it's even better than that. Thanks to the new divecomputer
datastructure we can now simply look up in the dive_table which dives have
been downloaded from this specific Uemis SDA.
This patch removes the old gconf based code - which leads to one
unfortunate problem: the first time a Uemis SDA owner runs this version of
Subsurface against their data file ALL dives will be downloaded again
(which may not be a bad thing as we have improved a few other details of
Uemis support so now they get their deco information, surface pressure and
other data that we have started to support since 2.1). Still, this is not
ideal. But I didn't want to keep the legacy code around since this new
solution is so much cleaner.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This makes the dive trip auto-generation a separate pass from the
showing of the dive trips, which makes things much more understandable.
It simplifies the code a lot too, because it's much more natural to
generate the automatic trip data by walking the dives from oldest to
newest (while the tree model wants to walk the other way).
It gets rid of the most annoying part of using the gtk tree model for
dive trip management, but some still remains.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When this was first implemented the assumption was that a downloaded dive
that is to be merged with an existing dive would have the same time stamp.
But as Linus pointed out even back then, this does fail if a dive has been
merged with a download from a different dive computer before (think:
download from computer a, then download same dive from b, then improve
something in the parsing from computer a and try to redownload; the time
stamp could have changed).
This commit also fixes a silly omission in the merge_dives() function
(which ended up ALWAYS prefering the downloaded dive) and finally
implements the necessary changes to mark dives downloaded from a Uemis SDA
as well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Prior to this commit, gtk often decided to collapse the trip with the
selected dive after the user imported or downloaded additional dives.
Since Subsurface tracks dives as being selected even after gtk collapses a
trip (which clears all selection state as far as gtk is concerned) this
could lead to the strange situation that the user could click on a new
dive to select it without unselecting the already selected dive - and
suddenly edit or delete did things that were entirely unwanted.
With this change we explicitly save and then restore the tree state around
import and download operations. This ensures that the same dive(s) stay
selected and trips stay expanded and therefore avoids the issues described
here.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The code pretended to support this for libdivecomputer based downloads,
but it had never been hooked up when the native Uemis downloader was
implemented. When I finally decided to close that feature gap I realized
that the original code was, shall we say, "aspirational" or "completely
bogus" and therefore never worked.
So instead of just hooking up the code for the Uemis downloader I instead
implemented this correctly for the first time for both libdivecomputer and
the native Uemis downloader.
In order not to have to mess with multithreaded Gtk development I simply
opted for a helper function that fires on a 100ms timeout and have it end
the dialog without a response. This way we can run the dialog while
waiting for the download to finish, still update the progress bar and
respond in a useful manner to the user clicking cancel.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This may seem like an esoteric corner case, but it will actually happen
reliably when re-downloading dives from the Uemis SDA:
If the user selects "Force downloada of all dives" in the "Download from
divecomputer" dialog and if the SDA runs out of space and needs to be
unmounted and remounted, then for the 'Retry' the 'force' flag should be
cleared - or the user will once again start from the first dive which
almost certainly is not what they expect.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This mirrors commit 59929fdb5d2a "Mark divelist changed as we download
dives from a dive computer" which only fixed things for the
libdivecomputer case.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This allows zooming in with the scroll-wheel if you have one (or the
two-finger scrolling on a touchpad).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I think I prefer the 2.5x zoom over the pure doubling.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This shows the values for all the graphs that are shown (depth,
temperature, tank pressure, pO2, pN2m pHe), but also correctly doesn't
display them when they are turned off or no data is available (prior to
this commit, tank pressure was always shown, even if no pressure samples
were available for the dive).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Linus convinced me that I was wrong to modify his commit 24690ce35f81
"Initial not-so-pretty profile zoom support" and so this changes it back
to use the left mouse button for zooming. It turns out that on some
touchpads there's a very nice way to hold down the click with one finger
and then pan with another finger, but that does not work if you do a two
finger click (and use one of those or a third to pan).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This extends on our current tooltip logic (which shows events when you
mouse over them) to show tooltips for the whole profile area.
If you mouse over an event, that is still shown in the tooltip, but
even in the absense of events, the tooltip will be active, and mousing
over the profile area will show the time, depth and pressure.
This can certainly be improved upon further, but even in this form it is
useful.
Fixes#9
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This will hopefully not be something we need often, but if we improve
support for a divecomputer (either in libdivecomputer or in our native
Uemis code or even in the way we handle (and potentially discard) events),
then it is extremely useful to be able to say "re-download things
from the divecomputer and for things that were not edited in Subsurface,
don't try to merge the data (which gives BAD results if for example you
fixed a bug in the depth calculation in libdivecomputer) but instead
simply take the samples, the events and some of the other unedited data
straight from the download".
This commit implements just that - a "force download" checkbox in the
download dialog that makes us reimport all dives from the dive computer,
even the ones we already have, and an "always prefer downloaded dive"
checkbox that then tells Subsurface not to merge but simply to take the
data from the downloaded dive - without overwriting the things we have
already edited in Subsurface (like location, buddy, equipment, etc).
This, as a precaution, refuses to merge dives that don't have identical
start times. So if you have edited the date / time of a dive or if you
have previously merged your dive with a different dive computer (and
therefore modified samples and events) you are out of luck.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
You can press the left mouse-button on the profile and drag the mouse
around to zoom in on a specific area. Releasing the mouse button unzooms.
Yeah, everybody wants rubber-banding, but I have reached the end of my
willingness to fight gtk for more details. Some day.
[Dirk Hohndel: changed this to use the right mouse button instead of the
left which seemed just terribly unnatural]
References ticket 9
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The tec diving preference pane now allows us to set a partial pressure
threshold for each of the three gases. When the partial pressure surpasses
that value, the graph becomes red.
Fixes#12
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The default filename handling is broken in two different ways:
(a) if we start subsurface with a non-existing file, we warn about
the inability to read that file, and then we exit without setting the
default filename.
This is broken because it means that if the user (perhaps by mistake,
by pressing ^S) now saves the file, he will overwrite the default
filename, even though that was *not* the file we read, and *not* the
file that subsurface was started with.
So just set the default filename even for a failed file open.
The exact same logic is true of a failed parse of an XML file that we
successfully opened. We do *not* want to leave the old default
filename in place just because the XML parsing failed, and possibly
then overwriting some file that was never involved with that failure
in the first place. So just get rid of all the logic to push the
filename saving into the XML parsing layer, it has zero relevance at
that point.
(b) if we do replace the default filename with a NULL file, we need
to set that even if we cannot do a strdup() on the NULL.
This fixes both errors.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We now throw away redundant events, just as we throw away other redundant
data coming from the dive computer. Events are considered redundant if
they are less than 61 seconds apart and identical.
This also improves the display of the remaining events in the profile as
we now show the value of the event, if it is present (for example for a
deco event we show the duration of the deepest stop).
Finally, for events that define a range (so they set the beginning flag
and assume and end flag some time later) we no loger show the triangle but
assume that some other code handles visualizing them (as happens for the
ceiling events).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This was introduced in commit ee803ef5d85b "Change preferences into a
notebook and add second page for tec settings"
In order to be able to get the new default XML file name back from the
button, we need to keep that variable around and not overwrite it with
more buttons for the tec preferences page.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While the import thread is running it is possible to:
1) click the [x] button of the "download dialog".
To prevent that, we attach a "delete-event" signal to no-op function.
2) to interact with the main window, once the "accept" event is triggered.
To prevent that, we make sure that the window is set back to "modal".
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
On Windows, device names can end up being <drive-letter> (<drive-label>).
In such a case we are only interested in the <drive-letter> part, when
passing this value to libdivecomputer.
This patch provides a method to trim all text in parentheses and also
any leading and trailing whitespace.
An important addition is enabling back the user to enter a device
manually even it's absent in the combo box list. This device is
then stored and retrieved as the default device, but not stored
in the device list (dc_device_selector()).
As a side effect this change prevents the download dialog closing,
when a user-entered device is not one of the found devices via
subsurface_fill_device_list().
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Not sure this is the best naming scheme (General Settings / Tec Settings)
but it's a start.
The idea is to have the settings that a recreational diver might care
about on the first page, and all the other stuff on the second one. Let's
see how this works out long term. For now I moved OTU over and added
toggles for the different partial pressure graphs (only the pO2 one is
implemented so far).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is intended to be unobtrusive, but add more information for people
who aren't satisfied with the numeric value we put inside the plot to mark
local peaks and troughs.
See ticket #9
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We try to identify devices that are connected and their matching device
names (and mount paths in the case of the Uemis Zurich). Those are
presented as a drop down menu to choose from. The user can still override
this by simply entering a different device / path name.
On Windows this is not functional. How do I find out which drive letter
corresponds to the USB device named "UEMISSDA"? Similarly we need code
that finds serial ports that are present. For now we once again default
to COM3 (so this isn't a step back, but of course it's far from what we
want).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This one breaks with my preference to separate generated changes from
content changes - I wanted to get the new comment next to the
translator-credits text that I added to every .po file. This way the
people who worked on these translations at least get shown in the About
box. But a simple grep on the diff will show you that this is indeed the
only set of changes that I made.
git diff HEAD^ | grep ^+ | grep -v -e^+# -e^+++ -ePOT-Creation
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is a very common standard in desktop programs - if a menu entry
immediately causes an action (like Close or New or Toggle Autogroup) then
it doesn't have the "..."; others that open a secondary dialog (like Open
or Import / Download) are marked with "...".
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add a link to the GPL, a link to the homepage, an opportunity for the
translator to be listed (this requires the translations to translate the
phrase "translator-credits" with the names of the translators - kinda
nifty).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Mainly affecting older Windows (such as XP), which do not have a more
fully featured unicode fonts installed, such as Arial Unicode MS.
With this patch we do a runtime check of the OS version in a couple of
places and if the OS is old, we use the asterix character and spaces instead
of the unicode star characters.
Linux and OSX should be unaffected by this change unless
subsurface_os_feature_available() returns FALSE for UTF8_FONT_WITH_STARS
at some point.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It appears that at least for Norwegian the translations of the stock menu
entries was missing. This patch adds those as explicit strings and merges
those new strings into the .po files.
The translations need to be updated in separate commits.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
Only files that are opened should be considered r/w. Files that are
imported should be treated as if they were r/o.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Right now the menu and button images are a distribution choice - some
have them on, some have them off. I kinda like them and think that even on
OSs that have them off by default this doesn't look out of place (as other
apps clearly do the same).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Each time we retrieve a string configuration entry via
subsurface_get_conf(), all the multiplatform methods in linux.c,
macos.c, windows.c allocate memory for the returned value.
In gtk-gui.c, lets try to release the memory at:
default_dive_computer_vendor, default_dive_computer_product, divelist_font
before assigning a new address to these pointers.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Renamed to "Import XML File(s)", since we can import more than one file.
H
From 8f9b11d940d903316dcf4d023e327f365e4f4ccb Mon Sep 17 00:00:00 2001
From: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Date: Tue, 2 Oct 2012 11:38:56 +0200
Subject: [PATCH] Rename Import XML File menu entry
Renamed to "Import XML File(s)", since we can import more than one file.
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When creating a new dive_trip from a dive, we should probably
always copy the location via strdup(). However we then have to take
care of the de-allocation in divelist.c:delete_trip()
and gtk-gui.c:file_close().
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Added new function dive_list_destroy() in divelist.c
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
The return value of subsurface_get_conf is a const void * - so we shouldn't
just assign it to a variable where we know it will be changed. Instead we
duplicate the string and free the original one. A little less efficient but
cleaner.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>