From: Kaj-Michael Lang Date: Thu, 31 Jul 2008 12:09:08 +0000 (+0300) Subject: Path: Add signals for near and reached waypoints X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=513c6b25183734a6b36be340a366369f18368a51;p=mapper Path: Add signals for near and reached waypoints --- diff --git a/libs/libgtkmap/path.c b/libs/libgtkmap/path.c index 9d69c44..7148d9e 100644 --- a/libs/libgtkmap/path.c +++ b/libs/libgtkmap/path.c @@ -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; diff --git a/libs/libgtkmap/path.h b/libs/libgtkmap/path.h index 668bf75..b37ce24 100644 --- a/libs/libgtkmap/path.h +++ b/libs/libgtkmap/path.h @@ -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);