From: Pierre-Luc Beaudoin Date: Tue, 5 May 2009 00:08:02 +0000 (-0400) Subject: Add Id to ChamplainMapSource X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb743746a89ef9ce8b47d0a061f89e7750cce3f0;p=libchamplain Add Id to ChamplainMapSource --- diff --git a/champlain/champlain-map-source-factory.c b/champlain/champlain-map-source-factory.c index fb93b4f..5b5271b 100644 --- a/champlain/champlain-map-source-factory.c +++ b/champlain/champlain-map-source-factory.c @@ -306,6 +306,7 @@ static ChamplainMapSource * champlain_map_source_new_osm_cyclemap (void) { return CHAMPLAIN_MAP_SOURCE (champlain_network_map_source_new_full (CHAMPLAIN_MAP_SOURCE_OSM_CYCLE_MAP, + "OpenStreetMap Cycle Map", "(CC) BY 2.0 OpenStreetMap contributors", "http://creativecommons.org/licenses/by/2.0/", 0, 18, 256, CHAMPLAIN_MAP_PROJECTION_MERCATOR, @@ -316,6 +317,7 @@ static ChamplainMapSource * champlain_map_source_new_osm_osmarender (void) { return CHAMPLAIN_MAP_SOURCE (champlain_network_map_source_new_full (CHAMPLAIN_MAP_SOURCE_OSM_OSMARENDER, + "OpenStreetMap Osmarender", "(CC) BY 2.0 OpenStreetMap contributors", "http://creativecommons.org/licenses/by/2.0/", 0, 18, 256, CHAMPLAIN_MAP_PROJECTION_MERCATOR, @@ -325,7 +327,8 @@ champlain_map_source_new_osm_osmarender (void) static ChamplainMapSource * champlain_map_source_new_osm_mapnik (void) { - return CHAMPLAIN_MAP_SOURCE (champlain_network_map_source_new_full ("OpenStreetMap Mapnik", + return CHAMPLAIN_MAP_SOURCE (champlain_network_map_source_new_full (CHAMPLAIN_MAP_SOURCE_OSM_MAPNIK, + "OpenStreetMap Mapnik", "(CC) BY 2.0 OpenStreetMap contributors", "http://creativecommons.org/licenses/by/2.0/", 0, 18, 256, CHAMPLAIN_MAP_PROJECTION_MERCATOR, @@ -336,6 +339,7 @@ static ChamplainMapSource * champlain_map_source_new_oam (void) { return CHAMPLAIN_MAP_SOURCE (champlain_network_map_source_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, @@ -346,6 +350,7 @@ static ChamplainMapSource * champlain_map_source_new_mff_relief (void) { return CHAMPLAIN_MAP_SOURCE (champlain_network_map_source_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, diff --git a/champlain/champlain-map-source.c b/champlain/champlain-map-source.c index ef9765b..1b89fbb 100644 --- a/champlain/champlain-map-source.c +++ b/champlain/champlain-map-source.c @@ -60,6 +60,7 @@ enum enum { PROP_0, + PROP_ID, PROP_NAME, PROP_LICENSE, PROP_LICENSE_URI, @@ -77,6 +78,7 @@ G_DEFINE_TYPE (ChamplainMapSource, champlain_map_source, G_TYPE_OBJECT); struct _ChamplainMapSourcePrivate { + gchar *id; gchar *name; gchar *license; gchar *license_uri; @@ -97,6 +99,9 @@ champlain_map_source_get_property (GObject *object, 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; @@ -134,6 +139,9 @@ champlain_map_source_set_property (GObject *object, switch(prop_id) { + case PROP_ID: + champlain_map_source_set_id (map_source, + g_value_get_string (value)); case PROP_NAME: champlain_map_source_set_name (map_source, g_value_get_string (value)); @@ -187,6 +195,20 @@ champlain_map_source_class_init (ChamplainMapSourceClass *klass) klass->fill_tile = champlain_map_source_real_fill_tile; + /** + * ChamplainMapSource:id: + * + * The name of the map source + * + * Since: 0.4 + */ + pspec = g_param_spec_string ("id", + "Id", + "The id of the map source", + "", + (G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + g_object_class_install_property (object_class, PROP_ID, pspec); + /** * ChamplainMapSource:name: * @@ -638,3 +660,38 @@ champlain_map_source_set_projection (ChamplainMapSource *map_source, g_object_notify (G_OBJECT (map_source), "projection"); } +/** + * champlain_map_source_get_id: + * @map_source: a #ChamplainMapSource + * + * Returns the map source's id. + * + * Since: 0.4 + */ +const gchar * +champlain_map_source_get_id (ChamplainMapSource *map_source) +{ + ChamplainMapSourcePrivate *priv = map_source->priv; + return priv->id; +} + +/** + * champlain_map_source_set_id: + * @map_source: a #ChamplainMapSource + * @id: a id + * + * Sets the map source's id. + * + * Since: 0.4 + */ +void +champlain_map_source_set_id (ChamplainMapSource *map_source, + const gchar *id) +{ + ChamplainMapSourcePrivate *priv = map_source->priv; + + g_free (priv->id); + priv->id = g_strdup (id); + g_object_notify (G_OBJECT (map_source), "id"); +} + diff --git a/champlain/champlain-map-source.h b/champlain/champlain-map-source.h index 8c82116..3845926 100644 --- a/champlain/champlain-map-source.h +++ b/champlain/champlain-map-source.h @@ -94,6 +94,10 @@ guint champlain_map_source_get_column_count (ChamplainMapSource *map_source, void champlain_map_source_fill_tile (ChamplainMapSource *map_source, ChamplainTile *tile); +void champlain_map_source_set_id (ChamplainMapSource *map_source, + const gchar *id); +const gchar * champlain_map_source_get_id (ChamplainMapSource *map_source); + void champlain_map_source_set_name (ChamplainMapSource *map_source, const gchar *name); const gchar * champlain_map_source_get_name (ChamplainMapSource *map_source); diff --git a/champlain/champlain-network-map-source.c b/champlain/champlain-network-map-source.c index 017d088..3e1c7ea 100644 --- a/champlain/champlain-network-map-source.c +++ b/champlain/champlain-network-map-source.c @@ -246,7 +246,8 @@ champlain_network_map_source_init (ChamplainNetworkMapSource *champlainMapSource * Since: 0.4 */ ChamplainNetworkMapSource* -champlain_network_map_source_new_full (const gchar *name, +champlain_network_map_source_new_full (const gchar *id, + const gchar *name, const gchar *license, const gchar *license_uri, guint min_zoom, @@ -256,8 +257,8 @@ champlain_network_map_source_new_full (const gchar *name, const gchar *uri_format) { ChamplainNetworkMapSource * source; - source = g_object_new (CHAMPLAIN_TYPE_NETWORK_MAP_SOURCE, "name", name, - "license", license, "license-uri", license_uri, + source = g_object_new (CHAMPLAIN_TYPE_NETWORK_MAP_SOURCE, "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); diff --git a/champlain/champlain-network-map-source.h b/champlain/champlain-network-map-source.h index f7a4fdf..4baadae 100644 --- a/champlain/champlain-network-map-source.h +++ b/champlain/champlain-network-map-source.h @@ -54,10 +54,15 @@ struct _ChamplainNetworkMapSourceClass GType champlain_network_map_source_get_type (void); -ChamplainNetworkMapSource* champlain_network_map_source_new_full ( - const gchar *name, const gchar *license, const gchar *license_uri, - guint min_zoom, guint max_zoom, guint tile_size, - ChamplainMapProjection projection, const gchar *uri_format); +ChamplainNetworkMapSource* champlain_network_map_source_new_full (const gchar *id, + const gchar *name, + const gchar *license, + const gchar *license_uri, + guint min_zoom, + guint max_zoom, + guint tile_size, + ChamplainMapProjection projection, + const gchar *uri_format); gchar * champlain_network_map_source_get_tile_uri (ChamplainNetworkMapSource *source, gint x,