forked from freefoote/gpscorrelate
-
Notifications
You must be signed in to change notification settings - Fork 8
/
gui.c
1840 lines (1621 loc) · 64.6 KB
/
gui.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* gui.c
* Originally written by Daniel Foote.
*
* The base of this file was generated with Glade, and then
* hand edited by me for some strange reason.
*
* This file contains the code to create, generate, and look after
* a GTK GUI for the photo correlation program. */
/* This is "basically" the GUI version of it. The only other
* part of the gui program is main-gui.c, but that ended up
* being little more than a "stub" to get the GUI up and running. */
/* Copyright 2005-2020 Daniel Foote, Dan Fandrich.
*
* This file is part of gpscorrelate.
*
* gpscorrelate is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* gpscorrelate is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gpscorrelate; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "i18n.h"
#include "gpsstructure.h"
#include "gui.h"
#include "exif-gps.h"
#include "gpx-read.h"
#include "correlate.h"
/* Declare all our widgets. Global to this module. */
GtkWidget *MatchWindow;
GtkWidget *WindowHBox;
GtkWidget *ControlsVBox;
GtkWidget *AddPhotosFrame;
GtkWidget *AddPhotosAlignment;
GtkWidget *AddPhotosVBox;
GtkWidget *PhotoAddButton;
GtkWidget *PhotoRemoveButton;
GtkWidget *AddPhotosLabel;
GtkWidget *GPSDataFrame;
GtkWidget *GPSDataAlignment;
GtkWidget *GPSDataVBox;
GtkWidget *GPSSelectedLabel;
GtkWidget *SelectGPSButton;
GtkWidget *GPSDataLabel;
GtkWidget *OptionsFrame;
GtkWidget *OptionsAlignment;
GtkWidget *OptionsVBox;
GtkWidget *InterpolateCheck;
GtkWidget *NoWriteCheck;
GtkWidget *OverwriteCheck;
GtkWidget *NoMtimeCheck;
GtkWidget *BetweenSegmentsCheck;
GtkWidget *DegMinSecsCheck;
GtkWidget *AutoTimeZoneCheck;
GtkWidget *HeadingCheck;
GtkWidget *DirectionCheck;
GtkWidget *OptionsTable;
GtkWidget *MaxGapTimeLabel;
GtkWidget *MaxHeadingLabel;
GtkWidget *CameraDirectionLabel;
GtkWidget *TimeZoneLabel;
GtkWidget *PhotoOffsetLabel;
GtkWidget *GPSDatumLabel;
GtkWidget *GapTimeEntry;
GtkWidget *MaxHeadingEntry;
GtkWidget *CameraDirectionEntry;
GtkWidget *TimeZoneEntry;
GtkWidget *PhotoOffsetEntry;
GtkWidget *GPSDatumEntry;
GtkWidget *OptionsFrameLable;
GtkWidget *CorrelateFrame;
GtkWidget *CorrelateAlignment;
GtkWidget *CorrelateButton;
GtkWidget *CorrelateLabel;
GtkWidget *OtherOptionsFrame;
GtkWidget *OtherOptionsVBox;
GtkWidget *OtherOptionsAlignment;
GtkWidget *OtherOptionsLabel;
GtkWidget *StripGPSButton;
GtkWidget *HelpButton;
GtkWidget *AboutButton;
GtkWidget *PhotoListVBox;
GtkWidget *PhotoListScroll;
GtkWidget *PhotoList;
#if !GTK_CHECK_VERSION(2, 12, 0)
GtkTooltips *tooltips;
#endif
/* Enum and other stuff for the Photo list box. */
enum
{
LIST_FILENAME,
LIST_LAT,
LIST_LONG,
LIST_ELEV,
LIST_TIME,
LIST_STATE,
LIST_POINTER,
LIST_NOCOLUMNS
};
GtkListStore *PhotoListStore;
GtkCellRenderer *PhotoListRenderer;
GtkTreeViewColumn *FileColumn;
GtkTreeViewColumn *LatColumn;
GtkTreeViewColumn *LongColumn;
GtkTreeViewColumn *ElevColumn;
GtkTreeViewColumn *TimeColumn;
GtkTreeViewColumn *StateColumn;
/* Structure and variables for holding the list of
* photos in memory. */
struct GUIPhotoList {
char* Filename;
char* Time;
GtkTreeIter ListPointer;
struct GUIPhotoList* Next;
};
struct GUIPhotoList* FirstPhoto = NULL;
struct GUIPhotoList* LastPhoto = NULL;
struct GPSTrack* GPSData; // Array of track entries; empty entry is last
int NumTracks; // Number of entries at GPSData
// Default values for configuration options
static const char* const ConfigDefaults[] = {
"interpolate", "true",
"dontwrite", "false",
"nochangemtime", "false",
"betweensegments", "false",
"writeddmmss", "true",
"replace", "false",
"autotimezone", "true",
"maxgap", "90",
"heading", "true",
"maxheading", "100",
"direction", "false",
"directionoffset", "0",
"timezone", "+0:00",
"photooffset", "0",
"gpsdatum", "WGS-84",
"gpxopendir", "",
"photoopendir", "",
NULL, NULL
};
GKeyFile* GUISettings;
char* SettingsFilename;
gchar* GPXOpenDir = NULL;
gchar* PhotoOpenDir = NULL;
static gboolean DestroyWindow(GtkWidget *Widget, GdkEvent *Event, gpointer Data);
static void AddPhotosButtonPress(GtkWidget *Widget, gpointer Data);
static void AddPhotoToList(const char* Filename);
static void RemovePhotosButtonPress( GtkWidget *Widget, gpointer Data );
static void SetListItem(GtkTreeIter* Iter, const char* Filename,
const char* Time, double Lat, double Long, double Elev,
const char* PassedState, int IncludesGPS);
static void SelectGPSButtonPress( GtkWidget *Widget, gpointer Data );
static void CorrelateButtonPress( GtkWidget *Widget, gpointer Data );
static void StripGPSButtonPress( GtkWidget *Widget, gpointer Data );
static void HelpButtonPress( GtkWidget *Widget, gpointer Data );
static void AboutButtonPress( GtkWidget *Widget, gpointer Data );
static void GtkGUIUpdate(void);
/* Load settings, insert defaults. */
void LoadSettings(void)
{
/* Generate the filename. */
const char* UserHomeDir = g_get_user_config_dir();
const int FilenameLength = strlen(UserHomeDir) + 30;
SettingsFilename = (char*) malloc(sizeof(char) * FilenameLength);
if (SettingsFilename == NULL) {
fprintf(stderr, _("Out of memory.\n"));
abort();
}
snprintf(SettingsFilename, FilenameLength, "%s%c.gpscorrelaterc", UserHomeDir, G_DIR_SEPARATOR);
/* Create a new key file. */
GUISettings = g_key_file_new();
if (!g_key_file_load_from_file(GUISettings, SettingsFilename, G_KEY_FILE_KEEP_COMMENTS, NULL))
{
/* Unable to load the file. Oh well. */
}
/* Now create all the default settings. */
int i = 0;
while (ConfigDefaults[i])
{
/* If the setting doesn't exist, set the default. */
if (NULL == g_key_file_get_value(GUISettings, "default", ConfigDefaults[i], NULL))
{
g_key_file_set_value(GUISettings, "default", ConfigDefaults[i], ConfigDefaults[i+1]);
}
i += 2;
}
/* Fetch the directory settings from the file. */
PhotoOpenDir = g_key_file_get_value(GUISettings, "default", "photoopendir", NULL);
GPXOpenDir = g_key_file_get_value(GUISettings, "default", "gpxopendir", NULL);
}
void SaveSettings(void)
{
/* Save the settings to file, and deallocate the settings. */
FILE* OutputFile;
OutputFile = fopen(SettingsFilename, "w");
if (OutputFile)
{
gsize SettingsLength = 0;
gchar* SettingsString = g_key_file_to_data(GUISettings, &SettingsLength, NULL);
fwrite((void*)SettingsString, sizeof(gchar), (size_t)SettingsLength, OutputFile);
fclose(OutputFile);
g_free(SettingsString);
}
free(SettingsFilename);
}
static void entry_toggle_visibility(GtkWidget *widget,
GtkWidget *entry)
{
gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
gtk_widget_set_sensitive(entry, !active);
}
static void entry_toggle_visibility_inv(GtkWidget *widget,
GtkWidget *entry)
{
gboolean active = !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
gtk_widget_set_sensitive(entry, !active);
}
GtkWidget* CreateMatchWindow (void)
{
GError *error = NULL;
/* Load the settings. */
LoadSettings();
#if !GTK_CHECK_VERSION(2, 12, 0)
/* Get our tooltips ready. */
tooltips = gtk_tooltips_new ();
#endif
/* Start with the window itself. */
MatchWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
char title[40];
snprintf(title, sizeof(title), _("GPS Photo Correlate %s"), PACKAGE_VERSION);
gtk_window_set_title (GTK_WINDOW (MatchWindow), title);
gtk_window_set_default_size (GTK_WINDOW (MatchWindow), 792, -1);
g_signal_connect (G_OBJECT (MatchWindow), "delete_event",
G_CALLBACK (DestroyWindow), NULL);
WindowHBox = gtk_hbox_new (FALSE, 0);
gtk_widget_show (WindowHBox);
gtk_container_add (GTK_CONTAINER (MatchWindow), WindowHBox);
/* The controls side of the window. */
ControlsVBox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (ControlsVBox);
gtk_box_pack_start (GTK_BOX (WindowHBox), ControlsVBox, FALSE, TRUE, 0);
/* Add/remove photos area. */
AddPhotosFrame = gtk_frame_new (NULL);
gtk_widget_show (AddPhotosFrame);
gtk_box_pack_start (GTK_BOX (ControlsVBox), AddPhotosFrame, FALSE, FALSE, 0);
AddPhotosAlignment = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_widget_show (AddPhotosAlignment);
gtk_container_add (GTK_CONTAINER (AddPhotosFrame), AddPhotosAlignment);
gtk_alignment_set_padding (GTK_ALIGNMENT (AddPhotosAlignment), 0, 4, 12, 4);
AddPhotosVBox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (AddPhotosVBox);
gtk_container_add (GTK_CONTAINER (AddPhotosAlignment), AddPhotosVBox);
PhotoAddButton = gtk_button_new_with_mnemonic (_("Add..."));
gtk_widget_show (PhotoAddButton);
gtk_box_pack_start (GTK_BOX (AddPhotosVBox), PhotoAddButton, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (PhotoAddButton, _("Add photos to be correlated."));
#else
gtk_tooltips_set_tip (tooltips, PhotoAddButton, _("Add photos to be correlated."), NULL);
#endif
g_signal_connect (G_OBJECT (PhotoAddButton), "clicked",
G_CALLBACK (AddPhotosButtonPress), NULL);
PhotoRemoveButton = gtk_button_new_with_mnemonic (_("Remove"));
gtk_widget_show (PhotoRemoveButton);
gtk_box_pack_start (GTK_BOX (AddPhotosVBox), PhotoRemoveButton, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (PhotoRemoveButton, _("Remove selected photos from the list."));
#else
gtk_tooltips_set_tip (tooltips, PhotoRemoveButton, _("Remove selected photos from the list."), NULL);
#endif
g_signal_connect (G_OBJECT (PhotoRemoveButton), "clicked",
G_CALLBACK (RemovePhotosButtonPress), NULL);
AddPhotosLabel = gtk_label_new (_("<b>1. Add Photos</b>"));
gtk_widget_show (AddPhotosLabel);
gtk_frame_set_label_widget (GTK_FRAME (AddPhotosFrame), AddPhotosLabel);
gtk_label_set_use_markup (GTK_LABEL (AddPhotosLabel), TRUE);
/* GPS data area */
GPSDataFrame = gtk_frame_new (NULL);
gtk_widget_show (GPSDataFrame);
gtk_box_pack_start (GTK_BOX (ControlsVBox), GPSDataFrame, FALSE, FALSE, 0);
GPSDataAlignment = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_widget_show (GPSDataAlignment);
gtk_container_add (GTK_CONTAINER (GPSDataFrame), GPSDataAlignment);
gtk_alignment_set_padding (GTK_ALIGNMENT (GPSDataAlignment), 0, 4, 12, 4);
GPSDataVBox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (GPSDataVBox);
gtk_container_add (GTK_CONTAINER (GPSDataAlignment), GPSDataVBox);
GPSSelectedLabel = gtk_label_new (_("Read from: No file")); /* FIX ME: Label not appropriately sized/placed for data. */
gtk_widget_show (GPSSelectedLabel);
gtk_box_pack_start (GTK_BOX (GPSDataVBox), GPSSelectedLabel, FALSE, FALSE, 0);
gtk_label_set_ellipsize(GTK_LABEL(GPSSelectedLabel), PANGO_ELLIPSIZE_END);
/*gtk_label_set_width_chars(GTK_LABEL(GPSSelectedLabel), 20);
gtk_label_set_line_wrap(GTK_LABEL(GPSSelectedLabel), TRUE);*/
SelectGPSButton = gtk_button_new_with_mnemonic (_("Choose..."));
gtk_widget_show (SelectGPSButton);
gtk_box_pack_start (GTK_BOX (GPSDataVBox), SelectGPSButton, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (SelectGPSButton,
_("Choose GPX file from which to read GPS data. If the GPS data is not in the "
"GPX format, use a converter like GPSBabel to convert it to GPX first."));
#else
gtk_tooltips_set_tip (tooltips, SelectGPSButton,
_("Choose GPX file from which to read GPS data. If the GPS data is not in the "
"GPX format, use a converter like GPSBabel to convert it to GPX first."), NULL);
#endif
g_signal_connect (G_OBJECT (SelectGPSButton), "clicked",
G_CALLBACK (SelectGPSButtonPress), NULL);
GPSDataLabel = gtk_label_new (_("<b>2. GPS Data</b>"));
gtk_widget_show (GPSDataLabel);
gtk_frame_set_label_widget (GTK_FRAME (GPSDataFrame), GPSDataLabel);
gtk_label_set_use_markup (GTK_LABEL (GPSDataLabel), TRUE);
/* Options area. */
OptionsFrame = gtk_frame_new (NULL);
gtk_widget_show (OptionsFrame);
gtk_box_pack_start (GTK_BOX (ControlsVBox), OptionsFrame, FALSE, FALSE, 0);
OptionsAlignment = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_widget_show (OptionsAlignment);
gtk_container_add (GTK_CONTAINER (OptionsFrame), OptionsAlignment);
gtk_alignment_set_padding (GTK_ALIGNMENT (OptionsAlignment), 0, 4, 12, 4);
OptionsVBox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (OptionsVBox);
gtk_container_add (GTK_CONTAINER (OptionsAlignment), OptionsVBox);
InterpolateCheck = gtk_check_button_new_with_mnemonic (_("Interpolate"));
gtk_widget_show (InterpolateCheck);
gtk_box_pack_start (GTK_BOX (OptionsVBox), InterpolateCheck, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (InterpolateCheck,
_("Interpolate between points. If disabled, points will be rounded to "
"the nearest recorded point."));
#else
gtk_tooltips_set_tip (tooltips, InterpolateCheck,
_("Interpolate between points. If disabled, points will be rounded to "
"the nearest recorded point."), NULL);
#endif
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (InterpolateCheck), g_key_file_get_boolean(GUISettings, "default", "interpolate", NULL));
NoWriteCheck = gtk_check_button_new_with_mnemonic (_("Don't write"));
gtk_widget_show (NoWriteCheck);
gtk_box_pack_start (GTK_BOX (OptionsVBox), NoWriteCheck, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (NoWriteCheck,
_("Don't write EXIF data back to the photos. This is useful for "
"testing the settings without modifying the photos."));
#else
gtk_tooltips_set_tip (tooltips, NoWriteCheck,
_("Don't write EXIF data back to the photos. This is useful for "
"testing the settings without modifying the photos."), NULL);
#endif
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NoWriteCheck), g_key_file_get_boolean(GUISettings, "default", "dontwrite", NULL));
OverwriteCheck = gtk_check_button_new_with_mnemonic (_("Replace existing tags"));
gtk_widget_show (OverwriteCheck);
gtk_box_pack_start (GTK_BOX (OptionsVBox), OverwriteCheck, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (OverwriteCheck, _("Replace any existing GPS tags in the photos."));
#else
gtk_tooltips_set_tip (tooltips, OverwriteCheck, _("Replace any existing GPS tags in the photos."), NULL);
#endif
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (OverwriteCheck), g_key_file_get_boolean(GUISettings, "default", "replace", NULL));
NoMtimeCheck = gtk_check_button_new_with_mnemonic (_("Don't change mtime"));
gtk_widget_show (NoMtimeCheck);
gtk_box_pack_start (GTK_BOX (OptionsVBox), NoMtimeCheck, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (NoMtimeCheck,
_("Don't change file modification time of the photos."));
#else
gtk_tooltips_set_tip (tooltips, NoMtimeCheck,
_("Don't change file modification time of the photos."), NULL);
#endif
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NoMtimeCheck), g_key_file_get_boolean(GUISettings, "default", "nochangemtime", NULL));
BetweenSegmentsCheck = gtk_check_button_new_with_mnemonic (_("Between Segments"));
gtk_widget_show (BetweenSegmentsCheck);
gtk_box_pack_start (GTK_BOX (OptionsVBox), BetweenSegmentsCheck, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (BetweenSegmentsCheck,
_("Interpolate between track segments. Generally the data is segmented "
"to show where location data was available and not available, but you might "
"still want to interpolate between segments."));
#else
gtk_tooltips_set_tip (tooltips, BetweenSegmentsCheck,
_("Interpolate between track segments. Generally the data is segmented "
"to show where location data was available and not available, but you might "
"still want to interpolate between segments."), NULL);
#endif
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (BetweenSegmentsCheck), g_key_file_get_boolean(GUISettings, "default", "betweensegments", NULL));
DegMinSecsCheck = gtk_check_button_new_with_mnemonic (_("Write DD MM SS.SS"));
gtk_widget_show (DegMinSecsCheck);
gtk_box_pack_start (GTK_BOX (OptionsVBox), DegMinSecsCheck, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (DegMinSecsCheck,
_("Write the latitude and longitude values as DD MM SS.SS; this is "
"the new default. The old behaviour was to write it as "
"DD MM.MM, which will occur if you uncheck this box."));
#else
gtk_tooltips_set_tip (tooltips, DegMinSecsCheck,
_("Write the latitude and longitude values as DD MM SS.SS; this is "
"the new default. The old behaviour was to write it as "
"DD MM.MM, which will occur if you uncheck this box."), NULL);
#endif
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (DegMinSecsCheck), g_key_file_get_boolean(GUISettings, "default", "writeddmmss", NULL));
AutoTimeZoneCheck = gtk_check_button_new_with_mnemonic (_("Auto time zone"));
gtk_widget_show (AutoTimeZoneCheck);
gtk_box_pack_start (GTK_BOX (OptionsVBox), AutoTimeZoneCheck, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (AutoTimeZoneCheck,
_("Assume the camera time zone is the same as the local time zone."));
#else
gtk_tooltips_set_tip (tooltips, AutoTimeZoneCheck,
_("Assume the camera time zone is the same as the local time zone."), NULL);
#endif
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (AutoTimeZoneCheck), g_key_file_get_boolean(GUISettings, "default", "autotimezone", &error));
HeadingCheck = gtk_check_button_new_with_mnemonic (_("Write heading"));
gtk_widget_show (HeadingCheck);
gtk_box_pack_start (GTK_BOX (OptionsVBox), HeadingCheck, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (HeadingCheck,
_("Write an EXIF tag specifying the direction of movement as the photo "
"was taken. This is only possible if the GPX file contains these data "
"and if the heading change does not exceed the maximum (specified below)."));
#else
gtk_tooltips_set_tip (tooltips, HeadingCheck,
_("Write an EXIF tag specifying the direction of movement as the photo "
"was taken. This is only possible if the GPX file contains these data "
"and if the heading change does not exceed the maximum (specified below)."), NULL););
#endif
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (HeadingCheck), g_key_file_get_boolean(GUISettings, "default", "heading", &error));
DirectionCheck = gtk_check_button_new_with_mnemonic (_("Write camera direction"));
gtk_widget_show (DirectionCheck);
gtk_box_pack_start (GTK_BOX (OptionsVBox), DirectionCheck, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (DirectionCheck,
_("Write an EXIF tag specifying the camera direction as the photo "
"was taken. This is only possible if the GPX file contains these data "
"and if the heading change does not exceed the maximum (specified below)."));
#else
gtk_tooltips_set_tip (tooltips, DirectionCheck,
_("Write an EXIF tag specifying the camera direction as the photo "
"was taken. This is only possible if the GPX file contains these data "
"and if the heading change does not exceed the maximum (specified below)."), NULL););
#endif
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (DirectionCheck), g_key_file_get_boolean(GUISettings, "default", "direction", &error));
OptionsTable = gtk_table_new (6, 2, FALSE);
gtk_widget_show (OptionsTable);
gtk_box_pack_start (GTK_BOX (OptionsVBox), OptionsTable, TRUE, TRUE, 0);
int row = 0;
MaxGapTimeLabel = gtk_label_new (_("Max gap time:"));
gtk_widget_show (MaxGapTimeLabel);
gtk_table_attach (GTK_TABLE (OptionsTable), MaxGapTimeLabel, 0, 1, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (MaxGapTimeLabel), 0, 0.5);
++row;
MaxHeadingLabel = gtk_label_new (_("Max heading change:"));
gtk_widget_show (MaxHeadingLabel);
gtk_table_attach (GTK_TABLE (OptionsTable), MaxHeadingLabel, 0, 1, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (MaxHeadingLabel), 0, 0.5);
++row;
CameraDirectionLabel = gtk_label_new (_("Camera direction:"));
gtk_widget_show (CameraDirectionLabel);
gtk_table_attach (GTK_TABLE (OptionsTable), CameraDirectionLabel, 0, 1, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (CameraDirectionLabel), 0, 0.5);
++row;
TimeZoneLabel = gtk_label_new (_("Time Zone:"));
gtk_widget_show (TimeZoneLabel);
gtk_table_attach (GTK_TABLE (OptionsTable), TimeZoneLabel, 0, 1, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (TimeZoneLabel), 0, 0.5);
++row;
PhotoOffsetLabel = gtk_label_new (_("Photo Offset:"));
gtk_widget_show (PhotoOffsetLabel);
gtk_table_attach (GTK_TABLE (OptionsTable), PhotoOffsetLabel, 0, 1, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (PhotoOffsetLabel), 0, 0.5);
++row;
GPSDatumLabel = gtk_label_new (_("GPS Datum:"));
gtk_widget_show (GPSDatumLabel);
gtk_table_attach (GTK_TABLE (OptionsTable), GPSDatumLabel, 0, 1, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (GPSDatumLabel), 0, 0.5);
++row;
row = 0;
GapTimeEntry = gtk_entry_new ();
gtk_widget_show (GapTimeEntry);
gtk_table_attach (GTK_TABLE (OptionsTable), GapTimeEntry, 1, 2, row, row+1,
(GtkAttachOptions) (0),
(GtkAttachOptions) (0), 0, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (GapTimeEntry,
_("Maximum time \"away\" from a point that the photo can be taken "
"yet still match, in seconds. If a photo's time is outside "
"this value (from both points on either side), the location will "
"not match."));
#else
gtk_tooltips_set_tip (tooltips, GapTimeEntry,
_("Maximum time \"away\" from a point that the photo can be taken "
"yet still match, in seconds. If a photo's time is outside "
"this value (from both points on either side), the location will "
"not match."), NULL);
#endif
gtk_entry_set_text (GTK_ENTRY (GapTimeEntry), g_key_file_get_value(GUISettings, "default", "maxgap", NULL));
gtk_entry_set_width_chars (GTK_ENTRY (GapTimeEntry), 7);
++row;
MaxHeadingEntry = gtk_entry_new ();
gtk_widget_show (MaxHeadingEntry);
gtk_table_attach (GTK_TABLE (OptionsTable), MaxHeadingEntry, 1, 2, row, row+1,
(GtkAttachOptions) (0),
(GtkAttachOptions) (0), 0, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (MaxHeadingEntry,
_("Maximum number of degrees of rotation allowed between points "
"while still writing a heading tag. -1 means no maximum."));
#else
gtk_tooltips_set_tip (tooltips, MaxHeadingEntry,
_("Maximum number of degrees of rotation allowed between points "
"while still writing a heading tag. -1 means no maximum."), NULL);
#endif
gtk_entry_set_text (GTK_ENTRY (MaxHeadingEntry), g_key_file_get_value(GUISettings, "default", "maxheading", NULL));
gtk_entry_set_width_chars (GTK_ENTRY (MaxHeadingEntry), 7);
/* Toggle visibility of max heading entry when heading is toggled */
entry_toggle_visibility_inv(HeadingCheck, MaxHeadingEntry);
g_signal_connect(HeadingCheck, "toggled",
G_CALLBACK (entry_toggle_visibility_inv), GTK_ENTRY (MaxHeadingEntry));
++row;
CameraDirectionEntry = gtk_entry_new ();
gtk_widget_show (CameraDirectionEntry);
gtk_table_attach (GTK_TABLE (OptionsTable), CameraDirectionEntry, 1, 2, row, row+1,
(GtkAttachOptions) (0),
(GtkAttachOptions) (0), 0, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (CameraDirectionEntry,
_("Number of degrees from the direction of movement towards which the "
"camera faces. If the camera is facing out the right-hand window of "
"a car, this would be 90."));
#else
gtk_tooltips_set_tip (tooltips, CameraDirectionEntry,
_("Number of degrees from the direction of movement towards which the "
"camera faces. If the camera is facing out the right-hand window of "
"a car, this would be 90."), NULL);
#endif
gtk_entry_set_text (GTK_ENTRY (CameraDirectionEntry), g_key_file_get_value(GUISettings, "default", "directionoffset", NULL));
gtk_entry_set_width_chars (GTK_ENTRY (CameraDirectionEntry), 7);
/* Toggle visibility of direction entry when direction is toggled */
entry_toggle_visibility_inv(DirectionCheck, CameraDirectionEntry);
g_signal_connect(DirectionCheck, "toggled",
G_CALLBACK (entry_toggle_visibility_inv), GTK_ENTRY (CameraDirectionEntry));
++row;
TimeZoneEntry = gtk_entry_new ();
gtk_widget_show (TimeZoneEntry);
gtk_table_attach (GTK_TABLE (OptionsTable), TimeZoneEntry, 1, 2, row, row+1,
(GtkAttachOptions) (0),
(GtkAttachOptions) (0), 0, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (TimeZoneEntry,
_("The timezone that the camera's time was set to when the photos were "
"taken. For example, if a camera is set to AWST or +8:00 hours from UTC, "
"enter +8:00 here so that the correct adjustment to the photo's time "
"can be made. GPS data is always in UTC."));
#else
gtk_tooltips_set_tip (tooltips, TimeZoneEntry,
_("The timezone that the camera's time was set to when the photos were "
"taken. For example, if a camera is set to AWST or +8:00 hours from UTC, "
"enter +8:00 here so that the correct adjustment to the photo's time "
"can be made. GPS data is always in UTC."), NULL);
#endif
gtk_entry_set_text (GTK_ENTRY (TimeZoneEntry), g_key_file_get_value(GUISettings, "default", "timezone", NULL));
gtk_entry_set_width_chars (GTK_ENTRY (TimeZoneEntry), 7);
/* Toggle visibility of time zone entry when auto time zone is toggled */
entry_toggle_visibility(AutoTimeZoneCheck, TimeZoneEntry);
g_signal_connect(AutoTimeZoneCheck, "toggled",
G_CALLBACK (entry_toggle_visibility), GTK_ENTRY (TimeZoneEntry));
++row;
PhotoOffsetEntry = gtk_entry_new ();
gtk_widget_show (PhotoOffsetEntry);
gtk_table_attach (GTK_TABLE (OptionsTable), PhotoOffsetEntry, 1, 2, row, row+1,
(GtkAttachOptions) (0),
(GtkAttachOptions) (0), 0, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (PhotoOffsetEntry,
_("The number of seconds to add to the photo's time to make it match "
"the GPS data. Calculate this with (GPS - Photo). "
"Can be negative or positive."));
#else
gtk_tooltips_set_tip (tooltips, PhotoOffsetEntry,
_("The number of seconds to add to the photo's time to make it match "
"the GPS data. Calculate this with (GPS - Photo). "
"Can be negative or positive."), NULL);
#endif
gtk_entry_set_text (GTK_ENTRY (PhotoOffsetEntry), g_key_file_get_value(GUISettings, "default", "photooffset", NULL));
gtk_entry_set_width_chars (GTK_ENTRY (PhotoOffsetEntry), 7);
++row;
GPSDatumEntry = gtk_entry_new ();
gtk_widget_show (GPSDatumEntry);
gtk_table_attach (GTK_TABLE (OptionsTable), GPSDatumEntry, 1, 2, row, row+1,
(GtkAttachOptions) (0),
(GtkAttachOptions) (0), 0, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (GPSDatumEntry,
_("The datum used for the GPS data. This text here is recorded in the "
"EXIF tags as the source datum. WGS-84 is very commonly used."));
#else
gtk_tooltips_set_tip (tooltips, GPSDatumEntry,
_("The datum used for the GPS data. This text here is recorded in the "
"EXIF tags as the source datum. WGS-84 is very commonly used."), NULL);
#endif
gtk_entry_set_text (GTK_ENTRY (GPSDatumEntry), g_key_file_get_value(GUISettings, "default", "gpsdatum", NULL));
gtk_entry_set_width_chars (GTK_ENTRY (GPSDatumEntry), 7);
++row;
OptionsFrameLable = gtk_label_new (_("<b>3. Set options</b>"));
gtk_widget_show (OptionsFrameLable);
gtk_frame_set_label_widget (GTK_FRAME (OptionsFrame), OptionsFrameLable);
gtk_label_set_use_markup (GTK_LABEL (OptionsFrameLable), TRUE);
/* Correlate button area. */
CorrelateFrame = gtk_frame_new (NULL);
gtk_widget_show (CorrelateFrame);
gtk_box_pack_start (GTK_BOX (ControlsVBox), CorrelateFrame, FALSE, FALSE, 0);
CorrelateAlignment = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_widget_show (CorrelateAlignment);
gtk_container_add (GTK_CONTAINER (CorrelateFrame), CorrelateAlignment);
gtk_alignment_set_padding (GTK_ALIGNMENT (CorrelateAlignment), 0, 4, 12, 4);
CorrelateButton = gtk_button_new_with_mnemonic (_("Correlate Photos"));
gtk_widget_show (CorrelateButton);
gtk_container_add (GTK_CONTAINER (CorrelateAlignment), CorrelateButton);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (CorrelateButton,
_("Begin the correlation process, writing back into the photos' "
"EXIF tags (unless Don't write is selected)."));
#else
gtk_tooltips_set_tip (tooltips, CorrelateButton,
_("Begin the correlation process, writing back into the photos' "
"EXIF tags (unless Don't write is selected)."), NULL);
#endif
g_signal_connect (G_OBJECT (CorrelateButton), "clicked",
G_CALLBACK (CorrelateButtonPress), NULL);
CorrelateLabel = gtk_label_new (_("<b>4. Correlate!</b>"));
gtk_widget_show (CorrelateLabel);
gtk_frame_set_label_widget (GTK_FRAME (CorrelateFrame), CorrelateLabel);
gtk_label_set_use_markup (GTK_LABEL (CorrelateLabel), TRUE);
/* Other options area. */
OtherOptionsFrame = gtk_frame_new (NULL);
gtk_widget_show (OtherOptionsFrame);
gtk_box_pack_start (GTK_BOX (ControlsVBox), OtherOptionsFrame, FALSE, FALSE, 0);
OtherOptionsAlignment = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_widget_show (OtherOptionsAlignment);
gtk_container_add (GTK_CONTAINER (OtherOptionsFrame), OtherOptionsAlignment);
gtk_alignment_set_padding (GTK_ALIGNMENT (OtherOptionsAlignment), 0, 4, 12, 4);
OtherOptionsVBox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (OtherOptionsVBox);
gtk_container_add (GTK_CONTAINER (OtherOptionsAlignment), OtherOptionsVBox);
StripGPSButton = gtk_button_new_with_mnemonic (_("Strip GPS tags"));
gtk_widget_show (StripGPSButton);
gtk_box_pack_start (GTK_BOX (OtherOptionsVBox), StripGPSButton, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (StripGPSButton,
_("Strip GPS tags from the selected photos."));
#else
gtk_tooltips_set_tip (tooltips, StripGPSButton,
_("Strip GPS tags from the selected photos."), NULL);
#endif
g_signal_connect (G_OBJECT (StripGPSButton), "clicked",
G_CALLBACK (StripGPSButtonPress), NULL);
HelpButton = gtk_button_new_with_mnemonic (_("Help"));
gtk_widget_show (HelpButton);
gtk_box_pack_start (GTK_BOX (OtherOptionsVBox), HelpButton, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (HelpButton,
_("View help for this application."));
#else
gtk_tooltips_set_tip (tooltips, HelpButton,
_("View help for this application."), NULL);
#endif
g_signal_connect (G_OBJECT (HelpButton), "clicked",
G_CALLBACK (HelpButtonPress), NULL);
AboutButton = gtk_button_new_with_mnemonic (_("About"));
gtk_widget_show (AboutButton);
gtk_box_pack_start (GTK_BOX (OtherOptionsVBox), AboutButton, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (AboutButton,
_("Show information about the program."));
#else
gtk_tooltips_set_tip (tooltips, AboutButton,
_("Show information about the program."), NULL);
#endif
g_signal_connect (G_OBJECT (AboutButton), "clicked",
G_CALLBACK (AboutButtonPress), NULL);
OtherOptionsLabel = gtk_label_new (_("<b>Other Tools</b>"));
gtk_widget_show (OtherOptionsLabel);
gtk_frame_set_label_widget (GTK_FRAME (OtherOptionsFrame), OtherOptionsLabel);
gtk_label_set_use_markup (GTK_LABEL (OtherOptionsLabel), TRUE);
/* Photo list box area of the window. */
PhotoListVBox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (PhotoListVBox);
gtk_box_pack_start (GTK_BOX (WindowHBox), PhotoListVBox, TRUE, TRUE, 0);
PhotoListScroll = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (PhotoListScroll);
gtk_box_pack_start (GTK_BOX (PhotoListVBox), PhotoListScroll, TRUE, TRUE, 0);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (PhotoListScroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (PhotoListScroll), GTK_SHADOW_IN);
/* Get the photo list store ready. */
PhotoListStore = gtk_list_store_new(LIST_NOCOLUMNS,
G_TYPE_STRING, /* The Filename */
G_TYPE_STRING, /* Latitude */
G_TYPE_STRING, /* Longitude */
G_TYPE_STRING, /* Elevation */
G_TYPE_STRING, /* The Time */
G_TYPE_STRING, /* The State */
G_TYPE_POINTER); /* Pointer to the matching list item. */
PhotoList = gtk_tree_view_new_with_model (GTK_TREE_MODEL(PhotoListStore));
gtk_widget_show (PhotoList);
gtk_container_add (GTK_CONTAINER (PhotoListScroll), PhotoList);
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(PhotoList)), GTK_SELECTION_MULTIPLE);
/* Prepare the columns. We need columns. Columns are good. */
PhotoListRenderer = gtk_cell_renderer_text_new ();
/* File Column. */
FileColumn = gtk_tree_view_column_new_with_attributes (_("File"), PhotoListRenderer,
"text", LIST_FILENAME,
NULL);
gtk_tree_view_column_set_resizable (FileColumn, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (PhotoList), FileColumn);
/* Latitude Column. */
LatColumn = gtk_tree_view_column_new_with_attributes (_("Latitude"), PhotoListRenderer,
"text", LIST_LAT,
NULL);
gtk_tree_view_column_set_resizable (LatColumn, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (PhotoList), LatColumn);
/* Longitude Column. */
LongColumn = gtk_tree_view_column_new_with_attributes (_("Longitude"), PhotoListRenderer,
"text", LIST_LONG,
NULL);
gtk_tree_view_column_set_resizable (LongColumn, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (PhotoList), LongColumn);
/* Elevation Column. */
ElevColumn = gtk_tree_view_column_new_with_attributes (_("Elevation"), PhotoListRenderer,
"text", LIST_ELEV,
NULL);
gtk_tree_view_column_set_resizable (ElevColumn, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (PhotoList), ElevColumn);
/* Time column. */
TimeColumn = gtk_tree_view_column_new_with_attributes (_("Time"), PhotoListRenderer,
"text", LIST_TIME,
NULL);
gtk_tree_view_column_set_resizable (TimeColumn, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (PhotoList), TimeColumn);
/* State column. */
StateColumn = gtk_tree_view_column_new_with_attributes (_("State"), PhotoListRenderer,
"text", LIST_STATE,
NULL);
gtk_tree_view_column_set_resizable (StateColumn, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (PhotoList), StateColumn);
/* Get the track list store ready.
* Create the empty terminating entry. */
GPSData = (struct GPSTrack*) calloc(1, sizeof(*GPSData));
if (GPSData == NULL) {
fprintf(stderr, _("Out of memory.\n"));
abort();
}
NumTracks = 0;
/* Final thing: show the window. */
gtk_widget_show(MatchWindow);
/* Done! Return a pointer to the window, although we never use it... */
return MatchWindow;
}
gboolean DestroyWindow(GtkWidget *Widget,
GdkEvent *Event,
gpointer Data)
{
(void) Widget; // Unused
(void) Event; // Unused
(void) Data; // Unused
/* Record the settings, and then save them. */
g_key_file_set_boolean(GUISettings, "default", "interpolate", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(InterpolateCheck)));
g_key_file_set_boolean(GUISettings, "default", "dontwrite", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(NoWriteCheck)));
g_key_file_set_boolean(GUISettings, "default", "replace", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(OverwriteCheck)));
g_key_file_set_boolean(GUISettings, "default", "nochangemtime", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(NoMtimeCheck)));
g_key_file_set_boolean(GUISettings, "default", "betweensegments", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(BetweenSegmentsCheck)));
g_key_file_set_boolean(GUISettings, "default", "writeddmmss", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(DegMinSecsCheck)));
g_key_file_set_boolean(GUISettings, "default", "autotimezone", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(AutoTimeZoneCheck)));
g_key_file_set_string(GUISettings, "default", "maxgap", gtk_entry_get_text(GTK_ENTRY(GapTimeEntry)));
g_key_file_set_string(GUISettings, "default", "maxheading", gtk_entry_get_text(GTK_ENTRY(MaxHeadingEntry)));
g_key_file_set_string(GUISettings, "default", "directionoffset", gtk_entry_get_text(GTK_ENTRY(CameraDirectionEntry)));
g_key_file_set_string(GUISettings, "default", "timezone", gtk_entry_get_text(GTK_ENTRY(TimeZoneEntry)));
g_key_file_set_string(GUISettings, "default", "photooffset", gtk_entry_get_text(GTK_ENTRY(PhotoOffsetEntry)));
g_key_file_set_string(GUISettings, "default", "gpsdatum", gtk_entry_get_text(GTK_ENTRY(GPSDatumEntry)));
if (GPXOpenDir)
g_key_file_set_string(GUISettings, "default", "gpxopendir", GPXOpenDir);
if (PhotoOpenDir)
g_key_file_set_string(GUISettings, "default", "photoopendir", PhotoOpenDir);
SaveSettings();
/* Someone closed the window. */
/* Free the memory we allocated for the photo list. */
struct GUIPhotoList* Free = NULL;
struct GUIPhotoList* Free2 = NULL;
if (FirstPhoto)
{
/* Walk through the singly-linked list
* freeing stuff. */
Free = FirstPhoto;
while (1)
{
free(Free->Filename);
free(Free->Time);
Free2 = Free->Next;
free(Free);
if (Free2 == NULL) break;
Free = Free2;
}
}
/* Free the memory for the GPS data, if applicable. */
while (NumTracks > 0)
{
--NumTracks;
FreeTrack(&GPSData[NumTracks]);
}
free(GPSData);
/* Tell GTK that we're done. */
#if GTK_CHECK_VERSION(2, 12, 0)
exit(0);
#else
gtk_exit(0);
#endif
/* And return FALSE so that GTK knows we have not
* vetoed the close. */
return FALSE;
}
void AddPhotosButtonPress( GtkWidget *Widget, gpointer Data )
{
(void) Widget; // Unused
(void) Data; // Unused
/* Add some photos to this thing. */
#if GTK_CHECK_VERSION(3, 20, 0)
GtkFileChooserNative *AddPhotosDialog;
#else
GtkWidget *AddPhotosDialog;
#endif
/* Get the dialog ready. */
#if GTK_CHECK_VERSION(3, 20, 0)
AddPhotosDialog = gtk_file_chooser_native_new (_("Add Photos..."),
GTK_WINDOW(MatchWindow),
GTK_FILE_CHOOSER_ACTION_OPEN,
NULL, NULL);
#else
AddPhotosDialog = gtk_file_chooser_dialog_new (_("Add Photos..."),
GTK_WINDOW(MatchWindow),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
#endif
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(AddPhotosDialog), TRUE);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(AddPhotosDialog), PhotoOpenDir);
GtkFileFilter *JpgFilter = gtk_file_filter_new();
if (JpgFilter) {
gtk_file_filter_add_pattern(JpgFilter, "*.[jJ][pP][gG]");
gtk_file_filter_add_pattern(JpgFilter, "*.[jJ][pP][eE][gG]");
gtk_file_filter_set_name(JpgFilter, _("JPEG images"));
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(AddPhotosDialog), JpgFilter);
}
GtkFileFilter *AllFilter = gtk_file_filter_new();