X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/beb9d63a39b01fad2c4126b695a9935443634eab..b22233bdbe84cee4af1cd2433cd25d63a300088c:/src/vikwindow.c diff --git a/src/vikwindow.c b/src/vikwindow.c index a1f49abe..e783e9a6 100644 --- a/src/vikwindow.c +++ b/src/vikwindow.c @@ -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" @@ -41,6 +42,7 @@ #include "garminsymbols.h" #include "vikmapslayer.h" #include "geonamessearch.h" +#include "vikutils.h" #ifdef HAVE_STDLIB_H #include @@ -692,6 +694,7 @@ static void drag_data_received_cb ( GtkWidget *widget, #define VIK_SETTINGS_WIN_SAVE_IMAGE_WIDTH "window_save_image_width" #define VIK_SETTINGS_WIN_SAVE_IMAGE_HEIGHT "window_save_image_height" #define VIK_SETTINGS_WIN_SAVE_IMAGE_PNG "window_save_image_as_png" +#define VIK_SETTINGS_WIN_COPY_CENTRE_FULL_FORMAT "window_copy_centre_full_format" static void vik_window_init ( VikWindow *vw ) { @@ -1156,11 +1159,34 @@ static void vik_window_pan_move (VikWindow *vw, GdkEventMotion *event) } } +/** + * get_location_strings: + * + * Utility function to get positional strings for the given location + * lat and lon strings will get allocated and so need to be freed after use + */ +static void get_location_strings ( VikWindow *vw, struct UTM utm, gchar **lat, gchar **lon ) +{ + if ( vik_viewport_get_drawmode ( vw->viking_vvp ) == VIK_VIEWPORT_DRAWMODE_UTM ) { + // Reuse lat for the first part (Zone + N or S, and lon for the second part (easting and northing) of a UTM format: + // ZONE[N|S] EASTING NORTHING + *lat = g_malloc(4*sizeof(gchar)); + // NB zone is stored in a char but is an actual number + g_snprintf (*lat, 4, "%d%c", utm.zone, utm.letter); + *lon = g_malloc(16*sizeof(gchar)); + g_snprintf (*lon, 16, "%d %d", (gint)utm.easting, (gint)utm.northing); + } + else { + struct LatLon ll; + a_coords_utm_to_latlon ( &utm, &ll ); + a_coords_latlon_to_string ( &ll, lat, lon ); + } +} + static void draw_mouse_motion (VikWindow *vw, GdkEventMotion *event) { static VikCoord coord; static struct UTM utm; - static struct LatLon ll; #define BUFFER_SIZE 50 static char pointer_buf[BUFFER_SIZE]; gchar *lat = NULL, *lon = NULL; @@ -1180,19 +1206,7 @@ static void draw_mouse_motion (VikWindow *vw, GdkEventMotion *event) vik_viewport_screen_to_coord ( vw->viking_vvp, event->x, event->y, &coord ); vik_coord_to_utm ( &coord, &utm ); - if ( vik_viewport_get_drawmode ( vw->viking_vvp ) == VIK_VIEWPORT_DRAWMODE_UTM ) { - // Reuse lat for the first part (Zone + N or S, and lon for the second part (easting and northing) of a UTM format: - // ZONE[N|S] EASTING NORTHING - lat = g_malloc(4*sizeof(gchar)); - // NB zone is stored in a char but is an actual number - g_snprintf (lat, 4, "%d%c", utm.zone, utm.letter); - lon = g_malloc(16*sizeof(gchar)); - g_snprintf (lon, 16, "%d %d", (gint)utm.easting, (gint)utm.northing); - } - else { - a_coords_utm_to_latlon ( &utm, &ll ); - a_coords_latlon_to_string ( &ll, &lat, &lon ); - } + get_location_strings ( vw, utm, &lat, &lon ); /* Change interpolate method according to scale */ zoom = vik_viewport_get_zoom(vw->viking_vvp); @@ -1249,6 +1263,8 @@ static gboolean vik_window_pan_timeout (VikWindow *vw) static void vik_window_pan_release ( VikWindow *vw, GdkEventButton *event ) { + gboolean do_draw = TRUE; + if ( vw->pan_move == FALSE ) { vw->single_click_pending = !vw->single_click_pending; @@ -1258,13 +1274,13 @@ static void vik_window_pan_release ( VikWindow *vw, GdkEventButton *event ) vw->delayed_pan_y = vw->pan_y; // Get double click time GtkSettings *gs = gtk_widget_get_settings ( GTK_WIDGET(vw) ); - GValue dct = G_VALUE_INIT; + 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 ); - goto skip_draw; + do_draw = FALSE; } else { vik_viewport_set_center_screen ( vw->viking_vvp, vw->pan_x, vw->pan_y ); @@ -1275,11 +1291,10 @@ static void vik_window_pan_release ( VikWindow *vw, GdkEventButton *event ) vik_viewport_get_height(vw->viking_vvp)/2 - event->y + vw->pan_y ); } - draw_update ( vw ); - - skip_draw: vw->pan_move = FALSE; vw->pan_x = vw->pan_y = -1; + if ( do_draw ) + draw_update ( vw ); } static void draw_release ( VikWindow *vw, GdkEventButton *event ) @@ -1432,20 +1447,29 @@ static void draw_ruler(VikViewport *vvp, GdkDrawable *d, GdkGC *gc, gint x1, gin switch (dist_units) { case VIK_UNITS_DISTANCE_KILOMETRES: if (distance >= 1000 && distance < 100000) { - g_sprintf(str, "%3.2f km", distance/1000.0); + g_sprintf(str, "%3.2f km", distance/1000.0); } else if (distance < 1000) { - g_sprintf(str, "%d m", (int)distance); + g_sprintf(str, "%d m", (int)distance); } else { - g_sprintf(str, "%d km", (int)distance/1000); + 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)); + 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)); + g_sprintf(str, "%d yards", (int)(distance*1.0936133)); } else { - g_sprintf(str, "%d miles", (int)VIK_METERS_TO_MILES(distance)); + g_sprintf(str, "%d miles", (int)VIK_METERS_TO_MILES(distance)); + } + break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + if (distance >= VIK_NAUTICAL_MILES_TO_METERS(1) && distance < VIK_NAUTICAL_MILES_TO_METERS(100)) { + g_sprintf(str, "%3.2f NM", VIK_METERS_TO_NAUTICAL_MILES(distance)); + } else if (distance < VIK_NAUTICAL_MILES_TO_METERS(1)) { + g_sprintf(str, "%d yards", (int)(distance*1.0936133)); + } else { + g_sprintf(str, "%d NM", (int)VIK_METERS_TO_NAUTICAL_MILES(distance)); } break; default: @@ -1532,14 +1556,17 @@ static VikLayerToolFuncStatus ruler_click (VikLayer *vl, GdkEventButton *event, 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; + 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; + temp = g_strdup_printf ( "%s %s DIFF %f miles", lat, lon, VIK_METERS_TO_MILES(vik_coord_diff( &coord, &(s->oldcoord) )) ); + break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + temp = g_strdup_printf ( "%s %s DIFF %f NM", lat, lon, VIK_METERS_TO_NAUTICAL_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); + 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; @@ -1609,6 +1636,9 @@ static VikLayerToolFuncStatus ruler_move (VikLayer *vl, GdkEventMotion *event, r 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; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + temp = g_strdup_printf ( "%s %s DIFF %f NM", lat, lon, VIK_METERS_TO_NAUTICAL_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); @@ -1653,7 +1683,8 @@ static VikToolInterface ruler_tool = (VikToolKeyFunc) ruler_key_press, FALSE, GDK_CURSOR_IS_PIXMAP, - &cursor_ruler_pixbuf }; + &cursor_ruler_pixbuf, + NULL }; /*** end ruler code ********************************************************/ @@ -1817,6 +1848,9 @@ static VikLayerToolFuncStatus zoomtool_move (VikLayer *vl, GdkEventMotion *event draw_buf_done = FALSE; } } + else + zts->bounds_active = FALSE; + return VIK_LAYER_TOOL_ACK; } @@ -1824,11 +1858,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); @@ -1883,9 +1917,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; } @@ -1901,7 +1956,8 @@ static VikToolInterface zoom_tool = NULL, FALSE, GDK_CURSOR_IS_PIXMAP, - &cursor_zoom_pixbuf }; + &cursor_zoom_pixbuf, + NULL }; /*** end zoom code ********************************************************/ /******************************************************************************** @@ -1964,7 +2020,9 @@ static VikToolInterface pan_tool = (VikToolMouseFunc) pantool_release, NULL, FALSE, - GDK_FLEUR }; + GDK_FLEUR, + NULL, + NULL }; /*** end pan code ********************************************************/ /******************************************************************************** @@ -2614,6 +2672,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); @@ -2622,7 +2681,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(); @@ -2643,7 +2705,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); @@ -2740,7 +2804,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; } @@ -2802,6 +2866,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" ); @@ -2904,7 +2973,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); @@ -2932,7 +3001,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 { @@ -3111,64 +3180,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) @@ -3192,6 +3267,38 @@ static void mapcache_flush_cb ( GtkAction *a, VikWindow *vw ) a_mapcache_flush(); } +static void menu_copy_centre_cb ( GtkAction *a, VikWindow *vw ) +{ + const VikCoord* coord; + struct UTM utm; + gchar *lat = NULL, *lon = NULL; + + coord = vik_viewport_get_center ( vw->viking_vvp ); + vik_coord_to_utm ( coord, &utm ); + + gboolean full_format = FALSE; + a_settings_get_boolean ( VIK_SETTINGS_WIN_COPY_CENTRE_FULL_FORMAT, &full_format ); + + if ( full_format ) + // Bells & Whistles - may include degrees, minutes and second symbols + get_location_strings ( vw, utm, &lat, &lon ); + else { + // Simple x.xx y.yy format + struct LatLon ll; + a_coords_utm_to_latlon ( &utm, &ll ); + lat = g_strdup_printf ( "%.6f", ll.lat ); + lon = g_strdup_printf ( "%.6f", ll.lon ); + } + + gchar *msg = g_strdup_printf ( "%s %s", lat, lon ); + g_free (lat); + g_free (lon); + + a_clipboard_copy ( VIK_CLIPBOARD_DATA_TEXT, 0, 0, 0, msg, NULL ); + + g_free ( msg ); +} + static void layer_defaults_cb ( GtkAction *a, VikWindow *vw ) { gchar **texts = g_strsplit ( gtk_action_get_name(a), "Layer", 0 ); @@ -3240,6 +3347,10 @@ static void preferences_cb ( GtkAction *a, VikWindow *vw ) // Update all windows g_slist_foreach ( window_list, (GFunc) preferences_change_update, NULL ); } + + // Ensure TZ Lookup initialized + if ( a_vik_get_time_ref_frame() == VIK_TIME_REF_WORLD ) + vu_setup_lat_lon_tz_lookup(); } static void default_location_cb ( GtkAction *a, VikWindow *vw ) @@ -3258,6 +3369,7 @@ static void default_location_cb ( GtkAction *a, VikWindow *vw ) NULL, NULL, NULL, + NULL, }, }; VikLayerParam pref_lon[] = { @@ -3272,6 +3384,7 @@ static void default_location_cb ( GtkAction *a, VikWindow *vw ) NULL, NULL, NULL, + NULL, }, }; @@ -3443,7 +3556,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); } @@ -3509,6 +3624,9 @@ static void draw_to_image_file_total_area_cb (GtkSpinButton *spinbutton, gpointe 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; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + label_text = g_strdup_printf ( _("Total area: %ldm x %ldm (%.3f sq. NM)"), (glong)w, (glong)h, (w*h/(1852.0*1852.0))); + 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); @@ -3714,8 +3832,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, @@ -3926,6 +4044,7 @@ 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 }, + { "CopyCentre",NULL, N_("Copy Centre _Location"), "h", NULL, (GCallback)menu_copy_centre_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 }, @@ -3940,6 +4059,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[] = { @@ -4002,6 +4125,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, + "", + -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);