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>
When updating the "You have usnaved change..." string I didn't pay
attention and missed the fact that we used it's hard coded length above to
allocate a large enough buffer.
Thanks you, Valgrind.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
Running under Valgrind showed a couple of silly bugs.
Worse, intentionally running into various error scenarios showed that we
could get the buffer handling in the raw parsing code to break down - we
would fail to process the correctly downloaded files.
To make it easier to get this right I restructured the code to collect the
XML buffer in a different way - this works much better and has stood up
well under testing so far.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of trying to figure out in the GUI code whether to call the
downloader again, the logic was moved into the downloader itself. It now
attempts to deal cleverly with running out of space on the dive computer
filesystem - and in return is able to process the maximum number of dives
(instead of just ten or so at a time).
Even on partial reads before a failure we are able to collect the data
that was completely transferred and report those dives.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This brings in the code to download dive information directly from a Uemis
Zurich dive computer.
The implementation contains a major hack that hooks the uemis code into
the same data structures used to setup libdivecomputer. This gives the
best result for the user, but is not something that I like as a long term
solution as it relies on internal libdivecomputer data structures.
This includes one major hack that uses a private data structure from
libdivecomputer to allow us to show the Uemis Zurich as one computer the
user can import from.
Once the user has chosen the Uemis we don't use libdivecomputer but our
own downloader. Just like in the libdicecomputer case this runs in its own
thread and updates the import dialog with progress information.
The code also keeps track of the last dive that has been downloaded from a
Uemis computer so we only import new dives on subsequent downloads. And
since the Uemis Zurich gives us its device id, we make this a "per
divecomputer" property for people who dive with multiple Uemis Zurich
computers.
This uses the debugfile infrastructure to allow easily collecting
debugging output - especially on Windows where by default console output
is lost.
Known limitations: when the Uemis runs out of space (it uses its
filesystem for communication with the host computer) we have no graceful
way to reset things. This is why the code doesn't try to download ALL
dives on the computer but instead download them in increments of ten
dives. This clearly needs to be addressed once I understand how to reset
the device.
The Cancel button of the import dialog isn't correctly hooked up, yet.
I still need to figure out how to gracefully shut down a download without
potentially hanging the device.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
gtk-gui.c:about_dialog():
Before assigning a pixel buffer to "logo" check if "image"
has a GTK_IMAGE_PIXBUF storage type.
Prevents the following message if the icon file is missing:
Gtk-CRITICAL **: gtk_image_get_pixbuf: assertion
The message that the file is missing is still shown.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
When calling gtk-gui.c:set_default_dive_computer_device(), first
free memory at default_dive_computer_device and then use strdup().
This fixed a case, where after selecting a device for the first time
in the "Download" dialog, then pressing "OK" followed by "Cancel"
(after a device error) the device text is garbled the next time the
dialog is opened.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Renamed the function pick_import_files() to import_files()
and added a declaration in "display-gtk.h". The declaration is "extern"
for consistency with download_dialog().
Since the new dialog is a real child off "main_window", we no longer need
some of the calls to gtk_widget_set_sensitive(), gtk_window_set_decorated()
to disable the parent, which previously was the old "Import" combined dialog.
Once the file list is retrieved, attempt to import each file and update
the list via report_dives().
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Minor changes to file select box title
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Renamed "import_dialog" to "download_dialog" and also focused the download
dialog strictly on dive computer functionality. Removed the file button
and "filenames" checks from "download_dialog".
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
New entries with icons and shortcut keys in the menus.
"Import XML File" is now using CTRL + I.
Reserve CTRL + E for "Export XML File" if possible.
"Download From Dive Computer" is using CTRL + D and
a GTK_STOCK_GO_DOWN icon.
Added separator below this entry in the "Log" menu.
Note: menu entry callbacks are NULL at this stage.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
There are possible bugs when targeting GTK 2.24.10.
When opening the "import XML files" file selector from the "import" dialog
on Ubuntu 12.04, even with gtk_window_set_accept_focus() setting FALSE
to the parent ("import"), it is still possible to click the title bar
and buttons, causing actions. This can trigger undefined behaviour -
e.g. opening multiple "import XML files" dialogs.
While on Windows the situation is more acceptable, on Ubuntu it is also
possible to click the [x] button on the title bar of the parent window,
which will close the parent dialog _with_ the current forward dialog.
Multiple proposed methods in the GTK documentation seem not to function
as expected, such as: gtk_window_set_modal() and gtk_window_set_accept_focus().
Passing the correct parent on dialog creation doesn't seems to help either.
The same problem occurs when selecting a default file from the preferences
dialog.
The proposed portable solution in this patch is to completely disable
the background windows by hiding the titlebar (gtk_window_set_decorated),
disabling child controls (gtk_widget_set_sensitive) and making the window
"transient for" or putting it on top (gtk_window_set_transient_for).
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Renamed the XML button and titles slightly.
Generalized the dialog topmost text to "Choose what to import:".
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
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>
Related to subsurface_default_filename() and g_path_get_basename().
Against 3835faa8fb.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Currently doubles the functionality of "Close" (file_close).
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since the GSList is now only created if the user enters the file selection
dialog, opening the import dialog and then clicking OK without selecting
either a dive computer or a file would cause a crash.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Renamed the title of the "Import" dialog to "Import", as there
are a couple of supported operations.
Removed the "Import:" text in the dialog body.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Moved the entry bellow the standard file operations and above "Print".
Also placed it between separators and added the GTK_STOCK_GO_BACK icon.
Later on "Export" can be placed below "Import" using GTK_STOCK_GO_FORWARD.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>