79 |
{ "compass_damping", STORE_INT, OFFSET(compass_damping) }, |
{ "compass_damping", STORE_INT, OFFSET(compass_damping) }, |
80 |
{ "cachelist_hide_found", STORE_BOOL, OFFSET(cachelist_hide_found) }, |
{ "cachelist_hide_found", STORE_BOOL, OFFSET(cachelist_hide_found) }, |
81 |
{ "cachelist_update", STORE_BOOL, OFFSET(cachelist_update) }, |
{ "cachelist_update", STORE_BOOL, OFFSET(cachelist_update) }, |
82 |
|
{ "disable_gcvote", STORE_BOOL, OFFSET(disable_gcvote) }, |
83 |
|
{ "username", STORE_STRING, OFFSET(username) }, |
84 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
85 |
{ "mmpoi_dontlaunch", STORE_BOOL, OFFSET(mmpoi_dontlaunch) }, |
{ "mmpoi_dontlaunch", STORE_BOOL, OFFSET(mmpoi_dontlaunch) }, |
86 |
{ "cachelist_dss", STORE_BOOL, OFFSET(cachelist_disable_screensaver) }, |
{ "cachelist_dss", STORE_BOOL, OFFSET(cachelist_disable_screensaver) }, |
92 |
{ "map_zoom", STORE_INT, OFFSET(map.zoom) }, |
{ "map_zoom", STORE_INT, OFFSET(map.zoom) }, |
93 |
{ "map_source", STORE_INT, OFFSET(map.source) }, |
{ "map_source", STORE_INT, OFFSET(map.source) }, |
94 |
#endif |
#endif |
95 |
|
|
96 |
|
{ "geotoad/password", STORE_STRING, OFFSET(gt.password) }, |
97 |
|
{ "geotoad/filename", STORE_STRING, OFFSET(gt.filename) }, |
98 |
|
{ "geotoad/distance", STORE_FLOAT, OFFSET(gt.distance) }, |
99 |
|
{ "geotoad/lat", STORE_FLOAT, OFFSET(gt.lat) }, |
100 |
|
{ "geotoad/lon", STORE_FLOAT, OFFSET(gt.lon) }, |
101 |
|
{ "geotoad/flags", STORE_INT, OFFSET(gt.flags) }, |
102 |
|
|
103 |
{ NULL, -1, -1 } |
{ NULL, -1, -1 } |
104 |
}; |
}; |
105 |
|
|
142 |
void gconf_save_state(appdata_t *appdata) { |
void gconf_save_state(appdata_t *appdata) { |
143 |
int entries = 0; |
int entries = 0; |
144 |
|
|
145 |
|
/* free proxy settings */ |
146 |
|
if(appdata->proxy) { |
147 |
|
proxy_t *proxy = appdata->proxy; |
148 |
|
|
149 |
|
if(proxy->authentication_password) g_free(proxy->authentication_password); |
150 |
|
if(proxy->authentication_user) g_free(proxy->authentication_user); |
151 |
|
if(proxy->host) g_free(proxy->host); |
152 |
|
if(proxy->ignore_hosts) g_free(proxy->ignore_hosts); |
153 |
|
|
154 |
|
g_free(proxy); |
155 |
|
appdata->proxy = NULL; |
156 |
|
} |
157 |
|
|
158 |
gpx_t *gpx = appdata->gpx; |
gpx_t *gpx = appdata->gpx; |
159 |
while(gpx) { |
while(gpx) { |
160 |
char str[128]; |
char str[128]; |
193 |
if((char*)(*ptr)) { |
if((char*)(*ptr)) { |
194 |
gconf_client_set_string(appdata->gconf_client, key, (char*)(*ptr), NULL); |
gconf_client_set_string(appdata->gconf_client, key, (char*)(*ptr), NULL); |
195 |
} |
} |
196 |
|
g_free((char*)(*ptr)); |
197 |
|
*ptr = NULL; |
198 |
break; |
break; |
199 |
|
|
200 |
case STORE_BOOL: |
case STORE_BOOL: |
232 |
appdata->manual_goto.lat = appdata->manual_goto.lon = NAN; |
appdata->manual_goto.lat = appdata->manual_goto.lon = NAN; |
233 |
appdata->gps.lat = appdata->gps.lon = NAN; |
appdata->gps.lat = appdata->gps.lon = NAN; |
234 |
|
|
235 |
|
appdata->gt.lat = appdata->gt.lon = NAN; |
236 |
|
appdata->gt.distance = 1.0; // in km/mil |
237 |
|
|
238 |
|
/* ------------- get proxy settings -------------------- */ |
239 |
|
if(gconf_client_get_bool(appdata->gconf_client, |
240 |
|
PROXY_KEY "use_http_proxy", NULL)) { |
241 |
|
proxy_t *proxy = appdata->proxy = g_new0(proxy_t, 1); |
242 |
|
|
243 |
|
/* get basic settings */ |
244 |
|
proxy->host = gconf_client_get_string(appdata->gconf_client, |
245 |
|
PROXY_KEY "host", NULL); |
246 |
|
proxy->port = gconf_client_get_int(appdata->gconf_client, |
247 |
|
PROXY_KEY "port", NULL); |
248 |
|
proxy->ignore_hosts = |
249 |
|
gconf_client_get_string(appdata->gconf_client, |
250 |
|
PROXY_KEY "ignore_hosts", NULL); |
251 |
|
|
252 |
|
/* check for authentication */ |
253 |
|
proxy->use_authentication = |
254 |
|
gconf_client_get_bool(appdata->gconf_client, |
255 |
|
PROXY_KEY "use_authentication", NULL); |
256 |
|
|
257 |
|
if(proxy->use_authentication) { |
258 |
|
proxy->authentication_user = |
259 |
|
gconf_client_get_string(appdata->gconf_client, |
260 |
|
PROXY_KEY "authentication_user", NULL); |
261 |
|
proxy->authentication_password = |
262 |
|
gconf_client_get_string(appdata->gconf_client, |
263 |
|
PROXY_KEY "authentication_password", NULL); |
264 |
|
} |
265 |
|
} |
266 |
|
|
267 |
|
/* restore everything listed in the store table */ |
268 |
|
store_t *st = store; |
269 |
|
while(st->key) { |
270 |
|
void **ptr = ((void*)appdata) + st->offset; |
271 |
|
char *key = g_strdup_printf(GCONF_PATH "%s", st->key); |
272 |
|
|
273 |
|
/* check if key is present */ |
274 |
|
GConfValue *value = gconf_client_get(appdata->gconf_client, key, NULL); |
275 |
|
if(value) { |
276 |
|
gconf_value_free(value); |
277 |
|
|
278 |
|
switch(st->type) { |
279 |
|
case STORE_STRING: { |
280 |
|
char **str = (char**)ptr; |
281 |
|
*str = gconf_client_get_string(appdata->gconf_client, key, NULL); |
282 |
|
} break; |
283 |
|
|
284 |
|
case STORE_BOOL: |
285 |
|
*((int*)ptr) = gconf_client_get_bool(appdata->gconf_client, key, NULL); |
286 |
|
break; |
287 |
|
|
288 |
|
case STORE_INT: |
289 |
|
*((int*)ptr) = gconf_client_get_int(appdata->gconf_client, key, NULL); |
290 |
|
break; |
291 |
|
|
292 |
|
case STORE_FLOAT: |
293 |
|
*((float*)ptr) = gconf_client_get_float(appdata->gconf_client, key, NULL); |
294 |
|
break; |
295 |
|
|
296 |
|
default: |
297 |
|
printf("Unsupported type %d\n", st->type); |
298 |
|
break; |
299 |
|
} |
300 |
|
} |
301 |
|
g_free(key); |
302 |
|
st++; |
303 |
|
} |
304 |
|
|
305 |
int i, entries = gconf_client_get_int(appdata->gconf_client, |
int i, entries = gconf_client_get_int(appdata->gconf_client, |
306 |
GCONF_KEY_CNT, NULL); |
GCONF_KEY_CNT, NULL); |
307 |
|
|
323 |
(*gpx)->closed = TRUE; |
(*gpx)->closed = TRUE; |
324 |
} else { |
} else { |
325 |
if(g_file_test(fname, G_FILE_TEST_IS_DIR)) |
if(g_file_test(fname, G_FILE_TEST_IS_DIR)) |
326 |
*gpx = gpx_parse_dir(dialog, fname); |
*gpx = gpx_parse_dir(dialog, fname, appdata->username); |
327 |
else |
else |
328 |
*gpx = gpx_parse(dialog, fname); |
*gpx = gpx_parse(dialog, fname, appdata->username); |
329 |
|
|
330 |
if(!*gpx) { |
if(!*gpx) { |
331 |
/* restoring the gpx file failed, mark it as unusable, but save */ |
/* restoring the gpx file failed, mark it as unusable, but save */ |
370 |
} |
} |
371 |
} |
} |
372 |
|
|
|
/* restore everything listed in the store table */ |
|
|
store_t *st = store; |
|
|
while(st->key) { |
|
|
void **ptr = ((void*)appdata) + st->offset; |
|
|
char *key = g_strdup_printf(GCONF_PATH "%s", st->key); |
|
|
|
|
|
/* check if key is present */ |
|
|
GConfValue *value = gconf_client_get(appdata->gconf_client, key, NULL); |
|
|
if(value) { |
|
|
gconf_value_free(value); |
|
|
|
|
|
switch(st->type) { |
|
|
case STORE_STRING: { |
|
|
char **str = (char**)ptr; |
|
|
*str = gconf_client_get_string(appdata->gconf_client, key, NULL); |
|
|
} break; |
|
|
|
|
|
case STORE_BOOL: |
|
|
*((int*)ptr) = gconf_client_get_bool(appdata->gconf_client, key, NULL); |
|
|
break; |
|
|
|
|
|
case STORE_INT: |
|
|
*((int*)ptr) = gconf_client_get_int(appdata->gconf_client, key, NULL); |
|
|
break; |
|
|
|
|
|
case STORE_FLOAT: |
|
|
*((float*)ptr) = gconf_client_get_float(appdata->gconf_client, key, NULL); |
|
|
break; |
|
|
|
|
|
default: |
|
|
printf("Unsupported type %d\n", st->type); |
|
|
break; |
|
|
} |
|
|
} |
|
|
g_free(key); |
|
|
st++; |
|
|
} |
|
|
|
|
373 |
/* ----- set all kinds of defaults ------- */ |
/* ----- set all kinds of defaults ------- */ |
374 |
|
|
375 |
if(!appdata->compass_damping) appdata->compass_damping = 1; |
if(!appdata->compass_damping) appdata->compass_damping = 1; |
486 |
char *name = g_strdup(ICONPATH "welcome.gpx"); |
char *name = g_strdup(ICONPATH "welcome.gpx"); |
487 |
dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
488 |
printf("No GPX file loaded, trying to load demo\n"); |
printf("No GPX file loaded, trying to load demo\n"); |
489 |
appdata->gpx = gpx_parse(dialog, name); |
appdata->gpx = gpx_parse(dialog, name, appdata->username); |
490 |
gpx_busy_dialog_destroy(dialog); |
gpx_busy_dialog_destroy(dialog); |
491 |
g_free(name); |
g_free(name); |
492 |
} |
} |