[libchamplain] Basic implementation of ChamplainSelectionLayer



commit 3bc917d09a5a72ac80ed8e4ea5c66113e05365ac
Author: Emmanuel Rodriguez <emmanuel rodriguez gmail com>
Date:   Wed Jul 8 23:11:02 2009 +0200

    Basic implementation of ChamplainSelectionLayer

 bindings/perl/Champlain/MANIFEST                   |    2 +
 bindings/perl/Champlain/maps                       |    2 +
 .../perl/Champlain/t/ChamplainSelectionLayer.t     |   70 ++++++++++++++++++++
 .../perl/Champlain/xs/ChamplainSelectionLayer.xs   |   57 ++++++++++++++++
 4 files changed, 131 insertions(+), 0 deletions(-)
---
diff --git a/bindings/perl/Champlain/MANIFEST b/bindings/perl/Champlain/MANIFEST
index 54775ba..130f0e7 100644
--- a/bindings/perl/Champlain/MANIFEST
+++ b/bindings/perl/Champlain/MANIFEST
@@ -18,6 +18,7 @@ xs/ChamplainMarker.xs
 xs/ChamplainNetworkMapSource.xs
 xs/ChamplainPoint.xs
 xs/ChamplainPolygon.xs
+xs/ChamplainSelectionLayer.xs
 xs/ChamplainTile.xs
 xs/ChamplainView.xs
 xs/ChamplainZoomLevel.xs
@@ -32,6 +33,7 @@ t/ChamplainMarker.t
 t/ChamplainNetworkMapSource.t
 t/ChamplainPoint.t
 t/ChamplainPolygon.t
+t/ChamplainSelectionLayer.t
 t/ChamplainTile.t
 t/ChamplainView.t
 t/ChamplainZoomLevel.t
diff --git a/bindings/perl/Champlain/maps b/bindings/perl/Champlain/maps
index 9910027..88f62d8 100644
--- a/bindings/perl/Champlain/maps
+++ b/bindings/perl/Champlain/maps
@@ -14,3 +14,5 @@ CHAMPLAIN_TYPE_CACHE               ChamplainCache             GObject  Champlain
 CHAMPLAIN_TYPE_MAP_SOURCE_DESC     ChamplainMapSourceDesc     GBoxed   Champlain::MapSourceDesc
 CHAMPLAIN_TYPE_POINT               ChamplainPoint             GBoxed   Champlain::Point
 CHAMPLAIN_TYPE_POLYGON             ChamplainPolygon           GObject  Champlain::Polygon
+CHAMPLAIN_TYPE_SELECTION_LAYER     ChamplainSelectionLayer    GObject  Champlain::SelectionLayer
+CHAMPLAIN_TYPE_SELECTION_LAYER     ChamplainSelectionMode     GEnum    Champlain::SelectionMode
diff --git a/bindings/perl/Champlain/t/ChamplainSelectionLayer.t b/bindings/perl/Champlain/t/ChamplainSelectionLayer.t
new file mode 100644
index 0000000..5726c54
--- /dev/null
+++ b/bindings/perl/Champlain/t/ChamplainSelectionLayer.t
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Clutter::TestHelper tests => 5;
+
+use Champlain;
+
+exit tests();
+
+sub tests {
+	test_empty();
+	test_markers();
+	return 0;
+}
+
+
+sub test_empty {
+	my $layer = Champlain::SelectionLayer->new();
+	isa_ok($layer, 'Champlain::Layer');
+	
+	is($layer->get_selected, undef, "No selection on an empty layer");
+	
+	my @markers;
+	@markers = $layer->get_selected_markers;
+	is_deeply(\ markers, [], "No selected markers on an empty layer");
+	
+	my $count = $layer->count_selected_markers;
+	is($count, 0, "Empty marker count on a empty layer");
+
+	my $marker = Champlain::BaseMarker->new();
+	
+	ok(!$layer->marker_is_selected($marker), "Marker is unselected on an empty layer");
+	
+	# Can't be tested but at least they are invoked
+	$layer->select($marker);
+	$layer->unselect($marker);
+#	$layer->select_all();
+	$layer->unselect_all();
+
+	return 0;
+}
+
+
+sub test_markers {
+	my $layer = Champlain::SelectionLayer->new();
+	isa_ok($layer, 'Champlain::Layer');
+	
+	is($layer->get_selected, undef, "No selection on an empty layer");
+	
+	my @markers;
+	@markers = $layer->get_selected_markers;
+	is_deeply(\ markers, [], "No selected markers on an empty layer");
+	
+	my $count = $layer->count_selected_markers;
+	is($count, 0, "Empty marker count on a empty layer");
+
+	my $marker = Champlain::BaseMarker->new();
+	
+	ok(!$layer->marker_is_selected($marker), "Marker is unselected on an empty layer");
+	
+	# Can't be tested but at least they are invoked
+	$layer->select($marker);
+	$layer->unselect($marker);
+#	$layer->select_all();
+	$layer->unselect_all();
+
+	return 0;
+}
diff --git a/bindings/perl/Champlain/xs/ChamplainSelectionLayer.xs b/bindings/perl/Champlain/xs/ChamplainSelectionLayer.xs
new file mode 100644
index 0000000..0f9a2ab
--- /dev/null
+++ b/bindings/perl/Champlain/xs/ChamplainSelectionLayer.xs
@@ -0,0 +1,57 @@
+#include "champlain-perl.h"
+
+
+MODULE = Champlain::SelectionLayer  PACKAGE = Champlain::SelectionLayer  PREFIX = champlain_selection_layer_
+
+
+ChamplainLayer*
+champlain_selection_layer_new (class)
+	C_ARGS: /* No args */
+
+
+ChamplainBaseMarker*
+champlain_selection_layer_get_selected (ChamplainSelectionLayer *layer)
+
+
+void
+champlain_selection_layer_get_selected_markers (ChamplainSelectionLayer *layer)
+	PREINIT:
+		const GList *item = NULL;
+	
+	PPCODE:
+		item = champlain_selection_layer_get_selected_markers(layer);
+
+		if (!item) {
+			XSRETURN_EMPTY;
+		}
+
+		for (; item != NULL; item = item->next) {
+			ChamplainBaseMarker *marker = CHAMPLAIN_BASE_MARKER(item->data);
+			XPUSHs(sv_2mortal(newSVChamplainBaseMarker(marker)));
+		}
+		
+		/* The doc says that the list shouldn't be freed! */
+
+
+guint
+champlain_selection_layer_count_selected_markers (ChamplainSelectionLayer *layer)
+
+
+void
+champlain_selection_layer_select (ChamplainSelectionLayer *layer, ChamplainBaseMarker *marker)
+
+
+void
+champlain_selection_layer_unselect (ChamplainSelectionLayer *layer, ChamplainBaseMarker *marker)
+
+
+gboolean
+champlain_selection_layer_marker_is_selected (ChamplainSelectionLayer *layer, ChamplainBaseMarker *marker)
+
+
+#void
+#champlain_selection_layer_select_all (ChamplainSelectionLayer *layer)
+
+
+void
+champlain_selection_layer_unselect_all (ChamplainSelectionLayer *layer)



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