Path *path;
};
+static gboolean route_auto_dl_idle_cb();
+static void route_cancel_autoroute(Path *route, gboolean temporary);
+
/**
* path_clear_ask:
* @path
}
/**
+ *
*
*/
void
if (_autoroute_data.enabled && !_autoroute_data.in_progress && path->near_point_dist_squared > 400) {
_autoroute_data.in_progress = TRUE;
- show_directions=FALSE;
- g_idle_add((GSourceFunc)route_auto_route_dl_idle_cb, NULL);
+ g_idle_add((GSourceFunc)route_auto_dl_idle_cb, NULL);
MACRO_BANNER_SHOW_INFO(_window, _("Recalculating directions..."));
}
gboolean r = FALSE;
if (file_save(&_track_file_uri, &_track_file_uri, &handle)) {
- if (path_gpx_write(track, handle)) {
+ if (path_gpx_write(track, handle, NULL)) {
MACRO_BANNER_SHOW_INFO(_window, _("Track Saved"));
r = TRUE;
- path_clear_ask(track);
+ path_clear_ask(track, _("Clear track ?"));
} else {
popup_error(_window, _("Error writing track GPX file."));
}
MACRO_BANNER_SHOW_INFO(_window, _("Route Opened"));
/* Find the nearest route point, if we're connected. */
- path_find_nearest_point(route);
+ path_find_nearest_point(route, _gps->data.lat, _gps->data.lon);
route_set_destination_from_last(route, &_dest);
return TRUE;
} else {
}
if (file_save(&_route_dir_uri, &_route_dir_uri, &handle)) {
- if (path_gpx_write(route, handle)) {
+ if (path_gpx_write(route, handle, NULL)) {
MACRO_BANNER_SHOW_INFO(_window, _("Route Saved"));
} else {
popup_error(_window, _("Error writing route GPX file."));
*
* Cancel the current auto-route.
*/
-void
+static void
route_cancel_autoroute(Path *route, gboolean temporary)
{
if (_autoroute_data.enabled) {
if (!temporary) {
- _autoroute_data.enabled = FALSE;
+ _autoroute_data.enabled=FALSE;
g_free(_autoroute_data.dest);
- _autoroute_data.dest = NULL;
+ _autoroute_data.dest=NULL;
g_free(_autoroute_data.src_str);
- _autoroute_data.src_str = NULL;
+ _autoroute_data.src_str=NULL;
}
if (_autoroute_data.curl_easy) {
curl_multi_remove_handle(_autoroute_data.curl_multi, _autoroute_data.curl_easy);
curl_easy_cleanup(_autoroute_data.curl_easy);
curl_multi_cleanup(_autoroute_data.curl_multi);
- _autoroute_data.curl_easy = NULL;
- _autoroute_data.curl_multi = NULL;
+ _autoroute_data.curl_easy=NULL;
+ _autoroute_data.curl_multi=NULL;
}
g_free(_autoroute_data.rdl_data.bytes);
- _autoroute_data.rdl_data.bytes = NULL;
- _autoroute_data.rdl_data.bytes_read = 0;
- _autoroute_data.in_progress = FALSE;
+ _autoroute_data.rdl_data.bytes=NULL;
+ _autoroute_data.rdl_data.bytes_read=0;
+ _autoroute_data.in_progress=FALSE;
}
}
path_find_nearest_point(_route, _gps->data.lat, _gps->data.lon);
}
route_cancel_autoroute(_route, TRUE); /* We're done. Clean up. */
+ return FALSE;
}
}
+return TRUE;
+}
/**
* Read the data provided by the given handle as GPX data, updating the
oti.path=route;
+memset(&_autoroute_data, 0, sizeof(_autoroute_data));
+
dialog = gtk_dialog_new_with_buttons(_("Download Route"),
GTK_WINDOW(_window),
GTK_DIALOG_MODAL, GTK_STOCK_OK,
/* Attempt to download the route from the server. */
MACRO_CURL_EASY_INIT(curl_easy);
curl_easy_setopt(curl_easy, CURLOPT_URL, buffer);
- curl_easy_setopt(curl_easy, CURLOPT_WRITEFUNCTION, route_dl_cb_read);
+ curl_easy_setopt(curl_easy, CURLOPT_WRITEFUNCTION, route_auto_dl_read_cb);
curl_easy_setopt(curl_easy, CURLOPT_WRITEDATA, &rdl_data);
if (CURLE_OK != curl_easy_perform(curl_easy)) {
popup_error(dialog, _("Failed to connect to GPX Directions server"));
GtkTreeIter iter;
/* Find the nearest route point, if we're connected. */
- path_find_nearest_point(route);
+ path_find_nearest_point(route, _gps->data.lat, _gps->data.lon);
/* Cancel any autoroute that might be occurring. */
route_cancel_autoroute(route, FALSE);
gboolean
track_insert_mark(Path *track)
{
-gdouble lat, lon;
gchar tmp1[16], tmp2[16], *p_latlon;
GtkWidget *dialog;
GtkWidget *table;
gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Near Lat, Lon")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4);
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-unit2latlon(_gps->data.unitx, _gps->data.unity, &lat, &lon);
-lat_format(_degformat, lat, tmp1);
-lon_format(_degformat, lon, tmp2);
-p_latlon = g_strdup_printf("%s, %s", tmp1, tmp2);
+lat_format(_degformat, _gps->data.lat, tmp1);
+lon_format(_degformat, _gps->data.lon, tmp2);
+p_latlon=g_strdup_printf("%s, %s", tmp1, tmp2);
gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(p_latlon), 1, 2, 0, 1, GTK_FILL, 0, 2, 4);
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
g_free(p_latlon);
gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Description")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-txt_scroll = gtk_scrolled_window_new(NULL, NULL);
+txt_scroll=gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(txt_scroll), GTK_SHADOW_IN);
gtk_table_attach(GTK_TABLE(table), txt_scroll, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-txt_desc = gtk_text_view_new();
+txt_desc=gtk_text_view_new();
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(txt_desc), GTK_WRAP_WORD);
gtk_container_add(GTK_CONTAINER(txt_scroll), txt_desc);
GtkTextBuffer *tbuf;
GtkTextIter ti1, ti2;
- tbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt_desc));
+ tbuf=gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt_desc));
gtk_text_buffer_get_iter_at_offset(tbuf, &ti1, 0);
gtk_text_buffer_get_end_iter(tbuf, &ti2);