]> err.no Git - libchamplain/commitdiff
Introduce ChamplainBaseMarker as a parent to ChamplainMarker
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Sat, 4 Apr 2009 14:09:46 +0000 (17:09 +0300)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Sun, 12 Apr 2009 01:41:48 +0000 (21:41 -0400)
16 files changed:
champlain/Makefile.am
champlain/champlain-base-marker.c [new file with mode: 0644]
champlain/champlain-base-marker.h [new file with mode: 0644]
champlain/champlain-defines.h
champlain/champlain-layer.c
champlain/champlain-marker.c
champlain/champlain-marker.h
champlain/champlain-private.h
champlain/champlain-view.c
champlain/champlain-view.h
champlain/champlain.h
demos/animated-marker.c
demos/launcher-gtk.c
demos/launcher.c
docs/reference/libchamplain-docs.sgml
docs/reference/libchamplain.types

index ac343f4645dd4599b36c931b4655c6483689a5c6..9a6f139f651f94d56c326ff946c1c12d154cbd89 100644 (file)
@@ -19,6 +19,7 @@ libchamplain_headers = \
        champlain-defines.h             \
        champlain-view.h                \
        champlain-layer.h               \
+       champlain-base-marker.h         \
        champlain-marker.h              \
        champlain-map.h                 \
        champlain-zoom-level.h          \
@@ -35,6 +36,7 @@ libchamplain_0_3_la_SOURCES = \
        champlain-debug.c               \
        champlain-view.c                \
        champlain-layer.c               \
+       champlain-base-marker.c         \
        champlain-marker.c              \
        champlain-map.c                 \
        champlain-zoom-level.c          \
@@ -45,7 +47,8 @@ libchamplain_0_3_la_SOURCES = \
 noinst_HEADERS = \
        champlain-debug.h               \
        champlain-view.h                \
-       champlain-marker.c              \
+       champlain-base-marker.h         \
+       champlain-marker.h              \
        champlain-private.h             \
        champlain-map.h                 \
        champlain-zoom-level.h          \
@@ -65,6 +68,7 @@ libchamplain_include_HEADERS = \
        champlain-network-map-source.h  \
        champlain-tile.h                \
        champlain-zoom-level.h          \
+       champlain-base-marker.h         \
        champlain-marker.h              \
        champlain-version.h
 
diff --git a/champlain/champlain-base-marker.c b/champlain/champlain-base-marker.c
new file mode 100644 (file)
index 0000000..368d733
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+/**
+ * SECTION:champlain-base_marker
+ * @short_description: A base_marker to identify points of interest on a map
+ *
+ * BaseMarkers reprensent points of interest on a map. BaseMarkers need to be placed on
+ * a layer (a #ClutterGroup).  Layers have to be added to a #ChamplainView for
+ * the base_markers to show on the map.
+ *
+ * A base_marker is nothing more than a regular #ClutterActor.  You can draw on it
+ * what ever you want.  Don't forget to set the anchor position in the base_marker
+ * using #champlain_base_marker_set_anchor.  Set the base_markers position on the map
+ * using #champlain_base_marker_set_position.
+ *
+ * Champlain has a default type of base_markers with text. To create one,
+ * use #champlain_base_marker_new_with_label.
+ */
+
+#include "config.h"
+
+#include "champlain-base-marker.h"
+
+#include "champlain.h"
+#include "champlain-defines.h"
+#include "champlain-marshal.h"
+#include "champlain-private.h"
+#include "champlain-map.h"
+#include "champlain-tile.h"
+#include "champlain-zoom-level.h"
+
+#include <clutter/clutter.h>
+#include <clutter-cairo/clutter-cairo.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <cairo.h>
+#include <math.h>
+
+enum
+{
+  /* normal signals */
+  LAST_SIGNAL
+};
+
+enum
+{
+  PROP_0,
+  PROP_LONGITUDE,
+  PROP_LATITUDE,
+};
+
+//static guint champlain_base_marker_signals[LAST_SIGNAL] = { 0, };
+
+G_DEFINE_TYPE (ChamplainBaseMarker, champlain_base_marker, CLUTTER_TYPE_GROUP);
+
+#define CHAMPLAIN_BASE_MARKER_GET_PRIVATE(obj)    (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_BASE_MARKER, ChamplainBaseMarkerPrivate))
+
+static void
+champlain_base_marker_get_property (GObject *object,
+                               guint prop_id,
+                               GValue *value,
+                               GParamSpec *pspec)
+{
+    ChamplainBaseMarker *base_marker = CHAMPLAIN_BASE_MARKER (object);
+    ChamplainBaseMarkerPrivate *priv = CHAMPLAIN_BASE_MARKER_GET_PRIVATE (base_marker);
+
+    switch (prop_id)
+      {
+        case PROP_LONGITUDE:
+          g_value_set_double (value, priv->lon);
+          break;
+        case PROP_LATITUDE:
+          g_value_set_double (value, priv->lat);
+          break;
+        default:
+          G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      }
+}
+
+static void
+champlain_base_marker_set_property (GObject *object,
+                               guint prop_id,
+                               const GValue *value,
+                               GParamSpec *pspec)
+{
+    ChamplainBaseMarker *base_marker = CHAMPLAIN_BASE_MARKER (object);
+    ChamplainBaseMarkerPrivate *priv = CHAMPLAIN_BASE_MARKER_GET_PRIVATE (base_marker);
+
+    switch (prop_id)
+    {
+      case PROP_LONGITUDE:
+        {
+          gdouble lon = g_value_get_double (value);
+          champlain_base_marker_set_position (base_marker, lon, priv->lat);
+          break;
+        }
+      case PROP_LATITUDE:
+        {
+          gdouble lat = g_value_get_double (value);
+          champlain_base_marker_set_position (base_marker, priv->lon, lat);
+          break;
+        }
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+champlain_base_marker_finalize (GObject *object)
+{
+  //ChamplainBaseMarker *base_marker = CHAMPLAIN_BASE_MARKER (object);
+  //ChamplainBaseMarkerPrivate *priv = CHAMPLAIN_BASE_MARKER_GET_PRIVATE (base_marker);
+
+  G_OBJECT_CLASS (champlain_base_marker_parent_class)->finalize (object);
+}
+
+static void
+champlain_base_marker_class_init (ChamplainBaseMarkerClass *champlainBaseMarkerClass)
+{
+  g_type_class_add_private (champlainBaseMarkerClass, sizeof (ChamplainBaseMarkerPrivate));
+
+  GObjectClass *object_class = G_OBJECT_CLASS (champlainBaseMarkerClass);
+  object_class->finalize = champlain_base_marker_finalize;
+  object_class->get_property = champlain_base_marker_get_property;
+  object_class->set_property = champlain_base_marker_set_property;
+
+  /**
+  * ChamplainBaseMarker:longitude:
+  *
+  * The longitude coordonate of the map
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class, PROP_LONGITUDE,
+      g_param_spec_double ("longitude", "Longitude",
+          "The longitude coordonate of the base_marker",
+          -180.0f, 180.0f, 0.0f, CHAMPLAIN_PARAM_READWRITE));
+
+  /**
+  * ChamplainBaseMarker:latitude:
+  *
+  * The latitude coordonate of the map
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class, PROP_LATITUDE,
+      g_param_spec_double ("latitude", "Latitude",
+          "The latitude coordonate of the base_marker",
+          -90.0f, 90.0f, 0.0f, CHAMPLAIN_PARAM_READWRITE));
+
+}
+
+static void
+champlain_base_marker_init (ChamplainBaseMarker *marker)
+{
+  ChamplainBaseMarkerPrivate *priv = CHAMPLAIN_BASE_MARKER_GET_PRIVATE (marker);
+  marker->priv = priv;
+}
+
+
+/**
+ * champlain_base_marker_new:
+ *
+ * Returns a new #ChamplainBaseMarker ready to be used as a #ClutterActor.
+ *
+ * Since: 0.4
+ */
+ClutterActor *
+champlain_base_marker_new (void)
+{
+  ChamplainBaseMarker *base_marker;
+
+  base_marker = CHAMPLAIN_BASE_MARKER (g_object_new (CHAMPLAIN_TYPE_BASE_MARKER, NULL));
+  //ChamplainBaseMarkerPrivate *priv = CHAMPLAIN_BASE_MARKER_GET_PRIVATE (base_marker);
+
+  return CLUTTER_ACTOR (base_marker);
+}
+
+/**
+ * champlain_base_marker_set_position:
+ * @base_marker: a #ChamplainBaseMarker
+ * @longitude: the longitude to center the map at
+ * @latitude: the longitude to center the map at
+ *
+ * Positions the base_marker on the map at the coordinates
+ *
+ * Since: 0.4
+ */
+void
+champlain_base_marker_set_position (ChamplainBaseMarker *champlainBaseMarker, gdouble latitude, gdouble longitude)
+{
+  g_return_if_fail (CHAMPLAIN_IS_BASE_MARKER (champlainBaseMarker));
+
+  ChamplainBaseMarkerPrivate *priv = CHAMPLAIN_BASE_MARKER_GET_PRIVATE (champlainBaseMarker);
+
+  priv->lon = longitude;
+  priv->lat = latitude;
+
+  g_object_notify (G_OBJECT (champlainBaseMarker), "latitude");
+  g_object_notify (G_OBJECT (champlainBaseMarker), "longitude");
+}
diff --git a/champlain/champlain-base-marker.h b/champlain/champlain-base-marker.h
new file mode 100644 (file)
index 0000000..e303afc
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#if !defined (__CHAMPLAIN_CHAMPLAIN_H_INSIDE__) && !defined (CHAMPLAIN_COMPILATION)
+#error "Only <champlain/champlain.h> can be included directly."
+#endif
+
+#ifndef CHAMPLAIN_BASE_MARKER_H
+#define CHAMPLAIN_BASE_MARKER_H
+
+#include <champlain/champlain-defines.h>
+
+#include <glib-object.h>
+#include <clutter/clutter.h>
+
+G_BEGIN_DECLS
+
+#define CHAMPLAIN_TYPE_BASE_MARKER     (champlain_base_marker_get_type())
+#define CHAMPLAIN_BASE_MARKER(obj)     (G_TYPE_CHECK_INSTANCE_CAST((obj), CHAMPLAIN_TYPE_BASE_MARKER, ChamplainBaseMarker))
+#define CHAMPLAIN_BASE_MARKER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  CHAMPLAIN_TYPE_BASE_MARKER, ChamplainBaseMarkerClass))
+#define CHAMPLAIN_IS_BASE_MARKER(obj)  (G_TYPE_CHECK_INSTANCE_TYPE((obj), CHAMPLAIN_TYPE_BASE_MARKER))
+#define CHAMPLAIN_IS_BASE_MARKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  CHAMPLAIN_TYPE_BASE_MARKER))
+#define CHAMPLAIN_BASE_MARKER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  CHAMPLAIN_TYPE_BASE_MARKER, ChamplainBaseMarkerClass))
+
+typedef struct _ChamplainBaseMarkerPrivate ChamplainBaseMarkerPrivate;
+
+typedef struct _ChamplainBaseMarker ChamplainBaseMarker;
+typedef struct _ChamplainBaseMarkerClass ChamplainBaseMarkerClass;
+
+
+struct _ChamplainBaseMarker
+{
+  ClutterGroup group;
+
+  ChamplainBaseMarkerPrivate *priv;
+};
+
+struct _ChamplainBaseMarkerClass
+{
+  ClutterGroupClass parent_class;
+
+};
+
+GType champlain_base_marker_get_type (void);
+
+ClutterActor *champlain_base_marker_new (void);
+
+void champlain_base_marker_set_position (ChamplainBaseMarker *marker,
+    gdouble longitude, gdouble latitude);
+
+G_END_DECLS
+
+#endif
index 3534a5a4f287fe4fc99fbacafd14c7436151735f..771b322d1d5d79c04239b1dd7cd6da7306b81c59 100644 (file)
@@ -29,9 +29,6 @@
 typedef struct _ChamplainView ChamplainView;
 typedef struct _ChamplainViewClass ChamplainViewClass;
 
-typedef struct _ChamplainMarker ChamplainMarker;
-typedef struct _ChamplainMarkerClass ChamplainMarkerClass;
-
 #define CHAMPLAIN_PARAM_READABLE     \
         (G_PARAM_READABLE |     \
          G_PARAM_STATIC_NICK | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB)
index a993cc122b42dcc9e663e1bc08d922cfd044f325..3fe1d3d05c43e3772df83eee26bcdf6d05094c60 100644 (file)
@@ -32,6 +32,7 @@
 #include "champlain-layer.h"
 
 #include "champlain-defines.h"
+#include "champlain-base-marker.h"
 
 #include <clutter/clutter.h>
 #include <glib.h>
@@ -130,7 +131,7 @@ layer_add_cb (ClutterGroup *layer,
   GList* markers = clutter_container_get_children (CLUTTER_CONTAINER(layer));
   gint size, i;
   gdouble y, tmp_y, low_y;
-  ChamplainMarker *lowest = NULL;
+  ChamplainBaseMarker *lowest = NULL;
 
   size = g_list_length (markers);
   g_object_get(G_OBJECT(marker), "latitude", &y, NULL);
@@ -139,11 +140,11 @@ layer_add_cb (ClutterGroup *layer,
 
   for (i = 0; i < size; i++)
     {
-      ChamplainMarker *prev_marker = (ChamplainMarker*) g_list_nth_data (markers, i);
+      ChamplainBaseMarker *prev_marker = (ChamplainBaseMarker*) g_list_nth_data (markers, i);
       g_object_get(G_OBJECT(prev_marker), "latitude", &tmp_y, NULL);
       tmp_y = 90 - tmp_y;
 
-      if (prev_marker == (ChamplainMarker*) marker)
+      if (prev_marker == (ChamplainBaseMarker*) marker)
         continue;
 
       if (y < tmp_y && tmp_y < low_y)
index bef0b76c8abec4df16e8511bddaede82ab02d794..defe131e6075b2c296b2a614293b1f83ee04513c 100644 (file)
@@ -38,6 +38,7 @@
 #include "champlain-marker.h"
 
 #include "champlain.h"
+#include "champlain-base-marker.h"
 #include "champlain-defines.h"
 #include "champlain-marshal.h"
 #include "champlain-private.h"
@@ -61,15 +62,18 @@ enum
 enum
 {
   PROP_0,
-  PROP_LONGITUDE,
-  PROP_LATITUDE,
-  PROP_ANCHOR_X,
-  PROP_ANCHOR_Y,
 };
 
 //static guint champlain_marker_signals[LAST_SIGNAL] = { 0, };
 
-G_DEFINE_TYPE (ChamplainMarker, champlain_marker, CLUTTER_TYPE_GROUP);
+struct _ChamplainMarkerPrivate
+{
+  gboolean tmp;
+};
+
+G_DEFINE_TYPE (ChamplainMarker, champlain_marker, CHAMPLAIN_TYPE_BASE_MARKER);
+
+#define CHAMPLAIN_MARKER_GET_PRIVATE(obj)    (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_MARKER, ChamplainMarkerPrivate))
 
 static void
 champlain_marker_get_property (GObject *object,
@@ -77,17 +81,11 @@ champlain_marker_get_property (GObject *object,
                                GValue *value,
                                GParamSpec *pspec)
 {
-    ChamplainMarker *marker = CHAMPLAIN_MARKER (object);
-    ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
+    //ChamplainMarker *marker = CHAMPLAIN_MARKER (object);
+    //ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
 
     switch (prop_id)
       {
-        case PROP_LONGITUDE:
-          g_value_set_double (value, priv->lon);
-          break;
-        case PROP_LATITUDE:
-          g_value_set_double (value, priv->lat);
-          break;
         default:
           G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       }
@@ -99,23 +97,11 @@ champlain_marker_set_property (GObject *object,
                                const GValue *value,
                                GParamSpec *pspec)
 {
-    ChamplainMarker *marker = CHAMPLAIN_MARKER (object);
-    ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
+    //ChamplainMarker *marker = CHAMPLAIN_MARKER (object);
+    //ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
 
     switch (prop_id)
     {
-      case PROP_LONGITUDE:
-        {
-          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);
-          break;
-        }
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -131,56 +117,24 @@ champlain_marker_finalize (GObject *object)
 }
 
 static void
-champlain_marker_class_init (ChamplainMarkerClass *champlainMarkerClass)
+champlain_marker_class_init (ChamplainMarkerClass *markerClass)
 {
-  g_type_class_add_private (champlainMarkerClass, sizeof (ChamplainMarkerPrivate));
+  g_type_class_add_private (markerClass, sizeof (ChamplainMarkerPrivate));
 
-  GObjectClass *object_class = G_OBJECT_CLASS (champlainMarkerClass);
+  GObjectClass *object_class = G_OBJECT_CLASS (markerClass);
   object_class->finalize = champlain_marker_finalize;
   object_class->get_property = champlain_marker_get_property;
   object_class->set_property = champlain_marker_set_property;
 
-  /**
-  * ChamplainMarker:longitude:
-  *
-  * The longitude coordonate of the map
-  *
-  * Since: 0.2
-  */
-  g_object_class_install_property (object_class, PROP_LONGITUDE,
-                                  g_param_spec_double ("longitude",
-                                                      "Longitude",
-                                                      "The longitude coordonate of the marker",
-                                                      -180.0f,
-                                                      180.0f,
-                                                      0.0f,
-                                                      CHAMPLAIN_PARAM_READWRITE));
-
-  /**
-  * ChamplainMarker:latitude:
-  *
-  * The latitude coordonate of the map
-  *
-  * Since: 0.2
-  */
-  g_object_class_install_property (object_class, PROP_LATITUDE,
-                                  g_param_spec_double ("latitude",
-                                                      "Latitude",
-                                                      "The latitude coordonate of the marker",
-                                                      -90.0f,
-                                                      90.0f,
-                                                      0.0f,
-                                                      CHAMPLAIN_PARAM_READWRITE));
-
 }
 
 static void
-champlain_marker_init (ChamplainMarker *champlainMarker)
+champlain_marker_init (ChamplainMarker *marker)
 {
-  //ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (champlainMarker);
+  ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
+  marker->priv = priv;
 }
 
-
 /**
  * champlain_marker_new:
  *
@@ -199,30 +153,6 @@ champlain_marker_new (void)
   return CLUTTER_ACTOR (marker);
 }
 
-/**
- * champlain_marker_set_position:
- * @marker: a #ChamplainMarker
- * @longitude: the longitude to center the map at
- * @latitude: the longitude to center the map at
- *
- * Positions the marker on the map at the coordinates
- *
- * Since: 0.2
- */
-void
-champlain_marker_set_position (ChamplainMarker *champlainMarker, gdouble latitude, gdouble longitude)
-{
-  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");
-}
-
 /**
  * champlain_marker_new_with_label:
  * @label: the text of the label
@@ -240,7 +170,7 @@ champlain_marker_new_with_label (const gchar *label,
                                  ClutterColor *text_color,
                                  ClutterColor *marker_color)
 {
-  ChamplainMarker *champlainMarker = CHAMPLAIN_MARKER (champlain_marker_new ());
+  ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ());
   ClutterColor default_text_color = { 0x22, 0x22, 0x22, 0xFF },
                default_marker_color = { 0x2A, 0xB1, 0x26, 0xEE },
                darker_color;
@@ -261,7 +191,7 @@ champlain_marker_new_with_label (const gchar *label,
   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_container_add_actor (CLUTTER_CONTAINER (marker), actor);
 
   point = (text_height + 2 * padding) / 4.0;
 
@@ -293,12 +223,12 @@ 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 (marker), 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 (marker), 0, text_height + point);
 
-  return CLUTTER_ACTOR (champlainMarker);
+  return CLUTTER_ACTOR (marker);
 }
 
 /**
@@ -316,17 +246,17 @@ champlain_marker_new_with_image (const gchar *filename, GError **error)
   if (filename == NULL)
     return NULL;
 
-  ChamplainMarker *champlainMarker = CHAMPLAIN_MARKER (champlain_marker_new ());
+  ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ());
   ClutterActor *actor = clutter_texture_new_from_file (filename, error);
 
   if (actor == NULL){
-    g_object_unref (G_OBJECT (champlainMarker));
+    g_object_unref (G_OBJECT (marker));
     return NULL;
   }
 
-  clutter_container_add_actor (CLUTTER_CONTAINER (champlainMarker), actor);
+  clutter_container_add_actor (CLUTTER_CONTAINER (marker), actor);
 
-  return CLUTTER_ACTOR (champlainMarker);
+  return CLUTTER_ACTOR (marker);
 }
 
 /**
@@ -353,21 +283,21 @@ champlain_marker_new_with_image_full (const gchar *filename,
   if (filename == NULL)
     return NULL;
 
-  ChamplainMarker *champlainMarker = CHAMPLAIN_MARKER (champlain_marker_new ());
+  ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ());
   ClutterActor *actor = clutter_texture_new_from_file (filename, error);
 
   if (actor == NULL)
     {
-      g_object_unref (G_OBJECT (champlainMarker));
+      g_object_unref (G_OBJECT (marker));
       return NULL;
     }
 
   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,
+  clutter_container_add_actor (CLUTTER_CONTAINER (marker), actor);
+  clutter_actor_set_anchor_point (CLUTTER_ACTOR (marker), anchor_x,
       anchor_y);
 
-  return CLUTTER_ACTOR (champlainMarker);
+  return CLUTTER_ACTOR (marker);
 }
 
index fb0c7ee53f41910c0e2f7495980742e09a8065eb..e9246e528c092f88e5e880daebc0e9289b245a7f 100644 (file)
 #ifndef CHAMPLAIN_MARKER_H
 #define CHAMPLAIN_MARKER_H
 
-#include <champlain/champlain-defines.h>
+#include <champlain/champlain-base-marker.h>
 
 #include <glib-object.h>
 #include <clutter/clutter.h>
 
+G_BEGIN_DECLS
+
 #define CHAMPLAIN_TYPE_MARKER     (champlain_marker_get_type())
 #define CHAMPLAIN_MARKER(obj)     (G_TYPE_CHECK_INSTANCE_CAST((obj), CHAMPLAIN_TYPE_MARKER, ChamplainMarker))
 #define CHAMPLAIN_MARKER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  CHAMPLAIN_TYPE_MARKER, ChamplainMarkerClass))
 
 typedef struct _ChamplainMarkerPrivate ChamplainMarkerPrivate;
 
-struct _ChamplainMarker
+typedef struct
 {
-  ClutterGroup group;
+  ChamplainBaseMarker base;
 
   ChamplainMarkerPrivate *priv;
-};
+} ChamplainMarker;
 
-struct _ChamplainMarkerClass
+typedef struct
 {
-  ClutterGroupClass parent_class;
+  ChamplainBaseMarkerClass parent_class;
 
-};
+} ChamplainMarkerClass;
 
 GType champlain_marker_get_type (void);
 
 ClutterActor *champlain_marker_new (void);
 
-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);
 
@@ -66,4 +65,6 @@ ClutterActor *champlain_marker_new_with_image(const gchar *filename,
 ClutterActor *champlain_marker_new_with_image_full(const gchar *filename,
     gint width, gint height, gint anchor_x, gint anchor_y, GError **error);
 
+G_END_DECLS
+
 #endif
index 5c053eb406b0a32f6a665ab4e4e4dabc7c1091eb..f3c398bbb56f47810700e880ca57d48a514c3286 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <glib.h>
 
-#define CHAMPLAIN_MARKER_GET_PRIVATE(obj)    (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_MARKER, ChamplainMarkerPrivate))
 
 typedef struct _Map Map;
 
@@ -32,7 +31,7 @@ typedef struct
   gint z;
 } ChamplainPoint;
 
-struct _ChamplainMarkerPrivate
+struct _ChamplainBaseMarkerPrivate
 {
   gdouble lon;
   gdouble lat;
index 5726aa0c8ed0f875136eb7b7a49bee8757ee5cd9..243e8216c9fbf38df8c5f1ece2299813a2ab1870 100644 (file)
@@ -307,7 +307,7 @@ marker_reposition_cb (ChamplainMarker *marker,
     ChamplainView *view)
 {
   ChamplainViewPrivate *priv = view->priv;
-  ChamplainMarkerPrivate *marker_priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
+  ChamplainBaseMarkerPrivate *marker_priv = CHAMPLAIN_BASE_MARKER(marker)->priv;
 
   gint x, y;
 
@@ -1840,11 +1840,11 @@ champlain_view_ensure_visible (ChamplainView *view,
  */
 void
 champlain_view_ensure_markers_visible (ChamplainView *view,
-    ChamplainMarker *markers[],
+    ChamplainBaseMarker *markers[],
     gboolean animate)
 {
   gdouble min_lat, min_lon, max_lat, max_lon;
-  ChamplainMarker *marker = NULL;
+  ChamplainBaseMarker *marker = NULL;
   gint i = 0;
 
   min_lat = min_lon = 200;
index d21de1c036f8449620c14c6c989aa0eca4a42b5f..afc88a18d5b7d9e7ed489838030437970e31a9d6 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <champlain/champlain-defines.h>
 #include <champlain/champlain-layer.h>
+#include <champlain/champlain-base-marker.h>
 #include <champlain/champlain-map-source.h>
 #include <champlain/champlain-zoom-level.h>
 
@@ -94,7 +95,7 @@ void champlain_view_ensure_visible (ChamplainView *view,
     gdouble lon2,
     gboolean animate);
 void champlain_view_ensure_markers_visible (ChamplainView *view,
-    ChamplainMarker *markers[],
+    ChamplainBaseMarker *markers[],
     gboolean animate);
 
 void champlain_view_set_map_source (ChamplainView *champlainView,
index 0d0a59fe3cd85c644194ef2a48d17de4a7ee5b96..75abce45b2de90b9d1dca9c8267204cacd34df6e 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "champlain/champlain-defines.h"
 #include "champlain/champlain-layer.h"
+#include "champlain/champlain-base-marker.h"
 #include "champlain/champlain-marker.h"
 #include "champlain/champlain-view.h"
 #include "champlain/champlain-enum-types.h"
index 2b92532aeac98b8af6f893a0d8c1e29d5f11d5d9..957477827c098ee5d4173d20b622a23efee83f29 100644 (file)
@@ -94,7 +94,7 @@ create_marker ()
   clutter_timeline_start (timeline);
 
   /* Sets marker position on the map */
-  champlain_marker_set_position (CHAMPLAIN_MARKER (marker),
+  champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker),
       45.528178, -73.563788);
 
   return marker;
index ba526829b9c18053b6bfcda452730c5ab0844b52..e93292e3d6b8f605be90f64363c0b0b74f904538 100644 (file)
@@ -48,15 +48,15 @@ create_marker_layer ()
   ClutterColor orange = { 0xf3, 0x94, 0x07, 0xbb };
   ClutterColor white = { 0xff, 0xff, 0xff, 0xff };
   marker = champlain_marker_new_with_label ("MontrĂ©al", "Airmole 14", NULL, NULL);
-  champlain_marker_set_position (CHAMPLAIN_MARKER (marker), 45.528178, -73.563788);
+  champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 45.528178, -73.563788);
   clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
 
   marker = champlain_marker_new_with_label ("New York", "Sans 25", &white, NULL);
-  champlain_marker_set_position (CHAMPLAIN_MARKER (marker), 40.77, -73.98);
+  champlain_base_marker_set_position (CHAMPLAIN_BASE_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", NULL, &orange);
-  champlain_marker_set_position(CHAMPLAIN_MARKER (marker), 47.130885, -70.764141);
+  champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 47.130885, -70.764141);
   clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
 
   clutter_actor_hide (CLUTTER_ACTOR (layer));
@@ -223,7 +223,7 @@ main (int argc,
   button = gtk_image_new ();
   g_signal_connect (view, "notify::state", G_CALLBACK (view_state_changed),
       button);
-  gtk_box_pack_end (GTK_HBOX (bbox), button, FALSE, FALSE, 0);
+  gtk_box_pack_end (GTK_BOX (bbox), button, FALSE, FALSE, 0);
 
   viewport = gtk_viewport_new (NULL, NULL);
   gtk_viewport_set_shadow_type (GTK_VIEWPORT(viewport), GTK_SHADOW_ETCHED_IN);
index 259751f1a69b80c7ac656d371e80e9238b68335a..809530fad99a9568bdf5deb6429e4861393ba9df 100644 (file)
@@ -19,7 +19,7 @@
 #include <champlain/champlain.h>
 
 #define PADDING 10
-ChamplainMarker *markers [4];
+ChamplainBaseMarker *markers [4];
 
 static gboolean
 map_view_button_release_cb (ClutterActor *actor,
@@ -91,8 +91,8 @@ create_marker_layer (ChamplainView *view)
 
   marker = champlain_marker_new_with_label ("MontrĂ©al", "Airmole 14", NULL,
       NULL);
-  markers[0] = CHAMPLAIN_MARKER (marker);
-  champlain_marker_set_position (CHAMPLAIN_MARKER (marker),
+  markers[0] = CHAMPLAIN_BASE_MARKER (marker);
+  champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker),
       45.528178, -73.563788);
   clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
   clutter_actor_set_reactive (marker, TRUE);
@@ -101,14 +101,14 @@ create_marker_layer (ChamplainView *view)
 
   marker = champlain_marker_new_with_label ("New York", "Sans 25", &white,
       NULL);
-  markers[1] = CHAMPLAIN_MARKER (marker);
-  champlain_marker_set_position (CHAMPLAIN_MARKER (marker), 40.77, -73.98);
+  markers[1] = CHAMPLAIN_BASE_MARKER (marker);
+  champlain_base_marker_set_position (CHAMPLAIN_BASE_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",
       NULL, &orange);
-  markers[2] = CHAMPLAIN_MARKER (marker);
-  champlain_marker_set_position (CHAMPLAIN_MARKER (marker), 47.130885,
+  markers[2] = CHAMPLAIN_BASE_MARKER (marker);
+  champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 47.130885,
       -70.764141);
   clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
 
index 84b245ee0e6b402593138b7f5e5085bbf5f2b407..5e757800b728eb19457f143a11632bcfaf5e2910 100644 (file)
@@ -42,6 +42,7 @@
     <title>I. View API Reference</title>
     <xi:include href="xml/champlain-view.xml"/>
     <xi:include href="xml/champlain-layer.xml"/>
+    <xi:include href="xml/champlain-base-marker.xml"/>
     <xi:include href="xml/champlain-marker.xml"/>
     <xi:include href="xml/champlain-version.xml"/>
   </chapter>
index 75c38b98d16d86b66b7c0f487d2709b273448bda..f13ddb42f3f394d4ab9b5d5740a99f9b8e0af10d 100644 (file)
@@ -2,6 +2,7 @@
 
 champlain_view_get_type
 champlain_marker_get_type
+champlain_base_marker_get_type
 champlain_layer_get_type
 champlain_map_source_get_type
 champlain_network_map_source_get_type