]> err.no Git - mapper/commitdiff
Move route_generate_store from route.c to path.c and rename to path_generate_store
authorKaj-Michael Lang <milang@onion.tal.org>
Wed, 13 Feb 2008 12:29:40 +0000 (14:29 +0200)
committerKaj-Michael Lang <milang@onion.tal.org>
Wed, 13 Feb 2008 12:29:40 +0000 (14:29 +0200)
src/cb.c
src/path.c
src/path.h
src/route.c
src/route.h

index e846a08268fa9d7604ef6ef97f4ff83548538039..28f269684104c8870ebe725eb6b3e3bea55f41b3 100644 (file)
--- a/src/cb.c
+++ b/src/cb.c
@@ -67,7 +67,7 @@ track_tree_view_update_store(GtkWidget *tree_view, Path *track)
 {
 GtkListStore *store;
 
-store=route_generate_store(track);
+store=path_generate_store(track);
 if (store!=NULL) {
        gtk_tree_view_set_model(tree_view, store);
        g_object_unref(G_OBJECT(store));
index 516a095fde86a6cbb6fd7df19b5d2ad95b638145..f5002ac6e00433772438a6a597a6827cc54fcacf 100644 (file)
@@ -1,12 +1,15 @@
 #include <config.h>
 
+#include <gtk/gtk.h>
+
 #include "utils.h"
 #include "map.h"
 #include "route.h"
 #include "mapper-types.h"
-
 #include "track.h"
 #include "path.h"
+#include "settings.h"
+#include "latlon.h"
 
 void 
 path_resize(Path *path, guint size)
@@ -36,3 +39,56 @@ if (path->whead + wsize != path->wcap) {
        path->wcap = path->whead + wsize;
 }
 }
+
+GtkListStore *
+path_generate_store(Path *path)
+{
+WayPoint *wcurr;
+GtkTreeIter iter;
+GtkListStore *store;
+gchar buffer1[80];
+gchar buffer2[32];
+gdouble lat1, lon1, lat2, lon2;
+gdouble sum=0.0;
+
+if (path->whead==path->wtail)
+       return NULL;
+
+wcurr=path->whead;
+
+if (!wcurr)
+       return NULL;
+
+if (!wcurr->point)
+       return NULL;
+
+unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat1, lon1);
+
+store = gtk_list_store_new(ROUTE_NUM_COLUMNS,G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
+
+while (wcurr!=path->wtail) {
+       if (!wcurr)
+               break;
+
+       unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat2, lon2);
+       g_snprintf(buffer1, sizeof(buffer1), "%.05f,%.05f", lat2, lon2);
+       sum += calculate_distance(lat1, lon1, lat2, lon2);
+       g_snprintf(buffer2, sizeof(buffer2), "%.02f %s", sum * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
+
+       gtk_list_store_append(store, &iter);
+       gtk_list_store_set(store, &iter,
+        ROUTE_LATLON, buffer1,
+               ROUTE_DISTANCE, buffer2,
+               ROUTE_WAYPOINT, wcurr->desc,
+               ROUTE_LAT, lat2,
+               ROUTE_LON, lon2,
+               -1);
+
+       lat1=lat2;
+       lon1=lon2;
+
+       wcurr++;
+}
+
+return store;
+}
index 12ed0ab82f0251639a8f78eb03d931f2418076f9..cba575b0abf962de0954c109a2011075ee0e6eff 100644 (file)
@@ -2,6 +2,7 @@
 #define _PATH_H
 
 #include <glib.h>
+#include <gtk/gtk.h>
 
 #define MACRO_PATH_INIT(path) { \
     (path).head = (path).tail = g_new(Point, ARRAY_CHUNK_SIZE); \
@@ -76,4 +77,6 @@ Position _dest;
 void path_resize(Path *path, guint size);
 void path_wresize(Path *path, guint wsize);
 
+GtkListStore *path_generate_store(Path *path);
+
 #endif
index 18cb83beff9e6f25ff7be8f51b2b652b4ebf8721..25a859bcee5fef2532a323201f0834b833a3d74d 100644 (file)
@@ -735,55 +735,3 @@ if (_route.head != _route.tail) {
 
 /***/
 
-GtkListStore *
-route_generate_store(Path *route)
-{
-WayPoint *wcurr;
-GtkTreeIter iter;
-GtkListStore *store;
-gchar buffer1[80];
-gchar buffer2[32];
-gdouble lat1, lon1, lat2, lon2;
-gdouble sum=0.0;
-
-if (route->whead==route->wtail)
-       return NULL;
-
-wcurr=route->whead;
-
-if (!wcurr)
-       return NULL;
-
-if (!wcurr->point)
-       return NULL;
-
-unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat1, lon1);
-
-store = gtk_list_store_new(ROUTE_NUM_COLUMNS,G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
-
-while (wcurr!=route->wtail) {
-       if (!wcurr)
-               break;
-
-       unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat2, lon2);
-       g_snprintf(buffer1, sizeof(buffer1), "%.05f,%.05f", lat2, lon2);
-       sum += calculate_distance(lat1, lon1, lat2, lon2);
-       g_snprintf(buffer2, sizeof(buffer2), "%.02f %s", sum * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
-
-       gtk_list_store_append(store, &iter);
-       gtk_list_store_set(store, &iter,
-        ROUTE_LATLON, buffer1,
-               ROUTE_DISTANCE, buffer2,
-               ROUTE_WAYPOINT, wcurr->desc,
-               ROUTE_LAT, lat2,
-               ROUTE_LON, lon2,
-               -1);
-
-       lat1=lat2;
-       lon1=lon2;
-
-       wcurr++;
-}
-
-return store;
-}
index 66f2acb1c2c16a62d969b3dea36b02f19326e536..ee4eae4257515e6eade33fb8d066e235800e1108 100644 (file)
@@ -55,6 +55,4 @@ void route_show_distance_to_last();
 void route_show_distance_to_next();
 gboolean route_show_distance_to(Point * point);
 
-GtkListStore *route_generate_store(Path *route);
-
 #endif