From: Kaj-Michael Lang Date: Thu, 9 Aug 2007 10:08:39 +0000 (+0300) Subject: Set home location as valid if we get proper values. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b11b1b566599a2463596f9ddc86e09fbf2044fac;p=mapper Set home location as valid if we get proper values. Misc other cleanups. --- diff --git a/src/config-gconf.c b/src/config-gconf.c index 657dab8..23af015 100644 --- a/src/config-gconf.c +++ b/src/config-gconf.c @@ -139,23 +139,20 @@ if (!gconf_client) /* Get Map Cache Dir. Default is REPO_DEFAULT_CACHE_DIR. */ repo->cache_dir = gconf_client_get_string(gconf_client, - GCONF_KEY_MAP_DIR_NAME, - NULL); + GCONF_KEY_MAP_DIR_NAME, NULL); if (!repo->cache_dir) repo->cache_dir = gnome_vfs_expand_initial_tilde(REPO_DEFAULT_CACHE_DIR); /* Get Map Download URL Format. Default is "". */ repo->url = gconf_client_get_string(gconf_client, - GCONF_KEY_MAP_URI_FORMAT, - NULL); + GCONF_KEY_MAP_URI_FORMAT, NULL); if (!repo->url) repo->url = g_strdup(REPO_DEFAULT_MAP_URI); /* Get Map Download Zoom Steps. Default is 2. */ repo->dl_zoom_steps = gconf_client_get_int(gconf_client, - GCONF_KEY_MAP_ZOOM_STEPS, - NULL); + GCONF_KEY_MAP_ZOOM_STEPS, NULL); if (!repo->dl_zoom_steps) repo->dl_zoom_steps = REPO_DEFAULT_DL_ZOOM_STEPS; @@ -440,8 +437,7 @@ void config_init(void) printf("%s()\n", __PRETTY_FUNCTION__); if (!gconf_client) { - popup_error(_window, - _("Failed to initialize GConf. Quitting.")); + popup_error(_window, _("Failed to initialize GConf. Quitting.")); exit(1); } @@ -492,6 +488,9 @@ void config_init(void) if (!_center_ratio) _center_ratio = 7; + /* Invalidate destination */ + _dest.valid=FALSE; + /* Get Lead Ratio - Default is 5. */ _lead_ratio = gconf_client_get_int(gconf_client, GCONF_KEY_LEAD_AMOUNT, NULL); @@ -641,10 +640,29 @@ void config_init(void) if (_gps.lon==0.0) _gps.lon=22.0; /* Home */ - _home.lat = gconf_client_get_float(gconf_client, GCONF_KEY_HOME_LAT, NULL); - _home.lon = gconf_client_get_float(gconf_client, GCONF_KEY_HOME_LON, NULL); - if (_home.lat==0.0) _home.lat=64.0; - if (_home.lon==0.0) _home.lon=22.0; + _home.valid=TRUE; + value = gconf_client_get(gconf_client, GCONF_KEY_HOME_LAT, NULL); + if (value) { + _home.lat = gconf_value_get_float(value); + gconf_value_free(value); + } else { + _home.valid=FALSE; + } + + value = gconf_client_get(gconf_client, GCONF_KEY_HOME_LON, NULL); + if (value) { + _home.lon = gconf_value_get_float(value); + gconf_value_free(value); + } else { + _home.valid=FALSE; + } + + /* Turku is default */ + if (_home.valid==FALSE) { + _home.lat=64.0; + _home.lon=22.0; + _home.valid=TRUE; + } /* Get last center point. */ {