+static gboolean
+route_download_swap(GtkWidget *button, RouteDownloadInfo *oti)
+{
+ gchar *old_origin;
+ printf("%s()\n", __PRETTY_FUNCTION__);
+
+ /* Save the old origin. */
+ old_origin = g_strdup(gtk_entry_get_text(GTK_ENTRY(oti->txt_from)));
+
+ /* Set the origin text field equal to the current destination. */
+ gtk_entry_set_text(GTK_ENTRY(oti->txt_from),
+ gtk_entry_get_text(GTK_ENTRY(oti->txt_to)));
+
+ /* Set the contents of the destination text field. */
+ if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(oti->rad_use_gps)))
+ {
+ /* "Use GPS Location" is enabled - set Destination to GPS Location */
+ gchar buffer[80];
+ gchar strlat[32];
+ gchar strlon[32];
+ g_ascii_formatd(strlat, 32, "%.06f", _gps.lat);
+ g_ascii_formatd(strlon, 32, "%.06f", _gps.lon);
+ snprintf(buffer, sizeof(buffer), "%s, %s", strlat, strlon);
+ gtk_entry_set_text(GTK_ENTRY(oti->txt_to), buffer);
+ }
+ else if(gtk_toggle_button_get_active(
+ GTK_TOGGLE_BUTTON(oti->rad_use_route)))
+ {
+ /* "Use End of Route" is enabled - set Destination to start of route */
+ gchar buffer[80];
+ gchar strlat[32];
+ gchar strlon[32];
+ Point *p;
+ gdouble lat, lon;
+
+ /* Use first non-zero route point. */
+ for(p = _route.head; !p->unity; p++) { }
+
+ unit2latlon(p->unitx, p->unity, lat, lon);
+ g_ascii_formatd(strlat, 32, "%.06f", lat);
+ g_ascii_formatd(strlon, 32, "%.06f", lon);
+ snprintf(buffer, sizeof(buffer), "%s, %s", strlat, strlon);
+ gtk_entry_set_text(GTK_ENTRY(oti->txt_to), buffer);
+ }
+ else if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(oti->rad_use_text)))
+ {
+ /* "Origin" is enabled - just use the text. */
+ gtk_entry_set_text(GTK_ENTRY(oti->txt_to), old_origin);
+ }
+
+ g_free(old_origin);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oti->rad_use_text), TRUE);
+
+ vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
+ return TRUE;
+}
+