From e243bb0d2e54306667a36f41f2d01d2e071070f1 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Wed, 13 Jun 2007 13:35:24 +0300 Subject: [PATCH] Cleanups. Add simple gps track point filtering with hdop, vdop and minimum heading change. --- src/config.c | 338 +++++++++++++++++++++---------------------- src/gps-nmea-parse.c | 27 +++- src/gps.h | 5 +- src/map-repo.c | 3 +- src/mapper.c | 3 +- src/poi.c | 11 ++ src/settings-gconf.h | 55 +++++-- src/settings-gui.c | 160 ++++++++++---------- src/settings.h | 56 +++---- src/ui-common.c | 16 +- src/ui-common.h | 1 + src/utils.h | 17 +-- 12 files changed, 375 insertions(+), 317 deletions(-) diff --git a/src/config.c b/src/config.c index c237a34..57570a6 100644 --- a/src/config.c +++ b/src/config.c @@ -7,10 +7,11 @@ #include #include #include -#include #include #include #include +#include +#include #include #include #include @@ -30,31 +31,29 @@ void config_update_proxy() { -#ifdef WITH_HILDON GConfClient *gconf_client = gconf_client_get_default(); printf("%s()\n", __PRETTY_FUNCTION__); - if (_iap_http_proxy_host) - g_free(_iap_http_proxy_host); + 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. */ - _iap_http_proxy_host = gconf_client_get_string(gconf_client, + _http_proxy_host = gconf_client_get_string(gconf_client, GCONF_KEY_HTTP_PROXY_HOST, NULL); - _iap_http_proxy_port = + _http_proxy_port = gconf_client_get_int(gconf_client, GCONF_KEY_HTTP_PROXY_PORT, NULL); } else { /* HTTP Proxy is off. */ - _iap_http_proxy_host = NULL; - _iap_http_proxy_port = 0; + _http_proxy_host = NULL; + _http_proxy_port = 0; } g_object_unref(gconf_client); vprintf("%s(): return\n", __PRETTY_FUNCTION__); -#endif } static void config_save_track(gchar *config_dir) @@ -83,22 +82,125 @@ if (GNOME_VFS_OK == gnome_vfs_create(&handle, route_file, GNOME_VFS_OPEN_WRITE, g_free(route_file); } +gboolean +config_save_repo() +{ +GConfClient *gconf_client = gconf_client_get_default(); +GList *curr = _repo_list; +GSList *temp_list = NULL; +gint curr_repo_index = 0; + +if (!gconf_client) + return FALSE; + +/* Save the repositories. */ +for (curr = _repo_list; curr != NULL; curr = curr->next) { + /* Build from each part of a repo, delimited by newline characters: + * 1. url + * 2. cache_dir + * 3. dl_zoom_steps + * 4. view_zoom_steps + */ + RepoData *rd = curr->data; + gchar buffer[BUFFER_SIZE]; + snprintf(buffer, sizeof(buffer), + "%s\t%s\t%s\t%d\t%d\t%d\t%d", + rd->name, + rd->url, + rd->cache_dir, + rd->dl_zoom_steps, + rd->view_zoom_steps, + rd->double_size, rd->nextable); + temp_list = g_slist_append(temp_list, g_strdup(buffer)); + if (rd == _curr_repo) + gconf_client_set_int(gconf_client, + GCONF_KEY_CURRREPO, curr_repo_index, NULL); + curr_repo_index++; +} +gconf_client_set_list(gconf_client, + GCONF_KEY_REPOSITORIES, + GCONF_VALUE_STRING, temp_list, NULL); +} + +gboolean +config_load_repo() +{ +GSList *list, *curr; +GConfValue *value; +GConfClient *gconf_client = gconf_client_get_default(); + +if (!gconf_client) + return FALSE; + +guint curr_repo_index = gconf_client_get_int(gconf_client, + GCONF_KEY_CURRREPO, + NULL); +list = gconf_client_get_list(gconf_client, GCONF_KEY_REPOSITORIES, GCONF_VALUE_STRING, NULL); + +for (curr = list; curr != NULL; curr = curr->next) { + RepoData *rd = config_parse_repo(curr->data); + _repo_list = g_list_append(_repo_list, rd); + if (!curr_repo_index--) + repo_set_curr(rd); + g_free(curr->data); +} +g_slist_free(list); + +if (_repo_list == NULL) { + /* We have no repositories - create a default one. */ + RepoData *repo = g_new(RepoData, 1); + + /* Many fields can be retrieved from the "old" gconf keys. */ + + /* 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); + + 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); + 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); + if (!repo->dl_zoom_steps) + repo->dl_zoom_steps = REPO_DEFAULT_DL_ZOOM_STEPS; + + /* Other fields are brand new. */ + repo->name = g_strdup(REPO_DEFAULT_NAME); + repo->view_zoom_steps = REPO_DEFAULT_VIEW_ZOOM_STEPS; + repo->double_size = FALSE; + repo->nextable = TRUE; + set_repo_type(repo); + + _repo_list = g_list_append(_repo_list, repo); + repo_set_curr(repo); +} + +return TRUE; +} + /** * Save all configuration data to GCONF. */ -void config_save() +gboolean +config_save() { gchar *config_dir; GConfClient *gconf_client = gconf_client_get_default(); gchar buffer[16]; printf("%s()\n", __PRETTY_FUNCTION__); - if (!gconf_client) { - popup_error(_window, - _ - ("Failed to initialize GConf. Settings were not saved.")); - return; - } + if (!gconf_client) + return FALSE; /* Initialize config_dir. */ config_dir = gnome_vfs_expand_initial_tilde(CONFIG_DIR_NAME); @@ -106,8 +208,7 @@ void config_save() /* Save Receiver MAC from GConf. */ if (_rcvr_mac) - gconf_client_set_string(gconf_client, - GCONF_KEY_RCVR_MAC, _rcvr_mac, NULL); + gconf_client_set_string(gconf_client, GCONF_KEY_RCVR_MAC, _rcvr_mac, NULL); else gconf_client_unset(gconf_client, GCONF_KEY_RCVR_MAC, NULL); @@ -207,41 +308,6 @@ void config_save() GCONF_KEY_ROUTEDIR, _route_dir_uri, NULL); - /* Save the repositories. */ - { - GList *curr = _repo_list; - GSList *temp_list = NULL; - gint curr_repo_index = 0; - - for (curr = _repo_list; curr != NULL; curr = curr->next) { - /* Build from each part of a repo, delimited by newline characters: - * 1. url - * 2. cache_dir - * 3. dl_zoom_steps - * 4. view_zoom_steps - */ - RepoData *rd = curr->data; - gchar buffer[BUFFER_SIZE]; - snprintf(buffer, sizeof(buffer), - "%s\t%s\t%s\t%d\t%d\t%d\t%d", - rd->name, - rd->url, - rd->cache_dir, - rd->dl_zoom_steps, - rd->view_zoom_steps, - rd->double_size, rd->nextable); - temp_list = g_slist_append(temp_list, g_strdup(buffer)); - if (rd == _curr_repo) - gconf_client_set_int(gconf_client, - GCONF_KEY_CURRREPO, - curr_repo_index, NULL); - curr_repo_index++; - } - gconf_client_set_list(gconf_client, - GCONF_KEY_REPOSITORIES, - GCONF_VALUE_STRING, temp_list, NULL); - } - /* Save Last Track File. */ if (_track_file_uri) gconf_client_set_string(gconf_client, @@ -262,38 +328,34 @@ void config_save() NULL); /* Save Show Routes flag. */ - gconf_client_set_bool(gconf_client, - GCONF_KEY_SHOWROUTES, _show_tracks & ROUTES_MASK, - NULL); + 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); + 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); + 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); + gconf_client_set_bool(gconf_client, GCONF_KEY_ENABLE_GPS, _enable_gps, NULL); + + /* Filtering */ + gconf_client_set_bool(gconf_client, GCONF_KEY_GPS_FILTER, _gps_filter, NULL); + gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_HDOP, _filter_hdop, NULL); + gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_VDOP, _filter_vdop, NULL); + gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_ANGLE, _filter_angle, NULL); /* Save Route Locations. */ - gconf_client_set_list(gconf_client, - GCONF_KEY_ROUTE_LOCATIONS, GCONF_VALUE_STRING, - _loc_list, NULL); + 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); + 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); + 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); + gconf_client_set_int(gconf_client, GCONF_KEY_ROUTE_DL_RADIUS, _route_dl_radius, NULL); /* Save Colors. */ { @@ -310,15 +372,13 @@ void config_save() /* Save POI database. */ if (_poi_db) - gconf_client_set_string(gconf_client, - GCONF_KEY_POI_DB, _poi_db, NULL); + gconf_client_set_string(gconf_client, GCONF_KEY_POI_DB, _poi_db, NULL); else gconf_client_unset(gconf_client, GCONF_KEY_POI_DB, NULL); /* Save Show POI below zoom. */ gconf_client_set_int(gconf_client, GCONF_KEY_POI_ZOOM, _poi_zoom, NULL); - config_save_track(config_dir); config_save_route(config_dir); @@ -327,6 +387,8 @@ void config_save() g_free(config_dir); vprintf("%s(): return\n", __PRETTY_FUNCTION__); + + return TRUE; } /** @@ -363,11 +425,8 @@ void config_init() 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)) + 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); } @@ -378,25 +437,17 @@ void config_init() gchar *bytes; gint size; - 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)) + 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); } /* Get Receiver MAC from GConf. Default is scanned via hci_inquiry. */ - { - _rcvr_mac = - gconf_client_get_string(gconf_client, GCONF_KEY_RCVR_MAC, - NULL); - } + _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); + _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, @@ -411,11 +462,10 @@ void config_init() if (!_lead_ratio) _lead_ratio = 5; - /* Get Draw Line Width- Default is 5. */ - _draw_width = gconf_client_get_int(gconf_client, - GCONF_KEY_DRAW_WIDTH, NULL); + /* 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 = 5; + _draw_width = 4; /* Get Announce Advance Notice - Default is 30. */ value = gconf_client_get(gconf_client, GCONF_KEY_ANNOUNCE_NOTICE, NULL); @@ -438,20 +488,26 @@ void config_init() if (value) { _voice_speed = gconf_value_get_float(value); gconf_value_free(value); - } else + } else { _voice_speed = 1.0; + } /* Get Voice Speed - Default is 0. */ 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 + } else { _voice_pitch = 3; + } /* Get Always Keep On flag. Default is FALSE. */ - _always_keep_on = gconf_client_get_bool(gconf_client, - GCONF_KEY_ALWAYS_KEEP_ON, NULL); + _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_floatt(gconf_client, GCONF_KEY_GPS_FILTER_ANGLE, NULL); /* Get Units. Default is UNITS_KM. */ { @@ -538,25 +594,21 @@ void config_init() _info_font_size = i; } - /* Get last saved latitude. Default is 50.f. */ - value = gconf_client_get(gconf_client, GCONF_KEY_LAT, NULL); - if (value) { - _gps.lat = gconf_value_get_float(value); - gconf_value_free(value); - } else - _gps.lat = 50.f; + /* Get Auto-Download. Default is FALSE. */ + _auto_download = gconf_client_get_bool(gconf_client, GCONF_KEY_AUTO_DOWNLOAD, NULL); - /* Get last saved longitude. Default is 0. */ - value = gconf_client_get(gconf_client, GCONF_KEY_LON, 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=24.0; /* 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); + value = gconf_client_get(gconf_client, GCONF_KEY_CENTER_LAT, NULL); if (value) { center_lat = gconf_value_get_float(value); gconf_value_free(value); @@ -564,77 +616,17 @@ void config_init() center_lat = _gps.lat; /* Get last saved longitude. Default is last saved longitude. */ - value = - gconf_client_get(gconf_client, GCONF_KEY_CENTER_LON, NULL); + 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); } - /* Load the repositories. */ - { - GSList *list, *curr; - guint curr_repo_index = gconf_client_get_int(gconf_client, - GCONF_KEY_CURRREPO, - NULL); - list = - gconf_client_get_list(gconf_client, GCONF_KEY_REPOSITORIES, - GCONF_VALUE_STRING, NULL); - - for (curr = list; curr != NULL; curr = curr->next) { - RepoData *rd = config_parse_repo(curr->data); - _repo_list = g_list_append(_repo_list, rd); - if (!curr_repo_index--) - repo_set_curr(rd); - g_free(curr->data); - } - g_slist_free(list); - } - - if (_repo_list == NULL) { - /* We have no repositories - create a default one. */ - RepoData *repo = g_new(RepoData, 1); - - /* Many fields can be retrieved from the "old" gconf keys. */ - - /* 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); - 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); - 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); - if (!repo->dl_zoom_steps) - repo->dl_zoom_steps = REPO_DEFAULT_DL_ZOOM_STEPS; - - /* Other fields are brand new. */ - repo->name = g_strdup(REPO_DEFAULT_NAME); - repo->view_zoom_steps = REPO_DEFAULT_VIEW_ZOOM_STEPS; - repo->double_size = FALSE; - repo->nextable = TRUE; - set_repo_type(repo); - - _repo_list = g_list_append(_repo_list, repo); - repo_set_curr(repo); - } + config_load_repo(); /* Get last Zoom Level. Default is 12. */ value = gconf_client_get(gconf_client, GCONF_KEY_ZOOM, NULL); diff --git a/src/gps-nmea-parse.c b/src/gps-nmea-parse.c index fda4ff5..e3dfbca 100644 --- a/src/gps-nmea-parse.c +++ b/src/gps-nmea-parse.c @@ -152,12 +152,27 @@ void channel_parse_rmc(gchar * sentence) _pos.time = time(NULL); /* Add new data to track only if we have a fix */ - if (_conn_state == RCVR_FIXED) { - /* Translate data into integers. */ - integerize_data(_vel_offsetx, _vel_offsety, _pos, _gps); - track_add(_pos.time, newly_fixed); - /* Move mark to new location. */ - refresh_mark(); + _track_store=TRUE; + + if ((_conn_state == RCVR_FIXED) && (_track_store==TRUE)) { + if (_gps_filter==TRUE) { + integerize_data(_vel_offsetx, _vel_offsety, _pos, _gps); + if ( (_gps.hdop<(_filter_hdop/4.0)+2.0 || _filter_hdop==0.0) && + (_gps.vdop<(_filter_vdop/4.0)+2.0 || _filter_vdop==0.0) && + (fabs(_gps.heading-_gps.lheading)>_filter_angle || _filter_angle==0.0 ) ) { + track_add(_pos.time, newly_fixed); + _gps.lheading=_gps.heading; + } else { + g_printf("*** Droping: H:%f V:%f A:%f (%f %f %f)\n", + _gps.hdop, _gps.vdop, abs(_gps.heading-_gps.lheading), + _filter_hdop, _filter_vdop, _filter_angle); + } + refresh_mark(); + } else { + integerize_data(_vel_offsetx, _vel_offsety, _pos, _gps); + track_add(_pos.time, newly_fixed); + refresh_mark(); + } } vprintf("%s(): return\n", __PRETTY_FUNCTION__); diff --git a/src/gps.h b/src/gps.h index 5dec5c3..3642526 100644 --- a/src/gps.h +++ b/src/gps.h @@ -30,10 +30,12 @@ struct _GpsData { gfloat lon; gfloat speed; /* in knots */ gfloat maxspeed; /* in knots */ + gfloat avgspeed; /* -- "" -- */ gfloat heading; + gfloat lheading; gfloat hdop; - gfloat pdop; gfloat vdop; + gfloat pdop; guint satinview; guint satinuse; guint satforfix[12]; @@ -66,6 +68,7 @@ guint _connect_sid; guint _error_sid; /** The Source ID of the input watch. */ guint _input_sid; + /** The Source ID of the "Connect Later" idle. */ guint _clater_sid; /** The Source ID of the CURL Multi Download timeout. */ diff --git a/src/map-repo.c b/src/map-repo.c index 612c531..fb0fa44 100644 --- a/src/map-repo.c +++ b/src/map-repo.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -777,7 +778,7 @@ gboolean repoman_dialog() data); menu_maps_add_repos(); - config_save(); + config_save_repo(); break; } diff --git a/src/mapper.c b/src/mapper.c index e605a4b..a77ded4 100644 --- a/src/mapper.c +++ b/src/mapper.c @@ -69,10 +69,10 @@ #include "utils.h" #include "poi.h" #include "route.h" +#include "mapper-types.h" #include "settings.h" #include "gps.h" #include "map.h" -#include "mapper-types.h" #include "bt.h" #include "ui-common.h" #include "cb.h" @@ -170,6 +170,7 @@ void mapper_destroy(void) _curl_sid = 0; } config_save(); + config_save_repo(); rcvr_disconnect(); /* _program and widgets have already been destroyed. */ diff --git a/src/poi.c b/src/poi.c index 94517c2..3fc610d 100644 --- a/src/poi.c +++ b/src/poi.c @@ -216,6 +216,17 @@ poi_db_prepare(sqlite3 *db) return TRUE; } +gboolean +poi_db_disconnect(sqlite3 **db) +{ +if (db && *db) { + /* XXX: Handle prepared statements */ + sqlite3_close(*db); + return TRUE; +} +return FALSE; +} + gboolean poi_db_connect(sqlite3 **db, const gchar *poi_db) { diff --git a/src/settings-gconf.h b/src/settings-gconf.h index 85015c6..eb19833 100644 --- a/src/settings-gconf.h +++ b/src/settings-gconf.h @@ -1,7 +1,8 @@ -#define CONFIG_DIR_NAME "~/.maemo-mapper/" +#define CONFIG_DIR_NAME "~/.mapper/" #define CONFIG_FILE_ROUTE "route.gpx" #define CONFIG_FILE_TRACK "track.gpx" +/* Default OSM Repository */ #define REPO_DEFAULT_NAME "OpenStreet" #define REPO_DEFAULT_CACHE_BASE "~/MyDocs/.documents/Maps/" #define REPO_DEFAULT_CACHE_DIR REPO_DEFAULT_CACHE_BASE"OpenStreet" @@ -9,8 +10,6 @@ #define REPO_DEFAULT_DL_ZOOM_STEPS (2) #define REPO_DEFAULT_VIEW_ZOOM_STEPS (1) -#define XML_DATE_FORMAT "%FT%T" - #define HELP_ID_PREFIX "help_maemomapper_" #define HELP_ID_INTRO HELP_ID_PREFIX"intro" #define HELP_ID_GETSTARTED HELP_ID_PREFIX"getstarted" @@ -21,26 +20,46 @@ #define HELP_ID_DOWNROUTE HELP_ID_PREFIX"downroute" #define HELP_ID_POICAT HELP_ID_PREFIX"poicat" -#define GCONF_KEY_PREFIX "/apps/maemo/maemo-mapper" +#define GCONF_KEY_PREFIX "/apps/maemo/mapper" + +/* GPS */ #define GCONF_KEY_RCVR_MAC GCONF_KEY_PREFIX"/receiver_mac" #define GCONF_KEY_RCVR_CHAN GCONF_KEY_PREFIX"/receiver_channel" +#define GCONF_KEY_ENABLE_GPS GCONF_KEY_PREFIX"/enable_gps" +#define GCONF_KEY_GPS_INFO GCONF_KEY_PREFIX"/gps_info" + +/* Track filtering */ +#define GCONF_KEY_GPS_FILTER GCONF_KEY_PREFIX"/gps_filter" +#define GCONF_KEY_GPS_FILTER_HDOP GCONF_KEY_PREFIX"/gps_filter_hdop" +#define GCONF_KEY_GPS_FILTER_VDOP GCONF_KEY_PREFIX"/gps_filter_vdop" +#define GCONF_KEY_GPS_FILTER_ANGLE GCONF_KEY_PREFIX"/gps_filter_angle" + #define GCONF_KEY_MAP_URI_FORMAT GCONF_KEY_PREFIX"/map_uri_format" #define GCONF_KEY_MAP_ZOOM_STEPS GCONF_KEY_PREFIX"/map_zoom_steps" #define GCONF_KEY_MAP_DIR_NAME GCONF_KEY_PREFIX"/map_cache_dir" #define GCONF_KEY_AUTO_DOWNLOAD GCONF_KEY_PREFIX"/auto_download" +#define GCONF_KEY_REPOSITORIES GCONF_KEY_PREFIX"/repositories" +#define GCONF_KEY_CURRREPO GCONF_KEY_PREFIX"/curr_repo" #define GCONF_KEY_CENTER_SENSITIVITY GCONF_KEY_PREFIX"/center_sensitivity" -#define GCONF_KEY_ANNOUNCE_NOTICE GCONF_KEY_PREFIX"/announce_notice" + #define GCONF_KEY_DRAW_WIDTH GCONF_KEY_PREFIX"/draw_width" +#define GCONF_KEY_INFO_FONT_SIZE GCONF_KEY_PREFIX"/info_font_size" + +/* Voice */ #define GCONF_KEY_ENABLE_VOICE GCONF_KEY_PREFIX"/enable_voice" #define GCONF_KEY_VOICE_SPEED GCONF_KEY_PREFIX"/voice_speed" #define GCONF_KEY_VOICE_PITCH GCONF_KEY_PREFIX"/voice_pitch" +#define GCONF_KEY_ANNOUNCE_NOTICE GCONF_KEY_PREFIX"/announce_notice" + #define GCONF_KEY_ALWAYS_KEEP_ON GCONF_KEY_PREFIX"/always_keep_on" #define GCONF_KEY_UNITS GCONF_KEY_PREFIX"/units" + +/* Speed display */ #define GCONF_KEY_SPEED_LIMIT_ON GCONF_KEY_PREFIX"/speed_limit_on" #define GCONF_KEY_SPEED_LIMIT GCONF_KEY_PREFIX"/speed_limit" #define GCONF_KEY_SPEED_LOCATION GCONF_KEY_PREFIX"/speed_location" -#define GCONF_KEY_INFO_FONT_SIZE GCONF_KEY_PREFIX"/info_font_size" +/* POI */ #define GCONF_KEY_POI_DB GCONF_KEY_PREFIX"/poi_db" #define GCONF_KEY_POI_ZOOM GCONF_KEY_PREFIX"/poi_zoom" @@ -51,26 +70,32 @@ #define GCONF_KEY_CENTER_LAT GCONF_KEY_PREFIX"/center_latitude" #define GCONF_KEY_CENTER_LON GCONF_KEY_PREFIX"/center_longitude" #define GCONF_KEY_ZOOM GCONF_KEY_PREFIX"/zoom" -#define GCONF_KEY_ROUTEDIR GCONF_KEY_PREFIX"/route_directory" -#define GCONF_KEY_TRACKFILE GCONF_KEY_PREFIX"/track_file" + +/* Display features */ #define GCONF_KEY_SHOWSCALE GCONF_KEY_PREFIX"/show_scale" #define GCONF_KEY_SHOWTRACKS GCONF_KEY_PREFIX"/show_tracks" #define GCONF_KEY_SHOWROUTES GCONF_KEY_PREFIX"/show_routes" #define GCONF_KEY_SHOWVELVEC GCONF_KEY_PREFIX"/show_velocity_vector" #define GCONF_KEY_SHOWPOIS GCONF_KEY_PREFIX"/show_poi" -#define GCONF_KEY_ENABLE_GPS GCONF_KEY_PREFIX"/enable_gps" + +/* Route */ #define GCONF_KEY_ROUTE_LOCATIONS GCONF_KEY_PREFIX"/route_locations" -#define GCONF_KEY_REPOSITORIES GCONF_KEY_PREFIX"/repositories" -#define GCONF_KEY_CURRREPO GCONF_KEY_PREFIX"/curr_repo" -#define GCONF_KEY_GPS_INFO GCONF_KEY_PREFIX"/gps_info" +#define GCONF_KEY_ROUTEDIR GCONF_KEY_PREFIX"/route_directory" #define GCONF_KEY_ROUTE_DL_URL GCONF_KEY_PREFIX"/route_dl_url" #define GCONF_KEY_ROUTE_DL_RADIUS GCONF_KEY_PREFIX"/route_dl_radius" -#define GCONF_KEY_DEG_FORMAT GCONF_KEY_PREFIX"/deg_format" -#define GCONF_KEY_DISCONNECT_ON_COVER \ - "/system/osso/connectivity/IAP/disconnect_on_cover" +#define GCONF_KEY_TRACKFILE GCONF_KEY_PREFIX"/track_file" +#define GCONF_KEY_DEG_FORMAT GCONF_KEY_PREFIX"/deg_format" +/* Proxy */ #define GCONF_KEY_HTTP_PROXY_PREFIX "/system/http_proxy" #define GCONF_KEY_HTTP_PROXY_ON GCONF_KEY_HTTP_PROXY_PREFIX"/use_http_proxy" #define GCONF_KEY_HTTP_PROXY_HOST GCONF_KEY_HTTP_PROXY_PREFIX"/host" #define GCONF_KEY_HTTP_PROXY_PORT GCONF_KEY_HTTP_PROXY_PREFIX"/port" + +/* Interface */ +#define GCONF_KEY_UI_TOOLBAR GCONF_KEY_PREFIX"/ui_show_toolbar" +#define GCONF_KEY_UI_FULLSCREEN GCONF_KEY_PREFIX"/ui_fullscreen" + +/* OSSO/IAP specific */ +#define GCONF_KEY_DISCONNECT_ON_COVER "/system/osso/connectivity/IAP/disconnect_on_cover" diff --git a/src/settings-gui.c b/src/settings-gui.c index 9662f24..fefb468 100644 --- a/src/settings-gui.c +++ b/src/settings-gui.c @@ -426,6 +426,11 @@ gboolean settings_dialog() GtkWidget *cmb_speed_location; GtkWidget *cmb_info_font_size; + GtkWidget *chk_gps_filter; + GtkWidget *num_angle; + GtkWidget *num_hdop_ratio; + GtkWidget *num_vdop_ratio; + BrowseInfo browse_info = { 0, 0 }; ScanInfo scan_info = { 0 }; gboolean rcvr_changed = FALSE; @@ -439,17 +444,14 @@ gboolean settings_dialog() #ifdef WITH_HILDON /* Enable the help button. */ - ossohelp_dialog_help_enable(GTK_DIALOG(dialog), HELP_ID_SETTINGS, - _osso); + ossohelp_dialog_help_enable(GTK_DIALOG(dialog), HELP_ID_SETTINGS, _osso); #endif gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), - btn_buttons = - gtk_button_new_with_label(_("Hardware Keys..."))); + btn_buttons = gtk_button_new_with_label(_("Hardware Keys..."))); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), - btn_colors = - gtk_button_new_with_label(_("Colors..."))); + btn_colors = gtk_button_new_with_label(_("Colors..."))); gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT); @@ -486,38 +488,64 @@ gboolean settings_dialog() gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); gtk_misc_set_alignment(GTK_MISC(label), 0.5f, 0.5f); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), + table = gtk_table_new(2, 4, FALSE), + label = gtk_label_new(_("Filter"))); + + gtk_table_attach(GTK_TABLE(table), + chk_gps_filter = gtk_check_button_new_with_label(_("Enable GPS track filter")), + 0, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_gps_filter), _gps_filter); + + gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Horizontal")), + 0, 1, 1, 2, GTK_FILL, 0, 2, 4); + gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); + gtk_table_attach(GTK_TABLE(table), num_hdop_ratio = hildon_controlbar_new(), + 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); + hildon_controlbar_set_range(HILDON_CONTROLBAR(num_hdop_ratio), 0, 200); + force_min_visible_bars(HILDON_CONTROLBAR(num_hdop_ratio), 1); + + gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Vertical")), + 0, 1, 2, 3, GTK_FILL, 0, 2, 4); + gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); + gtk_table_attach(GTK_TABLE(table), num_vdop_ratio = hildon_controlbar_new(), + 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 4); + hildon_controlbar_set_range(HILDON_CONTROLBAR(num_vdop_ratio), 0, 200); + force_min_visible_bars(HILDON_CONTROLBAR(num_vdop_ratio), 1); + + gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Angle")), + 0, 1, 3, 4, GTK_FILL, 0, 2, 4); + gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); + gtk_table_attach(GTK_TABLE(table), num_angle = hildon_controlbar_new(), + 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 2, 4); + hildon_controlbar_set_range(HILDON_CONTROLBAR(num_angle), 0, 45); + force_min_visible_bars(HILDON_CONTROLBAR(num_angle), 1); + /* Auto-Center page. */ gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table = gtk_table_new(2, 2, FALSE), label = gtk_label_new(_("Auto-Center"))); /* Auto-Center Sensitivity. */ - gtk_table_attach(GTK_TABLE(table), - label = gtk_label_new(_("Sensitivity")), + gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Sensitivity")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); - gtk_table_attach(GTK_TABLE(table), - label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), + gtk_table_attach(GTK_TABLE(table), num_center_ratio = hildon_controlbar_new(), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4); - gtk_container_add(GTK_CONTAINER(label), - num_center_ratio = hildon_controlbar_new()); hildon_controlbar_set_range(HILDON_CONTROLBAR(num_center_ratio), 1, 10); force_min_visible_bars(HILDON_CONTROLBAR(num_center_ratio), 1); /* Lead Amount. */ - gtk_table_attach(GTK_TABLE(table), - label = gtk_label_new(_("Lead Amount")), + gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Lead Amount")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); - gtk_table_attach(GTK_TABLE(table), - label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), + + gtk_table_attach(GTK_TABLE(table), num_lead_ratio = hildon_controlbar_new(), 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); - gtk_container_add(GTK_CONTAINER(label), - num_lead_ratio = hildon_controlbar_new()); hildon_controlbar_set_range(HILDON_CONTROLBAR(num_lead_ratio), 1, 10); force_min_visible_bars(HILDON_CONTROLBAR(num_lead_ratio), 1); - /* Announcement. */ + /* Announcement page */ gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table = gtk_table_new(2, 3, FALSE), label = gtk_label_new(_("Announce"))); @@ -527,11 +555,9 @@ gboolean settings_dialog() label = gtk_label_new(_("Advance Notice")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); - gtk_table_attach(GTK_TABLE(table), - num_announce_notice = hildon_controlbar_new(), + gtk_table_attach(GTK_TABLE(table), num_announce_notice = hildon_controlbar_new(), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4); - hildon_controlbar_set_range(HILDON_CONTROLBAR(num_announce_notice), 1, - 20); + hildon_controlbar_set_range(HILDON_CONTROLBAR(num_announce_notice), 1, 20); force_min_visible_bars(HILDON_CONTROLBAR(num_announce_notice), 1); /* Enable Voice. */ @@ -569,10 +595,10 @@ gboolean settings_dialog() hildon_controlbar_set_range(HILDON_CONTROLBAR(num_voice_pitch), -2, 8); force_min_visible_bars(HILDON_CONTROLBAR(num_voice_pitch), 1); - /* Misc. page. */ + /* Display settings page. */ gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table = gtk_table_new(2, 3, FALSE), - label = gtk_label_new(_("Misc."))); + label = gtk_label_new(_("Display"))); /* Line Width. */ gtk_table_attach(GTK_TABLE(table), @@ -588,8 +614,7 @@ gboolean settings_dialog() /* Keep Display On Only When Fullscreen. */ gtk_table_attach(GTK_TABLE(table), chk_always_keep_on = - gtk_check_button_new_with_label(_ - ("Keep Display On Only in Fullscreen Mode")), + gtk_check_button_new_with_label(_("Keep Display On Only in Fullscreen Mode")), 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); /* Information Font Size. */ @@ -606,10 +631,10 @@ gboolean settings_dialog() gtk_combo_box_append_text(GTK_COMBO_BOX(cmb_info_font_size), INFO_FONT_TEXT[i]); - /* Misc. 2 page. */ + /* Units page. */ gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table = gtk_table_new(2, 3, FALSE), - label = gtk_label_new(_("Misc. 2"))); + label = gtk_label_new(_("Units"))); /* Units. */ gtk_table_attach(GTK_TABLE(table), @@ -624,12 +649,10 @@ gboolean settings_dialog() UNITS_TEXT[i]); /* Degrees format */ - gtk_table_attach(GTK_TABLE(table), - label = gtk_label_new(_("Degrees Format")), + gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Degrees Format")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); - gtk_table_attach(GTK_TABLE(table), - label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), + gtk_table_attach(GTK_TABLE(table), label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), 1, 2, 1, 2, GTK_FILL, 0, 2, 4); gtk_container_add(GTK_CONTAINER(label), cmb_degformat = gtk_combo_box_new_text()); @@ -721,6 +744,7 @@ gboolean settings_dialog() gtk_entry_set_text(GTK_ENTRY(txt_rcvr_mac), _rcvr_mac); if (_poi_db) gtk_entry_set_text(GTK_ENTRY(txt_poi_db), _poi_db); + hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(num_poi_zoom), _poi_zoom); hildon_controlbar_set_value(HILDON_CONTROLBAR(num_center_ratio), @@ -742,12 +766,13 @@ gboolean settings_dialog() gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_speed_limit_on), _speed_limit_on); hildon_number_editor_set_range(HILDON_NUMBER_EDITOR(num_speed), 1, 300); - hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(num_speed), - _speed_limit); - gtk_combo_box_set_active(GTK_COMBO_BOX(cmb_speed_location), - _speed_location); - gtk_combo_box_set_active(GTK_COMBO_BOX(cmb_info_font_size), - _info_font_size); + hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(num_speed), _speed_limit); + gtk_combo_box_set_active(GTK_COMBO_BOX(cmb_speed_location), _speed_location); + gtk_combo_box_set_active(GTK_COMBO_BOX(cmb_info_font_size), _info_font_size); + + hildon_controlbar_set_value(HILDON_CONTROLBAR(num_hdop_ratio),(gint) _filter_hdop); + hildon_controlbar_set_value(HILDON_CONTROLBAR(num_vdop_ratio),(gint) _filter_vdop); + hildon_controlbar_set_value(HILDON_CONTROLBAR(num_angle),(gint) _filter_angle); gtk_widget_show_all(dialog); @@ -785,63 +810,46 @@ gboolean settings_dialog() (_menu_gps_reset_item), FALSE); } - } else if (!_rcvr_mac || strcmp(_rcvr_mac, - gtk_entry_get_text(GTK_ENTRY - (txt_rcvr_mac)))) - { + } else if (!_rcvr_mac || strcmp(_rcvr_mac, gtk_entry_get_text(GTK_ENTRY(txt_rcvr_mac)))) { /* User specified a new rcvr mac. */ g_free(_rcvr_mac); - _rcvr_mac = - g_strdup(gtk_entry_get_text - (GTK_ENTRY(txt_rcvr_mac))); + _rcvr_mac = g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_rcvr_mac))); rcvr_changed = TRUE; } - _center_ratio = hildon_controlbar_get_value(HILDON_CONTROLBAR - (num_center_ratio)); - - _lead_ratio = hildon_controlbar_get_value(HILDON_CONTROLBAR - (num_lead_ratio)); - - _draw_width = hildon_controlbar_get_value(HILDON_CONTROLBAR - (num_draw_width)); - - _always_keep_on = !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON - (chk_always_keep_on)); - + _center_ratio = hildon_controlbar_get_value(HILDON_CONTROLBAR(num_center_ratio)); + _lead_ratio = hildon_controlbar_get_value(HILDON_CONTROLBAR(num_lead_ratio)); + _draw_width = hildon_controlbar_get_value(HILDON_CONTROLBAR(num_draw_width)); + _always_keep_on = !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_always_keep_on)); _units = gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_units)); _degformat = gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_degformat)); - - _speed_limit_on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON - (chk_speed_limit_on)); - _speed_limit = hildon_number_editor_get_value(HILDON_NUMBER_EDITOR - (num_speed)); + _speed_limit_on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_speed_limit_on)); + _speed_limit = hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(num_speed)); _speed_location = gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_speed_location)); - _info_font_size = gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_info_font_size)); - _announce_notice_ratio = hildon_controlbar_get_value(HILDON_CONTROLBAR - (num_announce_notice)); + _announce_notice_ratio = hildon_controlbar_get_value(HILDON_CONTROLBAR(num_announce_notice)); - _voice_speed = hildon_controlbar_get_value(HILDON_CONTROLBAR - (num_voice_speed)) / 3.0; + _voice_speed = hildon_controlbar_get_value(HILDON_CONTROLBAR(num_voice_speed)) / 3.0; + _voice_pitch = hildon_controlbar_get_value(HILDON_CONTROLBAR(num_voice_pitch)); + _enable_voice = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_enable_voice)); - _voice_pitch = hildon_controlbar_get_value(HILDON_CONTROLBAR - (num_voice_pitch)); - - _enable_voice = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON - (chk_enable_voice)); + _filter_angle =(gfloat)hildon_controlbar_get_value(HILDON_CONTROLBAR(num_angle)); + _filter_hdop =(gfloat)hildon_controlbar_get_value(HILDON_CONTROLBAR(num_hdop_ratio)); + _filter_vdop =(gfloat)hildon_controlbar_get_value(HILDON_CONTROLBAR(num_vdop_ratio)); + _gps_filter = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_gps_filter)); if (_db) { - sqlite3_close(_db); + poi_db_disconnect(&_db); _db = NULL; } g_free(_poi_db); if (strlen(gtk_entry_get_text(GTK_ENTRY(txt_poi_db)))) { _poi_db = g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_poi_db))); poi_db_connect(&_db, _poi_db); - } else + } else { _poi_db = NULL; + } /* Sensitize menus based on whether we have a POI database conn. */ gtk_widget_set_sensitive(_cmenu_loc_add_poi, _db != NULL); @@ -857,7 +865,7 @@ gboolean settings_dialog() break; } - gtk_widget_hide(dialog); /* Destroying causes a crash (!?!?!??!) */ + gtk_widget_destroy(dialog); /* Destroying causes a crash (!?!?!??!) huh?*/ vprintf("%s(): return %d\n", __PRETTY_FUNCTION__, rcvr_changed); return rcvr_changed; diff --git a/src/settings.h b/src/settings.h index c8ee099..27f413d 100644 --- a/src/settings.h +++ b/src/settings.h @@ -1,25 +1,11 @@ -#ifndef _MAPPER_SETTINGS_H -#define _MAPPER_SETTINGS_H - -#include +#include "config.h" #define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#ifndef _MAPPER_SETTINGS_H +#define _MAPPER_SETTINGS_H #include "settings-gconf.h" @@ -27,33 +13,49 @@ gchar *_rcvr_mac; gchar *_route_dir_uri; gchar *_track_file_uri; +gchar *_route_dl_url; +guint _route_dl_radius; + +gboolean _track_store; + +gboolean _always_keep_on; gboolean _fullscreen; gboolean _enable_gps; gboolean _gps_info; -gchar *_route_dl_url; -guint _route_dl_radius; + +gboolean _gps_filter; +gfloat _filter_hdop; +gfloat _filter_vdop; +gfloat _filter_angle; + gint _show_tracks; gboolean _show_scale; gboolean _show_velvec; gboolean _show_poi; gboolean _auto_download; + guint _lead_ratio; guint _center_ratio; guint _draw_width; -guint _announce_notice_ratio; + gboolean _enable_voice; -gboolean _always_keep_on; +guint _announce_notice_ratio; gdouble _voice_speed; gint _voice_pitch; -GSList *_loc_list; -GtkListStore *_loc_model; + gboolean _speed_limit_on; -guint _speed_limit; gboolean _speed_excess; -CustomAction _action[CUSTOM_KEY_ENUM_COUNT]; +guint _speed_limit; gboolean _satdetails_on; +gchar *_http_proxy_host; +gint _http_proxy_port; + +GSList *_loc_list; +GtkListStore *_loc_model; + +CustomAction _action[CUSTOM_KEY_ENUM_COUNT]; CenterMode _center_mode; UnitType _units; guint _degformat; diff --git a/src/ui-common.c b/src/ui-common.c index f941666..eb54401 100644 --- a/src/ui-common.c +++ b/src/ui-common.c @@ -400,6 +400,8 @@ static void menu_init() = gtk_menu_item_new_with_label(_("Go to"))); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu = gtk_menu_new()); + gtk_menu_append(submenu, _menu_goto_home + = gtk_menu_item_new_with_label(_("Home"))); gtk_menu_append(submenu, _menu_goto_latlon = gtk_menu_item_new_with_label(_("Lat/Lon..."))); gtk_menu_append(submenu, _menu_goto_gps @@ -891,7 +893,7 @@ void mapper_init(gint argc, gchar ** argv) #ifdef WITH_HILDON /* Initialize _program. */ _program = HILDON_PROGRAM(hildon_program_get_instance()); - g_set_application_name("Table Mapper"); + g_set_application_name("Tablet Mapper"); /* Initialize _window. */ _window = GTK_WIDGET(hildon_window_new()); @@ -899,8 +901,7 @@ void mapper_init(gint argc, gchar ** argv) #else _window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(_window), "Desktop Mapper"); - gtk_widget_set_size_request(GTK_WIDGET(_window), WINDOW_SIZE_X, - WINDOW_SIZE_Y); + gtk_widget_set_size_request(GTK_WIDGET(_window), WINDOW_SIZE_X, WINDOW_SIZE_Y); gtk_window_resize(GTK_WINDOW(_window), WINDOW_SIZE_X, WINDOW_SIZE_Y); gtk_window_set_resizable(GTK_WINDOW(_window), TRUE); #endif @@ -990,7 +991,8 @@ void mapper_init(gint argc, gchar ** argv) gtk_widget_realize(_map_widget); map_poi_init(_map_widget); - _map_pixmap = gdk_pixmap_new(_map_widget->window, BUF_WIDTH_PIXELS, BUF_HEIGHT_PIXELS, -1); /* -1: use bit depth of widget->window. */ + /* -1: use bit depth of widget->window. */ + _map_pixmap = gdk_pixmap_new(_map_widget->window, BUF_WIDTH_PIXELS, BUF_HEIGHT_PIXELS, -1); _curl_easy_queue = g_queue_new(); @@ -998,8 +1000,7 @@ void mapper_init(gint argc, gchar ** argv) NULL, (GDestroyNotify) progress_update_info_free, NULL); - _downloading_tree = - g_tree_new_full((GCompareDataFunc) download_comparefunc, NULL, + _downloading_tree = g_tree_new_full((GCompareDataFunc) download_comparefunc, NULL, (GDestroyNotify) progress_update_info_free, NULL); _pui_by_easy = g_hash_table_new(g_direct_hash, g_direct_equal); @@ -1133,6 +1134,9 @@ void mapper_init(gint argc, gchar ** argv) _pos.unitx = 0; _pos.unity = 0; + _gps.heading = 0; + _gps.lheading = 0; + integerize_data(_vel_offsetx, _vel_offsety, _pos, _gps); /* Initialize our line styles. */ diff --git a/src/ui-common.h b/src/ui-common.h index 776bad9..13d0f0e 100644 --- a/src/ui-common.h +++ b/src/ui-common.h @@ -132,6 +132,7 @@ GtkWidget *_menu_ac_lead_item; GtkWidget *_menu_ac_none_item; /* Menu items for the "Go to" submenu. */ +GtkWidget *_menu_goto_home; GtkWidget *_menu_goto_latlon; GtkWidget *_menu_goto_gps; GtkWidget *_menu_goto_nextway; diff --git a/src/utils.h b/src/utils.h index 4bd4fec..a4c8fc2 100644 --- a/src/utils.h +++ b/src/utils.h @@ -303,18 +303,13 @@ curl_easy_setopt(C, CURLOPT_CONNECTTIMEOUT, 10); \ } -#ifdef WITH_HILDON -#define MACRO_CURL_PROXY(C) { -if (_iap_http_proxy_host) { - curl_easy_setopt(C, CURLOPT_PROXY, _iap_http_proxy_host); - if (_iap_http_proxy_port) - curl_easy_setopt(C, CURLOPT_PROXYPORT, _iap_http_proxy_port); -} +#define MACRO_CURL_PROXY(C) { \ +if (_http_proxy_host) { \ + curl_easy_setopt(C, CURLOPT_PROXY, _http_proxy_host);\ + if (_http_proxy_port) \ + curl_easy_setopt(C, CURLOPT_PROXYPORT, _http_proxy_port); \ +} \ } -#else -/* XXX: Get GNOME proxy settings */ -#define MACRO_CURL_PROXY(C) { } -#endif #ifdef WITH_HILDON #define MACRO_BANNER_SHOW_INFO(A, S) { \ -- 2.39.5