[libchamplain] Add test that simulates the use of GPS with libchamplain
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Add test that simulates the use of GPS with libchamplain
- Date: Tue, 23 Mar 2010 14:40:35 +0000 (UTC)
commit 835cd26008617685a1f64a580a6bb31de661f6cf
Author: JiÅ?Ã Techet <techet gmail com>
Date: Fri Mar 12 21:32:48 2010 +0100
Add test that simulates the use of GPS with libchamplain
This test uses champlain_view_center_on() to update the position on the
map and the position of the marker.
Signed-off-by: JiÅ?Ã Techet <techet gmail com>
demos/animated-marker.c | 34 ++++++++++++++++++++++++++++------
1 files changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/demos/animated-marker.c b/demos/animated-marker.c
index c241a14..e94031c 100644
--- a/demos/animated-marker.c
+++ b/demos/animated-marker.c
@@ -92,18 +92,34 @@ create_marker ()
clutter_timeline_start (timeline);
- /* Sets marker position on the map */
- champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker),
- 45.528178, -73.563788);
-
return marker;
}
+double lat = 45.466;
+double lon = -73.75;
+
+typedef struct
+{
+ ChamplainView *view;
+ ChamplainBaseMarker *marker;
+} GpsCallbackData;
+
+static gboolean
+gps_callback (GpsCallbackData *data)
+{
+ lat += 0.005;
+ lon += 0.005;
+ champlain_view_center_on (data->view, lat, lon);
+ champlain_base_marker_set_position (data->marker, lat, lon);
+ return TRUE;
+}
+
int
main (int argc, char *argv[])
{
ClutterActor* actor, *marker, *stage;
ChamplainLayer *layer;
+ GpsCallbackData callback_data;
g_thread_init (NULL);
clutter_init (&argc, &argv);
@@ -126,9 +142,15 @@ main (int argc, char *argv[])
clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
/* Finish initialising the map view */
- g_object_set (G_OBJECT (actor), "zoom-level", 5,
+ g_object_set (G_OBJECT (actor), "zoom-level", 12,
"scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC, NULL);
- champlain_view_center_on (CHAMPLAIN_VIEW (actor), 45.466, -73.75);
+ champlain_view_center_on (CHAMPLAIN_VIEW (actor), lat, lon);
+
+ /* Create callback that updates the map periodically */
+ callback_data.view = CHAMPLAIN_VIEW (actor);
+ callback_data.marker = CHAMPLAIN_BASE_MARKER (marker);
+
+ g_timeout_add (1000, (GSourceFunc) gps_callback, &callback_data);
clutter_actor_show (stage);
clutter_main ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]