Commit graph

30 commits

Author SHA1 Message Date
Benjamin
aa5365eb3f Clean up code to remove false messages about errors in Eclipse
Imported the subsurface project into Eclipse to try and pull apart
how it all works together. Added an include for profile.h and some
brackets around a condition, but didn't make any functional changes
(I hope). These 2 changes should be purely cosmetic.

Signed-off-by: Benjamin Fogel <benjaminfogel@yahoo.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-08-05 16:49:33 +02:00
Dirk Hohndel
d1c394e51f Make the map provider choice a preference
Not all of the providers seem to work for me (Yahoo Satellite doesn't
appear to give me any data), but for now I'll leave most of them in.
We can later decide to offer only some of them.

It might be more fun to be able to pick the provider directly from the map
widget. But for now I kept this in the preferences which seemed to be a
good place for it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-01 23:09:12 -08:00
Lubomir I. Ivanov
ef4a39c613 gps.c: Fixed a small memory leak
osm_gps_map_get_default_cache_directory() uses stdc:strdup to allocate
memory for the returned string. Lets try to free the memory
pointed by 'cachebasedir'.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-20 17:21:03 -08:00
Dirk Hohndel
f50ae3a689 Update German and Swiss-German translations for latest strings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-11 20:19:33 -08:00
Dirk Hohndel
4ed41dd49f Add instructions to GPS map window title
This is not what I really wanted (which was the ability to add text to the
map itself), but it should be at least somewhat better than what we have
today (which is a complete lack of instructions).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-11 19:52:44 -08:00
Dirk Hohndel
e5985b9657 Remove "target ring" in map display
This could easily lead to confusion that this is where a dive spot would
be marked (instead of the location of the mouse during right click).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-10 12:48:41 -08:00
Henrik Brautaset Aronsen
37364fb40a Make map dot more visible
The OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_HYBRID shows cities as red dots
in a couple of the zoom levels.  Make the dive dots larger and
yellow to make them stand out.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 13:16:10 -08:00
Henrik Brautaset Aronsen
8af8162809 Switch to satellite image map provider
The current google map provider doesn't show coast lines properly and
a lot of islands aren't shown at all.
OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_HYBRID is much better IMHO.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 12:44:05 -08:00
Dirk Hohndel
2f059c8b81 Replace deprecated gdk_pixbuf_unref with g_object_unref
This appears to be the better API call to do this (according to online
documentation and compiler warnings on Linux).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 11:48:12 -08:00
Lubomir I. Ivanov
df8fb3be98 gps.c: Make two more memory leak fixes and a small coding style change
1)
add_gps_point():
Apparently osm_gps_map_point_new_*() is leaking memory if the
point struct is not freed after the point is added to the
map osm_gps_map_track_add_point().

However the API for releasing a point is missing on
older Windows builds of the map library, so instead of
osm_gps_map_point_free() we simply call:
	free((void *)point);

2)
init_map()
According to memory management tools
osm_gps_map_get_default_cache_directory() is using g_realloc
for eventual string expansion therefore we have to release at the
returned pointer.

3)
add_gps_point()
Also a small coding style change is made:
move the pointer symbol (*) near the name of the variable
instead of leaving spaces on both sides, like:
<type> * <name>

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>

...

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 11:41:20 -08:00
Lubomir I. Ivanov
801b0832ae gps.c: Use only one instance of the map object and window
Both show_gps_locations() and show_gps_location() have
static local variables 'map' (OSM_TYPE_GPS_MAP) and 'window',
so technically both would create their own instances of these
objects.

This patch promotes the two variables to global, so that only
one instance per type ever exists.

A memory leak that is addressed is at the flag pixbuf
allocation, which has to be freed right after the image
is added to the map:
picture = gdk_pixbuf_from_pixdata(&flag_pixbuf, TRUE, NULL);
...
gdk_pixbuf_unref(picture);

There is also a heap-lifespan memory leak at:
map = g_object_new(OSM_TYPE_GPS_MAP,...
but GLib isn't exacly happy about us unrefing it right before
exiting the GTK main loop, so no fix is provided for that
unfortunately.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 11:40:55 -08:00
Dirk Hohndel
cf3c0266c2 Move flag icon to include file
Just like with the satellite icon we are creating a pixdata structure for
the flag.

The Makefile cleanup in commit df6a9ddd8a21 ("Auto-generate C file
dependencies, and make the build more quiet") removed the rules for
generating the .h file by mistake (I hope).

This adds a more generic rule back in and also makes sure that the data
structures get more useful names.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-01 17:25:41 +11:00
Dirk Hohndel
b87a10a696 Minor fine tuning of window size and initial zoom factors for maps
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>
2013-01-31 16:20:24 +11:00
Dirk Hohndel
635c28923d Better algorithm to merge gps locations & locations names from webservice
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>
2013-01-31 14:29:02 +11:00
Pierre-Yves Chibon
410c439aef Enable to key 'Esc' to close the map view
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>
2013-01-30 12:07:13 +11:00
Dirk Hohndel
e3a8ed5183 Massive cleanup
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>
2013-01-30 08:31:53 +11:00
Dirk Hohndel
a61877d1d4 Add missing strings for translations
Mostly in new code, but some of them are strings in older code that have
been missed in the past.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-29 20:32:56 +11:00
Lubomir I. Ivanov
37282176d5 GPS location map input
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>
2013-01-28 18:20:29 -08:00
Dirk Hohndel
24f1403831 Merge branch 'gps-map-input'
Add ability to pick GPS coordinates of dive locations from a map widget.
2013-01-28 13:18:48 -08:00
Dirk Hohndel
332d372b80 Pick GPS coordinates of dive location via map widget
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>
2013-01-28 13:07:08 -08:00
Linus Torvalds
41027c2843 Make subsurface compile with -DGSEAL_ENABLE
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>
2013-01-28 07:54:55 -08:00
Dirk Hohndel
075aba8f7d Fix the zooming bug in the map window
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>
2013-01-27 16:57:48 -08:00
Robert C. Helling
ae64abfbca Modify map zoom to keep the point under the mouse cursor constant
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>
2013-01-27 15:48:25 -08:00
Linus Torvalds
e618a245b9 Use proper helper functions for dive location and for_each_dive
This makes the code use the "dive_has_location()" function rather than
check the longitude and latitude directly.

It also uses "for_each_dive()" rather than open-coding it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-22 22:26:12 -08:00
Dirk Hohndel
9e13655854 White space and coding style adjustments for gps.c
It's just nicer this way.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-20 20:28:37 -08:00
Dirk Hohndel
97ce7a3763 Fix map scrolling
The osm-gps-map default is to scroll-and-recenter around the mouse position.
That is BAT SHIT CRAZY. So this implements our own scroll handling instead.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-20 20:26:15 -08:00
Dirk Hohndel
980ba9cb50 Reuse map windows
Instead of opening a new window / new map for every dive site we now have only
two windows / maps. One for the overview of all the dive sites, the other one
that is used to show the map for a specific dive site.

This also switches the position preference from CENTER to MOUSE - this way it's
less likely that the two map windows will be drawn exactly on top of each
other.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-20 17:07:07 -08:00
Henrik Brautaset Aronsen
e9953fa5e6 Show single dives in map.
This adds a "Show in map" entry in the dive list context menu.  It will
zoom to the dive location if it exists, otherwise the full map will be
displayed.

I've also switched map tiles from OpenStreetMap to Google Maps just to
show off that we can.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-15 17:41:57 -08:00
Lubomir I. Ivanov
2330f9b379 Use the legacy GDK keyboard definitions in gps.c
display-gtk.h has a check if gdkkeysyms-compat.h or gdkkeysyms.h
has to be used. In gps.c, from such as "GDK_Up" has to be used,
so that this file compiles on older GTK.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-14 20:17:20 -08:00
Pierre-Yves Chibon
8ff350387d Work on a dive localisation tool using GPS coordinates
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>
2013-01-13 10:08:07 -08:00