]> git.street.me.uk Git - andy/viking.git/blobdiff - src/vikwindow.c
Prevent the program grinding to a halt if trying to deal with thousands of tiles
[andy/viking.git] / src / vikwindow.c
index f444b87e3cf8df0cd0720979ff615e8acf2b3efb..7399d3622fe0d4af03771cb60cf3394e54e67a50 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
  * Copyright (C) 2005-2006, Alex Foobarian <foobarian@gmail.com>
  *
  * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
  * Copyright (C) 2005-2006, Alex Foobarian <foobarian@gmail.com>
+ * Copyright (C) 2012, Rob Norris <rw_norris@hotmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #include "mapcache.h"
 #include "print.h"
 #include "preferences.h"
 #include "mapcache.h"
 #include "print.h"
 #include "preferences.h"
+#include "viklayer_defaults.h"
 #include "icons/icons.h"
 #include "vikexttools.h"
 #include "garminsymbols.h"
 #include "icons/icons.h"
 #include "vikexttools.h"
 #include "garminsymbols.h"
+#include "vikmapslayer.h"
+#include "geonamessearch.h"
 
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #include <gio/gio.h>
 #include <gdk/gdkkeysyms.h>
 
 #include <gio/gio.h>
 #include <gdk/gdkkeysyms.h>
 
+// This seems rather arbitary, quite large and pointless
+//  I mean, if you have a thousand windows open;
+//   why not be allowed to open a thousand more...
+#define MAX_WINDOWS 1024
+static guint window_count = 0;
+
 #define VIKING_WINDOW_WIDTH      1000
 #define VIKING_WINDOW_HEIGHT     800
 #define DRAW_IMAGE_DEFAULT_WIDTH 1280
 #define VIKING_WINDOW_WIDTH      1000
 #define VIKING_WINDOW_HEIGHT     800
 #define DRAW_IMAGE_DEFAULT_WIDTH 1280
 static void window_finalize ( GObject *gob );
 static GObjectClass *parent_class;
 
 static void window_finalize ( GObject *gob );
 static GObjectClass *parent_class;
 
-static void window_init ( VikWindow *vw );
-static void window_class_init ( VikWindowClass *klass );
 static void window_set_filename ( VikWindow *vw, const gchar *filename );
 static void window_set_filename ( VikWindow *vw, const gchar *filename );
+static const gchar *window_get_filename ( VikWindow *vw );
+
+static VikWindow *window_new ();
 
 static void draw_update ( VikWindow *vw );
 
 static void newwindow_cb ( GtkAction *a, VikWindow *vw );
 
 
 static void draw_update ( VikWindow *vw );
 
 static void newwindow_cb ( GtkAction *a, VikWindow *vw );
 
+// Signals
+static void open_window ( VikWindow *vw, GSList *files );
+static void statusbar_update ( VikWindow *vw, const gchar *message, vik_statusbar_type_t vs_type );
+static void destroy_window ( GtkWidget *widget,
+                             gpointer   data );
+
 /* Drawing & stuff */
 
 static gboolean delete_event( VikWindow *vw );
 /* Drawing & stuff */
 
 static gboolean delete_event( VikWindow *vw );
@@ -86,6 +103,7 @@ static void draw_release ( VikWindow *vw, GdkEventButton *event );
 static void draw_mouse_motion ( VikWindow *vw, GdkEventMotion *event );
 static void draw_zoom_cb ( GtkAction *a, VikWindow *vw );
 static void draw_goto_cb ( GtkAction *a, VikWindow *vw );
 static void draw_mouse_motion ( VikWindow *vw, GdkEventMotion *event );
 static void draw_zoom_cb ( GtkAction *a, VikWindow *vw );
 static void draw_goto_cb ( GtkAction *a, VikWindow *vw );
+static void draw_refresh_cb ( GtkAction *a, VikWindow *vw );
 
 static void draw_status ( VikWindow *vw );
 
 
 static void draw_status ( VikWindow *vw );
 
@@ -140,8 +158,6 @@ struct _VikWindow {
 
   GtkToolbar *toolbar;
 
 
   GtkToolbar *toolbar;
 
-  GtkItemFactory *item_factory;
-
   /* tool management state */
   guint current_tool;
   toolbox_tools_t *vt;
   /* tool management state */
   guint current_tool;
   toolbox_tools_t *vt;
@@ -165,6 +181,7 @@ struct _VikWindow {
   gboolean only_updating_coord_mode_ui; /* hack for a bug in GTK */
   GtkUIManager *uim;
 
   gboolean only_updating_coord_mode_ui; /* hack for a bug in GTK */
   GtkUIManager *uim;
 
+  GThread  *thread;
   /* half-drawn update */
   VikLayer *trigger;
   VikCoord trigger_center;
   /* half-drawn update */
   VikLayer *trigger;
   VikCoord trigger_center;
@@ -172,16 +189,11 @@ struct _VikWindow {
   /* 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 */
   /* 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_track; /* notionally VikTrack */
-  gpointer selected_waypoints; /* notionally GList */
+  GHashTable *selected_waypoints;
   gpointer selected_waypoint; /* notionally VikWaypoint */
   /* only use for individual track or waypoint */
   gpointer selected_waypoint; /* notionally VikWaypoint */
   /* only use for individual track or waypoint */
-  gpointer selected_name; /* notionally gchar */
-  ////// 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 */
 };
   /* 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 */
 };
@@ -198,36 +210,16 @@ enum {
 enum {
   VW_NEWWINDOW_SIGNAL,
   VW_OPENWINDOW_SIGNAL,
 enum {
   VW_NEWWINDOW_SIGNAL,
   VW_OPENWINDOW_SIGNAL,
+  VW_STATUSBAR_UPDATE_SIGNAL,
   VW_LAST_SIGNAL
 };
 
 static guint window_signals[VW_LAST_SIGNAL] = { 0 };
 
   VW_LAST_SIGNAL
 };
 
 static guint window_signals[VW_LAST_SIGNAL] = { 0 };
 
+// TODO get rid of this as this is unnecessary duplication...
 static gchar *tool_names[NUMBER_OF_TOOLS] = { N_("Pan"), N_("Zoom"), N_("Ruler"), N_("Select") };
 
 static gchar *tool_names[NUMBER_OF_TOOLS] = { N_("Pan"), N_("Zoom"), N_("Ruler"), N_("Select") };
 
-GType vik_window_get_type (void)
-{
-  static GType vw_type = 0;
-
-  if (!vw_type)
-  {
-    static const GTypeInfo vw_info = 
-    {
-      sizeof (VikWindowClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) window_class_init, /* class_init */
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof (VikWindow),
-      0,
-      (GInstanceInitFunc) window_init,
-    };
-    vw_type = g_type_register_static ( GTK_TYPE_WINDOW, "VikWindow", &vw_info, 0 );
-  }
-
-  return vw_type;
-}
+G_DEFINE_TYPE (VikWindow, vik_window, GTK_TYPE_WINDOW)
 
 VikViewport * vik_window_viewport(VikWindow *vw)
 {
 
 VikViewport * vik_window_viewport(VikWindow *vw)
 {
@@ -247,6 +239,96 @@ VikStatusbar * vik_window_get_statusbar ( VikWindow *vw )
   return vw->viking_vs;
 }
 
   return vw->viking_vs;
 }
 
+/**
+ * For signalling the update from a background thread
+ */
+void vik_window_signal_statusbar_update (VikWindow *vw, const gchar* message, vik_statusbar_type_t vs_type)
+{
+  g_signal_emit ( G_OBJECT(vw), window_signals[VW_STATUSBAR_UPDATE_SIGNAL], 0, message, vs_type );
+}
+
+/**
+ * For the actual statusbar update!
+ */
+static gboolean statusbar_idle_update ( gpointer indata )
+{
+  gpointer *data = indata;
+  vik_statusbar_set_message ( data[0], GPOINTER_TO_INT(data[2]), data[1] );
+  return FALSE;
+}
+
+/**
+ * Update statusbar in the main thread
+ */
+static void window_statusbar_update ( VikWindow *vw, const gchar* message, vik_statusbar_type_t vs_type )
+{
+  // ATM we know the message has been statically allocated so this is OK (no need to handle any freeing)
+  static gpointer data[3];
+  data[0] = vw->viking_vs;
+  data[1] = (gchar*) message;
+  data[2] = GINT_TO_POINTER(vs_type);
+  g_idle_add ( (GSourceFunc) statusbar_idle_update, data );
+}
+
+// Actual signal handlers
+static void destroy_window ( GtkWidget *widget,
+                             gpointer   data )
+{
+    if ( ! --window_count )
+      gtk_main_quit ();
+}
+
+static void statusbar_update ( VikWindow *vw, const gchar *message, vik_statusbar_type_t vs_type )
+{
+  window_statusbar_update ( vw, message, vs_type );
+}
+
+VikWindow *vik_window_new_window ()
+{
+  if ( window_count < MAX_WINDOWS )
+  {
+    VikWindow *vw = window_new ();
+
+    g_signal_connect (G_OBJECT (vw), "destroy",
+                     G_CALLBACK (destroy_window), NULL);
+    g_signal_connect (G_OBJECT (vw), "newwindow",
+                     G_CALLBACK (vik_window_new_window), NULL);
+    g_signal_connect (G_OBJECT (vw), "openwindow",
+                     G_CALLBACK (open_window), NULL);
+    g_signal_connect (G_OBJECT (vw), "statusbarupdate",
+                     G_CALLBACK (statusbar_update), vw);
+
+    gtk_widget_show_all ( GTK_WIDGET(vw) );
+
+    window_count++;
+
+    return vw;
+  }
+  return NULL;
+}
+
+static void open_window ( VikWindow *vw, GSList *files )
+{
+  gboolean change_fn = (g_slist_length(files) == 1); /* only change fn if one file */
+  GSList *cur_file = files;
+  while ( cur_file ) {
+    // Only open a new window if a viking file
+    gchar *file_name = cur_file->data;
+    if (vw != NULL && check_file_magic_vik ( file_name ) ) {
+      VikWindow *newvw = vik_window_new_window ();
+      if (newvw)
+        vik_window_open_file ( newvw, file_name, TRUE );
+    }
+    else {
+      vik_window_open_file ( vw, file_name, change_fn );
+    }
+    g_free (file_name);
+    cur_file = g_slist_next (cur_file);
+  }
+  g_slist_free (files);
+}
+// End signals
+
 void vik_window_selected_layer(VikWindow *vw, VikLayer *vl)
 {
   int i, j, tool_count;
 void vik_window_selected_layer(VikWindow *vw, VikLayer *vl)
 {
   int i, j, tool_count;
@@ -261,7 +343,7 @@ void vik_window_selected_layer(VikWindow *vw, VikLayer *vl)
 
     for (j = 0; j < tool_count; j++) {
       action = gtk_action_group_get_action(vw->action_group,
 
     for (j = 0; j < tool_count; j++) {
       action = gtk_action_group_get_action(vw->action_group,
-           layer_interface->tools[j].name);
+                                           layer_interface->tools[j].radioActionEntry.name);
       g_object_set(action, "sensitive", i == vl->type, NULL);
     }
   }
       g_object_set(action, "sensitive", i == vl->type, NULL);
     }
   }
@@ -272,19 +354,20 @@ static void window_finalize ( GObject *gob )
   VikWindow *vw = VIK_WINDOW(gob);
   g_return_if_fail ( vw != NULL );
 
   VikWindow *vw = VIK_WINDOW(gob);
   g_return_if_fail ( vw != NULL );
 
-  a_background_remove_status ( vw->viking_vs );
+  a_background_remove_window ( vw );
 
   G_OBJECT_CLASS(parent_class)->finalize(gob);
 }
 
 
 
   G_OBJECT_CLASS(parent_class)->finalize(gob);
 }
 
 
-static void window_class_init ( VikWindowClass *klass )
+static void vik_window_class_init ( VikWindowClass *klass )
 {
   /* destructor */
   GObjectClass *object_class;
 
   window_signals[VW_NEWWINDOW_SIGNAL] = g_signal_new ( "newwindow", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (VikWindowClass, newwindow), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
   window_signals[VW_OPENWINDOW_SIGNAL] = g_signal_new ( "openwindow", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (VikWindowClass, openwindow), NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
 {
   /* destructor */
   GObjectClass *object_class;
 
   window_signals[VW_NEWWINDOW_SIGNAL] = g_signal_new ( "newwindow", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (VikWindowClass, newwindow), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
   window_signals[VW_OPENWINDOW_SIGNAL] = g_signal_new ( "openwindow", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (VikWindowClass, openwindow), NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
+  window_signals[VW_STATUSBAR_UPDATE_SIGNAL] = g_signal_new ( "statusbarupdate", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (VikWindowClass, statusbarupdate), NULL, NULL, gtk_marshal_VOID__POINTER_UINT, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT);
 
   object_class = G_OBJECT_CLASS (klass);
 
 
   object_class = G_OBJECT_CLASS (klass);
 
@@ -294,7 +377,87 @@ static void window_class_init ( VikWindowClass *klass )
 
 }
 
 
 }
 
-static void window_init ( VikWindow *vw )
+static void zoom_changed (GtkMenuShell *menushell,
+              gpointer      user_data)
+{
+  VikWindow *vw = VIK_WINDOW (user_data);
+
+  GtkWidget *aw = gtk_menu_get_active ( GTK_MENU (menushell) );
+  gint active = GPOINTER_TO_INT(g_object_get_data ( G_OBJECT (aw), "position" ));
+
+  gdouble zoom_request = pow (2, active-2 );
+
+  // But has it really changed?
+  gdouble current_zoom = vik_viewport_get_zoom ( vw->viking_vvp );
+  if ( current_zoom != 0.0 && zoom_request != current_zoom ) {
+    vik_viewport_set_zoom ( vw->viking_vvp, zoom_request );
+    // Force drawing update
+    draw_update ( vw );
+  }
+}
+
+static GtkWidget * create_zoom_menu_all_levels ()
+{
+  GtkWidget *menu = gtk_menu_new ();
+  char *itemLabels[] = { "0.25", "0.5", "1", "2", "4", "8", "16", "32", "64", "128", "256", "512", "1024", "2048", "4096", "8192", "16384", "32768", NULL };
+
+  int i;
+  for (i = 0 ; itemLabels[i] != NULL ; i++)
+    {
+      GtkWidget *item = gtk_menu_item_new_with_label (itemLabels[i]);
+      gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+      gtk_widget_show (item);
+      g_object_set_data (G_OBJECT (item), "position", GINT_TO_POINTER(i));
+    }
+
+  return menu;
+}
+
+static GtkWidget *create_zoom_combo_all_levels ()
+{
+  GtkWidget *zoom_combo = gtk_combo_box_new_text();
+  GtkComboBox *combo = GTK_COMBO_BOX ( zoom_combo );
+  gtk_combo_box_append_text ( combo, "0.25");
+  gtk_combo_box_append_text ( combo, "0.5");
+  gtk_combo_box_append_text ( combo, "1");
+  gtk_combo_box_append_text ( combo, "2");
+  gtk_combo_box_append_text ( combo, "4");
+  gtk_combo_box_append_text ( combo, "8");
+  gtk_combo_box_append_text ( combo, "16");
+  gtk_combo_box_append_text ( combo, "32");
+  gtk_combo_box_append_text ( combo, "64");
+  gtk_combo_box_append_text ( combo, "128");
+  gtk_combo_box_append_text ( combo, "256");
+  gtk_combo_box_append_text ( combo, "512");
+  gtk_combo_box_append_text ( combo, "1024");
+  gtk_combo_box_append_text ( combo, "2048");
+  gtk_combo_box_append_text ( combo, "4096");
+  gtk_combo_box_append_text ( combo, "8192");
+  gtk_combo_box_append_text ( combo, "16384");
+  gtk_combo_box_append_text ( combo, "32768");
+  /* Create tooltip */
+  gtk_widget_set_tooltip_text (GTK_WIDGET (combo), _("Select zoom level"));
+  return zoom_combo;
+}
+
+static gint zoom_popup_handler (GtkWidget *widget)
+{
+  GtkMenu *menu;
+
+  g_return_val_if_fail (widget != NULL, FALSE);
+  g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
+
+  /* The "widget" is the menu that was supplied when
+   * g_signal_connect_swapped() was called.
+   */
+  menu = GTK_MENU (widget);
+
+  gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
+                  1, gtk_get_current_event_time());
+  return TRUE;
+}
+
+static void vik_window_init ( VikWindow *vw )
 {
   GtkWidget *main_vbox;
   GtkWidget *hpaned;
 {
   GtkWidget *main_vbox;
   GtkWidget *hpaned;
@@ -311,10 +474,10 @@ static void window_init ( VikWindow *vw )
   window_set_filename (vw, NULL);
   vw->toolbar = GTK_TOOLBAR(gtk_ui_manager_get_widget (vw->uim, "/MainToolbar"));
 
   window_set_filename (vw, NULL);
   vw->toolbar = GTK_TOOLBAR(gtk_ui_manager_get_widget (vw->uim, "/MainToolbar"));
 
-  toolbox_activate(vw->vt, "Pan");
+  // Set the default tool
+  gtk_action_activate ( gtk_action_group_get_action ( vw->action_group, "Pan" ) );
 
   vw->filename = NULL;
 
   vw->filename = NULL;
-  vw->item_factory = NULL;
 
   vw->modified = FALSE;
   vw->only_updating_coord_mode_ui = FALSE;
 
   vw->modified = FALSE;
   vw->only_updating_coord_mode_ui = FALSE;
@@ -335,6 +498,12 @@ static void window_init ( VikWindow *vw )
 
   vik_ext_tools_add_menu_items ( vw, vw->uim );
 
 
   vik_ext_tools_add_menu_items ( vw, vw->uim );
 
+  GtkWidget * zoom_levels = gtk_ui_manager_get_widget (vw->uim, "/MainMenu/View/SetZoom");
+  GtkWidget * zoom_levels_menu = create_zoom_menu_all_levels ();
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (zoom_levels), zoom_levels_menu);
+  g_signal_connect ( G_OBJECT(zoom_levels_menu), "selection-done", G_CALLBACK(zoom_changed), vw);
+  g_signal_connect_swapped ( G_OBJECT(vw->viking_vs), "clicked", G_CALLBACK(zoom_popup_handler), zoom_levels_menu );
+
   g_signal_connect (G_OBJECT (vw), "delete_event", G_CALLBACK (delete_event), NULL);
 
   g_signal_connect_swapped (G_OBJECT(vw->viking_vvp), "expose_event", G_CALLBACK(draw_sync), vw);
   g_signal_connect (G_OBJECT (vw), "delete_event", G_CALLBACK (delete_event), NULL);
 
   g_signal_connect_swapped (G_OBJECT(vw->viking_vvp), "expose_event", G_CALLBACK(draw_sync), vw);
@@ -346,7 +515,8 @@ static void window_init ( VikWindow *vw )
   g_signal_connect_swapped (G_OBJECT(vw->viking_vvp), "motion_notify_event", G_CALLBACK(draw_mouse_motion), vw);
   g_signal_connect_swapped (G_OBJECT(vw->viking_vlp), "update", G_CALLBACK(draw_update), vw);
 
   g_signal_connect_swapped (G_OBJECT(vw->viking_vvp), "motion_notify_event", G_CALLBACK(draw_mouse_motion), vw);
   g_signal_connect_swapped (G_OBJECT(vw->viking_vlp), "update", G_CALLBACK(draw_update), vw);
 
-  g_signal_connect_swapped (G_OBJECT (vw->viking_vvp), "key_press_event", G_CALLBACK (key_press_event), vw);
+  // Allow key presses to be processed anywhere
+  g_signal_connect_swapped (G_OBJECT (vw), "key_press_event", G_CALLBACK (key_press_event), vw);
 
   gtk_window_set_default_size ( GTK_WINDOW(vw), VIKING_WINDOW_WIDTH, VIKING_WINDOW_HEIGHT);
 
 
   gtk_window_set_default_size ( GTK_WINDOW(vw), VIKING_WINDOW_WIDTH, VIKING_WINDOW_HEIGHT);
 
@@ -359,21 +529,75 @@ static void window_init ( VikWindow *vw )
 
   gtk_box_pack_end (GTK_BOX(main_vbox), GTK_WIDGET(vw->viking_vs), FALSE, TRUE, 0);
 
 
   gtk_box_pack_end (GTK_BOX(main_vbox), GTK_WIDGET(vw->viking_vs), FALSE, TRUE, 0);
 
-  a_background_add_status(vw->viking_vs);
+  a_background_add_window ( vw );
 
   vw->open_dia = NULL;
   vw->save_dia = NULL;
   vw->save_img_dia = NULL;
   vw->save_img_dir_dia = NULL;
 
   vw->open_dia = NULL;
   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();
 }
 
 }
 
-VikWindow *vik_window_new ()
+static VikWindow *window_new ()
 {
   return VIK_WINDOW ( g_object_new ( VIK_WINDOW_TYPE, NULL ) );
 }
 
 {
   return VIK_WINDOW ( g_object_new ( VIK_WINDOW_TYPE, NULL ) );
 }
 
+/**
+ * Update the displayed map
+ *  Only update the top most visible map layer
+ *  ATM this assumes (as per defaults) the top most map has full alpha setting
+ *   such that other other maps even though they may be active will not be seen
+ *  It's more complicated to work out which maps are actually visible due to alpha settings
+ *   and overkill for this simple refresh method.
+ */
+static void simple_map_update ( VikWindow *vw, gboolean only_new )
+{
+  // Find the most relevent single map layer to operate on
+  VikLayer *vl = vik_aggregate_layer_get_top_visible_layer_of_type (vik_layers_panel_get_top_layer(vw->viking_vlp), VIK_LAYER_MAPS);
+  if ( vl )
+       vik_maps_layer_download ( VIK_MAPS_LAYER(vl), vw->viking_vvp, only_new );
+}
+
+/**
+ * This is the global key press handler
+ *  Global shortcuts are available at any time and hence are not restricted to when a certain tool is enabled
+ */
 static gboolean key_press_event( VikWindow *vw, GdkEventKey *event, gpointer data )
 {
 static gboolean key_press_event( VikWindow *vw, GdkEventKey *event, gpointer data )
 {
+  // The keys handled here are not in the menuing system for a couple of reasons:
+  //  . Keeps the menu size compact (alebit at expense of discoverably)
+  //  . Allows differing key bindings to perform the same actions
+
+  // First decide if key events are related to the maps layer
+  gboolean map_download = FALSE;
+  gboolean map_download_only_new = TRUE; // Only new or reload
+
+  GdkModifierType modifiers = gtk_accelerator_get_default_mod_mask();
+
+  // Standard 'Refresh' keys: F5 or Ctrl+r
+  // Note 'F5' is actually handled via draw_refresh_cb() later on
+  //  (not 'R' it's 'r' notice the case difference!!)
+  if ( event->keyval == GDK_r && (event->state & modifiers) == GDK_CONTROL_MASK ) {
+       map_download = TRUE;
+       map_download_only_new = TRUE;
+  }
+  // Full cache reload with Ctrl+F5 or Ctrl+Shift+r [This is not in the menu system]
+  // Note the use of uppercase R here since shift key has been pressed
+  else if ( (event->keyval == GDK_F5 && (event->state & modifiers) == GDK_CONTROL_MASK ) ||
+           ( event->keyval == GDK_R && (event->state & modifiers) == (GDK_CONTROL_MASK + GDK_SHIFT_MASK) ) ) {
+       map_download = TRUE;
+       map_download_only_new = FALSE;
+  }
+
+  if ( map_download ) {
+    simple_map_update ( vw, map_download_only_new );
+  }
+
   VikLayer *vl = vik_layers_panel_get_selected ( vw->viking_vlp );
   if (vl && vw->vt->active_tool != -1 && vw->vt->tools[vw->vt->active_tool].ti.key_press ) {
     gint ltype = vw->vt->tools[vw->vt->active_tool].layer_type;
   VikLayer *vl = vik_layers_panel_get_selected ( vw->viking_vlp );
   if (vl && vw->vt->active_tool != -1 && vw->vt->tools[vw->vt->active_tool].ti.key_press ) {
     gint ltype = vw->vt->tools[vw->vt->active_tool].layer_type;
@@ -381,9 +605,12 @@ static gboolean key_press_event( VikWindow *vw, GdkEventKey *event, gpointer dat
       return vw->vt->tools[vw->vt->active_tool].ti.key_press(vl, event, vw->vt->tools[vw->vt->active_tool].state);
   }
 
       return vw->vt->tools[vw->vt->active_tool].ti.key_press(vl, event, vw->vt->tools[vw->vt->active_tool].state);
   }
 
-  // No layer - but enable window tool keypress processing - these should be able to handle a NULL layer
-  if ( vw->vt->tools[vw->vt->active_tool].ti.key_press ) {
-    return vw->vt->tools[vw->vt->active_tool].ti.key_press ( vl, event, vw->vt->tools[vw->vt->active_tool].state );
+  // Ensure called only on window tools (i.e. not on any of the Layer tools since the layer is NULL)
+  if ( vw->current_tool < TOOL_LAYER ) {
+    // No layer - but enable window tool keypress processing - these should be able to handle a NULL layer
+    if ( vw->vt->tools[vw->vt->active_tool].ti.key_press ) {
+      return vw->vt->tools[vw->vt->active_tool].ti.key_press ( vl, event, vw->vt->tools[vw->vt->active_tool].state );
+    }
   }
 
   /* Restore Main Menu via Escape key if the user has hidden it */
   }
 
   /* Restore Main Menu via Escape key if the user has hidden it */
@@ -416,7 +643,7 @@ static gboolean delete_event( VikWindow *vw )
       _("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."),
       _("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 ) )
     {
     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 ) )
     {
@@ -444,7 +671,19 @@ static void draw_sync ( VikWindow *vw )
 {
   vik_viewport_sync(vw->viking_vvp);
   draw_status ( vw );
 {
   vik_viewport_sync(vw->viking_vvp);
   draw_status ( vw );
-  /* other things may be necc here later. */
+}
+
+/*
+ * Split the status update, as sometimes only need to update the tool part
+ *  also on initialization the zoom related stuff is not ready to be used
+ */
+static void draw_status_tool ( VikWindow *vw )
+{
+  if ( vw->current_tool == TOOL_LAYER )
+    // Use tooltip rather than the internal name as the tooltip is i8n
+    vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_TOOL, vik_layer_get_interface(vw->tool_layer_id)->tools[vw->tool_tool_id].radioActionEntry.tooltip );
+  else
+    vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_TOOL, _(tool_names[vw->current_tool]) );
 }
 
 static void draw_status ( VikWindow *vw )
 }
 
 static void draw_status ( VikWindow *vw )
@@ -461,12 +700,10 @@ static void draw_status ( VikWindow *vw )
     else
       /* xmpp should be a whole number so don't show useless .000 bit */
       g_snprintf ( zoom_level, 22, "%d %s", (int)xmpp, unit );
     else
       /* xmpp should be a whole number so don't show useless .000 bit */
       g_snprintf ( zoom_level, 22, "%d %s", (int)xmpp, unit );
-  if ( vw->current_tool == TOOL_LAYER )
-    vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_TOOL, vik_layer_get_interface(vw->tool_layer_id)->tools[vw->tool_tool_id].name );
-  else
-    vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_TOOL, _(tool_names[vw->current_tool]) );
 
   vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_ZOOM, zoom_level );
 
   vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_ZOOM, zoom_level );
+
+  draw_status_tool ( vw );  
 }
 
 void vik_window_set_redraw_trigger(VikLayer *vl)
 }
 
 void vik_window_set_redraw_trigger(VikLayer *vl)
@@ -549,6 +786,9 @@ static void draw_click (VikWindow *vw, GdkEventButton *event)
    * for panning and zooming; tools only get left/right/movement 
    */
   if ( event->button == 2) {
    * for panning and zooming; tools only get left/right/movement 
    */
   if ( event->button == 2) {
+    if ( vw->vt->tools[vw->vt->active_tool].ti.pan_handler )
+      // Tool still may need to do something (such as disable something)
+      toolbox_click(vw->vt, event);
     vik_window_pan_click ( vw, event );
   } 
   else {
     vik_window_pan_click ( vw, event );
   } 
   else {
@@ -591,8 +831,21 @@ static void draw_mouse_motion (VikWindow *vw, GdkEventMotion *event)
 
   vik_viewport_screen_to_coord ( vw->viking_vvp, event->x, event->y, &coord );
   vik_coord_to_utm ( &coord, &utm );
 
   vik_viewport_screen_to_coord ( vw->viking_vvp, event->x, event->y, &coord );
   vik_coord_to_utm ( &coord, &utm );
-  a_coords_utm_to_latlon ( &utm, &ll );
-  a_coords_latlon_to_string ( &ll, &lat, &lon );
+
+  if ( vik_viewport_get_drawmode ( vw->viking_vvp ) == VIK_VIEWPORT_DRAWMODE_UTM ) {
+    // Reuse lat for the first part (Zone + N or S, and lon for the second part (easting and northing) of a UTM format:
+    //  ZONE[N|S] EASTING NORTHING
+    lat = g_malloc(4*sizeof(gchar));
+    // NB zone is stored in a char but is an actual number
+    g_snprintf (lat, 4, "%d%c", utm.zone, utm.letter);
+    lon = g_malloc(16*sizeof(gchar));
+    g_snprintf (lon, 16, "%d %d", (gint)utm.easting, (gint)utm.northing);
+  }
+  else {
+    a_coords_utm_to_latlon ( &utm, &ll );
+    a_coords_latlon_to_string ( &ll, &lat, &lon );
+  }
+
   /* Change interpolate method according to scale */
   zoom = vik_viewport_get_zoom(vw->viking_vvp);
   if (zoom > 2.0)
   /* Change interpolate method according to scale */
   zoom = vik_viewport_get_zoom(vw->viking_vvp);
   if (zoom > 2.0)
@@ -641,7 +894,10 @@ static void draw_release ( VikWindow *vw, GdkEventButton *event )
   gtk_widget_grab_focus ( GTK_WIDGET(vw->viking_vvp) );
 
   if ( event->button == 2 ) {  /* move / pan */
   gtk_widget_grab_focus ( GTK_WIDGET(vw->viking_vvp) );
 
   if ( event->button == 2 ) {  /* move / pan */
-    vik_window_pan_release(vw, event);
+    if ( vw->vt->tools[vw->vt->active_tool].ti.pan_handler )
+      // Tool still may need to do something (such as reenable something)
+      toolbox_release(vw->vt, event);
+    vik_window_pan_release ( vw, event );
   }
   else {
     toolbox_release(vw->vt, event);
   }
   else {
     toolbox_release(vw->vt, event);
@@ -664,7 +920,13 @@ static void draw_scroll (VikWindow *vw, GdkEventScroll *event)
     else
       vik_viewport_set_center_screen ( vw->viking_vvp, vik_viewport_get_width(vw->viking_vvp)*2/3, vik_viewport_get_height(vw->viking_vvp)/2 );
   } else if ( modifiers == (GDK_CONTROL_MASK | GDK_SHIFT_MASK) ) {
     else
       vik_viewport_set_center_screen ( vw->viking_vvp, vik_viewport_get_width(vw->viking_vvp)*2/3, vik_viewport_get_height(vw->viking_vvp)/2 );
   } else if ( modifiers == (GDK_CONTROL_MASK | GDK_SHIFT_MASK) ) {
-    /* control+shift == make sure mouse is still over the same point on the map when we zoom */
+    // This zoom is on the center position
+    if ( event->direction == GDK_SCROLL_UP )
+      vik_viewport_zoom_in (vw->viking_vvp);
+    else
+      vik_viewport_zoom_out (vw->viking_vvp);
+  } else {
+    /* make sure mouse is still over the same point on the map when we zoom */
     VikCoord coord;
     gint x, y;
     gint center_x = vik_viewport_get_width ( vw->viking_vvp ) / 2;
     VikCoord coord;
     gint x, y;
     gint center_x = vik_viewport_get_width ( vw->viking_vvp ) / 2;
@@ -677,11 +939,6 @@ static void draw_scroll (VikWindow *vw, GdkEventScroll *event)
     vik_viewport_coord_to_screen ( vw->viking_vvp, &coord, &x, &y );
     vik_viewport_set_center_screen ( vw->viking_vvp, center_x + (x - event->x),
                                      center_y + (y - event->y) );
     vik_viewport_coord_to_screen ( vw->viking_vvp, &coord, &x, &y );
     vik_viewport_set_center_screen ( vw->viking_vvp, center_x + (x - event->x),
                                      center_y + (y - event->y) );
-  } else {
-    if ( event->direction == GDK_SCROLL_UP )
-      vik_viewport_zoom_in (vw->viking_vvp);
-    else
-      vik_viewport_zoom_out (vw->viking_vvp);
   }
 
   draw_update(vw);
   }
 
   draw_update(vw);
@@ -694,7 +951,6 @@ static void draw_scroll (VikWindow *vw, GdkEventScroll *event)
  ********************************************************************************/
 static void draw_ruler(VikViewport *vvp, GdkDrawable *d, GdkGC *gc, gint x1, gint y1, gint x2, gint y2, gdouble distance)
 {
  ********************************************************************************/
 static void draw_ruler(VikViewport *vvp, GdkDrawable *d, GdkGC *gc, gint x1, gint y1, gint x2, gint y2, gdouble distance)
 {
-  PangoFontDescription *pfd;
   PangoLayout *pl;
   gchar str[128];
   GdkGC *labgc = vik_viewport_new_gc ( vvp, "#cccccc", 1);
   PangoLayout *pl;
   gchar str[128];
   GdkGC *labgc = vik_viewport_new_gc ( vvp, "#cccccc", 1);
@@ -703,8 +959,8 @@ static void draw_ruler(VikViewport *vvp, GdkDrawable *d, GdkGC *gc, gint x1, gin
   gdouble len = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
   gdouble dx = (x2-x1)/len*10; 
   gdouble dy = (y2-y1)/len*10;
   gdouble len = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
   gdouble dx = (x2-x1)/len*10; 
   gdouble dy = (y2-y1)/len*10;
-  gdouble c = cos(15.0 * M_PI/180.0);
-  gdouble s = sin(15.0 * M_PI/180.0);
+  gdouble c = cos(DEG2RAD(15.0));
+  gdouble s = sin(DEG2RAD(15.0));
   gdouble angle;
   gdouble baseangle = 0;
   gint i;
   gdouble angle;
   gdouble baseangle = 0;
   gint i;
@@ -729,29 +985,8 @@ static void draw_ruler(VikViewport *vvp, GdkDrawable *d, GdkGC *gc, gint x1, gin
   /* draw compass */
 #define CR 80
 #define CW 4
   /* 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;
 
   {
     GdkColor color;
@@ -760,14 +995,14 @@ static void draw_ruler(VikViewport *vvp, GdkDrawable *d, GdkGC *gc, gint x1, gin
     gdk_color_parse("#2255cc", &color);
     gdk_gc_set_rgb_fg_color(thickgc, &color);
   }
     gdk_color_parse("#2255cc", &color);
     gdk_gc_set_rgb_fg_color(thickgc, &color);
   }
-  gdk_draw_arc (d, thickgc, FALSE, x1-CR+CW/2, y1-CR+CW/2, 2*CR-CW, 2*CR-CW, (90 - baseangle*180/M_PI)*64, -angle*180/M_PI*64);
+  gdk_draw_arc (d, thickgc, FALSE, x1-CR+CW/2, y1-CR+CW/2, 2*CR-CW, 2*CR-CW, (90 - RAD2DEG(baseangle))*64, -RAD2DEG(angle)*64);
 
 
   gdk_gc_copy(thickgc, gc);
   gdk_gc_set_line_attributes(thickgc, 2, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
   for (i=0; i<180; i++) {
 
 
   gdk_gc_copy(thickgc, gc);
   gdk_gc_set_line_attributes(thickgc, 2, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
   for (i=0; i<180; i++) {
-    c = cos(i*M_PI/90.0 + baseangle);
-    s = sin(i*M_PI/90.0 + baseangle);
+    c = cos(DEG2RAD(i)*2 + baseangle);
+    s = sin(DEG2RAD(i)*2 + baseangle);
 
     if (i%5) {
       gdk_draw_line (d, gc, x1 + CR*c, y1 + CR*s, x1 + (CR+CW)*c, y1 + (CR+CW)*s);
 
     if (i%5) {
       gdk_draw_line (d, gc, x1 + CR*c, y1 + CR*s, x1 + (CR+CW)*c, y1 + (CR+CW)*s);
@@ -795,11 +1030,7 @@ static void draw_ruler(VikViewport *vvp, GdkDrawable *d, GdkGC *gc, gint x1, gin
     gint wb, hb, xb, yb;
 
     pl = gtk_widget_create_pango_layout (GTK_WIDGET(vvp), NULL);
     gint wb, hb, xb, yb;
 
     pl = gtk_widget_create_pango_layout (GTK_WIDGET(vvp), NULL);
-
-    pfd = pango_font_description_from_string ("Sans 8"); // FIXME: settable option? global variable?
-    pango_layout_set_font_description (pl, pfd);
-    pango_font_description_free (pfd);
-
+    pango_layout_set_font_description (pl, gtk_widget_get_style(GTK_WIDGET(vvp))->font_desc);
     pango_layout_set_text(pl, "N", -1);
     gdk_draw_layout(d, gc, x1-5, y1-CR-3*CW-8, pl);
 
     pango_layout_set_text(pl, "N", -1);
     gdk_draw_layout(d, gc, x1-5, y1-CR-3*CW-8, pl);
 
@@ -847,7 +1078,7 @@ static void draw_ruler(VikViewport *vvp, GdkDrawable *d, GdkGC *gc, gint x1, gin
     LABEL(xd, yd, wd, hd);
 
     /* draw label with bearing */
     LABEL(xd, yd, wd, hd);
 
     /* draw label with bearing */
-    g_sprintf(str, "%3.1f°", angle*180.0/M_PI);
+    g_sprintf(str, "%3.1f°", RAD2DEG(angle));
     pango_layout_set_text(pl, str, -1);
     pango_layout_get_pixel_size ( pl, &wb, &hb );
     xb = x1 + CR*cos(angle-M_PI_2);
     pango_layout_set_text(pl, str, -1);
     pango_layout_get_pixel_size ( pl, &wb, &hb );
     xb = x1 + CR*cos(angle-M_PI_2);
@@ -965,13 +1196,13 @@ static VikLayerToolFuncStatus ruler_move (VikLayer *vl, GdkEventMotion *event, r
     vik_coord_to_latlon ( &coord, &ll );
     vik_viewport_coord_to_screen ( vvp, &s->oldcoord, &oldx, &oldy );
 
     vik_coord_to_latlon ( &coord, &ll );
     vik_viewport_coord_to_screen ( vvp, &s->oldcoord, &oldx, &oldy );
 
-    gdk_draw_drawable (buf, GTK_WIDGET(vvp)->style->black_gc, 
+    gdk_draw_drawable (buf, gtk_widget_get_style(GTK_WIDGET(vvp))->black_gc,
                       vik_viewport_get_pixmap(vvp), 0, 0, 0, 0, -1, -1);
                       vik_viewport_get_pixmap(vvp), 0, 0, 0, 0, -1, -1);
-    draw_ruler(vvp, buf, GTK_WIDGET(vvp)->style->black_gc, oldx, oldy, event->x, event->y, vik_coord_diff( &coord, &(s->oldcoord)) );
+    draw_ruler(vvp, buf, gtk_widget_get_style(GTK_WIDGET(vvp))->black_gc, oldx, oldy, event->x, event->y, vik_coord_diff( &coord, &(s->oldcoord)) );
     if (draw_buf_done) {
       static gpointer pass_along[3];
       pass_along[0] = GTK_WIDGET(vvp)->window;
     if (draw_buf_done) {
       static gpointer pass_along[3];
       pass_along[0] = GTK_WIDGET(vvp)->window;
-      pass_along[1] = GTK_WIDGET(vvp)->style->black_gc;
+      pass_along[1] = gtk_widget_get_style(GTK_WIDGET(vvp))->black_gc;
       pass_along[2] = buf;
       g_idle_add_full (G_PRIORITY_HIGH_IDLE + 10, draw_buf, pass_along, NULL);
       draw_buf_done = FALSE;
       pass_along[2] = buf;
       g_idle_add_full (G_PRIORITY_HIGH_IDLE + 10, draw_buf, pass_along, NULL);
       draw_buf_done = FALSE;
@@ -1012,11 +1243,13 @@ static gboolean ruler_key_press (VikLayer *vl, GdkEventKey *event, ruler_tool_st
     ruler_deactivate ( vl, s );
     return TRUE;
   }
     ruler_deactivate ( vl, s );
     return TRUE;
   }
+  // Regardless of whether we used it, return false so other GTK things may use it
   return FALSE;
 }
 
   return FALSE;
 }
 
-static VikToolInterface ruler_tool = 
-  { "Ruler", 
+static VikToolInterface ruler_tool =
+  // NB Ctrl+Shift+R is used for Refresh (deemed more important), so use 'U' instead
+  { { "Ruler", "vik-icon-ruler", N_("_Ruler"), "<control><shift>U", N_("Ruler Tool"), 2 },
     (VikToolConstructorFunc) ruler_create,
     (VikToolDestructorFunc) ruler_destroy,
     (VikToolActivationFunc) NULL,
     (VikToolConstructorFunc) ruler_create,
     (VikToolDestructorFunc) ruler_destroy,
     (VikToolActivationFunc) NULL,
@@ -1025,6 +1258,7 @@ static VikToolInterface ruler_tool =
     (VikToolMouseMoveFunc) ruler_move, 
     (VikToolMouseFunc) ruler_release,
     (VikToolKeyFunc) ruler_key_press,
     (VikToolMouseMoveFunc) ruler_move, 
     (VikToolMouseFunc) ruler_release,
     (VikToolKeyFunc) ruler_key_press,
+    FALSE,
     GDK_CURSOR_IS_PIXMAP,
     &cursor_ruler_pixbuf };
 /*** end ruler code ********************************************************/
     GDK_CURSOR_IS_PIXMAP,
     &cursor_ruler_pixbuf };
 /*** end ruler code ********************************************************/
@@ -1034,43 +1268,245 @@ static VikToolInterface ruler_tool =
 /********************************************************************************
  ** Zoom tool code
  ********************************************************************************/
 /********************************************************************************
  ** Zoom tool code
  ********************************************************************************/
+
+typedef struct {
+  VikWindow *vw;
+  GdkPixmap *pixmap;
+  // Track zoom bounds for zoom tool with shift modifier:
+  gboolean bounds_active;
+  gint start_x;
+  gint start_y;
+} zoom_tool_state_t;
+
+/*
+ * In case the screen size has changed
+ */
+static void zoomtool_resize_pixmap (zoom_tool_state_t *zts)
+{
+    int w1, h1, w2, h2;
+
+    // Allocate a drawing area the size of the viewport
+    w1 = vik_viewport_get_width ( zts->vw->viking_vvp );
+    h1 = vik_viewport_get_height ( zts->vw->viking_vvp );
+
+    if ( !zts->pixmap ) {
+      // Totally new
+      zts->pixmap = gdk_pixmap_new ( GTK_WIDGET(zts->vw->viking_vvp)->window, w1, h1, -1 );
+    }
+
+    gdk_drawable_get_size ( zts->pixmap, &w2, &h2 );
+
+    if ( w1 != w2 || h1 != h2 ) {
+      // Has changed - delete and recreate with new values
+      g_object_unref ( G_OBJECT ( zts->pixmap ) );
+      zts->pixmap = gdk_pixmap_new ( GTK_WIDGET(zts->vw->viking_vvp)->window, w1, h1, -1 );
+    }
+}
+
 static gpointer zoomtool_create (VikWindow *vw, VikViewport *vvp)
 {
 static gpointer zoomtool_create (VikWindow *vw, VikViewport *vvp)
 {
-  return vw;
+  zoom_tool_state_t *zts = g_new(zoom_tool_state_t, 1);
+  zts->vw = vw;
+  zts->pixmap = NULL;
+  zts->start_x = 0;
+  zts->start_y = 0;
+  zts->bounds_active = FALSE;
+  return zts;
 }
 
 }
 
-static VikLayerToolFuncStatus zoomtool_click (VikLayer *vl, GdkEventButton *event, VikWindow *vw)
+static void zoomtool_destroy ( zoom_tool_state_t *zts)
 {
 {
-  vw->modified = TRUE;
-  vik_viewport_set_center_screen ( vw->viking_vvp, (gint) event->x, (gint) event->y );
-  if ( event->button == 1 )
-    vik_viewport_zoom_in (vw->viking_vvp);
-  else if ( event->button == 3 )
-    vik_viewport_zoom_out (vw->viking_vvp);
-  draw_update ( vw );
+  if ( zts->pixmap )
+    g_object_unref ( G_OBJECT ( zts->pixmap ) );
+  g_free(zts);
+}
+
+static VikLayerToolFuncStatus zoomtool_click (VikLayer *vl, GdkEventButton *event, zoom_tool_state_t *zts)
+{
+  zts->vw->modified = TRUE;
+  guint modifiers = event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK);
+
+  VikCoord coord;
+  gint x, y;
+  gint center_x = vik_viewport_get_width ( zts->vw->viking_vvp ) / 2;
+  gint center_y = vik_viewport_get_height ( zts->vw->viking_vvp ) / 2;
+
+  gboolean skip_update = FALSE;
+
+  zts->bounds_active = FALSE;
+
+  if ( modifiers == (GDK_CONTROL_MASK | GDK_SHIFT_MASK) ) {
+    // This zoom is on the center position
+    vik_viewport_set_center_screen ( zts->vw->viking_vvp, center_x, center_y );
+    if ( event->button == 1 )
+      vik_viewport_zoom_in (zts->vw->viking_vvp);
+    else if ( event->button == 3 )
+      vik_viewport_zoom_out (zts->vw->viking_vvp);
+  }
+  else if ( modifiers == GDK_CONTROL_MASK ) {
+    // This zoom is to recenter on the mouse position
+    vik_viewport_set_center_screen ( zts->vw->viking_vvp, (gint) event->x, (gint) event->y );
+    if ( event->button == 1 )
+      vik_viewport_zoom_in (zts->vw->viking_vvp);
+    else if ( event->button == 3 )
+      vik_viewport_zoom_out (zts->vw->viking_vvp);
+  }
+  else if ( modifiers == GDK_SHIFT_MASK ) {
+    // Get start of new zoom bounds
+    if ( event->button == 1 ) {
+      zts->bounds_active = TRUE;
+      zts->start_x = (gint) event->x;
+      zts->start_y = (gint) event->y;
+      skip_update = TRUE;
+    }
+  }
+  else {
+    /* make sure mouse is still over the same point on the map when we zoom */
+    vik_viewport_screen_to_coord ( zts->vw->viking_vvp, event->x, event->y, &coord );
+    if ( event->button == 1 )
+      vik_viewport_zoom_in (zts->vw->viking_vvp);
+    else if ( event->button == 3 )
+      vik_viewport_zoom_out(zts->vw->viking_vvp);
+    vik_viewport_coord_to_screen ( zts->vw->viking_vvp, &coord, &x, &y );
+    vik_viewport_set_center_screen ( zts->vw->viking_vvp,
+                                     center_x + (x - event->x),
+                                     center_y + (y - event->y) );
+  }
+
+  if ( !skip_update )
+    draw_update ( zts->vw );
+
   return VIK_LAYER_TOOL_ACK;
 }
 
   return VIK_LAYER_TOOL_ACK;
 }
 
-static VikLayerToolFuncStatus zoomtool_move (VikLayer *vl, GdkEventMotion *event, VikViewport *vvp)
+static VikLayerToolFuncStatus zoomtool_move (VikLayer *vl, GdkEventMotion *event, zoom_tool_state_t *zts)
 {
 {
+  guint modifiers = event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK);
+
+  if ( zts->bounds_active && modifiers == GDK_SHIFT_MASK ) {
+    zoomtool_resize_pixmap ( zts );
+
+    // Blank out currently drawn area
+    gdk_draw_drawable ( zts->pixmap,
+                        gtk_widget_get_style(GTK_WIDGET(zts->vw->viking_vvp))->black_gc,
+                        vik_viewport_get_pixmap(zts->vw->viking_vvp),
+                        0, 0, 0, 0, -1, -1);
+
+    // Calculate new box starting point & size in pixels
+    int xx, yy, width, height;
+    if ( event->y > zts->start_y ) {
+      yy = zts->start_y;
+      height = event->y-zts->start_y;
+    }
+    else {
+      yy = event->y;
+      height = zts->start_y-event->y;
+    }
+    if ( event->x > zts->start_x ) {
+      xx = zts->start_x;
+      width = event->x-zts->start_x;
+    }
+    else {
+      xx = event->x;
+      width = zts->start_x-event->x;
+    }
+
+    // Draw the box
+    gdk_draw_rectangle (zts->pixmap, gtk_widget_get_style(GTK_WIDGET(zts->vw->viking_vvp))->black_gc, FALSE, xx, yy, width, height);
+
+    // Only actually draw when there's time to do so
+    if (draw_buf_done) {
+      static gpointer pass_along[3];
+      pass_along[0] = GTK_WIDGET(zts->vw->viking_vvp)->window;
+      pass_along[1] = gtk_widget_get_style(GTK_WIDGET(zts->vw->viking_vvp))->black_gc;
+      pass_along[2] = zts->pixmap;
+      g_idle_add_full (G_PRIORITY_HIGH_IDLE + 10, draw_buf, pass_along, NULL);
+      draw_buf_done = FALSE;
+    }
+  }
   return VIK_LAYER_TOOL_ACK;
 }
 
   return VIK_LAYER_TOOL_ACK;
 }
 
-static VikLayerToolFuncStatus zoomtool_release (VikLayer *vl, GdkEventButton *event, VikViewport *vvp)
+static VikLayerToolFuncStatus zoomtool_release (VikLayer *vl, GdkEventButton *event, zoom_tool_state_t *zts)
 {
 {
+  guint modifiers = event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK);
+
+  zts->bounds_active = FALSE;
+
+  // Ensure haven't just released on the exact same position
+  //  i.e. probably haven't moved the mouse at all
+  if ( modifiers == GDK_SHIFT_MASK && !( ( event->x == zts->start_x ) && ( event->y == zts->start_y )) ) {
+
+    VikCoord coord1, coord2;
+    vik_viewport_screen_to_coord ( zts->vw->viking_vvp, zts->start_x, zts->start_y, &coord1);
+    vik_viewport_screen_to_coord ( zts->vw->viking_vvp, event->x, event->y, &coord2);
+
+    // From the extend of the bounds pick the best zoom level
+    // c.f. trw_layer_zoom_to_show_latlons()
+    // Maybe refactor...
+    struct LatLon ll1, ll2;
+    vik_coord_to_latlon(&coord1, &ll1);
+    vik_coord_to_latlon(&coord2, &ll2);
+    struct LatLon average = { (ll1.lat+ll2.lat)/2,
+                             (ll1.lon+ll2.lon)/2 };
+
+    VikCoord new_center;
+    vik_coord_load_from_latlon ( &new_center, vik_viewport_get_coord_mode ( zts->vw->viking_vvp ), &average );
+    vik_viewport_set_center_coord ( zts->vw->viking_vvp, &new_center );
+
+    /* Convert into definite 'smallest' and 'largest' positions */
+    struct LatLon minmin;
+    if ( ll1.lat < ll2.lat )
+      minmin.lat = ll1.lat;
+    else
+      minmin.lat = ll2.lat;
+
+    struct LatLon maxmax;
+    if ( ll1.lon > ll2.lon )
+      maxmax.lon = ll1.lon;
+    else
+      maxmax.lon = ll2.lon;
+
+    /* Always recalculate the 'best' zoom level */
+    gdouble zoom = VIK_VIEWPORT_MIN_ZOOM;
+    vik_viewport_set_zoom ( zts->vw->viking_vvp, zoom );
+
+    gdouble min_lat, max_lat, min_lon, max_lon;
+    /* Should only be a maximum of about 18 iterations from min to max zoom levels */
+    while ( zoom <= VIK_VIEWPORT_MAX_ZOOM ) {
+      vik_viewport_get_min_max_lat_lon ( zts->vw->viking_vvp, &min_lat, &max_lat, &min_lon, &max_lon );
+      /* NB I think the logic used in this test to determine if the bounds is within view
+        fails if track goes across 180 degrees longitude.
+        Hopefully that situation is not too common...
+        Mind you viking doesn't really do edge locations to well anyway */
+      if ( min_lat < minmin.lat &&
+           max_lat > minmin.lat &&
+           min_lon < maxmax.lon &&
+           max_lon > maxmax.lon )
+       /* Found within zoom level */
+       break;
+
+      /* Try next */
+      zoom = zoom * 2;
+      vik_viewport_set_zoom ( zts->vw->viking_vvp, zoom );
+    }
+
+    draw_update ( zts->vw );
+  }
   return VIK_LAYER_TOOL_ACK;
 }
 
 static VikToolInterface zoom_tool = 
   return VIK_LAYER_TOOL_ACK;
 }
 
 static VikToolInterface zoom_tool = 
-  { "Zoom", 
+  { { "Zoom", "vik-icon-zoom", N_("_Zoom"), "<control><shift>Z", N_("Zoom Tool"), 1 },
     (VikToolConstructorFunc) zoomtool_create,
     (VikToolConstructorFunc) zoomtool_create,
-    (VikToolDestructorFunc) NULL,
+    (VikToolDestructorFunc) zoomtool_destroy,
     (VikToolActivationFunc) NULL,
     (VikToolActivationFunc) NULL,
     (VikToolMouseFunc) zoomtool_click, 
     (VikToolMouseMoveFunc) zoomtool_move,
     (VikToolMouseFunc) zoomtool_release,
     NULL,
     (VikToolActivationFunc) NULL,
     (VikToolActivationFunc) NULL,
     (VikToolMouseFunc) zoomtool_click, 
     (VikToolMouseMoveFunc) zoomtool_move,
     (VikToolMouseFunc) zoomtool_release,
     NULL,
+    FALSE,
     GDK_CURSOR_IS_PIXMAP,
     &cursor_zoom_pixbuf };
 /*** end zoom code ********************************************************/
     GDK_CURSOR_IS_PIXMAP,
     &cursor_zoom_pixbuf };
 /*** end zoom code ********************************************************/
@@ -1106,7 +1542,7 @@ static VikLayerToolFuncStatus pantool_release (VikLayer *vl, GdkEventButton *eve
 }
 
 static VikToolInterface pan_tool = 
 }
 
 static VikToolInterface pan_tool = 
-  { "Pan", 
+  { { "Pan", "vik-icon-pan", N_("_Pan"), "<control><shift>P", N_("Pan Tool"), 0 },
     (VikToolConstructorFunc) pantool_create,
     (VikToolDestructorFunc) NULL,
     (VikToolActivationFunc) NULL,
     (VikToolConstructorFunc) pantool_create,
     (VikToolDestructorFunc) NULL,
     (VikToolActivationFunc) NULL,
@@ -1115,6 +1551,7 @@ static VikToolInterface pan_tool =
     (VikToolMouseMoveFunc) pantool_move,
     (VikToolMouseFunc) pantool_release,
     NULL,
     (VikToolMouseMoveFunc) pantool_move,
     (VikToolMouseFunc) pantool_release,
     NULL,
+    FALSE,
     GDK_FLEUR };
 /*** end pan code ********************************************************/
 
     GDK_FLEUR };
 /*** end pan code ********************************************************/
 
@@ -1189,7 +1626,7 @@ static VikLayerToolFuncStatus selecttool_click (VikLayer *vl, GdkEventButton *ev
   else if ( ( event->button == 3 ) && ( vl && ( vl->type == VIK_LAYER_TRW ) ) ) {
     if ( vl->visible )
       /* Act on currently selected item to show menu */
   else if ( ( event->button == 3 ) && ( vl && ( vl->type == VIK_LAYER_TRW ) ) ) {
     if ( vl->visible )
       /* Act on currently selected item to show menu */
-      if ( ( t->vw->selected_track || t->vw->selected_waypoint ) && t->vw->selected_name )
+      if ( t->vw->selected_track || t->vw->selected_waypoint )
        if ( vik_layer_get_interface(vl->type)->show_viewport_menu )
          vik_layer_get_interface(vl->type)->show_viewport_menu ( vl, event, t->vw->viking_vvp );
   }
        if ( vik_layer_get_interface(vl->type)->show_viewport_menu )
          vik_layer_get_interface(vl->type)->show_viewport_menu ( vl, event, t->vw->viking_vvp );
   }
@@ -1222,7 +1659,7 @@ static VikLayerToolFuncStatus selecttool_release (VikLayer *vl, GdkEventButton *
 }
 
 static VikToolInterface select_tool =
 }
 
 static VikToolInterface select_tool =
-  { "Select",
+  { { "Select", "vik-icon-select", N_("_Select"), "<control><shift>S", N_("Select Tool"), 3 },
     (VikToolConstructorFunc) selecttool_create,
     (VikToolDestructorFunc) selecttool_destroy,
     (VikToolActivationFunc) NULL,
     (VikToolConstructorFunc) selecttool_create,
     (VikToolDestructorFunc) selecttool_destroy,
     (VikToolActivationFunc) NULL,
@@ -1231,6 +1668,7 @@ static VikToolInterface select_tool =
     (VikToolMouseMoveFunc) selecttool_move,
     (VikToolMouseFunc) selecttool_release,
     (VikToolKeyFunc) NULL,
     (VikToolMouseMoveFunc) selecttool_move,
     (VikToolMouseFunc) selecttool_release,
     (VikToolKeyFunc) NULL,
+    FALSE,
     GDK_LEFT_PTR,
     NULL,
     NULL };
     GDK_LEFT_PTR,
     NULL,
     NULL };
@@ -1293,7 +1731,7 @@ static void draw_zoom_cb ( GtkAction *a, VikWindow *vw )
   draw_update ( vw );
 }
 
   draw_update ( vw );
 }
 
-void draw_goto_cb ( GtkAction *a, VikWindow *vw )
+static void draw_goto_cb ( GtkAction *a, VikWindow *vw )
 {
   VikCoord new_center;
 
 {
   VikCoord new_center;
 
@@ -1322,14 +1760,23 @@ void draw_goto_cb ( GtkAction *a, VikWindow *vw )
   draw_update ( vw );
 }
 
   draw_update ( vw );
 }
 
+/**
+ * Refresh maps displayed
+ */
+static void draw_refresh_cb ( GtkAction *a, VikWindow *vw )
+{
+  // Only get 'new' maps
+  simple_map_update ( vw, TRUE );
+}
+
 static void menu_addlayer_cb ( GtkAction *a, VikWindow *vw )
 {
 static void menu_addlayer_cb ( GtkAction *a, VikWindow *vw )
 {
 gint type;
VikLayerTypeEnum type;
   for ( type = 0; type < VIK_LAYER_NUM_TYPES; type++ ) {
     if (!strcmp(vik_layer_get_interface(type)->name, gtk_action_get_name(a))) {
       if ( vik_layers_panel_new_layer ( vw->viking_vlp, type ) ) {
   for ( type = 0; type < VIK_LAYER_NUM_TYPES; type++ ) {
     if (!strcmp(vik_layer_get_interface(type)->name, gtk_action_get_name(a))) {
       if ( vik_layers_panel_new_layer ( vw->viking_vlp, type ) ) {
-       draw_update ( vw );
-       vw->modified = TRUE;
+        draw_update ( vw );
+        vw->modified = TRUE;
       }
     }
   }
       }
     }
   }
@@ -1368,8 +1815,19 @@ static void help_help_cb ( GtkAction *a, VikWindow *vw )
 #if GTK_CHECK_VERSION (2, 14, 0)
   gchar *uri;
   uri = g_strdup_printf("ghelp:%s", PACKAGE);
 #if GTK_CHECK_VERSION (2, 14, 0)
   gchar *uri;
   uri = g_strdup_printf("ghelp:%s", PACKAGE);
-  gtk_show_uri(NULL, uri, GDK_CURRENT_TIME, NULL);
+  GError *error = NULL;
+  gboolean show = gtk_show_uri (NULL, uri, GDK_CURRENT_TIME, &error);
+  if ( !show && !error )
+    // No error to show, so unlikely this will get called
+    a_dialog_error_msg ( GTK_WINDOW(vw), _("The help system is not available.") );
+  else if ( error ) {
+    // Main error path
+    a_dialog_error_msg_extra ( GTK_WINDOW(vw), _("Help is not available because: %s.\nEnsure a Mime Type ghelp handler program is installed (e.g. yelp)."), error->message );
+    g_error_free ( error );
+  }
   g_free(uri);
   g_free(uri);
+#else
+  a_dialog_error_msg ( GTK_WINDOW(vw), "Help is not available in this build." ); // Unlikely to happen so not going to bother with I8N
 #endif
 #endif /* WINDOWS */
 }
 #endif
 #endif /* WINDOWS */
 }
@@ -1449,10 +1907,6 @@ static toolbox_tools_t* toolbox_create(VikWindow *vw)
   vt->n_tools = 0;
   vt->active_tool = -1;
   vt->vw = vw;
   vt->n_tools = 0;
   vt->active_tool = -1;
   vt->vw = vw;
-  if (!vw->viking_vvp) {
-    g_critical("no viewport found.");
-    exit(1);
-  }
   return vt;
 }
 
   return vt;
 }
 
@@ -1474,7 +1928,7 @@ static int toolbox_get_tool(toolbox_tools_t *vt, const gchar *tool_name)
 {
   int i;
   for (i=0; i<vt->n_tools; i++) {
 {
   int i;
   for (i=0; i<vt->n_tools; i++) {
-    if (!strcmp(tool_name, vt->tools[i].ti.name)) {
+    if (!strcmp(tool_name, vt->tools[i].ti.radioActionEntry.name)) {
       break;
     }
   }
       break;
     }
   }
@@ -1489,7 +1943,7 @@ static void toolbox_activate(toolbox_tools_t *vt, const gchar *tool_name)
 
   if (tool == vt->n_tools) {
     g_critical("trying to activate a non-existent tool...");
 
   if (tool == vt->n_tools) {
     g_critical("trying to activate a non-existent tool...");
-    exit(1);
+    return;
   }
   /* is the tool already active? */
   if (vt->active_tool == tool) {
   }
   /* is the tool already active? */
   if (vt->active_tool == tool) {
@@ -1559,21 +2013,23 @@ static void toolbox_release (toolbox_tools_t *vt, GdkEventButton *event)
 
 void vik_window_enable_layer_tool ( VikWindow *vw, gint layer_id, gint tool_id )
 {
 
 void vik_window_enable_layer_tool ( VikWindow *vw, gint layer_id, gint tool_id )
 {
-  gtk_action_activate ( gtk_action_group_get_action ( vw->action_group, vik_layer_get_interface(layer_id)->tools[tool_id].name ) );
+  gtk_action_activate ( gtk_action_group_get_action ( vw->action_group, vik_layer_get_interface(layer_id)->tools[tool_id].radioActionEntry.name ) );
 }
 
 /* this function gets called whenever a toolbar tool is clicked */
 static void menu_tool_cb ( GtkAction *old, GtkAction *a, VikWindow *vw )
 {
   /* White Magic, my friends ... White Magic... */
 }
 
 /* this function gets called whenever a toolbar tool is clicked */
 static void menu_tool_cb ( GtkAction *old, GtkAction *a, VikWindow *vw )
 {
   /* White Magic, my friends ... White Magic... */
-  int layer_id, tool_id;
+  gint tool_id;
   const GdkCursor *cursor = NULL;
 
   toolbox_activate(vw->vt, gtk_action_get_name(a));
 
   cursor = toolbox_get_cursor(vw->vt, gtk_action_get_name(a));
   const GdkCursor *cursor = NULL;
 
   toolbox_activate(vw->vt, gtk_action_get_name(a));
 
   cursor = toolbox_get_cursor(vw->vt, gtk_action_get_name(a));
-  /* We set cursor, even if it is NULL: it resets to default */
-  gdk_window_set_cursor ( GTK_WIDGET(vw->viking_vvp)->window, (GdkCursor *)cursor );
+
+  if ( GTK_WIDGET(vw->viking_vvp)->window )
+    /* We set cursor, even if it is NULL: it resets to default */
+    gdk_window_set_cursor ( GTK_WIDGET(vw->viking_vvp)->window, (GdkCursor *)cursor );
 
   if (!strcmp(gtk_action_get_name(a), "Pan")) {
     vw->current_tool = TOOL_PAN;
 
   if (!strcmp(gtk_action_get_name(a), "Pan")) {
     vw->current_tool = TOOL_PAN;
@@ -1589,9 +2045,10 @@ static void menu_tool_cb ( GtkAction *old, GtkAction *a, VikWindow *vw )
   }
   else {
     /* TODO: only enable tools from active layer */
   }
   else {
     /* TODO: only enable tools from active layer */
+    VikLayerTypeEnum layer_id;
     for (layer_id=0; layer_id<VIK_LAYER_NUM_TYPES; layer_id++) {
       for ( tool_id = 0; tool_id < vik_layer_get_interface(layer_id)->tools_count; tool_id++ ) {
     for (layer_id=0; layer_id<VIK_LAYER_NUM_TYPES; layer_id++) {
       for ( tool_id = 0; tool_id < vik_layer_get_interface(layer_id)->tools_count; tool_id++ ) {
-       if (!strcmp(vik_layer_get_interface(layer_id)->tools[tool_id].name, gtk_action_get_name(a))) {
+       if (!strcmp(vik_layer_get_interface(layer_id)->tools[tool_id].radioActionEntry.name, gtk_action_get_name(a))) {
            vw->current_tool = TOOL_LAYER;
            vw->tool_layer_id = layer_id;
            vw->tool_tool_id = tool_id;
            vw->current_tool = TOOL_LAYER;
            vw->tool_layer_id = layer_id;
            vw->tool_tool_id = tool_id;
@@ -1599,7 +2056,7 @@ static void menu_tool_cb ( GtkAction *old, GtkAction *a, VikWindow *vw )
       }
     }
   }
       }
     }
   }
-  draw_status ( vw );
+  draw_status_tool ( vw );
 }
 
 static void window_set_filename ( VikWindow *vw, const gchar *filename )
 }
 
 static void window_set_filename ( VikWindow *vw, const gchar *filename )
@@ -1611,18 +2068,24 @@ static void window_set_filename ( VikWindow *vw, const gchar *filename )
   if ( filename == NULL )
   {
     vw->filename = NULL;
   if ( filename == NULL )
   {
     vw->filename = NULL;
-    file = _("Untitled");
   }
   else
   {
     vw->filename = g_strdup(filename);
   }
   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 );
 }
 
   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;
 GtkWidget *vik_window_get_drawmode_button ( VikWindow *vw, VikViewportDrawMode mode )
 {
   GtkWidget *mode_button;
@@ -1670,12 +2133,15 @@ static void on_activate_recent_item (GtkRecentChooser *chooser,
     g_object_unref ( file );
     if ( self->filename )
     {
     g_object_unref ( file );
     if ( self->filename )
     {
-      gchar *filenames[] = { path, NULL };
+      GSList *filenames = NULL;
+      filenames = g_slist_append ( filenames, path );
       g_signal_emit ( G_OBJECT(self), window_signals[VW_OPENWINDOW_SIGNAL], 0, filenames );
       g_signal_emit ( G_OBJECT(self), window_signals[VW_OPENWINDOW_SIGNAL], 0, filenames );
+      // NB: GSList & contents are freed by main.open_window
     }
     }
-    else
+    else {
       vik_window_open_file ( self, path, TRUE );
       vik_window_open_file ( self, path, TRUE );
-    g_free ( path );
+      g_free ( path );
+    }
   }
 
   g_free (filename);
   }
 
   g_free (filename);
@@ -1743,9 +2209,21 @@ void vik_window_open_file ( VikWindow *vw, const gchar *filename, gboolean chang
     case LOAD_TYPE_GPSBABEL_FAILURE:
       a_dialog_error_msg ( GTK_WINDOW(vw), _("GPSBabel is required to load files of this type or GPSBabel encountered problems.") );
       break;
     case LOAD_TYPE_GPSBABEL_FAILURE:
       a_dialog_error_msg ( GTK_WINDOW(vw), _("GPSBabel is required to load files of this type or GPSBabel encountered problems.") );
       break;
+    case LOAD_TYPE_GPX_FAILURE:
+      a_dialog_error_msg_extra ( GTK_WINDOW(vw), _("Unable to load malformed GPX file %s"), filename );
+      break;
     case LOAD_TYPE_UNSUPPORTED_FAILURE:
       a_dialog_error_msg_extra ( GTK_WINDOW(vw), _("Unsupported file type for %s"), filename );
       break;
     case LOAD_TYPE_UNSUPPORTED_FAILURE:
       a_dialog_error_msg_extra ( GTK_WINDOW(vw), _("Unsupported file type for %s"), filename );
       break;
+    case LOAD_TYPE_VIK_FAILURE_NON_FATAL:
+    {
+      // Since we can process .vik files with issues just show a warning in the status bar
+      // Not that a user can do much about it... or tells them what this issue is yet...
+      gchar *msg = g_strdup_printf (_("WARNING: issues encountered loading %s"), a_file_basename (filename) );
+      vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_INFO, msg );
+      g_free ( msg );
+    }
+      // No break, carry on to show any data
     case LOAD_TYPE_VIK_SUCCESS:
     {
       GtkWidget *mode_button;
     case LOAD_TYPE_VIK_SUCCESS:
     {
       GtkWidget *mode_button;
@@ -1854,11 +2332,28 @@ static void load_file ( GtkAction *a, VikWindow *vw )
     else {
       files = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER(vw->open_dia) );
       gboolean change_fn = newwindow && (g_slist_length(files)==1); /* only change fn if one file */
     else {
       files = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER(vw->open_dia) );
       gboolean change_fn = newwindow && (g_slist_length(files)==1); /* only change fn if one file */
-      
+      gboolean first_vik_file = TRUE;
       cur_file = files;
       while ( cur_file ) {
       cur_file = files;
       while ( cur_file ) {
+
         gchar *file_name = cur_file->data;
         gchar *file_name = cur_file->data;
-        vik_window_open_file ( vw, file_name, change_fn );
+        if ( newwindow && check_file_magic_vik ( file_name ) ) {
+          // Load first of many .vik files in current window
+          if ( first_vik_file ) {
+            vik_window_open_file ( vw, file_name, TRUE );
+            first_vik_file = FALSE;
+          }
+          else {
+            // Load each subsequent .vik file in a separate window
+            VikWindow *newvw = vik_window_new_window ();
+            if (newvw)
+              vik_window_open_file ( newvw, file_name, TRUE );
+          }
+        }
+        else
+          // Other file types
+          vik_window_open_file ( vw, file_name, change_fn );
+
         g_free (file_name);
         cur_file = g_slist_next (cur_file);
       }
         g_free (file_name);
         cur_file = g_slist_next (cur_file);
       }
@@ -1881,9 +2376,29 @@ static gboolean save_file_as ( GtkAction *a, VikWindow *vw )
                                      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                      GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
                                      NULL);
                                      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                      GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
                                      NULL);
+    GtkFileFilter *filter;
+    filter = gtk_file_filter_new ();
+    gtk_file_filter_set_name( filter, _("All") );
+    gtk_file_filter_add_pattern ( filter, "*" );
+    gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(vw->save_dia), filter);
+
+    filter = gtk_file_filter_new ();
+    gtk_file_filter_set_name( filter, _("Viking") );
+    gtk_file_filter_add_pattern ( filter, "*.vik" );
+    gtk_file_filter_add_pattern ( filter, "*.viking" );
+    gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(vw->save_dia), filter);
+    // Default to a Viking file
+    gtk_file_chooser_set_filter (GTK_FILE_CHOOSER(vw->save_dia), filter);
+
     gtk_window_set_transient_for ( GTK_WINDOW(vw->save_dia), GTK_WINDOW(vw) );
     gtk_window_set_destroy_with_parent ( GTK_WINDOW(vw->save_dia), TRUE );
   }
     gtk_window_set_transient_for ( GTK_WINDOW(vw->save_dia), GTK_WINDOW(vw) );
     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 = g_strdup ( window_get_filename ( vw ) );
+  if ( ! check_file_ext ( auto_save_name, ".vik" ) )
+    auto_save_name = g_strconcat ( auto_save_name, ".vik", NULL );
+
+  gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(vw->save_dia), auto_save_name);
 
   while ( gtk_dialog_run ( GTK_DIALOG(vw->save_dia) ) == GTK_RESPONSE_ACCEPT )
   {
 
   while ( gtk_dialog_run ( GTK_DIALOG(vw->save_dia) ) == GTK_RESPONSE_ACCEPT )
   {
@@ -1896,6 +2411,7 @@ static gboolean save_file_as ( GtkAction *a, VikWindow *vw )
       break;
     }
   }
       break;
     }
   }
+  g_free ( auto_save_name );
   gtk_widget_hide ( vw->save_dia );
   return rv;
 }
   gtk_widget_hide ( vw->save_dia );
   return rv;
 }
@@ -1940,16 +2456,23 @@ static void acquire_from_file ( GtkAction *a, VikWindow *vw )
   a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_file_interface );
 }
 
   a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_file_interface );
 }
 
+#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 );
 }
 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_OPENSTREETMAP
 static void acquire_from_osm ( GtkAction *a, VikWindow *vw )
 {
   a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_osm_interface );
 }
 
 #ifdef VIK_CONFIG_OPENSTREETMAP
 static void acquire_from_osm ( GtkAction *a, VikWindow *vw )
 {
   a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_osm_interface );
 }
+
+static void acquire_from_my_osm ( GtkAction *a, VikWindow *vw )
+{
+  a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_osm_my_traces_interface );
+}
 #endif
 
 #ifdef VIK_CONFIG_GEOCACHES
 #endif
 
 #ifdef VIK_CONFIG_GEOCACHES
@@ -1959,6 +2482,21 @@ static void acquire_from_gc ( GtkAction *a, VikWindow *vw )
 }
 #endif
 
 }
 #endif
 
+#ifdef VIK_CONFIG_GEOTAG
+static void acquire_from_geotag ( GtkAction *a, VikWindow *vw )
+{
+  vik_datasource_geotag_interface.mode = VIK_DATASOURCE_CREATENEWLAYER;
+  a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_geotag_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_default_location( GtkAction *a, VikWindow *vw)
 {
   struct LatLon ll;
@@ -1971,7 +2509,8 @@ static void goto_default_location( GtkAction *a, VikWindow *vw)
 
 static void goto_address( GtkAction *a, VikWindow *vw)
 {
 
 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 )
 }
 
 static void mapcache_flush_cb ( GtkAction *a, VikWindow *vw )
@@ -1979,6 +2518,20 @@ static void mapcache_flush_cb ( GtkAction *a, VikWindow *vw )
   a_mapcache_flush();
 }
 
   a_mapcache_flush();
 }
 
+static void layer_defaults_cb ( GtkAction *a, VikWindow *vw )
+{
+  gchar **texts = g_strsplit ( gtk_action_get_name(a), "Layer", 0 );
+
+  if ( !texts[1] )
+    return; // Internally broken :(
+
+  if ( ! a_layer_defaults_show_window ( GTK_WINDOW(vw), texts[1] ) )
+    a_dialog_info_msg ( GTK_WINDOW(vw), _("This layer has no configurable properties.") );
+  // NB no update needed
+
+  g_strfreev ( texts );
+}
+
 static void preferences_cb ( GtkAction *a, VikWindow *vw )
 {
   gboolean wp_icon_size = a_vik_get_use_large_waypoint_icons();
 static void preferences_cb ( GtkAction *a, VikWindow *vw )
 {
   gboolean wp_icon_size = a_vik_get_use_large_waypoint_icons();
@@ -1997,21 +2550,25 @@ static void default_location_cb ( GtkAction *a, VikWindow *vw )
   /* Simplistic repeat of preference setting
      Only the name & type are important for setting the preference via this 'external' way */
   VikLayerParam pref_lat[] = {
   /* Simplistic repeat of preference setting
      Only the name & type are important for setting the preference via this 'external' way */
   VikLayerParam pref_lat[] = {
-    { VIKING_PREFERENCES_NAMESPACE "default_latitude",
+    { VIK_LAYER_NUM_TYPES,
+      VIKING_PREFERENCES_NAMESPACE "default_latitude",
       VIK_LAYER_PARAM_DOUBLE,
       VIK_LOCATION_LAT,
       NULL,
       VIK_LAYER_WIDGET_SPINBUTTON,
       NULL,
       VIK_LAYER_PARAM_DOUBLE,
       VIK_LOCATION_LAT,
       NULL,
       VIK_LAYER_WIDGET_SPINBUTTON,
       NULL,
+      NULL,
       NULL },
   };
   VikLayerParam pref_lon[] = {
       NULL },
   };
   VikLayerParam pref_lon[] = {
-    { VIKING_PREFERENCES_NAMESPACE "default_longitude",
+    { VIK_LAYER_NUM_TYPES,
+      VIKING_PREFERENCES_NAMESPACE "default_longitude",
       VIK_LAYER_PARAM_DOUBLE,
       VIK_LOCATION_LONG,
       NULL,
       VIK_LAYER_WIDGET_SPINBUTTON,
       NULL,
       VIK_LAYER_PARAM_DOUBLE,
       VIK_LOCATION_LONG,
       NULL,
       VIK_LAYER_WIDGET_SPINBUTTON,
       NULL,
+      NULL,
       NULL },
   };
 
       NULL },
   };
 
@@ -2070,6 +2627,23 @@ static void save_image_file ( VikWindow *vw, const gchar *fn, guint w, guint h,
   gdouble old_xmpp, old_ympp;
   GError *error = NULL;
 
   gdouble old_xmpp, old_ympp;
   GError *error = NULL;
 
+  GtkWidget *msgbox = gtk_message_dialog_new ( GTK_WINDOW(vw),
+                                               GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                               GTK_MESSAGE_INFO,
+                                               GTK_BUTTONS_NONE,
+                                              _("Generating image file...") );
+
+  g_signal_connect_swapped (msgbox, "response", G_CALLBACK (gtk_widget_destroy), msgbox);
+  // Ensure dialog shown
+  gtk_widget_show_all ( msgbox );
+  // Try harder...
+  vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_INFO, _("Generating image file...") );
+  while ( gtk_events_pending() )
+    gtk_main_iteration ();
+  // Despite many efforts & variations, GTK on my Linux system doesn't show the actual msgbox contents :(
+  // At least the empty box can give a clue something's going on + the statusbar msg...
+  // Windows version under Wine OK!
+
   /* backup old zoom & set new */
   old_xmpp = vik_viewport_get_xmpp ( vw->viking_vvp );
   old_ympp = vik_viewport_get_ympp ( vw->viking_vvp );
   /* backup old zoom & set new */
   old_xmpp = vik_viewport_get_xmpp ( vw->viking_vvp );
   old_ympp = vik_viewport_get_ympp ( vw->viking_vvp );
@@ -2083,14 +2657,30 @@ static void save_image_file ( VikWindow *vw, const gchar *fn, guint w, guint h,
 
   /* save buffer as file. */
   pixbuf_to_save = gdk_pixbuf_get_from_drawable ( NULL, GDK_DRAWABLE(vik_viewport_get_pixmap ( vw->viking_vvp )), NULL, 0, 0, 0, 0, w, h);
 
   /* save buffer as file. */
   pixbuf_to_save = gdk_pixbuf_get_from_drawable ( NULL, GDK_DRAWABLE(vik_viewport_get_pixmap ( vw->viking_vvp )), NULL, 0, 0, 0, 0, w, h);
+  if ( !pixbuf_to_save ) {
+    g_warning("Failed to generate internal pixmap size: %d x %d", w, h);
+    gtk_message_dialog_set_markup ( GTK_MESSAGE_DIALOG(msgbox), _("Failed to generate internal image.\n\nTry creating a smaller image.") );
+    goto cleanup;
+  }
+
   gdk_pixbuf_save ( pixbuf_to_save, fn, save_as_png ? "png" : "jpeg", &error, NULL );
   if (error)
   {
     g_warning("Unable to write to file %s: %s", fn, error->message );
   gdk_pixbuf_save ( pixbuf_to_save, fn, save_as_png ? "png" : "jpeg", &error, NULL );
   if (error)
   {
     g_warning("Unable to write to file %s: %s", fn, error->message );
+    gtk_message_dialog_set_markup ( GTK_MESSAGE_DIALOG(msgbox), _("Failed to generate image file.") );
     g_error_free (error);
   }
     g_error_free (error);
   }
+  else {
+    // Success
+    gtk_message_dialog_set_markup ( GTK_MESSAGE_DIALOG(msgbox), _("Image file generated.") );
+  }
   g_object_unref ( G_OBJECT(pixbuf_to_save) );
 
   g_object_unref ( G_OBJECT(pixbuf_to_save) );
 
+ cleanup:
+  vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_INFO, "" );
+  gtk_dialog_add_button ( GTK_DIALOG(msgbox), GTK_STOCK_OK, GTK_RESPONSE_OK );
+  gtk_dialog_run ( GTK_DIALOG(msgbox) ); // Don't care about the result
+
   /* pretend like nothing happened ;) */
   vik_viewport_set_xmpp ( vw->viking_vvp, old_xmpp );
   vik_viewport_set_ympp ( vw->viking_vvp, old_ympp );
   /* pretend like nothing happened ;) */
   vik_viewport_set_xmpp ( vw->viking_vvp, old_xmpp );
   vik_viewport_set_ympp ( vw->viking_vvp, old_ympp );
@@ -2171,7 +2761,10 @@ static void draw_to_image_file_current_window_cb(GtkWidget* widget,GdkEventButto
 {
   VikWindow *vw = VIK_WINDOW(pass_along[0]);
   GtkSpinButton *width_spin = GTK_SPIN_BUTTON(pass_along[1]), *height_spin = GTK_SPIN_BUTTON(pass_along[2]);
 {
   VikWindow *vw = VIK_WINDOW(pass_along[0]);
   GtkSpinButton *width_spin = GTK_SPIN_BUTTON(pass_along[1]), *height_spin = GTK_SPIN_BUTTON(pass_along[2]);
-  GtkSpinButton *zoom_spin = GTK_SPIN_BUTTON(pass_along[3]);
+
+  gint active = gtk_combo_box_get_active ( GTK_COMBO_BOX(pass_along[3]) );
+  gdouble zoom = pow (2, active-2 );
+
   gdouble width_min, width_max, height_min, height_max;
   gint width, height;
 
   gdouble width_min, width_max, height_min, height_max;
   gint width, height;
 
@@ -2179,8 +2772,8 @@ static void draw_to_image_file_current_window_cb(GtkWidget* widget,GdkEventButto
   gtk_spin_button_get_range ( height_spin, &height_min, &height_max );
 
   /* TODO: support for xzoom and yzoom values */
   gtk_spin_button_get_range ( height_spin, &height_min, &height_max );
 
   /* TODO: support for xzoom and yzoom values */
-  width = vik_viewport_get_width ( vw->viking_vvp ) * vik_viewport_get_xmpp ( vw->viking_vvp ) / gtk_spin_button_get_value ( zoom_spin );
-  height = vik_viewport_get_height ( vw->viking_vvp ) * vik_viewport_get_xmpp ( vw->viking_vvp ) / gtk_spin_button_get_value ( zoom_spin );
+  width = vik_viewport_get_width ( vw->viking_vvp ) * vik_viewport_get_xmpp ( vw->viking_vvp ) / zoom;
+  height = vik_viewport_get_height ( vw->viking_vvp ) * vik_viewport_get_xmpp ( vw->viking_vvp ) / zoom;
 
   if ( width > width_max || width < width_min || height > height_max || height < height_min )
     a_dialog_info_msg ( GTK_WINDOW(vw), _("Viewable region outside allowable pixel size bounds for image. Clipping width/height values.") );
 
   if ( width > width_max || width < width_min || height > height_max || height < height_min )
     a_dialog_info_msg ( GTK_WINDOW(vw), _("Viewable region outside allowable pixel size bounds for image. Clipping width/height values.") );
@@ -2192,11 +2785,14 @@ static void draw_to_image_file_current_window_cb(GtkWidget* widget,GdkEventButto
 static void draw_to_image_file_total_area_cb (GtkSpinButton *spinbutton, gpointer *pass_along)
 {
   GtkSpinButton *width_spin = GTK_SPIN_BUTTON(pass_along[1]), *height_spin = GTK_SPIN_BUTTON(pass_along[2]);
 static void draw_to_image_file_total_area_cb (GtkSpinButton *spinbutton, gpointer *pass_along)
 {
   GtkSpinButton *width_spin = GTK_SPIN_BUTTON(pass_along[1]), *height_spin = GTK_SPIN_BUTTON(pass_along[2]);
-  GtkSpinButton *zoom_spin = GTK_SPIN_BUTTON(pass_along[3]);
+
+  gint active = gtk_combo_box_get_active ( GTK_COMBO_BOX(pass_along[3]) );
+  gdouble zoom = pow (2, active-2 );
+
   gchar *label_text;
   gdouble w, h;
   gchar *label_text;
   gdouble w, h;
-  w = gtk_spin_button_get_value(width_spin) * gtk_spin_button_get_value(zoom_spin);
-  h = gtk_spin_button_get_value(height_spin) * gtk_spin_button_get_value(zoom_spin);
+  w = gtk_spin_button_get_value(width_spin) * zoom;
+  h = gtk_spin_button_get_value(height_spin) * zoom;
   if (pass_along[4]) /* save many images; find TOTAL area covered */
   {
     w *= gtk_spin_button_get_value(GTK_SPIN_BUTTON(pass_along[4]));
   if (pass_along[4]) /* save many images; find TOTAL area covered */
   {
     w *= gtk_spin_button_get_value(GTK_SPIN_BUTTON(pass_along[4]));
@@ -2219,7 +2815,84 @@ static void draw_to_image_file_total_area_cb (GtkSpinButton *spinbutton, gpointe
   g_free ( label_text );
 }
 
   g_free ( label_text );
 }
 
-static void draw_to_image_file ( VikWindow *vw, const gchar *fn, gboolean one_image_only )
+/*
+ * Get an allocated filename (or directory as specified)
+ */
+static gchar* draw_image_filename ( VikWindow *vw, gboolean one_image_only )
+{
+  gchar *fn = NULL;
+  if ( one_image_only )
+  {
+    // Single file
+    if (!vw->save_img_dia) {
+      vw->save_img_dia = gtk_file_chooser_dialog_new (_("Save Image"),
+                                                      GTK_WINDOW(vw),
+                                                      GTK_FILE_CHOOSER_ACTION_SAVE,
+                                                      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                                      GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+                                                      NULL);
+
+      GtkFileChooser *chooser = GTK_FILE_CHOOSER ( vw->save_img_dia );
+      /* Add filters */
+      GtkFileFilter *filter;
+      filter = gtk_file_filter_new ();
+      gtk_file_filter_set_name ( filter, _("All") );
+      gtk_file_filter_add_pattern ( filter, "*" );
+      gtk_file_chooser_add_filter ( chooser, filter );
+
+      filter = gtk_file_filter_new ();
+      gtk_file_filter_set_name ( filter, _("JPG") );
+      gtk_file_filter_add_mime_type ( filter, "image/jpeg");
+      gtk_file_chooser_add_filter ( chooser, filter );
+
+      filter = gtk_file_filter_new ();
+      gtk_file_filter_set_name ( filter, _("PNG") );
+      gtk_file_filter_add_mime_type ( filter, "image/png");
+      gtk_file_chooser_add_filter ( chooser, filter );
+
+      // Default to pngs
+      gtk_file_chooser_set_filter ( chooser, filter );
+
+      gtk_window_set_transient_for ( GTK_WINDOW(vw->save_img_dia), GTK_WINDOW(vw) );
+      gtk_window_set_destroy_with_parent ( GTK_WINDOW(vw->save_img_dia), TRUE );
+    }
+
+    if ( gtk_dialog_run ( GTK_DIALOG(vw->save_img_dia) ) == GTK_RESPONSE_ACCEPT ) {
+      fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(vw->save_img_dia) );
+      if ( g_file_test ( fn, G_FILE_TEST_EXISTS ) )
+       if ( ! a_dialog_yes_or_no ( GTK_WINDOW(vw->save_img_dia), _("The file \"%s\" exists, do you wish to overwrite it?"), a_file_basename ( fn ) ) )
+         fn = NULL;
+    }
+    gtk_widget_hide ( vw->save_img_dia );
+  }
+  else {
+    // A directory
+    // For some reason this method is only written to work in UTM...
+    if ( vik_viewport_get_coord_mode(vw->viking_vvp) != VIK_COORD_UTM ) {
+      a_dialog_error_msg ( GTK_WINDOW(vw), _("You must be in UTM mode to use this feature") );
+      return fn;
+    }
+
+    if (!vw->save_img_dir_dia) {
+      vw->save_img_dir_dia = gtk_file_chooser_dialog_new (_("Choose a directory to hold images"),
+                                                          GTK_WINDOW(vw),
+                                                          GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+                                                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                                          GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+                                                          NULL);
+      gtk_window_set_transient_for ( GTK_WINDOW(vw->save_img_dir_dia), GTK_WINDOW(vw) );
+      gtk_window_set_destroy_with_parent ( GTK_WINDOW(vw->save_img_dir_dia), TRUE );
+    }
+
+    if ( gtk_dialog_run ( GTK_DIALOG(vw->save_img_dir_dia) ) == GTK_RESPONSE_ACCEPT ) {
+      fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(vw->save_img_dir_dia) );
+    }
+    gtk_widget_hide ( vw->save_img_dir_dia );
+  }
+  return fn;
+}
+
+static void draw_to_image_file ( VikWindow *vw, gboolean one_image_only )
 {
   /* todo: default for answers inside VikWindow or static (thruout instance) */
   GtkWidget *dialog = gtk_dialog_new_with_buttons ( _("Save to Image File"), GTK_WINDOW(vw),
 {
   /* todo: default for answers inside VikWindow or static (thruout instance) */
   GtkWidget *dialog = gtk_dialog_new_with_buttons ( _("Save to Image File"), GTK_WINDOW(vw),
@@ -2233,21 +2906,30 @@ static void draw_to_image_file ( VikWindow *vw, const gchar *fn, gboolean one_im
   GtkWidget *png_radio, *jpeg_radio;
   GtkWidget *current_window_button;
   gpointer current_window_pass_along[7];
   GtkWidget *png_radio, *jpeg_radio;
   GtkWidget *current_window_button;
   gpointer current_window_pass_along[7];
-  GtkWidget *zoom_label, *zoom_spin;
+  GtkWidget *zoom_label, *zoom_combo;
   GtkWidget *total_size_label;
 
   /* only used if (!one_image_only) */
   GtkWidget *tiles_width_spin = NULL, *tiles_height_spin = NULL;
 
   GtkWidget *total_size_label;
 
   /* only used if (!one_image_only) */
   GtkWidget *tiles_width_spin = NULL, *tiles_height_spin = NULL;
 
-
   width_label = gtk_label_new ( _("Width (pixels):") );
   width_label = gtk_label_new ( _("Width (pixels):") );
-  width_spin = gtk_spin_button_new ( GTK_ADJUSTMENT(gtk_adjustment_new ( vw->draw_image_width, 10, 5000, 10, 100, 0 )), 10, 0 );
+  width_spin = gtk_spin_button_new ( GTK_ADJUSTMENT(gtk_adjustment_new ( vw->draw_image_width, 10, 50000, 10, 100, 0 )), 10, 0 );
   height_label = gtk_label_new ( _("Height (pixels):") );
   height_label = gtk_label_new ( _("Height (pixels):") );
-  height_spin = gtk_spin_button_new ( GTK_ADJUSTMENT(gtk_adjustment_new ( vw->draw_image_height, 10, 5000, 10, 100, 0 )), 10, 0 );
-
+  height_spin = gtk_spin_button_new ( GTK_ADJUSTMENT(gtk_adjustment_new ( vw->draw_image_height, 10, 50000, 10, 100, 0 )), 10, 0 );
+#ifdef WINDOWS
+  GtkWidget *win_warning_label = gtk_label_new ( _("WARNING: USING LARGE IMAGES OVER 10000x10000\nMAY CRASH THE PROGRAM!") );
+#endif
   zoom_label = gtk_label_new ( _("Zoom (meters per pixel):") );
   /* TODO: separate xzoom and yzoom factors */
   zoom_label = gtk_label_new ( _("Zoom (meters per pixel):") );
   /* TODO: separate xzoom and yzoom factors */
-  zoom_spin = gtk_spin_button_new ( GTK_ADJUSTMENT(gtk_adjustment_new ( vik_viewport_get_xmpp(vw->viking_vvp), VIK_VIEWPORT_MIN_ZOOM, VIK_VIEWPORT_MAX_ZOOM/2.0, 1, 100, 0 )), 16, 0);
+  zoom_combo = create_zoom_combo_all_levels();
+
+  gdouble mpp = vik_viewport_get_xmpp(vw->viking_vvp);
+  gint active = 2 + round ( log (mpp) / log (2) );
+
+  // Can we not hard code size here?
+  if ( active > 17 )
+    active = 17;
+  gtk_combo_box_set_active ( GTK_COMBO_BOX(zoom_combo), active );
 
   total_size_label = gtk_label_new ( NULL );
 
 
   total_size_label = gtk_label_new ( NULL );
 
@@ -2255,7 +2937,7 @@ static void draw_to_image_file ( VikWindow *vw, const gchar *fn, gboolean one_im
   current_window_pass_along [0] = vw;
   current_window_pass_along [1] = width_spin;
   current_window_pass_along [2] = height_spin;
   current_window_pass_along [0] = vw;
   current_window_pass_along [1] = width_spin;
   current_window_pass_along [2] = height_spin;
-  current_window_pass_along [3] = zoom_spin;
+  current_window_pass_along [3] = zoom_combo;
   current_window_pass_along [4] = NULL; /* used for one_image_only != 1 */
   current_window_pass_along [5] = NULL;
   current_window_pass_along [6] = total_size_label;
   current_window_pass_along [4] = NULL; /* used for one_image_only != 1 */
   current_window_pass_along [5] = NULL;
   current_window_pass_along [6] = total_size_label;
@@ -2271,17 +2953,19 @@ static void draw_to_image_file ( VikWindow *vw, const gchar *fn, gboolean one_im
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), width_spin, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), height_label, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), height_spin, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), width_spin, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), height_label, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), height_spin, FALSE, FALSE, 0);
+#ifdef WINDOWS
+  gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), win_warning_label, FALSE, FALSE, 0);
+#endif
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), current_window_button, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), png_radio, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), jpeg_radio, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), zoom_label, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), current_window_button, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), png_radio, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), jpeg_radio, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), zoom_label, FALSE, FALSE, 0);
-  gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), zoom_spin, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), zoom_combo, FALSE, FALSE, 0);
 
   if ( ! one_image_only )
   {
     GtkWidget *tiles_width_label, *tiles_height_label;
 
 
   if ( ! one_image_only )
   {
     GtkWidget *tiles_width_label, *tiles_height_label;
 
-
     tiles_width_label = gtk_label_new ( _("East-west image tiles:") );
     tiles_width_spin = gtk_spin_button_new ( GTK_ADJUSTMENT(gtk_adjustment_new ( 5, 1, 10, 1, 100, 0 )), 1, 0 );
     tiles_height_label = gtk_label_new ( _("North-south image tiles:") );
     tiles_width_label = gtk_label_new ( _("East-west image tiles:") );
     tiles_width_spin = gtk_spin_button_new ( GTK_ADJUSTMENT(gtk_adjustment_new ( 5, 1, 10, 1, 100, 0 )), 1, 0 );
     tiles_height_label = gtk_label_new ( _("North-south image tiles:") );
@@ -2299,7 +2983,7 @@ static void draw_to_image_file ( VikWindow *vw, const gchar *fn, gboolean one_im
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), total_size_label, FALSE, FALSE, 0);
   g_signal_connect ( G_OBJECT(width_spin), "value-changed", G_CALLBACK(draw_to_image_file_total_area_cb), current_window_pass_along );
   g_signal_connect ( G_OBJECT(height_spin), "value-changed", G_CALLBACK(draw_to_image_file_total_area_cb), current_window_pass_along );
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), total_size_label, FALSE, FALSE, 0);
   g_signal_connect ( G_OBJECT(width_spin), "value-changed", G_CALLBACK(draw_to_image_file_total_area_cb), current_window_pass_along );
   g_signal_connect ( G_OBJECT(height_spin), "value-changed", G_CALLBACK(draw_to_image_file_total_area_cb), current_window_pass_along );
-  g_signal_connect ( G_OBJECT(zoom_spin), "value-changed", G_CALLBACK(draw_to_image_file_total_area_cb), current_window_pass_along );
+  g_signal_connect ( G_OBJECT(zoom_combo), "changed", G_CALLBACK(draw_to_image_file_total_area_cb), current_window_pass_along );
 
   draw_to_image_file_total_area_cb ( NULL, current_window_pass_along ); /* set correct size info now */
 
 
   draw_to_image_file_total_area_cb ( NULL, current_window_pass_along ); /* set correct size info now */
 
@@ -2310,22 +2994,32 @@ static void draw_to_image_file ( VikWindow *vw, const gchar *fn, gboolean one_im
   if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT )
   {
     gtk_widget_hide ( GTK_WIDGET(dialog) );
   if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT )
   {
     gtk_widget_hide ( GTK_WIDGET(dialog) );
+
+    gchar *fn = draw_image_filename ( vw, one_image_only );
+    if ( !fn )
+      return;
+
+    gint active = gtk_combo_box_get_active ( GTK_COMBO_BOX(zoom_combo) );
+    gdouble zoom = pow (2, active-2 );
+
     if ( one_image_only )
       save_image_file ( vw, fn, 
                       vw->draw_image_width = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(width_spin) ),
                       vw->draw_image_height = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(height_spin) ),
     if ( one_image_only )
       save_image_file ( vw, fn, 
                       vw->draw_image_width = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(width_spin) ),
                       vw->draw_image_height = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(height_spin) ),
-                      gtk_spin_button_get_value ( GTK_SPIN_BUTTON(zoom_spin) ), /* do not save this value, default is current zoom */
+                      zoom,
                       vw->draw_image_save_as_png = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(png_radio) ) );
     else {
       // NB is in UTM mode ATM
       save_image_dir ( vw, fn,
                        vw->draw_image_width = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(width_spin) ),
                        vw->draw_image_height = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(height_spin) ),
                       vw->draw_image_save_as_png = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(png_radio) ) );
     else {
       // NB is in UTM mode ATM
       save_image_dir ( vw, fn,
                        vw->draw_image_width = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(width_spin) ),
                        vw->draw_image_height = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(height_spin) ),
-                       gtk_spin_button_get_value ( GTK_SPIN_BUTTON(zoom_spin) ), /* do not save this value, default is current zoom */
+                       zoom,
                        vw->draw_image_save_as_png = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(png_radio) ),
                        gtk_spin_button_get_value ( GTK_SPIN_BUTTON(tiles_width_spin) ),
                        gtk_spin_button_get_value ( GTK_SPIN_BUTTON(tiles_height_spin) ) );
     }
                        vw->draw_image_save_as_png = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(png_radio) ),
                        gtk_spin_button_get_value ( GTK_SPIN_BUTTON(tiles_width_spin) ),
                        gtk_spin_button_get_value ( GTK_SPIN_BUTTON(tiles_height_spin) ) );
     }
+
+    g_free ( fn );
   }
   gtk_widget_destroy ( GTK_WIDGET(dialog) );
 }
   }
   gtk_widget_destroy ( GTK_WIDGET(dialog) );
 }
@@ -2333,64 +3027,12 @@ static void draw_to_image_file ( VikWindow *vw, const gchar *fn, gboolean one_im
 
 static void draw_to_image_file_cb ( GtkAction *a, VikWindow *vw )
 {
 
 static void draw_to_image_file_cb ( GtkAction *a, VikWindow *vw )
 {
-  gchar *fn;
-  if (!vw->save_img_dia) {
-    vw->save_img_dia = gtk_file_chooser_dialog_new (_("Save Image"),
-                                     GTK_WINDOW(vw),
-                                     GTK_FILE_CHOOSER_ACTION_SAVE,
-                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                                     GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
-                                     NULL);
-    gtk_window_set_transient_for ( GTK_WINDOW(vw->save_img_dia), GTK_WINDOW(vw) );
-    gtk_window_set_destroy_with_parent ( GTK_WINDOW(vw->save_img_dia), TRUE );
-  }
-
-  while ( gtk_dialog_run ( GTK_DIALOG(vw->save_img_dia) ) == GTK_RESPONSE_ACCEPT )
-  {
-    fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(vw->save_img_dia) );
-    if ( g_file_test ( fn, G_FILE_TEST_EXISTS ) == FALSE || a_dialog_yes_or_no ( GTK_WINDOW(vw->save_img_dia), _("The file \"%s\" exists, do you wish to overwrite it?"), a_file_basename ( fn ) ) )
-    {
-      draw_to_image_file ( vw, fn, TRUE );
-      break;
-    }
-    g_free(fn);
-    fn = NULL;
-  }
-  gtk_widget_hide ( vw->save_img_dia );
+  draw_to_image_file ( vw, TRUE );
 }
 
 static void draw_to_image_dir_cb ( GtkAction *a, VikWindow *vw )
 {
 }
 
 static void draw_to_image_dir_cb ( GtkAction *a, VikWindow *vw )
 {
-  gchar *fn = NULL;
-  
-  if ( vik_viewport_get_coord_mode(vw->viking_vvp) != VIK_COORD_UTM ) {
-    a_dialog_error_msg ( GTK_WINDOW(vw), _("You must be in UTM mode to use this feature") );
-    return;
-  }
-
-  if (!vw->save_img_dir_dia) {
-    vw->save_img_dir_dia = gtk_file_chooser_dialog_new (_("Choose a directory to hold images"),
-                                     GTK_WINDOW(vw),
-                                     GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
-                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                                     GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
-                                     NULL);
-    gtk_window_set_transient_for ( GTK_WINDOW(vw->save_img_dir_dia), GTK_WINDOW(vw) );
-    gtk_window_set_destroy_with_parent ( GTK_WINDOW(vw->save_img_dir_dia), TRUE );
-  }
-  
-  while ( gtk_dialog_run ( GTK_DIALOG(vw->save_img_dir_dia) ) == GTK_RESPONSE_ACCEPT )
-  {
-    fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(vw->save_img_dir_dia) );
-    if ( fn )
-    {
-      draw_to_image_file ( vw, fn, FALSE );
-      g_free(fn);
-      fn = NULL;
-      break;
-    }
-  }
-  gtk_widget_hide ( vw->save_img_dir_dia );
+  draw_to_image_file ( vw, FALSE );
 }
 
 #if GTK_CHECK_VERSION(2,10,0)
 }
 
 #if GTK_CHECK_VERSION(2,10,0)
@@ -2522,12 +3164,21 @@ static GtkActionEntry entries[] = {
   { "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      },
   { "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
   { "AcquireGoogle",   NULL,             N_("Google _Directions..."),     NULL,         N_("Get driving directions from Google"),           (GCallback)acquire_from_google   },
   { "AcquireGoogle",   NULL,             N_("Google _Directions..."),     NULL,         N_("Get driving directions from Google"),           (GCallback)acquire_from_google   },
+#endif
 #ifdef VIK_CONFIG_OPENSTREETMAP
   { "AcquireOSM",   NULL,                 N_("_OSM Traces..."),          NULL,         N_("Get traces from OpenStreetMap"),            (GCallback)acquire_from_osm       },
 #ifdef VIK_CONFIG_OPENSTREETMAP
   { "AcquireOSM",   NULL,                 N_("_OSM Traces..."),          NULL,         N_("Get traces from OpenStreetMap"),            (GCallback)acquire_from_osm       },
+  { "AcquireMyOSM", NULL,                 N_("_My OSM Traces..."),       NULL,         N_("Get Your Own Traces from OpenStreetMap"),   (GCallback)acquire_from_my_osm    },
 #endif
 #ifdef VIK_CONFIG_GEOCACHES
   { "AcquireGC",   NULL,                 N_("Geo_caches..."),            NULL,         N_("Get Geocaches from geocaching.com"),            (GCallback)acquire_from_gc       },
 #endif
 #ifdef VIK_CONFIG_GEOCACHES
   { "AcquireGC",   NULL,                 N_("Geo_caches..."),            NULL,         N_("Get Geocaches from geocaching.com"),            (GCallback)acquire_from_gc       },
+#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          },
 #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          },
@@ -2545,29 +3196,12 @@ static GtkActionEntry entries[] = {
   { "GotoSearch", GTK_STOCK_JUMP_TO,     N_("Go to _Location..."),           NULL,         N_("Go to address/place using text search"),        (GCallback)goto_address       },
   { "GotoLL",    GTK_STOCK_JUMP_TO,      N_("_Go to Lat/Lon..."),           NULL,         N_("Go to arbitrary lat/lon coordinate"),         (GCallback)draw_goto_cb          },
   { "GotoUTM",   GTK_STOCK_JUMP_TO,      N_("Go to UTM..."),                  NULL,         N_("Go to arbitrary UTM coordinate"),               (GCallback)draw_goto_cb          },
   { "GotoSearch", GTK_STOCK_JUMP_TO,     N_("Go to _Location..."),           NULL,         N_("Go to address/place using text search"),        (GCallback)goto_address       },
   { "GotoLL",    GTK_STOCK_JUMP_TO,      N_("_Go to Lat/Lon..."),           NULL,         N_("Go to arbitrary lat/lon coordinate"),         (GCallback)draw_goto_cb          },
   { "GotoUTM",   GTK_STOCK_JUMP_TO,      N_("Go to UTM..."),                  NULL,         N_("Go to arbitrary UTM coordinate"),               (GCallback)draw_goto_cb          },
+  { "Refresh",   GTK_STOCK_REFRESH,      N_("_Refresh"),                      "F5",         N_("Refresh any maps displayed"),               (GCallback)draw_refresh_cb       },
   { "SetHLColor",GTK_STOCK_SELECT_COLOR, N_("Set _Highlight Color..."),       NULL,         NULL,                                           (GCallback)set_highlight_color   },
   { "SetBGColor",GTK_STOCK_SELECT_COLOR, N_("Set Bac_kground Color..."),      NULL,         NULL,                                           (GCallback)set_bg_color          },
   { "ZoomIn",    GTK_STOCK_ZOOM_IN,      N_("Zoom _In"),                   "<control>plus", NULL,                                           (GCallback)draw_zoom_cb          },
   { "ZoomOut",   GTK_STOCK_ZOOM_OUT,     N_("Zoom _Out"),                 "<control>minus", NULL,                                           (GCallback)draw_zoom_cb          },
   { "ZoomTo",    GTK_STOCK_ZOOM_FIT,     N_("Zoom _To..."),               "<control>Z", NULL,                                           (GCallback)zoom_to_cb            },
   { "SetHLColor",GTK_STOCK_SELECT_COLOR, N_("Set _Highlight Color..."),       NULL,         NULL,                                           (GCallback)set_highlight_color   },
   { "SetBGColor",GTK_STOCK_SELECT_COLOR, N_("Set Bac_kground Color..."),      NULL,         NULL,                                           (GCallback)set_bg_color          },
   { "ZoomIn",    GTK_STOCK_ZOOM_IN,      N_("Zoom _In"),                   "<control>plus", NULL,                                           (GCallback)draw_zoom_cb          },
   { "ZoomOut",   GTK_STOCK_ZOOM_OUT,     N_("Zoom _Out"),                 "<control>minus", NULL,                                           (GCallback)draw_zoom_cb          },
   { "ZoomTo",    GTK_STOCK_ZOOM_FIT,     N_("Zoom _To..."),               "<control>Z", NULL,                                           (GCallback)zoom_to_cb            },
-  { "Zoom0.25",  NULL,                   N_("0.25"),                          NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom0.5",   NULL,                   N_("0.5"),                           NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom1",     NULL,                   N_("1"),                             NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom2",     NULL,                   N_("2"),                             NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom4",     NULL,                   N_("4"),                             NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom8",     NULL,                   N_("8"),                             NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom16",    NULL,                   N_("16"),                            NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom32",    NULL,                   N_("32"),                            NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom64",    NULL,                   N_("64"),                            NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom128",   NULL,                   N_("128"),                           NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom256",   NULL,                   N_("256"),                           NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom512",   NULL,                   N_("512"),                           NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom1024",  NULL,                   N_("1024"),                          NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom2048",  NULL,                   N_("2048"),                          NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom4096",  NULL,                   N_("4096"),                          NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom8192",  NULL,                   N_("8192"),                          NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom16384", NULL,                   N_("16384"),                         NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
-  { "Zoom32768", NULL,                   N_("32768"),                         NULL,         NULL,                                           (GCallback)draw_zoom_cb          },
   { "PanNorth",  NULL,                   N_("Pan _North"),                "<control>Up",    NULL,                                           (GCallback)draw_pan_cb },
   { "PanEast",   NULL,                   N_("Pan _East"),                 "<control>Right", NULL,                                           (GCallback)draw_pan_cb },
   { "PanSouth",  NULL,                   N_("Pan _South"),                "<control>Down",  NULL,                                           (GCallback)draw_pan_cb },
   { "PanNorth",  NULL,                   N_("Pan _North"),                "<control>Up",    NULL,                                           (GCallback)draw_pan_cb },
   { "PanEast",   NULL,                   N_("Pan _East"),                 "<control>Right", NULL,                                           (GCallback)draw_pan_cb },
   { "PanSouth",  NULL,                   N_("Pan _South"),                "<control>Down",  NULL,                                           (GCallback)draw_pan_cb },
@@ -2582,6 +3216,7 @@ static GtkActionEntry entries[] = {
   { "MapCacheFlush",NULL,                N_("_Flush Map Cache"),              NULL,         NULL,                                           (GCallback)mapcache_flush_cb     },
   { "SetDefaultLocation", GTK_STOCK_GO_FORWARD, N_("_Set the Default Location"), NULL, N_("Set the Default Location to the current position"),(GCallback)default_location_cb },
   { "Preferences",GTK_STOCK_PREFERENCES, N_("_Preferences"),                  NULL,         NULL,                                           (GCallback)preferences_cb              },
   { "MapCacheFlush",NULL,                N_("_Flush Map Cache"),              NULL,         NULL,                                           (GCallback)mapcache_flush_cb     },
   { "SetDefaultLocation", GTK_STOCK_GO_FORWARD, N_("_Set the Default Location"), NULL, N_("Set the Default Location to the current position"),(GCallback)default_location_cb },
   { "Preferences",GTK_STOCK_PREFERENCES, N_("_Preferences"),                  NULL,         NULL,                                           (GCallback)preferences_cb              },
+  { "LayerDefaults",GTK_STOCK_PROPERTIES, N_("_Layer Defaults"),             NULL,         NULL,                                           NULL },
   { "Properties",GTK_STOCK_PROPERTIES,   N_("_Properties"),                   NULL,         NULL,                                           (GCallback)menu_properties_cb    },
 
   { "HelpEntry", GTK_STOCK_HELP,         N_("_Help"),                         "F1",         NULL,                                           (GCallback)help_help_cb     },
   { "Properties",GTK_STOCK_PROPERTIES,   N_("_Properties"),                   NULL,         NULL,                                           (GCallback)menu_properties_cb    },
 
   { "HelpEntry", GTK_STOCK_HELP,         N_("_Help"),                         "F1",         NULL,                                           (GCallback)help_help_cb     },
@@ -2597,15 +3232,8 @@ static GtkRadioActionEntry mode_entries[] = {
   { "ModeLatLon",      NULL,         N_("Lat_/Lon Mode"),           "<control>l", NULL, 5 },
 };
 
   { "ModeLatLon",      NULL,         N_("Lat_/Lon Mode"),           "<control>l", NULL, 5 },
 };
 
-static GtkRadioActionEntry tool_entries[] = {
-  { "Pan",      "vik-icon-pan",        N_("_Pan"),                         "<control><shift>P", N_("Pan Tool"),  0 },
-  { "Zoom",      "vik-icon-zoom",        N_("_Zoom"),                         "<control><shift>Z", N_("Zoom Tool"),  1 },
-  { "Ruler",     "vik-icon-ruler",       N_("_Ruler"),                        "<control><shift>R", N_("Ruler Tool"), 2 },
-  { "Select",    "vik-icon-select",      N_("_Select"),                       "<control><shift>S", N_("Select Tool"), 3 }
-};
-
 static GtkToggleActionEntry toggle_entries[] = {
 static GtkToggleActionEntry toggle_entries[] = {
-  { "ShowScale",      NULL,                 N_("Show _Scale"),               "F5",         N_("Show Scale"),                              (GCallback)set_draw_scale, TRUE },
+  { "ShowScale",      NULL,                 N_("Show _Scale"),               "<shift>F5",  N_("Show Scale"),                              (GCallback)set_draw_scale, TRUE },
   { "ShowCenterMark", NULL,                 N_("Show _Center Mark"),         "F6",         N_("Show Center Mark"),                        (GCallback)set_draw_centermark, TRUE },
   { "ShowHighlight",  GTK_STOCK_UNDERLINE,  N_("Show _Highlight"),           "F7",         N_("Show Highlight"),                          (GCallback)set_draw_highlight, TRUE },
   { "FullScreen",     GTK_STOCK_FULLSCREEN, N_("_Full Screen"),              "F11",        N_("Activate full screen mode"),               (GCallback)full_screen_cb, FALSE },
   { "ShowCenterMark", NULL,                 N_("Show _Center Mark"),         "F6",         N_("Show Center Mark"),                        (GCallback)set_draw_centermark, TRUE },
   { "ShowHighlight",  GTK_STOCK_UNDERLINE,  N_("Show _Highlight"),           "F7",         N_("Show Highlight"),                          (GCallback)set_draw_highlight, TRUE },
   { "FullScreen",     GTK_STOCK_FULLSCREEN, N_("_Full Screen"),              "F11",        N_("Activate full screen mode"),               (GCallback)full_screen_cb, FALSE },
@@ -2653,14 +3281,16 @@ static void window_create_ui( VikWindow *window )
 
   register_vik_icons(icon_factory);
 
 
   register_vik_icons(icon_factory);
 
+  // Copy the tool RadioActionEntries out of the main Window structure into an extending array 'tools'
+  //  so that it can be applied to the UI in one action group add function call below
   ntools = 0;
   ntools = 0;
-  for (i=0; i<G_N_ELEMENTS(tool_entries); i++) {
+  for (i=0; i<window->vt->n_tools; i++) {
       tools = g_renew(GtkRadioActionEntry, tools, ntools+1);
       radio = &tools[ntools];
       ntools++;
       tools = g_renew(GtkRadioActionEntry, tools, ntools+1);
       radio = &tools[ntools];
       ntools++;
-      *radio = tool_entries[i];
+      *radio = window->vt->tools[i].ti.radioActionEntry;
       radio->value = ntools;
       radio->value = ntools;
-  }  
+  }
 
   for (i=0; i<VIK_LAYER_NUM_TYPES; i++) {
     GtkActionEntry action;
 
   for (i=0; i<VIK_LAYER_NUM_TYPES; i++) {
     GtkActionEntry action;
@@ -2675,8 +3305,8 @@ static void window_create_ui( VikWindow *window )
 
     action.name = vik_layer_get_interface(i)->name;
     action.stock_id = vik_layer_get_interface(i)->name;
 
     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.accelerator = NULL;
+    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;
     gtk_action_group_add_actions(action_group, &action, 1, window);
     action.tooltip = NULL;
     action.callback = (GCallback)menu_addlayer_cb;
     gtk_action_group_add_actions(action_group, &action, 1, window);
@@ -2686,29 +3316,44 @@ static void window_create_ui( VikWindow *window )
       gtk_ui_manager_add_ui(uim, mid,  "/ui/MainToolbar/ToolItems/", vik_layer_get_interface(i)->name, NULL, GTK_UI_MANAGER_SEPARATOR, FALSE);
     }
 
       gtk_ui_manager_add_ui(uim, mid,  "/ui/MainToolbar/ToolItems/", vik_layer_get_interface(i)->name, NULL, GTK_UI_MANAGER_SEPARATOR, FALSE);
     }
 
+    // Further tool copying for to apply to the UI, also apply menu UI setup
     for ( j = 0; j < vik_layer_get_interface(i)->tools_count; j++ ) {
       tools = g_renew(GtkRadioActionEntry, tools, ntools+1);
       radio = &tools[ntools];
       ntools++;
       
       gtk_ui_manager_add_ui(uim, mid,  "/ui/MainMenu/Tools", 
     for ( j = 0; j < vik_layer_get_interface(i)->tools_count; j++ ) {
       tools = g_renew(GtkRadioActionEntry, tools, ntools+1);
       radio = &tools[ntools];
       ntools++;
       
       gtk_ui_manager_add_ui(uim, mid,  "/ui/MainMenu/Tools", 
-                           _(vik_layer_get_interface(i)->tools[j].name),
-                           vik_layer_get_interface(i)->tools[j].name,
+                           vik_layer_get_interface(i)->tools[j].radioActionEntry.label,
+                           vik_layer_get_interface(i)->tools[j].radioActionEntry.name,
                            GTK_UI_MANAGER_MENUITEM, FALSE);
       gtk_ui_manager_add_ui(uim, mid,  "/ui/MainToolbar/ToolItems", 
                            GTK_UI_MANAGER_MENUITEM, FALSE);
       gtk_ui_manager_add_ui(uim, mid,  "/ui/MainToolbar/ToolItems", 
-                           _(vik_layer_get_interface(i)->tools[j].name),
-                           vik_layer_get_interface(i)->tools[j].name,
+                           vik_layer_get_interface(i)->tools[j].radioActionEntry.label,
+                           vik_layer_get_interface(i)->tools[j].radioActionEntry.name,
                            GTK_UI_MANAGER_TOOLITEM, FALSE);
 
       toolbox_add_tool(window->vt, &(vik_layer_get_interface(i)->tools[j]), i);
 
                            GTK_UI_MANAGER_TOOLITEM, FALSE);
 
       toolbox_add_tool(window->vt, &(vik_layer_get_interface(i)->tools[j]), i);
 
-      radio->name = vik_layer_get_interface(i)->tools[j].name;
-      radio->stock_id = vik_layer_get_interface(i)->tools[j].name,
-      radio->label = _(vik_layer_get_interface(i)->tools[j].name);
-      radio->accelerator = NULL;
-      radio->tooltip = _(vik_layer_get_interface(i)->tools[j].name);
+      *radio = vik_layer_get_interface(i)->tools[j].radioActionEntry;
+      // Overwrite with actual number to use
       radio->value = ntools;
     }
       radio->value = ntools;
     }
+
+    GtkActionEntry action_dl;
+    gtk_ui_manager_add_ui(uim, mid,  "/ui/MainMenu/Edit/LayerDefaults",
+                         vik_layer_get_interface(i)->name,
+                         g_strdup_printf("Layer%s", vik_layer_get_interface(i)->fixed_layer_name),
+                         GTK_UI_MANAGER_MENUITEM, FALSE);
+
+    // For default layers use action names of the form 'Layer<LayerName>'
+    // 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.accelerator = NULL;
+    action_dl.tooltip = NULL;
+    action_dl.callback = (GCallback)layer_defaults_cb;
+    gtk_action_group_add_actions(action_group, &action_dl, 1, window);
+    // NB An alternate method of adding menuitems manually is performed ATM in vikexttools.c
   }
   g_object_unref (icon_factory);
 
   }
   g_object_unref (icon_factory);
 
@@ -2720,7 +3365,7 @@ static void window_create_ui( VikWindow *window )
   for (i=0; i<VIK_LAYER_NUM_TYPES; i++) {
     for ( j = 0; j < vik_layer_get_interface(i)->tools_count; j++ ) {
       GtkAction *action = gtk_action_group_get_action(action_group,
   for (i=0; i<VIK_LAYER_NUM_TYPES; i++) {
     for ( j = 0; j < vik_layer_get_interface(i)->tools_count; j++ ) {
       GtkAction *action = gtk_action_group_get_action(action_group,
-                           vik_layer_get_interface(i)->tools[j].name);
+                           vik_layer_get_interface(i)->tools[j].radioActionEntry.name);
       g_object_set(action, "sensitive", FALSE, NULL);
     }
   }
       g_object_set(action, "sensitive", FALSE, NULL);
     }
   }
@@ -2734,26 +3379,27 @@ static void window_create_ui( VikWindow *window )
 }
 
 
 }
 
 
-
+// TODO - add method to add tool icons defined from outside this file
+//  and remove the reverse dependency on icon definition from this file
 static struct { 
   const GdkPixdata *data;
   gchar *stock_id;
 } stock_icons[] = {
 static struct { 
   const GdkPixdata *data;
   gchar *stock_id;
 } stock_icons[] = {
-  { &begintr_18_pixbuf,                "Begin Track"      },
-  { &route_finder_18_pixbuf,   "Route Finder"     },
-  { &mover_22_pixbuf,          "vik-icon-pan"     },
-  { &demdl_18_pixbuf,          "DEM Download/Import"     },
-  { &showpic_18_pixbuf,                "Show Picture"      },
-  { &addtr_18_pixbuf,          "Create Track"      },
-  { &edtr_18_pixbuf,           "Edit Trackpoint"   },
-  { &addwp_18_pixbuf,          "Create Waypoint"   },
-  { &edwp_18_pixbuf,           "Edit Waypoint"     },
+  { &mover_22_pixbuf,          "vik-icon-pan"      },
   { &zoom_18_pixbuf,           "vik-icon-zoom"     },
   { &ruler_18_pixbuf,          "vik-icon-ruler"    },
   { &select_18_pixbuf,         "vik-icon-select"   },
   { &zoom_18_pixbuf,           "vik-icon-zoom"     },
   { &ruler_18_pixbuf,          "vik-icon-ruler"    },
   { &select_18_pixbuf,         "vik-icon-select"   },
-  { &geozoom_18_pixbuf,                "Georef Zoom Tool"  },
-  { &geomove_18_pixbuf,                "Georef Move Map"   },
-  { &mapdl_18_pixbuf,          "Maps Download"     },
+  { &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"     },
+  { &addtr_18_pixbuf,          "vik-icon-Create Track"     },
+  { &edtr_18_pixbuf,           "vik-icon-Edit Trackpoint"  },
+  { &addwp_18_pixbuf,          "vik-icon-Create Waypoint"  },
+  { &edwp_18_pixbuf,           "vik-icon-Edit Waypoint"    },
+  { &geozoom_18_pixbuf,                "vik-icon-Georef Zoom Tool" },
+  { &geomove_18_pixbuf,                "vik-icon-Georef Move Map"  },
+  { &mapdl_18_pixbuf,          "vik-icon-Maps Download"    },
 };
  
 static gint n_stock_icons = G_N_ELEMENTS (stock_icons);
 };
  
 static gint n_stock_icons = G_N_ELEMENTS (stock_icons);
@@ -2786,26 +3432,24 @@ void vik_window_set_selected_trw_layer ( VikWindow *vw, gpointer vtl )
   vw->selected_tracks    = NULL;
   vw->selected_waypoint  = NULL;
   vw->selected_waypoints = NULL;
   vw->selected_tracks    = NULL;
   vw->selected_waypoint  = NULL;
   vw->selected_waypoints = NULL;
-  vw->selected_name      = NULL;
   // Set highlight thickness
   vik_viewport_set_highlight_thickness ( vw->viking_vvp, vik_trw_layer_get_property_tracks_line_thickness (vw->containing_vtl) );
 }
 
   // Set highlight thickness
   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;
 }
 
 {
   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;
   vw->selected_track     = NULL;
   vw->selected_waypoint  = NULL;
   vw->selected_waypoints = NULL;
   vw->containing_vtl  = vtl;
   /* Clear others */
   vw->selected_vtl       = NULL;
   vw->selected_track     = NULL;
   vw->selected_waypoint  = NULL;
   vw->selected_waypoints = NULL;
-  vw->selected_name      = NULL;
   // Set highlight thickness
   vik_viewport_set_highlight_thickness ( vw->viking_vvp, vik_trw_layer_get_property_tracks_line_thickness (vw->containing_vtl) );
 }
   // Set highlight thickness
   vik_viewport_set_highlight_thickness ( vw->viking_vvp, vik_trw_layer_get_property_tracks_line_thickness (vw->containing_vtl) );
 }
@@ -2815,11 +3459,10 @@ gpointer vik_window_get_selected_track ( VikWindow *vw )
   return vw->selected_track;
 }
 
   return vw->selected_track;
 }
 
-void vik_window_set_selected_track ( VikWindow *vw, gpointer *vt, gpointer vtl, gpointer name )
+void vik_window_set_selected_track ( VikWindow *vw, gpointer *vt, gpointer vtl )
 {
   vw->selected_track = vt;
   vw->containing_vtl = vtl;
 {
   vw->selected_track = vt;
   vw->containing_vtl = vtl;
-  vw->selected_name  = name;
   /* Clear others */
   vw->selected_vtl       = NULL;
   vw->selected_tracks    = NULL;
   /* Clear others */
   vw->selected_vtl       = NULL;
   vw->selected_tracks    = NULL;
@@ -2829,21 +3472,20 @@ void vik_window_set_selected_track ( VikWindow *vw, gpointer *vt, gpointer vtl,
   vik_viewport_set_highlight_thickness ( vw->viking_vvp, vik_trw_layer_get_property_tracks_line_thickness (vw->containing_vtl) );
 }
 
   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;
 }
 
 {
   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;
   vw->selected_track     = NULL;
   vw->selected_tracks    = NULL;
   vw->selected_waypoint  = NULL;
   vw->containing_vtl     = vtl;
   /* Clear others */
   vw->selected_vtl       = NULL;
   vw->selected_track     = NULL;
   vw->selected_tracks    = NULL;
   vw->selected_waypoint  = NULL;
-  vw->selected_name      = NULL;
 }
 
 gpointer vik_window_get_selected_waypoint ( VikWindow *vw )
 }
 
 gpointer vik_window_get_selected_waypoint ( VikWindow *vw )
@@ -2851,11 +3493,10 @@ gpointer vik_window_get_selected_waypoint ( VikWindow *vw )
   return vw->selected_waypoint;
 }
 
   return vw->selected_waypoint;
 }
 
-void vik_window_set_selected_waypoint ( VikWindow *vw, gpointer *vwp, gpointer vtl, gpointer name )
+void vik_window_set_selected_waypoint ( VikWindow *vw, gpointer *vwp, gpointer vtl )
 {
   vw->selected_waypoint = vwp;
   vw->containing_vtl    = vtl;
 {
   vw->selected_waypoint = vwp;
   vw->containing_vtl    = vtl;
-  vw->selected_name     = name;
   /* Clear others */
   vw->selected_vtl       = NULL;
   vw->selected_track     = NULL;
   /* Clear others */
   vw->selected_vtl       = NULL;
   vw->selected_track     = NULL;
@@ -2863,11 +3504,6 @@ void vik_window_set_selected_waypoint ( VikWindow *vw, gpointer *vwp, gpointer v
   vw->selected_waypoints = NULL;
 }
 
   vw->selected_waypoints = NULL;
 }
 
-gpointer vik_window_get_selected_name ( VikWindow *vw )
-{
-  return vw->selected_name;
-}
-
 gboolean vik_window_clear_highlight ( VikWindow *vw )
 {
   gboolean need_redraw = FALSE;
 gboolean vik_window_clear_highlight ( VikWindow *vw )
 {
   gboolean need_redraw = FALSE;
@@ -2893,3 +3529,8 @@ gboolean vik_window_clear_highlight ( VikWindow *vw )
   }
   return need_redraw;
 }
   }
   return need_redraw;
 }
+
+GThread *vik_window_get_thread ( VikWindow *vw )
+{
+  return vw->thread;
+}