[libchamplain] Hide some of the Clutter API



commit bd3e6d13c93360d95e23deb692517ce99ac9a8a6
Author: Pierre-Luc Beaudoin <pierre-luc pierlux com>
Date:   Tue Jul 28 23:47:54 2009 -0400

    Hide some of the Clutter API
    
    Just in case we decide to have ChamplainLayer not be a
    ClutterGroup in future versions

 champlain/champlain-layer.c |   70 +++++++++++++++++++++++++++++++++++++++++++
 champlain/champlain-layer.h |    9 +++++
 demos/markers.c             |   10 +++---
 3 files changed, 84 insertions(+), 5 deletions(-)
---
diff --git a/champlain/champlain-layer.c b/champlain/champlain-layer.c
index c25192a..b28295b 100644
--- a/champlain/champlain-layer.c
+++ b/champlain/champlain-layer.c
@@ -189,3 +189,73 @@ champlain_layer_new ()
 {
   return g_object_new (CHAMPLAIN_TYPE_LAYER, NULL);
 }
+
+/**
+ * champlain_layer_add_marker:
+ * @layer: a #ChamplainLayer
+ * @marker: a #ChamplainBaseMarker
+ *
+ * Adds the marker to the layer.
+ *
+ * Since: 0.4
+ */
+void
+champlain_layer_add_marker (ChamplainLayer *layer,
+    ChamplainBaseMarker *marker)
+{
+  g_return_if_fail (CHAMPLAIN_IS_LAYER (layer));
+  g_return_if_fail (CHAMPLAIN_IS_BASE_MARKER (marker));
+
+  clutter_container_add (CLUTTER_CONTAINER (layer), CLUTTER_ACTOR (marker), NULL);
+}
+
+/**
+ * champlain_layer_remove_marker:
+ * @layer: a #ChamplainLayer
+ * @marker: a #ChamplainBaseMarker
+ *
+ * Removes the marker from the layer.
+ *
+ * Since: 0.4
+ */
+void
+champlain_layer_remove_marker (ChamplainLayer *layer,
+    ChamplainBaseMarker *marker)
+{
+  g_return_if_fail (CHAMPLAIN_IS_LAYER (layer));
+  g_return_if_fail (CHAMPLAIN_IS_BASE_MARKER (marker));
+
+  clutter_container_remove (CLUTTER_CONTAINER (layer), CLUTTER_ACTOR (marker), NULL);
+}
+
+/**
+ * champlain_layer_show:
+ * @layer: a #ChamplainLayer
+ *
+ * Makes the layer and its markers visible.
+ *
+ * Since: 0.4
+ */
+void
+champlain_layer_show (ChamplainLayer *layer)
+{
+  g_return_if_fail (CHAMPLAIN_IS_LAYER (layer));
+
+  clutter_actor_show (CLUTTER_ACTOR (layer));
+}
+
+/**
+ * champlain_layer_hide:
+ * @layer: a #ChamplainLayer
+ *
+ * Makes the layer and its markers invisible.
+ *
+ * Since: 0.4
+ */
+void
+champlain_layer_hide (ChamplainLayer *layer)
+{
+  g_return_if_fail (CHAMPLAIN_IS_LAYER (layer));
+
+  clutter_actor_hide (CLUTTER_ACTOR (layer));
+}
diff --git a/champlain/champlain-layer.h b/champlain/champlain-layer.h
index 6bd471a..54a5d5e 100644
--- a/champlain/champlain-layer.h
+++ b/champlain/champlain-layer.h
@@ -24,6 +24,7 @@
 #define CHAMPLAIN_LAYER_H
 
 #include <champlain/champlain-defines.h>
+#include <champlain/champlain-base-marker.h>
 
 #include <glib-object.h>
 #include <clutter/clutter.h>
@@ -59,6 +60,14 @@ GType champlain_layer_get_type (void);
 
 ChamplainLayer* champlain_layer_new (void);
 
+void champlain_layer_show (ChamplainLayer *layer);
+void champlain_layer_hide (ChamplainLayer *layer);
+
+void champlain_layer_add_marker (ChamplainLayer *layer,
+    ChamplainBaseMarker *marker);
+void champlain_layer_remove_marker (ChamplainLayer *layer,
+    ChamplainBaseMarker *marker);
+
 G_END_DECLS
 
 #endif
diff --git a/demos/markers.c b/demos/markers.c
index c8d9006..6166eaa 100644
--- a/demos/markers.c
+++ b/demos/markers.c
@@ -49,7 +49,7 @@ create_marker_layer (ChamplainView *view)
 
   champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker),
       45.528178, -73.563788);
-  clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
+  champlain_layer_add_marker (layer, CHAMPLAIN_BASE_MARKER (marker));
   clutter_actor_set_reactive (marker, TRUE);
   g_signal_connect_after (marker, "button-release-event",
       G_CALLBACK (marker_button_release_cb), view);
@@ -57,19 +57,19 @@ create_marker_layer (ChamplainView *view)
   marker = champlain_marker_new_from_file ("/usr/share/icons/gnome/24x24/emblems/emblem-generic.png", NULL);
   champlain_marker_set_text (CHAMPLAIN_MARKER (marker), "New York");
   champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 40.77, -73.98);
-  clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
+  champlain_layer_add_marker (layer, CHAMPLAIN_BASE_MARKER (marker));
 
   marker = champlain_marker_new_from_file ("/usr/share/icons/gnome/24x24/emblems/emblem-important.png", NULL);
   champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 47.130885,
       -70.764141);
-  clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
+  champlain_layer_add_marker (layer, CHAMPLAIN_BASE_MARKER (marker));
 
   marker = champlain_marker_new_from_file ("/usr/share/icons/gnome/24x24/emblems/emblem-favorite.png", NULL);
   champlain_marker_set_draw_background (CHAMPLAIN_MARKER (marker), FALSE);
   champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 45.41484,
       -71.918907);
-  clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
+  champlain_layer_add_marker (layer, CHAMPLAIN_BASE_MARKER (marker));
 
-  clutter_actor_show (CLUTTER_ACTOR (layer));
+  champlain_layer_show (layer);
   return layer;
 }



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