]> err.no Git - libchamplain/commitdiff
Hide some of the Clutter API
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Wed, 29 Jul 2009 03:47:54 +0000 (23:47 -0400)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Wed, 29 Jul 2009 03:47:54 +0000 (23:47 -0400)
Just in case we decide to have ChamplainLayer not be a
ClutterGroup in future versions

champlain/champlain-layer.c
champlain/champlain-layer.h
demos/markers.c

index c25192a8ffb87c97f9b8753bbca3d2c81cb52857..b28295bf5838b96498af116ee319671002c83371 100644 (file)
@@ -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));
+}
index 6bd471ae72d4b6bd47570a1d6a7eda9722ba537d..54a5d5e8bb9c2864c5e61d1c43d52283a9c89f58 100644 (file)
@@ -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
index c8d90060dde8d42ab0ab7049274f3494a4c5f1a4..6166eaa54e535d37442261d76aa1f1b7326ef5f1 100644 (file)
@@ -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;
 }