#include "vikexttool_datasources.h"
#include "garminsymbols.h"
#include "vikmapslayer.h"
+#include "vikrouting.h"
#include "geonamessearch.h"
-#include "vikutils.h"
#include "dir.h"
#include "kmz.h"
static void destroy_window ( GtkWidget *widget,
gpointer data )
{
+ g_debug ( "%s", __FUNCTION__ );
if ( ! --window_count ) {
g_free ( last_folder_files_uri );
g_free ( last_folder_images_uri );
{
VikWindow *vw = window_new ();
+ if ( window_count == 0 ) {
+ vik_window_statusbar_update ( vw, _("This is Viking "VIKING_VERSION), VIK_STATUSBAR_INFO );
+ }
+
g_signal_connect (G_OBJECT (vw), "destroy",
G_CALLBACK (destroy_window), NULL);
g_signal_connect (G_OBJECT (vw), "newwindow",
static gboolean draw_buf(gpointer data)
{
gpointer *pass_along = data;
- gdk_threads_enter();
gdk_draw_drawable (pass_along[0], pass_along[1],
pass_along[2], 0, 0, 0, 0, -1, -1);
draw_buf_done = TRUE;
- gdk_threads_leave();
return FALSE;
}
toggle_main_menu ( vw );
}
else
- toggle_toolbar ( vw );
+ toggle_main_menu ( vw );
}
/***************************************
return vw->pan_move;
}
+/**
+ * Remove the potentially auto added map
+ */
+static void remove_default_map_layer ( VikWindow *vw )
+{
+ if ( a_vik_get_add_default_map_layer () ) {
+ VikAggregateLayer *top = vik_layers_panel_get_top_layer(vw->viking_vlp);
+ if ( vik_aggregate_layer_count(top) == 1 ) {
+ VikLayer *vl = vik_aggregate_layer_get_top_visible_layer_of_type (top, VIK_LAYER_MAPS);
+ // Could try to compare name vs _("Default Map") but this might have i8n issues if not translated
+ if ( vl )
+ vik_aggregate_layer_delete_layer ( top, vl );
+ }
+ }
+}
+
static void on_activate_recent_item (GtkRecentChooser *chooser,
VikWindow *self)
{
// NB: GSList & contents are freed by main.open_window
}
else {
+ remove_default_map_layer ( self );
vik_window_open_file ( self, path, TRUE );
g_free ( path );
}
vw->filename = g_strdup ( filename );
gboolean success = FALSE;
gboolean restore_original_filename = FALSE;
-
- vw->loaded_type = a_file_load ( vik_layers_panel_get_top_layer(vw->viking_vlp), vw->viking_vvp, filename );
+ vw->loaded_type = a_file_load ( vik_layers_panel_get_top_layer(vw->viking_vlp), vw->viking_vvp, vw->containing_vtl, filename );
switch ( vw->loaded_type )
{
case LOAD_TYPE_READ_FAILURE:
if ( newwindow && check_file_magic_vik ( file_name ) ) {
// Load first of many .vik files in current window
if ( first_vik_file ) {
+ remove_default_map_layer ( vw );
vik_window_open_file ( vw, file_name, TRUE );
first_vik_file = FALSE;
}
{ "Export", GTK_STOCK_CONVERT, N_("_Export All"), NULL, N_("Export All TrackWaypoint Layers"), (GCallback)NULL },
{ "ExportGPX", NULL, N_("_GPX..."), NULL, N_("Export as GPX"), (GCallback)export_to_gpx },
{ "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 },
{ "AcquireRouting", NULL, N_("_Directions..."), NULL, N_("Get driving directions"), (GCallback)acquire_from_routing },
#ifdef VIK_CONFIG_OPENSTREETMAP
{ "AcquireOSM", NULL, N_("_OSM Traces..."), NULL, N_("Get traces from OpenStreetMap"), (GCallback)acquire_from_osm },
static GtkActionEntry entries_gpsbabel[] = {
{ "ExportKML", NULL, N_("_KML..."), NULL, N_("Export as KML"), (GCallback)export_to_kml },
+ { "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 },
};
static GtkActionEntry entries_geojson[] = {
// Use this to see if GPSBabel is available:
if ( a_babel_available () ) {
- // If going to add more entries then might be worth creating a menu_gpsbabel.xml.h file
- if ( gtk_ui_manager_add_ui_from_string ( uim,
- "<ui><menubar name='MainMenu'><menu action='File'><menu action='Export'><menuitem action='ExportKML'/></menu></menu></menubar></ui>",
- -1, &error ) )
+ // If going to add more entries then might be worth creating a menu_gpsbabel.xml.h file
+ if ( gtk_ui_manager_add_ui_from_string ( uim,
+ "<ui>" \
+ "<menubar name='MainMenu'>" \
+ "<menu action='File'><menu action='Export'><menuitem action='ExportKML'/></menu></menu>" \
+ "<menu action='File'><menu action='Acquire'><menuitem action='AcquireGPS'/></menu></menu>" \
+ "<menu action='File'><menu action='Acquire'><menuitem action='AcquireGPSBabel'/></menu></menu>" \
+ "</menubar>" \
+ "</ui>",
+ -1, &error ) )
gtk_action_group_add_actions ( action_group, entries_gpsbabel, G_N_ELEMENTS (entries_gpsbabel), window );
}
action.name = vik_layer_get_interface(i)->name;
action.stock_id = vik_layer_get_interface(i)->name;
- action.label = g_strdup_printf( _("New _%s Layer"), vik_layer_get_interface(i)->name);
+ action.label = g_strdup_printf( _("New _%s Layer"), _(vik_layer_get_interface(i)->name));
action.accelerator = vik_layer_get_interface(i)->accelerator;
action.tooltip = NULL;
action.callback = (GCallback)menu_addlayer_cb;
// This is to avoid clashing with just the layer name used above for the tool actions
action_dl.name = g_strconcat("Layer", vik_layer_get_interface(i)->fixed_layer_name, NULL);
action_dl.stock_id = NULL;
- action_dl.label = g_strconcat("_", vik_layer_get_interface(i)->name, "...", NULL); // Prepend marker for keyboard accelerator
+ action_dl.label = g_strconcat(_(vik_layer_get_interface(i)->name), _("..."), NULL);
action_dl.accelerator = NULL;
action_dl.tooltip = NULL;
action_dl.callback = (GCallback)layer_defaults_cb;
gtk_ui_manager_ensure_update (uim);
setup_recent_files(window);
+
+ if ( vik_routing_number_of_engines(VIK_ROUTING_METHOD_DIRECTIONS) == 0 ) {
+ GtkWidget *widget = gtk_ui_manager_get_widget ( uim, "/ui/MainMenu/File/Acquire/AcquireRouting" );
+ if ( widget ) {
+ g_object_set ( widget, "sensitive", FALSE, NULL );
+ }
+ g_warning ( "No direction routing engines available" );
+ }
}
gboolean vik_window_clear_highlight ( VikWindow *vw )
{
gboolean need_redraw = FALSE;
+ vw->containing_vtl = NULL;
if ( vw->selected_vtl != NULL ) {
vw->selected_vtl = NULL;
need_redraw = TRUE;