]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * viking -- GPS Data and Topo Analyzer, Explorer, and Manager | |
3 | * | |
4 | * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net> | |
5 | * Copyright (C) 2008, Guilhem Bonnefille <guilhem.bonnefille@gmail.com> | |
6 | * Copyright (C) 2010, Rob Norris <rw_norris@hotmail.com> | |
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 | */ | |
23 | #ifdef HAVE_CONFIG_H | |
24 | #include "config.h" | |
25 | #endif | |
26 | ||
27 | #include <glib/gi18n.h> | |
28 | ||
29 | #include "globals.h" | |
30 | #include "preferences.h" | |
31 | ||
32 | gboolean vik_debug = FALSE; | |
33 | gboolean vik_verbose = FALSE; | |
34 | gboolean vik_version = FALSE; | |
35 | ||
36 | static gchar * params_degree_formats[] = {"DDD", "DMM", "DMS", NULL}; | |
37 | static gchar * params_units_distance[] = {"Kilometres", "Miles", NULL}; | |
38 | static gchar * params_units_speed[] = {"km/h", "mph", "m/s", "knots", NULL}; | |
39 | static gchar * params_units_height[] = {"Metres", "Feet", NULL}; | |
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 | ||
43 | static VikLayerParam prefs1[] = { | |
44 | { VIKING_PREFERENCES_NAMESPACE "degree_format", VIK_LAYER_PARAM_UINT, VIK_DEGREE_FORMAT_DMS, N_("Degree format:"), VIK_LAYER_WIDGET_COMBOBOX, params_degree_formats, NULL }, | |
45 | }; | |
46 | ||
47 | static VikLayerParam prefs2[] = { | |
48 | { VIKING_PREFERENCES_NAMESPACE "units_distance", VIK_LAYER_PARAM_UINT, VIK_UNITS_DISTANCE_KILOMETRES, N_("Distance units:"), VIK_LAYER_WIDGET_COMBOBOX, params_units_distance, NULL }, | |
49 | }; | |
50 | ||
51 | static VikLayerParam prefs3[] = { | |
52 | { VIKING_PREFERENCES_NAMESPACE "units_speed", VIK_LAYER_PARAM_UINT, VIK_UNITS_SPEED_KILOMETRES_PER_HOUR, N_("Speed units:"), VIK_LAYER_WIDGET_COMBOBOX, params_units_speed, NULL }, | |
53 | }; | |
54 | ||
55 | static VikLayerParam prefs4[] = { | |
56 | { VIKING_PREFERENCES_NAMESPACE "units_height", VIK_LAYER_PARAM_UINT, VIK_UNITS_HEIGHT_METRES, N_("Height units:"), VIK_LAYER_WIDGET_COMBOBOX, params_units_height, NULL }, | |
57 | }; | |
58 | ||
59 | static VikLayerParam prefs5[] = { | |
60 | { VIKING_PREFERENCES_NAMESPACE "use_large_waypoint_icons", VIK_LAYER_PARAM_BOOLEAN, TRUE, N_("Use large waypoint icons:"), VIK_LAYER_WIDGET_CHECKBUTTON, NULL, NULL }, | |
61 | }; | |
62 | ||
63 | static VikLayerParam prefs6[] = { | |
64 | { VIKING_PREFERENCES_NAMESPACE "default_latitude", VIK_LAYER_PARAM_DOUBLE, VIK_LOCATION_LAT, N_("Default latitude:"), VIK_LAYER_WIDGET_SPINBUTTON, params_scales_lat, NULL }, | |
65 | }; | |
66 | static VikLayerParam prefs7[] = { | |
67 | { VIKING_PREFERENCES_NAMESPACE "default_longitude", VIK_LAYER_PARAM_DOUBLE, VIK_LOCATION_LONG, N_("Default longitude:"), VIK_LAYER_WIDGET_SPINBUTTON, params_scales_long, NULL }, | |
68 | }; | |
69 | ||
70 | void a_vik_preferences_init () | |
71 | { | |
72 | a_preferences_register_group ( VIKING_PREFERENCES_GROUP_KEY, "Global preferences" ); | |
73 | ||
74 | VikLayerParamData tmp; | |
75 | tmp.u = VIK_DEGREE_FORMAT_DMS; | |
76 | a_preferences_register(prefs1, tmp, VIKING_PREFERENCES_GROUP_KEY); | |
77 | ||
78 | tmp.u = VIK_UNITS_DISTANCE_KILOMETRES; | |
79 | a_preferences_register(prefs2, tmp, VIKING_PREFERENCES_GROUP_KEY); | |
80 | ||
81 | tmp.u = VIK_UNITS_SPEED_KILOMETRES_PER_HOUR; | |
82 | a_preferences_register(prefs3, tmp, VIKING_PREFERENCES_GROUP_KEY); | |
83 | ||
84 | tmp.u = VIK_UNITS_HEIGHT_METRES; | |
85 | a_preferences_register(prefs4, tmp, VIKING_PREFERENCES_GROUP_KEY); | |
86 | ||
87 | tmp.b = TRUE; | |
88 | a_preferences_register(prefs5, tmp, VIKING_PREFERENCES_GROUP_KEY); | |
89 | ||
90 | /* Maintain the default location to New York */ | |
91 | tmp.d = 40.714490; | |
92 | a_preferences_register(prefs6, tmp, VIKING_PREFERENCES_GROUP_KEY); | |
93 | tmp.d = -74.007130; | |
94 | a_preferences_register(prefs7, tmp, VIKING_PREFERENCES_GROUP_KEY); | |
95 | } | |
96 | ||
97 | vik_degree_format_t a_vik_get_degree_format ( ) | |
98 | { | |
99 | vik_degree_format_t format; | |
100 | format = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "degree_format")->u; | |
101 | return format; | |
102 | } | |
103 | ||
104 | vik_units_distance_t a_vik_get_units_distance ( ) | |
105 | { | |
106 | vik_units_distance_t units; | |
107 | units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "units_distance")->u; | |
108 | return units; | |
109 | } | |
110 | ||
111 | vik_units_speed_t a_vik_get_units_speed ( ) | |
112 | { | |
113 | vik_units_speed_t units; | |
114 | units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "units_speed")->u; | |
115 | return units; | |
116 | } | |
117 | ||
118 | vik_units_height_t a_vik_get_units_height ( ) | |
119 | { | |
120 | vik_units_height_t units; | |
121 | units = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "units_height")->u; | |
122 | return units; | |
123 | } | |
124 | ||
125 | gboolean a_vik_get_use_large_waypoint_icons ( ) | |
126 | { | |
127 | gboolean use_large_waypoint_icons; | |
128 | use_large_waypoint_icons = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "use_large_waypoint_icons")->b; | |
129 | return use_large_waypoint_icons; | |
130 | } | |
131 | ||
132 | gdouble a_vik_get_default_lat ( ) | |
133 | { | |
134 | gdouble data; | |
135 | data = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "default_latitude")->d; | |
136 | return data; | |
137 | } | |
138 | ||
139 | gdouble a_vik_get_default_long ( ) | |
140 | { | |
141 | gdouble data; | |
142 | data = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "default_longitude")->d; | |
143 | return data; | |
144 | } |