[libchamplain] Rename Line to Polygon



commit 7dba387a066533c807e6d349dd0af2a2dcce6d6d
Author: Pierre-Luc Beaudoin <pierre-luc pierlux com>
Date:   Tue Jun 9 21:00:49 2009 -0400

    Rename Line to Polygon

 champlain/Makefile.am                              |    8 +-
 champlain/champlain-line.h                         |   88 --------
 .../{champlain-line.c => champlain-polygon.c}      |  228 ++++++++++----------
 champlain/champlain-polygon.h                      |   88 ++++++++
 champlain/champlain-private.h                      |    2 +-
 champlain/champlain-view.c                         |  109 +++++-----
 champlain/champlain-view.h                         |   10 +-
 demos/Makefile.am                                  |    6 +-
 demos/{lines.c => polygons.c}                      |   46 ++--
 9 files changed, 293 insertions(+), 292 deletions(-)
---
diff --git a/champlain/Makefile.am b/champlain/Makefile.am
index 67cdcee..fd5b2ea 100644
--- a/champlain/Makefile.am
+++ b/champlain/Makefile.am
@@ -28,7 +28,7 @@ libchamplain_headers = \
 	champlain-network-map-source.h	\
 	champlain-map-source-factory.h	\
 	champlain-map-source-desc.h	\
-	champlain-line.h		\
+	champlain-polygon.h		\
 	champlain-version.h
 
 
@@ -47,7 +47,7 @@ libchamplain_0_3_la_SOURCES = \
 	champlain-network-map-source.c	\
 	champlain-map-source-factory.c	\
 	champlain-cache.c		\
-	champlain-line.c
+	champlain-polygon.c
 
 noinst_HEADERS = \
 	champlain-debug.h  		\
@@ -65,7 +65,7 @@ noinst_HEADERS = \
 	champlain-map-source-desc.h	\
 	champlain-version.h		\
 	champlain-cache.h		\
-	champlain-line.h		\
+	champlain-polygon.h		\
 	champlain-version.h
 
 libchamplain_include_HEADERS = \
@@ -84,7 +84,7 @@ libchamplain_include_HEADERS = \
 	champlain-marker.h		\
 	champlain-version.h		\
 	champlain-cache.h		\
-	champlain-line.h		\
+	champlain-polygon.h		\
 	champlain-version.h
 
 libchamplain_0_3_la_LIBADD = $(DEPS_LIBS) $(SOUP_LIBS) ../tidy/libtidy-1.0.la
diff --git a/champlain/champlain-line.c b/champlain/champlain-polygon.c
similarity index 55%
rename from champlain/champlain-line.c
rename to champlain/champlain-polygon.c
index d43bc7d..f569592 100644
--- a/champlain/champlain-line.c
+++ b/champlain/champlain-polygon.c
@@ -17,19 +17,19 @@
  */
 
 /**
- * SECTION:champlain-line
- * @short_description: A container for #ChamplainLine
+ * SECTION:champlain-polygon
+ * @short_description: A container for #ChamplainPolygon
  *
- * A ChamplainLine is little more than a #ClutterContainer. It keeps the
- * lines ordered so that they display correctly.
+ * A ChamplainPolygon is little more than a #ClutterContainer. It keeps the
+ * polygons ordered so that they display correctly.
  *
- * Use #clutter_container_add to add lines to the line and
+ * Use #clutter_container_add to add polygons to the polygon and
  * #clutter_container_remove to remove them.
  */
 
 #include "config.h"
 
-#include "champlain-line.h"
+#include "champlain-polygon.h"
 
 #include "champlain-defines.h"
 #include "champlain-private.h"
@@ -40,10 +40,10 @@
 static ClutterColor DEFAULT_FILL_COLOR = {0xcc, 0x00, 0x00, 0xaa};
 static ClutterColor DEFAULT_STROKE_COLOR = {0xa4, 0x00, 0x00, 0xff};
 
-G_DEFINE_TYPE (ChamplainLine, champlain_line, G_TYPE_OBJECT)
+G_DEFINE_TYPE (ChamplainPolygon, champlain_polygon, G_TYPE_OBJECT)
 
 #define GET_PRIVATE(o) \
-  (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHAMPLAIN_TYPE_LINE, ChamplainLinePrivate))
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHAMPLAIN_TYPE_POLYGON, ChamplainPolygonPrivate))
 
 enum
 {
@@ -57,12 +57,12 @@ enum
 };
 
 static void
-champlain_line_get_property (GObject *object,
+champlain_polygon_get_property (GObject *object,
     guint property_id,
     GValue *value,
     GParamSpec *pspec)
 {
-  ChamplainLinePrivate *priv = GET_PRIVATE (object);
+  ChamplainPolygonPrivate *priv = GET_PRIVATE (object);
 
   switch (property_id)
     {
@@ -90,12 +90,12 @@ champlain_line_get_property (GObject *object,
 }
 
 static void
-champlain_line_set_property (GObject *object,
+champlain_polygon_set_property (GObject *object,
     guint property_id,
     const GValue *value,
     GParamSpec *pspec)
 {
-  ChamplainLinePrivate *priv = GET_PRIVATE (object);
+  ChamplainPolygonPrivate *priv = GET_PRIVATE (object);
 
   switch (property_id)
     {
@@ -103,23 +103,23 @@ champlain_line_set_property (GObject *object,
         priv->closed_path = g_value_get_boolean (value);
         break;
       case PROP_FILL:
-        champlain_line_set_fill (CHAMPLAIN_LINE (object),
+        champlain_polygon_set_fill (CHAMPLAIN_POLYGON (object),
             g_value_get_boolean (value));
         break;
       case PROP_STROKE:
-        champlain_line_set_stroke (CHAMPLAIN_LINE (object),
+        champlain_polygon_set_stroke (CHAMPLAIN_POLYGON (object),
             g_value_get_boolean (value));
         break;
       case PROP_FILL_COLOR:
-        champlain_line_set_fill_color (CHAMPLAIN_LINE (object),
+        champlain_polygon_set_fill_color (CHAMPLAIN_POLYGON (object),
             clutter_value_get_color (value));
         break;
       case PROP_STROKE_COLOR:
-        champlain_line_set_stroke_color (CHAMPLAIN_LINE (object),
+        champlain_polygon_set_stroke_color (CHAMPLAIN_POLYGON (object),
             clutter_value_get_color (value));
         break;
       case PROP_STROKE_WIDTH:
-        champlain_line_set_stroke_width (CHAMPLAIN_LINE (object),
+        champlain_polygon_set_stroke_width (CHAMPLAIN_POLYGON (object),
             g_value_get_double (value));
         break;
       default:
@@ -128,33 +128,33 @@ champlain_line_set_property (GObject *object,
 }
 
 static void
-champlain_line_dispose (GObject *object)
+champlain_polygon_dispose (GObject *object)
 {
-  //ChamplainLinePrivate *priv = GET_PRIVATE (object);
+  //ChamplainPolygonPrivate *priv = GET_PRIVATE (object);
 
-  G_OBJECT_CLASS (champlain_line_parent_class)->dispose (object);
+  G_OBJECT_CLASS (champlain_polygon_parent_class)->dispose (object);
 }
 
 static void
-champlain_line_finalize (GObject *object)
+champlain_polygon_finalize (GObject *object)
 {
-  G_OBJECT_CLASS (champlain_line_parent_class)->finalize (object);
+  G_OBJECT_CLASS (champlain_polygon_parent_class)->finalize (object);
 }
 
 static void
-champlain_line_class_init (ChamplainLineClass *klass)
+champlain_polygon_class_init (ChamplainPolygonClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-  g_type_class_add_private (klass, sizeof (ChamplainLinePrivate));
+  g_type_class_add_private (klass, sizeof (ChamplainPolygonPrivate));
 
-  object_class->get_property = champlain_line_get_property;
-  object_class->set_property = champlain_line_set_property;
-  object_class->dispose = champlain_line_dispose;
-  object_class->finalize = champlain_line_finalize;
+  object_class->get_property = champlain_polygon_get_property;
+  object_class->set_property = champlain_polygon_set_property;
+  object_class->dispose = champlain_polygon_dispose;
+  object_class->finalize = champlain_polygon_finalize;
 
   /**
-  * ChamplainLine:close-path:
+  * ChamplainPolygon:close-path:
   *
   * The shape is a closed path
   *
@@ -168,7 +168,7 @@ champlain_line_class_init (ChamplainLineClass *klass)
           FALSE, CHAMPLAIN_PARAM_READWRITE));
 
   /**
-  * ChamplainLine:fill:
+  * ChamplainPolygon:fill:
   *
   * The shape should be filled
   *
@@ -182,7 +182,7 @@ champlain_line_class_init (ChamplainLineClass *klass)
           FALSE, CHAMPLAIN_PARAM_READWRITE));
 
   /**
-  * ChamplainLine:stroke:
+  * ChamplainPolygon:stroke:
   *
   * The shape should be stroked
   *
@@ -196,9 +196,9 @@ champlain_line_class_init (ChamplainLineClass *klass)
           TRUE, CHAMPLAIN_PARAM_READWRITE));
 
   /**
-  * ChamplainLine:stroke-color:
+  * ChamplainPolygon:stroke-color:
   *
-  * The line's stroke color
+  * The polygon's stroke color
   *
   * Since: 0.4
   */
@@ -206,14 +206,14 @@ champlain_line_class_init (ChamplainLineClass *klass)
       PROP_STROKE_COLOR,
       clutter_param_spec_color ("stroke-color",
         "Stroke Color",
-        "The line's stroke color",
+        "The polygon's stroke color",
         &DEFAULT_STROKE_COLOR,
         CHAMPLAIN_PARAM_READWRITE));
 
   /**
-  * ChamplainLine:text-color:
+  * ChamplainPolygon:text-color:
   *
-  * The line's fill color
+  * The polygon's fill color
   *
   * Since: 0.4
   */
@@ -221,14 +221,14 @@ champlain_line_class_init (ChamplainLineClass *klass)
       PROP_FILL_COLOR,
       clutter_param_spec_color ("fill-color",
           "Fill Color",
-          "The line's fill color",
+          "The polygon's fill color",
           &DEFAULT_FILL_COLOR,
           CHAMPLAIN_PARAM_READWRITE));
 
   /**
-  * ChamplainLine:stroke-width:
+  * ChamplainPolygon:stroke-width:
   *
-  * The line's stroke width (in pixels)
+  * The polygon's stroke width (in pixels)
   *
   * Since: 0.4
   */
@@ -236,14 +236,14 @@ champlain_line_class_init (ChamplainLineClass *klass)
       PROP_STROKE_WIDTH,
       g_param_spec_double ("stroke-width",
           "Stroke Width",
-          "The line's stroke width",
+          "The polygon's stroke width",
           0, 100.0,
           2.0,
           CHAMPLAIN_PARAM_READWRITE));
 }
 
 static void
-champlain_line_init (ChamplainLine *self)
+champlain_polygon_init (ChamplainPolygon *self)
 {
   self->priv = GET_PRIVATE (self);
 
@@ -257,24 +257,24 @@ champlain_line_init (ChamplainLine *self)
 }
 
 /**
- * champlain_line_new:
+ * champlain_polygon_new:
  *
- * Returns a new #ChamplainLine ready to be to draw lines on the map
+ * Returns a new #ChamplainPolygon ready to be to draw polygons on the map
  *
  * Since: 0.4
  */
-ChamplainLine *
-champlain_line_new ()
+ChamplainPolygon *
+champlain_polygon_new ()
 {
-  return g_object_new (CHAMPLAIN_TYPE_LINE, NULL);
+  return g_object_new (CHAMPLAIN_TYPE_POLYGON, NULL);
 }
 
 void
-champlain_line_add_point (ChamplainLine *self,
+champlain_polygon_add_point (ChamplainPolygon *self,
     gdouble lat,
     gdouble lon)
 {
-  g_return_if_fail (CHAMPLAIN_IS_LINE (self));
+  g_return_if_fail (CHAMPLAIN_IS_POLYGON (self));
 
   ChamplainPoint *point = g_new0 (ChamplainPoint, 1);
   point->lat = lat;
@@ -284,9 +284,9 @@ champlain_line_add_point (ChamplainLine *self,
 }
 
 void
-champlain_line_clear_points (ChamplainLine *self)
+champlain_polygon_clear_points (ChamplainPolygon *self)
 {
-  g_return_if_fail (CHAMPLAIN_IS_LINE (self));
+  g_return_if_fail (CHAMPLAIN_IS_POLYGON (self));
 
   GList *next = self->priv->points;
   while (next != NULL)
@@ -298,22 +298,22 @@ champlain_line_clear_points (ChamplainLine *self)
 }
 
 /**
- * champlain_line_set_fill_color:
- * @line: The line
- * @color: The line's fill color or NULL to reset to the
+ * champlain_polygon_set_fill_color:
+ * @polygon: The polygon
+ * @color: The polygon's fill color or NULL to reset to the
  *         default color. The color parameter is copied.
  *
- * Set the line's fill color.
+ * Set the polygon's fill color.
  *
  * Since: 0.4
  */
 void
-champlain_line_set_fill_color (ChamplainLine *line,
+champlain_polygon_set_fill_color (ChamplainPolygon *polygon,
     const ClutterColor *color)
 {
-  g_return_if_fail (CHAMPLAIN_IS_LINE (line));
+  g_return_if_fail (CHAMPLAIN_IS_POLYGON (polygon));
 
-  ChamplainLinePrivate *priv = line->priv;
+  ChamplainPolygonPrivate *priv = polygon->priv;
 
   if (priv->fill_color != NULL)
     clutter_color_free (priv->fill_color);
@@ -322,26 +322,26 @@ champlain_line_set_fill_color (ChamplainLine *line,
      color = &DEFAULT_FILL_COLOR;
 
   priv->fill_color = clutter_color_copy (color);
-  g_object_notify (G_OBJECT (line), "fill-color");
+  g_object_notify (G_OBJECT (polygon), "fill-color");
 }
 
 /**
- * champlain_line_set_stoke_color:
- * @line: The line
- * @color: The line's stroke color or NULL to reset to the
+ * champlain_polygon_set_stoke_color:
+ * @polygon: The polygon
+ * @color: The polygon's stroke color or NULL to reset to the
  *         default color. The color parameter is copied.
  *
- * Set the line's stroke color.
+ * Set the polygon's stroke color.
  *
  * Since: 0.4
  */
 void
-champlain_line_set_stroke_color (ChamplainLine *line,
+champlain_polygon_set_stroke_color (ChamplainPolygon *polygon,
     const ClutterColor *color)
 {
-  g_return_if_fail (CHAMPLAIN_IS_LINE (line));
+  g_return_if_fail (CHAMPLAIN_IS_POLYGON (polygon));
 
-  ChamplainLinePrivate *priv = line->priv;
+  ChamplainPolygonPrivate *priv = polygon->priv;
 
   if (priv->stroke_color != NULL)
     clutter_color_free (priv->stroke_color);
@@ -350,112 +350,112 @@ champlain_line_set_stroke_color (ChamplainLine *line,
      color = &DEFAULT_STROKE_COLOR;
 
   priv->stroke_color = clutter_color_copy (color);
-  g_object_notify (G_OBJECT (line), "stroke-color");
+  g_object_notify (G_OBJECT (polygon), "stroke-color");
 }
 
 /**
- * champlain_line_get_color:
- * @line: The line
+ * champlain_polygon_get_color:
+ * @polygon: The polygon
  *
- * Returns the line's fill color.
+ * Returns the polygon's fill color.
  *
  * Since: 0.4
  */
 ClutterColor *
-champlain_line_get_fill_color (ChamplainLine *line)
+champlain_polygon_get_fill_color (ChamplainPolygon *polygon)
 {
-  g_return_val_if_fail (CHAMPLAIN_IS_LINE (line), NULL);
+  g_return_val_if_fail (CHAMPLAIN_IS_POLYGON (polygon), NULL);
 
-  return line->priv->fill_color;
+  return polygon->priv->fill_color;
 }
 
 /**
- * champlain_line_get_stroke_color:
- * @line: The line
+ * champlain_polygon_get_stroke_color:
+ * @polygon: The polygon
  *
- * Returns the line's stroke color.
+ * Returns the polygon's stroke color.
  *
  * Since: 0.4
  */
 ClutterColor *
-champlain_line_get_stroke_color (ChamplainLine *line)
+champlain_polygon_get_stroke_color (ChamplainPolygon *polygon)
 {
-  g_return_val_if_fail (CHAMPLAIN_IS_LINE (line), NULL);
+  g_return_val_if_fail (CHAMPLAIN_IS_POLYGON (polygon), NULL);
 
-  return line->priv->stroke_color;
+  return polygon->priv->stroke_color;
 }
 
 /**
- * champlain_line_set_stroke:
- * @line: The line
- * @value: if the line is stroked
+ * champlain_polygon_set_stroke:
+ * @polygon: The polygon
+ * @value: if the polygon is stroked
  *
- * Sets the line to have a stroke
+ * Sets the polygon to have a stroke
  *
  * Since: 0.4
  */
 void
-champlain_line_set_stroke (ChamplainLine *line,
+champlain_polygon_set_stroke (ChamplainPolygon *polygon,
     gboolean value)
 {
-  g_return_if_fail (CHAMPLAIN_IS_LINE (line));
+  g_return_if_fail (CHAMPLAIN_IS_POLYGON (polygon));
 
-  line->priv->stroke = value;
+  polygon->priv->stroke = value;
 }
 
 /**
- * champlain_line_get_stroke:
- * @line: The line
+ * champlain_polygon_get_stroke:
+ * @polygon: The polygon
  *
- * Returns if the line has a stroke
+ * Returns if the polygon has a stroke
  *
  * Since: 0.4
  */
 gboolean
-champlain_line_get_stroke (ChamplainLine *line)
+champlain_polygon_get_stroke (ChamplainPolygon *polygon)
 {
-  g_return_val_if_fail (CHAMPLAIN_IS_LINE (line), FALSE);
+  g_return_val_if_fail (CHAMPLAIN_IS_POLYGON (polygon), FALSE);
 
-  return line->priv->stroke;
+  return polygon->priv->stroke;
 }
 
 /**
- * champlain_line_set_fill:
- * @line: The line
- * @value: if the line is filled
+ * champlain_polygon_set_fill:
+ * @polygon: The polygon
+ * @value: if the polygon is filled
  *
- * Sets the line to have be filled
+ * Sets the polygon to have be filled
  *
  * Since: 0.4
  */
 void
-champlain_line_set_fill (ChamplainLine *line,
+champlain_polygon_set_fill (ChamplainPolygon *polygon,
     gboolean value)
 {
-  g_return_if_fail (CHAMPLAIN_IS_LINE (line));
+  g_return_if_fail (CHAMPLAIN_IS_POLYGON (polygon));
 
-  line->priv->fill = value;
+  polygon->priv->fill = value;
 }
 
 /**
- * champlain_line_get_fill:
- * @line: The line
+ * champlain_polygon_get_fill:
+ * @polygon: The polygon
  *
- * Returns if the line is filled
+ * Returns if the polygon is filled
  *
  * Since: 0.4
  */
 gboolean
-champlain_line_get_fill (ChamplainLine *line)
+champlain_polygon_get_fill (ChamplainPolygon *polygon)
 {
-  g_return_val_if_fail (CHAMPLAIN_IS_LINE (line), FALSE);
+  g_return_val_if_fail (CHAMPLAIN_IS_POLYGON (polygon), FALSE);
 
-  return line->priv->fill;
+  return polygon->priv->fill;
 }
 
 /**
- * champlain_line_set_stroke_width:
- * @line: The line
+ * champlain_polygon_set_stroke_width:
+ * @polygon: The polygon
  * @value: the width of the stroke (in pixels)
  *
  * Sets the width of the stroke
@@ -463,26 +463,26 @@ champlain_line_get_fill (ChamplainLine *line)
  * Since: 0.4
  */
 void
-champlain_line_set_stroke_width (ChamplainLine *line,
+champlain_polygon_set_stroke_width (ChamplainPolygon *polygon,
     gdouble value)
 {
-  g_return_if_fail (CHAMPLAIN_IS_LINE (line));
+  g_return_if_fail (CHAMPLAIN_IS_POLYGON (polygon));
 
-  line->priv->stroke_width = value;
+  polygon->priv->stroke_width = value;
 }
 
 /**
- * champlain_line_get_stroke_width:
- * @line: The line
+ * champlain_polygon_get_stroke_width:
+ * @polygon: The polygon
  *
  * Returns the width of the stroke
  *
  * Since: 0.4
  */
 gdouble
-champlain_line_get_stroke_width (ChamplainLine *line)
+champlain_polygon_get_stroke_width (ChamplainPolygon *polygon)
 {
-  g_return_val_if_fail (CHAMPLAIN_IS_LINE (line), 0);
+  g_return_val_if_fail (CHAMPLAIN_IS_POLYGON (polygon), 0);
 
-  return line->priv->stroke_width;
+  return polygon->priv->stroke_width;
 }
diff --git a/champlain/champlain-polygon.h b/champlain/champlain-polygon.h
new file mode 100644
index 0000000..8f995d4
--- /dev/null
+++ b/champlain/champlain-polygon.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2009 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_POLYGON_H
+#define CHAMPLAIN_POLYGON_H
+
+#include <champlain/champlain-defines.h>
+
+#include <glib-object.h>
+#include <clutter/clutter.h>
+
+G_BEGIN_DECLS
+
+#define CHAMPLAIN_TYPE_POLYGON champlain_polygon_get_type()
+
+#define CHAMPLAIN_POLYGON(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHAMPLAIN_TYPE_POLYGON, ChamplainPolygon))
+
+#define CHAMPLAIN_POLYGON_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), CHAMPLAIN_TYPE_POLYGON, ChamplainPolygonClass))
+
+#define CHAMPLAIN_IS_POLYGON(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHAMPLAIN_TYPE_POLYGON))
+
+#define CHAMPLAIN_IS_POLYGON_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), CHAMPLAIN_TYPE_POLYGON))
+
+#define CHAMPLAIN_POLYGON_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), CHAMPLAIN_TYPE_POLYGON, ChamplainPolygonClass))
+
+typedef struct _ChamplainPolygonPrivate ChamplainPolygonPrivate;
+
+typedef struct {
+  GObject parent;
+  ChamplainPolygonPrivate *priv;
+} ChamplainPolygon;
+
+typedef struct {
+  GObjectClass parent_class;
+} ChamplainPolygonClass;
+
+GType champlain_polygon_get_type (void);
+
+ChamplainPolygon* champlain_polygon_new (void);
+
+void champlain_polygon_add_point (ChamplainPolygon *polygon,
+    gdouble lat,
+    gdouble lon);
+
+void champlain_polygon_clear_points (ChamplainPolygon *polygon);
+void champlain_polygon_set_fill_color (ChamplainPolygon *polygon,
+    const ClutterColor *color);
+void champlain_polygon_set_stroke_color (ChamplainPolygon *polygon,
+    const ClutterColor *color);
+ClutterColor * champlain_polygon_get_fill_color (ChamplainPolygon *polygon);
+ClutterColor * champlain_polygon_get_stroke_color (ChamplainPolygon *polygon);
+
+gboolean champlain_polygon_get_fill (ChamplainPolygon *polygon);
+void champlain_polygon_set_fill (ChamplainPolygon *polygon,
+    gboolean value);
+gboolean champlain_polygon_get_stroke (ChamplainPolygon *polygon);
+void champlain_polygon_set_stroke (ChamplainPolygon *polygon,
+    gboolean value);
+void champlain_polygon_set_stroke_width (ChamplainPolygon *polygon,
+    gdouble value);
+gdouble champlain_polygon_get_stroke_width (ChamplainPolygon *polygon);
+G_END_DECLS
+
+#endif
diff --git a/champlain/champlain-private.h b/champlain/champlain-private.h
index 2777a5a..37fa6c6 100644
--- a/champlain/champlain-private.h
+++ b/champlain/champlain-private.h
@@ -37,7 +37,7 @@ struct _ChamplainBaseMarkerPrivate
   gdouble lat;
 };
 
-struct _ChamplainLinePrivate {
+struct _ChamplainPolygonPrivate {
   GList *points;
   gboolean closed_path;
   ClutterColor *stroke_color;
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index cc61c30..f27b836 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -59,6 +59,7 @@
 #include "champlain-marshal.h"
 #include "champlain-map-source.h"
 #include "champlain-map-source-factory.h"
+#include "champlain-polygon.h"
 #include "champlain-private.h"
 #include "champlain-tile.h"
 #include "champlain-zoom-level.h"
@@ -156,8 +157,8 @@ struct _ChamplainViewPrivate
   GoToContext *goto_context;
 
   /* Lines and shapes */
-  GList *lines;
-  ClutterActor *line_layer;  /* Contains the lines */
+  GList *polygons;
+  ClutterActor *polygon_layer;  /* Contains the polygons */
 
 };
 
@@ -205,7 +206,7 @@ static gboolean view_set_zoom_level_at (ChamplainView *view,
 static void tile_state_notify (GObject *gobject,
     GParamSpec *pspec,
     gpointer data);
-static void view_update_lines (ChamplainView *view);
+static void view_update_polygons (ChamplainView *view);
 
 static gdouble
 viewport_get_longitude_at (ChamplainViewPrivate *priv, gint x)
@@ -857,15 +858,15 @@ champlain_view_init (ChamplainView *view)
       priv->user_layers);
   clutter_actor_raise (priv->user_layers, priv->map_layer);
 
-  priv->lines = NULL;
+  priv->polygons = NULL;
 
-  /* Setup line layer */
-  priv->line_layer = g_object_ref (clutter_cairo_new (800, 600));
-  clutter_actor_show (priv->line_layer);
+  /* Setup polygon layer */
+  priv->polygon_layer = g_object_ref (clutter_cairo_new (800, 600));
+  clutter_actor_show (priv->polygon_layer);
   clutter_container_add_actor (CLUTTER_CONTAINER (priv->viewport),
-      priv->line_layer);
-  clutter_actor_raise (priv->line_layer, priv->map_layer);
-  clutter_actor_set_position (priv->line_layer, 0, 0);
+      priv->polygon_layer);
+  clutter_actor_raise (priv->polygon_layer, priv->map_layer);
+  clutter_actor_set_position (priv->polygon_layer, 0, 0);
 
   champlain_view_set_size (view, priv->viewport_size.width,
       priv->viewport_size.height);
@@ -919,7 +920,7 @@ viewport_x_changed_cb (GObject *gobject,
   view_load_visible_tiles (view);
   view_tiles_reposition (view);
   marker_reposition (view);
-  view_update_lines (view);
+  view_update_polygons (view);
 
   priv->longitude = viewport_get_current_longitude (priv);
   priv->latitude = viewport_get_current_latitude (priv);
@@ -1098,7 +1099,7 @@ champlain_view_center_on (ChamplainView *view,
 
   view_load_visible_tiles (view);
   view_tiles_reposition (view);
-  view_update_lines (view);
+  view_update_polygons (view);
   marker_reposition (view);
 }
 
@@ -2178,12 +2179,12 @@ champlain_view_get_zoom_on_double_click (ChamplainView *view)
 }
 
 static void
-draw_line (ChamplainView *view, cairo_t *cr, ChamplainLine *line)
+draw_polygon (ChamplainView *view, cairo_t *cr, ChamplainPolygon *polygon)
 {
   ChamplainViewPrivate *priv = view->priv;
 
   cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
-  GList *list = g_list_first (line->priv->points);
+  GList *list = g_list_first (polygon->priv->points);
   while (list != NULL)
     {
       ChamplainPoint *point = (ChamplainPoint*) list->data;
@@ -2201,56 +2202,56 @@ draw_line (ChamplainView *view, cairo_t *cr, ChamplainLine *line)
       list = list->next;
     }
 
-  if (line->priv->closed_path)
+  if (polygon->priv->closed_path)
     cairo_close_path (cr);
 
   cairo_set_source_rgba (cr,
-      line->priv->fill_color->red / 255.0,
-      line->priv->fill_color->green / 255.0,
-      line->priv->fill_color->blue / 255.0,
-      line->priv->fill_color->alpha / 255.0);
+      polygon->priv->fill_color->red / 255.0,
+      polygon->priv->fill_color->green / 255.0,
+      polygon->priv->fill_color->blue / 255.0,
+      polygon->priv->fill_color->alpha / 255.0);
 
-  if (line->priv->fill)
+  if (polygon->priv->fill)
     cairo_fill_preserve (cr);
 
   cairo_set_source_rgba (cr,
-      line->priv->stroke_color->red / 255.0,
-      line->priv->stroke_color->green / 255.0,
-      line->priv->stroke_color->blue / 255.0,
-      line->priv->stroke_color->alpha / 255.0);
+      polygon->priv->stroke_color->red / 255.0,
+      polygon->priv->stroke_color->green / 255.0,
+      polygon->priv->stroke_color->blue / 255.0,
+      polygon->priv->stroke_color->alpha / 255.0);
 
-  cairo_set_line_width (cr, line->priv->stroke_width);
+  cairo_set_line_width (cr, polygon->priv->stroke_width);
 
-  if (line->priv->stroke)
+  if (polygon->priv->stroke)
     cairo_stroke (cr);
 }
 
 static void
-view_update_lines (ChamplainView *view)
+view_update_polygons (ChamplainView *view)
 {
   ChamplainViewPrivate *priv = view->priv;
-  GList * lines;
-    cairo_t *cr;
-    gint x, y;
+  GList *polygons;
+  cairo_t *cr;
+  gint x, y;
 
-  if (priv->lines == NULL)
+  if (priv->polygons == NULL)
     return;
 
-  cr = clutter_cairo_create (CLUTTER_CAIRO (priv->line_layer));
+  cr = clutter_cairo_create (CLUTTER_CAIRO (priv->polygon_layer));
 
   /* Clear the drawing area */
   cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
   cairo_rectangle (cr, 0, 0, 800, 600);
   cairo_fill (cr);
 
-  lines = priv->lines;
-  while (lines != NULL)
+  polygons = priv->polygons;
+  while (polygons != NULL)
     {
-      ChamplainLine *line;
+      ChamplainPolygon *polygon;
 
-      line = CHAMPLAIN_LINE (lines->data);
-      draw_line (view, cr, line);
-      lines = lines->next;
+      polygon = CHAMPLAIN_POLYGON (polygons->data);
+      draw_polygon (view, cr, polygon);
+      polygons = polygons->next;
     }
 
   /* Position the layer in the viewport */
@@ -2259,44 +2260,44 @@ view_update_lines (ChamplainView *view)
 
   cairo_destroy (cr);
 
-  clutter_actor_set_position (priv->line_layer, x, y);
+  clutter_actor_set_position (priv->polygon_layer, x, y);
 }
 
 /**
- * champlain_view_add_line:
+ * champlain_view_add_polygon:
  * @view: a #ChamplainView
- * @line: a #ChamplainLine
+ * @polygon: a #ChamplainPolygon
  *
- * Adds a #ChamplainLine to the #ChamplainView
+ * Adds a #ChamplainPolygon to the #ChamplainView
  *
  * Since: 0.4
  */
 void
-champlain_view_add_line (ChamplainView *view,
-    ChamplainLine *line)
+champlain_view_add_polygon (ChamplainView *view,
+    ChamplainPolygon *polygon)
 {
   g_return_if_fail (CHAMPLAIN_IS_VIEW (view));
-  g_return_if_fail (CHAMPLAIN_IS_LINE (line));
+  g_return_if_fail (CHAMPLAIN_IS_POLYGON (polygon));
 
-  view->priv->lines = g_list_append (view->priv->lines, g_object_ref (line));
+  view->priv->polygons = g_list_append (view->priv->polygons, g_object_ref (polygon));
 }
 
 /**
- * champlain_view_remove_line:
+ * champlain_view_remove_polygon:
  * @view: a #ChamplainView
- * @line: a #ChamplainLine
+ * @polygon: a #ChamplainPolygon
  *
- * Removes a #ChamplainLine to the #ChamplainView
+ * Removes a #ChamplainPolygon to the #ChamplainView
  *
  * Since: 0.4
  */
 void
-champlain_view_remove_line (ChamplainView *view,
-    ChamplainLine *line)
+champlain_view_remove_polygon (ChamplainView *view,
+    ChamplainPolygon *polygon)
 {
   g_return_if_fail (CHAMPLAIN_IS_VIEW (view));
-  g_return_if_fail (CHAMPLAIN_IS_LINE (line));
+  g_return_if_fail (CHAMPLAIN_IS_POLYGON (polygon));
 
-  view->priv->lines = g_list_remove (view->priv->lines, line);
-  g_object_unref (line);
+  view->priv->polygons = g_list_remove (view->priv->polygons, polygon);
+  g_object_unref (polygon);
 }
diff --git a/champlain/champlain-view.h b/champlain/champlain-view.h
index 1a11f1b..d3fd233 100644
--- a/champlain/champlain-view.h
+++ b/champlain/champlain-view.h
@@ -26,7 +26,7 @@
 #include <champlain/champlain-defines.h>
 #include <champlain/champlain-base-marker.h>
 #include <champlain/champlain-layer.h>
-#include <champlain/champlain-line.h>
+#include <champlain/champlain-polygon.h>
 #include <champlain/champlain-map-source.h>
 #include <champlain/champlain-zoom-level.h>
 
@@ -140,10 +140,10 @@ gboolean champlain_view_get_keep_center_on_resize (ChamplainView *view);
 gboolean champlain_view_get_show_license (ChamplainView *view);
 gboolean champlain_view_get_zoom_on_double_click (ChamplainView *view);
 
-void champlain_view_add_line (ChamplainView *view,
-    ChamplainLine *line);
-void champlain_view_remove_line (ChamplainView *view,
-    ChamplainLine *line);
+void champlain_view_add_polygon (ChamplainView *view,
+    ChamplainPolygon *polygon);
+void champlain_view_remove_polygon (ChamplainView *view,
+    ChamplainPolygon *polygon);
 
 
 G_END_DECLS
diff --git a/demos/Makefile.am b/demos/Makefile.am
index 5d9e6b4..8a710dd 100644
--- a/demos/Makefile.am
+++ b/demos/Makefile.am
@@ -1,4 +1,4 @@
-noinst_PROGRAMS = launcher animated-marker lines
+noinst_PROGRAMS = launcher animated-marker polygons
 
 INCLUDES = -I$(top_srcdir)
 
@@ -11,8 +11,8 @@ launcher_LDADD = $(DEPS_LIBS) ../champlain/libchamplain-0.3.la
 animated_marker_SOURCES = animated-marker.c
 animated_marker_LDADD = $(DEPS_LIBS) ../champlain/libchamplain-0.3.la
 
-lines_SOURCES = lines.c
-lines_LDADD = $(DEPS_LIBS) ../champlain/libchamplain-0.3.la
+polygons_SOURCES = polygons.c
+polygons_LDADD = $(DEPS_LIBS) ../champlain/libchamplain-0.3.la
 
 if ENABLE_GTK
 noinst_PROGRAMS += launcher-gtk
diff --git a/demos/lines.c b/demos/polygons.c
similarity index 73%
rename from demos/lines.c
rename to demos/polygons.c
index 955a297..7c23745 100644
--- a/demos/lines.c
+++ b/demos/polygons.c
@@ -68,7 +68,7 @@ main (int argc,
     char *argv[])
 {
   ClutterActor* actor, *stage, *buttons, *button;
-  ChamplainLine *line;
+  ChamplainPolygon *polygon;
   guint width, total_width = 0;;
 
   g_thread_init (NULL);
@@ -108,35 +108,35 @@ main (int argc,
   clutter_container_add_actor (CLUTTER_CONTAINER (stage), buttons);
 
   /* draw a line */
-  line = champlain_line_new ();
+  polygon = champlain_polygon_new ();
   /* Cheap approx of Highway 10 */
-  champlain_line_add_point (line, 45.4095, -73.3197);
-  champlain_line_add_point (line, 45.4104, -73.2846);
-  champlain_line_add_point (line, 45.4178, -73.2239);
-  champlain_line_add_point (line, 45.4176, -73.2181);
-  champlain_line_add_point (line, 45.4151, -73.2126);
-  champlain_line_add_point (line, 45.4016, -73.1926);
-  champlain_line_add_point (line, 45.3994, -73.1877);
-  champlain_line_add_point (line, 45.4000, -73.1815);
-  champlain_line_add_point (line, 45.4151, -73.1218);
-  champlain_line_set_stroke_width (line, 5.0);
-  champlain_view_add_line (CHAMPLAIN_VIEW (actor), line);
+  champlain_polygon_add_point (polygon, 45.4095, -73.3197);
+  champlain_polygon_add_point (polygon, 45.4104, -73.2846);
+  champlain_polygon_add_point (polygon, 45.4178, -73.2239);
+  champlain_polygon_add_point (polygon, 45.4176, -73.2181);
+  champlain_polygon_add_point (polygon, 45.4151, -73.2126);
+  champlain_polygon_add_point (polygon, 45.4016, -73.1926);
+  champlain_polygon_add_point (polygon, 45.3994, -73.1877);
+  champlain_polygon_add_point (polygon, 45.4000, -73.1815);
+  champlain_polygon_add_point (polygon, 45.4151, -73.1218);
+  champlain_polygon_set_stroke_width (polygon, 5.0);
+  champlain_view_add_polygon (CHAMPLAIN_VIEW (actor), polygon);
 
   /* draw a polygon */
-  line = champlain_line_new ();
-  champlain_line_add_point (line, 45.1386, -73.9196);
-  champlain_line_add_point (line, 45.1229, -73.8991);
-  champlain_line_add_point (line, 45.0946, -73.9531);
-  champlain_line_add_point (line, 45.1085, -73.9714);
-  champlain_line_add_point (line, 45.1104, -73.9761);
-  champlain_view_add_line (CHAMPLAIN_VIEW (actor), line);
-  g_object_set (line, "closed-path", TRUE, NULL);
-  g_object_set (line, "fill", TRUE, NULL);
+  polygon = champlain_polygon_new ();
+  champlain_polygon_add_point (polygon, 45.1386, -73.9196);
+  champlain_polygon_add_point (polygon, 45.1229, -73.8991);
+  champlain_polygon_add_point (polygon, 45.0946, -73.9531);
+  champlain_polygon_add_point (polygon, 45.1085, -73.9714);
+  champlain_polygon_add_point (polygon, 45.1104, -73.9761);
+  champlain_view_add_polygon (CHAMPLAIN_VIEW (actor), polygon);
+  g_object_set (polygon, "closed-path", TRUE, NULL);
+  g_object_set (polygon, "fill", TRUE, NULL);
 
   /* Finish initialising the map view */
   g_object_set (G_OBJECT (actor), "zoom-level", 9,
       "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC, NULL);
-  champlain_view_center_on(CHAMPLAIN_VIEW(actor), 45.466, -73.75);
+  champlain_view_center_on (CHAMPLAIN_VIEW (actor), 45.466, -73.75);
 
   clutter_actor_show (stage);
   clutter_main ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]