]> git.street.me.uk Git - andy/viking.git/blame - src/globals.c
SF#2998555: Control of saving Absolute vs Relative Paths in .vik files
[andy/viking.git] / src / globals.c
CommitLineData
2936913d
GB
1/*
2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
3 *
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
a482007a
GB
5 * Copyright (C) 2008, Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
6 * Copyright (C) 2010, Rob Norris <rw_norris@hotmail.com>
2936913d
GB
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
a58aaed4
GB
23#ifdef HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include <glib/gi18n.h>
2936913d
GB
28
29#include "globals.h"
a58aaed4 30#include "preferences.h"
2936913d
GB
31
32gboolean vik_debug = FALSE;
33gboolean vik_verbose = FALSE;
34gboolean vik_version = FALSE;
35
a58aaed4 36static gchar * params_degree_formats[] = {"DDD", "DMM", "DMS", NULL};
6f9336aa 37static gchar * params_units_distance[] = {"Kilometres", "Miles", NULL};
a4c92313 38static gchar * params_units_speed[] = {"km/h", "mph", "m/s", "knots", NULL};
6027a9c5 39static gchar * params_units_height[] = {"Metres", "Feet", NULL};
5210c3d3
GB
40static VikLayerParamScale params_scales_lat[] = { {-90.0, 90.0, 0.05, 2} };
41static VikLayerParamScale params_scales_long[] = { {-180.0, 180.0, 0.05, 2} };
88542aa9
RN
42static gchar * params_vik_fileref[] = {N_("Absolute"), N_("Relative"), NULL};
43
6f9336aa 44static VikLayerParam prefs1[] = {
a7023a1b 45 { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_NAMESPACE "degree_format", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Degree format:"), VIK_LAYER_WIDGET_COMBOBOX, params_degree_formats, NULL, NULL },
a58aaed4
GB
46};
47
6f9336aa 48static VikLayerParam prefs2[] = {
a7023a1b 49 { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_NAMESPACE "units_distance", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Distance units:"), VIK_LAYER_WIDGET_COMBOBOX, params_units_distance, NULL, NULL },
6f9336aa
RN
50};
51
13bdea80 52static VikLayerParam prefs3[] = {
a7023a1b 53 { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_NAMESPACE "units_speed", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Speed units:"), VIK_LAYER_WIDGET_COMBOBOX, params_units_speed, NULL, NULL },
13bdea80
RN
54};
55
6027a9c5 56static VikLayerParam prefs4[] = {
a7023a1b 57 { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_NAMESPACE "units_height", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Height units:"), VIK_LAYER_WIDGET_COMBOBOX, params_units_height, NULL, NULL },
6027a9c5
RN
58};
59
9be0449f 60static VikLayerParam prefs5[] = {
a7023a1b 61 { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_NAMESPACE "use_large_waypoint_icons", VIK_LAYER_PARAM_BOOLEAN, VIK_LAYER_GROUP_NONE, N_("Use large waypoint icons:"), VIK_LAYER_WIDGET_CHECKBUTTON, NULL, NULL, NULL },
9be0449f
RN
62};
63
5210c3d3 64static VikLayerParam prefs6[] = {
a7023a1b 65 { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_NAMESPACE "default_latitude", VIK_LAYER_PARAM_DOUBLE, VIK_LAYER_GROUP_NONE, N_("Default latitude:"), VIK_LAYER_WIDGET_SPINBUTTON, params_scales_lat, NULL, NULL },
5210c3d3
GB
66};
67static VikLayerParam prefs7[] = {
a7023a1b 68 { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_NAMESPACE "default_longitude", VIK_LAYER_PARAM_DOUBLE, VIK_LAYER_GROUP_NONE, N_("Default longitude:"), VIK_LAYER_WIDGET_SPINBUTTON, params_scales_long, NULL, NULL },
5210c3d3
GB
69};
70
60dbd0ad
RN
71/* External/Export Options */
72
73static gchar * params_kml_export_units[] = {"Metric", "Statute", "Nautical", NULL};
d13f1a57 74static gchar * params_gpx_export_trk_sort[] = {N_("Alphabetical"), N_("Time"), NULL};
72f067ad 75static gchar * params_gpx_export_wpt_symbols[] = {N_("Title Case"), N_("Lowercase"), NULL};
60dbd0ad
RN
76
77static VikLayerParam io_prefs[] = {
72f067ad
RN
78 { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_IO_NAMESPACE "kml_export_units", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("KML File Export Units:"), VIK_LAYER_WIDGET_COMBOBOX, params_kml_export_units, NULL, NULL, NULL },
79 { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_IO_NAMESPACE "gpx_export_track_sort", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("GPX Track Order:"), VIK_LAYER_WIDGET_COMBOBOX, params_gpx_export_trk_sort, NULL, NULL, NULL },
80 { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_IO_NAMESPACE "gpx_export_wpt_sym_names", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("GPX Waypoint Symbols:"), VIK_LAYER_WIDGET_COMBOBOX, params_gpx_export_wpt_symbols, NULL,
81 N_("Save GPX Waypoint Symbol names in the specified case. May be useful for compatibility with various devices"), NULL },
60dbd0ad
RN
82};
83
3317dc4e
RN
84#ifndef WINDOWS
85static VikLayerParam io_prefs_non_windows[] = {
a7023a1b 86 { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_IO_NAMESPACE "image_viewer", VIK_LAYER_PARAM_STRING, VIK_LAYER_GROUP_NONE, N_("Image Viewer:"), VIK_LAYER_WIDGET_FILEENTRY, NULL, NULL, NULL },
3317dc4e
RN
87};
88#endif
89
ccccf356 90static VikLayerParam io_prefs_external_gpx[] = {
a7023a1b
RN
91 { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_IO_NAMESPACE "external_gpx_1", VIK_LAYER_PARAM_STRING, VIK_LAYER_GROUP_NONE, N_("External GPX Program 1:"), VIK_LAYER_WIDGET_FILEENTRY, NULL, NULL, NULL },
92 { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_IO_NAMESPACE "external_gpx_2", VIK_LAYER_PARAM_STRING, VIK_LAYER_GROUP_NONE, N_("External GPX Program 2:"), VIK_LAYER_WIDGET_FILEENTRY, NULL, NULL, NULL },
ccccf356
RN
93};
94
88542aa9
RN
95static VikLayerParam prefs_advanced[] = {
96 { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_ADVANCED_NAMESPACE "save_file_reference_mode", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Save File Reference Mode:"), VIK_LAYER_WIDGET_COMBOBOX, params_vik_fileref, NULL,
97 N_("When saving a Viking .vik file, this determines how the directory paths of filenames are written."), NULL },
98};
99
60dbd0ad
RN
100/* End of Options static stuff */
101
a58aaed4
GB
102void a_vik_preferences_init ()
103{
f02faa96 104 // Defaults for the options are setup here
1b03d66d 105 a_preferences_register_group ( VIKING_PREFERENCES_GROUP_KEY, _("General") );
a58aaed4
GB
106
107 VikLayerParamData tmp;
108 tmp.u = VIK_DEGREE_FORMAT_DMS;
6f9336aa
RN
109 a_preferences_register(prefs1, tmp, VIKING_PREFERENCES_GROUP_KEY);
110
111 tmp.u = VIK_UNITS_DISTANCE_KILOMETRES;
112 a_preferences_register(prefs2, tmp, VIKING_PREFERENCES_GROUP_KEY);
13bdea80
RN
113
114 tmp.u = VIK_UNITS_SPEED_KILOMETRES_PER_HOUR;
115 a_preferences_register(prefs3, tmp, VIKING_PREFERENCES_GROUP_KEY);
6027a9c5
RN
116
117 tmp.u = VIK_UNITS_HEIGHT_METRES;
118 a_preferences_register(prefs4, tmp, VIKING_PREFERENCES_GROUP_KEY);
9be0449f
RN
119
120 tmp.b = TRUE;
121 a_preferences_register(prefs5, tmp, VIKING_PREFERENCES_GROUP_KEY);
5210c3d3
GB
122
123 /* Maintain the default location to New York */
124 tmp.d = 40.714490;
125 a_preferences_register(prefs6, tmp, VIKING_PREFERENCES_GROUP_KEY);
126 tmp.d = -74.007130;
127 a_preferences_register(prefs7, tmp, VIKING_PREFERENCES_GROUP_KEY);
2702f416
RN
128
129 // New Tab
130 a_preferences_register_group ( VIKING_PREFERENCES_IO_GROUP_KEY, _("Export/External") );
60dbd0ad
RN
131
132 tmp.u = VIK_KML_EXPORT_UNITS_METRIC;
133 a_preferences_register(&io_prefs[0], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
3317dc4e 134
d13f1a57
RN
135 tmp.u = VIK_GPX_EXPORT_TRK_SORT_TIME;
136 a_preferences_register(&io_prefs[1], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
137
72f067ad
RN
138 tmp.u = VIK_GPX_EXPORT_WPT_SYM_NAME_TITLECASE;
139 a_preferences_register(&io_prefs[2], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
140
3317dc4e 141#ifndef WINDOWS
0b386bf3 142 tmp.s = "xdg-open";
3317dc4e
RN
143 a_preferences_register(&io_prefs_non_windows[0], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
144#endif
ccccf356 145
1e6db2e3 146 // JOSM for OSM editing around a GPX track
ccccf356
RN
147 tmp.s = "josm";
148 a_preferences_register(&io_prefs_external_gpx[0], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
ff02058b
RN
149 // Add a second external program - another OSM editor by default
150 tmp.s = "merkaartor";
151 a_preferences_register(&io_prefs_external_gpx[1], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
29277258
RN
152
153 // 'Advanced' Properties
154 a_preferences_register_group ( VIKING_PREFERENCES_ADVANCED_GROUP_KEY, _("Advanced") );
88542aa9
RN
155
156 tmp.u = VIK_FILE_REF_FORMAT_ABSOLUTE;
157 a_preferences_register(&prefs_advanced[0], tmp, VIKING_PREFERENCES_ADVANCED_GROUP_KEY);
a58aaed4
GB
158}
159
160vik_degree_format_t a_vik_get_degree_format ( )
161{
162 vik_degree_format_t format;
163 format = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "degree_format")->u;
164 return format;
a58aaed4 165}
6f9336aa
RN
166
167vik_units_distance_t a_vik_get_units_distance ( )
168{
169 vik_units_distance_t units;
170 units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "units_distance")->u;
171 return units;
172}
13bdea80
RN
173
174vik_units_speed_t a_vik_get_units_speed ( )
175{
176 vik_units_speed_t units;
177 units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "units_speed")->u;
178 return units;
179}
6027a9c5
RN
180
181vik_units_height_t a_vik_get_units_height ( )
182{
183 vik_units_height_t units;
184 units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "units_height")->u;
185 return units;
186}
9be0449f
RN
187
188gboolean a_vik_get_use_large_waypoint_icons ( )
189{
190 gboolean use_large_waypoint_icons;
191 use_large_waypoint_icons = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "use_large_waypoint_icons")->b;
192 return use_large_waypoint_icons;
193}
5210c3d3
GB
194
195gdouble a_vik_get_default_lat ( )
196{
197 gdouble data;
198 data = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "default_latitude")->d;
199 return data;
200}
201
202gdouble a_vik_get_default_long ( )
203{
204 gdouble data;
205 data = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "default_longitude")->d;
206 return data;
207}
60dbd0ad
RN
208
209/* External/Export Options */
210
211vik_kml_export_units_t a_vik_get_kml_export_units ( )
212{
213 vik_kml_export_units_t units;
71eede92 214 units = a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "kml_export_units")->u;
60dbd0ad
RN
215 return units;
216}
3317dc4e 217
d13f1a57
RN
218vik_gpx_export_trk_sort_t a_vik_get_gpx_export_trk_sort ( )
219{
220 vik_gpx_export_trk_sort_t sort;
221 sort = a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "gpx_export_track_sort")->u;
222 return sort;
223}
224
72f067ad
RN
225vik_gpx_export_wpt_sym_name_t a_vik_gpx_export_wpt_sym_name ( )
226{
227 gboolean val;
228 val = a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "gpx_export_wpt_sym_names")->u;
229 return val;
230}
231
3317dc4e
RN
232#ifndef WINDOWS
233const gchar* a_vik_get_image_viewer ( )
234{
235 return a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "image_viewer")->s;
236}
237#endif
ccccf356
RN
238
239const gchar* a_vik_get_external_gpx_program_1 ( )
240{
241 return a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "external_gpx_1")->s;
242}
ff02058b
RN
243
244const gchar* a_vik_get_external_gpx_program_2 ( )
245{
246 return a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "external_gpx_2")->s;
247}
88542aa9
RN
248
249vik_file_ref_format_t a_vik_get_file_ref_format ( )
250{
251 vik_file_ref_format_t format;
252 format = a_preferences_get(VIKING_PREFERENCES_ADVANCED_NAMESPACE "save_file_reference_mode")->u;
253 return format;
254}