]> git.street.me.uk Git - andy/viking.git/blame - src/globals.c
Fix a_vik_gpx_export_wpt_sym_name internal type
[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};
b02cd3a3 74static gchar * params_gpx_export_trk_sort[] = {N_("Alphabetical"), N_("Time"), N_("Creation"), 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 },
90611609 98 { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_ADVANCED_NAMESPACE "create_track_tooltip", VIK_LAYER_PARAM_BOOLEAN, VIK_LAYER_GROUP_NONE, N_("Show Tooltip during Track Creation:"), VIK_LAYER_WIDGET_CHECKBUTTON, NULL, NULL, NULL, NULL },
88542aa9
RN
99};
100
60dbd0ad
RN
101/* End of Options static stuff */
102
a58aaed4
GB
103void a_vik_preferences_init ()
104{
f02faa96 105 // Defaults for the options are setup here
1b03d66d 106 a_preferences_register_group ( VIKING_PREFERENCES_GROUP_KEY, _("General") );
a58aaed4
GB
107
108 VikLayerParamData tmp;
109 tmp.u = VIK_DEGREE_FORMAT_DMS;
6f9336aa
RN
110 a_preferences_register(prefs1, tmp, VIKING_PREFERENCES_GROUP_KEY);
111
112 tmp.u = VIK_UNITS_DISTANCE_KILOMETRES;
113 a_preferences_register(prefs2, tmp, VIKING_PREFERENCES_GROUP_KEY);
13bdea80
RN
114
115 tmp.u = VIK_UNITS_SPEED_KILOMETRES_PER_HOUR;
116 a_preferences_register(prefs3, tmp, VIKING_PREFERENCES_GROUP_KEY);
6027a9c5
RN
117
118 tmp.u = VIK_UNITS_HEIGHT_METRES;
119 a_preferences_register(prefs4, tmp, VIKING_PREFERENCES_GROUP_KEY);
9be0449f
RN
120
121 tmp.b = TRUE;
122 a_preferences_register(prefs5, tmp, VIKING_PREFERENCES_GROUP_KEY);
5210c3d3
GB
123
124 /* Maintain the default location to New York */
125 tmp.d = 40.714490;
126 a_preferences_register(prefs6, tmp, VIKING_PREFERENCES_GROUP_KEY);
127 tmp.d = -74.007130;
128 a_preferences_register(prefs7, tmp, VIKING_PREFERENCES_GROUP_KEY);
2702f416
RN
129
130 // New Tab
131 a_preferences_register_group ( VIKING_PREFERENCES_IO_GROUP_KEY, _("Export/External") );
60dbd0ad
RN
132
133 tmp.u = VIK_KML_EXPORT_UNITS_METRIC;
134 a_preferences_register(&io_prefs[0], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
3317dc4e 135
d13f1a57
RN
136 tmp.u = VIK_GPX_EXPORT_TRK_SORT_TIME;
137 a_preferences_register(&io_prefs[1], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
138
5f2a108d 139 tmp.b = VIK_GPX_EXPORT_WPT_SYM_NAME_TITLECASE;
72f067ad
RN
140 a_preferences_register(&io_prefs[2], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
141
3317dc4e 142#ifndef WINDOWS
0b386bf3 143 tmp.s = "xdg-open";
3317dc4e
RN
144 a_preferences_register(&io_prefs_non_windows[0], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
145#endif
ccccf356 146
1e6db2e3 147 // JOSM for OSM editing around a GPX track
ccccf356
RN
148 tmp.s = "josm";
149 a_preferences_register(&io_prefs_external_gpx[0], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
ff02058b
RN
150 // Add a second external program - another OSM editor by default
151 tmp.s = "merkaartor";
152 a_preferences_register(&io_prefs_external_gpx[1], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
29277258
RN
153
154 // 'Advanced' Properties
155 a_preferences_register_group ( VIKING_PREFERENCES_ADVANCED_GROUP_KEY, _("Advanced") );
88542aa9
RN
156
157 tmp.u = VIK_FILE_REF_FORMAT_ABSOLUTE;
158 a_preferences_register(&prefs_advanced[0], tmp, VIKING_PREFERENCES_ADVANCED_GROUP_KEY);
90611609
RN
159
160 tmp.b = TRUE;
161 a_preferences_register(&prefs_advanced[1], tmp, VIKING_PREFERENCES_ADVANCED_GROUP_KEY);
a58aaed4
GB
162}
163
164vik_degree_format_t a_vik_get_degree_format ( )
165{
166 vik_degree_format_t format;
167 format = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "degree_format")->u;
168 return format;
a58aaed4 169}
6f9336aa
RN
170
171vik_units_distance_t a_vik_get_units_distance ( )
172{
173 vik_units_distance_t units;
174 units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "units_distance")->u;
175 return units;
176}
13bdea80
RN
177
178vik_units_speed_t a_vik_get_units_speed ( )
179{
180 vik_units_speed_t units;
181 units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "units_speed")->u;
182 return units;
183}
6027a9c5
RN
184
185vik_units_height_t a_vik_get_units_height ( )
186{
187 vik_units_height_t units;
188 units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "units_height")->u;
189 return units;
190}
9be0449f
RN
191
192gboolean a_vik_get_use_large_waypoint_icons ( )
193{
194 gboolean use_large_waypoint_icons;
195 use_large_waypoint_icons = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "use_large_waypoint_icons")->b;
196 return use_large_waypoint_icons;
197}
5210c3d3
GB
198
199gdouble a_vik_get_default_lat ( )
200{
201 gdouble data;
202 data = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "default_latitude")->d;
203 return data;
204}
205
206gdouble a_vik_get_default_long ( )
207{
208 gdouble data;
209 data = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "default_longitude")->d;
210 return data;
211}
60dbd0ad
RN
212
213/* External/Export Options */
214
215vik_kml_export_units_t a_vik_get_kml_export_units ( )
216{
217 vik_kml_export_units_t units;
71eede92 218 units = a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "kml_export_units")->u;
60dbd0ad
RN
219 return units;
220}
3317dc4e 221
d13f1a57
RN
222vik_gpx_export_trk_sort_t a_vik_get_gpx_export_trk_sort ( )
223{
224 vik_gpx_export_trk_sort_t sort;
225 sort = a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "gpx_export_track_sort")->u;
226 return sort;
227}
228
72f067ad
RN
229vik_gpx_export_wpt_sym_name_t a_vik_gpx_export_wpt_sym_name ( )
230{
231 gboolean val;
5f2a108d 232 val = a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "gpx_export_wpt_sym_names")->b;
72f067ad
RN
233 return val;
234}
235
3317dc4e
RN
236#ifndef WINDOWS
237const gchar* a_vik_get_image_viewer ( )
238{
239 return a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "image_viewer")->s;
240}
241#endif
ccccf356
RN
242
243const gchar* a_vik_get_external_gpx_program_1 ( )
244{
245 return a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "external_gpx_1")->s;
246}
ff02058b
RN
247
248const gchar* a_vik_get_external_gpx_program_2 ( )
249{
250 return a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "external_gpx_2")->s;
251}
88542aa9
RN
252
253vik_file_ref_format_t a_vik_get_file_ref_format ( )
254{
255 vik_file_ref_format_t format;
256 format = a_preferences_get(VIKING_PREFERENCES_ADVANCED_NAMESPACE "save_file_reference_mode")->u;
257 return format;
258}
90611609
RN
259
260gboolean a_vik_get_create_track_tooltip ( )
261{
262 return a_preferences_get(VIKING_PREFERENCES_ADVANCED_NAMESPACE "create_track_tooltip")->b;
263}