]> err.no Git - mapper/commitdiff
Path: Add signals for near and reached waypoints
authorKaj-Michael Lang <milang@tal.org>
Thu, 31 Jul 2008 12:09:08 +0000 (15:09 +0300)
committerKaj-Michael Lang <milang@tal.org>
Thu, 31 Jul 2008 12:09:08 +0000 (15:09 +0300)
libs/libgtkmap/path.c
libs/libgtkmap/path.h

index 9d69c4473978299c32f794ebe6910376a8149f7e..7148d9e62ae9cead637a37d06a20cf1a452b060c 100644 (file)
@@ -160,8 +160,6 @@ static void path_class_init(PathClass *klass);
 static void path_init(Path *path);
 static gboolean path_resize(Path *path, guint size);
 
-static void path_check_waypoint_announce(Path *path);
-
 static void
 path_dispose(GObject *object)
 {
@@ -206,12 +204,23 @@ object_class->finalize=path_finalize;
 signals[NEW_POINT]=g_signal_new("new-point", G_OBJECT_CLASS_TYPE(object_class),
        G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(PathClass, new_point),
        NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL);
+
 signals[NEW_BREAK]=g_signal_new("new-break", G_OBJECT_CLASS_TYPE(object_class),
        G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(PathClass, new_break),
        NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL);
+
 signals[NEW_WAYPOINT]=g_signal_new("new-waypoint", G_OBJECT_CLASS_TYPE(object_class),
        G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(PathClass, new_waypoint),
        NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL);
+
+signals[NEAR_WAYPOINT]=g_signal_new("near-waypoint", G_OBJECT_CLASS_TYPE(object_class),
+       G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(PathClass, near_waypoint),
+       NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL);
+
+signals[REACHED_WAYPOINT]=g_signal_new("reached-waypoint", G_OBJECT_CLASS_TYPE(object_class),
+       G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(PathClass, reached_waypoint),
+       NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL);
+
 }
 
 static void
@@ -232,6 +241,7 @@ p=g_object_new(PATH_TYPE, NULL);
 p->type=type;
 p->id=id;
 p->sensitivity=3;
+p->announce_waypoints=FALSE;
 
 if (time1==0) {
        time1=time(NULL);
@@ -376,7 +386,6 @@ if (abs((gint)unitx-path->tail->unitx) > path->sensitivity || abs((gint)unity-pa
 }
 
 return FALSE;
-
 }
 
 /**
@@ -635,19 +644,23 @@ return NULL;
 /**
  * path_check_waypoint_announce:
  * @path
- * @lat
- * @lon
  *
  * Check if we should announce upcoming waypoint.
  *
  */
-static void
+void
 path_check_waypoint_announce(Path *path)
 {
 guint a_thres_near, a_thres_at;
 
 g_return_if_fail(path);
 
+if (!path->announce_waypoints)
+       return;
+
+if (path->whead==path->wtail)
+       return;
+
 if (!path->next_way)
        return;
 
index 668bf7525991e6043bd296aa865f614246304e28..b37ce24aa486062da0efc5b405874f98cea3a454 100644 (file)
@@ -135,9 +135,10 @@ struct _Path {
        Point *next_wpt;
        guint64 next_wpt_dist_squared;
 
-       /* The waypoint we last announced */
+       /* The waypoint announcements vars */
        WayPoint *announced_waypoint;
        gint announce_notice_ratio;
+       gboolean announce_waypoints;
 
        /* Path statistics */
        guint32 points;
@@ -165,6 +166,8 @@ struct _PathClass {
        void (*new_point) (Path *path);
        void (*new_break) (Path *path);
        void (*new_waypoint) (Path *path);
+       void (*near_waypoint) (Path *path);
+       void (*reached_waypoint) (Path *path);
 };
 
 /* Null point */
@@ -192,6 +195,7 @@ gboolean path_add_waypoint(Path *path, gdouble lat, gdouble lon, gchar *desc);
 
 gboolean path_has_points(Path *path);
 gboolean path_has_waypoints(Path *path);
+void path_check_waypoint_announce(Path *path);
 
 gboolean path_set_destination_from_last(Path *path, Position *pos);