From 6f0e1a566b50288bc77555c1a16fb9ef45a0db46 Mon Sep 17 00:00:00 2001 From: gnuite Date: Mon, 17 Mar 2008 05:32:13 +0000 Subject: [PATCH] Added ability to disable the recording of your track (closes #2311). git-svn-id: svn+ssh://garage/var/lib/gforge/svnroot/maemo-mapper/trunk@179 6c538b50-5814-0410-93ad-8bdf4c0149d1 --- src/cmenu.c | 2 +- src/data.c | 6 +- src/data.h | 4 +- src/display.c | 2 +- src/display.h | 2 +- src/gps.c | 2 +- src/gpx.c | 2 + src/input.c | 2 +- src/menu.c | 49 +++++-- src/path.c | 357 ++++++++++++++++++++++++------------------------- src/poi.c | 5 +- src/settings.c | 15 +++ 12 files changed, 243 insertions(+), 205 deletions(-) diff --git a/src/cmenu.c b/src/cmenu.c index 5871d6c..0811d94 100644 --- a/src/cmenu.c +++ b/src/cmenu.c @@ -268,7 +268,7 @@ cmenu_cb_loc_apply_correction(GtkMenuItem *item) { printf("%s()\n", __PRETTY_FUNCTION__); - if(gtk_check_menu_item_get_active(item)) + if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item))) { /* Get difference between tap point and GPS location. */ gint unitx, unity; diff --git a/src/data.c b/src/data.c index 6850ff7..79e96cd 100644 --- a/src/data.c +++ b/src/data.c @@ -164,7 +164,8 @@ gchar *_track_file_uri = NULL; CenterMode _center_mode = CENTER_LEAD; gboolean _center_rotate = TRUE; gboolean _fullscreen = FALSE; -gboolean _enable_gps = FALSE; +gboolean _enable_gps = TRUE; +gboolean _enable_track = TRUE; gboolean _gps_info = FALSE; gchar *_route_dl_url = NULL; gint _route_dl_radius = 4; @@ -233,6 +234,7 @@ GtkWidget *_menu_track_insert_mark_item = NULL; GtkWidget *_menu_track_distlast_item = NULL; GtkWidget *_menu_track_distfirst_item = NULL; GtkWidget *_menu_track_clear_item = NULL; +GtkWidget *_menu_track_enable_item = NULL; /* Menu items for the "POI" submenu. */ GtkWidget *_menu_poi_item = NULL; @@ -286,7 +288,7 @@ GtkWidget *_menu_view_goto_nextway_item = NULL; GtkWidget *_menu_view_goto_nearpoi_item = NULL; /* Menu items for the "GPS" submenu. */ -GtkWidget *_menu_enable_gps_item = NULL; +GtkWidget *_menu_gps_enable_item = NULL; GtkWidget *_menu_gps_show_info_item = NULL; GtkWidget *_menu_gps_details_item = NULL; GtkWidget *_menu_gps_reset_item = NULL; diff --git a/src/data.h b/src/data.h index 9ff6e5f..981ef00 100644 --- a/src/data.h +++ b/src/data.h @@ -144,6 +144,7 @@ extern CenterMode _center_mode; extern gboolean _center_rotate; extern gboolean _fullscreen; extern gboolean _enable_gps; +extern gboolean _enable_track; extern gboolean _gps_info; extern gchar *_route_dl_url; extern gint _route_dl_radius; @@ -212,6 +213,7 @@ extern GtkWidget *_menu_track_insert_mark_item; extern GtkWidget *_menu_track_distlast_item; extern GtkWidget *_menu_track_distfirst_item; extern GtkWidget *_menu_track_clear_item; +extern GtkWidget *_menu_track_enable_item; /* Menu items for the "POI" submenu. */ extern GtkWidget *_menu_poi_item; @@ -265,7 +267,7 @@ extern GtkWidget *_menu_view_goto_nextway_item; extern GtkWidget *_menu_view_goto_nearpoi_item; /* Menu items for the "GPS" submenu. */ -extern GtkWidget *_menu_enable_gps_item; +extern GtkWidget *_menu_gps_enable_item; extern GtkWidget *_menu_gps_show_info_item; extern GtkWidget *_menu_gps_details_item; extern GtkWidget *_menu_gps_reset_item; diff --git a/src/display.c b/src/display.c index 87f4bfa..60e61c8 100644 --- a/src/display.c +++ b/src/display.c @@ -2474,7 +2474,7 @@ latlon_dialog(gdouble lat, gdouble lon) * This function returns TRUE if a file was successfully opened. */ gboolean -display_open_file(GtkWidget *parent, gchar **bytes_out, +display_open_file(GtkWindow *parent, gchar **bytes_out, GnomeVFSHandle **handle_out, gint *size_out, gchar **dir, gchar **file, GtkFileChooserAction chooser_action) { diff --git a/src/display.h b/src/display.h index b2f8b5d..76973af 100644 --- a/src/display.h +++ b/src/display.h @@ -68,7 +68,7 @@ gboolean map_cb_expose(GtkWidget *widget, GdkEventExpose *event); gboolean latlon_dialog(gdouble lat, gdouble lon); -gboolean display_open_file(GtkWidget *parent, gchar **bytes_out, +gboolean display_open_file(GtkWindow *parent, gchar **bytes_out, GnomeVFSHandle **handle_out, gint *size_out, gchar **dir, gchar **file, GtkFileChooserAction chooser_action); diff --git a/src/gps.c b/src/gps.c index 25a007e..5656ca7 100644 --- a/src/gps.c +++ b/src/gps.c @@ -462,7 +462,7 @@ gps_handle_error_idle(gchar *error) { /* Disable GPS. */ gtk_check_menu_item_set_active( - GTK_CHECK_MENU_ITEM(_menu_enable_gps_item), FALSE); + GTK_CHECK_MENU_ITEM(_menu_gps_enable_item), FALSE); } /* Ask user to re-connect. */ diff --git a/src/gpx.c b/src/gpx.c index 8dc9bf4..1ec1354 100644 --- a/src/gpx.c +++ b/src/gpx.c @@ -156,6 +156,8 @@ gpx_write_escaped(GnomeVFSHandle *handle, const gchar *str) case '>': to_write = ">"; break; + default: + to_write = ""; } gpx_write_string(handle, to_write); diff --git a/src/input.c b/src/input.c index 5065df9..5d9936c 100644 --- a/src/input.c +++ b/src/input.c @@ -416,7 +416,7 @@ window_cb_key_press(GtkWidget* widget, GdkEventKey *event) case CUSTOM_ACTION_TOGGLE_GPS: gtk_check_menu_item_set_active( - GTK_CHECK_MENU_ITEM(_menu_enable_gps_item), + GTK_CHECK_MENU_ITEM(_menu_gps_enable_item), !_enable_gps); break; diff --git a/src/menu.c b/src/menu.c index d97b7af..0efe37d 100644 --- a/src/menu.c +++ b/src/menu.c @@ -113,8 +113,8 @@ menu_cb_route_open(GtkMenuItem *item) gint size; printf("%s()\n", __PRETTY_FUNCTION__); - if(display_open_file(_window, &buffer, NULL, &size, &_route_dir_uri, NULL, - GTK_FILE_CHOOSER_ACTION_OPEN)) + if(display_open_file(GTK_WINDOW(_window), &buffer, NULL, &size, + &_route_dir_uri, NULL, GTK_FILE_CHOOSER_ACTION_OPEN)) { /* If auto is enabled, append the route, otherwise replace it. */ if(gpx_path_parse(&_route, buffer, size, @@ -154,8 +154,8 @@ menu_cb_route_save(GtkMenuItem *item) GnomeVFSHandle *handle; printf("%s()\n", __PRETTY_FUNCTION__); - if(display_open_file(_window, NULL, &handle, NULL, &_route_dir_uri, NULL, - GTK_FILE_CHOOSER_ACTION_SAVE)) + if(display_open_file(GTK_WINDOW(_window), NULL, &handle, NULL, + &_route_dir_uri, NULL, GTK_FILE_CHOOSER_ACTION_SAVE)) { if(gpx_path_write(&_route, handle)) { @@ -234,8 +234,8 @@ menu_cb_track_open(GtkMenuItem *item) gint size; printf("%s()\n", __PRETTY_FUNCTION__); - if(display_open_file(_window, &buffer, NULL, &size, NULL, &_track_file_uri, - GTK_FILE_CHOOSER_ACTION_OPEN)) + if(display_open_file(GTK_WINDOW(_window), &buffer, NULL, &size, + NULL, &_track_file_uri, GTK_FILE_CHOOSER_ACTION_OPEN)) { if(gpx_path_parse(&_track, buffer, size, -1)) { @@ -257,8 +257,8 @@ menu_cb_track_save(GtkMenuItem *item) GnomeVFSHandle *handle; printf("%s()\n", __PRETTY_FUNCTION__); - if(display_open_file(_window, NULL, &handle, NULL, NULL, &_track_file_uri, - GTK_FILE_CHOOSER_ACTION_SAVE)) + if(display_open_file(GTK_WINDOW(_window), NULL, &handle, NULL, + NULL, &_track_file_uri, GTK_FILE_CHOOSER_ACTION_SAVE)) { if(gpx_path_write(&_track, handle)) { @@ -421,6 +421,21 @@ menu_cb_track_clear(GtkMenuItem *item) return TRUE; } +static gboolean +menu_cb_track_enable(GtkMenuItem *item) +{ + printf("%s()\n", __PRETTY_FUNCTION__); + + if(!(_enable_track = gtk_check_menu_item_get_active( + GTK_CHECK_MENU_ITEM(_menu_track_enable_item)))) + { + track_insert_break(FALSE); /* FALSE = not temporary */ + } + + vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__); + return TRUE; +} + /**************************************************************************** * ABOVE: TRACK MENU ******************************************************** ****************************************************************************/ @@ -1230,12 +1245,12 @@ menu_cb_view_fullscreen(GtkMenuItem *item) ****************************************************************************/ static gboolean -menu_cb_enable_gps(GtkMenuItem *item) +menu_cb_gps_enable(GtkMenuItem *item) { printf("%s()\n", __PRETTY_FUNCTION__); if((_enable_gps = gtk_check_menu_item_get_active( - GTK_CHECK_MENU_ITEM(_menu_enable_gps_item)))) + GTK_CHECK_MENU_ITEM(_menu_gps_enable_item)))) rcvr_connect(); else rcvr_disconnect(); @@ -1453,6 +1468,10 @@ menu_init() = gtk_menu_item_new_with_label(_("Show Distance from Beginning"))); gtk_menu_append(submenu, _menu_track_clear_item = gtk_menu_item_new_with_label(_("Clear"))); + gtk_menu_append(submenu, _menu_track_enable_item + = gtk_check_menu_item_new_with_label(_("Enable Track"))); + gtk_check_menu_item_set_active( + GTK_CHECK_MENU_ITEM(_menu_track_enable_item), _enable_track); /* The "POI" submenu. */ gtk_menu_append(menu, menu_item = _menu_poi_item @@ -1634,10 +1653,10 @@ menu_init() = gtk_menu_item_new_with_label(_("GPS"))); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu = gtk_menu_new()); - gtk_menu_append(submenu, _menu_enable_gps_item + gtk_menu_append(submenu, _menu_gps_enable_item = gtk_check_menu_item_new_with_label(_("Enable GPS"))); gtk_check_menu_item_set_active( - GTK_CHECK_MENU_ITEM(_menu_enable_gps_item), _enable_gps); + GTK_CHECK_MENU_ITEM(_menu_gps_enable_item), _enable_gps); gtk_menu_append(submenu, _menu_gps_show_info_item = gtk_check_menu_item_new_with_label(_("Show Information"))); gtk_check_menu_item_set_active( @@ -1698,6 +1717,8 @@ menu_init() G_CALLBACK(menu_cb_track_distfirst), NULL); g_signal_connect(G_OBJECT(_menu_track_clear_item), "activate", G_CALLBACK(menu_cb_track_clear), NULL); + g_signal_connect(G_OBJECT(_menu_track_enable_item), "toggled", + G_CALLBACK(menu_cb_track_enable), NULL); /* Connect the "POI" signals. */ g_signal_connect(G_OBJECT(_menu_poi_import_item), "activate", @@ -1786,8 +1807,8 @@ menu_init() G_CALLBACK(menu_cb_view_fullscreen), NULL); /* Connect the "GPS" signals. */ - g_signal_connect(G_OBJECT(_menu_enable_gps_item), "toggled", - G_CALLBACK(menu_cb_enable_gps), NULL); + g_signal_connect(G_OBJECT(_menu_gps_enable_item), "toggled", + G_CALLBACK(menu_cb_gps_enable), NULL); g_signal_connect(G_OBJECT(_menu_gps_show_info_item), "toggled", G_CALLBACK(menu_cb_gps_show_info), NULL); g_signal_connect(G_OBJECT(_menu_gps_details_item), "activate", diff --git a/src/path.c b/src/path.c index be302f5..3a0ac5b 100644 --- a/src/path.c +++ b/src/path.c @@ -753,49 +753,43 @@ track_add(time_t time, gboolean newly_fixed) printf("%s(%d, %d, %d, %d)\n", __PRETTY_FUNCTION__, (guint)time, newly_fixed, _pos.unitx, _pos.unity); - if(!time) + gboolean moving = FALSE; + gboolean approaching_waypoint = FALSE; + gint xdiff, ydiff, dopcand; + + announce_thres_unsquared = (20+_gps.speed) * _announce_notice_ratio*32; + + if(!_track.tail->unity + || ((xdiff = _pos.unitx - _track.tail->unitx), /* comma op */ + (ydiff = _pos.unity - _track.tail->unity), /* comma op */ + /* Check if xdiff or ydiff are huge. */ + ((abs(xdiff) >> 12) || (abs(ydiff) >> 12) + /* Okay, let's see if we've moved enough to justify adding + * to the track. It depends on our error. I'd like to + * make the threshold roughly linear with respect to the + * P/HDOP (completely arbitrary, I know), but I also + * want to keep the threshold at a minimum of 2 + * zoom-level-4 pixel, and I want dop's of less than 2 to + * also have a 1-pixel threshold. I also throw in some + * PDOP into the mix, just for fun. */ + || ((dopcand = 8 * (_gps.pdop - 6 +(_gps.hdop*_gps.hdop))), + ((xdiff * xdiff) + (ydiff * ydiff) + >= (MAX(2, dopcand) << 8)))))) { - /* This is a null point. */ - MACRO_PATH_INCREMENT_TAIL(_track); - *_track.tail = _point_null; - } - else - { - gboolean moving = FALSE; - gboolean approaching_waypoint = FALSE; - gint xdiff, ydiff, dopcand; - - announce_thres_unsquared = (20+_gps.speed) * _announce_notice_ratio*32; - - if(!_track.tail->unity - || ((xdiff = _pos.unitx - _track.tail->unitx), /* comma op */ - (ydiff = _pos.unity - _track.tail->unity), /* comma op */ - /* Check if xdiff or ydiff are huge. */ - ((abs(xdiff) >> 12) || (abs(ydiff) >> 12) - /* Okay, let's see if we've moved enough to justify adding - * to the track. It depends on our error. I'd like to - * make the threshold roughly linear with respect to the - * P/HDOP (completely arbitrary, I know), but I also - * want to keep the threshold at a minimum of 2 - * zoom-level-4 pixel, and I want dop's of less than 2 to - * also have a 1-pixel threshold. I also throw in some - * PDOP into the mix, just for fun. */ - || ((dopcand = 8 * (_gps.pdop - 6 +(_gps.hdop*_gps.hdop))), - ((xdiff * xdiff) + (ydiff * ydiff) - >= (MAX(2, dopcand) << 8)))))) - { - /* We moved enough to actually register a move. */ - ret = TRUE; + /* We moved enough to actually register a move. */ + ret = TRUE; - /* Update the nearest-waypoint data. */ - if(_route.head != _route.tail - && (newly_fixed ? (route_find_nearest_point(), TRUE) - : route_update_nears(TRUE))) - { - /* Nearest waypoint has changed - re-render paths. */ - map_render_paths(); - MACRO_QUEUE_DRAW_AREA(); - } + /* Update the nearest-waypoint data. */ + if(_route.head != _route.tail + && (newly_fixed ? (route_find_nearest_point(), TRUE) + : route_update_nears(TRUE))) + { + /* Nearest waypoint has changed - re-render paths. */ + map_render_paths(); + MACRO_QUEUE_DRAW_AREA(); + } + if(_enable_track) + { if(_show_paths & TRACKS_MASK) { /* Instead of calling map_render_paths(), we'll draw the new @@ -817,176 +811,176 @@ track_add(time_t time, gboolean newly_fixed) abs(ty1 - ty2) + (2 * _draw_width)); } } - MACRO_PATH_INCREMENT_TAIL(_track); + MACRO_PATH_INCREMENT_TAIL(_track); *_track.tail = _pos; + } - /* Calculate distance to route. (point to line) */ - if(_near_point) - { - gint route_x1, route_x2, route_y1, route_y2; - gint64 route_dist_squared_1 = INT64_MAX; - gint64 route_dist_squared_2 = INT64_MAX; - gfloat slope; + /* Calculate distance to route. (point to line) */ + if(_near_point) + { + gint route_x1, route_x2, route_y1, route_y2; + gint64 route_dist_squared_1 = INT64_MAX; + gint64 route_dist_squared_2 = INT64_MAX; + gfloat slope; - route_x1 = _near_point->unitx; - route_y1 = _near_point->unity; + route_x1 = _near_point->unitx; + route_y1 = _near_point->unity; - /* Try previous point first. */ - if(_near_point != _route.head && _near_point[-1].unity) - { - route_x2 = _near_point[-1].unitx; - route_y2 = _near_point[-1].unity; - slope = (gfloat)(route_y2 - route_y1) - / (gfloat)(route_x2 - route_x1); + /* Try previous point first. */ + if(_near_point != _route.head && _near_point[-1].unity) + { + route_x2 = _near_point[-1].unitx; + route_y2 = _near_point[-1].unity; + slope = (gfloat)(route_y2 - route_y1) + / (gfloat)(route_x2 - route_x1); - if(route_x1 == route_x2) - { - /* Vertical line special case. */ - route_dist_squared_1 = (_pos.unitx - route_x1) - * (_pos.unitx - route_x1); - } - else - { - route_dist_squared_1 = abs((slope * _pos.unitx) - - _pos.unity + (route_y1 - (slope * route_x1))); - route_dist_squared_1 = - route_dist_squared_1 * route_dist_squared_1 - / ((slope * slope) + 1); - } + if(route_x1 == route_x2) + { + /* Vertical line special case. */ + route_dist_squared_1 = (_pos.unitx - route_x1) + * (_pos.unitx - route_x1); } - if(_near_point != _route.tail && _near_point[1].unity) + else { - route_x2 = _near_point[1].unitx; - route_y2 = _near_point[1].unity; - slope = (gfloat)(route_y2 - route_y1) - / (gfloat)(route_x2 - route_x1); - - if(route_x1 == route_x2) - { - /* Vertical line special case. */ - route_dist_squared_2 = (_pos.unitx - route_x1) - * (_pos.unitx - route_x1); - } - else - { - route_dist_squared_2 = abs((slope * _pos.unitx) - - _pos.unity + (route_y1 - (slope * route_x1))); - route_dist_squared_2 = - route_dist_squared_2 * route_dist_squared_2 - / ((slope * slope) + 1); - } + route_dist_squared_1 = abs((slope * _pos.unitx) + - _pos.unity + (route_y1 - (slope * route_x1))); + route_dist_squared_1 = + route_dist_squared_1 * route_dist_squared_1 + / ((slope * slope) + 1); } + } + if(_near_point != _route.tail && _near_point[1].unity) + { + route_x2 = _near_point[1].unitx; + route_y2 = _near_point[1].unity; + slope = (gfloat)(route_y2 - route_y1) + / (gfloat)(route_x2 - route_x1); - /* Check if our distance from the route is large. */ - if(MIN(route_dist_squared_1, route_dist_squared_2) - > (2000 * 2000)) + if(route_x1 == route_x2) { - /* Prevent announcments from occurring. */ - announce_thres_unsquared = INT_MAX; - - if(_autoroute_data.enabled && !_autoroute_data.in_progress) - { - MACRO_BANNER_SHOW_INFO(_window, - _("Recalculating directions...")); - _autoroute_data.in_progress = TRUE; - show_directions = FALSE; - g_idle_add((GSourceFunc)auto_route_dl_idle, NULL); - } - else - { - /* Reset the route to try and find the nearest point.*/ - path_reset_route(); - } + /* Vertical line special case. */ + route_dist_squared_2 = (_pos.unitx - route_x1) + * (_pos.unitx - route_x1); + } + else + { + route_dist_squared_2 = abs((slope * _pos.unitx) + - _pos.unity + (route_y1 - (slope * route_x1))); + route_dist_squared_2 = + route_dist_squared_2 * route_dist_squared_2 + / ((slope * slope) + 1); } } - /* Keep the display on. */ - moving = TRUE; + /* Check if our distance from the route is large. */ + if(MIN(route_dist_squared_1, route_dist_squared_2) + > (2000 * 2000)) + { + /* Prevent announcments from occurring. */ + announce_thres_unsquared = INT_MAX; + + if(_autoroute_data.enabled && !_autoroute_data.in_progress) + { + MACRO_BANNER_SHOW_INFO(_window, + _("Recalculating directions...")); + _autoroute_data.in_progress = TRUE; + show_directions = FALSE; + g_idle_add((GSourceFunc)auto_route_dl_idle, NULL); + } + else + { + /* Reset the route to try and find the nearest point.*/ + path_reset_route(); + } + } } - if(_initial_distance_waypoint - && (_next_way != _initial_distance_waypoint - || _next_way_dist_squared > (_initial_distance_from_waypoint - * _initial_distance_from_waypoint))) + /* Keep the display on. */ + moving = TRUE; + } + + if(_initial_distance_waypoint + && (_next_way != _initial_distance_waypoint + || _next_way_dist_squared > (_initial_distance_from_waypoint + * _initial_distance_from_waypoint))) + { + /* We've moved on to the next waypoint, or we're really far from + * the current waypoint. */ + if(_waypoint_banner) { - /* We've moved on to the next waypoint, or we're really far from - * the current waypoint. */ - if(_waypoint_banner) - { - gtk_widget_destroy(_waypoint_banner); - _waypoint_banner = NULL; - } - _initial_distance_from_waypoint = -1.f; - _initial_distance_waypoint = NULL; + gtk_widget_destroy(_waypoint_banner); + _waypoint_banner = NULL; } + _initial_distance_from_waypoint = -1.f; + _initial_distance_waypoint = NULL; + } - /* Check if we should announce upcoming waypoints. */ - if(_enable_announce - && (_initial_distance_waypoint || _next_way_dist_squared - < (announce_thres_unsquared * announce_thres_unsquared))) + /* Check if we should announce upcoming waypoints. */ + if(_enable_announce + && (_initial_distance_waypoint || _next_way_dist_squared + < (announce_thres_unsquared * announce_thres_unsquared))) + { + if(show_directions) { - if(show_directions) + if(!_initial_distance_waypoint) { - if(!_initial_distance_waypoint) + /* First time we're close enough to this waypoint. */ + if(_enable_voice + /* And that we haven't already announced it. */ + && strcmp(_next_way->desc, _last_spoken_phrase)) { - /* First time we're close enough to this waypoint. */ - if(_enable_voice - /* And that we haven't already announced it. */ - && strcmp(_next_way->desc, _last_spoken_phrase)) + g_free(_last_spoken_phrase); + _last_spoken_phrase = g_strdup(_next_way->desc); + if(!fork()) { - g_free(_last_spoken_phrase); - _last_spoken_phrase = g_strdup(_next_way->desc); - if(!fork()) - { - /* We are the fork child. Synthesize the voice. */ - hildon_play_system_sound( - "/usr/share/sounds/ui-information_note.wav"); - sleep(1); + /* We are the fork child. Synthesize the voice. */ + hildon_play_system_sound( + "/usr/share/sounds/ui-information_note.wav"); + sleep(1); # define _voice_synth_path "/usr/bin/flite" - printf("%s %s\n", _voice_synth_path, - _last_spoken_phrase); - execl(_voice_synth_path, _voice_synth_path, - "-t", _last_spoken_phrase, (char *)NULL); - exit(0); - } - } - _initial_distance_from_waypoint - = sqrtf(_next_way_dist_squared); - _initial_distance_waypoint = _next_way; - if(_next_wpt && _next_wpt->unity != 0) - { - /* Create a banner for us the show progress. */ - _waypoint_banner = hildon_banner_show_progress( - _window, NULL, _next_way->desc); - } - else - { - /* This is the last point in a segment, i.e. - * "Arrive at ..." - just announce. */ - MACRO_BANNER_SHOW_INFO(_window, _next_way->desc); + printf("%s %s\n", _voice_synth_path, + _last_spoken_phrase); + execl(_voice_synth_path, _voice_synth_path, + "-t", _last_spoken_phrase, (char *)NULL); + exit(0); } } - else if(_waypoint_banner); + _initial_distance_from_waypoint + = sqrtf(_next_way_dist_squared); + _initial_distance_waypoint = _next_way; + if(_next_wpt && _next_wpt->unity != 0) { - /* We're already close to this waypoint. */ - gdouble fraction = 1.f - (sqrtf(_next_way_dist_squared) - / _initial_distance_from_waypoint); - BOUND(fraction, 0.f, 1.f); - hildon_banner_set_fraction( - HILDON_BANNER(_waypoint_banner), fraction); + /* Create a banner for us the show progress. */ + _waypoint_banner = hildon_banner_show_progress( + _window, NULL, _next_way->desc); + } + else + { + /* This is the last point in a segment, i.e. + * "Arrive at ..." - just announce. */ + MACRO_BANNER_SHOW_INFO(_window, _next_way->desc); } } - approaching_waypoint = TRUE; - } - else if(_next_way_dist_squared > 2 * (_initial_distance_from_waypoint - * _initial_distance_from_waypoint)) - { - /* We're too far away now - destroy the banner. */ + else if(_waypoint_banner); + { + /* We're already close to this waypoint. */ + gdouble fraction = 1.f - (sqrtf(_next_way_dist_squared) + / _initial_distance_from_waypoint); + BOUND(fraction, 0.f, 1.f); + hildon_banner_set_fraction( + HILDON_BANNER(_waypoint_banner), fraction); + } } - - UNBLANK_SCREEN(moving, approaching_waypoint); + approaching_waypoint = TRUE; } + else if(_next_way_dist_squared > 2 * (_initial_distance_from_waypoint + * _initial_distance_from_waypoint)) + { + /* We're too far away now - destroy the banner. */ + } + + UNBLANK_SCREEN(moving, approaching_waypoint); /* Maybe update the track database. */ { @@ -1060,6 +1054,9 @@ track_insert_break(gboolean temporary) MACRO_BANNER_SHOW_INFO(_window, _("Break already inserted.")); } + /* Update the track database. */ + path_update_track_in_db(); + vprintf("%s(): return\n", __PRETTY_FUNCTION__); } diff --git a/src/poi.c b/src/poi.c index 3eba947..85c8b87 100644 --- a/src/poi.c +++ b/src/poi.c @@ -1123,7 +1123,6 @@ poi_create_cat_combo() gboolean poi_add_dialog(GtkWidget *parent, gint unitx, gint unity) { - gchar buffer[16]; static PoiInfo poi; static GtkWidget *dialog; static GtkWidget *table; @@ -2071,8 +2070,8 @@ poi_list_export_gpx(GtkWidget *widget, PoiListInfo *pli) GnomeVFSHandle *handle; printf("%s()\n", __PRETTY_FUNCTION__); - if(display_open_file(pli->dialog2, NULL, &handle, NULL, NULL, NULL, - GTK_FILE_CHOOSER_ACTION_SAVE)) + if(display_open_file(GTK_WINDOW(pli->dialog2), NULL, &handle, NULL, + NULL, NULL, GTK_FILE_CHOOSER_ACTION_SAVE)) { gint num_exported = gpx_poi_write( gtk_tree_view_get_model(GTK_TREE_VIEW(pli->tree_view)), handle); diff --git a/src/settings.c b/src/settings.c index debe6c2..2e00c94 100644 --- a/src/settings.c +++ b/src/settings.c @@ -120,6 +120,7 @@ #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" +#define GCONF_KEY_ENABLE_TRACK GCONF_KEY_PREFIX"/enable_track" #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" @@ -443,6 +444,10 @@ settings_save() gconf_client_set_bool(gconf_client, GCONF_KEY_ENABLE_GPS, _enable_gps, NULL); + /* Save Enable Track flag. */ + gconf_client_set_bool(gconf_client, + GCONF_KEY_ENABLE_TRACK, _enable_track, NULL); + /* Save Route Locations. */ gconf_client_set_list(gconf_client, GCONF_KEY_ROUTE_LOCATIONS, GCONF_VALUE_STRING, _loc_list, NULL); @@ -2350,6 +2355,16 @@ settings_init() else _enable_gps = TRUE; + /* Get Enable Track flag. Default is TRUE. */ + value = gconf_client_get(gconf_client, GCONF_KEY_ENABLE_TRACK, NULL); + if(value) + { + _enable_track = gconf_value_get_bool(value); + gconf_value_free(value); + } + else + _enable_track = TRUE; + /* Initialize _gps_state based on _enable_gps. */ _gps_state = RCVR_OFF; -- 2.45.0