From a050f6471293b2ab6da9260d57f67ec6356ee98b Mon Sep 17 00:00:00 2001 From: Pierre-Luc Beaudoin Date: Sun, 5 Jul 2009 20:10:12 +0100 Subject: [PATCH] Create ChamplainSelectionLayer --- champlain/Makefile.am | 3 + champlain/champlain-selection-layer.c | 112 ++++++++++++++++++++++++++ champlain/champlain-selection-layer.h | 65 +++++++++++++++ champlain/champlain.h | 1 + demos/markers.c | 2 +- 5 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 champlain/champlain-selection-layer.c create mode 100644 champlain/champlain-selection-layer.h diff --git a/champlain/Makefile.am b/champlain/Makefile.am index e81a29e..330807c 100644 --- a/champlain/Makefile.am +++ b/champlain/Makefile.am @@ -20,6 +20,7 @@ libchamplain_headers = \ champlain-point.h \ champlain-view.h \ champlain-layer.h \ + champlain-selection-layer.h \ champlain-base-marker.h \ champlain-marker.h \ champlain-map.h \ @@ -39,6 +40,7 @@ libchamplain_0_3_la_SOURCES = \ champlain-debug.c \ champlain-view.c \ champlain-layer.c \ + champlain-selection-layer.c \ champlain-base-marker.c \ champlain-marker.c \ champlain-map.c \ @@ -78,6 +80,7 @@ libchamplain_include_HEADERS = \ champlain-point.h \ champlain-enum-types.h \ champlain-layer.h \ + champlain-selection-layer.h \ champlain-map-source.h \ champlain-network-map-source.h \ champlain-map-source-factory.h \ diff --git a/champlain/champlain-selection-layer.c b/champlain/champlain-selection-layer.c new file mode 100644 index 0000000..5e52209 --- /dev/null +++ b/champlain/champlain-selection-layer.c @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2009 Pierre-Luc Beaudoin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * SECTION:champlain-selection-layer + * @short_description: A container for #ChamplainMarker supporting selection + * + * A ChamplainSelectionLayer is little more than a #ChamplainLayer. The markers + * can be selected. + * + * Use #clutter_container_add to add markers to the layer and + * #clutter_container_remove to remove them. + */ + +#include "config.h" + +#include "champlain-selection-layer.h" + +#include "champlain-defines.h" +#include "champlain-base-marker.h" + +#include +#include + +G_DEFINE_TYPE (ChamplainSelectionLayer, champlain_selection_layer, CHAMPLAIN_TYPE_LAYER) + +#define GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHAMPLAIN_TYPE_SELECTION_LAYER, ChamplainSelectionLayerPrivate)) + +enum +{ + PROP_0 +}; + +typedef struct _ChamplainSelectionLayerPrivate ChamplainSelectionLayerPrivate; + +struct _ChamplainSelectionLayerPrivate { + gpointer spacer; +}; + +static void +champlain_selection_layer_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + //ChamplainSelectionLayer *self = CHAMPLAIN_SELECTION_LAYER (object); + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +champlain_selection_layer_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + //ChamplainSelectionLayer *self = CHAMPLAIN_SELECTION_LAYER (object); + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +champlain_selection_layer_class_init (ChamplainSelectionLayerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (ChamplainSelectionLayerPrivate)); + + object_class->get_property = champlain_selection_layer_get_property; + object_class->set_property = champlain_selection_layer_set_property; +} + +static void +champlain_selection_layer_init (ChamplainSelectionLayer *self) +{ + +} + +/** + * champlain_selection_layer_new: + * + * Returns a new #ChamplainSelectionLayer ready to be used as a #ClutterContainer for the markers. + * + * Since: 0.4 + */ +ChamplainLayer * +champlain_selection_layer_new () +{ + return g_object_new (CHAMPLAIN_TYPE_SELECTION_LAYER, NULL); +} diff --git a/champlain/champlain-selection-layer.h b/champlain/champlain-selection-layer.h new file mode 100644 index 0000000..f8938fb --- /dev/null +++ b/champlain/champlain-selection-layer.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2009 Pierre-Luc Beaudoin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#if !defined (__CHAMPLAIN_CHAMPLAIN_H_INSIDE__) && !defined (CHAMPLAIN_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef CHAMPLAIN_SELECTION_LAYER_H +#define CHAMPLAIN_SELECTION_LAYER_H + +#include +#include + +#include +#include + +G_BEGIN_DECLS + +#define CHAMPLAIN_TYPE_SELECTION_LAYER champlain_selection_layer_get_type() + +#define CHAMPLAIN_SELECTION_LAYER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHAMPLAIN_TYPE_SELECTION_LAYER, ChamplainSelectionLayer)) + +#define CHAMPLAIN_SELECTION_LAYER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), CHAMPLAIN_TYPE_SELECTION_LAYER, ChamplainSelectionLayerClass)) + +#define CHAMPLAIN_IS_SELECTION_LAYER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHAMPLAIN_TYPE_SELECTION_LAYER)) + +#define CHAMPLAIN_IS_SELECTION_LAYER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), CHAMPLAIN_TYPE_SELECTION_LAYER)) + +#define CHAMPLAIN_SELECTION_LAYER_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), CHAMPLAIN_TYPE_SELECTION_LAYER, ChamplainSelectionLayerClass)) + +typedef struct { + ChamplainLayer parent; +} ChamplainSelectionLayer; + +typedef struct { + ChamplainLayerClass parent_class; +} ChamplainSelectionLayerClass; + +GType champlain_selection_layer_get_type (void); + +ChamplainLayer * champlain_selection_layer_new (void); + +G_END_DECLS + +#endif diff --git a/champlain/champlain.h b/champlain/champlain.h index 7f45eb6..241ff84 100644 --- a/champlain/champlain.h +++ b/champlain/champlain.h @@ -31,6 +31,7 @@ #include "champlain/champlain-defines.h" #include "champlain/champlain-cache.h" #include "champlain/champlain-layer.h" +#include "champlain/champlain-selection-layer.h" #include "champlain/champlain-base-marker.h" #include "champlain/champlain-marker.h" #include "champlain/champlain-view.h" diff --git a/demos/markers.c b/demos/markers.c index 72b8d17..c8d9006 100644 --- a/demos/markers.c +++ b/demos/markers.c @@ -39,7 +39,7 @@ create_marker_layer (ChamplainView *view) ChamplainLayer *layer; ClutterColor orange = { 0xf3, 0x94, 0x07, 0xbb }; - layer = champlain_layer_new (); + layer = champlain_selection_layer_new (); marker = champlain_marker_new_with_text ("Montréal\nQuébec", "Serif 14", NULL, NULL); -- 2.39.5