X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/b3eb3b98666b78dab0ca279808b529157d15d073..db771541ff9b86b3ef5e204d5d5d659ccf66e7e6:/src/viktrwlayer_geotag.c diff --git a/src/viktrwlayer_geotag.c b/src/viktrwlayer_geotag.c index 8e5b2d74..09f15166 100644 --- a/src/viktrwlayer_geotag.c +++ b/src/viktrwlayer_geotag.c @@ -36,8 +36,9 @@ #include "vikfilelist.h" #include "geotag_exif.h" #include "thumbnails.h" +#include "background.h" -// Taken from GPSCorrelate 1.6.1 +// Function taken from GPSCorrelate 1.6.1 // ConvertToUnixTime Copyright 2005 Daniel Foote. GPL2+ #define EXIF_DATE_FORMAT "%d:%d:%d %d:%d:%d" @@ -90,8 +91,11 @@ typedef struct { GtkWidget *dialog; VikFileList *files; VikTrwLayer *vtl; // to pass on + VikWaypoint *wpt; // Use specified waypoint or otherwise the track(s) if NULL VikTrack *track; // Use specified track or all tracks if NULL GtkCheckButton *create_waypoints_b; + GtkLabel *overwrite_waypoints_l; // Referenced so the sensitivity can be changed + GtkCheckButton *overwrite_waypoints_b; GtkCheckButton *write_exif_b; GtkLabel *overwrite_gps_exif_l; // Referenced so the sensitivity can be changed GtkCheckButton *overwrite_gps_exif_b; @@ -116,6 +120,7 @@ static void geotag_widgets_free ( GeoTagWidgets *widgets ) typedef struct { gboolean create_waypoints; + gboolean overwrite_waypoints; gboolean write_exif; gboolean overwrite_gps_exif; gboolean no_change_mtime; @@ -128,9 +133,11 @@ typedef struct { typedef struct { VikTrwLayer *vtl; gchar *image; + VikWaypoint *wpt; // Use specified waypoint or otherwise the track(s) if NULL VikTrack *track; // Use specified track or all tracks if NULL // User options... option_values_t ov; + GList *files; time_t PhotoTime; // Store answer from interpolation for an image gboolean found_match; @@ -140,21 +147,57 @@ typedef struct { gboolean redraw; } geotag_options_t; -static option_values_t default_values = { - TRUE, - TRUE, - FALSE, - TRUE, - TRUE, - 0, - 0, - 0, -}; +#define VIK_SETTINGS_GEOTAG_CREATE_WAYPOINT "geotag_create_waypoints" +#define VIK_SETTINGS_GEOTAG_OVERWRITE_WAYPOINTS "geotag_overwrite_waypoints" +#define VIK_SETTINGS_GEOTAG_WRITE_EXIF "geotag_write_exif" +#define VIK_SETTINGS_GEOTAG_OVERWRITE_GPS_EXIF "geotag_overwrite_gps" +#define VIK_SETTINGS_GEOTAG_NO_CHANGE_MTIME "geotag_no_change_mtime" +#define VIK_SETTINGS_GEOTAG_INTERPOLATE_SEGMENTS "geotag_interpolate_segments" +#define VIK_SETTINGS_GEOTAG_TIME_OFFSET "geotag_time_offset" +#define VIK_SETTINGS_GEOTAG_TIME_OFFSET_HOURS "geotag_time_offset_hours" +#define VIK_SETTINGS_GEOTAG_TIME_OFFSET_MINS "geotag_time_offset_mins" + +static void save_default_values ( option_values_t default_values ) +{ + a_settings_set_boolean ( VIK_SETTINGS_GEOTAG_CREATE_WAYPOINT, default_values.create_waypoints ); + a_settings_set_boolean ( VIK_SETTINGS_GEOTAG_OVERWRITE_WAYPOINTS, default_values.overwrite_waypoints ); + a_settings_set_boolean ( VIK_SETTINGS_GEOTAG_WRITE_EXIF, default_values.write_exif ); + a_settings_set_boolean ( VIK_SETTINGS_GEOTAG_OVERWRITE_GPS_EXIF, default_values.overwrite_gps_exif ); + a_settings_set_boolean ( VIK_SETTINGS_GEOTAG_NO_CHANGE_MTIME, default_values.no_change_mtime ); + a_settings_set_boolean ( VIK_SETTINGS_GEOTAG_INTERPOLATE_SEGMENTS, default_values.interpolate_segments ); + a_settings_set_integer ( VIK_SETTINGS_GEOTAG_TIME_OFFSET, default_values.time_offset ); + a_settings_set_integer ( VIK_SETTINGS_GEOTAG_TIME_OFFSET_HOURS, default_values.TimeZoneHours ); + a_settings_set_integer ( VIK_SETTINGS_GEOTAG_TIME_OFFSET_MINS, default_values.TimeZoneMins ); +} + +static option_values_t get_default_values ( ) +{ + option_values_t default_values; + if ( ! a_settings_get_boolean ( VIK_SETTINGS_GEOTAG_CREATE_WAYPOINT, &default_values.create_waypoints ) ) + default_values.create_waypoints = TRUE; + if ( ! a_settings_get_boolean ( VIK_SETTINGS_GEOTAG_OVERWRITE_WAYPOINTS, &default_values.overwrite_waypoints ) ) + default_values.overwrite_waypoints = TRUE; + if ( ! a_settings_get_boolean ( VIK_SETTINGS_GEOTAG_WRITE_EXIF, &default_values.write_exif ) ) + default_values.write_exif = TRUE; + if ( ! a_settings_get_boolean ( VIK_SETTINGS_GEOTAG_OVERWRITE_GPS_EXIF, &default_values.overwrite_gps_exif ) ) + default_values.overwrite_gps_exif = FALSE; + if ( ! a_settings_get_boolean ( VIK_SETTINGS_GEOTAG_NO_CHANGE_MTIME, &default_values.no_change_mtime ) ) + default_values.no_change_mtime = TRUE; + if ( ! a_settings_get_boolean ( VIK_SETTINGS_GEOTAG_INTERPOLATE_SEGMENTS, &default_values.interpolate_segments ) ) + default_values.interpolate_segments = TRUE; + if ( ! a_settings_get_integer ( VIK_SETTINGS_GEOTAG_TIME_OFFSET, &default_values.time_offset ) ) + default_values.time_offset = 0; + if ( ! a_settings_get_integer ( VIK_SETTINGS_GEOTAG_TIME_OFFSET_HOURS, &default_values.TimeZoneHours ) ) + default_values.TimeZoneHours = 0; + if ( ! a_settings_get_integer ( VIK_SETTINGS_GEOTAG_TIME_OFFSET_MINS, &default_values.TimeZoneMins ) ) + default_values.TimeZoneMins = 0; + return default_values; +} /** * Correlate the image against the specified track */ -static void trw_layer_geotag_track ( const gchar *name, VikTrack *track, geotag_options_t *options ) +static void trw_layer_geotag_track ( const gpointer id, VikTrack *track, geotag_options_t *options ) { // If already found match then don't need to check this track if ( options->found_match ) @@ -163,8 +206,8 @@ static void trw_layer_geotag_track ( const gchar *name, VikTrack *track, geotag_ VikTrackpoint *trkpt; VikTrackpoint *trkpt_next; - GList *mytrkpt = track->trackpoints; - for ( mytrkpt = mytrkpt; mytrkpt; mytrkpt = mytrkpt->next ) { + GList *mytrkpt; + for ( mytrkpt = track->trackpoints; mytrkpt; mytrkpt = mytrkpt->next ) { // Do something for this trackpoint... @@ -224,7 +267,28 @@ static void trw_layer_geotag_track ( const gchar *name, VikTrack *track, geotag_ options->altitude = trkpt->altitude + ((trkpt_next->altitude - trkpt->altitude) * scale); break; } - + } +} + +/** + * Simply align the images the waypoint position + */ +static void trw_layer_geotag_waypoint ( geotag_options_t *options ) +{ + // Write EXIF if specified - although a fairly useless process if you've turned it off! + if ( options->ov.write_exif ) { + gboolean has_gps_exif = FALSE; + gchar* datetime = a_geotag_get_exif_date_from_file ( options->image, &has_gps_exif ); + // If image already has gps info - don't attempt to change it unless forced + if ( options->ov.overwrite_gps_exif || !has_gps_exif ) { + gint ans = a_geotag_write_exif_gps ( options->image, options->wpt->coord, options->wpt->altitude, options->ov.no_change_mtime ); + if ( ans != 0 ) { + gchar *message = g_strdup_printf ( _("Failed updating EXIF on %s"), options->image ); + vik_window_statusbar_update ( VIK_WINDOW(VIK_GTK_WINDOW_FROM_LAYER(options->vtl)), message, VIK_STATUSBAR_INFO ); + g_free ( message ); + } + } + g_free ( datetime ); } } @@ -233,12 +297,17 @@ static void trw_layer_geotag_track ( const gchar *name, VikTrack *track, geotag_ */ static void trw_layer_geotag_process ( geotag_options_t *options ) { - if ( !options->vtl ) + if ( !options->vtl || !IS_VIK_LAYER(options->vtl) ) return; if ( !options->image ) return; + if ( options->wpt ) { + trw_layer_geotag_waypoint ( options ); + return; + } + gboolean has_gps_exif = FALSE; gchar* datetime = a_geotag_get_exif_date_from_file ( options->image, &has_gps_exif ); @@ -250,14 +319,35 @@ static void trw_layer_geotag_process ( geotag_options_t *options ) // Create waypoint with file information gchar *name = NULL; VikWaypoint *wp = a_geotag_create_waypoint_from_file ( options->image, vik_trw_layer_get_coord_mode (options->vtl), &name ); + if ( !wp ) { + // Couldn't create Waypoint + g_free ( datetime ); + return; + } if ( !name ) name = g_strdup ( a_file_basename ( options->image ) ); - vik_trw_layer_filein_add_waypoint ( options->vtl, name, wp ); + + gboolean updated_waypoint = FALSE; + + if ( options->ov.overwrite_waypoints ) { + VikWaypoint *current_wp = vik_trw_layer_get_waypoint ( options->vtl, name ); + if ( current_wp ) { + // Existing wp found, so set new position, comment and image + current_wp = a_geotag_waypoint_positioned ( options->image, wp->coord, wp->altitude, &name, current_wp ); + updated_waypoint = TRUE; + } + } + + if ( !updated_waypoint ) { + vik_trw_layer_filein_add_waypoint ( options->vtl, name, wp ); + } + g_free ( name ); // Mark for redraw options->redraw = TRUE; } + g_free ( datetime ); return; } @@ -271,7 +361,7 @@ static void trw_layer_geotag_process ( geotag_options_t *options ) if ( options->track ) { // Single specified track - // NB Doesn't care about track name + // NB Doesn't care about track id trw_layer_geotag_track ( NULL, options->track, options ); } else { @@ -287,26 +377,94 @@ static void trw_layer_geotag_process ( geotag_options_t *options ) if ( options->ov.create_waypoints ) { - // Create waypoint with found position - gchar *name = NULL; - VikWaypoint *wp = a_geotag_create_waypoint_positioned ( options->image, options->coord, options->altitude, &name ); - if ( !name ) - name = g_strdup ( a_file_basename ( options->image ) ); - vik_trw_layer_filein_add_waypoint ( options->vtl, name, wp ); - g_free ( name ); + gboolean updated_waypoint = FALSE; + + if ( options->ov.overwrite_waypoints ) { + // Update existing WP + // Find a WP with current name + gchar *name = NULL; + name = g_strdup ( a_file_basename ( options->image ) ); + VikWaypoint *wp = vik_trw_layer_get_waypoint ( options->vtl, name ); + if ( wp ) { + // Found, so set new position, comment and image + wp = a_geotag_waypoint_positioned ( options->image, options->coord, options->altitude, &name, wp ); + updated_waypoint = TRUE; + } + g_free ( name ); + } + + if ( !updated_waypoint ) { + // Create waypoint with found position + gchar *name = NULL; + VikWaypoint *wp = a_geotag_waypoint_positioned ( options->image, options->coord, options->altitude, &name, NULL ); + if ( !name ) + name = g_strdup ( a_file_basename ( options->image ) ); + vik_trw_layer_filein_add_waypoint ( options->vtl, name, wp ); + g_free ( name ); + } + // Mark for redraw options->redraw = TRUE; } // Write EXIF if specified if ( options->ov.write_exif ) { - a_geotag_write_exif_gps ( options->image, options->coord, options->altitude, options->ov.no_change_mtime ); + gint ans = a_geotag_write_exif_gps ( options->image, options->coord, options->altitude, options->ov.no_change_mtime ); + if ( ans != 0 ) { + gchar *message = g_strdup_printf ( _("Failed updating EXIF on %s"), options->image ); + vik_window_statusbar_update ( VIK_WINDOW(VIK_GTK_WINDOW_FROM_LAYER(options->vtl)), message, VIK_STATUSBAR_INFO ); + g_free ( message ); + } } } } } +/* + * Tidy up + */ +static void trw_layer_geotag_thread_free ( geotag_options_t *gtd ) +{ + if ( gtd->files ) + g_list_free ( gtd->files ); + g_free ( gtd ); +} + +/** + * Run geotagging process in a separate thread + */ +static int trw_layer_geotag_thread ( geotag_options_t *options, gpointer threaddata ) +{ + guint total = g_list_length(options->files), done = 0; + + // TODO decide how to report any issues to the user ... + + // Foreach file attempt to geotag it + while ( options->files ) { + options->image = (gchar *) ( options->files->data ); + trw_layer_geotag_process ( options ); + options->files = options->files->next; + + // Update thread progress and detect stop requests + int result = a_background_thread_progress ( threaddata, ((gdouble) ++done) / total ); + if ( result != 0 ) + return -1; /* Abort thread */ + } + + if ( options->redraw ) { + if ( IS_VIK_LAYER(options->vtl) ) { + trw_layer_calculate_bounds_waypoints ( options->vtl ); + // Ensure any new images get shown + trw_layer_verify_thumbnails ( options->vtl, NULL ); // NB second parameter not used ATM + // Force redraw as verify only redraws if there are new thumbnails (they may already exist) + vik_layer_emit_update ( VIK_LAYER(options->vtl) ); // NB Update from background + } + } + + return 0; +} + /** * Parse user input from dialog response */ @@ -319,56 +477,55 @@ static void trw_layer_geotag_response_cb ( GtkDialog *dialog, gint resp, GeoTagW default: { //GTK_RESPONSE_ACCEPT: // Get options - geotag_options_t options; - options.vtl = widgets->vtl; - options.track = widgets->track; + geotag_options_t *options = g_malloc ( sizeof(geotag_options_t) ); + options->vtl = widgets->vtl; + options->wpt = widgets->wpt; + options->track = widgets->track; // Values extracted from the widgets: - options.ov.create_waypoints = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->create_waypoints_b) ); - options.ov.write_exif = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->write_exif_b) ); - options.ov.overwrite_gps_exif = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->overwrite_gps_exif_b) ); - options.ov.no_change_mtime = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->no_change_mtime_b) ); - options.ov.interpolate_segments = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->interpolate_segments_b) ); - options.ov.TimeZoneHours = 0; - options.ov.TimeZoneMins = 0; + options->ov.create_waypoints = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->create_waypoints_b) ); + options->ov.overwrite_waypoints = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->overwrite_waypoints_b) ); + options->ov.write_exif = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->write_exif_b) ); + options->ov.overwrite_gps_exif = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->overwrite_gps_exif_b) ); + options->ov.no_change_mtime = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->no_change_mtime_b) ); + options->ov.interpolate_segments = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->interpolate_segments_b) ); + options->ov.TimeZoneHours = 0; + options->ov.TimeZoneMins = 0; const gchar* TZString = gtk_entry_get_text(GTK_ENTRY(widgets->time_zone_b)); /* Check the string. If there is a colon, then (hopefully) it's a time in xx:xx format. * If not, it's probably just a +/-xx format. In all other cases, * it will be interpreted as +/-xx, which, if given a string, returns 0. */ if (strstr(TZString, ":")) { /* Found colon. Split into two. */ - sscanf(TZString, "%d:%d", &options.ov.TimeZoneHours, &options.ov.TimeZoneMins); - if (options.ov.TimeZoneHours < 0) - options.ov.TimeZoneMins *= -1; + sscanf(TZString, "%d:%d", &options->ov.TimeZoneHours, &options->ov.TimeZoneMins); + if (options->ov.TimeZoneHours < 0) + options->ov.TimeZoneMins *= -1; } else { /* No colon. Just parse. */ - options.ov.TimeZoneHours = atoi(TZString); + options->ov.TimeZoneHours = atoi(TZString); } - options.ov.time_offset = atoi ( gtk_entry_get_text ( GTK_ENTRY(widgets->time_offset_b) ) ); + options->ov.time_offset = atoi ( gtk_entry_get_text ( GTK_ENTRY(widgets->time_offset_b) ) ); - options.redraw = FALSE; + options->redraw = FALSE; // Save settings for reuse - default_values = options.ov; - - // TODO consider if this should run in background as processing may take some time - // - especially if there are lots of images and/or large tracks - // However it seems reasonably quick on an average machine - - GList *iter = vik_file_list_get_files ( widgets->files ); - // TODO decide how to report any issues to the user ... - // Foreach file attempt to geotag it - while ( iter ) { - options.image = (gchar *) ( iter->data ); - trw_layer_geotag_process ( &options ); - iter = iter->next; - } + save_default_values ( options->ov ); - if ( options.redraw ) { - // Ensure any new images get shown - trw_layer_verify_thumbnails ( widgets->vtl, NULL ); // NB second parameter not used ATM - // Force redraw as verify only redraws if there are new thumbnails (they may already exist) - vik_layer_emit_update ( VIK_LAYER(widgets->vtl), FALSE ); - } + options->files = g_list_copy ( vik_file_list_get_files ( widgets->files ) ); + + gint len = g_list_length ( options->files ); + gchar *tmp = g_strdup_printf ( _("Geotagging %d Images..."), len ); + + // Processing lots of files can take time - so run a background effort + a_background_thread ( BACKGROUND_POOL_LOCAL, + VIK_GTK_WINDOW_FROM_LAYER(options->vtl), + tmp, + (vik_thr_func) trw_layer_geotag_thread, + options, + (vik_thr_free_func) trw_layer_geotag_thread_free, + NULL, + len ); + + g_free ( tmp ); break; } @@ -397,6 +554,18 @@ static void write_exif_b_cb ( GtkWidget *gw, GeoTagWidgets *gtw ) } } +static void create_waypoints_b_cb ( GtkWidget *gw, GeoTagWidgets *gtw ) +{ + // Overwriting waypoints are irrelevant if not going to create them! + if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(gtw->create_waypoints_b) ) ) { + gtk_widget_set_sensitive ( GTK_WIDGET(gtw->overwrite_waypoints_b), TRUE ); + gtk_widget_set_sensitive ( GTK_WIDGET(gtw->overwrite_waypoints_l), TRUE ); + } + else { + gtk_widget_set_sensitive ( GTK_WIDGET(gtw->overwrite_waypoints_b), FALSE ); + gtk_widget_set_sensitive ( GTK_WIDGET(gtw->overwrite_waypoints_l), FALSE ); + } +} /** * trw_layer_geotag_dialog: @@ -405,7 +574,10 @@ static void write_exif_b_cb ( GtkWidget *gw, GeoTagWidgets *gtw ) * @track: Optional - The particular track to use (if specified) for correlating images * @track_name: Optional - The name of specified track to use */ -void trw_layer_geotag_dialog ( GtkWindow *parent, VikTrwLayer *vtl, VikTrack *track, const gchar *track_name ) +void trw_layer_geotag_dialog ( GtkWindow *parent, + VikTrwLayer *vtl, + VikWaypoint *wpt, + VikTrack *track ) { GeoTagWidgets *widgets = geotag_widgets_new(); @@ -415,10 +587,17 @@ void trw_layer_geotag_dialog ( GtkWindow *parent, VikTrwLayer *vtl, VikTrack *tr GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL ); - widgets->files = VIK_FILE_LIST(vik_file_list_new ( _("Images") )); // TODO would be nice to be able to set a filefilter + GtkFileFilter *filter = gtk_file_filter_new (); + gtk_file_filter_set_name ( filter, _("JPG") ); + gtk_file_filter_add_mime_type ( filter, "image/jpeg"); + + widgets->files = VIK_FILE_LIST(vik_file_list_new ( _("Images"), filter )); widgets->vtl = vtl; + widgets->wpt = wpt; widgets->track = track; widgets->create_waypoints_b = GTK_CHECK_BUTTON ( gtk_check_button_new () ); + widgets->overwrite_waypoints_l = GTK_LABEL ( gtk_label_new ( _("Overwrite Existing Waypoints:") ) ); + widgets->overwrite_waypoints_b = GTK_CHECK_BUTTON ( gtk_check_button_new () ); widgets->write_exif_b = GTK_CHECK_BUTTON ( gtk_check_button_new () ); widgets->overwrite_gps_exif_l = GTK_LABEL ( gtk_label_new ( _("Overwrite Existing GPS Information:") ) ); widgets->overwrite_gps_exif_b = GTK_CHECK_BUTTON ( gtk_check_button_new () ); @@ -431,8 +610,11 @@ void trw_layer_geotag_dialog ( GtkWindow *parent, VikTrwLayer *vtl, VikTrack *tr gtk_entry_set_width_chars ( widgets->time_zone_b, 7); gtk_entry_set_width_chars ( widgets->time_offset_b, 7); - // Defaults - TODO restore previous values / save settings somewhere?? + // Defaults + option_values_t default_values = get_default_values (); + gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(widgets->create_waypoints_b), default_values.create_waypoints ); + gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(widgets->overwrite_waypoints_b), default_values.overwrite_waypoints ); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(widgets->write_exif_b), default_values.write_exif ); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(widgets->overwrite_gps_exif_b), default_values.overwrite_gps_exif ); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(widgets->no_change_mtime_b), default_values.no_change_mtime ); @@ -445,13 +627,20 @@ void trw_layer_geotag_dialog ( GtkWindow *parent, VikTrwLayer *vtl, VikTrack *tr // Ensure sensitivities setup write_exif_b_cb ( GTK_WIDGET(widgets->write_exif_b), widgets ); - g_signal_connect ( G_OBJECT(widgets->write_exif_b), "toggled", G_CALLBACK(write_exif_b_cb), widgets ); + create_waypoints_b_cb ( GTK_WIDGET(widgets->create_waypoints_b), widgets ); + g_signal_connect ( G_OBJECT(widgets->create_waypoints_b), "toggled", G_CALLBACK(create_waypoints_b_cb), widgets ); + GtkWidget *cw_hbox = gtk_hbox_new ( FALSE, 0 ); - gtk_box_pack_start ( GTK_BOX(cw_hbox), gtk_label_new ( _("Create Waypoints:") ), FALSE, FALSE, 5 ); + GtkWidget *create_waypoints_l = gtk_label_new ( _("Create Waypoints:") ); + gtk_box_pack_start ( GTK_BOX(cw_hbox), create_waypoints_l, FALSE, FALSE, 5 ); gtk_box_pack_start ( GTK_BOX(cw_hbox), GTK_WIDGET(widgets->create_waypoints_b), FALSE, FALSE, 5 ); + GtkWidget *ow_hbox = gtk_hbox_new ( FALSE, 0 ); + gtk_box_pack_start ( GTK_BOX(ow_hbox), GTK_WIDGET(widgets->overwrite_waypoints_l), FALSE, FALSE, 5 ); + gtk_box_pack_start ( GTK_BOX(ow_hbox), GTK_WIDGET(widgets->overwrite_waypoints_b), FALSE, FALSE, 5 ); + GtkWidget *we_hbox = gtk_hbox_new ( FALSE, 0 ); gtk_box_pack_start ( GTK_BOX(we_hbox), gtk_label_new ( _("Write EXIF:") ), FALSE, FALSE, 5 ); gtk_box_pack_start ( GTK_BOX(we_hbox), GTK_WIDGET(widgets->write_exif_b), FALSE, FALSE, 5 ); @@ -465,36 +654,54 @@ void trw_layer_geotag_dialog ( GtkWindow *parent, VikTrwLayer *vtl, VikTrack *tr gtk_box_pack_start ( GTK_BOX(fm_hbox), GTK_WIDGET(widgets->no_change_mtime_b), FALSE, FALSE, 5 ); GtkWidget *is_hbox = gtk_hbox_new ( FALSE, 0 ); - gtk_box_pack_start ( GTK_BOX(is_hbox), gtk_label_new ( _("Interpolate Between Track Segments:") ), FALSE, FALSE, 5 ); + GtkWidget *interpolate_segments_l = gtk_label_new ( _("Interpolate Between Track Segments:") ); + gtk_box_pack_start ( GTK_BOX(is_hbox), interpolate_segments_l, FALSE, FALSE, 5 ); gtk_box_pack_start ( GTK_BOX(is_hbox), GTK_WIDGET(widgets->interpolate_segments_b), FALSE, FALSE, 5 ); GtkWidget *to_hbox = gtk_hbox_new ( FALSE, 0 ); - gtk_box_pack_start ( GTK_BOX(to_hbox), gtk_label_new ( _("Image Time Offset (Seconds):") ), FALSE, FALSE, 5 ); + GtkWidget *time_offset_l = gtk_label_new ( _("Image Time Offset (Seconds):") ); + gtk_box_pack_start ( GTK_BOX(to_hbox), time_offset_l, FALSE, FALSE, 5 ); gtk_box_pack_start ( GTK_BOX(to_hbox), GTK_WIDGET(widgets->time_offset_b), FALSE, FALSE, 5 ); gtk_widget_set_tooltip_text ( GTK_WIDGET(widgets->time_offset_b), _("The number of seconds to ADD to the photos time to make it match the GPS data. Calculate this with (GPS - Photo). Can be negative or positive. Useful to adjust times when a camera's timestamp was incorrect.") ); GtkWidget *tz_hbox = gtk_hbox_new ( FALSE, 0 ); - gtk_box_pack_start ( GTK_BOX(tz_hbox), gtk_label_new ( _("Image Timezone:") ), FALSE, FALSE, 5 ); + GtkWidget *time_zone_l = gtk_label_new ( _("Image Timezone:") ); + gtk_box_pack_start ( GTK_BOX(tz_hbox), time_zone_l, FALSE, FALSE, 5 ); gtk_box_pack_start ( GTK_BOX(tz_hbox), GTK_WIDGET(widgets->time_zone_b), FALSE, FALSE, 5 ); gtk_widget_set_tooltip_text ( GTK_WIDGET(widgets->time_zone_b), _("The timezone that was used when the images were created. For example, if a camera is set to AWST or +8:00 hours. Enter +8:00 here so that the correct adjustment to the images' time can be made. GPS data is always in UTC.") ); gchar *track_string = NULL; - if ( widgets->track ) - track_string = g_strdup_printf ( _("Using track: %s"), track_name ); + if ( widgets->wpt ) { + track_string = g_strdup_printf ( _("Using waypoint: %s"), wpt->name ); + // Control sensitivities + gtk_widget_set_sensitive ( GTK_WIDGET(widgets->create_waypoints_b), FALSE ); + gtk_widget_set_sensitive ( GTK_WIDGET(create_waypoints_l), FALSE ); + gtk_widget_set_sensitive ( GTK_WIDGET(widgets->overwrite_waypoints_b), FALSE ); + gtk_widget_set_sensitive ( GTK_WIDGET(widgets->overwrite_waypoints_l), FALSE ); + gtk_widget_set_sensitive ( GTK_WIDGET(widgets->interpolate_segments_b), FALSE ); + gtk_widget_set_sensitive ( GTK_WIDGET(interpolate_segments_l), FALSE ); + gtk_widget_set_sensitive ( GTK_WIDGET(widgets->time_offset_b), FALSE ); + gtk_widget_set_sensitive ( GTK_WIDGET(time_offset_l), FALSE ); + gtk_widget_set_sensitive ( GTK_WIDGET(widgets->time_zone_b), FALSE ); + gtk_widget_set_sensitive ( GTK_WIDGET(time_zone_l), FALSE ); + } + else if ( widgets->track ) + track_string = g_strdup_printf ( _("Using track: %s"), track->name ); else track_string = g_strdup_printf ( _("Using all tracks in: %s"), VIK_LAYER(widgets->vtl)->name ); - gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), gtk_label_new ( track_string ), FALSE, FALSE, 5 ); + gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(widgets->dialog))), gtk_label_new ( track_string ), FALSE, FALSE, 5 ); - gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), GTK_WIDGET(widgets->files), TRUE, TRUE, 0 ); + gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(widgets->dialog))), GTK_WIDGET(widgets->files), TRUE, TRUE, 0 ); - gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), cw_hbox, FALSE, FALSE, 0); - gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), we_hbox, FALSE, FALSE, 0); - gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), og_hbox, FALSE, FALSE, 0); - gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), fm_hbox, FALSE, FALSE, 0); - gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), is_hbox, FALSE, FALSE, 0); - gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), to_hbox, FALSE, FALSE, 0); - gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), tz_hbox, FALSE, FALSE, 0); + gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(widgets->dialog))), cw_hbox, FALSE, FALSE, 0); + gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(widgets->dialog))), ow_hbox, FALSE, FALSE, 0); + gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(widgets->dialog))), we_hbox, FALSE, FALSE, 0); + gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(widgets->dialog))), og_hbox, FALSE, FALSE, 0); + gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(widgets->dialog))), fm_hbox, FALSE, FALSE, 0); + gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(widgets->dialog))), is_hbox, FALSE, FALSE, 0); + gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(widgets->dialog))), to_hbox, FALSE, FALSE, 0); + gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(widgets->dialog))), tz_hbox, FALSE, FALSE, 0); g_signal_connect ( widgets->dialog, "response", G_CALLBACK(trw_layer_geotag_response_cb), widgets );