]>
Commit | Line | Data |
---|---|---|
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 | |
32 | gboolean vik_debug = FALSE; | |
33 | gboolean vik_verbose = FALSE; | |
34 | gboolean vik_version = FALSE; | |
35 | ||
a58aaed4 | 36 | static gchar * params_degree_formats[] = {"DDD", "DMM", "DMS", NULL}; |
6f9336aa | 37 | static gchar * params_units_distance[] = {"Kilometres", "Miles", NULL}; |
a4c92313 | 38 | static gchar * params_units_speed[] = {"km/h", "mph", "m/s", "knots", NULL}; |
6027a9c5 | 39 | static gchar * params_units_height[] = {"Metres", "Feet", NULL}; |
5210c3d3 GB |
40 | static VikLayerParamScale params_scales_lat[] = { {-90.0, 90.0, 0.05, 2} }; |
41 | static VikLayerParamScale params_scales_long[] = { {-180.0, 180.0, 0.05, 2} }; | |
42 | ||
6f9336aa | 43 | static 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 | 47 | static 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 | 51 | static 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 | 55 | static 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 | 59 | static 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 | 63 | static 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 | }; |
66 | static 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 | ||
72 | static gchar * params_kml_export_units[] = {"Metric", "Statute", "Nautical", NULL}; | |
73 | ||
74 | static 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 |
79 | static 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 | ||
60dbd0ad RN |
84 | /* End of Options static stuff */ |
85 | ||
a58aaed4 GB |
86 | void a_vik_preferences_init () |
87 | { | |
f02faa96 | 88 | // Defaults for the options are setup here |
1b03d66d | 89 | a_preferences_register_group ( VIKING_PREFERENCES_GROUP_KEY, _("General") ); |
a58aaed4 GB |
90 | |
91 | VikLayerParamData tmp; | |
92 | tmp.u = VIK_DEGREE_FORMAT_DMS; | |
6f9336aa RN |
93 | a_preferences_register(prefs1, tmp, VIKING_PREFERENCES_GROUP_KEY); |
94 | ||
95 | tmp.u = VIK_UNITS_DISTANCE_KILOMETRES; | |
96 | a_preferences_register(prefs2, tmp, VIKING_PREFERENCES_GROUP_KEY); | |
13bdea80 RN |
97 | |
98 | tmp.u = VIK_UNITS_SPEED_KILOMETRES_PER_HOUR; | |
99 | a_preferences_register(prefs3, tmp, VIKING_PREFERENCES_GROUP_KEY); | |
6027a9c5 RN |
100 | |
101 | tmp.u = VIK_UNITS_HEIGHT_METRES; | |
102 | a_preferences_register(prefs4, tmp, VIKING_PREFERENCES_GROUP_KEY); | |
9be0449f RN |
103 | |
104 | tmp.b = TRUE; | |
105 | a_preferences_register(prefs5, tmp, VIKING_PREFERENCES_GROUP_KEY); | |
5210c3d3 GB |
106 | |
107 | /* Maintain the default location to New York */ | |
108 | tmp.d = 40.714490; | |
109 | a_preferences_register(prefs6, tmp, VIKING_PREFERENCES_GROUP_KEY); | |
110 | tmp.d = -74.007130; | |
111 | a_preferences_register(prefs7, tmp, VIKING_PREFERENCES_GROUP_KEY); | |
2702f416 RN |
112 | |
113 | // New Tab | |
114 | a_preferences_register_group ( VIKING_PREFERENCES_IO_GROUP_KEY, _("Export/External") ); | |
60dbd0ad RN |
115 | |
116 | tmp.u = VIK_KML_EXPORT_UNITS_METRIC; | |
117 | a_preferences_register(&io_prefs[0], tmp, VIKING_PREFERENCES_IO_GROUP_KEY); | |
3317dc4e RN |
118 | |
119 | #ifndef WINDOWS | |
0b386bf3 | 120 | tmp.s = "xdg-open"; |
3317dc4e RN |
121 | a_preferences_register(&io_prefs_non_windows[0], tmp, VIKING_PREFERENCES_IO_GROUP_KEY); |
122 | #endif | |
a58aaed4 GB |
123 | } |
124 | ||
125 | vik_degree_format_t a_vik_get_degree_format ( ) | |
126 | { | |
127 | vik_degree_format_t format; | |
128 | format = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "degree_format")->u; | |
129 | return format; | |
a58aaed4 | 130 | } |
6f9336aa RN |
131 | |
132 | vik_units_distance_t a_vik_get_units_distance ( ) | |
133 | { | |
134 | vik_units_distance_t units; | |
135 | units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "units_distance")->u; | |
136 | return units; | |
137 | } | |
13bdea80 RN |
138 | |
139 | vik_units_speed_t a_vik_get_units_speed ( ) | |
140 | { | |
141 | vik_units_speed_t units; | |
142 | units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "units_speed")->u; | |
143 | return units; | |
144 | } | |
6027a9c5 RN |
145 | |
146 | vik_units_height_t a_vik_get_units_height ( ) | |
147 | { | |
148 | vik_units_height_t units; | |
149 | units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "units_height")->u; | |
150 | return units; | |
151 | } | |
9be0449f RN |
152 | |
153 | gboolean a_vik_get_use_large_waypoint_icons ( ) | |
154 | { | |
155 | gboolean use_large_waypoint_icons; | |
156 | use_large_waypoint_icons = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "use_large_waypoint_icons")->b; | |
157 | return use_large_waypoint_icons; | |
158 | } | |
5210c3d3 GB |
159 | |
160 | gdouble a_vik_get_default_lat ( ) | |
161 | { | |
162 | gdouble data; | |
163 | data = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "default_latitude")->d; | |
164 | return data; | |
165 | } | |
166 | ||
167 | gdouble a_vik_get_default_long ( ) | |
168 | { | |
169 | gdouble data; | |
170 | data = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "default_longitude")->d; | |
171 | return data; | |
172 | } | |
60dbd0ad RN |
173 | |
174 | /* External/Export Options */ | |
175 | ||
176 | vik_kml_export_units_t a_vik_get_kml_export_units ( ) | |
177 | { | |
178 | vik_kml_export_units_t units; | |
179 | units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "kml_export_units")->u; | |
180 | return units; | |
181 | } | |
3317dc4e RN |
182 | |
183 | #ifndef WINDOWS | |
184 | const gchar* a_vik_get_image_viewer ( ) | |
185 | { | |
186 | return a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "image_viewer")->s; | |
187 | } | |
188 | #endif |