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>
The planned dive always has to be the last dive in the dive list. To make
sure of that we interpret the relative start time to be relative to either
the current time or the end of the last dive, whichever is later.
This fixes a bug where we would delete the wrong dive and get our data
structures confused by planning multiple dives out of order.
Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
With the changes to the selection logic the selected_dive variable didn't
get updated at the end of planning a dive. With an empty dive list that
could cause selected_dive to be -1 which would subsequently cause a
SIGSEGV when trying to edit the newly created dive.
With this commit we use the shared go_to_iter() function and also make
sure that selected_dive is set correctly.
Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This fixes "enter" after moving around with the cursor keys.
Hinted-at-by: Carl Worth <cworth@cworth.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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>
This may be a matter of taste, but it seems that these values work better.
Most importantly, Hawaii is now visible by default...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Commit a52b0aa5ea8d ("Show Gradient Factors in plot when showing
calculated ceilings") incorrectly modified the gc which caused the mouse
position no longer correctly being correlated to the time on the plot.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This became very obvious after commit df6a9ddd8a21 ("Auto-generate C file
dependencies, and make the build more quiet") went in; since not having
osm-gps-map is one of the few errors that aren't fatal for building it
seemed worth quieting this down.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This does some rough auto-generation of header file dependencies for all
the *.c files, rather than our file-by-file incomplete hardcoded ones.
It also stops showing the whole compile line, because it's ugly and
distracting. Instead it just shows "CC file.c". If you care about the
full thing, you still see them with "make -n".
Only tested on Linux. It probably is missing some Windows or
OSX-specific header includes.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use libglib2.0-dev instead of glib-2.0 and add both libssl-dev and
libsoup2.4-dev.
Signed-off-by: Carl Worth <cworth@cworth.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This no longer abuses the dive merging code (which would leave stray
"dives" behind if a gps fix couldn't be merged with any of the dives) and
instead parses the gps fixes into a second table and then walks that table
and tries to find matching dives.
The code tries to be reasonably smart about this. If we have
auto-generated GPS fixes at regular intervals, we look for a fix that is
during a dive (that's likely when the boat where the phone is staying dry
is more or less above the diver having fun). And if we have named entries
(so the user typed in a location name) we try to match them in order to
the dives that happened "that day" (where "that day" is about 6h before
and after the timestamp of the gps fix).
This commit also renames dive_has_location() to dive_has_gps_location() as
the difference between if(!dive->location) and if(dives_has_location) is a
bit too subtle...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This only changes the infrastructure and actually loses functionality as
it no longer does the simplistic "just treat the locations as dives and
merge them".
The new code that does something "smart" with the gps_location_table is
yet to be written. But now we can use the XML parser to put the gps
locations downloaded from the webservice into their own data structure.
In the process I noticed that we never used the two delete functions in
parse-xml.c and removed them.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When we create the event names, the name itself does not include the
information about whether the event is the beginning or end of some
state, so we end up having things like events named "deco" and then in
the event flags it says whether this is the *beginning* of deco, or the
end.
And when we show the event, we only used to show the name. This patch
makes us show whether it's the begin or end event for events that have
those flags. So now you see "deco begin" and "deco end" instead of just
two events both called "deco".
It would perhaps be nice if we somehow showed the range between the
events too, and paired them up visually some way, but that's a separate
and much more difficult thing to do.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It's only used by the Uemis importer, and Dirk always seems to import
his Uemis data first, so it wasn't very noticeable. But if the Uemis
data wasn't the first dive computer, it would not find the dive.
Side note: just comparing deviceid is not correct. We should pass in
the device model too. But again, that will realistically never really
matter, since non-Uemis importers will generate complex SHA1 hashes of
the dive data for the dive ID, so a collision with the Uemis numbers is
very unlikely.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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>
This commit makes the behavior consistent between the map window and the yearly
statistics window. Both can now be closed by just pressing the 'Esc' key.
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Pierre wrote: "On my keyboard I have a key on the right side
of the space bar, between the alt+gr key and the right ctrl
which most of the time emulates the right mouse click.
If I press this button on subsurface, I end up with:
Segmentation fault (core dumped)
This whatever the selection and nicely always reproducible."
This patch doesn't make the key work, but it fixes the segfault.
Reported-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Debugged-and-acked-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The "visibility" value in MacDive XML files could be a random
string, while it's a value of 0-5 in Subsurface. Importing an
illegal value (such as "11m") resulted in a segfault from
libpangocairo and an "Invalid UTF-8 string passed to
pango_layout_set_text()".
[Dirk Hohndel: fixed int * vs. int issue]
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
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>
In commit 304526850c91 ("Don't deselect all dives on all selection
"change" events") the handling of "selected_dive" is incorrect. We ended
up with non-sensical values for the selected dive, including dives that
Gtk didn't think were selected.
This commit tries to be smart about what to do when the dive that we
currently consider selected is unselected (we have this weird notion of
many dives being selected, but one of them is shown in the profile and
that is the "selected_dive"). As long as there are others selected, we
pick one of them (first walking to earlier dives and if there are none
that are selected, looking for a later dive) as the new selected dive.
This appears to give us a rather intuitive behavior when playing with
multiple selected dives.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
gtk sends the selection change events all the time, for pretty much any
"divelist changed - so selection changed". The expansion of a trip, the
switch to a new model, yadda yadda. But we actually want selections to
be sticky across these events, so we can't just forget all of our old
selection state and repopulate it.
So we re-introduce the "am I allowed to change this row" callback, which
we used to use to create a list of every actual selection that was
changed. But instead of remembering the list (and having the stale
entries issue with that remembered list that caused problems), we now
just use that as a "that *particular* selection cleared" event.
So this callback works as the "which part of the visible, currently
selected state got cleared" notifier, and handles unselection.
Then, when the selection is over, we use the new model of "let's just
traverse the list of things gtk thinks are selected" and use that to
handle new selections in the visible state that gtk actually tracks
well. So that logic handles the new selections.
This way, dives that aren't visible to gtk don't ever get modified: gtk
won't ask about them being selected or not, and gtk won't track them in
its selection logic, so with this model their state never changes for
us.
gtk selections are annoying. They are simple for the case gtk knows
about (ie they are *visually* selected in the GUI), but since we very
much want to track selection across events that change the visual state,
we need to have this insane "impedance match".
Reported-by: Dirk Hohdnel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I can't find it in myself to care enough to display this in other units.
mm/Hg anyone? I didn't think so.
We still can't edit this value, but at least if w are able to read it from
the dive computer we also show it to the user.
See #19
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>
Also make sure to pass the "Accept" request header
set to "text/xml", so that XML is retrieved.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We used to generate a list of possibly changed selections using the gtk
tree selection "selection function".
But that's actually meant to just tell gtk whether an entry can be
selected or not, and our list of possibly changed entries ended up being
stale if the selection change was due to a list entry removal, for
example.
So rip out the old model entirely, and instead just walk the whole
selection that gtk gives us on a selection "change" event. We throw all
our old selections away when this happens, and just rebuild it all.
This should fix the occasional internal gtklib-quartz assertion that
Henrik is seeing. And it actually simplifies the code too.
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>
This made sense briefly when libdivecomputer reported ceiling data through
events with those flags, but it actually made us hide valid events from
some divecomputers that give us only very limited information (e.g., deco
events from some Suunto divecomputers).
Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Analyzed-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
They happen for CDATA content, where libxml2 turns the CDATA fields into
a child of the parent entry, but without a name.
Now, of course, any sane person would just want to use the CDATA as the
string value of the parent itself, but libxml2 probably does this
insanity for a reason. And the reason is probably that some misguided
people want to *write* XML using libxml2, and then the stupid child node
actually acts as a "now I want you to write this data as CDATA".
Whatever the reason, let's just ignore it. We will just traverse such a
nameless child and be happy, and we'll give the nameless child the name
of the parent. Our XML node matching logic will then never see this
insane nameless child at all, and doesn't have to care.
Our whole XML parsing rule-of-thumb is to take the whole "be strict in
what you output, but generous in what you accept" to its logical
conclusion. Because we will literally accept almost anything, in any
format. You can mix tags or attributes wildly, and youc an use CDATA or
not as you see fit. We just don't care.
We're the honeybadger of the divelog world.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Are they ugly and insane tags? Yes. Are they used? Bingo. MacDive uses
this lovely format for specifying dive site location.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Not that we aren't already insanely permissive in parsing just about any
random noise that could _possibly_ be construed as xml and turn it into
a dive, this makes us even laxer.
If somebody wants to have a <date> tag with both date and time, why the
heck not? It's fine. And if it has just the date, that's fine too. And
the date can be in any of several formats. We really don't care, the
more permissive, the better.
We strive to always write beautiful xml, but let's face it, not
everybody else does. If we can turn random line noise into a dive, we
should do so.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add a sample at time 0 to allow for a pO2 from the start of the dive.
Remember the last pO2 so it doesn't have to be repeated (and the right
thing happens for the planned part of the dive).
This still doesn't allow us to change the setpoint at a certain depth
(which would be analogous to being able to switch to a certain gas at a
certain depth in OC plans), but with this commit it's already usable.
This commit also fixes a couple of small bugs in commit b8ee3de870fa
("Dive planning for closed circuit rebreather") where a pO2 of 1.1 was
hardcoded in one place, throwing off all plan calculations and integer
math was used to calculate a floating point value (leading to most pO2
values actually used being 1.0).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This misses a single issue to be used as a base for further discussion:
The CC setpoint is used for the next segment, not the one specified for. I
also have in mind to modify the existing code to use setpoints specified
in mbar and plain integer instead of float values.
Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
On 28 January 2013 23:26, Dirk Hohndel <dirk@hohndel.org> wrote:
>
> Just pushed out Linus' Gtk3 readiness changes plus my change that allows
> the user to not only type in GPS coordinates but also use a map widget
> to pick the dive site.
>
> There were a few very odd Gtk things going on - when I opened the map
> widget from the dive info dialog (by clicking the button), the widget
> would be completely unresponsive. No panning, no zooming, no
> right-click, nothing.
>
> Opening an equipent widget and immideately closing it again suddenly
> made the map widget responsive. WTF?
>
> I worked around this by doing an explicit grab in the map widget, but
> that seems like a hack and just to work around the underlying issue.
>
> If anyone can figure this out, patches welcome.
>
> The other shortcomings (besides the uglyness of the UI) are that it may
> be non-obvious to the user that it takes a right click to get a menu
> item that allows you to "mark location here" - I'm sure there's a more
> intuitive way to do this, but since left click is used for panning, this
> was the best idea I could come up with...
>
> Please test - I wouldn't be surprised if there are a few bugs still
> hidden in this code.
>
here an fix to make this work on win32 and also solve a potential issue of type:
(subsurface.bin:19441): Gtk-CRITICAL **: IA__gtk_entry_set_text:
assertion `GTK_IS_ENTRY (entry)' failed
my commit message is explicit on the reasons:
------------------------
When called from the "dive edit" dialog the, map windows seems
inactive on Windows. It cannot accept focus and is also behind all
other application windows.
There are a couple of important new calls in gps.c:show_map():
gtk_window_set_transient_for(GTK_WINDOW(*window), GTK_WINDOW(main_window));
(^ docs say gtk "may" call this one for us, on what condition - not specified)
gtk_window_set_modal(GTK_WINDOW(*window), TRUE);
(^ broken on ubuntu 12.04, but needed on Win32))
Making the window transient for the main window and also modal for
the entire application's window stack (or at least try).
Older versions of gtk+2 and also in the most recently tested
libgtk2.0-0 2.24.10-0ubuntu6, seem not to recognize the significance
of gtk_window_set_modal() and the call does not work as expected.
This forces us to check if the dialog from which the call originated
exists, since its possible to close it _while_ the map widget is active.
More specifically, we check in info.c if the location_update.entry pointer
was set to NULL before performing actions with in the update_gps_entry()
callback.
------------------------
also removed the gtk_window_present() call as it seemed redundant post
these changes (?).
-------
on a side note:
looks like i'm above 100 commits...
cheers everyone <has a sip of some late beer> :0 ~ c|_|
lubomir
--
From fe9967c7ad2ec3b93ad336c2c6bed492a5ad0d8b Mon Sep 17 00:00:00 2001
From: "Lubomir I. Ivanov" <neolit123@gmail.com>
Date: Tue, 29 Jan 2013 00:24:21 +0200
Subject: [PATCH] Fix a "stacking" issue with the map-window on Windows
When called from the "dive edit" dialog the, map windows seems
inactive on Windows. It cannot accept focus and is also behind all
other application windows.
There are a couple of important new calls in gps.c:show_map():
gtk_window_set_transient_for(GTK_WINDOW(*window), GTK_WINDOW(main_window));
(^ docs say gtk "may" call this one for us, on what condition - not specified)
gtk_window_set_modal(GTK_WINDOW(*window), TRUE);
(^ broken on ubuntu 12.04, but needed on Win32))
Making the window transient for the main window and also modal for
the entire application's window stack (or at least try).
Older versions of gtk+2 and also in the most recently tested
libgtk2.0-0 2.24.10-0ubuntu6, seem not to recognize the significance
of gtk_window_set_modal() and the call does not work as expected.
This forces us to check if the dialog from which the call originated
exists, since its possible to close it _while_ the map widget is active.
More specifically, we check in info.c if the location_update.entry pointer
was set to NULL before performing actions with in the update_gps_entry()
callback.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The location map picker introduced in commit 801a61e7e0f2 ("Pick GPS
coordinates of dive location via map widget") failed to add the necessary
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>
I have some concerns about the way this is implemented - especially the
use of gtk_grab_add to make the map widget work has me worried. But it
seems to work and survived some test cases that I threw at it.
The GtkButton with the Pixmap looks a little off on my screen, but this
way it was easy to implement. Feel free to come up with a better design.
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>
There are more events than scroll_up and scroll_down - and because of this
we could end up with target_lat and target_lon being uninitialized.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The idea is that while zooming the map the point under the mouse would
stay as close to constant as possible (given that we use integer
coordinates).
This version uses some algebra to figure out the correct new parameters
for the mercator projection used in osm-gps-map.
Occasionally (and we haven't figured out what triggers it) zooming out
suddenly resets your position to 0,0.
[Dirk Hohndel: switched this to using the correct interface to get the
object properties and did some serious whitespace cleanup]
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I'm sure there are better ways to do this, but this appears to grok most
rational formats I was able to find. NSEW or positive/negative numbers.
Decimal degrees (WGS84) or degrees and decimal minutes (that's what most
GPSs seem to provide). I'm sure there are still corner cases that confuse
it, but it seemed reasonably robust in testing.
I don't really love the ';' as separator but that solves the obvious
problem with locales that use a decimal comma.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
That's much more intuitive to remove GPS data from a dive than having to
type in 0,0 as coordinates.
With this change we also skip leading whitespace for WGS84 coordinates.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>