[libchamplain] Encapsulate ChamplainMapSourceDesc into a class
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Encapsulate ChamplainMapSourceDesc into a class
- Date: Wed, 9 Feb 2011 08:40:05 +0000 (UTC)
commit 299b538b80d4776d0166de78cc1e2f822283c618
Author: JiÅ?Ã Techet <techet gmail com>
Date: Fri Feb 4 23:36:07 2011 +0100
Encapsulate ChamplainMapSourceDesc into a class
The factory can provide a list of ChamplainMapSourceDesc structures,
which is a bit dangerous because the user code can easily modify
their contents, which is illegal. Convert the structure to class with
construct-only writable properties to avoid this problem.
Thanks to Emmanuel Rodriguez for pointing out this problem.
champlain/champlain-license.c | 1 -
champlain/champlain-map-source-desc.c | 647 ++++++++++++++++++++++++++----
champlain/champlain-map-source-desc.h | 84 +++--
champlain/champlain-map-source-factory.c | 409 ++++++++++----------
champlain/champlain-map-source-factory.h | 7 +-
champlain/champlain-scale.c | 3 -
demos/launcher-gtk.c | 12 +-
demos/local-rendering.c | 12 +-
8 files changed, 847 insertions(+), 328 deletions(-)
---
diff --git a/champlain/champlain-license.c b/champlain/champlain-license.c
index b3320c2..99a18f2 100644
--- a/champlain/champlain-license.c
+++ b/champlain/champlain-license.c
@@ -197,7 +197,6 @@ create_license (ChamplainLicense *license)
clutter_text_set_line_alignment (CLUTTER_TEXT (priv->license_actor), PANGO_ALIGN_RIGHT);
clutter_actor_set_opacity (priv->license_actor, 128);
clutter_container_add_actor (CLUTTER_CONTAINER (license), priv->license_actor);
-// clutter_actor_set_anchor_point_from_gravity (priv->license_actor, CLUTTER_GRAVITY_SOUTH_EAST);
}
diff --git a/champlain/champlain-map-source-desc.c b/champlain/champlain-map-source-desc.c
index a52c4b2..7a63b71 100644
--- a/champlain/champlain-map-source-desc.c
+++ b/champlain/champlain-map-source-desc.c
@@ -29,111 +29,608 @@
#include "champlain-map-source-desc.h"
-GType
-champlain_map_source_desc_get_type (void)
+#include "champlain-enum-types.h"
+
+enum
+{
+ PROP_0,
+ PROP_ID,
+ PROP_NAME,
+ PROP_LICENSE,
+ PROP_LICENSE_URI,
+ PROP_URI_FORMAT,
+ PROP_MIN_ZOOM_LEVEL,
+ PROP_MAX_ZOOM_LEVEL,
+ PROP_TILE_SIZE,
+ PROP_PROJECTION,
+ PROP_CONSTRUCTOR,
+ PROP_DATA,
+};
+
+struct _ChamplainMapSourceDescPrivate
+{
+ gchar *id;
+ gchar *name;
+ gchar *license;
+ gchar *license_uri;
+ gchar *uri_format;
+ guint min_zoom_level;
+ guint max_zoom_level;
+ guint tile_size;
+ ChamplainMapProjection projection;
+ ChamplainMapSourceConstructor constructor;
+ gpointer data;
+};
+
+G_DEFINE_TYPE (ChamplainMapSourceDesc, champlain_map_source_desc, G_TYPE_OBJECT);
+
+#define GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CHAMPLAIN_TYPE_MAP_SOURCE_DESC, ChamplainMapSourceDescPrivate))
+
+
+static void set_id (ChamplainMapSourceDesc *desc,
+ const gchar *id);
+static void set_name (ChamplainMapSourceDesc *desc,
+ const gchar *name);
+static void set_license (ChamplainMapSourceDesc *desc,
+ const gchar *license);
+static void set_license_uri (ChamplainMapSourceDesc *desc,
+ const gchar *license_uri);
+static void set_uri_format (ChamplainMapSourceDesc *desc,
+ const gchar *uri_format);
+static void set_min_zoom_level (ChamplainMapSourceDesc *desc,
+ guint zoom_level);
+static void set_max_zoom_level (ChamplainMapSourceDesc *desc,
+ guint zoom_level);
+static void set_tile_size (ChamplainMapSourceDesc *desc,
+ guint tile_size);
+static void set_projection (ChamplainMapSourceDesc *desc,
+ ChamplainMapProjection projection);
+static void set_data (ChamplainMapSourceDesc *desc,
+ gpointer data);
+static void set_constructor (ChamplainMapSourceDesc *desc,
+ ChamplainMapSourceConstructor constructor);
+
+
+static void
+champlain_map_source_desc_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ ChamplainMapSourceDescPrivate *priv = CHAMPLAIN_MAP_SOURCE_DESC (object)->priv;
+
+ switch (prop_id)
+ {
+ case PROP_ID:
+ g_value_set_string (value, priv->id);
+ break;
+
+ case PROP_NAME:
+ g_value_set_string (value, priv->name);
+ break;
+
+ case PROP_LICENSE:
+ g_value_set_string (value, priv->license);
+ break;
+
+ case PROP_LICENSE_URI:
+ g_value_set_string (value, priv->license_uri);
+ break;
+
+ case PROP_URI_FORMAT:
+ g_value_set_string (value, priv->uri_format);
+ break;
+
+ case PROP_MIN_ZOOM_LEVEL:
+ g_value_set_uint (value, priv->min_zoom_level);
+ break;
+
+ case PROP_MAX_ZOOM_LEVEL:
+ g_value_set_uint (value, priv->max_zoom_level);
+ break;
+
+ case PROP_TILE_SIZE:
+ g_value_set_uint (value, priv->tile_size);
+ break;
+
+ case PROP_PROJECTION:
+ g_value_set_enum (value, priv->projection);
+ break;
+
+ case PROP_CONSTRUCTOR:
+ g_value_set_pointer (value, priv->constructor);
+ break;
+
+ case PROP_DATA:
+ g_value_set_pointer (value, priv->data);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+
+static void
+champlain_map_source_desc_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- static GType type = 0;
+ ChamplainMapSourceDesc *desc = CHAMPLAIN_MAP_SOURCE_DESC (object);
- if (G_UNLIKELY (type == 0))
+ switch (prop_id)
{
- type = g_boxed_type_register_static (g_intern_static_string ("ChamplainMapSourceDesc"),
- (GBoxedCopyFunc) champlain_map_source_desc_copy,
- (GBoxedFreeFunc) champlain_map_source_desc_free);
+ case PROP_ID:
+ set_id (desc, g_value_get_string (value));
+
+ case PROP_NAME:
+ set_name (desc, g_value_get_string (value));
+ break;
+
+ case PROP_LICENSE:
+ set_license (desc, g_value_get_string (value));
+ break;
+
+ case PROP_LICENSE_URI:
+ set_license_uri (desc, g_value_get_string (value));
+ break;
+
+ case PROP_URI_FORMAT:
+ set_uri_format (desc, g_value_get_string (value));
+ break;
+
+ case PROP_MIN_ZOOM_LEVEL:
+ set_min_zoom_level (desc, g_value_get_uint (value));
+ break;
+
+ case PROP_MAX_ZOOM_LEVEL:
+ set_max_zoom_level (desc, g_value_get_uint (value));
+ break;
+
+ case PROP_TILE_SIZE:
+ set_tile_size (desc, g_value_get_uint (value));
+ break;
+
+ case PROP_PROJECTION:
+ set_projection (desc, g_value_get_enum (value));
+ break;
+
+ case PROP_CONSTRUCTOR:
+ set_constructor (desc, g_value_get_pointer (value));
+ break;
+
+ case PROP_DATA:
+ set_data (desc, g_value_get_pointer (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
+}
+
+
+static void
+champlain_map_source_desc_dispose (GObject *object)
+{
+// ChamplainMapSourceDesc *desc = CHAMPLAIN_MAP_SOURCE_DESC (object);
+
+ G_OBJECT_CLASS (champlain_map_source_desc_parent_class)->dispose (object);
+}
+
+
+static void
+champlain_map_source_desc_finalize (GObject *object)
+{
+ ChamplainMapSourceDescPrivate *priv = CHAMPLAIN_MAP_SOURCE_DESC (object)->priv;
+
+ g_free (priv->id);
+ g_free (priv->name);
+ g_free (priv->license);
+ g_free (priv->license_uri);
+ g_free (priv->uri_format);
+
+ G_OBJECT_CLASS (champlain_map_source_desc_parent_class)->finalize (object);
+}
+
+
+static void
+champlain_map_source_desc_class_init (ChamplainMapSourceDescClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (ChamplainMapSourceDescPrivate));
+
+ object_class->finalize = champlain_map_source_desc_finalize;
+ object_class->dispose = champlain_map_source_desc_dispose;
+ object_class->get_property = champlain_map_source_desc_get_property;
+ object_class->set_property = champlain_map_source_desc_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_ID,
+ g_param_spec_string ("id",
+ "Map source id",
+ "Map source id",
+ "",
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_NAME,
+ g_param_spec_string ("name",
+ "Map source name",
+ "Map source name",
+ "",
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_LICENSE,
+ g_param_spec_string ("license",
+ "Map source license",
+ "Map source license",
+ "",
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_LICENSE_URI,
+ g_param_spec_string ("license-uri",
+ "Map source license URI",
+ "Map source license URI",
+ "",
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_URI_FORMAT,
+ g_param_spec_string ("uri-format",
+ "Network map source URI format",
+ "Network map source URI format",
+ "",
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_MIN_ZOOM_LEVEL,
+ g_param_spec_uint ("min-zoom-level",
+ "Min zoom level",
+ "The lowest allowed level of zoom",
+ 0, 20, 0,
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_MAX_ZOOM_LEVEL,
+ g_param_spec_uint ("max-zoom-level",
+ "Max zoom level",
+ "The highest allowed level of zoom",
+ 0, 20, 20,
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_PROJECTION,
+ g_param_spec_enum ("projection",
+ "Map source projection",
+ "Map source projection",
+ CHAMPLAIN_TYPE_MAP_PROJECTION,
+ CHAMPLAIN_MAP_PROJECTION_MERCATOR,
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_TILE_SIZE,
+ g_param_spec_uint ("tile-size",
+ "Tile Size",
+ "The size of the map source tile",
+ 0,
+ G_MAXINT,
+ 256,
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_CONSTRUCTOR,
+ g_param_spec_pointer ("constructor",
+ "Map source constructor",
+ "Map source constructor",
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_DATA,
+ g_param_spec_pointer ("data",
+ "User data",
+ "User data",
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+}
+
+
+static void
+champlain_map_source_desc_init (ChamplainMapSourceDesc *desc)
+{
+ ChamplainMapSourceDescPrivate *priv = GET_PRIVATE (desc);
+
+ desc->priv = priv;
+
+ priv->id = NULL;
+ priv->name = NULL;
+ priv->license = NULL;
+ priv->license_uri = NULL;
+ priv->uri_format = NULL;
+ priv->min_zoom_level = 0;
+ priv->max_zoom_level = 20;
+ priv->tile_size = 256;
+ priv->projection = CHAMPLAIN_MAP_PROJECTION_MERCATOR;
+ priv->constructor = NULL;
+ priv->data = NULL;
- return type;
}
-/**
- * champlain_map_source_desc_copy:
- * @desc: a #ChamplainMapSourceDesc
- *
- * Makes a copy of the map source desc structure. The result must be
- * freed using #champlain_map_source_desc_free. All string fields will
- * be duplicated with #g_strdup.
- *
- * Return value: an allocated copy of @desc.
- *
- * Since: 0.4
- */
ChamplainMapSourceDesc *
-champlain_map_source_desc_copy (const ChamplainMapSourceDesc *desc)
+champlain_map_source_desc_new_full (
+ gchar *id,
+ gchar *name,
+ gchar *license,
+ gchar *license_uri,
+ guint min_zoom_level,
+ guint max_zoom_level,
+ guint tile_size,
+ ChamplainMapProjection projection,
+ gchar *uri_format,
+ ChamplainMapSourceConstructor constructor,
+ gpointer data)
{
- ChamplainMapSourceDesc *dest = NULL;
+ return g_object_new (CHAMPLAIN_TYPE_MAP_SOURCE_DESC,
+ "id", id,
+ "name", name,
+ "license", license,
+ "license-uri", license_uri,
+ "min-zoom-level", min_zoom_level,
+ "max-zoom-level", max_zoom_level,
+ "tile-size", tile_size,
+ "projection", projection,
+ "uri-format", uri_format,
+ "constructor", constructor,
+ "data", data,
+ NULL);
+}
- if (G_UNLIKELY (desc == NULL))
- return NULL;
- dest = g_slice_dup (ChamplainMapSourceDesc, desc);
- if (G_LIKELY (desc->id != NULL))
- dest->id = g_strdup (desc->id);
+const gchar *
+champlain_map_source_desc_get_id (ChamplainMapSourceDesc *desc)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc), NULL);
+
+ return desc->priv->id;
+}
- if (G_LIKELY (desc->name != NULL))
- dest->name = g_strdup (desc->name);
- if (G_LIKELY (desc->license != NULL))
- dest->license = g_strdup (desc->license);
+const gchar *
+champlain_map_source_desc_get_name (ChamplainMapSourceDesc *desc)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc), NULL);
- if (G_LIKELY (desc->license_uri != NULL))
- dest->license_uri = g_strdup (desc->license_uri);
+ return desc->priv->name;
+}
- if (G_LIKELY (desc->uri_format != NULL))
- dest->uri_format = g_strdup (desc->uri_format);
- /* Can't make a copy of obscure pointer data */
- dest->data = desc->data;
+const gchar *
+champlain_map_source_desc_get_license (ChamplainMapSourceDesc *desc)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc), NULL);
- return dest;
+ return desc->priv->license;
}
-/**
- * champlain_map_source_desc_free:
- * @desc: a #ChamplainMapSourceDesc
- *
- * Frees a desc structure created with #champlain_map_source_desc_new or
- * #champlain_map_source_desc_copy. All strings will be freed with #g_free.
- * The data pointer will not be freed.
- *
- * Since: 0.4
- */
-void
-champlain_map_source_desc_free (ChamplainMapSourceDesc *desc)
+const gchar *
+champlain_map_source_desc_get_license_uri (ChamplainMapSourceDesc *desc)
{
- if (G_UNLIKELY (desc == NULL))
- return;
+ g_return_val_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc), NULL);
+
+ return desc->priv->license_uri;
+}
- if (G_LIKELY (desc->id != NULL))
- g_free (desc->id);
- if (G_LIKELY (desc->name != NULL))
- g_free (desc->name);
+const gchar *
+champlain_map_source_desc_get_uri_format (ChamplainMapSourceDesc *desc)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc), NULL);
- if (G_LIKELY (desc->license != NULL))
- g_free (desc->license);
+ return desc->priv->uri_format;
+}
- if (G_LIKELY (desc->license_uri != NULL))
- g_free (desc->license_uri);
- if (G_LIKELY (desc->uri_format != NULL))
- g_free (desc->uri_format);
+guint
+champlain_map_source_desc_get_min_zoom_level (ChamplainMapSourceDesc *desc)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc), 0);
- g_slice_free (ChamplainMapSourceDesc, desc);
+ return desc->priv->min_zoom_level;
}
-/**
- * champlain_map_source_desc_new:
- *
- * Creates a new instance of #ChamplainMapSourceDesc.
- *
- * Returns: a newly allocated #ChamplainMapSourceDesc to be freed with #champlain_map_source_desc_free
- *
- * Since: 0.4
- */
-ChamplainMapSourceDesc *
-champlain_map_source_desc_new ()
+guint
+champlain_map_source_desc_get_max_zoom_level (ChamplainMapSourceDesc *desc)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc), 0);
+
+ return desc->priv->max_zoom_level;
+}
+
+
+guint
+champlain_map_source_desc_get_tile_size (ChamplainMapSourceDesc *desc)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc), 0);
+
+ return desc->priv->tile_size;
+}
+
+
+ChamplainMapProjection
+champlain_map_source_desc_get_projection (ChamplainMapSourceDesc *desc)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc), CHAMPLAIN_MAP_PROJECTION_MERCATOR);
+
+ return desc->priv->projection;
+}
+
+
+gpointer
+champlain_map_source_desc_get_data (ChamplainMapSourceDesc *desc)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc), NULL);
+
+ return desc->priv->data;
+}
+
+
+const ChamplainMapSourceConstructor champlain_map_source_desc_get_constructor (ChamplainMapSourceDesc *desc)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc), NULL);
+
+ return desc->priv->constructor;
+}
+
+
+static void
+set_id (ChamplainMapSourceDesc *desc,
+ const gchar *id)
+{
+ g_return_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc));
+
+ ChamplainMapSourceDescPrivate *priv = desc->priv;
+
+ g_free (priv->id);
+ priv->id = g_strdup (id);
+
+ g_object_notify (G_OBJECT (desc), "id");
+}
+
+
+static void
+set_name (ChamplainMapSourceDesc *desc,
+ const gchar *name)
+{
+ g_return_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc));
+
+ ChamplainMapSourceDescPrivate *priv = desc->priv;
+
+ g_free (priv->name);
+ priv->name = g_strdup (name);
+
+ g_object_notify (G_OBJECT (desc), "name");
+}
+
+
+static void
+set_license (ChamplainMapSourceDesc *desc,
+ const gchar *license)
+{
+ g_return_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc));
+
+ ChamplainMapSourceDescPrivate *priv = desc->priv;
+
+ g_free (priv->license);
+ priv->license = g_strdup (license);
+
+ g_object_notify (G_OBJECT (desc), "license");
+}
+
+
+static void
+set_license_uri (ChamplainMapSourceDesc *desc,
+ const gchar *license_uri)
{
- return g_slice_new (ChamplainMapSourceDesc);
+ g_return_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc));
+
+ ChamplainMapSourceDescPrivate *priv = desc->priv;
+
+ g_free (priv->license_uri);
+ priv->license_uri = g_strdup (license_uri);
+
+ g_object_notify (G_OBJECT (desc), "license-uri");
+}
+
+
+static void
+set_uri_format (ChamplainMapSourceDesc *desc,
+ const gchar *uri_format)
+{
+ g_return_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc));
+
+ ChamplainMapSourceDescPrivate *priv = desc->priv;
+
+ g_free (priv->uri_format);
+ priv->uri_format = g_strdup (uri_format);
+
+ g_object_notify (G_OBJECT (desc), "uri-format");
+}
+
+
+static void
+set_min_zoom_level (ChamplainMapSourceDesc *desc,
+ guint zoom_level)
+{
+ g_return_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc));
+
+ desc->priv->min_zoom_level = zoom_level;
+
+ g_object_notify (G_OBJECT (desc), "min-zoom-level");
+}
+
+
+static void
+set_max_zoom_level (ChamplainMapSourceDesc *desc,
+ guint zoom_level)
+{
+ g_return_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc));
+
+ desc->priv->max_zoom_level = zoom_level;
+
+ g_object_notify (G_OBJECT (desc), "max-zoom-level");
}
+
+
+static void
+set_tile_size (ChamplainMapSourceDesc *desc,
+ guint tile_size)
+{
+ g_return_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc));
+
+ desc->priv->tile_size = tile_size;
+
+ g_object_notify (G_OBJECT (desc), "tile-size");
+}
+
+
+static void
+set_projection (ChamplainMapSourceDesc *desc,
+ ChamplainMapProjection projection)
+{
+ g_return_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc));
+
+ desc->priv->projection = projection;
+
+ g_object_notify (G_OBJECT (desc), "projection");
+}
+
+
+static void
+set_data (ChamplainMapSourceDesc *desc,
+ gpointer data)
+{
+ g_return_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc));
+
+ desc->priv->data = data;
+
+ g_object_notify (G_OBJECT (desc), "data");
+}
+
+
+static void
+set_constructor (ChamplainMapSourceDesc *desc,
+ ChamplainMapSourceConstructor constructor)
+{
+ g_return_if_fail (CHAMPLAIN_IS_MAP_SOURCE_DESC (desc));
+
+ desc->priv->constructor = constructor;
+
+ g_object_notify (G_OBJECT (desc), "constructor");
+}
+
diff --git a/champlain/champlain-map-source-desc.h b/champlain/champlain-map-source-desc.h
index d0b576c..6f96a1a 100644
--- a/champlain/champlain-map-source-desc.h
+++ b/champlain/champlain-map-source-desc.h
@@ -28,9 +28,41 @@
G_BEGIN_DECLS
+#define CHAMPLAIN_TYPE_MAP_SOURCE_DESC champlain_map_source_desc_get_type ()
+
+#define CHAMPLAIN_MAP_SOURCE_DESC(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHAMPLAIN_TYPE_MAP_SOURCE_DESC, ChamplainMapSourceDesc))
+
+#define CHAMPLAIN_MAP_SOURCE_DESC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), CHAMPLAIN_TYPE_MAP_SOURCE_DESC, ChamplainMapSourceDescClass))
+
+#define CHAMPLAIN_IS_MAP_SOURCE_DESC(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHAMPLAIN_TYPE_MAP_SOURCE_DESC))
+
+#define CHAMPLAIN_IS_MAP_SOURCE_DESC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), CHAMPLAIN_TYPE_MAP_SOURCE_DESC))
+
+#define CHAMPLAIN_MAP_SOURCE_DESC_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), CHAMPLAIN_TYPE_MAP_SOURCE_DESC, ChamplainMapSourceDescClass))
+
+typedef struct _ChamplainMapSourceDescPrivate ChamplainMapSourceDescPrivate;
typedef struct _ChamplainMapSourceDesc ChamplainMapSourceDesc;
+typedef struct _ChamplainMapSourceDescClass ChamplainMapSourceDescClass;
+
+struct _ChamplainMapSourceDesc
+{
+ GObject parent_instance;
+
+ ChamplainMapSourceDescPrivate *priv;
+};
+
+struct _ChamplainMapSourceDescClass
+{
+ GObjectClass parent_class;
+};
+GType champlain_map_source_desc_get_type (void);
/**
* ChamplainMapSourceConstructor:
@@ -45,13 +77,13 @@ typedef struct _ChamplainMapSourceDesc ChamplainMapSourceDesc;
* Since: 0.4
*/
typedef ChamplainMapSource * (*ChamplainMapSourceConstructor)
- (ChamplainMapSourceDesc *desc, gpointer data);
+ (ChamplainMapSourceDesc *desc);
#define CHAMPLAIN_MAP_SOURCE_CONSTRUCTOR (f) ((ChamplainMapSourceConstructor) (f))
-#define CHAMPLAIN_MAP_SOURCE_DESC(obj) ((ChamplainMapSourceDesc *) (obj))
-/**
+
+/*
* ChamplainMapSourceDesc:
* @id: A unique identifier, should contain only characters found in filenames
* @name: A display name
@@ -68,28 +100,30 @@ typedef ChamplainMapSource * (*ChamplainMapSourceConstructor)
*
* Since: 0.4
*/
-struct _ChamplainMapSourceDesc
-{
- gchar *id;
- gchar *name;
- gchar *license;
- gchar *license_uri;
- gint min_zoom_level;
- gint max_zoom_level;
- ChamplainMapProjection projection;
- ChamplainMapSourceConstructor constructor;
- gchar *uri_format;
- gpointer data;
-};
-
-GType champlain_map_source_desc_get_type (void) G_GNUC_CONST;
-#define CHAMPLAIN_TYPE_MAP_SOURCE_DESC (champlain_map_source_desc_get_type ())
-
-ChamplainMapSourceDesc *champlain_map_source_desc_copy (const ChamplainMapSourceDesc *desc);
-
-void champlain_map_source_desc_free (ChamplainMapSourceDesc *desc);
-
-ChamplainMapSourceDesc *champlain_map_source_desc_new (void);
+ChamplainMapSourceDesc *champlain_map_source_desc_new_full (
+ gchar *id,
+ gchar *name,
+ gchar *license,
+ gchar *license_uri,
+ guint min_zoom_level,
+ guint max_zoom_level,
+ guint tile_size,
+ ChamplainMapProjection projection,
+ gchar *uri_format,
+ ChamplainMapSourceConstructor constructor,
+ gpointer data);
+
+const gchar *champlain_map_source_desc_get_id (ChamplainMapSourceDesc *desc);
+const gchar *champlain_map_source_desc_get_name (ChamplainMapSourceDesc *desc);
+const gchar *champlain_map_source_desc_get_license (ChamplainMapSourceDesc *desc);
+const gchar *champlain_map_source_desc_get_license_uri (ChamplainMapSourceDesc *desc);
+const gchar *champlain_map_source_desc_get_uri_format (ChamplainMapSourceDesc *desc);
+guint champlain_map_source_desc_get_min_zoom_level (ChamplainMapSourceDesc *desc);
+guint champlain_map_source_desc_get_max_zoom_level (ChamplainMapSourceDesc *desc);
+guint champlain_map_source_desc_get_tile_size (ChamplainMapSourceDesc *desc);
+ChamplainMapProjection champlain_map_source_desc_get_projection (ChamplainMapSourceDesc *desc);
+gpointer champlain_map_source_desc_get_data (ChamplainMapSourceDesc *desc);
+const ChamplainMapSourceConstructor champlain_map_source_desc_get_constructor (ChamplainMapSourceDesc *desc);
G_END_DECLS
diff --git a/champlain/champlain-map-source-factory.c b/champlain/champlain-map-source-factory.c
index 3bc0b0c..00ef48c 100644
--- a/champlain/champlain-map-source-factory.c
+++ b/champlain/champlain-map-source-factory.c
@@ -29,7 +29,7 @@
* will return a ready to use #ChamplainMapSource.
*
* To get the list of registered map sources, use
- * #champlain_map_source_factory_dup_list.
+ * #champlain_map_source_factory_get_registered.
*
*/
#include "config.h"
@@ -83,13 +83,11 @@ struct _ChamplainMapSourceFactoryPrivate
};
static ChamplainMapSource *champlain_map_source_new_generic (
- ChamplainMapSourceDesc *desc,
- gpointer data);
+ ChamplainMapSourceDesc *desc);
#ifdef CHAMPLAIN_HAS_MEMPHIS
static ChamplainMapSource *champlain_map_source_new_memphis (
- ChamplainMapSourceDesc *desc,
- gpointer user_data);
+ ChamplainMapSourceDesc *desc);
#endif
@@ -140,176 +138,144 @@ champlain_map_source_factory_class_init (ChamplainMapSourceFactoryClass *klass)
}
-static
-ChamplainMapSourceDesc OSM_MAPNIK_DESC =
-{
- CHAMPLAIN_MAP_SOURCE_OSM_MAPNIK,
- "OpenStreetMap Mapnik",
- "Map data is CC-BY-SA 2.0 OpenStreetMap contributors",
- "http://creativecommons.org/licenses/by-sa/2.0/",
- 0,
- 18,
- CHAMPLAIN_MAP_PROJECTION_MERCATOR,
- champlain_map_source_new_generic,
- "http://tile.openstreetmap.org/#Z#/#X#/#Y#.png",
- NULL
-};
-
-static
-ChamplainMapSourceDesc OSM_OSMARENDER_DESC =
-{
- CHAMPLAIN_MAP_SOURCE_OSM_OSMARENDER,
- "OpenStreetMap Osmarender",
- "Map data is CC-BY-SA 2.0 OpenStreetMap contributors",
- "http://creativecommons.org/licenses/by-sa/2.0/",
- 0,
- 17,
- CHAMPLAIN_MAP_PROJECTION_MERCATOR,
- champlain_map_source_new_generic,
- "http://tah.openstreetmap.org/Tiles/tile/#Z#/#X#/#Y#.png",
- NULL
-};
-
-static
-ChamplainMapSourceDesc OSM_MAPQUEST_DESC =
-{
- CHAMPLAIN_MAP_SOURCE_OSM_MAPQUEST,
- "MapQuest OSM",
- "Data, imagery and map information provided by MapQuest, Open Street Map and contributors",
- "http://creativecommons.org/licenses/by-sa/2.0/",
- 0,
- 17,
- CHAMPLAIN_MAP_PROJECTION_MERCATOR,
- champlain_map_source_new_generic,
- "http://otile1.mqcdn.com/tiles/1.0.0/osm/#Z#/#X#/#Y#.png",
- NULL
-};
-
-static
-ChamplainMapSourceDesc OSM_CYCLEMAP_DESC =
-{
- CHAMPLAIN_MAP_SOURCE_OSM_CYCLE_MAP,
- "OpenStreetMap Cycle Map",
- "Map data is CC-BY-SA 2.0 OpenStreetMap contributors",
- "http://creativecommons.org/licenses/by-sa/2.0/",
- 0,
- 18,
- CHAMPLAIN_MAP_PROJECTION_MERCATOR,
- champlain_map_source_new_generic,
- "http://andy.sandbox.cloudmade.com/tiles/cycle/#Z#/#X#/#Y#.png",
- NULL
-};
-
-static
-ChamplainMapSourceDesc OSM_TRANSPORTMAP_DESC =
-{
- CHAMPLAIN_MAP_SOURCE_OSM_TRANSPORT_MAP,
- "OpenStreetMap Transport Map",
- "Map data is CC-BY-SA 2.0 OpenStreetMap contributors",
- "http://creativecommons.org/licenses/by-sa/2.0/",
- 0,
- 18,
- CHAMPLAIN_MAP_PROJECTION_MERCATOR,
- champlain_map_source_new_generic,
- "http://tile.xn--pnvkarte-m4a.de/tilegen/#Z#/#X#/#Y#.png",
- NULL
-};
-
-#if 0
-/* Disabling until OpenArealMap works again */
-static
-ChamplainMapSourceDesc OAM_DESC =
-{
- CHAMPLAIN_MAP_SOURCE_OAM,
- "OpenAerialMap",
- "(CC) BY 3.0 OpenAerialMap contributors",
- "http://creativecommons.org/licenses/by/3.0/",
- 0,
- 17,
- CHAMPLAIN_MAP_PROJECTION_MERCATOR,
- champlain_map_source_new_generic,
- "http://tile.openaerialmap.org/tiles/1.0.0/openaerialmap-900913/#Z#/#X#/#Y#.jpg",
- NULL
-};
-#endif
-
-static
-ChamplainMapSourceDesc MFF_RELIEF_DESC =
-{
- CHAMPLAIN_MAP_SOURCE_MFF_RELIEF,
- "Maps for Free Relief",
- "Map data available under GNU Free Documentation license, Version 1.2 or later",
- "http://www.gnu.org/copyleft/fdl.html",
- 0,
- 11,
- CHAMPLAIN_MAP_PROJECTION_MERCATOR,
- champlain_map_source_new_generic,
- "http://maps-for-free.com/layer/relief/z#Z#/row#Y#/#Z#_#X#-#Y#.jpg",
- NULL
-};
-
-#ifdef CHAMPLAIN_HAS_MEMPHIS
-static
-ChamplainMapSourceDesc MEMPHIS_LOCAL_DESC =
-{
- CHAMPLAIN_MAP_SOURCE_MEMPHIS_LOCAL,
- "OpenStreetMap Memphis Local Map",
- "(CC) BY 2.0 OpenStreetMap contributors",
- "http://creativecommons.org/licenses/by/2.0/",
- 12,
- 18,
- CHAMPLAIN_MAP_PROJECTION_MERCATOR,
- champlain_map_source_new_memphis,
- "",
- NULL
-};
-
-static
-ChamplainMapSourceDesc MEMPHIS_NETWORK_DESC =
-{
- CHAMPLAIN_MAP_SOURCE_MEMPHIS_NETWORK,
- "OpenStreetMap Memphis Network Map",
- "(CC) BY 2.0 OpenStreetMap contributors",
- "http://creativecommons.org/licenses/by/2.0/",
- 12,
- 18,
- CHAMPLAIN_MAP_PROJECTION_MERCATOR,
- champlain_map_source_new_memphis,
- "",
- NULL
-};
-#endif
-
static void
champlain_map_source_factory_init (ChamplainMapSourceFactory *factory)
{
ChamplainMapSourceFactoryPrivate *priv = GET_PRIVATE (factory);
+ ChamplainMapSourceDesc *desc;
factory->priv = priv;
-
priv->registered_sources = NULL;
- champlain_map_source_factory_register (factory, &OSM_MAPNIK_DESC,
- OSM_MAPNIK_DESC.constructor, OSM_MAPNIK_DESC.data);
- champlain_map_source_factory_register (factory, &OSM_CYCLEMAP_DESC,
- OSM_CYCLEMAP_DESC.constructor, OSM_CYCLEMAP_DESC.data);
- champlain_map_source_factory_register (factory, &OSM_TRANSPORTMAP_DESC,
- OSM_TRANSPORTMAP_DESC.constructor, OSM_TRANSPORTMAP_DESC.data);
- champlain_map_source_factory_register (factory, &OSM_OSMARENDER_DESC,
- OSM_OSMARENDER_DESC.constructor, OSM_OSMARENDER_DESC.data);
- champlain_map_source_factory_register (factory, &OSM_MAPQUEST_DESC,
- OSM_MAPQUEST_DESC.constructor, OSM_MAPQUEST_DESC.data);
+ desc = champlain_map_source_desc_new_full (
+ CHAMPLAIN_MAP_SOURCE_OSM_MAPNIK,
+ "OpenStreetMap Mapnik",
+ "Map data is CC-BY-SA 2.0 OpenStreetMap contributors",
+ "http://creativecommons.org/licenses/by-sa/2.0/",
+ 0,
+ 18,
+ 256,
+ CHAMPLAIN_MAP_PROJECTION_MERCATOR,
+ "http://tile.openstreetmap.org/#Z#/#X#/#Y#.png",
+ champlain_map_source_new_generic,
+ NULL);
+ champlain_map_source_factory_register (factory, desc);
+
+ desc = champlain_map_source_desc_new_full (
+ CHAMPLAIN_MAP_SOURCE_OSM_OSMARENDER,
+ "OpenStreetMap Osmarender",
+ "Map data is CC-BY-SA 2.0 OpenStreetMap contributors",
+ "http://creativecommons.org/licenses/by-sa/2.0/",
+ 0,
+ 17,
+ 256,
+ CHAMPLAIN_MAP_PROJECTION_MERCATOR,
+ "http://tah.openstreetmap.org/Tiles/tile/#Z#/#X#/#Y#.png",
+ champlain_map_source_new_generic,
+ NULL);
+ champlain_map_source_factory_register (factory, desc);
+
+ desc = champlain_map_source_desc_new_full (
+ CHAMPLAIN_MAP_SOURCE_OSM_MAPQUEST,
+ "MapQuest OSM",
+ "Data, imagery and map information provided by MapQuest, Open Street Map and contributors",
+ "http://creativecommons.org/licenses/by-sa/2.0/",
+ 0,
+ 17,
+ 256,
+ CHAMPLAIN_MAP_PROJECTION_MERCATOR,
+ "http://otile1.mqcdn.com/tiles/1.0.0/osm/#Z#/#X#/#Y#.png",
+ champlain_map_source_new_generic,
+ NULL);
+ champlain_map_source_factory_register (factory, desc);
+
+ desc = champlain_map_source_desc_new_full (
+ CHAMPLAIN_MAP_SOURCE_OSM_CYCLE_MAP,
+ "OpenStreetMap Cycle Map",
+ "Map data is CC-BY-SA 2.0 OpenStreetMap contributors",
+ "http://creativecommons.org/licenses/by-sa/2.0/",
+ 0,
+ 18,
+ 256,
+ CHAMPLAIN_MAP_PROJECTION_MERCATOR,
+ "http://andy.sandbox.cloudmade.com/tiles/cycle/#Z#/#X#/#Y#.png",
+ champlain_map_source_new_generic,
+ NULL);
+ champlain_map_source_factory_register (factory, desc);
+
+ desc = champlain_map_source_desc_new_full (
+ CHAMPLAIN_MAP_SOURCE_OSM_TRANSPORT_MAP,
+ "OpenStreetMap Transport Map",
+ "Map data is CC-BY-SA 2.0 OpenStreetMap contributors",
+ "http://creativecommons.org/licenses/by-sa/2.0/",
+ 0,
+ 18,
+ 256,
+ CHAMPLAIN_MAP_PROJECTION_MERCATOR,
+ "http://tile.xn--pnvkarte-m4a.de/tilegen/#Z#/#X#/#Y#.png",
+ champlain_map_source_new_generic,
+ NULL);
+ champlain_map_source_factory_register (factory, desc);
+
#if 0
- champlain_map_source_factory_register (factory, &OAM_DESC,
- OAM_DESC.constructor, OAM_DESC.data);
+/* Disabling until OpenArealMap works again */
+ desc = champlain_map_source_desc_new_full (
+ CHAMPLAIN_MAP_SOURCE_OAM,
+ "OpenAerialMap",
+ "(CC) BY 3.0 OpenAerialMap contributors",
+ "http://creativecommons.org/licenses/by/3.0/",
+ 0,
+ 17,
+ 256,
+ CHAMPLAIN_MAP_PROJECTION_MERCATOR,
+ "http://tile.openaerialmap.org/tiles/1.0.0/openaerialmap-900913/#Z#/#X#/#Y#.jpg",
+ champlain_map_source_new_generic,
+ NULL);
+ champlain_map_source_factory_register (factory, desc);
#endif
- champlain_map_source_factory_register (factory, &MFF_RELIEF_DESC,
- MFF_RELIEF_DESC.constructor, MFF_RELIEF_DESC.data);
+
+ desc = champlain_map_source_desc_new_full (
+ CHAMPLAIN_MAP_SOURCE_MFF_RELIEF,
+ "Maps for Free Relief",
+ "Map data available under GNU Free Documentation license, Version 1.2 or later",
+ "http://www.gnu.org/copyleft/fdl.html",
+ 0,
+ 11,
+ 256,
+ CHAMPLAIN_MAP_PROJECTION_MERCATOR,
+ "http://maps-for-free.com/layer/relief/z#Z#/row#Y#/#Z#_#X#-#Y#.jpg",
+ champlain_map_source_new_generic,
+ NULL);
+ champlain_map_source_factory_register (factory, desc);
+
#ifdef CHAMPLAIN_HAS_MEMPHIS
- champlain_map_source_factory_register (factory, &MEMPHIS_LOCAL_DESC,
- MEMPHIS_LOCAL_DESC.constructor, MEMPHIS_LOCAL_DESC.data);
- champlain_map_source_factory_register (factory, &MEMPHIS_NETWORK_DESC,
- MEMPHIS_NETWORK_DESC.constructor, MEMPHIS_NETWORK_DESC.data);
+ desc = champlain_map_source_desc_new_full (
+ CHAMPLAIN_MAP_SOURCE_MEMPHIS_LOCAL,
+ "OpenStreetMap Memphis Local Map",
+ "(CC) BY 2.0 OpenStreetMap contributors",
+ "http://creativecommons.org/licenses/by/2.0/",
+ 12,
+ 18,
+ 256,
+ CHAMPLAIN_MAP_PROJECTION_MERCATOR,
+ "",
+ champlain_map_source_new_memphis,
+ NULL);
+ champlain_map_source_factory_register (factory, desc);
+
+ desc = champlain_map_source_desc_new_full (
+ CHAMPLAIN_MAP_SOURCE_MEMPHIS_NETWORK,
+ "OpenStreetMap Memphis Network Map",
+ "(CC) BY 2.0 OpenStreetMap contributors",
+ "http://creativecommons.org/licenses/by/2.0/",
+ 12,
+ 18,
+ 256,
+ CHAMPLAIN_MAP_PROJECTION_MERCATOR,
+ "",
+ champlain_map_source_new_memphis,
+ NULL);
+ champlain_map_source_factory_register (factory, desc);
#endif
}
@@ -332,7 +298,7 @@ champlain_map_source_factory_dup_default (void)
/**
- * champlain_map_source_factory_dup_list:
+ * champlain_map_source_factory_get_registered:
* @factory: the Factory
*
* Get the list of registered map sources.
@@ -343,7 +309,7 @@ champlain_map_source_factory_dup_default (void)
* Since: 0.4
*/
GSList *
-champlain_map_source_factory_dup_list (ChamplainMapSourceFactory *factory)
+champlain_map_source_factory_get_registered (ChamplainMapSourceFactory *factory)
{
return g_slist_copy (factory->priv->registered_sources);
}
@@ -373,8 +339,13 @@ champlain_map_source_factory_create (ChamplainMapSourceFactory *factory,
while (item != NULL)
{
ChamplainMapSourceDesc *desc = CHAMPLAIN_MAP_SOURCE_DESC (item->data);
- if (strcmp (desc->id, id) == 0)
- return desc->constructor (desc, desc->data);
+ if (strcmp (champlain_map_source_desc_get_id (desc), id) == 0)
+ {
+ ChamplainMapSourceConstructor constructor;
+
+ constructor = champlain_map_source_desc_get_constructor (desc);
+ return constructor (desc);
+ }
item = g_slist_next (item);
}
@@ -472,37 +443,48 @@ champlain_map_source_factory_create_error_source (ChamplainMapSourceFactory *fac
*/
gboolean
champlain_map_source_factory_register (ChamplainMapSourceFactory *factory,
- ChamplainMapSourceDesc *desc,
- ChamplainMapSourceConstructor constructor,
- gpointer data)
+ ChamplainMapSourceDesc *desc)
{
/* FIXME: check for existing factory with that name? */
- desc->constructor = constructor;
- desc->data = data;
factory->priv->registered_sources = g_slist_append (factory->priv->registered_sources, desc);
return TRUE;
}
static ChamplainMapSource *
-champlain_map_source_new_generic (
- ChamplainMapSourceDesc *desc, G_GNUC_UNUSED gpointer user_data)
+champlain_map_source_new_generic (ChamplainMapSourceDesc *desc)
{
ChamplainMapSource *map_source;
ChamplainRenderer *renderer;
+ gchar *id, *name, *license, *license_uri, *uri_format;
+ guint min_zoom, max_zoom, tile_size;
+ ChamplainMapProjection projection;
+
+ g_object_get (G_OBJECT (desc),
+ "id", &id,
+ "name", &name,
+ "license", &license,
+ "license-uri", &license_uri,
+ "min-zoom-level", &min_zoom,
+ "max-zoom-level", &max_zoom,
+ "tile-size", &tile_size,
+ "projection", &projection,
+ "uri-format", &uri_format,
+ NULL);
renderer = CHAMPLAIN_RENDERER (champlain_image_renderer_new ());
+
map_source = CHAMPLAIN_MAP_SOURCE (champlain_network_tile_source_new_full (
- desc->id,
- desc->name,
- desc->license,
- desc->license_uri,
- desc->min_zoom_level,
- desc->max_zoom_level,
- 256,
- desc->projection,
- desc->uri_format,
- renderer));
+ id,
+ name,
+ license,
+ license_uri,
+ min_zoom,
+ max_zoom,
+ tile_size,
+ projection,
+ uri_format,
+ renderer));
return map_source;
}
@@ -510,42 +492,55 @@ champlain_map_source_new_generic (
#ifdef CHAMPLAIN_HAS_MEMPHIS
static ChamplainMapSource *
-champlain_map_source_new_memphis (ChamplainMapSourceDesc *desc,
- G_GNUC_UNUSED gpointer user_data)
+champlain_map_source_new_memphis (ChamplainMapSourceDesc *desc)
{
ChamplainMapSource *map_source;
ChamplainRenderer *renderer;
-
- renderer = CHAMPLAIN_RENDERER (champlain_memphis_renderer_new_full (256));
- if (g_strcmp0 (desc->id, CHAMPLAIN_MAP_SOURCE_MEMPHIS_LOCAL) == 0)
+ gchar *id, *name, *license, *license_uri;
+ guint min_zoom, max_zoom, tile_size;
+ ChamplainMapProjection projection;
+
+ g_object_get (G_OBJECT (desc),
+ "id", &id,
+ "name", &name,
+ "license", &license,
+ "license-uri", &license_uri,
+ "min-zoom-level", &min_zoom,
+ "max-zoom-level", &max_zoom,
+ "tile-size", &tile_size,
+ "projection", &projection,
+ NULL);
+
+ renderer = CHAMPLAIN_RENDERER (champlain_memphis_renderer_new_full (tile_size));
+
+ if (g_strcmp0 (id, CHAMPLAIN_MAP_SOURCE_MEMPHIS_LOCAL) == 0)
{
map_source = CHAMPLAIN_MAP_SOURCE (champlain_file_tile_source_new_full (
- desc->id,
- desc->name,
- desc->license,
- desc->license_uri,
- desc->min_zoom_level,
- desc->max_zoom_level,
- 256,
- desc->projection,
+ id,
+ name,
+ license,
+ license_uri,
+ min_zoom,
+ max_zoom,
+ tile_size,
+ projection,
renderer));
}
else
{
map_source = CHAMPLAIN_MAP_SOURCE (champlain_network_bbox_tile_source_new_full (
- desc->id,
- desc->name,
- desc->license,
- desc->license_uri,
- desc->min_zoom_level,
- desc->max_zoom_level,
- 256,
- desc->projection,
+ id,
+ name,
+ license,
+ license_uri,
+ min_zoom,
+ max_zoom,
+ tile_size,
+ projection,
renderer));
}
return map_source;
}
-
#endif
diff --git a/champlain/champlain-map-source-factory.h b/champlain/champlain-map-source-factory.h
index 8312089..774683e 100644
--- a/champlain/champlain-map-source-factory.h
+++ b/champlain/champlain-map-source-factory.h
@@ -70,8 +70,6 @@ GType champlain_map_source_factory_get_type (void);
ChamplainMapSourceFactory *champlain_map_source_factory_dup_default (void);
-GSList *champlain_map_source_factory_dup_list (ChamplainMapSourceFactory *factory);
-
ChamplainMapSource *champlain_map_source_factory_create (ChamplainMapSourceFactory *factory,
const gchar *id);
ChamplainMapSource *champlain_map_source_factory_create_cached_source (ChamplainMapSourceFactory *factory,
@@ -80,9 +78,8 @@ ChamplainMapSource *champlain_map_source_factory_create_error_source (ChamplainM
guint tile_size);
gboolean champlain_map_source_factory_register (ChamplainMapSourceFactory *factory,
- ChamplainMapSourceDesc *desc,
- ChamplainMapSourceConstructor constructor,
- gpointer data);
+ ChamplainMapSourceDesc *desc);
+GSList *champlain_map_source_factory_get_registered (ChamplainMapSourceFactory *factory);
#ifndef CHAMPLAIN_HAS_MAEMO
/**
diff --git a/champlain/champlain-scale.c b/champlain/champlain-scale.c
index 32d3417..7a504dd 100644
--- a/champlain/champlain-scale.c
+++ b/champlain/champlain-scale.c
@@ -350,11 +350,8 @@ create_scale (ChamplainScale *scale)
scale_actor = clutter_cairo_texture_new (priv->max_scale_width + 2 * SCALE_INSIDE_PADDING, SCALE_HEIGHT + priv->text_height + GAP_SIZE + 2*SCALE_INSIDE_PADDING);
clutter_actor_set_name (scale_actor, "scale-line");
clutter_container_add_actor (CLUTTER_CONTAINER (scale), scale_actor);
-// clutter_actor_set_position (CLUTTER_ACTOR (scale_actor), 0, 2*SCALE_INSIDE_PADDING);
-// priv->viewport_size.height - SCALE_HEIGHT - SCALE_PADDING - SCALE_INSIDE_PADDING);
clutter_actor_set_opacity (CLUTTER_ACTOR (scale), 200);
-// clutter_actor_raise_top (scale);
}
diff --git a/demos/launcher-gtk.c b/demos/launcher-gtk.c
index a791859..53b3208 100644
--- a/demos/launcher-gtk.c
+++ b/demos/launcher-gtk.c
@@ -173,18 +173,18 @@ build_combo_box (GtkComboBox *box)
-1);
factory = champlain_map_source_factory_dup_default ();
- sources = champlain_map_source_factory_dup_list (factory);
+ sources = champlain_map_source_factory_get_registered (factory);
iter = sources;
while (iter != NULL)
{
- ChamplainMapSourceDesc *desc;
-
- desc = (ChamplainMapSourceDesc *) iter->data;
+ ChamplainMapSourceDesc *desc = CHAMPLAIN_MAP_SOURCE_DESC (iter->data);
+ const gchar *id = champlain_map_source_desc_get_id (desc);
+ const gchar *name = champlain_map_source_desc_get_name (desc);
gtk_tree_store_append (store, &parent, NULL);
- gtk_tree_store_set (store, &parent, COL_ID, desc->id,
- COL_NAME, desc->name, -1);
+ gtk_tree_store_set (store, &parent, COL_ID, id,
+ COL_NAME, name, -1);
iter = g_slist_next (iter);
}
diff --git a/demos/local-rendering.c b/demos/local-rendering.c
index 9cc1808..3fa998c 100644
--- a/demos/local-rendering.c
+++ b/demos/local-rendering.c
@@ -613,18 +613,18 @@ build_source_combo_box (GtkComboBox *box)
-1);
factory = champlain_map_source_factory_dup_default ();
- sources = champlain_map_source_factory_dup_list (factory);
+ sources = champlain_map_source_factory_get_registered (factory);
iter = sources;
while (iter != NULL)
{
- ChamplainMapSourceDesc *desc;
-
- desc = (ChamplainMapSourceDesc *) iter->data;
+ ChamplainMapSourceDesc *desc = CHAMPLAIN_MAP_SOURCE_DESC (iter->data);
+ const gchar *id = champlain_map_source_desc_get_id (desc);
+ const gchar *name = champlain_map_source_desc_get_name (desc);
gtk_tree_store_append (store, &parent, NULL);
- gtk_tree_store_set (store, &parent, COL_ID, desc->id,
- COL_NAME, desc->name, -1);
+ gtk_tree_store_set (store, &parent, COL_ID, id,
+ COL_NAME, name, -1);
iter = g_slist_next (iter);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]