]> git.street.me.uk Git - andy/viking.git/blobdiff - src/vikwindow.c
Allow setting timestamps on trackpoints and waypoints that previously had none.
[andy/viking.git] / src / vikwindow.c
index 1e3fb9bc0075e6838136f573d046d7cd4eb1958b..b8fdc8b78095bfe7e566d347311d2f1fe7e2be45 100644 (file)
@@ -29,6 +29,7 @@
 #include "background.h"
 #include "acquire.h"
 #include "datasources.h"
+#include "geojson.h"
 #include "vikgoto.h"
 #include "dems.h"
 #include "mapcache.h"
@@ -95,6 +96,7 @@ static gboolean delete_event( VikWindow *vw );
 
 static gboolean key_press_event( VikWindow *vw, GdkEventKey *event, gpointer data );
 
+static void center_changed_cb ( VikWindow *vw );
 static void window_configure_event ( VikWindow *vw );
 static void draw_sync ( VikWindow *vw );
 static void draw_redraw ( VikWindow *vw );
@@ -172,6 +174,8 @@ struct _VikWindow {
 
   gboolean pan_move;
   gint pan_x, pan_y;
+  gint delayed_pan_x, delayed_pan_y; // Temporary storage
+  gboolean single_click_pending;
 
   guint draw_image_width, draw_image_height;
   gboolean draw_image_save_as_png;
@@ -404,7 +408,7 @@ static int determine_location_thread ( VikWindow *vw, gpointer threaddata )
     }
 
     vik_viewport_set_zoom ( vw->viking_vvp, zoom );
-    vik_viewport_set_center_latlon ( vw->viking_vvp, &ll );
+    vik_viewport_set_center_latlon ( vw->viking_vvp, &ll, FALSE );
 
     gchar *message = g_strdup_printf ( _("Location found: %s"), name );
     vik_window_statusbar_update ( vw, message, VIK_STATUSBAR_INFO );
@@ -437,7 +441,7 @@ void vik_window_new_window_finish ( VikWindow *vw )
 
   // Maybe add a default map layer
   if ( a_vik_get_add_default_map_layer () ) {
-    VikMapsLayer *vml = VIK_MAPS_LAYER ( vik_layer_create(VIK_LAYER_MAPS, vw->viking_vvp, NULL, FALSE) );
+    VikMapsLayer *vml = VIK_MAPS_LAYER ( vik_layer_create(VIK_LAYER_MAPS, vw->viking_vvp, FALSE) );
     vik_layer_rename ( VIK_LAYER(vml), _("Default Map") );
     vik_aggregate_layer_add_layer ( vik_layers_panel_get_top_layer(vw->viking_vlp), VIK_LAYER(vml), TRUE );
 
@@ -719,6 +723,7 @@ static void vik_window_init ( VikWindow *vw )
  
   vw->pan_move = FALSE; 
   vw->pan_x = vw->pan_y = -1;
+  vw->single_click_pending = FALSE;
 
   gint draw_image_width;
   if ( a_settings_get_integer ( VIK_SETTINGS_WIN_SAVE_IMAGE_WIDTH, &draw_image_width ) )
@@ -754,6 +759,9 @@ static void vik_window_init ( VikWindow *vw )
 
   g_signal_connect (G_OBJECT (vw), "delete_event", G_CALLBACK (delete_event), NULL);
 
+  // Own signals
+  g_signal_connect_swapped (G_OBJECT(vw->viking_vvp), "updated_center", G_CALLBACK(center_changed_cb), vw);
+  // Signals from GTK
   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_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK );
@@ -768,6 +776,9 @@ static void vik_window_init ( VikWindow *vw )
   // Allow key presses to be processed anywhere
   g_signal_connect_swapped (G_OBJECT (vw), "key_press_event", G_CALLBACK (key_press_event), vw);
 
+  // Set initial button sensitivity
+  center_changed_cb ( vw );
+
   hpaned = gtk_hpaned_new ();
   gtk_paned_pack1 ( GTK_PANED(hpaned), GTK_WIDGET (vw->viking_vlp), FALSE, FALSE );
   gtk_paned_pack2 ( GTK_PANED(hpaned), GTK_WIDGET (vw->viking_vvp), TRUE, TRUE );
@@ -1215,16 +1226,62 @@ static void draw_mouse_motion (VikWindow *vw, GdkEventMotion *event)
   /* gdk_event_request_motions ( event ); */
 }
 
+/**
+ * Action the single click after a small timeout
+ * If a double click has occurred then this will do nothing
+ */
+static gboolean vik_window_pan_timeout (VikWindow *vw)
+{
+  if ( ! vw->single_click_pending ) {
+    // Double click happened, so don't do anything
+    return FALSE;
+  }
+
+  /* set panning origin */
+  vw->pan_move = FALSE;
+  vw->single_click_pending = FALSE;
+  vik_viewport_set_center_screen ( vw->viking_vvp, vw->delayed_pan_x, vw->delayed_pan_y );
+  draw_update ( vw );
+
+  // Really turn off the pan moving!!
+  vw->pan_x = vw->pan_y = -1;
+  return FALSE;
+}
+
 static void vik_window_pan_release ( VikWindow *vw, GdkEventButton *event )
 {
-  if ( vw->pan_move == FALSE )
-    vik_viewport_set_center_screen ( vw->viking_vvp, vw->pan_x, vw->pan_y );
-  else
+  gboolean do_draw = TRUE;
+
+  if ( vw->pan_move == FALSE ) {
+    vw->single_click_pending = !vw->single_click_pending;
+
+    if ( vw->single_click_pending ) {
+      // Store offset to use
+      vw->delayed_pan_x = vw->pan_x;
+      vw->delayed_pan_y = vw->pan_y;
+      // Get double click time
+      GtkSettings *gs = gtk_widget_get_settings ( GTK_WIDGET(vw) );
+      GValue dct = { 0 }; // = G_VALUE_INIT; // GLIB 2.30+ only
+      g_value_init ( &dct, G_TYPE_INT );
+      g_object_get_property ( G_OBJECT(gs), "gtk-double-click-time", &dct );
+      // Give chance for a double click to occur
+      gint timer = g_value_get_int ( &dct ) + 50;
+      g_timeout_add ( timer, (GSourceFunc)vik_window_pan_timeout, vw );
+      do_draw = FALSE;
+    }
+    else {
+      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 );
+  }
+
   vw->pan_move = FALSE;
   vw->pan_x = vw->pan_y = -1;
-  draw_update ( vw );
+  if ( do_draw )
+    draw_update ( vw );
 }
 
 static void draw_release ( VikWindow *vw, GdkEventButton *event )
@@ -1598,7 +1655,8 @@ static VikToolInterface ruler_tool =
     (VikToolKeyFunc) ruler_key_press,
     FALSE,
     GDK_CURSOR_IS_PIXMAP,
-    &cursor_ruler_pixbuf };
+    &cursor_ruler_pixbuf,
+    NULL };
 /*** end ruler code ********************************************************/
 
 
@@ -1762,6 +1820,9 @@ static VikLayerToolFuncStatus zoomtool_move (VikLayer *vl, GdkEventMotion *event
       draw_buf_done = FALSE;
     }
   }
+  else
+    zts->bounds_active = FALSE;
+
   return VIK_LAYER_TOOL_ACK;
 }
 
@@ -1769,11 +1830,11 @@ static VikLayerToolFuncStatus zoomtool_release (VikLayer *vl, GdkEventButton *ev
 {
   guint modifiers = event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK);
 
-  zts->bounds_active = FALSE;
-
   // Ensure haven't just released on the exact same position
   //  i.e. probably haven't moved the mouse at all
-  if ( modifiers == GDK_SHIFT_MASK && !( ( event->x == zts->start_x ) && ( event->y == zts->start_y )) ) {
+  if ( zts->bounds_active && modifiers == GDK_SHIFT_MASK &&
+     ( event->x < zts->start_x-5 || event->x > zts->start_x+5 ) &&
+     ( event->y < zts->start_y-5 || event->y > zts->start_y+5 ) ) {
 
     VikCoord coord1, coord2;
     vik_viewport_screen_to_coord ( zts->vw->viking_vvp, zts->start_x, zts->start_y, &coord1);
@@ -1790,7 +1851,7 @@ static VikLayerToolFuncStatus zoomtool_release (VikLayer *vl, GdkEventButton *ev
 
     VikCoord new_center;
     vik_coord_load_from_latlon ( &new_center, vik_viewport_get_coord_mode ( zts->vw->viking_vvp ), &average );
-    vik_viewport_set_center_coord ( zts->vw->viking_vvp, &new_center );
+    vik_viewport_set_center_coord ( zts->vw->viking_vvp, &new_center, FALSE );
 
     /* Convert into definite 'smallest' and 'largest' positions */
     struct LatLon minmin;
@@ -1828,9 +1889,30 @@ static VikLayerToolFuncStatus zoomtool_release (VikLayer *vl, GdkEventButton *ev
       zoom = zoom * 2;
       vik_viewport_set_zoom ( zts->vw->viking_vvp, zoom );
     }
-
-    draw_update ( zts->vw );
   }
+  else {
+     // When pressing shift and clicking for zoom, then jump three levels
+     if ( modifiers == GDK_SHIFT_MASK ) {
+       // Zoom in/out by three if possible
+       vik_viewport_set_center_screen ( zts->vw->viking_vvp, event->x, event->y );
+       if ( event->button == 1 ) {
+          vik_viewport_zoom_in ( zts->vw->viking_vvp );
+          vik_viewport_zoom_in ( zts->vw->viking_vvp );
+          vik_viewport_zoom_in ( zts->vw->viking_vvp );
+       }
+       else if ( event->button == 3 ) {
+          vik_viewport_zoom_out ( zts->vw->viking_vvp );
+          vik_viewport_zoom_out ( zts->vw->viking_vvp );
+          vik_viewport_zoom_out ( zts->vw->viking_vvp );
+       }
+     }
+  }
+
+  draw_update ( zts->vw );
+
+  // Reset
+  zts->bounds_active = FALSE;
+
   return VIK_LAYER_TOOL_ACK;
 }
 
@@ -1846,7 +1928,8 @@ static VikToolInterface zoom_tool =
     NULL,
     FALSE,
     GDK_CURSOR_IS_PIXMAP,
-    &cursor_zoom_pixbuf };
+    &cursor_zoom_pixbuf,
+    NULL };
 /*** end zoom code ********************************************************/
 
 /********************************************************************************
@@ -1857,12 +1940,31 @@ static gpointer pantool_create (VikWindow *vw, VikViewport *vvp)
   return vw;
 }
 
+// NB Double clicking means this gets called THREE times!!!
 static VikLayerToolFuncStatus pantool_click (VikLayer *vl, GdkEventButton *event, VikWindow *vw)
 {
   vw->modified = TRUE;
-  if ( event->button == 1 )
-    vik_window_pan_click ( vw, event );
-  draw_update ( vw );
+
+  if ( event->type == GDK_2BUTTON_PRESS ) {
+    // Zoom in / out on double click
+    // No need to change the center as that has already occurred in the first click of a double click occurrence
+    if ( event->button == 1 ) {
+      guint modifier = event->state & GDK_SHIFT_MASK;
+      if ( modifier )
+        vik_viewport_zoom_out ( vw->viking_vvp );
+      else
+        vik_viewport_zoom_in ( vw->viking_vvp );
+    }
+    else if ( event->button == 3 )
+      vik_viewport_zoom_out ( vw->viking_vvp );
+
+    draw_update ( vw );
+  }
+  else
+    // Standard pan click
+    if ( event->button == 1 )
+      vik_window_pan_click ( vw, event );
+
   return VIK_LAYER_TOOL_ACK;
 }
 
@@ -1890,7 +1992,9 @@ static VikToolInterface pan_tool =
     (VikToolMouseFunc) pantool_release,
     NULL,
     FALSE,
-    GDK_FLEUR };
+    GDK_FLEUR,
+    NULL,
+    NULL };
 /*** end pan code ********************************************************/
 
 /********************************************************************************
@@ -2100,10 +2204,52 @@ static void draw_goto_cb ( GtkAction *a, VikWindow *vw )
     return;
   }
 
-  vik_viewport_set_center_coord ( vw->viking_vvp, &new_center );
+  vik_viewport_set_center_coord ( vw->viking_vvp, &new_center, TRUE );
   draw_update ( vw );
 }
 
+/**
+ * center_changed_cb:
+ */
+static void center_changed_cb ( VikWindow *vw )
+{
+// ATM Keep back always available, so when we pan - we can jump to the last requested position
+/*
+  GtkAction* action_back = gtk_action_group_get_action ( vw->action_group, "GoBack" );
+  if ( action_back ) {
+    gtk_action_set_sensitive ( action_back, vik_viewport_back_available(vw->viking_vvp) );
+  }
+*/
+  GtkAction* action_forward = gtk_action_group_get_action ( vw->action_group, "GoForward" );
+  if ( action_forward ) {
+    gtk_action_set_sensitive ( action_forward, vik_viewport_forward_available(vw->viking_vvp) );
+  }
+}
+
+/**
+ * draw_goto_back_and_forth:
+ */
+static void draw_goto_back_and_forth ( GtkAction *a, VikWindow *vw )
+{
+  gboolean changed = FALSE;
+  if (!strcmp(gtk_action_get_name(a), "GoBack")) {
+    changed = vik_viewport_go_back ( vw->viking_vvp );
+  }
+  else if (!strcmp(gtk_action_get_name(a), "GoForward")) {
+    changed = vik_viewport_go_forward ( vw->viking_vvp );
+  }
+  else {
+    return;
+  }
+
+  // Recheck buttons sensitivities, as the center changed signal is not sent on back/forward changes
+  //  (otherwise we would get stuck in an infinite loop!)
+  center_changed_cb ( vw );
+
+  if ( changed )
+    draw_update ( vw );
+}
+
 /**
  * Refresh maps displayed
  */
@@ -2382,15 +2528,14 @@ static void menu_tool_cb ( GtkAction *old, GtkAction *a, VikWindow *vw )
     vw->current_tool = TOOL_SELECT;
   }
   else {
-    /* TODO: only enable tools from active layer */
     VikLayerTypeEnum layer_id;
     for (layer_id=0; layer_id<VIK_LAYER_NUM_TYPES; layer_id++) {
       for ( tool_id = 0; tool_id < vik_layer_get_interface(layer_id)->tools_count; tool_id++ ) {
-       if (!strcmp(vik_layer_get_interface(layer_id)->tools[tool_id].radioActionEntry.name, gtk_action_get_name(a))) {
+        if (!strcmp(vik_layer_get_interface(layer_id)->tools[tool_id].radioActionEntry.name, gtk_action_get_name(a))) {
            vw->current_tool = TOOL_LAYER;
            vw->tool_layer_id = layer_id;
            vw->tool_tool_id = tool_id;
-       }
+        }
       }
     }
   }
@@ -2499,6 +2644,7 @@ static void setup_recent_files (VikWindow *self)
   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);
+  gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (menu), a_vik_get_recent_number_files() );
 
   menu_item = gtk_ui_manager_get_widget (self->uim, "/ui/MainMenu/File/OpenRecentFile");
   gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);
@@ -2507,7 +2653,10 @@ static void setup_recent_files (VikWindow *self)
                     G_CALLBACK (on_activate_recent_item), (gpointer) self);
 }
 
-static void update_recently_used_document(const gchar *filename)
+/*
+ *
+ */
+static void update_recently_used_document (VikWindow *vw, const gchar *filename)
 {
   /* Update Recently Used Document framework */
   GtkRecentManager *manager = gtk_recent_manager_get_default();
@@ -2528,7 +2677,9 @@ static void update_recently_used_document(const gchar *filename)
   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);
+    gchar *msg = g_strdup_printf (_("Unable to add '%s' to the list of recently used documents"), uri);
+    vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_INFO, msg );
+    g_free ( msg );
   }
 
   g_free (uri);
@@ -2625,7 +2776,7 @@ void vik_window_open_file ( VikWindow *vw, const gchar *filename, gboolean chang
       success = TRUE;
       // When LOAD_TYPE_OTHER_SUCCESS *only*, this will maintain the existing Viking project
       restore_original_filename = ! restore_original_filename;
-      update_recently_used_document(filename);
+      update_recently_used_document (vw, filename);
       draw_update ( vw );
       break;
   }
@@ -2687,6 +2838,11 @@ static void load_file ( GtkAction *a, VikWindow *vw )
     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, _("JPG") );
+    gtk_file_filter_add_mime_type ( filter, "image/jpeg");
+    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" );
@@ -2789,7 +2945,7 @@ static gboolean save_file_as ( GtkAction *a, VikWindow *vw )
   }
   // Auto append / replace extension with '.vik' to the suggested file name as it's going to be a Viking File
   gchar* auto_save_name = g_strdup ( window_get_filename ( vw ) );
-  if ( ! check_file_ext ( auto_save_name, ".vik" ) )
+  if ( ! a_file_check_ext ( auto_save_name, ".vik" ) )
     auto_save_name = g_strconcat ( auto_save_name, ".vik", NULL );
 
   gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(vw->save_dia), auto_save_name);
@@ -2817,7 +2973,7 @@ 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 );
+    update_recently_used_document ( vw, vw->filename );
   }
   else
   {
@@ -2996,64 +3152,70 @@ static void file_properties_cb ( GtkAction *a, VikWindow *vw )
   g_free ( message );
 }
 
+static void my_acquire ( VikWindow *vw, VikDataSourceInterface *datasource )
+{
+  vik_datasource_mode_t mode = datasource->mode;
+  if ( mode == VIK_DATASOURCE_AUTO_LAYER_MANAGEMENT )
+    mode = VIK_DATASOURCE_CREATENEWLAYER;
+  a_acquire ( vw, vw->viking_vlp, vw->viking_vvp, mode, datasource, NULL, NULL );
+}
+
 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, NULL, NULL );
+  my_acquire ( vw, &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, NULL, NULL );
+  my_acquire ( vw, &vik_datasource_file_interface );
+}
+
+static void acquire_from_geojson ( GtkAction *a, VikWindow *vw )
+{
+  my_acquire ( vw, &vik_datasource_geojson_interface );
 }
 
 static void acquire_from_routing ( GtkAction *a, VikWindow *vw )
 {
-  a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_routing_interface, NULL, NULL );
+  my_acquire ( vw, &vik_datasource_routing_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, NULL, NULL );
+  my_acquire ( vw, &vik_datasource_osm_interface );
 }
 
 static void acquire_from_my_osm ( GtkAction *a, VikWindow *vw )
 {
-  a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_osm_my_traces_interface, NULL, NULL );
+  my_acquire ( vw, &vik_datasource_osm_my_traces_interface );
 }
 #endif
 
 #ifdef VIK_CONFIG_GEOCACHES
 static void acquire_from_gc ( GtkAction *a, VikWindow *vw )
 {
-  a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_gc_interface, NULL, NULL );
+  my_acquire ( vw, &vik_datasource_gc_interface );
 }
 #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, NULL, NULL );
+  my_acquire ( vw, &vik_datasource_geotag_interface );
 }
 #endif
 
 #ifdef VIK_CONFIG_GEONAMES
 static void acquire_from_wikipedia ( GtkAction *a, VikWindow *vw )
 {
-  a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_wikipedia_interface, NULL, NULL );
+  my_acquire ( vw, &vik_datasource_wikipedia_interface );
 }
 #endif
 
 static void acquire_from_url ( GtkAction *a, VikWindow *vw )
 {
-  vik_datasource_url_interface.mode = VIK_DATASOURCE_CREATENEWLAYER;
-  a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_url_interface, NULL, NULL );
+  my_acquire ( vw, &vik_datasource_url_interface );
 }
 
 static void goto_default_location( GtkAction *a, VikWindow *vw)
@@ -3061,7 +3223,7 @@ 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_viewport_set_center_latlon(vw->viking_vvp, &ll, TRUE);
   vik_layers_panel_emit_update(vw->viking_vlp);
 }
 
@@ -3143,6 +3305,7 @@ static void default_location_cb ( GtkAction *a, VikWindow *vw )
       NULL,
       NULL,
       NULL,
+      NULL,
     },
   };
   VikLayerParam pref_lon[] = {
@@ -3157,6 +3320,7 @@ static void default_location_cb ( GtkAction *a, VikWindow *vw )
       NULL,
       NULL,
       NULL,
+      NULL,
     },
   };
 
@@ -3319,7 +3483,7 @@ static void save_image_dir ( VikWindow *vw, const gchar *fn, guint w, guint h, g
         utm.northing -= ((gdouble)y - (((gdouble)tiles_h)+1)/2) * (h*zoom);
 
       /* move to correct place. */
-      vik_viewport_set_center_utm ( vw->viking_vvp, &utm );
+      vik_viewport_set_center_utm ( vw->viking_vvp, &utm, FALSE );
 
       draw_redraw ( vw );
 
@@ -3328,7 +3492,9 @@ static void save_image_dir ( VikWindow *vw, const gchar *fn, guint w, guint h, g
       gdk_pixbuf_save ( pixbuf_to_save, name_of_file, save_as_png ? "png" : "jpeg", &error, NULL );
       if (error)
       {
-        g_warning("Unable to write to file %s: %s", name_of_file, error->message );
+        gchar *msg = g_strdup_printf (_("Unable to write to file %s: %s"), name_of_file, error->message );
+        vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_INFO, msg );
+        g_free ( msg );
         g_error_free (error);
       }
 
@@ -3336,7 +3502,7 @@ static void save_image_dir ( VikWindow *vw, const gchar *fn, guint w, guint h, g
     }
   }
 
-  vik_viewport_set_center_utm ( vw->viking_vvp, &utm_orig );
+  vik_viewport_set_center_utm ( vw->viking_vvp, &utm_orig, FALSE );
   vik_viewport_set_xmpp ( vw->viking_vvp, old_xmpp );
   vik_viewport_set_ympp ( vw->viking_vvp, old_ympp );
   vik_viewport_configure ( vw->viking_vvp );
@@ -3599,8 +3765,8 @@ static void draw_to_image_file ( VikWindow *vw, gboolean one_image_only )
     if ( !fn )
       return;
 
-    gint active = gtk_combo_box_get_active ( GTK_COMBO_BOX(zoom_combo) );
-    gdouble zoom = pow (2, active-2 );
+    gint active_z = gtk_combo_box_get_active ( GTK_COMBO_BOX(zoom_combo) );
+    gdouble zoom = pow (2, active_z-2 );
 
     if ( one_image_only )
       save_image_file ( vw, fn, 
@@ -3788,6 +3954,8 @@ 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          },
 
+  { "GoBack",    GTK_STOCK_GO_BACK,      N_("Go to the Pre_vious Location"),  NULL,         N_("Go to the previous location"),              (GCallback)draw_goto_back_and_forth },
+  { "GoForward", GTK_STOCK_GO_FORWARD,   N_("Go to the _Next Location"),      NULL,         N_("Go to the next location"),                  (GCallback)draw_goto_back_and_forth },
   { "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          },
@@ -3823,6 +3991,10 @@ static GtkActionEntry entries_gpsbabel[] = {
   { "ExportKML", NULL,                   N_("_KML..."),                      NULL,         N_("Export as KML"),                                (GCallback)export_to_kml },
 };
 
+static GtkActionEntry entries_geojson[] = {
+  { "AcquireGeoJSON",   NULL,            N_("Import Geo_JSON File..."),   NULL,         N_("Import GeoJSON file"),                          (GCallback)acquire_from_geojson },
+};
+
 /* Radio items */
 /* FIXME use VIEWPORT_DRAWMODE values */
 static GtkRadioActionEntry mode_entries[] = {
@@ -3885,6 +4057,14 @@ static void window_create_ui( VikWindow *window )
       gtk_action_group_add_actions ( action_group, entries_gpsbabel, G_N_ELEMENTS (entries_gpsbabel), window );
   }
 
+  // GeoJSON import capability
+  if ( g_find_program_in_path ( a_geojson_program_import() ) ) {
+    if ( gtk_ui_manager_add_ui_from_string ( uim,
+         "<ui><menubar name='MainMenu'><menu action='File'><menu action='Acquire'><menuitem action='AcquireGeoJSON'/></menu></menu></menubar></ui>",
+         -1, &error ) )
+      gtk_action_group_add_actions ( action_group, entries_geojson, G_N_ELEMENTS (entries_geojson), window );
+  }
+
   icon_factory = gtk_icon_factory_new ();
   gtk_icon_factory_add_default (icon_factory);