#include "vikexttools.h"
#include "garminsymbols.h"
#include "vikmapslayer.h"
+#include "geonamessearch.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
static GObjectClass *parent_class;
static void window_set_filename ( VikWindow *vw, const gchar *filename );
+static const gchar *window_get_filename ( VikWindow *vw );
static VikWindow *window_new ();
gboolean only_updating_coord_mode_ui; /* hack for a bug in GTK */
GtkUIManager *uim;
+ GThread *thread;
/* half-drawn update */
VikLayer *trigger;
VikCoord trigger_center;
/* Store at this level for highlighted selection drawing since it applies to the viewport and the layers panel */
/* Only one of these items can be selected at the same time */
gpointer selected_vtl; /* notionally VikTrwLayer */
- gpointer selected_tracks; /* notionally GList */
+ GHashTable *selected_tracks;
gpointer selected_track; /* notionally VikTrack */
- gpointer selected_waypoints; /* notionally GList */
+ GHashTable *selected_waypoints;
gpointer selected_waypoint; /* notionally VikWaypoint */
/* only use for individual track or waypoint */
- ////// NEED TO THINK ABOUT VALIDITY OF THESE //////
- ////// i.e. what happens when stuff is deleted elsewhere //////
- ////// Generally seems alright as can not access them //////
- ////// containing_vtl now seems unecessary //////
/* For track(s) & waypoint(s) it is the layer they are in - this helps refering to the individual item easier */
gpointer containing_vtl; /* notionally VikTrwLayer */
};
static void set_toolbar_zoom ( VikWindow *vw, gdouble mpp )
{
- gint active = 2 + ( log (mpp) / log (2) );
+ gint active = 2 + round ( log (mpp) / log (2) );
// Can we not hard code size here?
if ( active > 17 )
active = 17;
vw->save_dia = NULL;
vw->save_img_dia = NULL;
vw->save_img_dir_dia = NULL;
+
+ // Store the thread value so comparisons can be made to determine the gdk update method
+ // Hopefully we are storing the main thread value here :)
+ // [ATM any window initialization is always be performed by the main thread]
+ vw->thread = g_thread_self();
}
static VikWindow *window_new ()
_("Do you want to save the changes you made to the document \"%s\"?\n"
"\n"
"Your changes will be lost if you don't save them."),
- vw->filename ? a_file_basename ( vw->filename ) : _("Untitled") ) );
+ window_get_filename ( vw ) ) );
gtk_dialog_add_buttons ( dia, _("Don't Save"), GTK_RESPONSE_NO, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_YES, NULL );
switch ( gtk_dialog_run ( dia ) )
{
/* draw compass */
#define CR 80
#define CW 4
- angle = atan2(dy, dx) + M_PI_2;
-
- if ( vik_viewport_get_drawmode ( vvp ) == VIK_VIEWPORT_DRAWMODE_UTM) {
- VikCoord test;
- struct LatLon ll;
- struct UTM u;
- gint tx, ty;
-
- vik_viewport_screen_to_coord ( vvp, x1, y1, &test );
- vik_coord_to_latlon ( &test, &ll );
- ll.lat += vik_viewport_get_ympp ( vvp ) * vik_viewport_get_height ( vvp ) / 11000.0; // about 11km per degree latitude
- a_coords_latlon_to_utm ( &ll, &u );
- vik_coord_load_from_utm ( &test, VIK_VIEWPORT_DRAWMODE_UTM, &u );
- vik_viewport_coord_to_screen ( vvp, &test, &tx, &ty );
-
- baseangle = M_PI - atan2(tx-x1, ty-y1);
- angle -= baseangle;
- }
- if (angle<0)
- angle+=2*M_PI;
- if (angle>2*M_PI)
- angle-=2*M_PI;
+ vik_viewport_compute_bearing ( vvp, x1, y1, x2, y2, &angle, &baseangle );
{
GdkColor color;
if ( filename == NULL )
{
vw->filename = NULL;
- file = _("Untitled");
}
else
{
vw->filename = g_strdup(filename);
- file = a_file_basename ( filename );
}
+
+ /* Refresh window's title */
+ file = window_get_filename ( vw );
title = g_strdup_printf( "%s - Viking", file );
gtk_window_set_title ( GTK_WINDOW(vw), title );
g_free ( title );
}
+static const gchar *window_get_filename ( VikWindow *vw )
+{
+ return vw->filename ? a_file_basename ( vw->filename ) : _("Untitled");
+}
+
GtkWidget *vik_window_get_drawmode_button ( VikWindow *vw, VikViewportDrawMode mode )
{
GtkWidget *mode_button;
gtk_window_set_destroy_with_parent ( GTK_WINDOW(vw->save_dia), TRUE );
}
// Auto append / replace extension with '.vik' to the suggested file name as it's going to be a Viking File
- gchar* auto_save_name = strdup ( vw->filename ? a_file_basename ( vw->filename ) : _("Untitled") );
+ gchar* auto_save_name = g_strdup ( window_get_filename ( vw ) );
if ( ! check_file_ext ( auto_save_name, ".vik" ) )
auto_save_name = g_strconcat ( auto_save_name, ".vik", NULL );
a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_file_interface );
}
-#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS
+#ifdef VIK_CONFIG_GOOGLE
static void acquire_from_google ( GtkAction *a, VikWindow *vw )
{
a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_google_interface );
}
#endif
+#ifdef VIK_CONFIG_GEONAMES
+static void acquire_from_wikipedia ( GtkAction *a, VikWindow *vw )
+{
+ a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_wikipedia_interface );
+}
+#endif
+
static void goto_default_location( GtkAction *a, VikWindow *vw)
{
struct LatLon ll;
static void goto_address( GtkAction *a, VikWindow *vw)
{
- a_vik_goto(vw, vw->viking_vlp, vw->viking_vvp);
+ a_vik_goto ( vw, vw->viking_vvp );
+ vik_layers_panel_emit_update ( vw->viking_vlp );
}
static void mapcache_flush_cb ( GtkAction *a, VikWindow *vw )
NULL,
VIK_LAYER_WIDGET_SPINBUTTON,
NULL,
+ NULL,
NULL },
};
VikLayerParam pref_lon[] = {
NULL,
VIK_LAYER_WIDGET_SPINBUTTON,
NULL,
+ NULL,
NULL },
};
zoom_combo = create_zoom_combo_all_levels();
gdouble mpp = vik_viewport_get_xmpp(vw->viking_vvp);
- gint active = 2 + ( log (mpp) / log (2) );
+ gint active = 2 + round ( log (mpp) / log (2) );
// Can we not hard code size here?
if ( active > 17 )
{ "Acquire", GTK_STOCK_GO_DOWN, N_("A_cquire"), NULL, NULL, (GCallback)NULL },
{ "AcquireGPS", NULL, N_("From _GPS..."), NULL, N_("Transfer data from a GPS device"), (GCallback)acquire_from_gps },
{ "AcquireGPSBabel", NULL, N_("Import File With GPS_Babel..."), NULL, N_("Import file via GPSBabel converter"), (GCallback)acquire_from_file },
-#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS
+#ifdef VIK_CONFIG_GOOGLE
{ "AcquireGoogle", NULL, N_("Google _Directions..."), NULL, N_("Get driving directions from Google"), (GCallback)acquire_from_google },
#endif
#ifdef VIK_CONFIG_OPENSTREETMAP
#endif
#ifdef VIK_CONFIG_GEOTAG
{ "AcquireGeotag", NULL, N_("From Geotagged _Images..."), NULL, N_("Create waypoints from geotagged images"), (GCallback)acquire_from_geotag },
+#endif
+#ifdef VIK_CONFIG_GEONAMES
+ { "AcquireWikipedia", NULL, N_("From _Wikipedia Waypoints"), NULL, N_("Create waypoints from Wikipedia items in the current view"), (GCallback)acquire_from_wikipedia },
#endif
{ "Save", GTK_STOCK_SAVE, N_("_Save"), "<control>S", N_("Save the file"), (GCallback)save_file },
{ "SaveAs", GTK_STOCK_SAVE_AS, N_("Save _As..."), NULL, N_("Save the file under different name"), (GCallback)save_file_as },
{ &zoom_18_pixbuf, "vik-icon-zoom" },
{ &ruler_18_pixbuf, "vik-icon-ruler" },
{ &select_18_pixbuf, "vik-icon-select" },
- { &begintr_18_pixbuf, "vik-icon-Begin Track" },
+ { &vik_new_route_18_pixbuf, "vik-icon-Create Route" },
{ &route_finder_18_pixbuf, "vik-icon-Route Finder" },
{ &demdl_18_pixbuf, "vik-icon-DEM Download" },
{ &showpic_18_pixbuf, "vik-icon-Show Picture" },
vik_viewport_set_highlight_thickness ( vw->viking_vvp, vik_trw_layer_get_property_tracks_line_thickness (vw->containing_vtl) );
}
-gpointer vik_window_get_selected_tracks ( VikWindow *vw )
+GHashTable *vik_window_get_selected_tracks ( VikWindow *vw )
{
return vw->selected_tracks;
}
-void vik_window_set_selected_tracks ( VikWindow *vw, gpointer gl, gpointer vtl )
+void vik_window_set_selected_tracks ( VikWindow *vw, GHashTable *ght, gpointer vtl )
{
- vw->selected_tracks = gl;
+ vw->selected_tracks = ght;
vw->containing_vtl = vtl;
/* Clear others */
vw->selected_vtl = NULL;
vik_viewport_set_highlight_thickness ( vw->viking_vvp, vik_trw_layer_get_property_tracks_line_thickness (vw->containing_vtl) );
}
-gpointer vik_window_get_selected_waypoints ( VikWindow *vw )
+GHashTable *vik_window_get_selected_waypoints ( VikWindow *vw )
{
return vw->selected_waypoints;
}
-void vik_window_set_selected_waypoints ( VikWindow *vw, gpointer gl, gpointer vtl )
+void vik_window_set_selected_waypoints ( VikWindow *vw, GHashTable *ght, gpointer vtl )
{
- vw->selected_waypoints = gl;
+ vw->selected_waypoints = ght;
vw->containing_vtl = vtl;
/* Clear others */
vw->selected_vtl = NULL;
}
return need_redraw;
}
+
+GThread *vik_window_get_thread ( VikWindow *vw )
+{
+ return vw->thread;
+}