]> err.no Git - mapper/commitdiff
Fix route save.
authorKaj-Michael Lang <milang@angel.tal.org>
Wed, 27 Jun 2007 13:27:25 +0000 (16:27 +0300)
committerKaj-Michael Lang <milang@angel.tal.org>
Wed, 27 Jun 2007 13:27:25 +0000 (16:27 +0300)
Move save operation from cb.c to route.c

src/cb.c
src/route.c
src/route.h

index 6d8a0e9af6a07b55618b181854caa47c272c15bd..aa08bdb646b03ed514a7bcfcb5b317575f915e7e 100644 (file)
--- a/src/cb.c
+++ b/src/cb.c
@@ -194,17 +194,9 @@ gboolean menu_cb_track_distfirst(GtkAction * action)
 
 gboolean menu_cb_route_save(GtkAction * action)
 {
-       GnomeVFSHandle *handle;
        printf("%s()\n", __PRETTY_FUNCTION__);
 
-       if (open_file(NULL, &handle, NULL, &_route_dir_uri, NULL,
-                     GTK_FILE_CHOOSER_ACTION_SAVE)) {
-               if (write_gpx(&_route, handle)) {
-                       MACRO_BANNER_SHOW_INFO(_window, _("Route Saved"));
-               } else
-                       popup_error(_window, _("Error writing GPX file."));
-               gnome_vfs_close(handle);
-       }
+       route_save();
 
        vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
        return TRUE;
index 48b7bd4d3cc247e33af971f7ee7407a63cf436f8..55e406d31b115ca75a995e186ea7f017d0f21e7c 100644 (file)
@@ -7,6 +7,7 @@
 #include <string.h>
 #include <strings.h>
 #include <stddef.h>
+#include <libintl.h>
 #include <locale.h>
 #include <math.h>
 #include <errno.h>
@@ -16,8 +17,6 @@
 #include <fcntl.h>
 #include <libgnomevfs/gnome-vfs.h>
 #include <curl/multi.h>
-#include <gconf/gconf-client.h>
-#include <libxml/parser.h>
 
 #include "utils.h"
 #include "gps.h"
@@ -43,25 +42,40 @@ struct _OriginToggleInfo {
 
 gboolean route_open_file()
 {
-       gchar *buffer;
-       gint size;
-
-       if (open_file(&buffer, NULL, &size, &_route_dir_uri, NULL,
-                     GTK_FILE_CHOOSER_ACTION_OPEN)) {
-               /* If auto is enabled, append the route, otherwise replace it. */
-               if (parse_gpx(&_route, buffer, size,
-                             _autoroute_data.enabled ? 0 : 1)) {
-                       cancel_autoroute(FALSE);
+gchar *buffer;
+gint size;
+
+if (open_file(&buffer, NULL, &size, &_route_dir_uri, NULL, GTK_FILE_CHOOSER_ACTION_OPEN)) {
+       /* If auto is enabled, append the route, otherwise replace it. */
+       if (parse_gpx(&_route, buffer, size, _autoroute_data.enabled ? 0 : 1)) {
+               cancel_autoroute(FALSE);
+
+               /* Find the nearest route point, if we're connected. */
+               route_find_nearest_point();
+
+               map_force_redraw();
+               MACRO_BANNER_SHOW_INFO(_window, _("Route Opened"));
+       } else
+               popup_error(_window, _("Error parsing GPX file."));
+       g_free(buffer);
+}
+}
 
-                       /* Find the nearest route point, if we're connected. */
-                       route_find_nearest_point();
+gboolean
+route_save(void)
+{
+GnomeVFSHandle *handle;
 
-                       map_force_redraw();
-                       MACRO_BANNER_SHOW_INFO(_window, _("Route Opened"));
-               } else
-                       popup_error(_window, _("Error parsing GPX file."));
-               g_free(buffer);
+if (file_save(_route_dir_uri, _route_dir_uri, &handle)) {
+       if (write_gpx(&_route, handle)) {
+               MACRO_BANNER_SHOW_INFO(_window, _("Route Saved"));
+       } else {
+               popup_error(_window, _("Error writing GPX file."));
        }
+       gnome_vfs_close(handle);
+       return TRUE;
+}
+return FALSE;
 }
 
 gboolean origin_type_selected(GtkWidget * toggle, OriginToggleInfo * oti)
@@ -191,15 +205,12 @@ gboolean auto_route_dl_idle()
 
 #ifdef WITH_HILDON
        if (_iap_connected && !_curl_sid)
-               _curl_sid = g_timeout_add(100,
-                                         (GSourceFunc) curl_download_timeout,
-                                         NULL);
 #else
        if (!_curl_sid)
+#endif
                _curl_sid = g_timeout_add(100,
                                          (GSourceFunc) curl_download_timeout,
                                          NULL);
-#endif
 
        _autoroute_data.in_progress = TRUE;
 
@@ -487,7 +498,7 @@ gboolean route_download(gchar * to)
        return TRUE;
 }
 
-WayPoint *find_nearest_waypoint(guint unitx, guint unity, guint _zoom)
+WayPoint *find_nearest_waypoint(guint unitx, guint unity)
 {
        WayPoint *wcurr;
        WayPoint *wnear;
index f83178c492e856f2df5a78c544cdbe8c74c7e651..448a29bd33ebd8a30805fceb0fd8b8382b73bfe1 100644 (file)
@@ -43,6 +43,11 @@ guint64 _next_wpt_dist_squared;
 /** The singleton auto-route-download data. */
 AutoRouteDownloadData _autoroute_data;
 
+gboolean route_open_file();
+gboolean route_save(void);
 gboolean auto_route_dl_idle();
+gboolean route_download(gchar * to);
+WayPoint *find_nearest_waypoint(guint unitx, guint unity);
+gboolean route_update_nears(gboolean quick);
 
 #endif