diff options
author | Jiří Techet <techet@gmail.com> | 2013-08-21 16:16:09 +0200 |
---|---|---|
committer | Jiří Techet <techet@gmail.com> | 2013-08-21 16:16:09 +0200 |
commit | 9ef17c3564e95bf8366c0af76b599428b8dbc922 (patch) | |
tree | 811ef80c6f37cc217326913a87fca16035f3adc5 | |
parent | 1bf7575f26bcc7773580c825440f0921598d4e06 (diff) | |
download | libchamplain-9ef17c3564e95bf8366c0af76b599428b8dbc922.tar.gz |
Make overlay sources accessible outside of ChamplainView and update license actor
Add a function to access the list of overlay sources, emit the "map-source"
signal when overlay sources changed and update the license actor with
all the overlay source licenses.
-rw-r--r-- | champlain/champlain-license.c | 19 | ||||
-rw-r--r-- | champlain/champlain-view.c | 27 | ||||
-rw-r--r-- | champlain/champlain-view.h | 1 | ||||
-rw-r--r-- | docs/reference/libchamplain-sections.txt | 1 |
4 files changed, 48 insertions, 0 deletions
diff --git a/champlain/champlain-license.c b/champlain/champlain-license.c index f29bd04..eb81f03 100644 --- a/champlain/champlain-license.c +++ b/champlain/champlain-license.c @@ -128,6 +128,7 @@ redraw_license (ChamplainLicense *license) gchar *text; gfloat width, height; ChamplainMapSource *map_source; + GList *overlay_sources, *iter; if (!priv->view) return; @@ -144,6 +145,24 @@ redraw_license (ChamplainLicense *license) NULL); else text = g_strdup (champlain_map_source_get_license (map_source)); + + overlay_sources = champlain_view_get_overlay_sources (priv->view); + for (iter = overlay_sources; iter; iter = iter->next) + { + ChamplainMapSource *map_source = iter->data; + const gchar *overlay_license = champlain_map_source_get_license (map_source); + + if (g_strrstr (text, overlay_license) == NULL) + { + gchar *old_text = text; + text = g_strjoin ("\n", + text, + champlain_map_source_get_license (map_source), + NULL); + g_free (old_text); + } + } + g_list_free (overlay_sources); clutter_text_set_text (CLUTTER_TEXT (priv->license_actor), text); clutter_actor_get_size (priv->license_actor, &width, &height); diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c index d69fff0..16c64ee 100644 --- a/champlain/champlain-view.c +++ b/champlain/champlain-view.c @@ -3078,6 +3078,7 @@ champlain_view_add_overlay_source (ChamplainView *view, g_object_ref (source); priv->overlay_sources = g_list_append (priv->overlay_sources, source); g_object_set_data (G_OBJECT (source), "opacity", GINT_TO_POINTER (opacity)); + g_object_notify (G_OBJECT (view), "map-source"); champlain_view_reload_tiles (view); } @@ -3106,6 +3107,32 @@ champlain_view_remove_overlay_source (ChamplainView *view, priv = view->priv; priv->overlay_sources = g_list_remove (priv->overlay_sources, source); g_object_unref (source); + g_object_notify (G_OBJECT (view), "map-source"); champlain_view_reload_tiles (view); } + + +/** + * champlain_view_get_overlay_sources: + * @view: a #ChamplainView + * + * Gets a list of overlay sources. + * + * Returns: (transfer container) (element-type ChamplainMapSource): the list + * + * Since: 0.12.5 + */ +GList * +champlain_view_get_overlay_sources (ChamplainView *view) +{ + DEBUG_LOG () + + ChamplainViewPrivate *priv; + + g_return_val_if_fail (CHAMPLAIN_IS_VIEW (view), NULL); + + priv = view->priv; + + return g_list_copy (priv->overlay_sources); +} diff --git a/champlain/champlain-view.h b/champlain/champlain-view.h index f3b95b9..36ffb35 100644 --- a/champlain/champlain-view.h +++ b/champlain/champlain-view.h @@ -112,6 +112,7 @@ void champlain_view_add_overlay_source (ChamplainView *view, guint8 opacity); void champlain_view_remove_overlay_source (ChamplainView *view, ChamplainMapSource *map_source); +GList *champlain_view_get_overlay_sources (ChamplainView *view); void champlain_view_set_deceleration (ChamplainView *view, gdouble rate); diff --git a/docs/reference/libchamplain-sections.txt b/docs/reference/libchamplain-sections.txt index 6a91ab2..88a946b 100644 --- a/docs/reference/libchamplain-sections.txt +++ b/docs/reference/libchamplain-sections.txt @@ -134,6 +134,7 @@ champlain_view_ensure_layers_visible champlain_view_set_map_source champlain_view_add_overlay_source champlain_view_remove_overlay_source +champlain_view_get_overlay_sources champlain_view_set_deceleration champlain_view_set_kinetic_mode champlain_view_set_keep_center_on_resize |