From d3dd7082960c0dca984405f2393dafa6056e36a8 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Fri, 10 Aug 2007 10:05:32 +0300 Subject: [PATCH] Confirm Route clear operation. Formating. --- src/cb.c | 6 +----- src/route.c | 50 +++++++++++++++++++++++++++++++++++++++----------- src/route.h | 5 ++++- src/track.c | 3 +-- 4 files changed, 45 insertions(+), 19 deletions(-) diff --git a/src/cb.c b/src/cb.c index e5a1d1b..72a8774 100644 --- a/src/cb.c +++ b/src/cb.c @@ -118,11 +118,7 @@ gboolean menu_cb_route_clear(GtkAction * action) { printf("%s()\n", __PRETTY_FUNCTION__); - cancel_autoroute(FALSE); - MACRO_PATH_FREE(_route); - MACRO_PATH_INIT(_route); - route_find_nearest_point(); - map_force_redraw(); + route_clear(); vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__); return TRUE; diff --git a/src/route.c b/src/route.c index daf865e..e33920d 100644 --- a/src/route.c +++ b/src/route.c @@ -41,7 +41,25 @@ struct _OriginToggleInfo { GtkWidget *txt_to; }; -gboolean route_open_file() +void +route_clear(void) +{ +GtkWidget *confirm; + +confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), _("Really clear the route?")); + +if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) { + cancel_autoroute(FALSE); + MACRO_PATH_FREE(_route); + MACRO_PATH_INIT(_route); + route_find_nearest_point(); + map_force_redraw(); +} +gtk_widget_destroy(confirm); +} + +gboolean +route_open_file() { gchar *buffer; gint size; @@ -83,7 +101,8 @@ if (file_save(&_route_dir_uri, &_route_dir_uri, &handle)) { return FALSE; } -gboolean origin_type_selected(GtkWidget * toggle, OriginToggleInfo * oti) +gboolean +origin_type_selected(GtkWidget * toggle, OriginToggleInfo * oti) { printf("%s()\n", __PRETTY_FUNCTION__); @@ -128,7 +147,8 @@ gboolean origin_type_selected(GtkWidget * toggle, OriginToggleInfo * oti) /** * Cancel the current auto-route. */ -void cancel_autoroute(gboolean temporary) +void +cancel_autoroute(gboolean temporary) { printf("%s()\n", __PRETTY_FUNCTION__); @@ -180,7 +200,8 @@ route_dl_cb_read(void *ptr, size_t size, size_t nmemb, return (size * nmemb); } -gboolean auto_route_dl_idle() +gboolean +auto_route_dl_idle() { gchar latstr[32], lonstr[32], *latlonstr; printf("%s(%f, %f, %s)\n", __PRETTY_FUNCTION__, @@ -232,7 +253,8 @@ gboolean auto_route_dl_idle() * None of the passed strings are freed - that is left to the caller, and it is * safe to free either string as soon as this function returns. */ -gboolean route_download(gchar * to) +gboolean +route_download(gchar * to) { GtkWidget *dialog; GtkWidget *table; @@ -486,7 +508,8 @@ gboolean route_download(gchar * to) return TRUE; } -WayPoint *find_nearest_waypoint(guint unitx, guint unity) +WayPoint * +find_nearest_waypoint(guint unitx, guint unity) { WayPoint *wcurr; WayPoint *wnear; @@ -530,7 +553,8 @@ WayPoint *find_nearest_waypoint(guint unitx, guint unity) * the entire list (starting from _near_point) is searched. Otherwise, we * stop searching when we find a point that is farther away. */ -gboolean route_update_nears(gboolean quick) +gboolean +route_update_nears(gboolean quick) { gboolean ret = FALSE; Point *curr, *near; @@ -641,7 +665,8 @@ gboolean route_update_nears(gboolean quick) * Reset the _near_point data by searching the entire route for the nearest * route point and waypoint. */ -void route_find_nearest_point() +void +route_find_nearest_point() { printf("%s()\n", __PRETTY_FUNCTION__); @@ -674,7 +699,8 @@ void route_find_nearest_point() * following the route. If point is NULL, then the distance is shown to the * next waypoint. */ -gboolean route_show_distance_to(Point * point) +gboolean +route_show_distance_to(Point * point) { gchar buffer[80]; gfloat lat1, lon1, lat2, lon2; @@ -730,7 +756,8 @@ gboolean route_show_distance_to(Point * point) printf("%s(): return TRUE\n", __PRETTY_FUNCTION__); } -void route_show_distance_to_next() +void +route_show_distance_to_next() { printf("%s()\n", __PRETTY_FUNCTION__); @@ -741,7 +768,8 @@ void route_show_distance_to_next() printf("%s(): return\n", __PRETTY_FUNCTION__); } -void route_show_distance_to_last() +void +route_show_distance_to_last() { printf("%s()\n", __PRETTY_FUNCTION__); diff --git a/src/route.h b/src/route.h index 448a29b..fb4082f 100644 --- a/src/route.h +++ b/src/route.h @@ -45,9 +45,12 @@ AutoRouteDownloadData _autoroute_data; gboolean route_open_file(); gboolean route_save(void); +void route_clear(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); - +void route_show_distance_to_last(); +void route_show_distance_to_next(); +gboolean route_show_distance_to(Point * point); #endif diff --git a/src/track.c b/src/track.c index c255470..c667f76 100644 --- a/src/track.c +++ b/src/track.c @@ -28,8 +28,7 @@ track_clear(void) { GtkWidget *confirm; - confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), - _("Really clear the track?")); + confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), _("Really clear the track?")); if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) { _track.tail = _track.head; -- 2.39.5