Calling set_dc_nickname() only added a new entry if there was a conflict
with an existing one - which works fine if we are reading a file saved by
Subsurface, as there the device_info_list is populated at parse time, but
fails for data imported from other sources.
Fixes#74
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is dedicated to Lubomir ;)
Should work (tm). Not sure though if you want target
'gen_version_file' as a pre-requisite to $(NAME) or some other target.
[Dirk Hohndel: minor adjustments to make it work with gtk-gui.c]
Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Yes, we could try and bundle the user manual with the executables and open
a local copy of it - but this seemed much easier and safer to do. It does,
of course, add another string...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Uses profile.c:evn_foreach() to retrieve the number of events, which
if zero, no table is added in the dialog and the label is added instead.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There is a bug in GTK 2.2x where the links in the about dialog
(and URI's in general) do not work on Windows. To solve that
we add the OS specific method subsurface_launch_for_uri().
But to dispatch URI requests from the about dialog we need to
set a hook either with gtk_about_dialog_set_url_hook() (which is
deprecated from 2.24) or using signals like "activate-link".
One problem with the "activate-link" signal thought is that
we need to have a reference of an about dialog to pass to
g_signal_connect(). So instead of using gtk_show_about_dialog()
let's manage a dialog ourself with gtk_about_dialog_new(),
gtk_dialog_run(), gtk_widget_destroy().
Other changes:
- for GTK _bellow_ (but not including) 2.24 use
gtk_about_dialog_set_url_hook()
- use g_object_set() which is a convenient replacement for
the varargs list in gtk_show_about_dialog() (also makes the diff smaller).
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The about dialog URI calls are broken on Windows, therefore we needed
a way to override the default URI method. On versions bellow or equal to
GTK 2.24 this is possible with gtk_about_dialog_set_url_hook(),
which on the other hand is deprecated for newer GTK versions.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Apparently at least in Unity on Ubuntu 12.10 using those icons causes the
default Menu text to be displayed (Back instead of Import).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add a new method in info.c called info_widget_destroy(), which
clears all GtkListStore instances. The method is exposed via
display-gtk.h and called from gtk-gui.c:on_destroy().
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
As Rainer finished up the export function on divelogs.de, he
used DLD as a suffix instead.
Suggested-by: Rainer Mohr <mail@divelogs.de>
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead, just keep track of the expanded state of trips as we get the
gtk callbacks for the state changes (which we need to track anyway for
the selection logic), and automatically restore the state whenever we
re-create the divelist.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This just adds the "remember_tree_state()" and "restore_tree_state()"
calls around the divelist update when autogrouping is turned on: that
way existing expanded groups aren't blindly collapsed.
It makes it much easier to see what autogrouping does if it only groups
a few dives, because the overall state of the divelist isn't radically
changed.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Include SDE files on the file selectors if zip support is enabled.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
gtk-gui.c:
+ added the method get_screen_dpi() that uses a simple
formula to retrieve the actual screen DPI
display.h:
+ use get_screen_dpi() in the SCALE_PRINT macro
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Getting the about icon to display in various scenarios on MacOSX
was a pain. Moving the icon to an include file solved the problem.
This commit also fixes the problem Dirk was having when converting
satellite.svg to a png in commit cf3c0266c2. I couldn't
quite get ImageMagick to preserve transparency and color when
converting subsurface-icon.svg, though, so I used Gimp instead.
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Another oversight of what needed to be done when cleaning up the UI after
closing the data file.
Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When the data file is closed we should reset the events that we offer for
filtering.
Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We already clear the widgets but forgot to turn off the tooltips as well.
Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds the tooltip just to the Dive Notes page of the notebook area -
that's where people are tempted to try to do "edit in-place" which we
currently don't support.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Henrik reports that on OSX, not destroying the cairo context results in
a corrupted profile display. It seems to just leak memory on Linux.
For gtk3, the cairo context is embedded in the GtkDrawable, for gtk2 we
need to create and destroy it appropriately. Although maybe we could
just make it static instead of creating/destroying it all the time.
Anyway, this goes back to the old cairo destroy logic for gtk2.
Reported-and-analyzed-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Mostly coding style and whitespace changes plus making lots of functions
static that have no need to be extern. This also helped find a bit of code
that is actually no longer used.
This should have absolutely no functional impact - all changes should be
purely cosmetic. But it removes a bunch of lines of code and makes the
rest easier to read.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds the GFlow/high values used to calculate the ceiling (if any).
Right now it shows those numbers even if at no point of the dive there was
an actual ceiling (but only if showing the ceiling itself is enabled).
This should make it easier to for the user to make sense of the calculated
ceiling, especially if posting screen shots.
As an aside - for some dive computers like the OSTC and the Shearwaters we
should be able to also plot the GF used by its calculation which might be
interesting for comparison purposes, as both of them also give us the
ceiling (lowest deco stop) calculated during the dive..
See #13
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
To actually compile with gtk-3 you currently need to disable the use of
OSM (compatible with gtk2 only for now). And obviously figure out the
headers and libraries by using pkg-config on gtk-3 instead of gtk-2.
But now it should be only a Makefile change.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This cleans up our handling of combo boxes and all the duplicated
completion logic, and simplifies the code.
In particular, we get rid of the deprecated GtkComboBoxEntry. While it
made some things easier, it made other things harder. Just using
GtkComboBox and setting that up correctly ends up being simpler, and
also makes the logic work with gtk-3.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This forces us to use the proper gtk accessor functions. It may not be
worth it if people actually do the Qt conversion, but if we want to try
gtk3 at some point, this might help.
This all came about because I was trying to explain on G+ what an
immense pain this all was to even figure out, if you don't actually know
gtk at all. Google and the gtk migration guide are almost useless, and
the gtk2 documentation itself actually uses the fields directly without
any accessor functions in several places.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
get_units() returns the current unit preference, thus it
belongs in prefs.c rather than gtk-gui.c
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We save the (more complete) dive computer information in the XML file
with serial numbers and firmware version if we know about them, so using
a complicated string in the system config was redundant and confusing.
So remove that code.
NOTE! Since the dive computer nicknames are now only saved if the XML
file is saved, we also mark the dive list "changed" when we edit the
nicknames. That way we'll be prompted to save things before exiting,
even if we don't actually edit any actual dive data.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We used to save dive computer information only if that dive computer was
actually used in any of the dives we saved. But we can simplify the
code if we just always save any dive computers we know about. And it
does allow for some usage cases where you have nicknames for other
peoples computers that you may not actively use, but you want to see if
you end up loading multiple XML files in one go.
So there's just no compelling reason to not just save all the info we
have. And this will make it less painful to remove the "use system
config for dive computer nicknames", because you can also use this to
continue to gather dive computer info in a separate XML file if you want
to.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The 'preexisting' value is used for downloading dives: we want to add
new dives but, but then compare those new dives against the
preexisting ones before we start sorting things and possibly merging
them.
However, the value was only updated sporadically, resulting in it
having stale information in it. Which would cause problems
particularly if you deleted dives, so that the preexisting value would
point past the actual existing values!
So just update it unconditionally in dive_list_update_dives(), which
anything that changes the dive list is supposed to call in order to
display the changes anyway.
Also, just for safety, when removing a dive, put NULL in the last dive
table location. Nobody should ever access past the end anyway (this
is enforced by 'get_dive()') but there are places that access the dive
list table directly, and the libdivecomputer download was one of
those. No reason to leave stale dive pointers possibly around for
uses like that.
Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
As reported by Henrik, there was a crash lurking in edit_dc_nickname code.
Invoking the dialog and selecting apply without changes exposed it neatly.
This is a one line fix.
Signed off by Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This replaces the really lame "italics text" from commit abe810ca1a29
("Mark locations that have GPS location data attached") with a marginally
less lame GPS icon.There's a reason why I am not making a living as
graphics artist. But I think this is a huge step forward from what we had
before...
The satellite.svg file is very loosely based on a different icon that I
found as public domain here http://www.clker.com/clipart-30400.html.
From that I created the PNG and then that was converted into the
GdkPixdata via gdk-pixbuf-csource; a rule for that was added to
the Makefile but commented out as I don't know if this tool will always be
available in the path. Having this icon included in the sources avoids
locating yet another icon file.
Better icons are certainly welcome!
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This allows users to edit one or more nick name entries in a single
session. Entries can also be removed individually.
Based on mock up by Lubomir Ivanov and various conversations from Dirk.
Thanks to both.
[Dirk Hohndel: quite a bit of editing for coding style and whitespace]
Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
A couple of new files webservice.c and webservice.h are added.
webservice.h exposes two methods at the moment:
- webservice_download_dialog():
this function creates the user interface for the download dialog
from the web service.
- webservice_request_user_xml()
this function is a direct call to retrieve XML for a specific
user identifier. the actual data, data length and error codes
are stored in passed pointers.
A menu entry is added in the Log menu:
"Download From Web Service"
The used backend for communication at the moment is provided
by libsoup.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While we are waiting for an autotools generated Makefile, this should allow
people to build that don't have osm-gps-map.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The previous patch in this series adds the function
subsurface_launch_for_uri(), which has to be called from the about
dialog instead of the default function for the URI calls to work
on Windows - i.e. opening links from the dialog.
gtk_about_dialog_set_url_hook() is a deprecated method, but seems
to be the only reasonable way to make the override between GTK 2.20 -
2.24 possible. The "activate-link" signal is recomended instead,
but is not portable for GTK bellow 2.24.
An alternative would be to somehow hack into the GtkAboutDialog
and override the callback for each clickable link.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch centralizes the definition for surface pressure, oxygen in
air, (re)defines all such values as plain integers and adapts calculations.
It eliminates 11 (!) occurrences of definitions for surface pressure and
also a few for oxygen in air.
It also rewrites the calculation for EAD, END and EADD using the new
definitons, harmonizing it for OC and CC and fixes a bug for EADD OC
calculation.
And finally it removes the unneeded variable entry_ead in gtk-gui.c.
Jan
Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
- MOD: Maximum Operation Depth based on a configurable limit
- EAD: Equivalent Air Depth considering N2 and (!) O2 narcotic
- END: Equivalent Nitrogen (Narcotic) Depth considering just N2 narcotic
(ignoring O2)
- EADD: Equivalent Air Density Depth
Please note that some people and even diving organisations have opposite
definitions for EAD and END. Considering A stands for Air, lets choose the
above. And considering N for Nitrogen it also fits in this scheme.
This patch moves N2_IN_AIR from deco.c to dive.h as this is already used
in several places and might be useful for future use also. It also
respecifies N2_IN_AIR to a more correct value of 78,084%, the former one
also included all other gases than oxygen appearing in air. If someone
needs to use the former value it would be more correct to use 1-O2_IN_AIR
instead.
Signed-off-by: Jan Schubert / Jan.Schubert@GMX.li
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For each dive recorded, place their GPS coordinates onto a map using the
OSM-GPS-MAP library.
This map is accessible via the "log" menu or the shortcut ctrl+M (M as map).
We check for the GPS coordinates "0, 0" which are the default when we do not
have real GPS coordinates set.
[Dirk Hohndel: fixed int/float math confusion, fixed some whitespace and
coding style issues, cleaned up some comments, added a
missing cast to prevent a compiler warning]
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Signed-Off-By: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
.. and add the usual logic to not save the default values.
This also simplifies the initial system-specific setup of both of these:
since we have defaults for all the preferences that get set up at
startup, we can just initialize those defaults to the system-specific
fonts then and there.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Loading an xml file with dive computer information without any
preexisting nickname data would try to "remember" that NULL nickname.
Causing a SIGSEGV if there was no nickname information.
The bug was introduced by commit ec38d3708d ("Move device_info handling
into a new 'device.c' file") when I inadvertently removed a bit too much
code. It actually wants to remember a missing DC nickname as an empty one.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This does the "don't save defaults" for numeric values too.
Also, move the preferences loading/saving to a new "prefs.c" file.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
A new file download-dialog.c now contains all code related
to the download dialog, which was previously defined in gtk-gui.c.
Also, a new file callbacks-gtk.h now has two macros
OPTIONCALLBACK, UNITCALLBACK shared only between
download-dialog.c and gtk-gui.c.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The old code (on purpose) didn't try to differentiate "nonexisting
boolean configuration" with "existing boolean configuration set to
false", which is problematic if we optimize the saving to not save
default preferences at all.
Which this does.
So in addition to the logic to know about default preferences, this has
to change the interfaces for the PREF_BOOL reading code so that you can
tell the difference between "no value" and "false".
And since the previous calling convention was an abomination of doing
pointer casting and having case-statements for the config types, change
that while at it. Both from a usage perspective *and* from a back-end
perspective it is actually much simpler to just have different functions
for the string vs boolean config read/write versions. The OSX versions
in particular end up being one-liners.
(The GConf library is a nightmare, and doesn't seem to have any way to
know whether a boolean value exists or not, so you have to read it as a
GConfVal and then turn it into a gboolean rather than just get the "oh,
it didn't exist" as an error value).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This makes it explicit what the default preferences are, so that we can
more easily avoid unnecessarily saving default settings. It also makes
imperial metrics the default for the US (Burma and Liberia always get
forgotten!)
Right now we tend to be somewhat confused about defaults. We do have
them, but then even if something has a default value, we tend to write
it out to the config file. Which is not just unnecessary, but makes it
really hard to see after-the-fact whether the user actually wanted that
*specific* value, or whether they just wanted the default behavior.
So this prepares for having explicit configuration for when we want
something different than the defaults.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>