From: Pierre-Luc Beaudoin Date: Thu, 29 Jan 2009 21:03:14 +0000 (+0200) Subject: Apply coding convention X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b048b8b9a075ca076958067e5a9daf4093c83cc6;p=libchamplain Apply coding convention --- diff --git a/champlain/champlainmarker.c b/champlain/champlainmarker.c index ba1b5af..b938e77 100644 --- a/champlain/champlainmarker.c +++ b/champlain/champlainmarker.c @@ -71,46 +71,52 @@ enum G_DEFINE_TYPE (ChamplainMarker, champlain_marker, CLUTTER_TYPE_GROUP); static void -champlain_marker_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +champlain_marker_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - ChamplainMarker *marker = CHAMPLAIN_MARKER(object); + ChamplainMarker *marker = CHAMPLAIN_MARKER (object); ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker); - switch(prop_id) + switch (prop_id) { case PROP_LONGITUDE: - g_value_set_double(value, priv->lon); + g_value_set_double (value, priv->lon); break; case PROP_LATITUDE: - g_value_set_double(value, priv->lat); + g_value_set_double (value, priv->lat); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void -champlain_marker_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +champlain_marker_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { - ChamplainMarker *marker = CHAMPLAIN_MARKER(object); + ChamplainMarker *marker = CHAMPLAIN_MARKER (object); ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker); - switch(prop_id) + switch (prop_id) { case PROP_LONGITUDE: { - gdouble lon = g_value_get_double(value); - champlain_marker_set_position(marker, lon, priv->lat); + gdouble lon = g_value_get_double (value); + champlain_marker_set_position (marker, lon, priv->lat); break; } case PROP_LATITUDE: { - gdouble lat = g_value_get_double(value); - champlain_marker_set_position(marker, priv->lon, lat); + gdouble lat = g_value_get_double (value); + champlain_marker_set_position (marker, priv->lon, lat); break; } default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } @@ -140,8 +146,8 @@ champlain_marker_class_init (ChamplainMarkerClass *champlainMarkerClass) * * Since: 0.2 */ - g_object_class_install_property(object_class, PROP_LONGITUDE, - g_param_spec_double("longitude", + g_object_class_install_property (object_class, PROP_LONGITUDE, + g_param_spec_double ("longitude", "Longitude", "The longitude coordonate of the marker", -180.0f, @@ -156,8 +162,8 @@ champlain_marker_class_init (ChamplainMarkerClass *champlainMarkerClass) * * Since: 0.2 */ - g_object_class_install_property(object_class, PROP_LATITUDE, - g_param_spec_double("latitude", + g_object_class_install_property (object_class, PROP_LATITUDE, + g_param_spec_double ("latitude", "Latitude", "The latitude coordonate of the marker", -90.0f, @@ -205,15 +211,15 @@ champlain_marker_new () void champlain_marker_set_position (ChamplainMarker *champlainMarker, gdouble latitude, gdouble longitude) { - g_return_if_fail(CHAMPLAIN_IS_MARKER(champlainMarker)); + g_return_if_fail (CHAMPLAIN_IS_MARKER (champlainMarker)); ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (champlainMarker); priv->lon = longitude; priv->lat = latitude; - g_object_notify(G_OBJECT(champlainMarker), "latitude"); - g_object_notify(G_OBJECT(champlainMarker), "longitude"); + g_object_notify (G_OBJECT (champlainMarker), "latitude"); + g_object_notify (G_OBJECT (champlainMarker), "longitude"); } /** @@ -233,7 +239,7 @@ champlain_marker_new_with_label (const gchar *label, ClutterColor *text_color, ClutterColor *marker_color) { - ChamplainMarker *champlainMarker = CHAMPLAIN_MARKER(champlain_marker_new ()); + ChamplainMarker *champlainMarker = CHAMPLAIN_MARKER (champlain_marker_new ()); ClutterColor default_text_color = { 0x22, 022, 0x22, 0xFF }, default_marker_color = { 0x2A, 0xB1, 0x26, 0xEE }, darker_color; @@ -253,8 +259,8 @@ champlain_marker_new_with_label (const gchar *label, clutter_actor_set_position (actor, padding, padding / 2.0); text_width = clutter_actor_get_width (actor) + 2 * padding; text_height = clutter_actor_get_height (actor)+ padding; - clutter_label_set_color (CLUTTER_LABEL(actor), text_color); - clutter_container_add_actor (CLUTTER_CONTAINER(champlainMarker), actor); + clutter_label_set_color (CLUTTER_LABEL (actor), text_color); + clutter_container_add_actor (CLUTTER_CONTAINER (champlainMarker), actor); point = (text_height + 2 * padding) / 4.0; @@ -286,10 +292,10 @@ champlain_marker_new_with_label (const gchar *label, cairo_destroy (cr); - clutter_container_add_actor (CLUTTER_CONTAINER(champlainMarker), bg); + clutter_container_add_actor (CLUTTER_CONTAINER (champlainMarker), bg); clutter_actor_raise (actor, bg); - clutter_actor_set_anchor_point (CLUTTER_ACTOR(champlainMarker), 0, text_height + point); + clutter_actor_set_anchor_point (CLUTTER_ACTOR (champlainMarker), 0, text_height + point); return CLUTTER_ACTOR (champlainMarker); } @@ -298,27 +304,28 @@ champlain_marker_new_with_label (const gchar *label, * champlain_marker_new_with_image: * @filename: The filename of the image. * @error: Return location for an error. - * - * Returns a new #ChamplainMarker with a drawn marker containing the given image. + * + * Returns a new #ChamplainMarker with a drawn marker containing the given + * image. * */ ClutterActor * -champlain_marker_new_with_image(const gchar *filename, GError **error) +champlain_marker_new_with_image (const gchar *filename, GError **error) { - if (filename == NULL) - return NULL; + if (filename == NULL) + return NULL; + + ChamplainMarker *champlainMarker = CHAMPLAIN_MARKER (champlain_marker_new ()); + ClutterActor *actor = clutter_texture_new_from_file (filename, error); - ChamplainMarker *champlainMarker = CHAMPLAIN_MARKER(champlain_marker_new ()); - ClutterActor *actor = clutter_texture_new_from_file(filename, error); + if (actor == NULL){ + g_object_unref (G_OBJECT (champlainMarker)); + return NULL; + } - if (actor == NULL){ - g_object_unref(G_OBJECT(champlainMarker)); - return NULL; - } + clutter_container_add_actor (CLUTTER_CONTAINER (champlainMarker), actor); - clutter_container_add_actor (CLUTTER_CONTAINER(champlainMarker), actor); - - return CLUTTER_ACTOR (champlainMarker); + return CLUTTER_ACTOR (champlainMarker); } /** @@ -330,28 +337,36 @@ champlain_marker_new_with_image(const gchar *filename, GError **error) * @anchor_y: Y coordinate of the anchor point. * @error: Return location for an error. * - * Returns a new #ChamplainMarker with a drawn marker containing the given image. + * Returns a new #ChamplainMarker with a drawn marker containing the given + * image. * */ ClutterActor * -champlain_marker_new_with_image_full(const gchar *filename, gint width, gint height, gint anchor_x, gint anchor_y, GError **error) +champlain_marker_new_with_image_full (const gchar *filename, + gint width, + gint height, + gint anchor_x, + gint anchor_y, + GError **error) { - if(filename == NULL) - return NULL; + if (filename == NULL) + return NULL; - ChamplainMarker *champlainMarker = CHAMPLAIN_MARKER(champlain_marker_new()); - ClutterActor *actor = clutter_texture_new_from_file(filename, error); + ChamplainMarker *champlainMarker = CHAMPLAIN_MARKER (champlain_marker_new ()); + ClutterActor *actor = clutter_texture_new_from_file (filename, error); - if(actor == NULL){ - g_object_unref(G_OBJECT(champlainMarker)); - return NULL; - } + if (actor == NULL) + { + g_object_unref (G_OBJECT (champlainMarker)); + return NULL; + } - clutter_actor_set_size(actor, width, height); + clutter_actor_set_size (actor, width, height); - clutter_container_add_actor(CLUTTER_CONTAINER(champlainMarker), actor); - clutter_actor_set_anchor_point(CLUTTER_ACTOR(champlainMarker), anchor_x, anchor_y); + clutter_container_add_actor (CLUTTER_CONTAINER (champlainMarker), actor); + clutter_actor_set_anchor_point (CLUTTER_ACTOR (champlainMarker), anchor_x, + anchor_y); - return CLUTTER_ACTOR(champlainMarker); + return CLUTTER_ACTOR (champlainMarker); } diff --git a/champlain/champlainmarker.h b/champlain/champlainmarker.h index 7708547..887fea2 100644 --- a/champlain/champlainmarker.h +++ b/champlain/champlainmarker.h @@ -53,20 +53,16 @@ GType champlain_marker_get_type (void); ClutterActor *champlain_marker_new (); -void champlain_marker_set_position (ChamplainMarker *marker, gdouble longitude, gdouble latitude); +void champlain_marker_set_position (ChamplainMarker *marker, + gdouble longitude, gdouble latitude); ClutterActor *champlain_marker_new_with_label (const gchar *label, - const gchar *font, - ClutterColor *text_color, - ClutterColor *marker_color); + const gchar *font, ClutterColor *text_color, ClutterColor *marker_color); -ClutterActor *champlain_marker_new_with_image(const gchar *filename, - GError **error); +ClutterActor *champlain_marker_new_with_image(const gchar *filename, + GError **error); ClutterActor *champlain_marker_new_with_image_full(const gchar *filename, - gint width, - gint height, - gint anchor_x, - gint anchor_y, - GError **error); + gint width, gint height, gint anchor_x, gint anchor_y, GError **error); + #endif diff --git a/champlain/champlainview.c b/champlain/champlainview.c index eaec4ed..bca6db4 100644 --- a/champlain/champlainview.c +++ b/champlain/champlainview.c @@ -42,8 +42,8 @@ * offline mode). * * The button-press-event and button-release-event signals are emitted each - * time a mouse button is pressed on the @view. Coordinates can be converted with - * #champlain_view_get_coords_from_event. + * time a mouse button is pressed on the @view. Coordinates can be converted + * with #champlain_view_get_coords_from_event. */ #include "config.h" @@ -88,15 +88,17 @@ enum #define PADDING 10 //static guint signals[LAST_SIGNAL] = { 0, }; -#define CHAMPLAIN_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_VIEW, ChamplainViewPrivate)) +#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CHAMPLAIN_TYPE_VIEW, ChamplainViewPrivate)) + struct _ChamplainViewPrivate { ClutterActor *stage; ChamplainMapSource map_source; - gint zoom_level; // only used when the zoom-level property is set before map is created + gint zoom_level; /* Only used when the zoom-level property is set before map + * is created */ - // Represents the (lat, lon) at the center of the viewport + /* Represents the (lat, lon) at the center of the viewport */ gdouble longitude; gdouble latitude; @@ -117,79 +119,89 @@ struct _ChamplainViewPrivate G_DEFINE_TYPE (ChamplainView, champlain_view, CLUTTER_TYPE_GROUP); -static gdouble viewport_get_current_longitude(ChamplainViewPrivate *priv); -static gdouble viewport_get_current_latitude(ChamplainViewPrivate *priv); -static gdouble viewport_get_longitude_at(ChamplainViewPrivate *priv, gint x); -static gdouble viewport_get_latitude_at(ChamplainViewPrivate *priv, gint y); -static gboolean scroll_event (ClutterActor *actor, ClutterScrollEvent *event, ChamplainView *view); +static gdouble viewport_get_current_longitude (ChamplainViewPrivate *priv); +static gdouble viewport_get_current_latitude (ChamplainViewPrivate *priv); +static gdouble viewport_get_longitude_at (ChamplainViewPrivate *priv, gint x); +static gdouble viewport_get_latitude_at (ChamplainViewPrivate *priv, gint y); +static gboolean scroll_event (ClutterActor *actor, ClutterScrollEvent *event, + ChamplainView *view); static void marker_reposition_cb (ChamplainMarker *marker, ChamplainView *view); static void layer_reposition_cb (ClutterActor *layer, ChamplainView *view); static void marker_reposition (ChamplainView *view); -static void create_initial_map(ChamplainView *view); -static void resize_viewport(ChamplainView *view); -static void champlain_view_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void champlain_view_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); +static void create_initial_map (ChamplainView *view); +static void resize_viewport (ChamplainView *view); +static void champlain_view_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec); +static void champlain_view_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec); static void champlain_view_finalize (GObject *object); static void champlain_view_class_init (ChamplainViewClass *champlainViewClass); static void champlain_view_init (ChamplainView *view); -static void viewport_x_changed_cb(GObject *gobject, GParamSpec *arg1, ChamplainView *view); -static void notify_marker_reposition_cb(ChamplainMarker *marker, GParamSpec *arg1, ChamplainView *view); -static void layer_add_marker_cb (ClutterGroup *layer, ChamplainMarker *marker, ChamplainView *view); -static void connect_marker_notify_cb (ChamplainMarker *marker, ChamplainView *view); +static void viewport_x_changed_cb (GObject *gobject, GParamSpec *arg1, + ChamplainView *view); +static void notify_marker_reposition_cb (ChamplainMarker *marker, + GParamSpec *arg1, ChamplainView *view); +static void layer_add_marker_cb (ClutterGroup *layer, ChamplainMarker *marker, + ChamplainView *view); +static void connect_marker_notify_cb (ChamplainMarker *marker, + ChamplainView *view); static gboolean finger_scroll_button_press_cb (ClutterActor *actor, ClutterButtonEvent *event, ChamplainView *view); static void update_license (ChamplainView *view); static void license_set_position (ChamplainView *view); static gdouble -viewport_get_longitude_at(ChamplainViewPrivate *priv, gint x) +viewport_get_longitude_at (ChamplainViewPrivate *priv, gint x) { if (!priv->map) return 0.0; - return priv->map->x_to_longitude(priv->map, x, priv->map->current_level->level); + return priv->map->x_to_longitude (priv->map, x, + priv->map->current_level->level); } static gdouble -viewport_get_current_longitude(ChamplainViewPrivate *priv) +viewport_get_current_longitude (ChamplainViewPrivate *priv) { if (!priv->map) return 0.0; - return viewport_get_longitude_at(priv, - priv->map->current_level->anchor.x + priv->viewport_size.x + priv->viewport_size.width / 2.0); + return viewport_get_longitude_at (priv, priv->map->current_level->anchor.x + + priv->viewport_size.x + priv->viewport_size.width / 2.0); } static gdouble -viewport_get_latitude_at(ChamplainViewPrivate *priv, gint y) +viewport_get_latitude_at (ChamplainViewPrivate *priv, gint y) { if (!priv->map) return 0.0; - return priv->map->y_to_latitude(priv->map, y, priv->map->current_level->level); + return priv->map->y_to_latitude (priv->map, y, + priv->map->current_level->level); } static gdouble -viewport_get_current_latitude(ChamplainViewPrivate *priv) +viewport_get_current_latitude (ChamplainViewPrivate *priv) { if (!priv->map) return 0.0; - return viewport_get_latitude_at(priv, - priv->map->current_level->anchor.y + priv->viewport_size.y + priv->viewport_size.height / 2.0); + return viewport_get_latitude_at (priv, + priv->map->current_level->anchor.y + priv->viewport_size.y + + priv->viewport_size.height / 2.0); } static gboolean scroll_event (ClutterActor *actor, ClutterScrollEvent *event, ChamplainView *view) { - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + ChamplainViewPrivate *priv = GET_PRIVATE (view); ClutterActor *group = priv->map->current_level->group; gboolean success = FALSE; // Keep the lon, lat where the mouse is - gdouble lon = viewport_get_longitude_at(priv, + gdouble lon = viewport_get_longitude_at (priv, priv->viewport_size.x + event->x + priv->map->current_level->anchor.x); - gdouble lat = viewport_get_latitude_at(priv, + gdouble lat = viewport_get_latitude_at (priv, priv->viewport_size.y + event->y + priv->map->current_level->anchor.y); // How far was it from the center of the viewport (in px) @@ -197,139 +209,156 @@ scroll_event (ClutterActor *actor, ClutterScrollEvent *event, ChamplainView *vie gint y_diff = priv->viewport_size.height / 2 - event->y; if (event->direction == CLUTTER_SCROLL_UP) - success = map_zoom_in(priv->map); - else if (event->direction == CLUTTER_SCROLL_DOWN) - success = map_zoom_out(priv->map); + success = map_zoom_in (priv->map); + else if (event->direction == CLUTTER_SCROLL_DOWN) + success = map_zoom_out (priv->map); if (success) { - // Get the new x,y in the new zoom level - gint x2 = priv->map->longitude_to_x(priv->map, lon, priv->map->current_level->level); - gint y2 = priv->map->latitude_to_y(priv->map, lat, priv->map->current_level->level); - // Get the new lon,lat of these new x,y minus the distance from the viewport center - gdouble lon2 = priv->map->x_to_longitude(priv->map, x2 + x_diff, priv->map->current_level->level); - gdouble lat2 = priv->map->y_to_latitude(priv->map, y2 + y_diff, priv->map->current_level->level); - - resize_viewport(view); - clutter_container_remove_actor (CLUTTER_CONTAINER (priv->map_layer), group); - clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), priv->map->current_level->group); - champlain_view_center_on(view, lat2, lon2); - - g_object_notify(G_OBJECT(view), "zoom-level"); + /* Get the new x,y in the new zoom level */ + gint x2 = priv->map->longitude_to_x (priv->map, lon, + priv->map->current_level->level); + gint y2 = priv->map->latitude_to_y (priv->map, lat, + priv->map->current_level->level); + /* Get the new lon,lat of these new x,y minus the distance from the + * viewport center */ + gdouble lon2 = priv->map->x_to_longitude (priv->map, x2 + x_diff, + priv->map->current_level->level); + gdouble lat2 = priv->map->y_to_latitude (priv->map, y2 + y_diff, + priv->map->current_level->level); + + resize_viewport (view); + clutter_container_remove_actor (CLUTTER_CONTAINER (priv->map_layer), + group); + clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), + priv->map->current_level->group); + champlain_view_center_on (view, lat2, lon2); + + g_object_notify (G_OBJECT (view), "zoom-level"); } - + return success; } static void -marker_reposition_cb (ChamplainMarker *marker, ChamplainView *view) +marker_reposition_cb (ChamplainMarker *marker, + ChamplainView *view) { - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + ChamplainViewPrivate *priv = GET_PRIVATE (view); ChamplainMarkerPrivate *marker_priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker); gint x, y; - if(priv->map) + if (priv->map) { - x = priv->map->longitude_to_x(priv->map, marker_priv->lon, priv->map->current_level->level); - y = priv->map->latitude_to_y(priv->map, marker_priv->lat, priv->map->current_level->level); + x = priv->map->longitude_to_x (priv->map, marker_priv->lon, priv->map->current_level->level); + y = priv->map->latitude_to_y (priv->map, marker_priv->lat, priv->map->current_level->level); - clutter_actor_set_position(CLUTTER_ACTOR(marker), + clutter_actor_set_position (CLUTTER_ACTOR (marker), x - priv->map->current_level->anchor.x, y - priv->map->current_level->anchor.y); } } static void -notify_marker_reposition_cb(ChamplainMarker *marker, GParamSpec *arg1, ChamplainView *view) +notify_marker_reposition_cb (ChamplainMarker *marker, + GParamSpec *arg1, + ChamplainView *view) { - marker_reposition_cb(marker, view); + marker_reposition_cb (marker, view); } static void -layer_add_marker_cb (ClutterGroup *layer, ChamplainMarker *marker, ChamplainView *view) +layer_add_marker_cb (ClutterGroup *layer, + ChamplainMarker *marker, + ChamplainView *view) { - g_signal_connect (marker, - "notify::longitude", - G_CALLBACK (notify_marker_reposition_cb), - view); - marker_reposition(view); + g_signal_connect (marker, "notify::longitude", + G_CALLBACK (notify_marker_reposition_cb), view); + + marker_reposition (view); } static void -connect_marker_notify_cb (ChamplainMarker *marker, ChamplainView *view) +connect_marker_notify_cb (ChamplainMarker *marker, + ChamplainView *view) { - g_signal_connect (marker, - "notify::longitude", - G_CALLBACK (notify_marker_reposition_cb), - view); + g_signal_connect (marker, "notify::longitude", + G_CALLBACK (notify_marker_reposition_cb), view); } static void -layer_reposition_cb (ClutterActor *layer, ChamplainView *view) +layer_reposition_cb (ClutterActor *layer, + ChamplainView *view) { - clutter_container_foreach(CLUTTER_CONTAINER(layer), CLUTTER_CALLBACK(marker_reposition_cb), view); + clutter_container_foreach (CLUTTER_CONTAINER (layer), + CLUTTER_CALLBACK (marker_reposition_cb), view); } static void marker_reposition (ChamplainView *view) { - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); - clutter_container_foreach(CLUTTER_CONTAINER(priv->user_layers), CLUTTER_CALLBACK(layer_reposition_cb), view); + ChamplainViewPrivate *priv = GET_PRIVATE (view); + clutter_container_foreach (CLUTTER_CONTAINER (priv->user_layers), + CLUTTER_CALLBACK (layer_reposition_cb), view); } static void -create_initial_map(ChamplainView *view) +create_initial_map (ChamplainView *view) { - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); - priv->map = map_new(priv->map_source); - map_load_level(priv->map, priv->zoom_level); - clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), priv->map->current_level->group); + ChamplainViewPrivate *priv = GET_PRIVATE (view); + priv->map = map_new (priv->map_source); + map_load_level (priv->map, priv->zoom_level); + clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), + priv->map->current_level->group); - marker_reposition(view); + marker_reposition (view); update_license (view); - g_object_notify(G_OBJECT(view), "zoom-level"); - g_object_notify(G_OBJECT(view), "map-source"); + g_object_notify (G_OBJECT (view), "zoom-level"); + g_object_notify (G_OBJECT (view), "map-source"); } static void license_set_position (ChamplainView *view) { - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + ChamplainViewPrivate *priv = GET_PRIVATE (view); guint width, height; if (!priv->license_actor) return; clutter_actor_get_size (priv->license_actor, &width, &height); - clutter_actor_set_position (priv->license_actor, priv->viewport_size.width - PADDING - width, priv->viewport_size.height - PADDING - height); + clutter_actor_set_position (priv->license_actor, priv->viewport_size.width - + PADDING - width, priv->viewport_size.height - PADDING - height); } - + static void -resize_viewport(ChamplainView *view) +resize_viewport (ChamplainView *view) { gdouble lower, upper; gboolean center = FALSE; TidyAdjustment *hadjust, *vadjust; - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + ChamplainViewPrivate *priv = GET_PRIVATE (view); - if(!priv->map) + if (!priv->map) { - create_initial_map(view); + create_initial_map (view); center = TRUE; } clutter_actor_set_size (priv->finger_scroll, priv->viewport_size.width, priv->viewport_size.height); - tidy_scrollable_get_adjustments (TIDY_SCROLLABLE (priv->viewport), &hadjust, &vadjust); + tidy_scrollable_get_adjustments (TIDY_SCROLLABLE (priv->viewport), &hadjust, + &vadjust); if (priv->map->current_level->level < 8) { lower = -priv->viewport_size.width / 2.0; - upper = zoom_level_get_width(priv->map->current_level) - priv->viewport_size.width / 2.0; + upper = zoom_level_get_width (priv->map->current_level) - + priv->viewport_size.width / 2.0; } else { @@ -337,12 +366,13 @@ resize_viewport(ChamplainView *view) upper = G_MAXINT16; } g_object_set (hadjust, "lower", lower, "upper", upper, - "step-increment", 1.0, "elastic", TRUE, NULL); + "step-increment", 1.0, "elastic", TRUE, NULL); if (priv->map->current_level->level < 8) { lower = -priv->viewport_size.height / 2.0; - upper = zoom_level_get_height(priv->map->current_level) - priv->viewport_size.height / 2.0; + upper = zoom_level_get_height (priv->map->current_level) - + priv->viewport_size.height / 2.0; } else { @@ -354,67 +384,70 @@ resize_viewport(ChamplainView *view) if (center) { - champlain_view_center_on(view, priv->latitude, priv->longitude); + champlain_view_center_on (view, priv->latitude, priv->longitude); } } static void -champlain_view_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +champlain_view_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - ChamplainView *view = CHAMPLAIN_VIEW(object); - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + ChamplainView *view = CHAMPLAIN_VIEW (object); + ChamplainViewPrivate *priv = GET_PRIVATE (view); - switch(prop_id) + switch (prop_id) { case PROP_LONGITUDE: - g_value_set_double(value, viewport_get_current_longitude(priv)); + g_value_set_double (value, viewport_get_current_longitude (priv)); break; case PROP_LATITUDE: - g_value_set_double(value, viewport_get_current_latitude(priv)); + g_value_set_double (value, viewport_get_current_latitude (priv)); break; case PROP_ZOOM_LEVEL: { if (priv->map) { - g_value_set_int(value, priv->map->current_level->level); + g_value_set_int (value, priv->map->current_level->level); } else { - g_value_set_int(value, 0); + g_value_set_int (value, 0); } break; } case PROP_MAP_SOURCE: - g_value_set_int(value, priv->map_source); + g_value_set_int (value, priv->map_source); break; case PROP_OFFLINE: - g_value_set_boolean(value, priv->offline); + g_value_set_boolean (value, priv->offline); break; case PROP_DECEL_RATE: { gdouble decel; g_object_get (priv->finger_scroll, "decel-rate", decel, NULL); - g_value_set_double(value, decel); + g_value_set_double (value, decel); break; } case PROP_KEEP_CENTER_ON_RESIZE: - g_value_set_boolean(value, priv->keep_center_on_resize); + g_value_set_boolean (value, priv->keep_center_on_resize); break; case PROP_SHOW_LICENSE: - g_value_set_boolean(value, priv->show_license); + g_value_set_boolean (value, priv->show_license); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void -champlain_view_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +champlain_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - ChamplainView *view = CHAMPLAIN_VIEW(object); - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + ChamplainView *view = CHAMPLAIN_VIEW (object); + ChamplainViewPrivate *priv = GET_PRIVATE (view); - switch(prop_id) + switch (prop_id) { case PROP_LONGITUDE: { @@ -428,18 +461,18 @@ champlain_view_set_property(GObject *object, guint prop_id, const GValue *value, } case PROP_ZOOM_LEVEL: { - gint level = g_value_get_int(value); + gint level = g_value_get_int (value); if (priv->map) { if (level != priv->map->current_level->level) { ClutterActor *group = priv->map->current_level->group; - if (map_zoom_to(priv->map, level)) + if (map_zoom_to (priv->map, level)) { - resize_viewport(view); + resize_viewport (view); clutter_container_remove_actor (CLUTTER_CONTAINER (priv->map_layer), group); clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), priv->map->current_level->group); - champlain_view_center_on(view, priv->latitude, priv->longitude); + champlain_view_center_on (view, priv->latitude, priv->longitude); } } } @@ -451,52 +484,52 @@ champlain_view_set_property(GObject *object, guint prop_id, const GValue *value, } case PROP_MAP_SOURCE: { - ChamplainMapSource source = g_value_get_int(value); + ChamplainMapSource source = g_value_get_int (value); if (priv->map_source != source) { priv->map_source = source; if (priv->map) { guint currentLevel = priv->map->current_level->level; - map_free(priv->map); - priv->map = map_new(priv->map_source); + map_free (priv->map); + priv->map = map_new (priv->map_source); // Keep same zoom level if the new map supports it if (currentLevel > priv->map->zoom_levels) { currentLevel = priv->map->zoom_levels; - g_object_notify(G_OBJECT(view), "zoom-level"); + g_object_notify (G_OBJECT (view), "zoom-level"); } - map_load_level(priv->map, currentLevel); + map_load_level (priv->map, currentLevel); map_load_visible_tiles (priv->map, priv->viewport_size, priv->offline); clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), priv->map->current_level->group); update_license (view); marker_reposition (view); - champlain_view_center_on(view, priv->latitude, priv->longitude); + champlain_view_center_on (view, priv->latitude, priv->longitude); } } break; } case PROP_OFFLINE: - priv->offline = g_value_get_boolean(value); + priv->offline = g_value_get_boolean (value); break; case PROP_DECEL_RATE: { - gdouble decel = g_value_get_double(value); + gdouble decel = g_value_get_double (value); g_object_set (priv->finger_scroll, "decel-rate", decel, NULL); break; } case PROP_KEEP_CENTER_ON_RESIZE: - priv->keep_center_on_resize = g_value_get_boolean(value); + priv->keep_center_on_resize = g_value_get_boolean (value); break; case PROP_SHOW_LICENSE: - priv->show_license = g_value_get_boolean(value); + priv->show_license = g_value_get_boolean (value); update_license (view); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } @@ -504,7 +537,7 @@ static void champlain_view_finalize (GObject *object) { //ChamplainView *view = CHAMPLAIN_VIEW (object); - //ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + //ChamplainViewPrivate *priv = GET_PRIVATE (view); G_OBJECT_CLASS (champlain_view_parent_class)->finalize (object); } @@ -526,8 +559,8 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass) * * Since: 0.1 */ - g_object_class_install_property(object_class, PROP_LONGITUDE, - g_param_spec_float("longitude", + g_object_class_install_property (object_class, PROP_LONGITUDE, + g_param_spec_float ("longitude", "Longitude", "The longitude coordonate of the map", -180.0f, @@ -542,8 +575,8 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass) * * Since: 0.1 */ - g_object_class_install_property(object_class, PROP_LATITUDE, - g_param_spec_float("latitude", + g_object_class_install_property (object_class, PROP_LATITUDE, + g_param_spec_float ("latitude", "Latitude", "The latitude coordonate of the map", -90.0f, @@ -558,8 +591,8 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass) * * Since: 0.1 */ - g_object_class_install_property(object_class, PROP_ZOOM_LEVEL, - g_param_spec_int("zoom-level", + g_object_class_install_property (object_class, PROP_ZOOM_LEVEL, + g_param_spec_int ("zoom-level", "Zoom level", "The level of zoom of the map", 0, @@ -575,8 +608,8 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass) * * Since: 0.2 */ - g_object_class_install_property(object_class, PROP_MAP_SOURCE, - g_param_spec_int("map-source", + g_object_class_install_property (object_class, PROP_MAP_SOURCE, + g_param_spec_int ("map-source", "Map source", "The map source being displayed", 0, @@ -591,8 +624,8 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass) * * Since: 0.2 */ - g_object_class_install_property(object_class, PROP_OFFLINE, - g_param_spec_boolean("offline", + g_object_class_install_property (object_class, PROP_OFFLINE, + g_param_spec_boolean ("offline", "Offline Mode", "If viewer is in offline mode.", FALSE, @@ -651,7 +684,7 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass) static void champlain_view_init (ChamplainView *view) { - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + ChamplainViewPrivate *priv = GET_PRIVATE (view); priv->map_source = CHAMPLAIN_MAP_SOURCE_OPENSTREETMAP; priv->zoom_level = 3; @@ -662,12 +695,12 @@ champlain_view_init (ChamplainView *view) } static void -viewport_x_changed_cb(GObject *gobject, GParamSpec *arg1, ChamplainView *view) +viewport_x_changed_cb (GObject *gobject, GParamSpec *arg1, ChamplainView *view) { - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + ChamplainViewPrivate *priv = GET_PRIVATE (view); ChamplainPoint rect; - tidy_viewport_get_origin(TIDY_VIEWPORT(priv->viewport), &rect.x, &rect.y, NULL); + tidy_viewport_get_origin (TIDY_VIEWPORT (priv->viewport), &rect.x, &rect.y, NULL); if (rect.x == priv->viewport_size.x && rect.y == priv->viewport_size.y) @@ -678,16 +711,16 @@ viewport_x_changed_cb(GObject *gobject, GParamSpec *arg1, ChamplainView *view) map_load_visible_tiles (priv->map, priv->viewport_size, priv->offline); - g_object_notify(G_OBJECT(view), "longitude"); - g_object_notify(G_OBJECT(view), "latitude"); + g_object_notify (G_OBJECT (view), "longitude"); + g_object_notify (G_OBJECT (view), "latitude"); } void champlain_view_set_size (ChamplainView *view, guint width, guint height) { - g_return_if_fail(CHAMPLAIN_IS_VIEW(view)); + g_return_if_fail (CHAMPLAIN_IS_VIEW (view)); - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + ChamplainViewPrivate *priv = GET_PRIVATE (view); gdouble lat, lon; lat = priv->latitude; @@ -700,7 +733,7 @@ champlain_view_set_size (ChamplainView *view, guint width, guint height) resize_viewport (view); if (priv->keep_center_on_resize) - champlain_view_center_on(view, lat, lon); + champlain_view_center_on (view, lat, lon); else map_load_visible_tiles (priv->map, priv->viewport_size, priv->offline); } @@ -708,7 +741,7 @@ champlain_view_set_size (ChamplainView *view, guint width, guint height) static void update_license (ChamplainView *view) { - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + ChamplainViewPrivate *priv = GET_PRIVATE (view); if (priv->license_actor) clutter_container_remove_actor (CLUTTER_CONTAINER (priv->stage), priv->license_actor); @@ -729,18 +762,18 @@ static gboolean finger_scroll_button_press_cb (ClutterActor *actor, ClutterButtonEvent *event, ChamplainView *view) -{ - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); +{ + ChamplainViewPrivate *priv = GET_PRIVATE (view); if (event->button == 1 && event->click_count == 2) { ClutterActor *group = priv->map->current_level->group; // Keep the lon, lat where the mouse is - gdouble lon = viewport_get_longitude_at(priv, + gdouble lon = viewport_get_longitude_at (priv, priv->viewport_size.x + event->x + priv->map->current_level->anchor.x); - gdouble lat = viewport_get_latitude_at(priv, + gdouble lat = viewport_get_latitude_at (priv, priv->viewport_size.y + event->y + priv->map->current_level->anchor.y); - + // How far was it from the center of the viewport (in px) gint x_diff = priv->viewport_size.width / 2 - event->x; gint y_diff = priv->viewport_size.height / 2 - event->y; @@ -748,18 +781,18 @@ finger_scroll_button_press_cb (ClutterActor *actor, if (map_zoom_in (priv->map)) { // Get the new x,y in the new zoom level - gint x2 = priv->map->longitude_to_x(priv->map, lon, priv->map->current_level->level); - gint y2 = priv->map->latitude_to_y(priv->map, lat, priv->map->current_level->level); + gint x2 = priv->map->longitude_to_x (priv->map, lon, priv->map->current_level->level); + gint y2 = priv->map->latitude_to_y (priv->map, lat, priv->map->current_level->level); // Get the new lon,lat of these new x,y minus the distance from the viewport center - gdouble lon2 = priv->map->x_to_longitude(priv->map, x2 + x_diff, priv->map->current_level->level); - gdouble lat2 = priv->map->y_to_latitude(priv->map, y2 + y_diff, priv->map->current_level->level); + gdouble lon2 = priv->map->x_to_longitude (priv->map, x2 + x_diff, priv->map->current_level->level); + gdouble lat2 = priv->map->y_to_latitude (priv->map, y2 + y_diff, priv->map->current_level->level); - resize_viewport(view); + resize_viewport (view); clutter_container_remove_actor (CLUTTER_CONTAINER (priv->map_layer), group); clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), priv->map->current_level->group); - champlain_view_center_on(view, lat2, lon2); + champlain_view_center_on (view, lat2, lon2); - g_object_notify(G_OBJECT(view), "zoom-level"); + g_object_notify (G_OBJECT (view), "zoom-level"); } champlain_view_center_on (view, lat, lon); return TRUE; @@ -780,7 +813,7 @@ champlain_view_new (ChamplainViewMode mode) ChamplainView *view; view = CHAMPLAIN_VIEW (g_object_new (CHAMPLAIN_TYPE_VIEW, NULL)); - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + ChamplainViewPrivate *priv = GET_PRIVATE (view); priv->stage = clutter_group_new (); @@ -796,7 +829,7 @@ champlain_view_new (ChamplainViewMode mode) // Setup finger scroll TidyFingerScrollMode tidy_mode; - switch(mode) + switch (mode) { case CHAMPLAIN_VIEW_MODE_PUSH: tidy_mode = TIDY_FINGER_SCROLL_MODE_PUSH; @@ -806,7 +839,7 @@ champlain_view_new (ChamplainViewMode mode) break; } - priv->finger_scroll = tidy_finger_scroll_new(mode); + priv->finger_scroll = tidy_finger_scroll_new (mode); g_signal_connect (priv->finger_scroll, "scroll-event", @@ -818,8 +851,8 @@ champlain_view_new (ChamplainViewMode mode) clutter_container_add_actor (CLUTTER_CONTAINER (view), priv->stage); // Map Layer - priv->map_layer = clutter_group_new(); - clutter_actor_show(priv->map_layer); + priv->map_layer = clutter_group_new (); + clutter_actor_show (priv->map_layer); clutter_container_add_actor (CLUTTER_CONTAINER (priv->viewport), priv->map_layer); g_signal_connect (priv->finger_scroll, @@ -828,10 +861,10 @@ champlain_view_new (ChamplainViewMode mode) view); // Setup user_layers - priv->user_layers = clutter_group_new(); - clutter_actor_show(priv->user_layers); + priv->user_layers = clutter_group_new (); + clutter_actor_show (priv->user_layers); clutter_container_add_actor (CLUTTER_CONTAINER (priv->viewport), priv->user_layers); - clutter_actor_raise(priv->user_layers, priv->map_layer); + clutter_actor_raise (priv->user_layers, priv->map_layer); return CLUTTER_ACTOR (view); } @@ -850,19 +883,19 @@ champlain_view_new (ChamplainViewMode mode) void champlain_view_center_on (ChamplainView *view, gdouble latitude, gdouble longitude) { - g_return_if_fail(CHAMPLAIN_IS_VIEW(view)); + g_return_if_fail (CHAMPLAIN_IS_VIEW (view)); - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + ChamplainViewPrivate *priv = GET_PRIVATE (view); priv->longitude = longitude; priv->latitude = latitude; - if(!priv->map) + if (!priv->map) return; gint x, y; - x = priv->map->longitude_to_x(priv->map, longitude, priv->map->current_level->level); - y = priv->map->latitude_to_y(priv->map, latitude, priv->map->current_level->level); + x = priv->map->longitude_to_x (priv->map, longitude, priv->map->current_level->level); + y = priv->map->latitude_to_y (priv->map, latitude, priv->map->current_level->level); ChamplainPoint* anchor = &priv->map->current_level->anchor; if (priv->map->current_level->level >= 8) { @@ -874,7 +907,7 @@ champlain_view_center_on (ChamplainView *view, gdouble latitude, gdouble longitu if ( anchor->y < 0 ) anchor->y = 0; - gdouble max = zoom_level_get_width(priv->map->current_level) - (G_MAXINT16 / 2); + gdouble max = zoom_level_get_width (priv->map->current_level) - (G_MAXINT16 / 2); if (anchor->x > max) anchor->x = max; if (anchor->y > max) @@ -890,18 +923,18 @@ champlain_view_center_on (ChamplainView *view, gdouble latitude, gdouble longitu guint i; for (i = 0; i < priv->map->current_level->tiles->len; i++) { - Tile *tile = g_ptr_array_index(priv->map->current_level->tiles, i); + Tile *tile = g_ptr_array_index (priv->map->current_level->tiles, i); if (!tile->loading) - tile_set_position(priv->map, tile); + tile_set_position (priv->map, tile); } - tidy_viewport_set_origin(TIDY_VIEWPORT(priv->viewport), + tidy_viewport_set_origin (TIDY_VIEWPORT (priv->viewport), x - priv->viewport_size.width / 2.0, y - priv->viewport_size.height / 2.0, 0); - g_object_notify(G_OBJECT(view), "longitude"); - g_object_notify(G_OBJECT(view), "latitude"); + g_object_notify (G_OBJECT (view), "longitude"); + g_object_notify (G_OBJECT (view), "latitude"); map_load_visible_tiles (priv->map, priv->viewport_size, priv->offline); marker_reposition (view); @@ -918,19 +951,19 @@ champlain_view_center_on (ChamplainView *view, gdouble latitude, gdouble longitu void champlain_view_zoom_in (ChamplainView *view) { - g_return_if_fail(CHAMPLAIN_IS_VIEW(view)); + g_return_if_fail (CHAMPLAIN_IS_VIEW (view)); - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + ChamplainViewPrivate *priv = GET_PRIVATE (view); ClutterActor *group = priv->map->current_level->group; - if(map_zoom_in(priv->map)) + if (map_zoom_in (priv->map)) { - resize_viewport(view); + resize_viewport (view); clutter_container_remove_actor (CLUTTER_CONTAINER (priv->map_layer), group); clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), priv->map->current_level->group); - champlain_view_center_on(view, priv->latitude, priv->longitude); + champlain_view_center_on (view, priv->latitude, priv->longitude); - g_object_notify(G_OBJECT(view), "zoom-level"); + g_object_notify (G_OBJECT (view), "zoom-level"); } } @@ -945,19 +978,19 @@ champlain_view_zoom_in (ChamplainView *view) void champlain_view_zoom_out (ChamplainView *view) { - g_return_if_fail(CHAMPLAIN_IS_VIEW(view)); + g_return_if_fail (CHAMPLAIN_IS_VIEW (view)); - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + ChamplainViewPrivate *priv = GET_PRIVATE (view); ClutterActor *group = priv->map->current_level->group; - if(map_zoom_out(priv->map)) + if (map_zoom_out (priv->map)) { - resize_viewport(view); + resize_viewport (view); clutter_container_remove_actor (CLUTTER_CONTAINER (priv->map_layer), group); clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), priv->map->current_level->group); - champlain_view_center_on(view, priv->latitude, priv->longitude); + champlain_view_center_on (view, priv->latitude, priv->longitude); - g_object_notify(G_OBJECT(view), "zoom-level"); + g_object_notify (G_OBJECT (view), "zoom-level"); } } @@ -973,22 +1006,22 @@ champlain_view_zoom_out (ChamplainView *view) void champlain_view_add_layer (ChamplainView *view, ClutterActor *layer) { - g_return_if_fail(CHAMPLAIN_IS_VIEW(view)); - g_return_if_fail(CLUTTER_IS_ACTOR(layer)); + g_return_if_fail (CHAMPLAIN_IS_VIEW (view)); + g_return_if_fail (CLUTTER_IS_ACTOR (layer)); - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); - clutter_container_add(CLUTTER_CONTAINER(priv->user_layers), layer, NULL); - clutter_actor_raise_top(layer); + ChamplainViewPrivate *priv = GET_PRIVATE (view); + clutter_container_add (CLUTTER_CONTAINER (priv->user_layers), layer, NULL); + clutter_actor_raise_top (layer); - if(priv->map) - marker_reposition(view); + if (priv->map) + marker_reposition (view); g_signal_connect_after (layer, "add", G_CALLBACK (layer_add_marker_cb), view); - clutter_container_foreach(CLUTTER_CONTAINER(layer), CLUTTER_CALLBACK(connect_marker_notify_cb), view); + clutter_container_foreach (CLUTTER_CONTAINER (layer), CLUTTER_CALLBACK (connect_marker_notify_cb), view); } /** @@ -1008,10 +1041,10 @@ champlain_view_get_coords_from_event (ChamplainView *view, gdouble *latitude, gdouble *longitude) { - g_return_val_if_fail(CHAMPLAIN_IS_VIEW(view), FALSE); - g_return_val_if_fail(event, FALSE); // Apparently there isn't a more precise test + g_return_val_if_fail (CHAMPLAIN_IS_VIEW (view), FALSE); + g_return_val_if_fail (event, FALSE); // Apparently there isn't a more precise test - ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + ChamplainViewPrivate *priv = GET_PRIVATE (view); guint x, y; switch (clutter_event_type (event)) diff --git a/demos/launcher.c b/demos/launcher.c index b3867f7..bc225c7 100644 --- a/demos/launcher.c +++ b/demos/launcher.c @@ -29,16 +29,16 @@ map_view_button_release_cb (ClutterActor *actor, return; g_print("Map was clicked at "); - if (champlain_view_get_coords_from_event (view, event, &lat, &lon)) + if (champlain_view_get_coords_from_event (view, (ClutterEvent*)event, &lat, &lon)) g_print("%f, %f \n", lat, lon); return TRUE; } static gboolean -montreal_click (ClutterActor *actor, - ClutterButtonEvent *event, - ChamplainView * view) +marker_button_release_cb (ClutterActor *actor, + ClutterButtonEvent *event, + ChamplainView * view) { if (event->button != 1 || event->click_count > 1) return; @@ -52,32 +52,32 @@ static ClutterActor* create_marker_layer (ChamplainView *view) { ClutterActor *layer, *marker; - - layer = champlain_layer_new(); - ClutterColor orange = { 0xf3, 0x94, 0x07, 0xbb }; ClutterColor white = { 0xff, 0xff, 0xff, 0xff }; - marker = champlain_marker_new_with_label("Montréal", "Airmole 14", NULL, + + layer = champlain_layer_new (); + + marker = champlain_marker_new_with_label ("Montréal", "Airmole 14", NULL, NULL); - champlain_marker_set_position(CHAMPLAIN_MARKER(marker), 45.528178, - -73.563788); - clutter_container_add(CLUTTER_CONTAINER(layer), marker, NULL); - clutter_actor_set_reactive(marker, TRUE); + champlain_marker_set_position (CHAMPLAIN_MARKER (marker), + 45.528178, -73.563788); + clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL); + clutter_actor_set_reactive (marker, TRUE); g_signal_connect_after (marker, "button-release-event", - G_CALLBACK (montreal_click), view); + G_CALLBACK (marker_button_release_cb), view); - marker = champlain_marker_new_with_label("New York", "Sans 25", &white, + marker = champlain_marker_new_with_label ("New York", "Sans 25", &white, NULL); - champlain_marker_set_position(CHAMPLAIN_MARKER(marker), 40.77, -73.98); - clutter_container_add(CLUTTER_CONTAINER(layer), marker, NULL); + champlain_marker_set_position (CHAMPLAIN_MARKER (marker), 40.77, -73.98); + clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL); - marker = champlain_marker_new_with_label("Saint-Tite-des-Caps", "Serif 12", + marker = champlain_marker_new_with_label ("Saint-Tite-des-Caps", "Serif 12", NULL, &orange); - champlain_marker_set_position(CHAMPLAIN_MARKER(marker), 47.130885, + champlain_marker_set_position (CHAMPLAIN_MARKER (marker), 47.130885, -70.764141); - clutter_container_add(CLUTTER_CONTAINER(layer), marker, NULL); + clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL); - clutter_actor_show(layer); + clutter_actor_show (layer); return layer; } @@ -101,12 +101,12 @@ main (int argc, champlain_view_set_size (CHAMPLAIN_VIEW (actor), 800, 600); - layer = create_marker_layer(actor); + layer = create_marker_layer (actor); champlain_view_add_layer(CHAMPLAIN_VIEW (actor), layer); clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor); g_object_set (G_OBJECT (actor), "zoom-level", 12, NULL); - champlain_view_center_on(CHAMPLAIN_VIEW(actor), 45.466, -73.75); + champlain_view_center_on (CHAMPLAIN_VIEW(actor), 45.466, -73.75); clutter_actor_show (stage); clutter_main ();