]> git.street.me.uk Git - andy/viking.git/blame - src/globals.c
Bump up default map cache size to 128MB and allow setting to 1GB.
[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} };
42
6f9336aa 43static VikLayerParam prefs1[] = {
f02faa96 44 { VIKING_PREFERENCES_NAMESPACE "degree_format", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Degree format:"), VIK_LAYER_WIDGET_COMBOBOX, params_degree_formats, NULL },
a58aaed4
GB
45};
46
6f9336aa 47static VikLayerParam prefs2[] = {
f02faa96 48 { VIKING_PREFERENCES_NAMESPACE "units_distance", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Distance units:"), VIK_LAYER_WIDGET_COMBOBOX, params_units_distance, NULL },
6f9336aa
RN
49};
50
13bdea80 51static VikLayerParam prefs3[] = {
f02faa96 52 { VIKING_PREFERENCES_NAMESPACE "units_speed", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Speed units:"), VIK_LAYER_WIDGET_COMBOBOX, params_units_speed, NULL },
13bdea80
RN
53};
54
6027a9c5 55static VikLayerParam prefs4[] = {
f02faa96 56 { VIKING_PREFERENCES_NAMESPACE "units_height", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Height units:"), VIK_LAYER_WIDGET_COMBOBOX, params_units_height, NULL },
6027a9c5
RN
57};
58
9be0449f 59static VikLayerParam prefs5[] = {
f02faa96 60 { 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 },
9be0449f
RN
61};
62
5210c3d3 63static VikLayerParam prefs6[] = {
f02faa96 64 { VIKING_PREFERENCES_NAMESPACE "default_latitude", VIK_LAYER_PARAM_DOUBLE, VIK_LAYER_GROUP_NONE, N_("Default latitude:"), VIK_LAYER_WIDGET_SPINBUTTON, params_scales_lat, NULL },
5210c3d3
GB
65};
66static VikLayerParam prefs7[] = {
f02faa96 67 { VIKING_PREFERENCES_NAMESPACE "default_longitude", VIK_LAYER_PARAM_DOUBLE, VIK_LAYER_GROUP_NONE, N_("Default longitude:"), VIK_LAYER_WIDGET_SPINBUTTON, params_scales_long, NULL },
5210c3d3
GB
68};
69
60dbd0ad
RN
70/* External/Export Options */
71
72static gchar * params_kml_export_units[] = {"Metric", "Statute", "Nautical", NULL};
73
74static VikLayerParam io_prefs[] = {
75 { 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 },
76};
77
3317dc4e
RN
78#ifndef WINDOWS
79static VikLayerParam io_prefs_non_windows[] = {
80 { VIKING_PREFERENCES_IO_NAMESPACE "image_viewer", VIK_LAYER_PARAM_STRING, VIK_LAYER_GROUP_NONE, N_("Image Viewer:"), VIK_LAYER_WIDGET_FILEENTRY, NULL, NULL },
81};
82#endif
83
ccccf356
RN
84static VikLayerParam io_prefs_external_gpx[] = {
85 { 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 },
ff02058b 86 { 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 },
ccccf356
RN
87};
88
60dbd0ad
RN
89/* End of Options static stuff */
90
a58aaed4
GB
91void a_vik_preferences_init ()
92{
f02faa96 93 // Defaults for the options are setup here
1b03d66d 94 a_preferences_register_group ( VIKING_PREFERENCES_GROUP_KEY, _("General") );
a58aaed4
GB
95
96 VikLayerParamData tmp;
97 tmp.u = VIK_DEGREE_FORMAT_DMS;
6f9336aa
RN
98 a_preferences_register(prefs1, tmp, VIKING_PREFERENCES_GROUP_KEY);
99
100 tmp.u = VIK_UNITS_DISTANCE_KILOMETRES;
101 a_preferences_register(prefs2, tmp, VIKING_PREFERENCES_GROUP_KEY);
13bdea80
RN
102
103 tmp.u = VIK_UNITS_SPEED_KILOMETRES_PER_HOUR;
104 a_preferences_register(prefs3, tmp, VIKING_PREFERENCES_GROUP_KEY);
6027a9c5
RN
105
106 tmp.u = VIK_UNITS_HEIGHT_METRES;
107 a_preferences_register(prefs4, tmp, VIKING_PREFERENCES_GROUP_KEY);
9be0449f
RN
108
109 tmp.b = TRUE;
110 a_preferences_register(prefs5, tmp, VIKING_PREFERENCES_GROUP_KEY);
5210c3d3
GB
111
112 /* Maintain the default location to New York */
113 tmp.d = 40.714490;
114 a_preferences_register(prefs6, tmp, VIKING_PREFERENCES_GROUP_KEY);
115 tmp.d = -74.007130;
116 a_preferences_register(prefs7, tmp, VIKING_PREFERENCES_GROUP_KEY);
2702f416
RN
117
118 // New Tab
119 a_preferences_register_group ( VIKING_PREFERENCES_IO_GROUP_KEY, _("Export/External") );
60dbd0ad
RN
120
121 tmp.u = VIK_KML_EXPORT_UNITS_METRIC;
122 a_preferences_register(&io_prefs[0], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
3317dc4e
RN
123
124#ifndef WINDOWS
0b386bf3 125 tmp.s = "xdg-open";
3317dc4e
RN
126 a_preferences_register(&io_prefs_non_windows[0], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
127#endif
ccccf356 128
1e6db2e3 129 // JOSM for OSM editing around a GPX track
ccccf356
RN
130 tmp.s = "josm";
131 a_preferences_register(&io_prefs_external_gpx[0], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
ff02058b
RN
132 // Add a second external program - another OSM editor by default
133 tmp.s = "merkaartor";
134 a_preferences_register(&io_prefs_external_gpx[1], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
a58aaed4
GB
135}
136
137vik_degree_format_t a_vik_get_degree_format ( )
138{
139 vik_degree_format_t format;
140 format = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "degree_format")->u;
141 return format;
a58aaed4 142}
6f9336aa
RN
143
144vik_units_distance_t a_vik_get_units_distance ( )
145{
146 vik_units_distance_t units;
147 units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "units_distance")->u;
148 return units;
149}
13bdea80
RN
150
151vik_units_speed_t a_vik_get_units_speed ( )
152{
153 vik_units_speed_t units;
154 units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "units_speed")->u;
155 return units;
156}
6027a9c5
RN
157
158vik_units_height_t a_vik_get_units_height ( )
159{
160 vik_units_height_t units;
161 units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "units_height")->u;
162 return units;
163}
9be0449f
RN
164
165gboolean a_vik_get_use_large_waypoint_icons ( )
166{
167 gboolean use_large_waypoint_icons;
168 use_large_waypoint_icons = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "use_large_waypoint_icons")->b;
169 return use_large_waypoint_icons;
170}
5210c3d3
GB
171
172gdouble a_vik_get_default_lat ( )
173{
174 gdouble data;
175 data = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "default_latitude")->d;
176 return data;
177}
178
179gdouble a_vik_get_default_long ( )
180{
181 gdouble data;
182 data = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "default_longitude")->d;
183 return data;
184}
60dbd0ad
RN
185
186/* External/Export Options */
187
188vik_kml_export_units_t a_vik_get_kml_export_units ( )
189{
190 vik_kml_export_units_t units;
71eede92 191 units = a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "kml_export_units")->u;
60dbd0ad
RN
192 return units;
193}
3317dc4e
RN
194
195#ifndef WINDOWS
196const gchar* a_vik_get_image_viewer ( )
197{
198 return a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "image_viewer")->s;
199}
200#endif
ccccf356
RN
201
202const gchar* a_vik_get_external_gpx_program_1 ( )
203{
204 return a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "external_gpx_1")->s;
205}
ff02058b
RN
206
207const gchar* a_vik_get_external_gpx_program_2 ( )
208{
209 return a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "external_gpx_2")->s;
210}