20 |
#include <stddef.h> |
#include <stddef.h> |
21 |
#include <stdlib.h> |
#include <stdlib.h> |
22 |
#include <ctype.h> |
#include <ctype.h> |
23 |
|
#include <math.h> // for isnan |
24 |
#include "gpxview.h" |
#include "gpxview.h" |
25 |
|
|
26 |
#define GCONF_PATH "/apps/gpxview/" |
#define GCONF_PATH "/apps/gpxview/" |
84 |
{ "goto_dss", STORE_BOOL, OFFSET(goto_disable_screensaver) }, |
{ "goto_dss", STORE_BOOL, OFFSET(goto_disable_screensaver) }, |
85 |
{ "cachelist_update", STORE_BOOL, OFFSET(cachelist_update) }, |
{ "cachelist_update", STORE_BOOL, OFFSET(cachelist_update) }, |
86 |
#endif |
#endif |
87 |
|
#ifdef ENABLE_OSM_GPS_MAP |
88 |
|
{ "map_lat", STORE_FLOAT, OFFSET(map.pos.lat) }, |
89 |
|
{ "map_lon", STORE_FLOAT, OFFSET(map.pos.lon) }, |
90 |
|
{ "map_zoom", STORE_INT, OFFSET(map.zoom) }, |
91 |
|
#endif |
92 |
{ NULL, -1, -1 } |
{ NULL, -1, -1 } |
93 |
}; |
}; |
94 |
|
|
161 |
/* store everything listed in the store table */ |
/* store everything listed in the store table */ |
162 |
store_t *st = store; |
store_t *st = store; |
163 |
while(st->key) { |
while(st->key) { |
|
char key[256]; |
|
164 |
void **ptr = ((void*)appdata) + st->offset; |
void **ptr = ((void*)appdata) + st->offset; |
165 |
snprintf(key, sizeof(key), GCONF_PATH "%s", st->key); |
char *key = g_strdup_printf(GCONF_PATH "%s", st->key); |
166 |
|
|
167 |
switch(st->type) { |
switch(st->type) { |
168 |
case STORE_STRING: |
case STORE_STRING: |
180 |
break; |
break; |
181 |
|
|
182 |
case STORE_FLOAT: |
case STORE_FLOAT: |
183 |
gconf_client_set_float(appdata->gconf_client, key, *((float*)ptr), NULL); |
if(!isnan(*((float*)ptr))) |
184 |
|
gconf_client_set_float(appdata->gconf_client, key, *((float*)ptr), NULL); |
185 |
break; |
break; |
186 |
|
|
187 |
default: |
default: |
189 |
break; |
break; |
190 |
} |
} |
191 |
|
|
192 |
|
g_free(key); |
193 |
st++; |
st++; |
194 |
} |
} |
195 |
} |
} |
201 |
|
|
202 |
gpx_dialog_t *dialog = NULL; |
gpx_dialog_t *dialog = NULL; |
203 |
|
|
204 |
|
/* default positions are invalid */ |
205 |
|
appdata->home.lat = appdata->home.lon = NAN; |
206 |
|
appdata->manual_goto.lat = appdata->manual_goto.lon = NAN; |
207 |
|
appdata->gps.lat = appdata->gps.lon = NAN; |
208 |
|
|
209 |
int i, entries = gconf_client_get_int(appdata->gconf_client, |
int i, entries = gconf_client_get_int(appdata->gconf_client, |
210 |
GCONF_KEY_CNT, NULL); |
GCONF_KEY_CNT, NULL); |
211 |
|
|
266 |
/* restore everything listed in the store table */ |
/* restore everything listed in the store table */ |
267 |
store_t *st = store; |
store_t *st = store; |
268 |
while(st->key) { |
while(st->key) { |
|
char key[256]; |
|
269 |
void **ptr = ((void*)appdata) + st->offset; |
void **ptr = ((void*)appdata) + st->offset; |
270 |
snprintf(key, sizeof(key), GCONF_PATH "%s", st->key); |
char *key = g_strdup_printf(GCONF_PATH "%s", st->key); |
271 |
|
|
272 |
switch(st->type) { |
/* check if key is present */ |
273 |
case STORE_STRING: { |
GConfValue *value = gconf_client_get(appdata->gconf_client, key, NULL); |
274 |
char **str = (char**)ptr; |
if(value) { |
275 |
*str = gconf_client_get_string(appdata->gconf_client, key, NULL); |
gconf_value_free(value); |
276 |
|
|
277 |
|
switch(st->type) { |
278 |
|
case STORE_STRING: { |
279 |
|
char **str = (char**)ptr; |
280 |
|
*str = gconf_client_get_string(appdata->gconf_client, key, NULL); |
281 |
} break; |
} break; |
282 |
|
|
283 |
case STORE_BOOL: |
case STORE_BOOL: |
284 |
*((int*)ptr) = gconf_client_get_bool(appdata->gconf_client, key, NULL); |
*((int*)ptr) = gconf_client_get_bool(appdata->gconf_client, key, NULL); |
285 |
break; |
break; |
286 |
|
|
287 |
case STORE_INT: |
case STORE_INT: |
288 |
*((int*)ptr) = gconf_client_get_int(appdata->gconf_client, key, NULL); |
*((int*)ptr) = gconf_client_get_int(appdata->gconf_client, key, NULL); |
289 |
break; |
break; |
290 |
|
|
291 |
case STORE_FLOAT: |
case STORE_FLOAT: |
292 |
*((float*)ptr) = gconf_client_get_float(appdata->gconf_client, key, NULL); |
*((float*)ptr) = gconf_client_get_float(appdata->gconf_client, key, NULL); |
293 |
break; |
break; |
294 |
|
|
295 |
default: |
default: |
296 |
printf("Unsupported type %d\n", st->type); |
printf("Unsupported type %d\n", st->type); |
297 |
break; |
break; |
298 |
|
} |
299 |
} |
} |
300 |
|
g_free(key); |
301 |
st++; |
st++; |
302 |
} |
} |
303 |
|
|
304 |
/* ----- set all kinds of defaults ------- */ |
/* ----- set all kinds of defaults ------- */ |
305 |
|
|
|
#if 0 |
|
|
if(!appdata->home.lon || !appdata->home.lat) { |
|
|
appdata->home.lat = DEFAULT_LAT; |
|
|
appdata->home.lon = DEFAULT_LON; |
|
|
} |
|
|
|
|
|
if(!appdata->manual_goto.lon || !appdata->manual_goto.lat) { |
|
|
appdata->manual_goto.lat = DEFAULT_LAT; |
|
|
appdata->manual_goto.lon = DEFAULT_LON; |
|
|
} |
|
|
|
|
|
if(!appdata->gps.lon || !appdata->gps.lat) { |
|
|
appdata->gps.lat = DEFAULT_LAT; |
|
|
appdata->gps.lon = DEFAULT_LON; |
|
|
} |
|
|
#endif |
|
|
|
|
306 |
if(!appdata->compass_damping) appdata->compass_damping = 1; |
if(!appdata->compass_damping) appdata->compass_damping = 1; |
307 |
|
|
308 |
if(!appdata->mmpoi_radius) |
if(!appdata->mmpoi_radius) |
394 |
/* if there are no entries in the main list, try to add the */ |
/* if there are no entries in the main list, try to add the */ |
395 |
/* "welcome" one */ |
/* "welcome" one */ |
396 |
if(!appdata->gpx) { |
if(!appdata->gpx) { |
397 |
char *name = g_strdup("/usr/share/gpxview/welcome.gpx"); |
char *name = g_strdup(ICONPATH "welcome.gpx"); |
398 |
dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
399 |
printf("No GPX file loaded, trying to load demo\n"); |
printf("No GPX file loaded, trying to load demo\n"); |
400 |
appdata->gpx = gpx_parse(dialog, name); |
appdata->gpx = gpx_parse(dialog, name); |