]> git.street.me.uk Git - andy/viking.git/blob - src/viktrwlayer_geotag.c
Merge tag 'viking-1.2.2'
[andy/viking.git] / src / viktrwlayer_geotag.c
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3  * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4  *
5  * Copyright (C) 2011, Rob Norris <rw_norris@hotmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22 /*
23  *  Similar to the track and trackpoint properties dialogs,
24  *   this is made a separate file for ease of grouping related stuff together
25  */
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29 #include <math.h>
30 #include <time.h>
31 #include <string.h>
32 #include <stdlib.h>
33 #include <gtk/gtk.h>
34 #include <glib/gi18n.h>
35 #include "viking.h"
36 #include "vikfilelist.h"
37 #include "geotag_exif.h"
38 #include "thumbnails.h"
39 #include "background.h"
40
41 // Function taken from GPSCorrelate 1.6.1
42 // ConvertToUnixTime Copyright 2005 Daniel Foote. GPL2+
43
44 #define EXIF_DATE_FORMAT "%d:%d:%d %d:%d:%d"
45
46 time_t ConvertToUnixTime(char* StringTime, char* Format, int TZOffsetHours, int TZOffsetMinutes)
47 {
48         /* Read the time using the specified format.
49          * The format and string being read from must
50          * have the most significant time on the left,
51          * and the least significant on the right:
52          * ie, Year on the left, seconds on the right. */
53
54         /* Sanity check... */
55         if (StringTime == NULL || Format == NULL)
56         {
57                 return 0;
58         }
59
60         /* Define and set up our structure. */
61         struct tm Time;
62         Time.tm_wday = 0;
63         Time.tm_yday = 0;
64         Time.tm_isdst = -1;
65
66         /* Read out the time from the string using our format. */
67         sscanf(StringTime, Format, &Time.tm_year, &Time.tm_mon,
68                         &Time.tm_mday, &Time.tm_hour,
69                         &Time.tm_min, &Time.tm_sec);
70
71         /* Adjust the years for the mktime function to work. */
72         Time.tm_year -= 1900;
73         Time.tm_mon  -= 1;
74
75         /* Add our timezone offset to the time.
76          * We don't check to see if it overflowed anything;
77          * mktime does this and fixes it for us. */
78         /* Note also that we SUBTRACT these times. We want the
79          * result to be in UTC. */
80
81         Time.tm_hour -= TZOffsetHours;
82         Time.tm_min  -= TZOffsetMinutes;
83
84         /* Calculate and return the unix time. */
85         return mktime(&Time);
86 }
87
88 // GPSCorrelate END
89
90 typedef struct {
91         GtkWidget *dialog;
92         VikFileList *files;
93         VikTrwLayer *vtl;    // to pass on
94         VikTrack *track;     // Use specified track or all tracks if NULL
95         GtkCheckButton *create_waypoints_b;
96         GtkCheckButton *write_exif_b;
97         GtkLabel *overwrite_gps_exif_l; // Referenced so the sensitivity can be changed
98         GtkCheckButton *overwrite_gps_exif_b;
99         GtkLabel *no_change_mtime_l; // Referenced so the sensitivity can be changed
100         GtkCheckButton *no_change_mtime_b;
101         GtkCheckButton *interpolate_segments_b;
102         GtkEntry *time_zone_b; // TODO consider a more user friendly tz widget eg libtimezonemap or similar
103         GtkEntry *time_offset_b;
104 } GeoTagWidgets;
105
106 static GeoTagWidgets *geotag_widgets_new()
107 {
108         GeoTagWidgets *widgets = g_malloc0(sizeof(GeoTagWidgets));
109         return widgets;
110 }
111
112 static void geotag_widgets_free ( GeoTagWidgets *widgets )
113 {
114         // Need to free VikFileList??
115         g_free(widgets);
116 }
117
118 typedef struct {
119         gboolean create_waypoints;
120         gboolean write_exif;
121         gboolean overwrite_gps_exif;
122         gboolean no_change_mtime;
123         gboolean interpolate_segments;
124         gint time_offset;
125         gint TimeZoneHours;
126         gint TimeZoneMins;
127 } option_values_t;
128
129 typedef struct {
130         VikTrwLayer *vtl;
131         gchar *image;
132         VikTrack *track;     // Use specified track or all tracks if NULL
133         // User options...
134         option_values_t ov;
135         GList *files;
136         time_t PhotoTime;
137         // Store answer from interpolation for an image
138         gboolean found_match;
139         VikCoord coord;
140         gdouble altitude;
141         // If anything has changed
142         gboolean redraw;
143 } geotag_options_t;
144
145 static option_values_t default_values = {
146         TRUE,
147         TRUE,
148         FALSE,
149         TRUE,
150         TRUE,
151         0,
152         0,
153         0,
154 };
155
156 /**
157  * Correlate the image against the specified track
158  */
159 static void trw_layer_geotag_track ( const gchar *name, VikTrack *track, geotag_options_t *options )
160 {
161         // If already found match then don't need to check this track
162         if ( options->found_match )
163                 return;
164
165         VikTrackpoint *trkpt;
166         VikTrackpoint *trkpt_next;
167
168         GList *mytrkpt = track->trackpoints;
169         for ( mytrkpt = mytrkpt; mytrkpt; mytrkpt = mytrkpt->next ) {
170
171                 // Do something for this trackpoint...
172
173                 trkpt = VIK_TRACKPOINT(mytrkpt->data);
174
175                 // is it exactly this point?
176                 if ( options->PhotoTime == trkpt->timestamp ) {
177                         options->coord = trkpt->coord;
178                         options->altitude = trkpt->altitude;
179                         options->found_match = TRUE;
180                         break;
181                 }
182
183                 // Now need two trackpoints, hence check next is available
184                 if ( !mytrkpt->next ) break;
185                 trkpt_next = VIK_TRACKPOINT(mytrkpt->next->data);
186
187                 // TODO need to use 'has_timestamp' property
188                 if ( trkpt->timestamp == trkpt_next->timestamp ) continue;
189                 if ( trkpt->timestamp > trkpt_next->timestamp ) continue;
190
191                 // When interpolating between segments, no need for any special segment handling
192                 if ( !options->ov.interpolate_segments )
193                         // Don't check between segments
194                         if ( trkpt_next->newsegment )
195                                 // Simply move on to consider next point
196                                 continue;
197
198                 // Too far
199                 if ( trkpt->timestamp > options->PhotoTime ) break;
200
201                 // Is is between this and the next point?
202                 if ( (options->PhotoTime > trkpt->timestamp) && (options->PhotoTime < trkpt_next->timestamp) ) {
203                         options->found_match = TRUE;
204                         // Interpolate
205                         /* Calculate the "scale": a decimal giving the relative distance
206                          * in time between the two points. Ie, a number between 0 and 1 -
207                          * 0 is the first point, 1 is the next point, and 0.5 would be
208                          * half way. */
209                         gdouble scale = (gdouble)trkpt_next->timestamp - (gdouble)trkpt->timestamp;
210                         scale = ((gdouble)options->PhotoTime - (gdouble)trkpt->timestamp) / scale;
211
212                         struct LatLon ll_result, ll1, ll2;
213
214                         vik_coord_to_latlon ( &(trkpt->coord), &ll1 );
215                         vik_coord_to_latlon ( &(trkpt_next->coord), &ll2 );
216
217                         ll_result.lat = ll1.lat + ((ll2.lat - ll1.lat) * scale);
218
219                         // NB This won't cope with going over the 180 degrees longitude boundary
220                         ll_result.lon = ll1.lon + ((ll2.lon - ll1.lon) * scale);
221
222                         // set coord
223                         vik_coord_load_from_latlon ( &(options->coord), VIK_COORD_LATLON, &ll_result );
224
225                         // Interpolate elevation
226                         options->altitude = trkpt->altitude + ((trkpt_next->altitude - trkpt->altitude) * scale);
227                         break;
228                 }
229                         
230         }
231 }
232
233 /**
234  * Correlate the image to any track within the TrackWaypoint layer
235  */
236 static void trw_layer_geotag_process ( geotag_options_t *options )
237 {
238         if ( !options->vtl || !IS_VIK_LAYER(options->vtl) )
239                 return;
240
241         if ( !options->image )
242                 return;
243
244         gboolean has_gps_exif = FALSE;
245         gchar* datetime = a_geotag_get_exif_date_from_file ( options->image, &has_gps_exif );
246
247         if ( datetime ) {
248         
249                 // If image already has gps info - don't attempt to change it.
250                 if ( !options->ov.overwrite_gps_exif && has_gps_exif ) {
251                         if ( options->ov.create_waypoints ) {
252                                 // Create waypoint with file information
253                                 gchar *name = NULL;
254                                 VikWaypoint *wp = a_geotag_create_waypoint_from_file ( options->image, vik_trw_layer_get_coord_mode (options->vtl), &name );
255                                 if ( !name )
256                                         name = g_strdup ( a_file_basename ( options->image ) );
257                                 vik_trw_layer_filein_add_waypoint ( options->vtl, name, wp );
258                                 g_free ( name );
259                                 
260                                 // Mark for redraw
261                                 options->redraw = TRUE;
262                         }
263                         g_free ( datetime );
264                         return;
265                 }
266
267                 options->PhotoTime = ConvertToUnixTime ( datetime, EXIF_DATE_FORMAT, options->ov.TimeZoneHours, options->ov.TimeZoneMins);
268                 g_free ( datetime );
269                 
270                 // Apply any offset
271                 options->PhotoTime = options->PhotoTime + options->ov.time_offset;
272
273                 options->found_match = FALSE;
274
275                 if ( options->track ) {
276                         // Single specified track
277                         // NB Doesn't care about track name
278                         trw_layer_geotag_track ( NULL, options->track, options );
279                 }
280                 else {
281                         // Try all tracks
282                         GHashTable *tracks = vik_trw_layer_get_tracks ( options->vtl );
283                         if ( g_hash_table_size (tracks) > 0 ) {
284                                 g_hash_table_foreach ( tracks, (GHFunc) trw_layer_geotag_track, options );
285                         }
286                 }
287
288                 // Match found ?
289                 if ( options->found_match ) {
290
291                         if ( options->ov.create_waypoints ) {
292
293                                 // Create waypoint with found position
294                                 gchar *name = NULL;
295                                 VikWaypoint *wp = a_geotag_create_waypoint_positioned ( options->image, options->coord, options->altitude, &name );
296                                 if ( !name )
297                                         name = g_strdup ( a_file_basename ( options->image ) );
298                                 vik_trw_layer_filein_add_waypoint ( options->vtl, name, wp );
299                                 g_free ( name );
300                                 
301                                 // Mark for redraw
302                                 options->redraw = TRUE;
303                         }
304
305                         // Write EXIF if specified
306                         if ( options->ov.write_exif ) {
307                                 a_geotag_write_exif_gps ( options->image, options->coord, options->altitude, options->ov.no_change_mtime );
308                         }
309                 }
310         }
311 }
312
313 /*
314  * Tidy up
315  */
316 static void trw_layer_geotag_thread_free ( geotag_options_t *gtd )
317 {
318         if ( gtd->files )
319                 g_list_free ( gtd->files );
320         g_free ( gtd );
321 }
322
323 /**
324  * Run geotagging process in a separate thread
325  */
326 static int trw_layer_geotag_thread ( geotag_options_t *options, gpointer threaddata )
327 {
328         guint total = g_list_length(options->files), done = 0;
329
330         // TODO decide how to report any issues to the user ...
331
332         // Foreach file attempt to geotag it
333         while ( options->files ) {
334                 options->image = (gchar *) ( options->files->data );
335                 trw_layer_geotag_process ( options );
336                 options->files = options->files->next;
337
338                 // Update thread progress and detect stop requests
339                 int result = a_background_thread_progress ( threaddata, ((gdouble) ++done) / total );
340                 if ( result != 0 )
341                         return -1; /* Abort thread */
342         }
343
344         if ( options->redraw ) {
345                 if ( IS_VIK_LAYER(options->vtl) ) {
346                         // Ensure any new images get shown
347                         trw_layer_verify_thumbnails ( options->vtl, NULL ); // NB second parameter not used ATM
348                         // Force redraw as verify only redraws if there are new thumbnails (they may already exist)
349                         vik_layer_emit_update ( VIK_LAYER(options->vtl), TRUE ); // Update from background
350                 }
351         }
352
353         return 0;
354 }
355
356 /**
357  * Parse user input from dialog response
358  */
359 static void trw_layer_geotag_response_cb ( GtkDialog *dialog, gint resp, GeoTagWidgets *widgets )
360 {
361         switch (resp) {
362     case GTK_RESPONSE_DELETE_EVENT: /* received delete event (not from buttons) */
363     case GTK_RESPONSE_REJECT:
364                 break;
365         default: {
366                 //GTK_RESPONSE_ACCEPT:
367                 // Get options
368                 geotag_options_t *options = g_malloc ( sizeof(geotag_options_t) );
369                 options->vtl = widgets->vtl;
370                 options->track = widgets->track;
371                 // Values extracted from the widgets:
372                 options->ov.create_waypoints = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->create_waypoints_b) );
373                 options->ov.write_exif = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->write_exif_b) );
374                 options->ov.overwrite_gps_exif = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->overwrite_gps_exif_b) );
375                 options->ov.no_change_mtime = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->no_change_mtime_b) );
376                 options->ov.interpolate_segments = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->interpolate_segments_b) );
377                 options->ov.TimeZoneHours = 0;
378                 options->ov.TimeZoneMins = 0;
379                 const gchar* TZString = gtk_entry_get_text(GTK_ENTRY(widgets->time_zone_b));
380                 /* Check the string. If there is a colon, then (hopefully) it's a time in xx:xx format.
381                  * If not, it's probably just a +/-xx format. In all other cases,
382                  * it will be interpreted as +/-xx, which, if given a string, returns 0. */
383                 if (strstr(TZString, ":")) {
384                         /* Found colon. Split into two. */
385                         sscanf(TZString, "%d:%d", &options->ov.TimeZoneHours, &options->ov.TimeZoneMins);
386                         if (options->ov.TimeZoneHours < 0)
387                                 options->ov.TimeZoneMins *= -1;
388                 } else {
389                         /* No colon. Just parse. */
390                         options->ov.TimeZoneHours = atoi(TZString);
391                 }
392                 options->ov.time_offset = atoi ( gtk_entry_get_text ( GTK_ENTRY(widgets->time_offset_b) ) );
393
394                 options->redraw = FALSE;
395
396                 // Save settings for reuse
397                 default_values = options->ov;
398
399                 options->files = g_list_copy ( vik_file_list_get_files ( widgets->files ) );
400
401                 gint len = g_list_length ( options->files );
402                 gchar *tmp = g_strdup_printf ( _("Geotagging %d Images..."), len );
403
404                 // Processing lots of files can take time - so run a background effort
405                 a_background_thread ( VIK_GTK_WINDOW_FROM_LAYER(options->vtl),
406                                                           tmp,
407                                                           (vik_thr_func) trw_layer_geotag_thread,
408                                                           options,
409                                                           (vik_thr_free_func) trw_layer_geotag_thread_free,
410                                                           NULL,
411                                                           len );
412
413                 g_free ( tmp );
414
415                 break;
416         }
417         }
418         geotag_widgets_free ( widgets );
419         gtk_widget_destroy ( GTK_WIDGET(dialog) );
420 }
421
422 /**
423  * Handle widget sensitivities
424  */
425 static void write_exif_b_cb ( GtkWidget *gw, GeoTagWidgets *gtw )
426 {
427         // Overwriting & file modification times are irrelevant if not going to write EXIF!
428         if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(gtw->write_exif_b) ) ) {
429                 gtk_widget_set_sensitive ( GTK_WIDGET(gtw->overwrite_gps_exif_b), TRUE );
430                 gtk_widget_set_sensitive ( GTK_WIDGET(gtw->overwrite_gps_exif_l), TRUE );
431                 gtk_widget_set_sensitive ( GTK_WIDGET(gtw->no_change_mtime_b), TRUE );
432                 gtk_widget_set_sensitive ( GTK_WIDGET(gtw->no_change_mtime_l), TRUE );
433         }
434         else {
435                 gtk_widget_set_sensitive ( GTK_WIDGET(gtw->overwrite_gps_exif_b), FALSE );
436                 gtk_widget_set_sensitive ( GTK_WIDGET(gtw->overwrite_gps_exif_l), FALSE );
437                 gtk_widget_set_sensitive ( GTK_WIDGET(gtw->no_change_mtime_b), FALSE );
438                 gtk_widget_set_sensitive ( GTK_WIDGET(gtw->no_change_mtime_l), FALSE );
439         }
440 }
441
442
443 /**
444  * trw_layer_geotag_dialog:
445  * @parent: The Window of the calling process
446  * @vtl: The VikTrwLayer to use for correlating images to tracks
447  * @track: Optional - The particular track to use (if specified) for correlating images
448  * @track_name: Optional - The name of specified track to use
449  */
450 void trw_layer_geotag_dialog ( GtkWindow *parent, VikTrwLayer *vtl, VikTrack *track, const gchar *track_name )
451 {
452         GeoTagWidgets *widgets = geotag_widgets_new();
453
454         widgets->dialog = gtk_dialog_new_with_buttons ( _("Geotag Images"),
455                                                                                                         parent,
456                                                                                                         GTK_DIALOG_DESTROY_WITH_PARENT,
457                                                                                                         GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
458                                                                                                         GTK_STOCK_OK,     GTK_RESPONSE_ACCEPT,
459                                                                                                         NULL );
460         widgets->files = VIK_FILE_LIST(vik_file_list_new ( _("Images") )); // TODO would be nice to be able to set a filefilter
461         widgets->vtl = vtl;
462         widgets->track = track;
463         widgets->create_waypoints_b = GTK_CHECK_BUTTON ( gtk_check_button_new () );
464         widgets->write_exif_b = GTK_CHECK_BUTTON ( gtk_check_button_new () );
465         widgets->overwrite_gps_exif_l = GTK_LABEL ( gtk_label_new ( _("Overwrite Existing GPS Information:") ) );
466         widgets->overwrite_gps_exif_b = GTK_CHECK_BUTTON ( gtk_check_button_new () );
467         widgets->no_change_mtime_l = GTK_LABEL ( gtk_label_new ( _("Keep File Modification Timestamp:") ) );
468         widgets->no_change_mtime_b = GTK_CHECK_BUTTON ( gtk_check_button_new () );
469         widgets->interpolate_segments_b = GTK_CHECK_BUTTON ( gtk_check_button_new () );
470         widgets->time_zone_b = GTK_ENTRY ( gtk_entry_new () );
471         widgets->time_offset_b = GTK_ENTRY ( gtk_entry_new () );
472
473         gtk_entry_set_width_chars ( widgets->time_zone_b, 7);
474         gtk_entry_set_width_chars ( widgets->time_offset_b, 7);
475
476         // Defaults - TODO restore previous values / save settings somewhere??
477         gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(widgets->create_waypoints_b), default_values.create_waypoints );
478         gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(widgets->write_exif_b), default_values.write_exif );
479         gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(widgets->overwrite_gps_exif_b), default_values.overwrite_gps_exif );
480         gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(widgets->no_change_mtime_b), default_values.no_change_mtime );
481         gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(widgets->interpolate_segments_b), default_values.interpolate_segments );
482         gchar tmp_string[7];
483         snprintf (tmp_string, 7, "%+02d:%02d", default_values.TimeZoneHours, abs (default_values.TimeZoneMins) );
484         gtk_entry_set_text ( widgets->time_zone_b, tmp_string );
485         snprintf (tmp_string, 7, "%d", default_values.time_offset );
486         gtk_entry_set_text ( widgets->time_offset_b, tmp_string );
487
488         // Ensure sensitivities setup
489         write_exif_b_cb ( GTK_WIDGET(widgets->write_exif_b), widgets );
490
491         g_signal_connect ( G_OBJECT(widgets->write_exif_b), "toggled", G_CALLBACK(write_exif_b_cb), widgets );
492
493         GtkWidget *cw_hbox = gtk_hbox_new ( FALSE, 0 );
494         gtk_box_pack_start ( GTK_BOX(cw_hbox), gtk_label_new ( _("Create Waypoints:") ), FALSE, FALSE, 5 );
495         gtk_box_pack_start ( GTK_BOX(cw_hbox), GTK_WIDGET(widgets->create_waypoints_b), FALSE, FALSE, 5 );
496
497         GtkWidget *we_hbox = gtk_hbox_new ( FALSE, 0 );
498         gtk_box_pack_start ( GTK_BOX(we_hbox), gtk_label_new ( _("Write EXIF:") ), FALSE, FALSE, 5 );
499         gtk_box_pack_start ( GTK_BOX(we_hbox), GTK_WIDGET(widgets->write_exif_b), FALSE, FALSE, 5 );
500
501         GtkWidget *og_hbox = gtk_hbox_new ( FALSE, 0 );
502         gtk_box_pack_start ( GTK_BOX(og_hbox), GTK_WIDGET(widgets->overwrite_gps_exif_l), FALSE, FALSE, 5 );
503         gtk_box_pack_start ( GTK_BOX(og_hbox), GTK_WIDGET(widgets->overwrite_gps_exif_b), FALSE, FALSE, 5 );
504
505         GtkWidget *fm_hbox = gtk_hbox_new ( FALSE, 0 );
506         gtk_box_pack_start ( GTK_BOX(fm_hbox), GTK_WIDGET(widgets->no_change_mtime_l), FALSE, FALSE, 5 );
507         gtk_box_pack_start ( GTK_BOX(fm_hbox), GTK_WIDGET(widgets->no_change_mtime_b), FALSE, FALSE, 5 );
508
509         GtkWidget *is_hbox = gtk_hbox_new ( FALSE, 0 );
510         gtk_box_pack_start ( GTK_BOX(is_hbox), gtk_label_new ( _("Interpolate Between Track Segments:") ), FALSE, FALSE, 5 );
511         gtk_box_pack_start ( GTK_BOX(is_hbox), GTK_WIDGET(widgets->interpolate_segments_b), FALSE, FALSE, 5 );
512
513         GtkWidget *to_hbox = gtk_hbox_new ( FALSE, 0 );
514         gtk_box_pack_start ( GTK_BOX(to_hbox), gtk_label_new ( _("Image Time Offset (Seconds):") ), FALSE, FALSE, 5 );
515         gtk_box_pack_start ( GTK_BOX(to_hbox), GTK_WIDGET(widgets->time_offset_b), FALSE, FALSE, 5 );
516         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.") );
517
518         GtkWidget *tz_hbox = gtk_hbox_new ( FALSE, 0 );
519         gtk_box_pack_start ( GTK_BOX(tz_hbox), gtk_label_new ( _("Image Timezone:") ), FALSE, FALSE, 5 );
520         gtk_box_pack_start ( GTK_BOX(tz_hbox), GTK_WIDGET(widgets->time_zone_b), FALSE, FALSE, 5 );
521         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.") );
522
523         gchar *track_string = NULL;
524         if ( widgets->track )
525                 track_string = g_strdup_printf ( _("Using track: %s"), track_name );
526         else
527                 track_string = g_strdup_printf ( _("Using all tracks in: %s"), VIK_LAYER(widgets->vtl)->name );
528
529         gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), gtk_label_new ( track_string ), FALSE, FALSE, 5 );
530
531         gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), GTK_WIDGET(widgets->files), TRUE, TRUE, 0 );
532
533         gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), cw_hbox,  FALSE, FALSE, 0);
534         gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), we_hbox,  FALSE, FALSE, 0);
535         gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), og_hbox,  FALSE, FALSE, 0);
536         gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), fm_hbox,  FALSE, FALSE, 0);
537         gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), is_hbox,  FALSE, FALSE, 0);
538         gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), to_hbox,  FALSE, FALSE, 0);
539         gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(widgets->dialog)->vbox), tz_hbox,  FALSE, FALSE, 0);
540
541         g_signal_connect ( widgets->dialog, "response", G_CALLBACK(trw_layer_geotag_response_cb), widgets );
542
543         gtk_dialog_set_default_response ( GTK_DIALOG(widgets->dialog), GTK_RESPONSE_REJECT );
544
545         gtk_widget_show_all ( widgets->dialog );
546
547         g_free ( track_string );
548 }