[libchamplain] Add the property selection-mode



commit 2b86484d884567eeb84484d7b490bf7338bb7987
Author: Emmanuel Rodriguez <emmanuel rodriguez gmail com>
Date:   Thu Jul 9 23:21:37 2009 +0200

    Add the property selection-mode

 champlain/champlain-selection-layer.c |   67 +++++++++++++++++++++++++++++++-
 champlain/champlain-selection-layer.h |    5 ++
 2 files changed, 69 insertions(+), 3 deletions(-)
---
diff --git a/champlain/champlain-selection-layer.c b/champlain/champlain-selection-layer.c
index 40728d4..f0252ba 100644
--- a/champlain/champlain-selection-layer.c
+++ b/champlain/champlain-selection-layer.c
@@ -36,6 +36,7 @@
 
 #include "champlain-defines.h"
 #include "champlain-base-marker.h"
+#include "champlain-enum-types.h"
 
 #include <clutter/clutter.h>
 #include <glib.h>
@@ -47,7 +48,8 @@ G_DEFINE_TYPE (ChamplainSelectionLayer, champlain_selection_layer, CHAMPLAIN_TYP
 
 enum
 {
-  PROP_0
+  PROP_0,
+  PROP_SELECTION_MODE
 };
 
 struct _ChamplainSelectionLayerPrivate {
@@ -61,9 +63,14 @@ champlain_selection_layer_get_property (GObject *object,
     GValue *value,
     GParamSpec *pspec)
 {
-  //ChamplainSelectionLayer *self = CHAMPLAIN_SELECTION_LAYER (object);
+  ChamplainSelectionLayer *self = CHAMPLAIN_SELECTION_LAYER (object);
+  ChamplainSelectionLayerPrivate *priv = self->priv;
+
   switch (property_id)
     {
+      case PROP_SELECTION_MODE:
+        g_value_set_enum (value, priv->mode);
+        break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
@@ -75,9 +82,13 @@ champlain_selection_layer_set_property (GObject *object,
     const GValue *value,
     GParamSpec *pspec)
 {
-  //ChamplainSelectionLayer *self = CHAMPLAIN_SELECTION_LAYER (object);
+  ChamplainSelectionLayer *self = CHAMPLAIN_SELECTION_LAYER (object);
+
   switch (property_id)
     {
+      case PROP_SELECTION_MODE:
+        champlain_selection_layer_set_selection_mode (self, g_value_get_enum (value));
+        break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
@@ -92,6 +103,22 @@ champlain_selection_layer_class_init (ChamplainSelectionLayerClass *klass)
 
   object_class->get_property = champlain_selection_layer_get_property;
   object_class->set_property = champlain_selection_layer_set_property;
+
+  /**
+  * ChamplainView:selection-mode:
+  *
+  * Determines the type of selection that will be performed.
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class,
+      PROP_SELECTION_MODE,
+      g_param_spec_enum ("selection-mode",
+           "Selection Mode",
+           "Determines the type of selection that will be performed.",
+           CHAMPLAIN_TYPE_SELECTION_MODE,
+           CHAMPLAIN_SELECTION_MULTIPLE,
+           CHAMPLAIN_PARAM_READWRITE));
 }
 
 static void
@@ -292,3 +319,37 @@ champlain_selection_layer_marker_is_selected (ChamplainSelectionLayer *layer,
   selection = g_list_find (layer->priv->selection, marker);
   return selection != NULL;
 }
+
+/**
+* champlain_selection_layer_set_selection_mode:
+* @layer: a #ChamplainSelectionLayer
+* @mode: a #ChamplainSelectionMode value
+*
+* Sets the selection mode of the layer.
+*
+* Since: 0.4
+*/
+void
+champlain_selection_layer_set_selection_mode (ChamplainSelectionLayer *layer,
+    ChamplainSelectionMode mode)
+{
+  g_return_if_fail (CHAMPLAIN_IS_SELECTION_LAYER (layer));
+  layer->priv->mode = mode;
+}
+
+/**
+* champlain_selection_layer_get_selection_mode:
+* @layer: a #ChamplainSelectionLayer
+*
+* REturns the selection mode of the layer.
+*
+* Since: 0.4
+*/
+ChamplainSelectionMode
+champlain_selection_layer_get_selection_mode (ChamplainSelectionLayer *layer)
+{
+  g_return_val_if_fail (
+      CHAMPLAIN_IS_SELECTION_LAYER (layer),
+      CHAMPLAIN_SELECTION_MULTIPLE);
+  return layer->priv->mode;
+}
diff --git a/champlain/champlain-selection-layer.h b/champlain/champlain-selection-layer.h
index 3ab4767..ab911f4 100644
--- a/champlain/champlain-selection-layer.h
+++ b/champlain/champlain-selection-layer.h
@@ -92,6 +92,11 @@ gboolean champlain_selection_layer_marker_is_selected (ChamplainSelectionLayer *
 void champlain_selection_layer_select_all (ChamplainSelectionLayer *layer);
 void champlain_selection_layer_unselect_all (ChamplainSelectionLayer *layer);
 
+void champlain_selection_layer_set_selection_mode (ChamplainSelectionLayer *layer,
+    ChamplainSelectionMode mode);
+ChamplainSelectionMode champlain_selection_layer_get_selection_mode (
+    ChamplainSelectionLayer *layer);
+
 G_END_DECLS
 
 #endif



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