]> git.street.me.uk Git - andy/viking.git/blobdiff - src/vikwindow.c
Fix printing of DEBUG message since glib 2.32
[andy/viking.git] / src / vikwindow.c
index 6343af64d06b3e72cbe34439f0a6ba36050fa168..51c51ba9d02f2cd7bf26f53733a0a58bc3c59dae 100644 (file)
@@ -87,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_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 */
 
 
 /* End Drawing Functions */
 
@@ -168,12 +168,29 @@ struct _VikWindow {
   /* half-drawn update */
   VikLayer *trigger;
   VikCoord trigger_center;
   /* 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 */
+  /* 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 */
 };
 
 enum {
  TOOL_PAN = 0,
  TOOL_ZOOM,
  TOOL_RULER,
 };
 
 enum {
  TOOL_PAN = 0,
  TOOL_ZOOM,
  TOOL_RULER,
+ TOOL_SELECT,
  TOOL_LAYER,
  NUMBER_OF_TOOLS
 };
  TOOL_LAYER,
  NUMBER_OF_TOOLS
 };
@@ -186,7 +203,7 @@ enum {
 
 static guint window_signals[VW_LAST_SIGNAL] = { 0 };
 
 
 static guint window_signals[VW_LAST_SIGNAL] = { 0 };
 
-static gchar *tool_names[NUMBER_OF_TOOLS] = { N_("Pan"), N_("Zoom"), N_("Ruler") };
+static gchar *tool_names[NUMBER_OF_TOOLS] = { N_("Pan"), N_("Zoom"), N_("Ruler"), N_("Select") };
 
 GType vik_window_get_type (void)
 {
 
 GType vik_window_get_type (void)
 {
@@ -217,6 +234,19 @@ VikViewport * vik_window_viewport(VikWindow *vw)
   return(vw->viking_vvp);
 }
 
   return(vw->viking_vvp);
 }
 
+VikLayersPanel * vik_window_layers_panel(VikWindow *vw)
+{
+  return(vw->viking_vlp);
+}
+
+/**
+ *  Returns the statusbar for the window
+ */
+VikStatusbar * vik_window_get_statusbar ( VikWindow *vw )
+{
+  return vw->viking_vs;
+}
+
 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;
@@ -351,6 +381,11 @@ 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 );
+  }
+
   /* 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 ) {
   /* 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 ) {
@@ -427,11 +462,11 @@ static void draw_status ( VikWindow *vw )
       /* 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 )
       /* 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 );
+    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
   else
-    vik_statusbar_set_message ( vw->viking_vs, 0, _(tool_names[vw->current_tool]) );
+    vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_TOOL, _(tool_names[vw->current_tool]) );
 
 
-  vik_statusbar_set_message ( vw->viking_vs, 2, zoom_level );
+  vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_ZOOM, zoom_level );
 }
 
 void vik_window_set_redraw_trigger(VikLayer *vl)
 }
 
 void vik_window_set_redraw_trigger(VikLayer *vl)
@@ -477,6 +512,7 @@ static void draw_redraw ( VikWindow *vw )
   vik_viewport_draw_scale ( vw->viking_vvp );
   vik_viewport_draw_copyright ( vw->viking_vvp );
   vik_viewport_draw_centermark ( vw->viking_vvp );
   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. */
 }
 
   vik_viewport_set_half_drawn ( vw->viking_vvp, FALSE ); /* just in case. */
 }
@@ -577,7 +613,7 @@ static void draw_mouse_motion (VikWindow *vw, GdkEventMotion *event)
   lat = NULL;
   g_free (lon);
   lon = NULL;
   lat = NULL;
   g_free (lon);
   lon = NULL;
-  vik_statusbar_set_message ( vw->viking_vs, 4, pointer_buf );
+  vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_POSITION, pointer_buf );
 
   vik_window_pan_move ( vw, event );
 
 
   vik_window_pan_move ( vw, event );
 
@@ -889,7 +925,7 @@ static VikLayerToolFuncStatus ruler_click (VikLayer *vl, GdkEventButton *event,
       s->has_oldcoord = TRUE;
     }
 
       s->has_oldcoord = TRUE;
     }
 
-    vik_statusbar_set_message ( s->vw->viking_vs, 3, temp );
+    vik_statusbar_set_message ( s->vw->viking_vs, VIK_STATUSBAR_INFO, temp );
     g_free ( temp );
 
     s->oldcoord = coord;
     g_free ( temp );
 
     s->oldcoord = coord;
@@ -953,7 +989,7 @@ static VikLayerToolFuncStatus ruler_move (VikLayer *vl, GdkEventMotion *event, r
       temp = g_strdup_printf ("Just to keep the compiler happy");
       g_critical("Houston, we've had a problem. distance=%d", dist_units);
     }
       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 );
+    vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_INFO, temp );
     g_free ( temp );
   }
   return VIK_LAYER_TOOL_ACK;
     g_free ( temp );
   }
   return VIK_LAYER_TOOL_ACK;
@@ -969,6 +1005,16 @@ static void ruler_deactivate (VikLayer *vl, ruler_tool_state_t *s)
   draw_update ( s->vw );
 }
 
   draw_update ( s->vw );
 }
 
+static gboolean ruler_key_press (VikLayer *vl, GdkEventKey *event, ruler_tool_state_t *s)
+{
+  if (event->keyval == GDK_Escape) {
+    s->has_oldcoord = FALSE;
+    ruler_deactivate ( vl, s );
+    return TRUE;
+  }
+  return FALSE;
+}
+
 static VikToolInterface ruler_tool = 
   { "Ruler", 
     (VikToolConstructorFunc) ruler_create,
 static VikToolInterface ruler_tool = 
   { "Ruler", 
     (VikToolConstructorFunc) ruler_create,
@@ -978,7 +1024,7 @@ static VikToolInterface ruler_tool =
     (VikToolMouseFunc) ruler_click, 
     (VikToolMouseMoveFunc) ruler_move, 
     (VikToolMouseFunc) ruler_release,
     (VikToolMouseFunc) ruler_click, 
     (VikToolMouseMoveFunc) ruler_move, 
     (VikToolMouseFunc) ruler_release,
-    NULL,
+    (VikToolKeyFunc) ruler_key_press,
     GDK_CURSOR_IS_PIXMAP,
     &cursor_ruler_pixbuf };
 /*** end ruler code ********************************************************/
     GDK_CURSOR_IS_PIXMAP,
     &cursor_ruler_pixbuf };
 /*** end ruler code ********************************************************/
@@ -1072,6 +1118,124 @@ static VikToolInterface pan_tool =
     GDK_FLEUR };
 /*** end pan code ********************************************************/
 
     GDK_FLEUR };
 /*** end pan code ********************************************************/
 
+/********************************************************************************
+ ** Select tool code
+ ********************************************************************************/
+static gpointer selecttool_create (VikWindow *vw, VikViewport *vvp)
+{
+  tool_ed_t *t = g_new(tool_ed_t, 1);
+  t->vw = vw;
+  t->vvp = vvp;
+  t->vtl = NULL;
+  t->is_waypoint = FALSE;
+  return t;
+}
+
+static void selecttool_destroy (tool_ed_t *t)
+{
+  g_free(t);
+}
+
+typedef struct {
+  gboolean cont;
+  VikViewport *vvp;
+  GdkEventButton *event;
+  tool_ed_t *tool_edit;
+} clicker;
+
+static void click_layer_selected (VikLayer *vl, clicker *ck)
+{
+  /* Do nothing when function call returns true; */
+  /* i.e. stop on first found item */
+  if ( ck->cont )
+    if ( vl->visible )
+      if ( vik_layer_get_interface(vl->type)->select_click )
+       ck->cont = !vik_layer_get_interface(vl->type)->select_click ( vl, ck->event, ck->vvp, ck->tool_edit );
+}
+
+static VikLayerToolFuncStatus selecttool_click (VikLayer *vl, GdkEventButton *event, tool_ed_t *t)
+{
+  /* Only allow selection on primary button */
+  if ( event->button == 1 ) {
+    /* Enable click to apply callback to potentially all track/waypoint layers */
+    /* Useful as we can find things that aren't necessarily in the currently selected layer */
+    GList* gl = vik_layers_panel_get_all_layers_of_type ( t->vw->viking_vlp, VIK_LAYER_TRW, FALSE ); // Don't get invisible layers
+    clicker ck;
+    ck.cont = TRUE;
+    ck.vvp = t->vw->viking_vvp;
+    ck.event = event;
+    ck.tool_edit = t;
+    g_list_foreach ( gl, (GFunc) click_layer_selected, &ck );
+    g_list_free ( gl );
+
+    // If nothing found then deselect & redraw screen if necessary to remove the highlight
+    if ( ck.cont ) {
+      GtkTreeIter iter;
+      VikTreeview *vtv = vik_layers_panel_get_treeview ( t->vw->viking_vlp );
+
+      if ( vik_treeview_get_selected_iter ( vtv, &iter ) ) {
+       // Only clear if selected thing is a TrackWaypoint layer or a sublayer
+       gint type = vik_treeview_item_get_type ( vtv, &iter );
+       if ( type == VIK_TREEVIEW_TYPE_SUBLAYER ||
+            VIK_LAYER(vik_treeview_item_get_pointer ( vtv, &iter ))->type == VIK_LAYER_TRW ) {
+   
+         vik_treeview_item_unselect ( vtv, &iter );
+         if ( vik_window_clear_highlight ( t->vw ) )
+           draw_update ( t->vw );
+       }
+      }
+    }
+  }
+  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 ( vik_layer_get_interface(vl->type)->show_viewport_menu )
+         vik_layer_get_interface(vl->type)->show_viewport_menu ( vl, event, t->vw->viking_vvp );
+  }
+
+  return VIK_LAYER_TOOL_ACK;
+}
+
+static VikLayerToolFuncStatus selecttool_move (VikLayer *vl, GdkEventButton *event, tool_ed_t *t)
+{
+  /* Only allow selection on primary button */
+  if ( event->button == 1 ) {
+    // Don't care about vl here
+    if ( t->vtl )
+      if ( vik_layer_get_interface(VIK_LAYER_TRW)->select_move )
+       vik_layer_get_interface(VIK_LAYER_TRW)->select_move ( vl, event, t->vvp, t );
+  }
+  return VIK_LAYER_TOOL_ACK;
+}
+
+static VikLayerToolFuncStatus selecttool_release (VikLayer *vl, GdkEventButton *event, tool_ed_t *t)
+{
+  /* Only allow selection on primary button */
+  if ( event->button == 1 ) {
+    // Don't care about vl here
+    if ( t->vtl )
+      if ( vik_layer_get_interface(VIK_LAYER_TRW)->select_release )
+       vik_layer_get_interface(VIK_LAYER_TRW)->select_release ( (VikLayer*)t->vtl, event, t->vvp, t );
+  }
+  return VIK_LAYER_TOOL_ACK;
+}
+
+static VikToolInterface select_tool =
+  { "Select",
+    (VikToolConstructorFunc) selecttool_create,
+    (VikToolDestructorFunc) selecttool_destroy,
+    (VikToolActivationFunc) NULL,
+    (VikToolActivationFunc) NULL,
+    (VikToolMouseFunc) selecttool_click,
+    (VikToolMouseMoveFunc) selecttool_move,
+    (VikToolMouseFunc) selecttool_release,
+    (VikToolKeyFunc) NULL,
+    GDK_LEFT_PTR,
+    NULL,
+    NULL };
+/*** end select tool code ********************************************************/
+
 static void draw_pan_cb ( GtkAction *a, VikWindow *vw )
 {
   if (!strcmp(gtk_action_get_name(a), "PanNorth")) {
 static void draw_pan_cb ( GtkAction *a, VikWindow *vw )
 {
   if (!strcmp(gtk_action_get_name(a), "PanNorth")) {
@@ -1178,15 +1342,14 @@ static void menu_copy_layer_cb ( GtkAction *a, VikWindow *vw )
 
 static void menu_cut_layer_cb ( GtkAction *a, VikWindow *vw )
 {
 
 static void menu_cut_layer_cb ( GtkAction *a, VikWindow *vw )
 {
-  a_clipboard_copy_selected ( vw->viking_vlp );
-  menu_delete_layer_cb ( a, vw );
+  vik_layers_panel_cut_selected ( vw->viking_vlp );
+  vw->modified = TRUE;
 }
 
 static void menu_paste_layer_cb ( GtkAction *a, VikWindow *vw )
 {
   if ( a_clipboard_paste ( vw->viking_vlp ) )
   {
 }
 
 static void menu_paste_layer_cb ( GtkAction *a, VikWindow *vw )
 {
   if ( a_clipboard_paste ( vw->viking_vlp ) )
   {
-    draw_update ( vw );
     vw->modified = TRUE;
   }
 }
     vw->modified = TRUE;
   }
 }
@@ -1199,12 +1362,16 @@ static void menu_properties_cb ( GtkAction *a, VikWindow *vw )
 
 static void help_help_cb ( GtkAction *a, VikWindow *vw )
 {
 
 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
 #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 )
 }
 
 static void help_about_cb ( GtkAction *a, VikWindow *vw )
@@ -1417,6 +1584,9 @@ static void menu_tool_cb ( GtkAction *old, GtkAction *a, VikWindow *vw )
   else if (!strcmp(gtk_action_get_name(a), "Ruler")) {
     vw->current_tool = TOOL_RULER;
   }
   else if (!strcmp(gtk_action_get_name(a), "Ruler")) {
     vw->current_tool = TOOL_RULER;
   }
+  else if (!strcmp(gtk_action_get_name(a), "Select")) {
+    vw->current_tool = TOOL_SELECT;
+  }
   else {
     /* TODO: only enable tools from active layer */
     for (layer_id=0; layer_id<VIK_LAYER_NUM_TYPES; layer_id++) {
   else {
     /* TODO: only enable tools from active layer */
     for (layer_id=0; layer_id<VIK_LAYER_NUM_TYPES; layer_id++) {
@@ -1500,12 +1670,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);
@@ -1567,10 +1740,16 @@ void vik_window_open_file ( VikWindow *vw, const gchar *filename, gboolean chang
 {
   switch ( a_file_load ( vik_layers_panel_get_top_layer(vw->viking_vlp), vw->viking_vvp, filename ) )
   {
 {
   switch ( a_file_load ( vik_layers_panel_get_top_layer(vw->viking_vlp), vw->viking_vvp, filename ) )
   {
-    case 0:
+    case LOAD_TYPE_READ_FAILURE:
       a_dialog_error_msg ( GTK_WINDOW(vw), _("The file you requested could not be opened.") );
       break;
       a_dialog_error_msg ( GTK_WINDOW(vw), _("The file you requested could not be opened.") );
       break;
-    case 1:
+    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_UNSUPPORTED_FAILURE:
+      a_dialog_error_msg_extra ( GTK_WINDOW(vw), _("Unsupported file type for %s"), filename );
+      break;
+    case LOAD_TYPE_VIK_SUCCESS:
     {
       GtkWidget *mode_button;
       /* Update UI */
     {
       GtkWidget *mode_button;
       /* Update UI */
@@ -1582,7 +1761,7 @@ 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 ) );
       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/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/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) );
@@ -1590,10 +1769,16 @@ void vik_window_open_file ( VikWindow *vw, const gchar *filename, gboolean chang
       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/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) );
     }
     }
+    //case LOAD_TYPE_OTHER_SUCCESS:
     default:
       update_recently_used_document(filename);
       draw_update ( vw );
     default:
       update_recently_used_document(filename);
       draw_update ( vw );
+      break;
   }
 }
 static void load_file ( GtkAction *a, VikWindow *vw )
   }
 }
 static void load_file ( GtkAction *a, VikWindow *vw )
@@ -1620,6 +1805,42 @@ static void load_file ( GtkAction *a, VikWindow *vw )
                                      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                      GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                                      NULL);
                                      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                      GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                                      NULL);
+    GtkFileFilter *filter;
+    // NB file filters are listed this way for alphabetical ordering
+#ifdef VIK_CONFIG_GEOCACHES
+    filter = gtk_file_filter_new ();
+    gtk_file_filter_set_name( filter, _("Geocaching") );
+    gtk_file_filter_add_pattern ( filter, "*.loc" ); // No MIME type available
+    gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(vw->open_dia), filter);
+#endif
+
+    filter = gtk_file_filter_new ();
+    gtk_file_filter_set_name( filter, _("Google Earth") );
+    gtk_file_filter_add_mime_type ( filter, "application/vnd.google-earth.kml+xml");
+    gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(vw->open_dia), filter);
+
+    filter = gtk_file_filter_new ();
+    gtk_file_filter_set_name( filter, _("GPX") );
+    gtk_file_filter_add_pattern ( filter, "*.gpx" ); // No MIME type available
+    gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(vw->open_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->open_dia), filter);
+
+    // NB could have filters for gpspoint (*.gps,*.gpsoint?) + gpsmapper (*.gsm,*.gpsmapper?)
+    // However assume this are barely used and thus not worthy of inclusion
+    //   as they'll just make the options too many and have no clear file pattern
+    //   one can always use the all option
+    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->open_dia), filter);
+    // Default to any file - same as before open filters were added
+    gtk_file_chooser_set_filter (GTK_FILE_CHOOSER(vw->open_dia), filter);
+
     gtk_file_chooser_set_select_multiple ( GTK_FILE_CHOOSER(vw->open_dia), TRUE );
     gtk_window_set_transient_for ( GTK_WINDOW(vw->open_dia), GTK_WINDOW(vw) );
     gtk_window_set_destroy_with_parent ( GTK_WINDOW(vw->open_dia), TRUE );
     gtk_file_chooser_set_select_multiple ( GTK_FILE_CHOOSER(vw->open_dia), TRUE );
     gtk_window_set_transient_for ( GTK_WINDOW(vw->open_dia), GTK_WINDOW(vw) );
     gtk_window_set_destroy_with_parent ( GTK_WINDOW(vw->open_dia), TRUE );
@@ -1709,14 +1930,31 @@ static gboolean save_file ( GtkAction *a, VikWindow *vw )
 
 static void acquire_from_gps ( GtkAction *a, VikWindow *vw )
 {
 
 static void acquire_from_gps ( GtkAction *a, VikWindow *vw )
 {
+  // Via the file menu, acquiring from a GPS makes a new layer
+  //  this has always been the way (not entirely sure if this was the real intention!)
+  //  thus maintain the behaviour ATM.
+  // Hence explicit setting here (as the value may be changed elsewhere)
+  vik_datasource_gps_interface.mode = VIK_DATASOURCE_CREATENEWLAYER;
   a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_gps_interface );
 }
 
   a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_gps_interface );
 }
 
+static void acquire_from_file ( GtkAction *a, VikWindow *vw )
+{
+  a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_file_interface );
+}
+
 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 );
 }
 
+#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 );
+}
+#endif
+
 #ifdef VIK_CONFIG_GEOCACHES
 static void acquire_from_gc ( GtkAction *a, VikWindow *vw )
 {
 #ifdef VIK_CONFIG_GEOCACHES
 static void acquire_from_gc ( GtkAction *a, VikWindow *vw )
 {
@@ -1724,6 +1962,14 @@ 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
+
 static void goto_default_location( GtkAction *a, VikWindow *vw)
 {
   struct LatLon ll;
 static void goto_default_location( GtkAction *a, VikWindow *vw)
 {
   struct LatLon ll;
@@ -2082,16 +2328,14 @@ static void draw_to_image_file ( VikWindow *vw, const gchar *fn, gboolean one_im
                       gtk_spin_button_get_value ( GTK_SPIN_BUTTON(zoom_spin) ), /* do not save this value, default is current zoom */
                       vw->draw_image_save_as_png = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(png_radio) ) );
     else {
                       gtk_spin_button_get_value ( GTK_SPIN_BUTTON(zoom_spin) ), /* do not save this value, default is current zoom */
                       vw->draw_image_save_as_png = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(png_radio) ) );
     else {
-      if ( vik_viewport_get_coord_mode(vw->viking_vvp) == VIK_COORD_UTM )
-        save_image_dir ( vw, fn, 
+      // 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 */
                        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_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 */
                        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) ) );
-      else
-        a_dialog_error_msg ( GTK_WINDOW(vw), _("You must be in UTM mode to use this feature") );
     }
   }
   gtk_widget_destroy ( GTK_WIDGET(dialog) );
     }
   }
   gtk_widget_destroy ( GTK_WIDGET(dialog) );
@@ -2130,6 +2374,11 @@ static void draw_to_image_dir_cb ( GtkAction *a, VikWindow *vw )
 {
   gchar *fn = NULL;
   
 {
   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),
   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),
@@ -2218,6 +2467,15 @@ static void set_draw_centermark ( GtkAction *a, VikWindow *vw )
   draw_update ( vw );
 }
 
   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") );
 static void set_bg_color ( GtkAction *a, VikWindow *vw )
 {
   GtkWidget *colorsd = gtk_color_selection_dialog_new ( _("Choose a background color") );
@@ -2234,6 +2492,22 @@ static void set_bg_color ( GtkAction *a, VikWindow *vw )
   gtk_widget_destroy ( colorsd );
 }
 
   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 );
+}
+
 
 
 /***********************************************************************************************
 
 
 /***********************************************************************************************
@@ -2256,11 +2530,18 @@ static GtkActionEntry entries[] = {
   { "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             },
   { "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 },
+  { "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      },
   { "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      },
   { "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   },
+#ifdef VIK_CONFIG_OPENSTREETMAP
+  { "AcquireOSM",   NULL,                 N_("_OSM Traces..."),          NULL,         N_("Get traces from OpenStreetMap"),            (GCallback)acquire_from_osm       },
+#endif
 #ifdef VIK_CONFIG_GEOCACHES
   { "AcquireGC",   NULL,                 N_("Geo_caches..."),            NULL,         N_("Get Geocaches from geocaching.com"),            (GCallback)acquire_from_gc       },
 #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
   { "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          },
@@ -2278,6 +2559,7 @@ 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          },
+  { "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          },
   { "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          },
@@ -2332,12 +2614,14 @@ static GtkRadioActionEntry mode_entries[] = {
 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 },
 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 }
+  { "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[] = {
   { "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 },
 };
 
 static GtkToggleActionEntry toggle_entries[] = {
   { "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 },
   { "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 },
@@ -2364,6 +2648,7 @@ static void window_create_ui( VikWindow *window )
   toolbox_add_tool(window->vt, &ruler_tool, TOOL_LAYER_TYPE_NONE);
   toolbox_add_tool(window->vt, &zoom_tool, TOOL_LAYER_TYPE_NONE);
   toolbox_add_tool(window->vt, &pan_tool, TOOL_LAYER_TYPE_NONE);
   toolbox_add_tool(window->vt, &ruler_tool, TOOL_LAYER_TYPE_NONE);
   toolbox_add_tool(window->vt, &zoom_tool, TOOL_LAYER_TYPE_NONE);
   toolbox_add_tool(window->vt, &pan_tool, TOOL_LAYER_TYPE_NONE);
+  toolbox_add_tool(window->vt, &select_tool, TOOL_LAYER_TYPE_NONE);
 
   error = NULL;
   if (!(mid = gtk_ui_manager_add_ui_from_string (uim, menu_xml, -1, &error))) {
 
   error = NULL;
   if (!(mid = gtk_ui_manager_add_ui_from_string (uim, menu_xml, -1, &error))) {
@@ -2469,7 +2754,7 @@ static struct {
   gchar *stock_id;
 } stock_icons[] = {
   { &begintr_18_pixbuf,                "Begin Track"      },
   gchar *stock_id;
 } stock_icons[] = {
   { &begintr_18_pixbuf,                "Begin Track"      },
-  { &iscissors_18_pixbuf,      "Magic Scissors"   },
+  { &route_finder_18_pixbuf,   "Route Finder"     },
   { &mover_22_pixbuf,          "vik-icon-pan"     },
   { &demdl_18_pixbuf,          "DEM Download/Import"     },
   { &showpic_18_pixbuf,                "Show Picture"      },
   { &mover_22_pixbuf,          "vik-icon-pan"     },
   { &demdl_18_pixbuf,          "DEM Download/Import"     },
   { &showpic_18_pixbuf,                "Show Picture"      },
@@ -2479,6 +2764,7 @@ static struct {
   { &edwp_18_pixbuf,           "Edit Waypoint"     },
   { &zoom_18_pixbuf,           "vik-icon-zoom"     },
   { &ruler_18_pixbuf,          "vik-icon-ruler"    },
   { &edwp_18_pixbuf,           "Edit Waypoint"     },
   { &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"     },
   { &geozoom_18_pixbuf,                "Georef Zoom Tool"  },
   { &geomove_18_pixbuf,                "Georef Move Map"   },
   { &mapdl_18_pixbuf,          "Maps Download"     },
@@ -2500,3 +2786,124 @@ 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;
+  vw->containing_vtl = vtl;
+  /* Clear others */
+  vw->selected_track     = 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) );
+}
+
+gpointer vik_window_get_selected_tracks ( VikWindow *vw )
+{
+  return vw->selected_tracks;
+}
+
+void vik_window_set_selected_tracks ( VikWindow *vw, gpointer gl, gpointer vtl )
+{
+  vw->selected_tracks = gl;
+  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) );
+}
+
+gpointer vik_window_get_selected_track ( VikWindow *vw )
+{
+  return vw->selected_track;
+}
+
+void vik_window_set_selected_track ( VikWindow *vw, gpointer *vt, gpointer vtl, gpointer name )
+{
+  vw->selected_track = vt;
+  vw->containing_vtl = vtl;
+  vw->selected_name  = name;
+  /* Clear others */
+  vw->selected_vtl       = NULL;
+  vw->selected_tracks    = NULL;
+  vw->selected_waypoint  = NULL;
+  vw->selected_waypoints = NULL;
+  // 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_waypoints ( VikWindow *vw )
+{
+  return vw->selected_waypoints;
+}
+
+void vik_window_set_selected_waypoints ( VikWindow *vw, gpointer gl, gpointer vtl )
+{
+  vw->selected_waypoints = gl;
+  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 )
+{
+  return vw->selected_waypoint;
+}
+
+void vik_window_set_selected_waypoint ( VikWindow *vw, gpointer *vwp, gpointer vtl, gpointer name )
+{
+  vw->selected_waypoint = vwp;
+  vw->containing_vtl    = vtl;
+  vw->selected_name     = name;
+  /* Clear others */
+  vw->selected_vtl       = NULL;
+  vw->selected_track     = NULL;
+  vw->selected_tracks    = 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;
+  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;
+}