From: Emmanuel Rodriguez Date: Thu, 9 Jul 2009 21:21:37 +0000 (+0200) Subject: Add the property selection-mode X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b86484d884567eeb84484d7b490bf7338bb7987;p=libchamplain Add the property selection-mode --- 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 #include @@ -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