]> git.street.me.uk Git - andy/viking.git/blobdiff - src/vikwindow.c
Add internal track right click menu variable.
[andy/viking.git] / src / vikwindow.c
index a41ed626b00dbde2615f61060c713ddc2d1e3895..3a63af0df192b50c419a7ad75d35355b60f3a570 100644 (file)
@@ -2,6 +2,7 @@
  * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
  *
  * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
+ * Copyright (C) 2005-2006, Alex Foobarian <foobarian@gmail.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
 #include "background.h"
 #include "acquire.h"
 #include "datasources.h"
-#include "googlesearch.h"
+#include "vikgoto.h"
 #include "dems.h"
+#include "mapcache.h"
 #include "print.h"
 #include "preferences.h"
 #include "icons/icons.h"
+#include "vikexttools.h"
+#include "garminsymbols.h"
 
+#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
+#endif
+#ifdef HAVE_MATH_H
 #include <math.h>
+#endif
+#ifdef HAVE_STRING_H
 #include <string.h>
+#endif
 #include <ctype.h>
 #include <glib.h>
 #include <glib/gstdio.h>
 #include <glib/gprintf.h>
 #include <glib/gi18n.h>
+#include <gio/gio.h>
+#include <gdk/gdkkeysyms.h>
 
 #define VIKING_WINDOW_WIDTH      1000
 #define VIKING_WINDOW_HEIGHT     800
@@ -75,7 +87,7 @@ 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_status ();
+static void draw_status ( VikWindow *vw );
 
 /* End Drawing Functions */
 
@@ -138,6 +150,7 @@ struct _VikWindow {
 
   GtkActionGroup *action_group;
 
+  gboolean pan_move;
   gint pan_x, pan_y;
 
   guint draw_image_width, draw_image_height;
@@ -155,6 +168,14 @@ struct _VikWindow {
   /* half-drawn update */
   VikLayer *trigger;
   VikCoord trigger_center;
+
+  /* Store at this level for highlighted selection drawing since it applies to the viewport and the layers panel */
+  /* Only one of these items can be selected at the same time */
+  gpointer selected_vtl; /* notionally VikTrwLayer */
+  gpointer selected_tracks; /* notionally GList */
+  gpointer selected_track; /* notionally VikTrack */
+  gpointer selected_waypoints; /* notionally GList */
+  gpointer selected_waypoint; /* notionally VikWaypoint */
 };
 
 enum {
@@ -204,6 +225,11 @@ VikViewport * vik_window_viewport(VikWindow *vw)
   return(vw->viking_vvp);
 }
 
+VikLayersPanel * vik_window_layers_panel(VikWindow *vw)
+{
+  return(vw->viking_vlp);
+}
+
 void vik_window_selected_layer(VikWindow *vw, VikLayer *vl)
 {
   int i, j, tool_count;
@@ -266,7 +292,8 @@ static void window_init ( VikWindow *vw )
   vw->vt = toolbox_create(vw);
   window_create_ui(vw);
   window_set_filename (vw, NULL);
-  
+  vw->toolbar = GTK_TOOLBAR(gtk_ui_manager_get_widget (vw->uim, "/MainToolbar"));
+
   toolbox_activate(vw->vt, "Pan");
 
   vw->filename = NULL;
@@ -274,7 +301,8 @@ static void window_init ( VikWindow *vw )
 
   vw->modified = FALSE;
   vw->only_updating_coord_mode_ui = FALSE;
-  
+  vw->pan_move = FALSE; 
   vw->pan_x = vw->pan_y = -1;
   vw->draw_image_width = DRAW_IMAGE_DEFAULT_WIDTH;
   vw->draw_image_height = DRAW_IMAGE_DEFAULT_HEIGHT;
@@ -284,16 +312,17 @@ static void window_init ( VikWindow *vw )
   gtk_container_add (GTK_CONTAINER (vw), main_vbox);
 
   gtk_box_pack_start (GTK_BOX(main_vbox), gtk_ui_manager_get_widget (vw->uim, "/MainMenu"), FALSE, TRUE, 0);
-  gtk_box_pack_start (GTK_BOX(main_vbox), gtk_ui_manager_get_widget (vw->uim, "/MainToolbar"), FALSE, TRUE, 0);
-  gtk_toolbar_set_icon_size(GTK_TOOLBAR(gtk_ui_manager_get_widget (vw->uim, "/MainToolbar")), GTK_ICON_SIZE_SMALL_TOOLBAR);
-  gtk_toolbar_set_style (GTK_TOOLBAR(gtk_ui_manager_get_widget (vw->uim, "/MainToolbar")), GTK_TOOLBAR_ICONS);
+  gtk_box_pack_start (GTK_BOX(main_vbox), GTK_WIDGET(vw->toolbar), FALSE, TRUE, 0);
+  gtk_toolbar_set_icon_size (vw->toolbar, GTK_ICON_SIZE_SMALL_TOOLBAR);
+  gtk_toolbar_set_style (vw->toolbar, GTK_TOOLBAR_ICONS);
 
+  vik_ext_tools_add_menu_items ( vw, vw->uim );
 
   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_swapped (G_OBJECT(vw->viking_vvp), "configure_event", G_CALLBACK(window_configure_event), vw);
-  gtk_widget_add_events ( GTK_WIDGET(vw->viking_vvp), GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK );
+  gtk_widget_add_events ( GTK_WIDGET(vw->viking_vvp), GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK );
   g_signal_connect_swapped (G_OBJECT(vw->viking_vvp), "scroll_event", G_CALLBACK(draw_scroll), vw);
   g_signal_connect_swapped (G_OBJECT(vw->viking_vvp), "button_press_event", G_CALLBACK(draw_click), vw);
   g_signal_connect_swapped (G_OBJECT(vw->viking_vvp), "button_release_event", G_CALLBACK(draw_release), vw);
@@ -334,6 +363,21 @@ static gboolean key_press_event( VikWindow *vw, GdkEventKey *event, gpointer dat
     if ( vl && ltype == vl->type )
       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 */
+  /* This key is more likely to be used as they may not remember the function key */
+  if ( event->keyval == GDK_Escape ) {
+    GtkWidget *check_box = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/SetShow/ViewMainMenu" );
+    if ( check_box ) {
+      gboolean state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box) );
+      if ( !state ) {
+       gtk_widget_show ( gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu" ) );
+       gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(check_box), TRUE );
+       return TRUE; /* handled keypress */
+      }
+    }
+  }
+
   return FALSE; /* don't handle the keypress */
 }
 
@@ -384,7 +428,17 @@ static void draw_sync ( VikWindow *vw )
 static void draw_status ( VikWindow *vw )
 {
   static gchar zoom_level[22];
-  g_snprintf ( zoom_level, 22, "%.3f/%.3f %s", vik_viewport_get_xmpp (vw->viking_vvp), vik_viewport_get_ympp(vw->viking_vvp), vik_viewport_get_coord_mode(vw->viking_vvp) == VIK_COORD_UTM ? _("mpp") : _("pixelfact") );
+  gdouble xmpp = vik_viewport_get_xmpp (vw->viking_vvp);
+  gdouble ympp = vik_viewport_get_ympp(vw->viking_vvp);
+  gchar *unit = vik_viewport_get_coord_mode(vw->viking_vvp) == VIK_COORD_UTM ? _("mpp") : _("pixelfact");
+  if (xmpp != ympp)
+    g_snprintf ( zoom_level, 22, "%.3f/%.3f %s", xmpp, ympp, unit );
+  else
+    if ( (int)xmpp - xmpp < 0.0 )
+      g_snprintf ( zoom_level, 22, "%.3f %s", 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, 0, vik_layer_get_interface(vw->tool_layer_id)->tools[vw->tool_tool_id].name );
   else
@@ -411,7 +465,7 @@ static void window_configure_event ( VikWindow *vw )
     first = 0;
     cursor = toolbox_get_cursor(vw->vt, "Pan");
     /* We set cursor, even if it is NULL: it resets to default */
-    gdk_window_set_cursor ( GTK_WIDGET(vw->viking_vvp)->window, cursor );
+    gdk_window_set_cursor ( GTK_WIDGET(vw->viking_vvp)->window, (GdkCursor *)cursor );
   }
 }
 
@@ -425,7 +479,7 @@ static void draw_redraw ( VikWindow *vw )
 
   if ( ! new_trigger )
     ; /* do nothing -- have to redraw everything. */
-  else if ( (old_trigger != new_trigger) || !vik_coord_equals(&old_center, &vw->trigger_center) )
+  else if ( (old_trigger != new_trigger) || !vik_coord_equals(&old_center, &vw->trigger_center) || (new_trigger->type == VIK_LAYER_AGGREGATE) )
     vik_viewport_set_trigger ( vw->viking_vvp, new_trigger ); /* todo: set to half_drawn mode if new trigger is above old */
   else
     vik_viewport_set_half_drawn ( vw->viking_vvp, TRUE );
@@ -434,7 +488,9 @@ static void draw_redraw ( VikWindow *vw )
   vik_viewport_clear ( vw->viking_vvp);
   vik_layers_panel_draw_all ( vw->viking_vlp );
   vik_viewport_draw_scale ( vw->viking_vvp );
+  vik_viewport_draw_copyright ( vw->viking_vvp );
   vik_viewport_draw_centermark ( vw->viking_vvp );
+  vik_viewport_draw_logo ( vw->viking_vvp );
 
   vik_viewport_set_half_drawn ( vw->viking_vvp, FALSE ); /* just in case. */
 }
@@ -458,6 +514,7 @@ static gboolean draw_buf(gpointer data)
 static void vik_window_pan_click (VikWindow *vw, GdkEventButton *event)
 {
   /* set panning origin */
+  vw->pan_move = FALSE;
   vw->pan_x = (gint) event->x;
   vw->pan_y = (gint) event->y;
 }
@@ -480,7 +537,12 @@ static void draw_click (VikWindow *vw, GdkEventButton *event)
 static void vik_window_pan_move (VikWindow *vw, GdkEventMotion *event)
 {
   if ( vw->pan_x != -1 ) {
-    vik_viewport_pan_sync ( vw->viking_vvp, event->x - vw->pan_x, event->y - vw->pan_y );
+    vik_viewport_set_center_screen ( vw->viking_vvp, vik_viewport_get_width(vw->viking_vvp)/2 - event->x + vw->pan_x,
+                                     vik_viewport_get_height(vw->viking_vvp)/2 - event->y + vw->pan_y );
+    vw->pan_move = TRUE;
+    vw->pan_x = event->x;
+    vw->pan_y = event->y;
+    draw_update ( vw );
   }
 }
 
@@ -496,6 +558,13 @@ static void draw_mouse_motion (VikWindow *vw, GdkEventMotion *event)
   gdouble zoom;
   VikDemInterpol interpol_method;
 
+  /* This is a hack, but work far the best, at least for single pointer systems.
+   * See http://bugzilla.gnome.org/show_bug.cgi?id=587714 for more. */
+  gint x, y;
+  gdk_window_get_pointer (event->window, &x, &y, NULL);
+  event->x = x;
+  event->y = y;
+
   toolbox_move(vw->vt, event);
 
   vik_viewport_screen_to_coord ( vw->viking_vvp, event->x, event->y, &coord );
@@ -510,8 +579,12 @@ static void draw_mouse_motion (VikWindow *vw, GdkEventMotion *event)
     interpol_method = VIK_DEM_INTERPOL_SIMPLE;
   else
     interpol_method = VIK_DEM_INTERPOL_BEST;
-  if ((alt = a_dems_get_elev_by_coord(&coord, interpol_method)) != VIK_DEM_INVALID_ELEVATION)
-    g_snprintf ( pointer_buf, BUFFER_SIZE, _("%s %s %dm"), lat, lon, alt );
+  if ((alt = a_dems_get_elev_by_coord(&coord, interpol_method)) != VIK_DEM_INVALID_ELEVATION) {
+    if ( a_vik_get_units_height () == VIK_UNITS_HEIGHT_METRES )
+      g_snprintf ( pointer_buf, BUFFER_SIZE, _("%s %s %dm"), lat, lon, alt );
+    else
+      g_snprintf ( pointer_buf, BUFFER_SIZE, _("%s %s %dft"), lat, lon, (int)VIK_METERS_TO_FEET(alt) );
+  }
   else
     g_snprintf ( pointer_buf, BUFFER_SIZE, _("%s %s"), lat, lon );
   g_free (lat);
@@ -521,17 +594,24 @@ static void draw_mouse_motion (VikWindow *vw, GdkEventMotion *event)
   vik_statusbar_set_message ( vw->viking_vs, 4, pointer_buf );
 
   vik_window_pan_move ( vw, event );
+
+  /* This is recommended by the GTK+ documentation, but does not work properly.
+   * Use deprecated way until GTK+ gets a solution for correct motion hint handling:
+   * http://bugzilla.gnome.org/show_bug.cgi?id=587714
+  */
+  /* gdk_event_request_motions ( event ); */
 }
 
 static void vik_window_pan_release ( VikWindow *vw, GdkEventButton *event )
 {
-  if ( ABS(vw->pan_x - event->x) <= 1 && ABS(vw->pan_y - event->y) <= 1 )
+  if ( vw->pan_move == FALSE )
     vik_viewport_set_center_screen ( vw->viking_vvp, vw->pan_x, vw->pan_y );
   else
      vik_viewport_set_center_screen ( vw->viking_vvp, vik_viewport_get_width(vw->viking_vvp)/2 - event->x + vw->pan_x,
                                       vik_viewport_get_height(vw->viking_vvp)/2 - event->y + vw->pan_y );
-  draw_update ( vw );
+  vw->pan_move = FALSE;
   vw->pan_x = vw->pan_y = -1;
+  draw_update ( vw );
 }
 
 static void draw_release ( VikWindow *vw, GdkEventButton *event )
@@ -548,42 +628,33 @@ static void draw_release ( VikWindow *vw, GdkEventButton *event )
 
 static void draw_scroll (VikWindow *vw, GdkEventScroll *event)
 {
-  if ( event->state == GDK_CONTROL_MASK ) {
+  guint modifiers = event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK);
+  if ( modifiers == GDK_CONTROL_MASK ) {
     /* control == pan up & down */
     if ( event->direction == GDK_SCROLL_UP )
       vik_viewport_set_center_screen ( vw->viking_vvp, vik_viewport_get_width(vw->viking_vvp)/2, vik_viewport_get_height(vw->viking_vvp)/3 );
     else
       vik_viewport_set_center_screen ( vw->viking_vvp, vik_viewport_get_width(vw->viking_vvp)/2, vik_viewport_get_height(vw->viking_vvp)*2/3 );
-  } else if ( event->state == GDK_SHIFT_MASK ) {
-    /* control-shift == pan left & right */
+  } else if ( modifiers == GDK_SHIFT_MASK ) {
+    /* shift == pan left & right */
     if ( event->direction == GDK_SCROLL_UP )
       vik_viewport_set_center_screen ( vw->viking_vvp, vik_viewport_get_width(vw->viking_vvp)/3, vik_viewport_get_height(vw->viking_vvp)/2 );
     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 ( event->state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK) ) {
-    if ( event->direction == GDK_SCROLL_UP ) {
-      /* 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;
-      gint center_y = vik_viewport_get_height ( vw->viking_vvp ) / 2;
-      vik_viewport_screen_to_coord ( vw->viking_vvp, event->x, event->y, &coord );
+  } 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 */
+    VikCoord coord;
+    gint x, y;
+    gint center_x = vik_viewport_get_width ( vw->viking_vvp ) / 2;
+    gint center_y = vik_viewport_get_height ( vw->viking_vvp ) / 2;
+    vik_viewport_screen_to_coord ( vw->viking_vvp, event->x, event->y, &coord );
+    if ( event->direction == GDK_SCROLL_UP )
       vik_viewport_zoom_in (vw->viking_vvp);
-      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 {
-      VikCoord coord;
-      gint x, y;
-      gint center_x = vik_viewport_get_width ( vw->viking_vvp ) / 2;
-      gint center_y = vik_viewport_get_height ( vw->viking_vvp ) / 2;
-      vik_viewport_screen_to_coord ( vw->viking_vvp, event->x, event->y, &coord );
+    else
       vik_viewport_zoom_out(vw->viking_vvp);
-      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);
@@ -711,13 +782,30 @@ static void draw_ruler(VikViewport *vvp, GdkDrawable *d, GdkGC *gc, gint x1, gin
     gdk_draw_layout(d, gc, x1-5, y1-CR-3*CW-8, pl);
 
     /* draw label with distance */
-    if (distance >= 1000 && distance < 100000) {
-      g_sprintf(str, "%3.2f km", distance/1000.0);
-    } else if (distance < 1000) {
-      g_sprintf(str, "%d m", (int)distance);
-    } else {
-      g_sprintf(str, "%d km", (int)distance/1000);
+    vik_units_distance_t dist_units = a_vik_get_units_distance ();
+    switch (dist_units) {
+    case VIK_UNITS_DISTANCE_KILOMETRES:
+      if (distance >= 1000 && distance < 100000) {
+       g_sprintf(str, "%3.2f km", distance/1000.0);
+      } else if (distance < 1000) {
+       g_sprintf(str, "%d m", (int)distance);
+      } else {
+       g_sprintf(str, "%d km", (int)distance/1000);
+      }
+      break;
+    case VIK_UNITS_DISTANCE_MILES:
+      if (distance >= VIK_MILES_TO_METERS(1) && distance < VIK_MILES_TO_METERS(100)) {
+       g_sprintf(str, "%3.2f miles", VIK_METERS_TO_MILES(distance));
+      } else if (distance < VIK_MILES_TO_METERS(1)) {
+       g_sprintf(str, "%d yards", (int)(distance*1.0936133));
+      } else {
+       g_sprintf(str, "%d miles", (int)VIK_METERS_TO_MILES(distance));
+      }
+      break;
+    default:
+      g_critical("Houston, we've had a problem. distance=%d", dist_units);
     }
+
     pango_layout_set_text(pl, str, -1);
 
     pango_layout_get_pixel_size ( pl, &wd, &hd );
@@ -795,7 +883,19 @@ static VikLayerToolFuncStatus ruler_click (VikLayer *vl, GdkEventButton *event,
     vik_coord_to_latlon ( &coord, &ll );
     a_coords_latlon_to_string ( &ll, &lat, &lon );
     if ( s->has_oldcoord ) {
-      temp = g_strdup_printf ( "%s %s DIFF %f meters", lat, lon, vik_coord_diff( &coord, &(s->oldcoord) ) );
+      vik_units_distance_t dist_units = a_vik_get_units_distance ();
+      switch (dist_units) {
+      case VIK_UNITS_DISTANCE_KILOMETRES:
+       temp = g_strdup_printf ( "%s %s DIFF %f meters", lat, lon, vik_coord_diff( &coord, &(s->oldcoord) ) );
+       break;
+      case VIK_UNITS_DISTANCE_MILES:
+       temp = g_strdup_printf ( "%s %s DIFF %f miles", lat, lon, VIK_METERS_TO_MILES(vik_coord_diff( &coord, &(s->oldcoord) )) );
+       break;
+      default:
+       temp = g_strdup_printf ("Just to keep the compiler happy");
+       g_critical("Houston, we've had a problem. distance=%d", dist_units);
+      }
+
       s->has_oldcoord = FALSE;
     }
     else {
@@ -855,7 +955,18 @@ static VikLayerToolFuncStatus ruler_move (VikLayer *vl, GdkEventMotion *event, r
       draw_buf_done = FALSE;
     }
     a_coords_latlon_to_string(&ll, &lat, &lon);
-    temp = g_strdup_printf ( "%s %s DIFF %f meters", lat, lon, vik_coord_diff( &coord, &(s->oldcoord) ) );
+    vik_units_distance_t dist_units = a_vik_get_units_distance ();
+    switch (dist_units) {
+    case VIK_UNITS_DISTANCE_KILOMETRES:
+      temp = g_strdup_printf ( "%s %s DIFF %f meters", lat, lon, vik_coord_diff( &coord, &(s->oldcoord) ) );
+      break;
+    case VIK_UNITS_DISTANCE_MILES:
+      temp = g_strdup_printf ( "%s %s DIFF %f miles", lat, lon, VIK_METERS_TO_MILES (vik_coord_diff( &coord, &(s->oldcoord) )) );
+      break;
+    default:
+      temp = g_strdup_printf ("Just to keep the compiler happy");
+      g_critical("Houston, we've had a problem. distance=%d", dist_units);
+    }
     vik_statusbar_set_message ( vw->viking_vs, 3, temp );
     g_free ( temp );
   }
@@ -1100,6 +1211,20 @@ static void menu_properties_cb ( GtkAction *a, VikWindow *vw )
     a_dialog_info_msg ( GTK_WINDOW(vw), _("You must select a layer to show its properties.") );
 }
 
+static void help_help_cb ( GtkAction *a, VikWindow *vw )
+{
+#ifdef WINDOWS
+  ShellExecute(NULL, "open", ""PACKAGE".pdf", NULL, NULL, SW_SHOWNORMAL);
+#else /* WINDOWS */
+#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);
+  g_free(uri);
+#endif
+#endif /* WINDOWS */
+}
+
 static void help_about_cb ( GtkAction *a, VikWindow *vw )
 {
   a_dialog_about(GTK_WINDOW(vw));
@@ -1118,7 +1243,7 @@ static void menu_delete_layer_cb ( GtkAction *a, VikWindow *vw )
 
 static void view_side_panel_cb ( GtkAction *a, VikWindow *vw )
 {
-  GtkWidget *check_box = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/ViewSidePanel" );
+  GtkWidget *check_box = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/SetShow/ViewSidePanel" );
   g_assert(check_box);
   gboolean state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box));
   if ( state )
@@ -1127,6 +1252,42 @@ static void view_side_panel_cb ( GtkAction *a, VikWindow *vw )
     gtk_widget_hide(GTK_WIDGET(vw->viking_vlp));
 }
 
+static void view_statusbar_cb ( GtkAction *a, VikWindow *vw )
+{
+  GtkWidget *check_box = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/SetShow/ViewStatusBar" );
+  if ( !check_box )
+    return;
+  gboolean state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box) );
+  if ( state )
+    gtk_widget_show ( GTK_WIDGET(vw->viking_vs) );
+  else
+    gtk_widget_hide ( GTK_WIDGET(vw->viking_vs) );
+}
+
+static void view_toolbar_cb ( GtkAction *a, VikWindow *vw )
+{
+  GtkWidget *check_box = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/SetShow/ViewToolbar" );
+  if ( !check_box )
+    return;
+  gboolean state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box) );
+  if ( state )
+    gtk_widget_show ( GTK_WIDGET(vw->toolbar) );
+  else
+    gtk_widget_hide ( GTK_WIDGET(vw->toolbar) );
+}
+
+static void view_main_menu_cb ( GtkAction *a, VikWindow *vw )
+{
+  GtkWidget *check_box = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/SetShow/ViewMainMenu" );
+  if ( !check_box )
+    return;
+  gboolean state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box) );
+  if ( !state )
+    gtk_widget_hide ( gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu" ) );
+  else
+    gtk_widget_show ( gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu" ) );
+}
+
 /***************************************
  ** tool management routines
  **
@@ -1263,7 +1424,7 @@ static void menu_tool_cb ( GtkAction *old, GtkAction *a, VikWindow *vw )
 
   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, cursor );
+  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;
@@ -1317,12 +1478,9 @@ GtkWidget *vik_window_get_drawmode_button ( VikWindow *vw, VikViewportDrawMode m
   switch ( mode ) {
 #ifdef VIK_CONFIG_EXPEDIA
     case VIK_VIEWPORT_DRAWMODE_EXPEDIA: buttonname = "/ui/MainMenu/View/ModeExpedia"; break;
-#endif
-#ifdef VIK_CONFIG_OLD_GOOGLE
-    case VIK_VIEWPORT_DRAWMODE_GOOGLE: buttonname = "/ui/MainMenu/View/ModeGoogle"; break;
-    case VIK_VIEWPORT_DRAWMODE_KH: buttonname = "/ui/MainMenu/View/ModeKH"; break;
 #endif
     case VIK_VIEWPORT_DRAWMODE_MERCATOR: buttonname = "/ui/MainMenu/View/ModeMercator"; break;
+    case VIK_VIEWPORT_DRAWMODE_LATLON: buttonname = "/ui/MainMenu/View/ModeLatLon"; break;
     default: buttonname = "/ui/MainMenu/View/ModeUTM";
   }
   mode_button = gtk_ui_manager_get_widget ( vw->uim, buttonname );
@@ -1330,6 +1488,99 @@ GtkWidget *vik_window_get_drawmode_button ( VikWindow *vw, VikViewportDrawMode m
   return mode_button;
 }
 
+/**
+ * vik_window_get_pan_move:
+ * @vw: some VikWindow
+ *
+ * Retrieves @vw's pan_move.
+ *
+ * Should be removed as soon as possible.
+ *
+ * Returns: @vw's pan_move
+ *
+ * Since: 0.9.96
+ **/
+gboolean vik_window_get_pan_move ( VikWindow *vw )
+{
+  return vw->pan_move;
+}
+
+static void on_activate_recent_item (GtkRecentChooser *chooser,
+                                     VikWindow *self)
+{
+  gchar *filename;
+
+  filename = gtk_recent_chooser_get_current_uri (chooser);
+  if (filename != NULL)
+  {
+    GFile *file = g_file_new_for_uri ( filename );
+    gchar *path = g_file_get_path ( file );
+    g_object_unref ( file );
+    if ( self->filename )
+    {
+      gchar *filenames[] = { path, NULL };
+      g_signal_emit ( G_OBJECT(self), window_signals[VW_OPENWINDOW_SIGNAL], 0, filenames );
+    }
+    else
+      vik_window_open_file ( self, path, TRUE );
+    g_free ( path );
+  }
+
+  g_free (filename);
+}
+
+static void setup_recent_files (VikWindow *self)
+{
+  GtkRecentManager *manager;
+  GtkRecentFilter *filter;
+  GtkWidget *menu, *menu_item;
+
+  filter = gtk_recent_filter_new ();
+  /* gtk_recent_filter_add_application (filter, g_get_application_name()); */
+  gtk_recent_filter_add_group(filter, "viking");
+
+  manager = gtk_recent_manager_get_default ();
+  menu = gtk_recent_chooser_menu_new_for_manager (manager);
+  gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (menu), GTK_RECENT_SORT_MRU);
+  gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (menu), filter);
+
+  menu_item = gtk_ui_manager_get_widget (self->uim, "/ui/MainMenu/File/OpenRecentFile");
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);
+
+  g_signal_connect (G_OBJECT (menu), "item-activated",
+                    G_CALLBACK (on_activate_recent_item), (gpointer) self);
+}
+
+static void update_recently_used_document(const gchar *filename)
+{
+  /* Update Recently Used Document framework */
+  GtkRecentManager *manager = gtk_recent_manager_get_default();
+  GtkRecentData *recent_data = g_slice_new (GtkRecentData);
+  gchar *groups[] = {"viking", NULL};
+  GFile *file = g_file_new_for_commandline_arg(filename);
+  gchar *uri = g_file_get_uri(file);
+  gchar *basename = g_path_get_basename(filename);
+  g_object_unref(file);
+  file = NULL;
+
+  recent_data->display_name   = basename;
+  recent_data->description    = NULL;
+  recent_data->mime_type      = "text/x-gps-data";
+  recent_data->app_name       = (gchar *) g_get_application_name ();
+  recent_data->app_exec       = g_strjoin (" ", g_get_prgname (), "%f", NULL);
+  recent_data->groups         = groups;
+  recent_data->is_private     = FALSE;
+  if (!gtk_recent_manager_add_full (manager, uri, recent_data))
+  {
+    g_warning (_("Unable to add '%s' to the list of recently used documents"), uri);
+  }
+
+  g_free (uri);
+  g_free (basename);
+  g_free (recent_data->app_exec);
+  g_slice_free (GtkRecentData, recent_data);
+}
+
 void vik_window_open_file ( VikWindow *vw, const gchar *filename, gboolean change_filename )
 {
   switch ( a_file_load ( vik_layers_panel_get_top_layer(vw->viking_vlp), vw->viking_vvp, filename ) )
@@ -1340,6 +1591,7 @@ void vik_window_open_file ( VikWindow *vw, const gchar *filename, gboolean chang
     case 1:
     {
       GtkWidget *mode_button;
+      /* Update UI */
       if ( change_filename )
         window_set_filename ( vw, filename );
       mode_button = vik_window_get_drawmode_button ( vw, vik_viewport_get_drawmode ( vw->viking_vvp ) );
@@ -1348,16 +1600,22 @@ void vik_window_open_file ( VikWindow *vw, const gchar *filename, gboolean chang
       vw->only_updating_coord_mode_ui = FALSE;
 
       vik_layers_panel_change_coord_mode ( vw->viking_vlp, vik_viewport_get_coord_mode ( vw->viking_vvp ) );
-
-      mode_button = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/ShowScale" );
+      
+      mode_button = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/SetShow/ShowScale" );
       g_assert ( mode_button );
       gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(mode_button),vik_viewport_get_draw_scale(vw->viking_vvp) );
 
-      mode_button = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/ShowCenterMark" );
+      mode_button = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/SetShow/ShowCenterMark" );
       g_assert ( mode_button );
       gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(mode_button),vik_viewport_get_draw_centermark(vw->viking_vvp) );
+      
+      mode_button = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/SetShow/ShowHighlight" );
+      g_assert ( mode_button );
+      gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(mode_button),vik_viewport_get_draw_highlight (vw->viking_vvp) );
     }
-    default: draw_update ( vw );
+    default:
+      update_recently_used_document(filename);
+      draw_update ( vw );
   }
 }
 static void load_file ( GtkAction *a, VikWindow *vw )
@@ -1434,7 +1692,7 @@ static gboolean save_file_as ( GtkAction *a, VikWindow *vw )
   while ( gtk_dialog_run ( GTK_DIALOG(vw->save_dia) ) == GTK_RESPONSE_ACCEPT )
   {
     fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(vw->save_dia) );
-    if ( g_file_test ( fn, G_FILE_TEST_EXISTS ) == FALSE || a_dialog_overwrite ( GTK_WINDOW(vw->save_dia), _("The file \"%s\" exists, do you wish to overwrite it?"), a_file_basename ( fn ) ) )
+    if ( g_file_test ( fn, G_FILE_TEST_EXISTS ) == FALSE || a_dialog_yes_or_no ( GTK_WINDOW(vw->save_dia), _("The file \"%s\" exists, do you wish to overwrite it?"), a_file_basename ( fn ) ) )
     {
       window_set_filename ( vw, fn );
       rv = window_save ( vw );
@@ -1449,7 +1707,10 @@ static gboolean save_file_as ( GtkAction *a, VikWindow *vw )
 static gboolean window_save ( VikWindow *vw )
 {
   if ( a_file_save ( vik_layers_panel_get_top_layer ( vw->viking_vlp ), vw->viking_vvp, vw->filename ) )
+  {
+    update_recently_used_document ( vw->filename );
     return TRUE;
+  }
   else
   {
     a_dialog_error_msg ( GTK_WINDOW(vw), _("The filename you requested could not be opened for writing.") );
@@ -1485,14 +1746,74 @@ static void acquire_from_gc ( GtkAction *a, VikWindow *vw )
 }
 #endif
 
+static void goto_default_location( GtkAction *a, VikWindow *vw)
+{
+  struct LatLon ll;
+  ll.lat = a_vik_get_default_lat();
+  ll.lon = a_vik_get_default_long();
+  vik_viewport_set_center_latlon(vw->viking_vvp, &ll);
+  vik_layers_panel_emit_update(vw->viking_vlp);
+}
+
+
 static void goto_address( GtkAction *a, VikWindow *vw)
 {
-  a_google_search(vw, vw->viking_vlp, vw->viking_vvp);
+  a_vik_goto(vw, vw->viking_vlp, vw->viking_vvp);
+}
+
+static void mapcache_flush_cb ( GtkAction *a, VikWindow *vw )
+{
+  a_mapcache_flush();
 }
 
 static void preferences_cb ( GtkAction *a, VikWindow *vw )
 {
+  gboolean wp_icon_size = a_vik_get_use_large_waypoint_icons();
+
   a_preferences_show_window ( GTK_WINDOW(vw) );
+
+  // Delete icon indexing 'cache' and so automatically regenerates with the new setting when changed
+  if (wp_icon_size != a_vik_get_use_large_waypoint_icons())
+    clear_garmin_icon_syms ();
+
+  draw_update ( vw );
+}
+
+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[] = {
+    { VIKING_PREFERENCES_NAMESPACE "default_latitude",
+      VIK_LAYER_PARAM_DOUBLE,
+      VIK_LOCATION_LAT,
+      NULL,
+      VIK_LAYER_WIDGET_SPINBUTTON,
+      NULL,
+      NULL },
+  };
+  VikLayerParam pref_lon[] = {
+    { VIKING_PREFERENCES_NAMESPACE "default_longitude",
+      VIK_LAYER_PARAM_DOUBLE,
+      VIK_LOCATION_LONG,
+      NULL,
+      VIK_LAYER_WIDGET_SPINBUTTON,
+      NULL,
+      NULL },
+  };
+
+  /* Get current center */
+  struct LatLon ll;
+  vik_coord_to_latlon ( vik_viewport_get_center ( vw->viking_vvp ), &ll );
+
+  /* Apply to preferences */
+  VikLayerParamData vlp_data;
+  vlp_data.d = ll.lat;
+  a_preferences_run_setparam (vlp_data, pref_lat);
+  vlp_data.d = ll.lon;
+  a_preferences_run_setparam (vlp_data, pref_lon);
+  /* Remember to save */
+  a_preferences_save_to_file();
 }
 
 static void clear_cb ( GtkAction *a, VikWindow *vw )
@@ -1668,7 +1989,19 @@ static void draw_to_image_file_total_area_cb (GtkSpinButton *spinbutton, gpointe
     w *= gtk_spin_button_get_value(GTK_SPIN_BUTTON(pass_along[4]));
     h *= gtk_spin_button_get_value(GTK_SPIN_BUTTON(pass_along[5]));
   }
-  label_text = g_strdup_printf ( _("Total area: %ldm x %ldm (%.3f sq. km)"), (glong)w, (glong)h, (w*h/1000000));
+  vik_units_distance_t dist_units = a_vik_get_units_distance ();
+  switch (dist_units) {
+  case VIK_UNITS_DISTANCE_KILOMETRES:
+    label_text = g_strdup_printf ( _("Total area: %ldm x %ldm (%.3f sq. km)"), (glong)w, (glong)h, (w*h/1000000));
+    break;
+  case VIK_UNITS_DISTANCE_MILES:
+    label_text = g_strdup_printf ( _("Total area: %ldm x %ldm (%.3f sq. miles)"), (glong)w, (glong)h, (w*h/2589988.11));
+    break;
+  default:
+    label_text = g_strdup_printf ("Just to keep the compiler happy");
+    g_critical("Houston, we've had a problem. distance=%d", dist_units);
+  }
+
   gtk_label_set_text(GTK_LABEL(pass_along[6]), label_text);
   g_free ( label_text );
 }
@@ -1701,7 +2034,7 @@ static void draw_to_image_file ( VikWindow *vw, const gchar *fn, gboolean one_im
 
   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, 3 )), 16, 3);
+  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);
 
   total_size_label = gtk_label_new ( NULL );
 
@@ -1757,6 +2090,8 @@ static void draw_to_image_file ( VikWindow *vw, const gchar *fn, gboolean one_im
 
   draw_to_image_file_total_area_cb ( NULL, current_window_pass_along ); /* set correct size info now */
 
+  gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT );
+
   gtk_widget_show_all ( GTK_DIALOG(dialog)->vbox );
 
   if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT )
@@ -1787,7 +2122,7 @@ 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 )
 {
-  const gchar *fn;
+  gchar *fn;
   if (!vw->save_img_dia) {
     vw->save_img_dia = gtk_file_chooser_dialog_new (_("Save Image"),
                                      GTK_WINDOW(vw),
@@ -1802,11 +2137,13 @@ static void draw_to_image_file_cb ( GtkAction *a, VikWindow *vw )
   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_overwrite ( GTK_WINDOW(vw->save_img_dia), _("The file \"%s\" exists, do you wish to overwrite it?"), a_file_basename ( fn ) ) )
+    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 );
 }
@@ -1854,15 +2191,12 @@ static void window_change_coord_mode_cb ( GtkAction *old_a, GtkAction *a, VikWin
   if (!strcmp(gtk_action_get_name(a), "ModeUTM")) {
     drawmode = VIK_VIEWPORT_DRAWMODE_UTM;
   }
+  else if (!strcmp(gtk_action_get_name(a), "ModeLatLon")) {
+    drawmode = VIK_VIEWPORT_DRAWMODE_LATLON;
+  }
   else if (!strcmp(gtk_action_get_name(a), "ModeExpedia")) {
     drawmode = VIK_VIEWPORT_DRAWMODE_EXPEDIA;
   }
-  else if (!strcmp(gtk_action_get_name(a), "ModeGoogle")) {
-    drawmode = VIK_VIEWPORT_DRAWMODE_GOOGLE;
-  }
-  else if (!strcmp(gtk_action_get_name(a), "ModeKH")) {
-    drawmode = VIK_VIEWPORT_DRAWMODE_KH;
-  }
   else if (!strcmp(gtk_action_get_name(a), "ModeMercator")) {
     drawmode = VIK_VIEWPORT_DRAWMODE_MERCATOR;
   }
@@ -1890,7 +2224,7 @@ static void window_change_coord_mode_cb ( GtkAction *old_a, GtkAction *a, VikWin
 
 static void set_draw_scale ( GtkAction *a, VikWindow *vw )
 {
-  GtkWidget *check_box = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/ShowScale" );
+  GtkWidget *check_box = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/SetShow/ShowScale" );
   g_assert(check_box);
   gboolean state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box));
   vik_viewport_set_draw_scale ( vw->viking_vvp, state );
@@ -1899,13 +2233,22 @@ static void set_draw_scale ( GtkAction *a, VikWindow *vw )
 
 static void set_draw_centermark ( GtkAction *a, VikWindow *vw )
 {
-  GtkWidget *check_box = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/ShowCenterMark" );
+  GtkWidget *check_box = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/SetShow/ShowCenterMark" );
   g_assert(check_box);
   gboolean state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box));
   vik_viewport_set_draw_centermark ( vw->viking_vvp, state );
   draw_update ( vw );
 }
 
+static void set_draw_highlight ( GtkAction *a, VikWindow *vw )
+{
+  GtkWidget *check_box = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/SetShow/ShowHighlight" );
+  g_assert(check_box);
+  gboolean state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box));
+  vik_viewport_set_draw_highlight (  vw->viking_vvp, state );
+  draw_update ( vw );
+}
+
 static void set_bg_color ( GtkAction *a, VikWindow *vw )
 {
   GtkWidget *colorsd = gtk_color_selection_dialog_new ( _("Choose a background color") );
@@ -1922,6 +2265,22 @@ static void set_bg_color ( GtkAction *a, VikWindow *vw )
   gtk_widget_destroy ( colorsd );
 }
 
+static void set_highlight_color ( GtkAction *a, VikWindow *vw )
+{
+  GtkWidget *colorsd = gtk_color_selection_dialog_new ( _("Choose a track highlight color") );
+  GdkColor *color = vik_viewport_get_highlight_gdkcolor ( vw->viking_vvp );
+  gtk_color_selection_set_previous_color ( GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(colorsd)->colorsel), color );
+  gtk_color_selection_set_current_color ( GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(colorsd)->colorsel), color );
+  if ( gtk_dialog_run ( GTK_DIALOG(colorsd) ) == GTK_RESPONSE_OK )
+  {
+    gtk_color_selection_get_current_color ( GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(colorsd)->colorsel), color );
+    vik_viewport_set_highlight_gdkcolor ( vw->viking_vvp, color );
+    draw_update ( vw );
+  }
+  g_free ( color );
+  gtk_widget_destroy ( colorsd );
+}
+
 
 
 /***********************************************************************************************
@@ -1932,25 +2291,28 @@ static GtkActionEntry entries[] = {
   { "File", NULL, N_("_File"), 0, 0, 0 },
   { "Edit", NULL, N_("_Edit"), 0, 0, 0 },
   { "View", NULL, N_("_View"), 0, 0, 0 },
+  { "SetShow", NULL, N_("_Show"), 0, 0, 0 },
   { "SetZoom", NULL, N_("_Zoom"), 0, 0, 0 },
   { "SetPan", NULL, N_("_Pan"), 0, 0, 0 },
   { "Layers", NULL, N_("_Layers"), 0, 0, 0 },
   { "Tools", NULL, N_("_Tools"), 0, 0, 0 },
+  { "Exttools", NULL, N_("_Webtools"), 0, 0, 0 },
   { "Help", NULL, N_("_Help"), 0, 0, 0 },
 
   { "New",       GTK_STOCK_NEW,          N_("_New"),                          "<control>N", N_("New file"),                                     (GCallback)newwindow_cb          },
-  { "Open",      GTK_STOCK_OPEN,         N_("_Open"),                         "<control>O", N_("Open a file"),                                  (GCallback)load_file             },
-  { "Append",    GTK_STOCK_ADD,          N_("A_ppend File"),                  NULL,         N_("Append data from a different file"),            (GCallback)load_file             },
+  { "Open",      GTK_STOCK_OPEN,         N_("_Open..."),                         "<control>O", N_("Open a file"),                                  (GCallback)load_file             },
+  { "OpenRecentFile", NULL,              N_("Open _Recent File"),         NULL,         NULL,                                               (GCallback)NULL },
+  { "Append",    GTK_STOCK_ADD,          N_("Append _File..."),           NULL,         N_("Append data from a different file"),            (GCallback)load_file             },
   { "Acquire", NULL, N_("A_cquire"), 0, 0, 0 },
-  { "AcquireGPS",   NULL,                N_("From _GPS"),                NULL,         N_("Transfer data from a GPS device"),              (GCallback)acquire_from_gps      },
-  { "AcquireGoogle",   NULL,             N_("Google _Directions"),       NULL,         N_("Get driving directions from Google"),           (GCallback)acquire_from_google   },
+  { "AcquireGPS",   NULL,                N_("From _GPS..."),                     NULL,         N_("Transfer data from a GPS device"),              (GCallback)acquire_from_gps      },
+  { "AcquireGoogle",   NULL,             N_("Google _Directions..."),     NULL,         N_("Get driving directions from Google"),           (GCallback)acquire_from_google   },
 #ifdef VIK_CONFIG_GEOCACHES
-  { "AcquireGC",   NULL,                 N_("Geo_caches"),               NULL,         N_("Get Geocaches from geocaching.com"),            (GCallback)acquire_from_gc       },
+  { "AcquireGC",   NULL,                 N_("Geo_caches..."),            NULL,         N_("Get Geocaches from geocaching.com"),            (GCallback)acquire_from_gc       },
 #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          },
-  { "GenImg",    GTK_STOCK_CLEAR,        N_("_Generate Image File"),          NULL,         N_("Save a snapshot of the workspace into a file"), (GCallback)draw_to_image_file_cb },
-  { "GenImgDir", GTK_STOCK_DND_MULTIPLE, N_("Generate _Directory of Images"), NULL,         N_("FIXME:IMGDIR"),                                 (GCallback)draw_to_image_dir_cb  },
+  { "SaveAs",    GTK_STOCK_SAVE_AS,      N_("Save _As..."),                      NULL,  N_("Save the file under different name"),           (GCallback)save_file_as          },
+  { "GenImg",    GTK_STOCK_CLEAR,        N_("_Generate Image File..."),          NULL,  N_("Save a snapshot of the workspace into a file"), (GCallback)draw_to_image_file_cb },
+  { "GenImgDir", GTK_STOCK_DND_MULTIPLE, N_("Generate _Directory of Images..."), NULL,  N_("FIXME:IMGDIR"),                                 (GCallback)draw_to_image_dir_cb  },
 
 #if GTK_CHECK_VERSION(2,10,0)
   { "Print",    GTK_STOCK_PRINT,        N_("_Print..."),          NULL,         N_("Print maps"), (GCallback)print_cb },
@@ -1959,13 +2321,15 @@ static GtkActionEntry entries[] = {
   { "Exit",      GTK_STOCK_QUIT,         N_("E_xit"),                         "<control>W", N_("Exit the program"),                             (GCallback)window_close          },
   { "SaveExit",  GTK_STOCK_QUIT,         N_("Save and Exit"),                 NULL, N_("Save and Exit the program"),                             (GCallback)save_file_and_exit          },
 
-  { "GoogleMapsSearch",   GTK_STOCK_JUMP_TO,                 N_("Go To Google Maps location"),                   NULL,         N_("Go to address/place using Google Maps search"),            (GCallback)goto_address       },
-  { "GotoLL",    GTK_STOCK_QUIT,         N_("_Go to Lat\\/Lon..."),           NULL,         N_("Go to arbitrary lat\\/lon coordinate"),         (GCallback)draw_goto_cb          },
-  { "GotoUTM",   GTK_STOCK_QUIT,         N_("Go to UTM..."),                  NULL,         N_("Go to arbitrary UTM coordinate"),               (GCallback)draw_goto_cb          },
-  { "SetBGColor",GTK_STOCK_SELECT_COLOR, N_("Set Background Color..."),       NULL,         NULL,                                           (GCallback)set_bg_color          },
+  { "GotoDefaultLocation", GTK_STOCK_HOME, N_("Go to the _Default Location"),  NULL,         N_("Go to the default location"),                     (GCallback)goto_default_location },
+  { "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          },
+  { "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            },
+  { "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          },
@@ -1976,10 +2340,18 @@ static GtkActionEntry entries[] = {
   { "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          },
-  { "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 },
-  { "PanWest",  NULL,                    N_("Pan West"),                   "<control>Left", NULL,                                           (GCallback)draw_pan_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 },
+  { "PanWest",   NULL,                   N_("Pan _West"),                 "<control>Left",  NULL,                                           (GCallback)draw_pan_cb },
   { "BGJobs",    GTK_STOCK_EXECUTE,      N_("Background _Jobs"),              NULL,         NULL,                                           (GCallback)a_background_show_window },
 
   { "Cut",       GTK_STOCK_CUT,          N_("Cu_t"),                          NULL,         NULL,                                           (GCallback)menu_cut_layer_cb     },
@@ -1987,19 +2359,22 @@ static GtkActionEntry entries[] = {
   { "Paste",     GTK_STOCK_PASTE,        N_("_Paste"),                        NULL,         NULL,                                           (GCallback)menu_paste_layer_cb   },
   { "Delete",    GTK_STOCK_DELETE,       N_("_Delete"),                       NULL,         NULL,                                           (GCallback)menu_delete_layer_cb  },
   { "DeleteAll", NULL,                   N_("Delete All"),                    NULL,         NULL,                                           (GCallback)clear_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              },
   { "Properties",GTK_STOCK_PROPERTIES,   N_("_Properties"),                   NULL,         NULL,                                           (GCallback)menu_properties_cb    },
 
+  { "HelpEntry", GTK_STOCK_HELP,         N_("_Help"),                         "F1",         NULL,                                           (GCallback)help_help_cb     },
   { "About",     GTK_STOCK_ABOUT,        N_("_About"),                        NULL,         NULL,                                           (GCallback)help_about_cb    },
 };
 
 /* Radio items */
+/* FIXME use VIEWPORT_DRAWMODE values */
 static GtkRadioActionEntry mode_entries[] = {
   { "ModeUTM",         NULL,         N_("_UTM Mode"),               "<control>u", NULL, 0 },
   { "ModeExpedia",     NULL,         N_("_Expedia Mode"),           "<control>e", NULL, 1 },
-  { "ModeGoogle",      NULL,         N_("_Old Google Mode"),        "<control>o", NULL, 2 },
-  { "ModeKH",          NULL,         N_("Old _KH Mode"),            "<control>k", NULL, 3 },
-  { "ModeMercator",    NULL,         N_("_Google Mode"),            "<control>g", NULL, 4 }
+  { "ModeMercator",    NULL,         N_("_Mercator Mode"),            "<control>m", NULL, 4 },
+  { "ModeLatLon",      NULL,         N_("Lat_/Lon Mode"),           "<control>l", NULL, 5 },
 };
 
 static GtkRadioActionEntry tool_entries[] = {
@@ -2009,10 +2384,14 @@ static GtkRadioActionEntry tool_entries[] = {
 };
 
 static GtkToggleActionEntry toggle_entries[] = {
-  { "ShowScale", NULL,                   N_("Show Scale"),                    NULL,         N_("Show Scale"),                                           (GCallback)set_draw_scale, TRUE   },
-  { "ShowCenterMark", NULL,                   N_("Show Center Mark"),                    NULL,         N_("Show Center Mark"),                                           (GCallback)set_draw_centermark, TRUE   },
-  { "FullScreen",    GTK_STOCK_FULLSCREEN,      N_("Full Screen"),                   "F11", N_("Activate full screen mode"),                                           (GCallback)full_screen_cb, FALSE },
-  { "ViewSidePanel", GTK_STOCK_INDEX,   N_("Show Side Panel"),                   "F9",         N_("Show Side Panel"),                                           (GCallback)view_side_panel_cb, TRUE    },
+  { "ShowScale",      NULL,                 N_("Show _Scale"),               "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 },
+  { "ViewSidePanel",  GTK_STOCK_INDEX,      N_("Show Side _Panel"),          "F9",         N_("Show Side Panel"),                         (GCallback)view_side_panel_cb, TRUE },
+  { "ViewStatusBar",  NULL,                 N_("Show Status_bar"),           "F12",        N_("Show Statusbar"),                          (GCallback)view_statusbar_cb, TRUE },
+  { "ViewToolbar",    NULL,                 N_("Show _Toolbar"),             "F3",         N_("Show Toolbar"),                            (GCallback)view_toolbar_cb, TRUE },
+  { "ViewMainMenu",   NULL,                 N_("Show _Menu"),                "F4",         N_("Show Menu"),                               (GCallback)view_main_menu_cb, TRUE },
 };
 
 #include "menu.xml.h"
@@ -2128,6 +2507,8 @@ static void window_create_ui( VikWindow *window )
   accel_group = gtk_ui_manager_get_accel_group (uim);
   gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
   gtk_ui_manager_ensure_update (uim);
+  
+  setup_recent_files(window);
 }
 
 
@@ -2150,7 +2531,6 @@ static struct {
   { &geozoom_18_pixbuf,                "Georef Zoom Tool"  },
   { &geomove_18_pixbuf,                "Georef Move Map"   },
   { &mapdl_18_pixbuf,          "Maps Download"     },
-  { &showpic_18_pixbuf,                "Show Picture"      },
 };
  
 static gint n_stock_icons = G_N_ELEMENTS (stock_icons);
@@ -2169,3 +2549,102 @@ register_vik_icons (GtkIconFactory *icon_factory)
   }
 }
 
+gpointer vik_window_get_selected_trw_layer ( VikWindow *vw )
+{
+  return vw->selected_vtl;
+}
+
+void vik_window_set_selected_trw_layer ( VikWindow *vw, gpointer vtl )
+{
+  vw->selected_vtl = vtl;
+  /* Clear others */
+  vw->selected_track     = NULL;
+  vw->selected_tracks    = NULL;
+  vw->selected_waypoint  = NULL;
+  vw->selected_waypoints = NULL;
+}
+
+gpointer vik_window_get_selected_tracks ( VikWindow *vw )
+{
+  return vw->selected_tracks;
+}
+
+void vik_window_set_selected_tracks ( VikWindow *vw, gpointer gl )
+{
+  vw->selected_tracks = gl;
+  /* Clear others */
+  vw->selected_vtl       = NULL;
+  vw->selected_track     = NULL;
+  vw->selected_waypoint  = NULL;
+  vw->selected_waypoints = NULL;
+}
+
+gpointer vik_window_get_selected_track ( VikWindow *vw )
+{
+  return vw->selected_track;
+}
+
+void vik_window_set_selected_track ( VikWindow *vw, gpointer *vt )
+{
+  vw->selected_track = vt;
+  /* Clear others */
+  vw->selected_vtl       = NULL;
+  vw->selected_tracks    = NULL;
+  vw->selected_waypoint  = NULL;
+  vw->selected_waypoints = NULL;
+}
+gpointer vik_window_get_selected_waypoints ( VikWindow *vw )
+{
+  return vw->selected_waypoints;
+}
+
+void vik_window_set_selected_waypoints ( VikWindow *vw, gpointer gl )
+{
+  vw->selected_waypoints = gl;
+  /* Clear others */
+  vw->selected_vtl       = NULL;
+  vw->selected_track     = NULL;
+  vw->selected_tracks    = NULL;
+  vw->selected_waypoint  = NULL;
+}
+
+gpointer vik_window_get_selected_waypoint ( VikWindow *vw )
+{
+  return vw->selected_waypoint;
+}
+
+void vik_window_set_selected_waypoint ( VikWindow *vw, gpointer *vwp )
+{
+  vw->selected_waypoint = vwp;
+  /* Clear others */
+  vw->selected_vtl       = NULL;
+  vw->selected_track     = NULL;
+  vw->selected_tracks    = NULL;
+  vw->selected_waypoints = NULL;
+}
+
+gboolean vik_window_clear_highlight ( VikWindow *vw )
+{
+  gboolean need_redraw = FALSE;
+  if ( vw->selected_vtl != NULL ) {
+    vw->selected_vtl = NULL;
+    need_redraw = TRUE;
+  }
+  if ( vw->selected_track != NULL ) {
+    vw->selected_track = NULL;
+    need_redraw = TRUE;
+  }
+  if ( vw->selected_tracks != NULL ) {
+    vw->selected_tracks = NULL;
+    need_redraw = TRUE;
+  }
+  if ( vw->selected_waypoint != NULL ) {
+    vw->selected_waypoint = NULL;
+    need_redraw = TRUE;
+  }
+  if ( vw->selected_waypoints != NULL ) {
+    vw->selected_waypoints = NULL;
+    need_redraw = TRUE;
+  }
+  return need_redraw;
+}