From: Pierre-Luc Beaudoin Date: Thu, 13 Nov 2008 04:07:17 +0000 (-0500) Subject: Add license data to maps X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccab2c47b5b4e3466e1668fd071f083352c5e250;p=libchamplain Add license data to maps --- diff --git a/champlain/champlainview.c b/champlain/champlainview.c index 6774bea..a5bbdd3 100644 --- a/champlain/champlainview.c +++ b/champlain/champlainview.c @@ -52,7 +52,8 @@ enum PROP_MAP_SOURCE, PROP_OFFLINE, PROP_DECEL_RATE, - PROP_KEEP_CENTER_ON_RESIZE + PROP_KEEP_CENTER_ON_RESIZE, + PROP_SHOW_LICENSE }; // static guint champlain_view_signals[LAST_SIGNAL] = { 0, }; @@ -74,6 +75,7 @@ struct _ChamplainViewPrivate ClutterActor *viewport; ClutterActor *finger_scroll; ChamplainRectangle viewport_size; + ClutterActor *license_actor; ClutterActor *user_layers; @@ -81,6 +83,7 @@ struct _ChamplainViewPrivate gboolean offline; gboolean keep_center_on_resize; + gboolean show_license; }; G_DEFINE_TYPE (ChamplainView, champlain_view, CLUTTER_TYPE_GROUP); @@ -351,6 +354,9 @@ champlain_view_get_property(GObject *object, guint prop_id, GValue *value, GPara case PROP_KEEP_CENTER_ON_RESIZE: g_value_set_boolean(value, priv->keep_center_on_resize); break; + case PROP_SHOW_LICENSE: + g_value_set_boolean(value, priv->show_license); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); } @@ -387,7 +393,7 @@ champlain_view_set_property(GObject *object, guint prop_id, const GValue *value, resize_viewport(view); clutter_container_remove_actor (CLUTTER_CONTAINER (priv->map_layer), group); clutter_container_add_actor (CLUTTER_CONTAINER (priv->map_layer), priv->map->current_level->group); - champlain_view_center_on(view, priv->latitude, priv->longtitude); + champlain_view_center_on(view, priv->latitude, priv->longitude); } } } @@ -438,6 +444,9 @@ champlain_view_set_property(GObject *object, guint prop_id, const GValue *value, case PROP_KEEP_CENTER_ON_RESIZE: priv->keep_center_on_resize = g_value_get_boolean(value); break; + case PROP_SHOW_LICENSE: + priv->show_license = g_value_get_boolean(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); } @@ -574,6 +583,21 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass) "upon resizing", TRUE, CHAMPLAIN_PARAM_READWRITE)); + /** + * ChamplainView:show-license: + * + * Show the license on the map view. The license information should always be available + * in a way or another in your application. You can have it in About, or on the map. + * + * Since: 0.2.8 + */ + g_object_class_install_property (object_class, + PROP_SHOW_LICENSE, + g_param_spec_boolean ("show-license", + "Show the map data license", + "Show the map data license on the map view", + TRUE, + CHAMPLAIN_PARAM_READWRITE)); } static void @@ -726,6 +750,12 @@ champlain_view_new (ChamplainViewMode mode) "button-press-event", G_CALLBACK (finger_scroll_clicked), view); + + // License layer + priv->license_actor = clutter_group_new(); + clutter_actor_show(priv->license_actor); + clutter_container_add_actor (CLUTTER_CONTAINER (priv->stage), priv->license_actor); + clutter_actor_raise_top (priv->license_actor); // Setup user_layers priv->user_layers = clutter_group_new(); diff --git a/champlain/map.h b/champlain/map.h index e52c815..3c68bbb 100644 --- a/champlain/map.h +++ b/champlain/map.h @@ -32,6 +32,8 @@ struct _Map { guint zoom_levels; const gchar *name; + const gchar *license; + const gchar *license_uri; int tile_size; ZoomLevel *current_level; @@ -49,8 +51,6 @@ struct _Map gchar *(* get_tile_uri) (Map *map, Tile *tile); }; - - Map *map_new (ChamplainMapSource source); void map_load_visible_tiles (Map *map, ChamplainRectangle viewport, gboolean offline); diff --git a/champlain/sources/debugmap.c b/champlain/sources/debugmap.c index 333d184..5e30730 100644 --- a/champlain/sources/debugmap.c +++ b/champlain/sources/debugmap.c @@ -34,6 +34,8 @@ debugmap_init(Map *map) { map->name = "Debug"; map->zoom_levels = 1; + map->license = "Map data available under GNU Free Documentation license, Version 1.2 or later"; + map->license_uri = "http://www.gnu.org/copyleft/fdl.html"; map->tile_size = 256; map->get_row_count = debugmap_row_count; diff --git a/champlain/sources/mffrelief.c b/champlain/sources/mffrelief.c index 6956a2e..220436b 100644 --- a/champlain/sources/mffrelief.c +++ b/champlain/sources/mffrelief.c @@ -41,6 +41,8 @@ void mff_relief_init(Map *map) { map->name = "Maps For Free Relief"; + map->license = "Map data available under GNU Free Documentation license, Version 1.2 or later"; + map->license_uri = "http://www.gnu.org/copyleft/fdl.html"; map->zoom_levels = 11; map->tile_size = 256; diff --git a/champlain/sources/oam.c b/champlain/sources/oam.c index 9cb0e88..de72b5d 100644 --- a/champlain/sources/oam.c +++ b/champlain/sources/oam.c @@ -38,6 +38,8 @@ void oam_init(Map *map) { map->name = "OpenArialMap"; + map->license = "Map data is CC BY 3.0 by OpenArialMap Contributors"; + map->license_uri = "http://creativecommons.org/licenses/by/3.0/"; map->zoom_levels = 17; map->tile_size = 256; diff --git a/champlain/sources/osmmapnik.c b/champlain/sources/osmmapnik.c index 1425e53..45dda6e 100644 --- a/champlain/sources/osmmapnik.c +++ b/champlain/sources/osmmapnik.c @@ -41,6 +41,8 @@ void osm_mapnik_init(Map *map) { map->name = "OpenStreetMap"; + map->license = "Map data is CC BY-SA 2.0 by OpenStreetMap Contributors"; + map->license_uri = "http://creativecommons.org/licenses/by-sa/2.0/"; map->zoom_levels = 18; map->tile_size = 256;