]> err.no Git - libchamplain/commitdiff
Basic implementation of ChamplainSelectionLayer
authorEmmanuel Rodriguez <emmanuel.rodriguez@gmail.com>
Wed, 8 Jul 2009 21:11:02 +0000 (23:11 +0200)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Tue, 28 Jul 2009 21:25:12 +0000 (17:25 -0400)
bindings/perl/Champlain/MANIFEST
bindings/perl/Champlain/maps
bindings/perl/Champlain/t/ChamplainSelectionLayer.t [new file with mode: 0644]
bindings/perl/Champlain/xs/ChamplainSelectionLayer.xs [new file with mode: 0644]

index 54775ba201e07b483410c0873a87bfb40aeec4c8..130f0e7f38234dcc7a685e56e497bef18c856b8d 100644 (file)
@@ -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
index 9910027e78730f969431d00a05bd630831479925..88f62d88c4008c76a086b38d5c76a4cf3f53ef96 100644 (file)
@@ -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 (file)
index 0000000..5726c54
--- /dev/null
@@ -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 (file)
index 0000000..0f9a2ab
--- /dev/null
@@ -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)