]> err.no Git - libchamplain/commitdiff
Create ChamplainSelectionLayer
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Sun, 5 Jul 2009 19:10:12 +0000 (20:10 +0100)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Tue, 28 Jul 2009 21:23:16 +0000 (17:23 -0400)
champlain/Makefile.am
champlain/champlain-selection-layer.c [new file with mode: 0644]
champlain/champlain-selection-layer.h [new file with mode: 0644]
champlain/champlain.h
demos/markers.c

index e81a29e5f74ec8ac581aa171d5b3808a3a02f4e1..330807c67aa6dd994733df4d28c0584249b5b2a6 100644 (file)
@@ -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 (file)
index 0000000..5e52209
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2009 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
+ *
+ * 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 <clutter/clutter.h>
+#include <glib.h>
+
+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 (file)
index 0000000..f8938fb
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2009 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
+ *
+ * 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 <champlain/champlain.h> can be included directly."
+#endif
+
+#ifndef CHAMPLAIN_SELECTION_LAYER_H
+#define CHAMPLAIN_SELECTION_LAYER_H
+
+#include <champlain/champlain-defines.h>
+#include <champlain/champlain-layer.h>
+
+#include <glib-object.h>
+#include <clutter/clutter.h>
+
+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
index 7f45eb6497d48446331fa2771b1ea75ef49189ea..241ff84b3ce85423578513fffa417193198534dd 100644 (file)
@@ -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"
index 72b8d17c9faa5c1b5a1b873ba7409f8465df3b00..c8d90060dde8d42ab0ab7049274f3494a4c5f1a4 100644 (file)
@@ -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\n<span size=\"xx-small\">Québec</span>",
       "Serif 14", NULL, NULL);