#include "settings.h"
#include "gpx.h"
-void config_update_proxy(void)
+void
+config_update_proxy(void)
{
- GConfClient *gconf_client = gconf_client_get_default();
- printf("%s()\n", __PRETTY_FUNCTION__);
-
- if (_http_proxy_host)
- g_free(_http_proxy_host);
-
- /* Get proxy data and register for updates. */
- if (gconf_client_get_bool(gconf_client, GCONF_KEY_HTTP_PROXY_ON, NULL)) {
- /* HTTP Proxy is on. */
- _http_proxy_host = gconf_client_get_string(gconf_client,
- GCONF_KEY_HTTP_PROXY_HOST,
- NULL);
- _http_proxy_port =
- gconf_client_get_int(gconf_client,
- GCONF_KEY_HTTP_PROXY_PORT, NULL);
- } else {
- /* HTTP Proxy is off. */
- _http_proxy_host = NULL;
- _http_proxy_port = 0;
- }
- g_object_unref(gconf_client);
+GConfClient *gconf_client = gconf_client_get_default();
- vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+if (_http_proxy_host)
+ g_free(_http_proxy_host);
+
+/* Get proxy data and register for updates. */
+if (gconf_client_get_bool(gconf_client, GCONF_KEY_HTTP_PROXY_ON, NULL)) {
+ _http_proxy_host = gconf_client_get_string(gconf_client,
+ GCONF_KEY_HTTP_PROXY_HOST,
+ NULL);
+ _http_proxy_port = gconf_client_get_int(gconf_client, GCONF_KEY_HTTP_PROXY_PORT, NULL);
+} else {
+ _http_proxy_host = NULL;
+ _http_proxy_port = 0;
+}
+g_object_unref(gconf_client);
}
-static void config_save_track(gchar *config_dir)
+static void
+config_save_track(gchar *config_dir)
{
GnomeVFSHandle *handle;
gchar *track_file;
g_free(track_file);
}
-static void config_save_route(gchar *config_dir)
+static void
+config_save_route(gchar *config_dir)
{
GnomeVFSHandle *handle;
gchar *route_file;
GConfClient *gconf_client = gconf_client_get_default();
if (!gconf_client)
- return FALSE;
+ return;
/* 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);
gboolean
config_save(void)
{
- gchar *config_dir;
- GConfClient *gconf_client = gconf_client_get_default();
- gchar buffer[16];
- printf("%s()\n", __PRETTY_FUNCTION__);
-
- if (!gconf_client)
- return FALSE;
-
- /* Initialize config_dir. */
- config_dir = gnome_vfs_expand_initial_tilde(CONFIG_DIR_NAME);
- g_mkdir_with_parents(config_dir, 0700);
-
- /* Save Receiver MAC from GConf. */
- if (_rcvr_mac)
- gconf_client_set_string(gconf_client, GCONF_KEY_RCVR_MAC, _rcvr_mac, NULL);
- else
- gconf_client_unset(gconf_client, GCONF_KEY_RCVR_MAC, NULL);
-
- /* Save Auto-Download. */
- gconf_client_set_bool(gconf_client,
- GCONF_KEY_AUTO_DOWNLOAD, _auto_download, NULL);
-
- /* Save Auto-Center Sensitivity. */
- gconf_client_set_int(gconf_client,
- GCONF_KEY_CENTER_SENSITIVITY, _center_ratio, NULL);
-
- /* Save Auto-Center Lead Amount. */
- gconf_client_set_int(gconf_client,
- GCONF_KEY_LEAD_AMOUNT, _lead_ratio, NULL);
-
- /* Save Draw Line Width. */
- gconf_client_set_int(gconf_client,
- GCONF_KEY_DRAW_WIDTH, _draw_width, NULL);
-
- /* Save Announce Advance Notice Ratio. */
- gconf_client_set_int(gconf_client,
- GCONF_KEY_ANNOUNCE_NOTICE, _announce_notice_ratio,
- NULL);
-
- /* Save Enable Voice flag. */
- gconf_client_set_bool(gconf_client,
- GCONF_KEY_ENABLE_VOICE, _enable_voice, NULL);
-
- /* Save Keep On When Fullscreen flag. */
- gconf_client_set_bool(gconf_client,
- GCONF_KEY_ALWAYS_KEEP_ON, _always_keep_on, NULL);
-
- /* Save Units. */
- gconf_client_set_string(gconf_client,
- GCONF_KEY_UNITS, UNITS_TEXT[_units], NULL);
-
- /* Save Custom Key Actions. */
- {
- gint i;
- for (i = 0; i < CUSTOM_KEY_ENUM_COUNT; i++)
- gconf_client_set_string(gconf_client,
- CUSTOM_KEY_GCONF[i],
- CUSTOM_ACTION_TEXT[_action[i]],
- NULL);
- }
+gchar *config_dir;
+GConfClient *gconf_client = gconf_client_get_default();
+gchar buffer[16];
+gfloat center_lat, center_lon;
+gint i;
- /* Save Deg Format. */
- gconf_client_set_string(gconf_client,
- GCONF_KEY_DEG_FORMAT,
- DEG_FORMAT_TEXT[_degformat], NULL);
+if (!gconf_client)
+ return FALSE;
- /* Save Speed Limit On flag. */
- gconf_client_set_bool(gconf_client,
- GCONF_KEY_SPEED_LIMIT_ON, _speed_limit_on, NULL);
+/* Initialize config_dir. */
+config_dir = gnome_vfs_expand_initial_tilde(CONFIG_DIR_NAME);
+g_mkdir_with_parents(config_dir, 0700);
- /* Save Speed Limit. */
- gconf_client_set_int(gconf_client,
- GCONF_KEY_SPEED_LIMIT, _speed_limit, NULL);
+/* Save Receiver MAC from GConf. */
+if (_rcvr_mac)
+ gconf_client_set_string(gconf_client, GCONF_KEY_RCVR_MAC, _rcvr_mac, NULL);
+else
+ gconf_client_unset(gconf_client, GCONF_KEY_RCVR_MAC, NULL);
- /* Save Speed Location. */
- gconf_client_set_string(gconf_client,
- GCONF_KEY_SPEED_LOCATION,
- SPEED_LOCATION_TEXT[_speed_location], NULL);
+/* Save Auto-Download. */
+gconf_client_set_bool(gconf_client, GCONF_KEY_AUTO_DOWNLOAD, _auto_download, NULL);
+
+/* Save Auto-Center Sensitivity. */
+gconf_client_set_int(gconf_client, GCONF_KEY_CENTER_SENSITIVITY, _center_ratio, NULL);
+
+/* Save Auto-Center Lead Amount. */
+gconf_client_set_int(gconf_client, GCONF_KEY_LEAD_AMOUNT, _lead_ratio, NULL);
+
+/* Save Draw Line Width. */
+gconf_client_set_int(gconf_client, GCONF_KEY_DRAW_WIDTH, _draw_width, NULL);
+
+/* Save Announce Advance Notice Ratio. */
+gconf_client_set_int(gconf_client, GCONF_KEY_ANNOUNCE_NOTICE, _announce_notice_ratio, NULL);
- /* Save Info Font Size. */
+/* Save Enable Voice flag. */
+gconf_client_set_bool(gconf_client, GCONF_KEY_ENABLE_VOICE, _enable_voice, NULL);
+
+/* Save Keep On When Fullscreen flag. */
+gconf_client_set_bool(gconf_client, GCONF_KEY_ALWAYS_KEEP_ON, _always_keep_on, NULL);
+
+/* Save Units. */
+gconf_client_set_string(gconf_client, GCONF_KEY_UNITS, UNITS_TEXT[_units], NULL);
+
+/* Save Custom Key Actions. */
+for (i = 0; i < CUSTOM_KEY_ENUM_COUNT; i++)
gconf_client_set_string(gconf_client,
- GCONF_KEY_INFO_FONT_SIZE,
- INFO_FONT_TEXT[_info_font_size], NULL);
-
- /* Save last saved latitude/longiture. */
- gconf_client_set_float(gconf_client, GCONF_KEY_LAT, _gps.lat, NULL);
- gconf_client_set_float(gconf_client, GCONF_KEY_LON, _gps.lon, NULL);
-
- /* Save last center point. */
- {
- gfloat center_lat, center_lon;
- unit2latlon(_center.unitx, _center.unity, center_lat,
- center_lon);
-
- /* Save last center latitude. */
- gconf_client_set_float(gconf_client,
- GCONF_KEY_CENTER_LAT, center_lat, NULL);
-
- /* Save last center longitude. */
- gconf_client_set_float(gconf_client,
- GCONF_KEY_CENTER_LON, center_lon, NULL);
- }
+ CUSTOM_KEY_GCONF[i],
+ CUSTOM_ACTION_TEXT[_action[i]],
+ NULL);
- /* Save last Zoom Level. */
- gconf_client_set_int(gconf_client, GCONF_KEY_ZOOM, _zoom, NULL);
-
- /* Save Route Directory. */
- if (_route_dir_uri)
- gconf_client_set_string(gconf_client,
- GCONF_KEY_ROUTEDIR, _route_dir_uri,
- NULL);
-
- /* Save Last Track File. */
- if (_track_file_uri)
- gconf_client_set_string(gconf_client,
- GCONF_KEY_TRACKFILE, _track_file_uri,
- NULL);
-
- /* Save Auto-Center Mode. */
- gconf_client_set_int(gconf_client,
- GCONF_KEY_AUTOCENTER_MODE, _center_mode, NULL);
-
- /* Save Show Scale flag. */
- gconf_client_set_bool(gconf_client,
- GCONF_KEY_SHOWSCALE, _show_scale, NULL);
-
- /* Save Show Tracks flag. */
- gconf_client_set_bool(gconf_client,
- GCONF_KEY_SHOWTRACKS, _show_tracks & TRACKS_MASK,
- NULL);
-
- /* Save Show Routes flag. */
- gconf_client_set_bool(gconf_client, GCONF_KEY_SHOWROUTES, _show_tracks & ROUTES_MASK, NULL);
-
- /* Save Show Velocity Vector flag. */
- gconf_client_set_bool(gconf_client, GCONF_KEY_SHOWVELVEC, _show_velvec, NULL);
-
- /* Save Show POIs flag. */
- gconf_client_set_bool(gconf_client, GCONF_KEY_SHOWPOIS, _show_poi, NULL);
-
- /* Save Enable GPS flag. */
- gconf_client_set_bool(gconf_client, GCONF_KEY_ENABLE_GPS, _enable_gps, NULL);
-
- /* Save Route Locations. */
- gconf_client_set_list(gconf_client, GCONF_KEY_ROUTE_LOCATIONS, GCONF_VALUE_STRING, _loc_list, NULL);
-
- /* Save GPS Info flag. */
- gconf_client_set_bool(gconf_client, GCONF_KEY_GPS_INFO, _gps_info, NULL);
-
- /* Save Route Download URL Format. */
- gconf_client_set_string(gconf_client, GCONF_KEY_ROUTE_DL_URL, _route_dl_url, NULL);
-
- /* Save Route Download Radius. */
- gconf_client_set_int(gconf_client, GCONF_KEY_ROUTE_DL_RADIUS, _route_dl_radius, NULL);
-
- /* Save Colors. */
- {
- gint i;
- for (i = 0; i < COLORABLE_ENUM_COUNT; i++) {
- snprintf(buffer, sizeof(buffer), "#%02x%02x%02x",
- _color[i].red >> 8,
- _color[i].green >> 8, _color[i].blue >> 8);
- gconf_client_set_string(gconf_client,
- COLORABLE_GCONF[i], buffer,
- NULL);
- }
- }
+/* Save Deg Format. */
+gconf_client_set_string(gconf_client,
+ GCONF_KEY_DEG_FORMAT,
+ DEG_FORMAT_TEXT[_degformat], NULL);
+
+/* Save Speed Limit On flag. */
+gconf_client_set_bool(gconf_client, GCONF_KEY_SPEED_LIMIT_ON, _speed_limit_on, NULL);
+
+/* Save Speed Limit. */
+gconf_client_set_int(gconf_client, GCONF_KEY_SPEED_LIMIT, _speed_limit, NULL);
+
+/* Save Speed Location. */
+gconf_client_set_string(gconf_client,
+ GCONF_KEY_SPEED_LOCATION,
+ SPEED_LOCATION_TEXT[_speed_location], NULL);
+
+/* Save Info Font Size. */
+gconf_client_set_string(gconf_client,
+ GCONF_KEY_INFO_FONT_SIZE,
+ INFO_FONT_TEXT[_info_font_size], NULL);
+
+/* Save last latitude/longiture. */
+gconf_client_set_float(gconf_client, GCONF_KEY_LAT, _gps.lat, NULL);
+gconf_client_set_float(gconf_client, GCONF_KEY_LON, _gps.lon, NULL);
+
+/* Save last center latitude/longitude. */
+unit2latlon(_center.unitx, _center.unity, center_lat, center_lon);
+gconf_client_set_float(gconf_client, GCONF_KEY_CENTER_LAT, center_lat, NULL);
+gconf_client_set_float(gconf_client, GCONF_KEY_CENTER_LON, center_lon, NULL);
+
+/* Save last Zoom Level. */
+gconf_client_set_int(gconf_client, GCONF_KEY_ZOOM, _zoom, NULL);
+
+/* Save Route Directory. */
+if (_route_dir_uri)
+ gconf_client_set_string(gconf_client, GCONF_KEY_ROUTEDIR, _route_dir_uri, NULL);
+
+/* Save Last Track File. */
+if (_track_file_uri)
+ gconf_client_set_string(gconf_client, GCONF_KEY_TRACKFILE, _track_file_uri, NULL);
+
+/* Save Auto-Center Mode. */
+gconf_client_set_int(gconf_client, GCONF_KEY_AUTOCENTER_MODE, _center_mode, NULL);
+
+/* Save Show Scale flag. */
+gconf_client_set_bool(gconf_client, GCONF_KEY_SHOWSCALE, _show_scale, NULL);
+
+/* Save Show Tracks flag. */
+gconf_client_set_bool(gconf_client, GCONF_KEY_SHOWTRACKS, _show_tracks & TRACKS_MASK, NULL);
+
+/* Save Show Routes flag. */
+gconf_client_set_bool(gconf_client, GCONF_KEY_SHOWROUTES, _show_tracks & ROUTES_MASK, NULL);
+
+/* Save Show Velocity Vector flag. */
+gconf_client_set_bool(gconf_client, GCONF_KEY_SHOWVELVEC, _show_velvec, NULL);
- /* Save Mapper database. */
- if (_mapper_db)
- gconf_client_set_string(gconf_client, GCONF_KEY_MAPPER_DB, _mapper_db, NULL);
- else
- gconf_client_unset(gconf_client, GCONF_KEY_MAPPER_DB, NULL);
+/* Save Show POIs flag. */
+gconf_client_set_bool(gconf_client, GCONF_KEY_SHOWPOIS, _show_poi, NULL);
- /* Save Show POI below zoom. */
- gconf_client_set_int(gconf_client, GCONF_KEY_POI_ZOOM, _poi_zoom, NULL);
+/* Save Enable GPS flag. */
+gconf_client_set_bool(gconf_client, GCONF_KEY_ENABLE_GPS, _enable_gps, NULL);
+/* Save Route Locations. */
+gconf_client_set_list(gconf_client, GCONF_KEY_ROUTE_LOCATIONS, GCONF_VALUE_STRING, _loc_list, NULL);
+
+/* Save GPS Info flag. */
+gconf_client_set_bool(gconf_client, GCONF_KEY_GPS_INFO, _gps_info, NULL);
+
+/* Save Route Download URL Format. */
+gconf_client_set_string(gconf_client, GCONF_KEY_ROUTE_DL_URL, _route_dl_url, NULL);
+
+/* Save Route Download Radius. */
+gconf_client_set_int(gconf_client, GCONF_KEY_ROUTE_DL_RADIUS, _route_dl_radius, NULL);
+
+/* Save Colors. */
+for (i = 0; i < COLORABLE_ENUM_COUNT; i++) {
+ snprintf(buffer, sizeof(buffer), "#%02x%02x%02x",
+ _color[i].red >> 8, _color[i].green >> 8, _color[i].blue >> 8);
+ gconf_client_set_string(gconf_client, COLORABLE_GCONF[i], buffer, NULL);
+}
+
+/* Save Mapper database. */
+if (_mapper_db)
+ gconf_client_set_string(gconf_client, GCONF_KEY_MAPPER_DB, _mapper_db, NULL);
+else
+ gconf_client_unset(gconf_client, GCONF_KEY_MAPPER_DB, NULL);
+
+/* Save Show POI below zoom. */
+gconf_client_set_int(gconf_client, GCONF_KEY_POI_ZOOM, _poi_zoom, NULL);
+
+#if 0
config_save_track(config_dir);
config_save_route(config_dir);
+#endif
- gconf_client_clear_cache(gconf_client);
- g_object_unref(gconf_client);
- g_free(config_dir);
+gconf_client_clear_cache(gconf_client);
+g_object_unref(gconf_client);
+g_free(config_dir);
+return TRUE;
+}
+
+static void
+config_load_saved_route(gchar *config_dir)
+{
+gchar *route_file;
+gchar *bytes;
+gint size;
+
+route_file = gnome_vfs_uri_make_full_from_relative(config_dir, CONFIG_FILE_ROUTE);
+if (GNOME_VFS_OK == gnome_vfs_read_entire_file(route_file, &size, &bytes))
+ parse_gpx(&_route, bytes, size, 0); /* 0 to replace route. */
+g_free(route_file);
+}
- vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+static void
+config_load_saved_track(gchar *config_dir)
+{
+gchar *track_file;
+gchar *bytes;
+gint size;
- return TRUE;
+track_file = gnome_vfs_uri_make_full_from_relative(config_dir, CONFIG_FILE_TRACK);
+if (GNOME_VFS_OK == gnome_vfs_read_entire_file(track_file, &size, &bytes))
+ parse_gpx(&_track, bytes, size, 0); /* 0 to replace track. */
+g_free(track_file);
}
+
/**
* Initialize all configuration from GCONF. This should not be called more
* than once during execution.
*/
void config_init(void)
{
- GConfValue *value;
- GConfClient *gconf_client = gconf_client_get_default();
- gchar *config_dir;
- gchar *str;
- printf("%s()\n", __PRETTY_FUNCTION__);
-
- if (!gconf_client) {
- popup_error(_window, _("Failed to initialize GConf. Quitting."));
- exit(1);
- }
+GConfValue *value;
+GConfClient *gconf_client = gconf_client_get_default();
+gchar *config_dir;
+gchar *str;
+gint i;
- CenterMode _center_mode = CENTER_LEAD;
- UnitType _units = UNITS_KM;
- guint _degformat = DDPDDDDD;
- SpeedLocation _speed_location = SPEED_LOCATION_TOP_RIGHT;
- InfoFontSize _info_font_size = INFO_FONT_MEDIUM;
-
- /* Initialize config_dir. */
- config_dir = gnome_vfs_expand_initial_tilde(CONFIG_DIR_NAME);
- g_mkdir_with_parents(config_dir, 0700);
-
- /* Retrieve route. */
- {
- gchar *route_file;
- gchar *bytes;
- gint size;
-
- route_file = gnome_vfs_uri_make_full_from_relative(config_dir, CONFIG_FILE_ROUTE);
- if (GNOME_VFS_OK == gnome_vfs_read_entire_file(route_file, &size, &bytes))
- parse_gpx(&_route, bytes, size, 0); /* 0 to replace route. */
- g_free(route_file);
- }
+if (!gconf_client) {
+ popup_error(_window, _("Failed to initialize GConf. Quitting."));
+ exit(1);
+}
- /* Retrieve track. */
- {
- gchar *track_file;
- gchar *bytes;
- gint size;
+CenterMode _center_mode = CENTER_LEAD;
+UnitType _units = UNITS_KM;
+guint _degformat = DDPDDDDD;
+SpeedLocation _speed_location = SPEED_LOCATION_TOP_RIGHT;
+InfoFontSize _info_font_size = INFO_FONT_MEDIUM;
- track_file = gnome_vfs_uri_make_full_from_relative(config_dir, CONFIG_FILE_TRACK);
- if (GNOME_VFS_OK == gnome_vfs_read_entire_file(track_file, &size, &bytes))
- parse_gpx(&_track, bytes, size, 0); /* 0 to replace track. */
- g_free(track_file);
- }
+/* Initialize config_dir. */
+config_dir = gnome_vfs_expand_initial_tilde(CONFIG_DIR_NAME);
+g_mkdir_with_parents(config_dir, 0700);
- /* Get Receiver MAC from GConf. Default is scanned via hci_inquiry. */
- _rcvr_mac = gconf_client_get_string(gconf_client, GCONF_KEY_RCVR_MAC, NULL);
+/* Get Receiver MAC from GConf. Default is scanned via hci_inquiry. */
+_rcvr_mac = gconf_client_get_string(gconf_client, GCONF_KEY_RCVR_MAC, NULL);
- /* Get Auto-Download. Default is FALSE. */
- _auto_download = gconf_client_get_bool(gconf_client, GCONF_KEY_AUTO_DOWNLOAD, NULL);
+/* Get Auto-Download. Default is FALSE. */
+_auto_download = gconf_client_get_bool(gconf_client, GCONF_KEY_AUTO_DOWNLOAD, NULL);
- /* Get Center Ratio - Default is 3. */
- _center_ratio = gconf_client_get_int(gconf_client, GCONF_KEY_CENTER_SENSITIVITY, NULL);
- if (!_center_ratio)
- _center_ratio = 7;
+/* Get Center Ratio - Default is 3. */
+_center_ratio = gconf_client_get_int(gconf_client, GCONF_KEY_CENTER_SENSITIVITY, NULL);
+if (!_center_ratio)
+ _center_ratio = 7;
- /* Invalidate destination */
- _dest.valid=FALSE;
+/* Invalidate destination */
+_dest.valid=FALSE;
- /* Get Lead Ratio - Default is 5. */
- _lead_ratio = gconf_client_get_int(gconf_client, GCONF_KEY_LEAD_AMOUNT, NULL);
- if (!_lead_ratio)
- _lead_ratio = 5;
+/* Get Lead Ratio - Default is 5. */
+_lead_ratio = gconf_client_get_int(gconf_client, GCONF_KEY_LEAD_AMOUNT, NULL);
+if (!_lead_ratio)
+ _lead_ratio = 5;
- /* Get Draw Line Width- Default is 4. */
- _draw_width = gconf_client_get_int(gconf_client, GCONF_KEY_DRAW_WIDTH, NULL);
- if (!_draw_width)
- _draw_width = 4;
+/* Get Draw Line Width- Default is 4. */
+_draw_width = gconf_client_get_int(gconf_client, GCONF_KEY_DRAW_WIDTH, NULL);
+if (!_draw_width)
+ _draw_width = 4;
- /* Get Announce Advance Notice - Default is 30. */
- value = gconf_client_get(gconf_client, GCONF_KEY_ANNOUNCE_NOTICE, NULL);
- if (value) {
- _announce_notice_ratio = gconf_value_get_int(value);
- gconf_value_free(value);
- } else
- _announce_notice_ratio = 8;
+/* Get Announce Advance Notice - Default is 30. */
+value = gconf_client_get(gconf_client, GCONF_KEY_ANNOUNCE_NOTICE, NULL);
+if (value) {
+ _announce_notice_ratio = gconf_value_get_int(value);
+ gconf_value_free(value);
+} else {
+ _announce_notice_ratio = 8;
+}
- /* Get Enable Voice flag. Default is TRUE. */
- value = gconf_client_get(gconf_client, GCONF_KEY_ENABLE_VOICE, NULL);
- if (value) {
- _enable_voice = gconf_value_get_bool(value);
- gconf_value_free(value);
- } else
- _enable_voice = TRUE;
+/* Get Enable Voice flag. Default is TRUE. */
+value = gconf_client_get(gconf_client, GCONF_KEY_ENABLE_VOICE, NULL);
+if (value) {
+ _enable_voice = gconf_value_get_bool(value);
+ gconf_value_free(value);
+} else {
+ _enable_voice = TRUE;
+}
- /* Get Voice Speed - Default is . */
- value = gconf_client_get(gconf_client, GCONF_KEY_VOICE_SPEED, NULL);
- if (value) {
- _voice_speed = gconf_value_get_int(value);
- gconf_value_free(value);
- } else {
- _voice_speed = 120;
- }
- if (_voice_speed<80 || _voice_speed>370)
- _voice_speed = 120;
+ /* Get Voice Speed - Default is 120 */
+value = gconf_client_get(gconf_client, GCONF_KEY_VOICE_SPEED, NULL);
+if (value) {
+ _voice_speed = gconf_value_get_int(value);
+ gconf_value_free(value);
+} else {
+ _voice_speed = 120;
+}
+BOUND(_voice_speed, 80, 370);
- /* Get Voice Speed - Default is 50. */
- value = gconf_client_get(gconf_client, GCONF_KEY_VOICE_PITCH, NULL);
- if (value) {
- _voice_pitch = gconf_value_get_int(value);
- gconf_value_free(value);
- } else {
- _voice_pitch = 50;
- }
- if (_voice_pitch<1 || _voice_pitch>99)
- _voice_pitch = 50;
-
- /* Get Always Keep On flag. Default is FALSE. */
- _always_keep_on = gconf_client_get_bool(gconf_client,GCONF_KEY_ALWAYS_KEEP_ON, NULL);
-
- _gps_filter = gconf_client_get_bool(gconf_client, GCONF_KEY_GPS_FILTER, NULL);
- _filter_hdop = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_HDOP, NULL);
- _filter_vdop = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_VDOP, NULL);
- _filter_angle = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_ANGLE, NULL);
- _filter_osm = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_OSM, NULL);
-
- /* Get Units. Default is UNITS_KM. */
- {
- gchar *units_str = gconf_client_get_string(gconf_client, GCONF_KEY_UNITS, NULL);
- guint i = 0;
- if (units_str)
- for (i = UNITS_ENUM_COUNT - 1; i > 0; i--)
- if (!strcmp(units_str, UNITS_TEXT[i]))
- break;
- _units = i;
- }
+/* Get Voice Speed - Default is 50. */
+value = gconf_client_get(gconf_client, GCONF_KEY_VOICE_PITCH, NULL);
+if (value) {
+ _voice_pitch = gconf_value_get_int(value);
+ gconf_value_free(value);
+} else {
+ _voice_pitch = 50;
+}
+BOUND(_voice_pitch, 10, 99);
- /* Get Custom Key Actions. */
- {
- gint i;
- for (i = 0; i < CUSTOM_KEY_ENUM_COUNT; i++) {
- gint j = CUSTOM_KEY_DEFAULT[i];
- gchar *str = gconf_client_get_string(gconf_client, CUSTOM_KEY_GCONF[i], NULL);
- if (str)
- for (j = CUSTOM_ACTION_ENUM_COUNT - 1; j > 0; j--)
- if (!strcmp(str, CUSTOM_ACTION_TEXT[j]))
- break;
- _action[i] = j;
- }
- }
+/* Get Always Keep On flag. Default is FALSE. */
+_always_keep_on = gconf_client_get_bool(gconf_client,GCONF_KEY_ALWAYS_KEEP_ON, NULL);
- /* Get Deg format. Default is DDPDDDDD. */
- {
- gchar *degformat_key_str = gconf_client_get_string(gconf_client,
- GCONF_KEY_DEG_FORMAT,
- NULL);
- guint i = 0;
- if (degformat_key_str)
- for (i = DEG_FORMAT_ENUM_COUNT - 1; i > 0; i--)
- if (!strcmp
- (degformat_key_str, DEG_FORMAT_TEXT[i]))
- break;
- _degformat = i;
- }
+_gps_filter = gconf_client_get_bool(gconf_client, GCONF_KEY_GPS_FILTER, NULL);
+_filter_hdop = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_HDOP, NULL);
+_filter_vdop = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_VDOP, NULL);
+_filter_angle = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_ANGLE, NULL);
+_filter_osm = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_OSM, NULL);
- /* Get Speed Limit On flag. Default is FALSE. */
- _speed_limit_on = gconf_client_get_bool(gconf_client,
- GCONF_KEY_SPEED_LIMIT_ON, NULL);
-
- /* Get Speed Limit */
- _speed_limit = gconf_client_get_int(gconf_client, GCONF_KEY_SPEED_LIMIT, NULL);
- if (_speed_limit <= 0)
- _speed_limit = 100;
-
- /* Get Speed Location. Default is SPEED_LOCATION_TOP_LEFT. */
- {
- gchar *speed_location_str = gconf_client_get_string(gconf_client,
- GCONF_KEY_SPEED_LOCATION, NULL);
- guint i = 0;
- if (speed_location_str)
- for (i = SPEED_LOCATION_ENUM_COUNT - 1; i > 0; i--)
- if (!strcmp
- (speed_location_str,
- SPEED_LOCATION_TEXT[i]))
- break;
- _speed_location = i;
- }
+/* Get Units. Default is UNITS_KM. */
+{
+ gchar *units_str = gconf_client_get_string(gconf_client, GCONF_KEY_UNITS, NULL);
+ guint i = 0;
+ if (units_str)
+ for (i = UNITS_ENUM_COUNT - 1; i > 0; i--)
+ if (!strcmp(units_str, UNITS_TEXT[i]))
+ break;
+ _units = i;
+}
- /* Get Info Font Size. Default is INFO_FONT_MEDIUM. */
- {
- gchar *info_font_size_str =
- gconf_client_get_string(gconf_client,
- GCONF_KEY_INFO_FONT_SIZE, NULL);
- guint i = -1;
- if (info_font_size_str)
- for (i = INFO_FONT_ENUM_COUNT - 1; i >= 0; i--)
- if (!strcmp
- (info_font_size_str, INFO_FONT_TEXT[i]))
+ /* Get Custom Key Actions. */
+{
+ gint i;
+ for (i = 0; i < CUSTOM_KEY_ENUM_COUNT; i++) {
+ gint j = CUSTOM_KEY_DEFAULT[i];
+ gchar *str = gconf_client_get_string(gconf_client, CUSTOM_KEY_GCONF[i], NULL);
+ if (str)
+ for (j = CUSTOM_ACTION_ENUM_COUNT - 1; j > 0; j--)
+ if (!strcmp(str, CUSTOM_ACTION_TEXT[j]))
break;
- if (i == -1)
- i = INFO_FONT_MEDIUM;
- _info_font_size = i;
+ _action[i] = j;
}
+}
+
+/* Get Deg format. Default is DDPDDDDD. */
+{
+ gchar *degformat_key_str = gconf_client_get_string(gconf_client,
+ GCONF_KEY_DEG_FORMAT,
+ NULL);
+ guint i = 0;
+ if (degformat_key_str)
+ for (i = DEG_FORMAT_ENUM_COUNT - 1; i > 0; i--)
+ if (!strcmp(degformat_key_str, DEG_FORMAT_TEXT[i]))
+ break;
+ _degformat = i;
+}
- /* Get Auto-Download. Default is FALSE. */
- _auto_download = gconf_client_get_bool(gconf_client, GCONF_KEY_AUTO_DOWNLOAD, NULL);
+/* Get Speed Limit On flag. Default is FALSE. */
+_speed_limit_on = gconf_client_get_bool(gconf_client, GCONF_KEY_SPEED_LIMIT_ON, NULL);
- /* Get saved location */
- _gps.lat = gconf_client_get_float(gconf_client, GCONF_KEY_LAT, NULL);
- _gps.lon = gconf_client_get_float(gconf_client, GCONF_KEY_LON, NULL);
- if (_gps.lat==0.0) _gps.lat=64.0;
- if (_gps.lon==0.0) _gps.lon=22.0;
+/* Get Speed Limit */
+_speed_limit = gconf_client_get_int(gconf_client, GCONF_KEY_SPEED_LIMIT, NULL);
+BOUND(_speed_limit, 1, 200);
- /* Home */
+/* Get Speed Location. Default is SPEED_LOCATION_TOP_LEFT. */
+{
+ gchar *speed_location_str = gconf_client_get_string(gconf_client,
+ GCONF_KEY_SPEED_LOCATION, NULL);
+ guint i = 0;
+ if (speed_location_str)
+ for (i = SPEED_LOCATION_ENUM_COUNT - 1; i > 0; i--)
+ if (!strcmp(speed_location_str, SPEED_LOCATION_TEXT[i]))
+ break;
+ _speed_location = i;
+}
+
+/* Get Info Font Size. Default is INFO_FONT_MEDIUM. */
+{
+ gchar *info_font_size_str = gconf_client_get_string(gconf_client, GCONF_KEY_INFO_FONT_SIZE, NULL);
+ guint i = -1;
+ if (info_font_size_str)
+ for (i = INFO_FONT_ENUM_COUNT - 1; i >= 0; i--)
+ if (!strcmp(info_font_size_str, INFO_FONT_TEXT[i]))
+ break;
+ if (i == -1)
+ i = INFO_FONT_MEDIUM;
+ _info_font_size = i;
+}
+
+/* Get Auto-Download. Default is FALSE. */
+_auto_download = gconf_client_get_bool(gconf_client, GCONF_KEY_AUTO_DOWNLOAD, NULL);
+
+/* Get saved location */
+_gps.lat = gconf_client_get_float(gconf_client, GCONF_KEY_LAT, NULL);
+_gps.lon = gconf_client_get_float(gconf_client, GCONF_KEY_LON, NULL);
+if (_gps.lat==0.0) _gps.lat=64.0;
+if (_gps.lon==0.0) _gps.lon=22.0;
+
+/* Home */
+_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;
- value = gconf_client_get(gconf_client, GCONF_KEY_HOME_LAT, NULL);
+}
+
+/* Get last center point. */
+{
+ gfloat center_lat, center_lon;
+
+ /* Get last saved latitude. Default is last saved latitude. */
+ value = gconf_client_get(gconf_client, GCONF_KEY_CENTER_LAT, NULL);
if (value) {
- _home.lat = gconf_value_get_float(value);
+ center_lat = gconf_value_get_float(value);
gconf_value_free(value);
} else {
- _home.valid=FALSE;
+ center_lat = _gps.lat;
}
- value = gconf_client_get(gconf_client, GCONF_KEY_HOME_LON, NULL);
+ /* Get last saved longitude. Default is last saved longitude. */
+ value = gconf_client_get(gconf_client, GCONF_KEY_CENTER_LON, NULL);
if (value) {
- _home.lon = gconf_value_get_float(value);
+ center_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;
+ center_lon = _gps.lon;
}
- /* Get last center point. */
- {
- gfloat center_lat, center_lon;
-
- /* Get last saved latitude. Default is last saved latitude. */
- value = gconf_client_get(gconf_client, GCONF_KEY_CENTER_LAT, NULL);
- if (value) {
- center_lat = gconf_value_get_float(value);
- gconf_value_free(value);
- } else
- center_lat = _gps.lat;
-
- /* Get last saved longitude. Default is last saved longitude. */
- value = gconf_client_get(gconf_client, GCONF_KEY_CENTER_LON, NULL);
- if (value) {
- center_lon = gconf_value_get_float(value);
- gconf_value_free(value);
- } else
- center_lon = _gps.lon;
-
- latlon2unit(center_lat, center_lon, _center.unitx, _center.unity);
- }
+ latlon2unit(center_lat, center_lon, _center.unitx, _center.unity);
+}
config_load_repo();
_show_poi = TRUE;
}
-/* Get Enable GPS flag. Default is TRUE. */
+/* Get Enable GPS flag. Default is FALSE. */
value = gconf_client_get(gconf_client, GCONF_KEY_ENABLE_GPS, NULL);
if (value) {
_enable_gps = gconf_value_get_bool(value);
gconf_value_free(value);
} else {
- _enable_gps = TRUE;
+ _enable_gps = FALSE;
}
/* Initialize _conn_state based on _enable_gps. */
_conn_state = (_enable_gps ? RCVR_DOWN : RCVR_OFF);
- /* Load the route locations. */
- {
- GSList *curr;
- _loc_list = gconf_client_get_list(gconf_client,
- GCONF_KEY_ROUTE_LOCATIONS,
- GCONF_VALUE_STRING, NULL);
- _loc_model = gtk_list_store_new(1, G_TYPE_STRING);
- for (curr = _loc_list; curr != NULL; curr = curr->next) {
- GtkTreeIter iter;
- gtk_list_store_insert_with_values(_loc_model, &iter,
- INT_MAX, 0,
- curr->data, -1);
- }
- }
-
- /* Get Mapper Database. Default is in REPO_DEFAULT_CACHE_BASE */
- _mapper_db = gconf_client_get_string(gconf_client, GCONF_KEY_MAPPER_DB, NULL);
- if (_mapper_db == NULL) {
- gchar *poi_base = gnome_vfs_expand_initial_tilde(REPO_DEFAULT_CACHE_BASE);
- _mapper_db = gnome_vfs_uri_make_full_from_relative(poi_base, "poi.db");
- g_free(poi_base);
+/* Load the route locations. */
+{
+ GSList *curr;
+ _loc_list = gconf_client_get_list(gconf_client,
+ GCONF_KEY_ROUTE_LOCATIONS,
+ GCONF_VALUE_STRING, NULL);
+ _loc_model = gtk_list_store_new(1, G_TYPE_STRING);
+ for (curr = _loc_list; curr != NULL; curr = curr->next) {
+ GtkTreeIter iter;
+ gtk_list_store_insert_with_values(_loc_model, &iter,
+ INT_MAX, 0,
+ curr->data, -1);
}
+}
-mapper_db_connect(&_db, _mapper_db);
+/* Get Mapper Database. Default is in REPO_DEFAULT_CACHE_BASE */
+_mapper_db = gconf_client_get_string(gconf_client, GCONF_KEY_MAPPER_DB, NULL);
+if (_mapper_db == NULL) {
+ gchar *poi_base = gnome_vfs_expand_initial_tilde(REPO_DEFAULT_CACHE_BASE);
+ _mapper_db = gnome_vfs_uri_make_full_from_relative(poi_base, "poi.db");
+ g_free(poi_base);
+}
_poi_zoom = gconf_client_get_int(gconf_client, GCONF_KEY_POI_ZOOM, NULL);
if (!_poi_zoom)
_poi_zoom = 6;
-/* Get GPS Info flag. Default is FALSE. */
+/* Get GPS Info flag. Default is FALSE. */
value = gconf_client_get(gconf_client, GCONF_KEY_GPS_INFO, NULL);
if (value) {
_gps_info = gconf_value_get_bool(value);
}
/* Get Colors. */
-{
- gint i;
- for (i = 0; i < COLORABLE_ENUM_COUNT; i++) {
- str = gconf_client_get_string(gconf_client, COLORABLE_GCONF[i], NULL);
- if (!str || !gdk_color_parse(str, &_color[i]))
- _color[i] = COLORABLE_DEFAULT[i];
- }
+for (i = 0; i < COLORABLE_ENUM_COUNT; i++) {
+ str = gconf_client_get_string(gconf_client, COLORABLE_GCONF[i], NULL);
+ if (!str || !gdk_color_parse(str, &_color[i]))
+ _color[i] = COLORABLE_DEFAULT[i];
}
/* Get current proxy settings. */
config_update_proxy();
+/* Connect to db */
+mapper_db_connect(&_db, _mapper_db);
+
gconf_client_clear_cache(gconf_client);
g_object_unref(gconf_client);
g_free(config_dir);