]> err.no Git - libchamplain/commitdiff
Add a lot of properties to markers, and have it change if they are updated.
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Sat, 4 Apr 2009 18:09:32 +0000 (21:09 +0300)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Sun, 12 Apr 2009 01:41:48 +0000 (21:41 -0400)
champlain/champlain-marker.c
champlain/champlain-marker.h
demos/launcher-gtk.c
demos/launcher.c
docs/reference/libchamplain-sections.txt

index defe131e6075b2c296b2a614293b1f83ee04513c..02fd50727fbe2a04e2dc7994198b61d17e678e72 100644 (file)
  *
  * A 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 marker
- * using #champlain_marker_set_anchor.  Set the markers position on the map
+ * using #clutter_actor_set_anchor.  Set the markers position on the map
  * using #champlain_marker_set_position.
  *
  * Champlain has a default type of markers with text. To create one,
- * use #champlain_marker_new_with_label.
+ * use #champlain_marker_new_with_text.
  */
 
 #include "config.h"
@@ -52,6 +52,7 @@
 #include <glib-object.h>
 #include <cairo.h>
 #include <math.h>
+#include <string.h>
 
 enum
 {
@@ -62,30 +63,89 @@ enum
 enum
 {
   PROP_0,
+  PROP_IMAGE,
+  PROP_TEXT,
+  PROP_USE_MARKUP,
+  PROP_ALIGNMENT,
+  PROP_ATTRIBUTES,
+  PROP_ELLIPSIZE,
+  PROP_COLOR,
+  PROP_TEXT_COLOR,
+  PROP_FONT_NAME,
+  PROP_WRAP,
+  PROP_WRAP_MODE,
+  PROP_SINGLE_LINE_MODE
 };
 
 //static guint champlain_marker_signals[LAST_SIGNAL] = { 0, };
 
 struct _ChamplainMarkerPrivate
 {
-  gboolean tmp;
+  gchar *text;
+  ClutterActor *image;
+  gboolean use_markup;
+  PangoAlignment alignment;
+  PangoAttrList *attributes;
+  ClutterColor *color;
+  ClutterColor *text_color;
+  gchar *font_name;
+  gboolean wrap;
+  PangoWrapMode wrap_mode;
+  gboolean single_line_mode;
+  PangoEllipsizeMode ellipsize;
+
+  ClutterActor *text_actor;
+  ClutterActor *shadow;
+  ClutterActor *background;
 };
 
 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 draw_marker (ChamplainMarker *marker);
+
 static void
 champlain_marker_get_property (GObject *object,
                                guint prop_id,
                                GValue *value,
                                GParamSpec *pspec)
 {
-    //ChamplainMarker *marker = CHAMPLAIN_MARKER (object);
-    //ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
+    ChamplainMarker *marker = CHAMPLAIN_MARKER (object);
+    ChamplainMarkerPrivate *priv = marker->priv;
 
     switch (prop_id)
       {
+        case PROP_TEXT:
+          g_value_set_string (value, priv->text);
+          break;
+        case PROP_IMAGE:
+          g_value_set_object (value, priv->image);
+          break;
+        case PROP_USE_MARKUP:
+          g_value_set_boolean (value, priv->use_markup);
+          break;
+        case PROP_ALIGNMENT:
+          g_value_set_enum (value, priv->alignment);
+          break;
+        case PROP_COLOR:
+          clutter_value_set_color (value, priv->color);
+          break;
+        case PROP_TEXT_COLOR:
+          clutter_value_set_color (value, priv->text_color);
+          break;
+        case PROP_FONT_NAME:
+          g_value_set_string (value, priv->font_name);
+          break;
+        case PROP_WRAP:
+          g_value_set_boolean (value, priv->wrap);
+          break;
+        case PROP_WRAP_MODE:
+          g_value_set_enum (value, priv->wrap_mode);
+          break;
+        case PROP_ELLIPSIZE:
+          g_value_set_enum (value, priv->ellipsize);
+          break;
         default:
           G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       }
@@ -97,11 +157,41 @@ 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 = marker->priv;
 
     switch (prop_id)
     {
+      case PROP_TEXT:
+        champlain_marker_set_text (marker, g_value_get_string (value));
+        break;
+      case PROP_IMAGE:
+        champlain_marker_set_image (marker, g_value_get_object (value));
+        break;
+      case PROP_USE_MARKUP:
+        champlain_marker_set_use_markup (marker, g_value_get_boolean (value));
+        break;
+      case PROP_ALIGNMENT:
+        champlain_marker_set_alignment (marker, g_value_get_enum (value));
+        break;
+      case PROP_COLOR:
+        champlain_marker_set_color (marker, clutter_value_get_color (value));
+        break;
+      case PROP_TEXT_COLOR:
+        champlain_marker_set_text_color (marker, clutter_value_get_color (value));
+        break;
+      case PROP_FONT_NAME:
+        champlain_marker_set_font_name (marker, g_value_get_string (value));
+        break;
+      case PROP_WRAP:
+        champlain_marker_set_wrap (marker, g_value_get_boolean (value));
+        break;
+      case PROP_WRAP_MODE:
+        champlain_marker_set_wrap_mode (marker, g_value_get_enum (value));
+        break;
+      case PROP_ELLIPSIZE:
+        champlain_marker_set_ellipsize (marker, g_value_get_enum (value));
+        break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -110,8 +200,14 @@ champlain_marker_set_property (GObject *object,
 static void
 champlain_marker_finalize (GObject *object)
 {
-  //ChamplainMarker *marker = CHAMPLAIN_MARKER (object);
-  //ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
+  ChamplainMarker *marker = CHAMPLAIN_MARKER (object);
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  if (priv->text != NULL)
+    g_free (priv->text);
+
+  if (priv->image != NULL)
+    g_object_unref (priv->image);
 
   G_OBJECT_CLASS (champlain_marker_parent_class)->finalize (object);
 }
@@ -126,71 +222,139 @@ champlain_marker_class_init (ChamplainMarkerClass *markerClass)
   object_class->get_property = champlain_marker_get_property;
   object_class->set_property = champlain_marker_set_property;
 
+  /**
+  * ChamplainMarker:text:
+  *
+  * The text of the marker
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class, PROP_TEXT,
+      g_param_spec_string ("text", "Text", "The text of the marker",
+          "", CHAMPLAIN_PARAM_READWRITE));
+
+  /**
+  * ChamplainMarker:image:
+  *
+  * The image of the marker
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class, PROP_IMAGE,
+      g_param_spec_object ("image", "Image", "The image of the marker",
+          CLUTTER_TYPE_ACTOR, CHAMPLAIN_PARAM_READWRITE));
+
+  /**
+  * ChamplainMarker:use-markup:
+  *
+  * If the marker's text uses markup
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class, PROP_USE_MARKUP,
+      g_param_spec_boolean ("use-markup", "Use Markup", "The text uses markup",
+          FALSE, CHAMPLAIN_PARAM_READWRITE));
+
+  /**
+  * ChamplainMarker:alignment:
+  *
+  * The marker's alignment
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class, PROP_ALIGNMENT,
+      g_param_spec_enum ("alignment", "Alignment", "The marker's alignment",
+          PANGO_TYPE_ALIGNMENT, PANGO_ALIGN_LEFT, CHAMPLAIN_PARAM_READWRITE));
+
+  static const ClutterColor color = {50, 50, 50, 255};
+  static const ClutterColor text_color = {240, 240, 240, 255};
+
+  /**
+  * ChamplainMarker:color:
+  *
+  * The marker's color
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class, PROP_COLOR,
+      clutter_param_spec_color ("color", "Color", "The marker's color",
+          &color, CHAMPLAIN_PARAM_READWRITE));
+
+  /**
+  * ChamplainMarker:text-color:
+  *
+  * The marker's text color
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class, PROP_TEXT_COLOR,
+      clutter_param_spec_color ("text-color", "Text Color", "The marker's text color",
+          &text_color, CHAMPLAIN_PARAM_READWRITE));
+
+  /**
+  * ChamplainMarker:font-name:
+  *
+  * The marker's text font name
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class, PROP_FONT_NAME,
+      g_param_spec_string ("font-name", "Font Name", "The marker's text font name",
+          "Sans 11", CHAMPLAIN_PARAM_READWRITE));
+
+  /**
+  * ChamplainMarker:wrap:
+  *
+  * If the marker's text wrap
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class, PROP_WRAP,
+      g_param_spec_boolean ("wrap", "Wrap", "The marker's text wrap",
+          FALSE, CHAMPLAIN_PARAM_READWRITE));
+
+  /**
+  * ChamplainMarker:wrap-mode:
+  *
+  * If the marker's text wrap mode
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class, PROP_WRAP_MODE,
+      g_param_spec_enum ("wrap-mode", "Wrap Mode", "The marker's text wrap mode",
+          PANGO_TYPE_WRAP_MODE, PANGO_WRAP_WORD, CHAMPLAIN_PARAM_READWRITE));
+
+  /**
+  * ChamplainMarker:ellipsize:
+  *
+  * If the marker's ellipsize mode
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class, PROP_ELLIPSIZE,
+      g_param_spec_enum ("ellipsize", "Ellipsize Mode", "The marker's text ellipsize mode",
+          PANGO_TYPE_ELLIPSIZE_MODE, PANGO_ELLIPSIZE_NONE, CHAMPLAIN_PARAM_READWRITE));
 }
 
 static void
-champlain_marker_init (ChamplainMarker *marker)
-{
-  ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
-  marker->priv = priv;
-}
-
-/**
- * champlain_marker_new:
- *
- * Returns a new #ChamplainMarker ready to be used as a #ClutterActor.
- *
- * Since: 0.2
- */
-ClutterActor *
-champlain_marker_new (void)
-{
-  ChamplainMarker *marker;
-
-  marker = CHAMPLAIN_MARKER (g_object_new (CHAMPLAIN_TYPE_MARKER, NULL));
-  //ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
-
-  return CLUTTER_ACTOR (marker);
-}
-
-/**
- * champlain_marker_new_with_label:
- * @label: the text of the label
- * @font: the font to use to draw the text, for example "Courrier Bold 11", can be NULL
- * @text_color: a #ClutterColor, the color of the text, can be NULL
- * @marker_color: a #ClutterColor, the color of the marker, can be NULL
- *
- * Returns a new #ChamplainMarker with a drawn marker containing the given text.
- *
- * Since: 0.2
- */
-ClutterActor *
-champlain_marker_new_with_label (const gchar *label,
-                                 const gchar *font,
-                                 ClutterColor *text_color,
-                                 ClutterColor *marker_color)
+draw_marker (ChamplainMarker *marker)
 {
-  ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ());
-  ClutterColor default_text_color = { 0x22, 0x22, 0x22, 0xFF },
-               default_marker_color = { 0x2A, 0xB1, 0x26, 0xEE },
-               darker_color;
+  ChamplainMarkerPrivate *priv = marker->priv;
+  ClutterColor darker_color;
   ClutterActor *actor, *bg;
   cairo_t *cr;
   guint text_width, text_height, point;
   const gint padding = 5;
+  gboolean has_text = FALSE;
 
-  if (!font)
-    font = "Sans 11";
-  if (!text_color)
-    text_color = &default_text_color;
-  if (!marker_color)
-    marker_color = &default_marker_color;
+  if (priv->text != NULL && strlen (priv->text) > 0)
+    has_text = TRUE;
 
-  actor = clutter_label_new_with_text (font, label);
+  actor = clutter_label_new_with_text (priv->font_name, priv->text);
   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_label_set_color (CLUTTER_LABEL (actor), priv->text_color);
   clutter_container_add_actor (CLUTTER_CONTAINER (marker), actor);
 
   point = (text_height + 2 * padding) / 4.0;
@@ -208,12 +372,12 @@ champlain_marker_new_with_label (const gchar *label,
 
   cairo_set_line_width (cr, 1.0);
   cairo_set_source_rgba (cr,
-                        marker_color->red / 255.0,
-                        marker_color->green / 255.0,
-                        marker_color->blue / 255.0,
-                        marker_color->alpha / 255.0);
+                        priv->color->red / 255.0,
+                        priv->color->green / 255.0,
+                        priv->color->blue / 255.0,
+                        priv->color->alpha / 255.0);
   cairo_fill_preserve (cr);
-  clutter_color_darken (marker_color, &darker_color);
+  clutter_color_darken (priv->color, &darker_color);
   cairo_set_source_rgba (cr,
                         darker_color.red / 255.0,
                         darker_color.green / 255.0,
@@ -227,6 +391,82 @@ champlain_marker_new_with_label (const gchar *label,
   clutter_actor_raise (actor, bg);
 
   clutter_actor_set_anchor_point (CLUTTER_ACTOR (marker), 0, text_height + point);
+}
+
+static void
+property_notify (GObject *gobject,
+    GParamSpec *arg1,
+    gpointer user_data)
+{
+  draw_marker (CHAMPLAIN_MARKER (gobject));
+}
+
+static void
+champlain_marker_init (ChamplainMarker *marker)
+{
+  ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker) ;
+  marker->priv = priv;
+
+  priv->text = NULL;
+  priv->image = NULL;
+  priv->use_markup = FALSE;
+  priv->alignment = PANGO_ALIGN_LEFT;
+  priv->attributes = NULL;
+  priv->color = g_new0 (ClutterColor, 1);
+  clutter_color_parse ("#333", priv->color);
+  priv->text_color = g_new0 (ClutterColor, 1);
+  clutter_color_parse ("#eee", priv->text_color);
+  priv->font_name = g_strdup ("Sans 11");
+  priv->wrap = FALSE;
+  priv->wrap_mode = PANGO_WRAP_WORD;
+  priv->single_line_mode = TRUE;
+  priv->ellipsize = PANGO_ELLIPSIZE_NONE;
+
+  g_signal_connect (G_OBJECT (marker), "notify", G_CALLBACK (property_notify), NULL);
+}
+
+/**
+ * champlain_marker_new:
+ *
+ * Returns a new #ChamplainMarker ready to be used as a #ClutterActor.
+ *
+ * Since: 0.2
+ */
+ClutterActor *
+champlain_marker_new (void)
+{
+  return CLUTTER_ACTOR (g_object_new (CHAMPLAIN_TYPE_MARKER, NULL));
+}
+
+/**
+ * champlain_marker_new_with_text:
+ * @text: the text of the text
+ * @font: the font to use to draw the text, for example "Courrier Bold 11", can be NULL
+ * @text_color: a #ClutterColor, the color of the text, can be NULL
+ * @marker_color: a #ClutterColor, the color of the marker, can be NULL
+ *
+ * Returns a new #ChamplainMarker with a drawn marker containing the given text.
+ *
+ * Since: 0.2
+ */
+ClutterActor *
+champlain_marker_new_with_text (const gchar *text,
+                                 const gchar *font,
+                                 ClutterColor *text_color,
+                                 ClutterColor *marker_color)
+{
+  ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ());
+
+  champlain_marker_set_text (marker, text);
+
+  if (font != NULL)
+    champlain_marker_set_font_name (marker, font);
+
+  if (text_color != NULL)
+    champlain_marker_set_text_color (marker, text_color);
+
+  if (marker_color != NULL)
+    champlain_marker_set_color (marker, marker_color);
 
   return CLUTTER_ACTOR (marker);
 }
@@ -239,6 +479,7 @@ champlain_marker_new_with_label (const gchar *label,
  * Returns a new #ChamplainMarker with a drawn marker containing the given
  * image.
  *
+ * Since: 0.2
  */
 ClutterActor *
 champlain_marker_new_with_image (const gchar *filename, GError **error)
@@ -271,14 +512,12 @@ champlain_marker_new_with_image (const gchar *filename, GError **error)
  * Returns a new #ChamplainMarker with a drawn marker containing the given
  * image.
  *
+ * Since: 0.4
  */
 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_full (const gchar *text,
+    const gchar *filename,
+    GError **error)
 {
   if (filename == NULL)
     return NULL;
@@ -291,13 +530,480 @@ champlain_marker_new_with_image_full (const gchar *filename,
       g_object_unref (G_OBJECT (marker));
       return NULL;
     }
+// TODO
+  clutter_container_add_actor (CLUTTER_CONTAINER (marker), actor);
+  return CLUTTER_ACTOR (marker);
+}
 
-  clutter_actor_set_size (actor, width, height);
+/**
+ * champlain_marker_set_text:
+ * @marker: The marker
+ * @text: The text
+ *
+ * Sets the marker's text.
+ *
+ * Since: 0.4
+ */
+void
+champlain_marker_set_text (ChamplainMarker *marker,
+    const gchar *text)
+{
+  g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
 
-  clutter_container_add_actor (CLUTTER_CONTAINER (marker), actor);
-  clutter_actor_set_anchor_point (CLUTTER_ACTOR (marker), anchor_x,
-      anchor_y);
+  ChamplainMarkerPrivate *priv = marker->priv;
 
-  return CLUTTER_ACTOR (marker);
+  if (priv->text != NULL)
+    g_free (priv->text);
+
+  priv->text = g_strdup (text);
+  g_object_notify (G_OBJECT (marker), "text");
+}
+
+/**
+ * champlain_marker_set_image:
+ * @marker: The marker
+ * @image: The image as a @ClutterActor
+ *
+ * Sets the marker's image.
+ *
+ * Since: 0.4
+ */
+void
+champlain_marker_set_image (ChamplainMarker *marker,
+    ClutterActor *image)
+{
+  g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
+  g_return_if_fail (CLUTTER_IS_ACTOR (image));
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  if (priv->image != NULL)
+    g_object_unref (priv->image);
+
+  priv->image = g_object_ref (image);
+  g_object_notify (G_OBJECT (marker), "image");
+}
+
+/**
+ * champlain_marker_set_use_markup:
+ * @marker: The marker
+ * @markup: The value
+ *
+ * Sets if the marker's text uses markup.
+ *
+ * Since: 0.4
+ */
+void
+champlain_marker_set_use_markup (ChamplainMarker *marker,
+    gboolean markup)
+{
+  g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  priv->use_markup = markup;
+  g_object_notify (G_OBJECT (marker), "use-markup");
+}
+
+/**
+ * champlain_marker_set_alignment:
+ * @marker: The marker
+ * @alignment: The marker's alignment
+ *
+ * Set the marker's text alignment.
+ *
+ * Since: 0.4
+ */
+void
+champlain_marker_set_alignment (ChamplainMarker *marker,
+    PangoAlignment alignment)
+{
+  g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  priv->alignment = alignment;
+  g_object_notify (G_OBJECT (marker), "alignment");
+}
+
+/**
+ * champlain_marker_set_color:
+ * @marker: The marker
+ * @color: The marker's background color.
+ *
+ * Set the marker's background color.
+ *
+ * Since: 0.4
+ */
+void
+champlain_marker_set_color (ChamplainMarker *marker,
+    const ClutterColor *color)
+{
+  g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  if (priv->color != NULL)
+    clutter_color_free (priv->color);
+
+  priv->color = clutter_color_copy (color);
+  g_object_notify (G_OBJECT (marker), "color");
+}
+
+/**
+ * champlain_marker_set_text_color:
+ * @marker: The marker
+ * @color: The marker's text color.
+ *
+ * Set the marker's text color.
+ *
+ * Since: 0.4
+ */
+void
+champlain_marker_set_text_color (ChamplainMarker *marker,
+    const ClutterColor *color)
+{
+  g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  if (priv->text_color != NULL)
+    clutter_color_free (priv->text_color);
+
+  priv->text_color = clutter_color_copy (color);
+  g_object_notify (G_OBJECT (marker), "text-color");
+}
+
+/**
+ * champlain_marker_set_text_color:
+ * @marker: The marker
+ * @font_name: The marker's font name.
+ *
+ * Set the marker's font name such as "Sans 12".
+ *
+ * Since: 0.4
+ */
+void
+champlain_marker_set_font_name (ChamplainMarker *marker,
+    const gchar *font_name)
+{
+  g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  if (priv->font_name != NULL)
+    g_free (priv->font_name);
+
+  priv->font_name = g_strdup (font_name);
+  g_object_notify (G_OBJECT (marker), "font-name");
+}
+
+/**
+ * champlain_marker_set_wrap:
+ * @marker: The marker
+ * @wrap: The marker's wrap.
+ *
+ * Set if the marker's text wrap.
+ *
+ * Since: 0.4
+ */
+void
+champlain_marker_set_wrap (ChamplainMarker *marker,
+    gboolean wrap)
+{
+  g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  priv->wrap = wrap;
+  g_object_notify (G_OBJECT (marker), "wrap");
+}
+
+/**
+ * champlain_marker_set_wrap_mode:
+ * @marker: The marker
+ * @wrap: The marker's wrap.
+ *
+ * Set the marker's text color.
+ *
+ * Since: 0.4
+ */
+void
+champlain_marker_set_wrap_mode (ChamplainMarker *marker,
+    PangoWrapMode wrap_mode)
+{
+  g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  priv->wrap_mode = wrap_mode;
+  g_object_notify (G_OBJECT (marker), "wrap");
 }
 
+/**
+ * champlain_marker_set_attributes:
+ * @marker: The marker
+ * @attributes: The marker's text attributes.
+ *
+ * Set the marker's text attribute.
+ *
+ * Since: 0.4
+ */
+void
+champlain_marker_set_attributes (ChamplainMarker *marker,
+    PangoAttrList *attributes)
+{
+  g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  if (attributes)
+    pango_attr_list_ref (attributes);
+
+  if (priv->attributes)
+    pango_attr_list_unref (priv->attributes);
+
+  priv->attributes = attributes;
+
+  g_object_notify (G_OBJECT (marker), "attributes");
+}
+
+/**
+ * champlain_marker_set_ellipsize:
+ * @marker: The marker
+ * @ellipsize: The marker's ellipsize mode.
+ *
+ * Set the marker's text ellipsize mode.
+ *
+ * Since: 0.4
+ */
+void
+champlain_marker_set_ellipsize (ChamplainMarker *marker,
+    PangoEllipsizeMode ellipsize)
+{
+  g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  priv->ellipsize = ellipsize;
+  g_object_notify (G_OBJECT (marker), "ellipsize");
+}
+/**
+ * champlain_marker_set_single_line_mode:
+ * @marker: The marker
+ * @mode: The marker's single line mode
+ *
+ * Set if the marker's text is on a single line.
+ *
+ * Since: 0.4
+ */
+void
+champlain_marker_set_single_line_mode (ChamplainMarker *marker,
+    gboolean mode)
+{
+  g_return_if_fail (CHAMPLAIN_IS_MARKER (marker));
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  priv->single_line_mode = mode;
+
+  g_object_notify (G_OBJECT (marker), "single-line-mode");
+}
+
+/**
+ * champlain_marker_get_image:
+ * @marker: The marker
+ *
+ * Returns the marker's image.
+ *
+ * Since: 0.4
+ */
+ClutterActor *
+champlain_marker_get_image (ChamplainMarker *marker)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), NULL);
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  return priv->image;
+}
+
+/**
+ * champlain_marker_get_use_markup:
+ * @marker: The marker
+ *
+ * Returns if the marker's text contains markup.
+ *
+ * Since: 0.4
+ */
+gboolean
+champlain_marker_get_use_markup (ChamplainMarker *marker)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  return priv->use_markup;
+}
+
+/**
+ * champlain_marker_get_text:
+ * @marker: The marker
+ *
+ * Returns the marker's text.
+ *
+ * Since: 0.4
+ */
+const gchar *
+champlain_marker_get_text (ChamplainMarker *marker)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  return priv->text;
+}
+
+/**
+ * champlain_marker_get_alignment:
+ * @marker: The marker
+ *
+ * Returns the marker's text alignment.
+ *
+ * Since: 0.4
+ */
+PangoAlignment
+champlain_marker_get_alignment (ChamplainMarker *marker)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  return priv->alignment;
+}
+
+/**
+ * champlain_marker_get_color:
+ * @marker: The marker
+ *
+ * Returns the marker's color.
+ *
+ * Since: 0.4
+ */
+ClutterColor *
+champlain_marker_get_color (ChamplainMarker *marker)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  return priv->color;
+}
+
+/**
+ * champlain_marker_get_text_color:
+ * @marker: The marker
+ *
+ * Returns the marker's text color.
+ *
+ * Since: 0.4
+ */
+ClutterColor *
+champlain_marker_get_text_color (ChamplainMarker *marker)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  return priv->text_color;
+}
+
+/**
+ * champlain_marker_get_font_name:
+ * @marker: The marker
+ *
+ * Returns the marker's font name.
+ *
+ * Since: 0.4
+ */
+const gchar *
+champlain_marker_get_font_name (ChamplainMarker *marker)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  return priv->font_name;
+}
+
+/**
+ * champlain_marker_get_wrap:
+ * @marker: The marker
+ *
+ * Returns if the marker's text wraps.
+ *
+ * Since: 0.4
+ */
+gboolean
+champlain_marker_get_wrap (ChamplainMarker *marker)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  return priv->wrap;
+}
+
+/**
+ * champlain_marker_get_wrap_mode:
+ * @marker: The marker
+ *
+ * Returns the marker's text wrap mode.
+ *
+ * Since: 0.4
+ */
+PangoWrapMode
+champlain_marker_get_wrap_mode (ChamplainMarker *marker)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  return priv->wrap_mode;
+}
+
+/**
+ * champlain_marker_get_ellipsize:
+ * @marker: The marker
+ *
+ * Returns the marker's text ellipsize mode;
+ *
+ * Since: 0.4
+ */
+PangoEllipsizeMode
+champlain_marker_get_ellipsize (ChamplainMarker *marker)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  return priv->ellipsize;
+}
+
+/**
+ * champlain_marker_get_single_line_mode:
+ * @marker: The marker
+ *
+ * Returns the marker's text single side mode;
+ *
+ * Since: 0.4
+ */
+gboolean
+champlain_marker_get_single_line_mode (ChamplainMarker *marker)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MARKER (marker), FALSE);
+
+  ChamplainMarkerPrivate *priv = marker->priv;
+
+  return priv->single_line_mode;
+}
index e9246e528c092f88e5e880daebc0e9289b245a7f..f2d7c7a08a3a03e872dd4b26472f1bf6d349dbf6 100644 (file)
@@ -56,14 +56,52 @@ GType champlain_marker_get_type (void);
 
 ClutterActor *champlain_marker_new (void);
 
-ClutterActor *champlain_marker_new_with_label (const gchar *label,
+ClutterActor *champlain_marker_new_with_text (const gchar *text,
     const gchar *font, ClutterColor *text_color, ClutterColor *marker_color);
 
-ClutterActor *champlain_marker_new_with_image(const gchar *filename,
+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);
+ClutterActor *champlain_marker_new_full (const gchar *text,
+    const gchar *image_filename,
+    GError **error);
+
+void champlain_marker_set_text (ChamplainMarker *marker,
+    const gchar *text);
+void champlain_marker_set_image (ChamplainMarker *marker,
+    ClutterActor *image);
+void champlain_marker_set_use_markup (ChamplainMarker *marker,
+    gboolean use_markup);
+void champlain_marker_set_alignment (ChamplainMarker *marker,
+    PangoAlignment alignment);
+void champlain_marker_set_color (ChamplainMarker *marker,
+    const ClutterColor *color);
+void champlain_marker_set_text_color (ChamplainMarker *marker,
+    const ClutterColor *color);
+void champlain_marker_set_font_name (ChamplainMarker *marker,
+    const gchar *font_name);
+void champlain_marker_set_wrap (ChamplainMarker *marker,
+    gboolean wrap);
+void champlain_marker_set_wrap_mode (ChamplainMarker *marker,
+    PangoWrapMode wrap_mode);
+void champlain_marker_set_attributes (ChamplainMarker *marker,
+    PangoAttrList *list);
+void champlain_marker_set_single_line_mode (ChamplainMarker *marker,
+    gboolean mode);
+void champlain_marker_set_ellipsize (ChamplainMarker *marker,
+    PangoEllipsizeMode mode);
+
+gboolean champlain_marker_get_use_markup (ChamplainMarker *marker);
+const gchar * champlain_marker_get_text (ChamplainMarker *marker);
+ClutterActor * champlain_marker_get_image (ChamplainMarker *marker);
+PangoAlignment champlain_marker_get_alignment (ChamplainMarker *marker);
+ClutterColor * champlain_marker_get_color (ChamplainMarker *marker);
+ClutterColor * champlain_marker_get_text_color (ChamplainMarker *marker);
+const gchar * champlain_marker_get_font_name (ChamplainMarker *marker);
+gboolean champlain_marker_get_wrap (ChamplainMarker *marker);
+PangoWrapMode champlain_marker_get_wrap_mode (ChamplainMarker *marker);
+PangoEllipsizeMode champlain_marker_get_ellipsize (ChamplainMarker *marker);
+gboolean champlain_marker_get_single_line_mode (ChamplainMarker *marker);
 
 G_END_DECLS
 
index e93292e3d6b8f605be90f64363c0b0b74f904538..c92a3e76ec379a95fd3b1203c9580dfd13e3913c 100644 (file)
@@ -47,15 +47,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);
+  marker = champlain_marker_new_with_text ("Montréal", "Airmole 14", NULL, NULL);
   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);
+  marker = champlain_marker_new_with_text ("New York", "Sans 25", &white, NULL);
   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);
+  marker = champlain_marker_new_with_text ("Saint-Tite-des-Caps", "Serif 12", NULL, &orange);
   champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 47.130885, -70.764141);
   clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
 
index 809530fad99a9568bdf5deb6429e4861393ba9df..b505168195cf0ca57960e3976ad708dfbffffc0f 100644 (file)
@@ -89,7 +89,7 @@ create_marker_layer (ChamplainView *view)
 
   layer = champlain_layer_new ();
 
-  marker = champlain_marker_new_with_label ("Montréal", "Airmole 14", NULL,
+  marker = champlain_marker_new_with_text ("Montréal", "Airmole 14", NULL,
       NULL);
   markers[0] = CHAMPLAIN_BASE_MARKER (marker);
   champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker),
@@ -99,13 +99,13 @@ create_marker_layer (ChamplainView *view)
   g_signal_connect_after (marker, "button-release-event",
       G_CALLBACK (marker_button_release_cb), view);
 
-  marker = champlain_marker_new_with_label ("New York", "Sans 25", &white,
+  marker = champlain_marker_new_with_text ("New York", "Sans 25", &white,
       NULL);
   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",
+  marker = champlain_marker_new_with_text ("Saint-Tite-des-Caps", "Serif 12",
       NULL, &orange);
   markers[2] = CHAMPLAIN_BASE_MARKER (marker);
   champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 47.130885,
index b34ac374c4d00599f8f7ef3ea867a1f9c7d7f2d0..57fce397c092f4ee4c755208c3dc517a2408d520 100644 (file)
@@ -31,13 +31,33 @@ CHAMPLAIN_MAP_SOURCE_GET_CLASS
 <SECTION>
 <FILE>champlain-marker</FILE>
 ChamplainMarkerPrivate
-<TITLE>ChamplainMarker</TITLE>
-ChamplainMarker
 champlain_marker_new
-champlain_marker_set_position
-champlain_marker_new_with_label
+champlain_marker_new_with_text
 champlain_marker_new_with_image
-champlain_marker_new_with_image_full
+champlain_marker_new_full
+champlain_marker_set_text
+champlain_marker_set_image
+champlain_marker_set_use_markup
+champlain_marker_set_alignment
+champlain_marker_set_color
+champlain_marker_set_text_color
+champlain_marker_set_font_name
+champlain_marker_set_wrap
+champlain_marker_set_wrap_mode
+champlain_marker_set_attributes
+champlain_marker_set_single_line_mode
+champlain_marker_set_ellipsize
+champlain_marker_get_use_markup
+champlain_marker_get_text
+champlain_marker_get_image
+champlain_marker_get_alignment
+champlain_marker_get_color
+champlain_marker_get_text_color
+champlain_marker_get_font_name
+champlain_marker_get_wrap
+champlain_marker_get_wrap_mode
+champlain_marker_get_ellipsize
+champlain_marker_get_single_line_mode
 <SUBSECTION Standard>
 CHAMPLAIN_MARKER
 CHAMPLAIN_IS_MARKER
@@ -48,8 +68,26 @@ CHAMPLAIN_IS_MARKER_CLASS
 CHAMPLAIN_MARKER_GET_CLASS
 </SECTION>
 
+<SECTION>
+<FILE>champlain-base-marker</FILE>
+ChamplainBaseMarkerPrivate
+<TITLE>ChamplainBaseMarker</TITLE>
+ChamplainBaseMarker
+champlain_base_marker_new
+champlain_base_marker_set_position
+<SUBSECTION Standard>
+CHAMPLAIN_BASE_MARKER
+CHAMPLAIN_IS_BASE_MARKER
+CHAMPLAIN_TYPE_BASE_MARKER
+champlain_base_marker_get_type
+CHAMPLAIN_BASE_MARKER_CLASS
+CHAMPLAIN_IS_BASE_MARKER_CLASS
+CHAMPLAIN_BASE_MARKER_GET_CLASS
+</SECTION>
+
 <SECTION>
 <FILE>champlain-zoom-level</FILE>
+ChamplainZoomLevelPrivate
 <TITLE>ChamplainZoomLevel</TITLE>
 ChamplainZoomLevel
 champlain_zoom_level_new
@@ -184,9 +222,8 @@ CHAMPLAIN_LAYER_GET_CLASS
 
 <SECTION>
 <FILE>champlain-private</FILE>
-CHAMPLAIN_MARKER_GET_PRIVATE
 Map
-ChamplainMarkerPrivate
+ChamplainBaseMarkerPrivate
 </SECTION>
 
 <SECTION>
@@ -250,8 +287,6 @@ CHAMPLAIN_API
 CHAMPLAIN_OBSOLETE_API
 ChamplainView
 ChamplainViewClass
-ChamplainMarker
-ChamplainMarkerClass
 CHAMPLAIN_PARAM_READABLE
 CHAMPLAIN_PARAM_READWRITE
 ChamplainState