]> err.no Git - libchamplain/commitdiff
Register ChamplainMapSourceDesc as a G_TYPE_BOXED
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Fri, 12 Jun 2009 04:51:52 +0000 (00:51 -0400)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Fri, 12 Jun 2009 04:51:52 +0000 (00:51 -0400)
champlain/Makefile.am
champlain/champlain-map-source-desc.c [new file with mode: 0644]
champlain/champlain-map-source-desc.h
champlain/champlain-point.c

index c9922aeed4e4c6903522df88f1e54a30bc169386..70a5df0fc19d5d26d7e78e66b0f72e528ed92f1b 100644 (file)
@@ -47,6 +47,7 @@ libchamplain_0_3_la_SOURCES = \
        champlain-map-source.c          \
        champlain-network-map-source.c  \
        champlain-map-source-factory.c  \
+       champlain-map-source-desc.c     \
        champlain-point.c               \
        champlain-cache.c               \
        champlain-polygon.c
diff --git a/champlain/champlain-map-source-desc.c b/champlain/champlain-map-source-desc.c
new file mode 100644 (file)
index 0000000..cfeaeca
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2009 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
+ *
+ * This file is inspired by clutter-color.c which is
+ * Copyright (C) 2006 OpenedHand, and has the same license.
+ *
+ * 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-map-source-desc
+ * @short_description: A basic struct to describe map sources
+ */
+
+#include "champlain-map-source-desc.h"
+
+GType
+champlain_map_source_desc_get_type (void)
+{
+  static GType type = 0;
+
+  if (G_UNLIKELY (type == 0))
+    {
+      type = g_boxed_type_register_static (g_intern_static_string ("ChamplainMapSourceDesc"),
+          (GBoxedCopyFunc) champlain_map_source_desc_copy,
+          (GBoxedFreeFunc) champlain_map_source_desc_free);
+    }
+
+  return type;
+}
+
+/**
+ * champlain_map_source_desc_copy:
+ * @desc: a #ChamplainMapSourceDesc
+ *
+ * Makes a copy of the map source desc structure.  The result must be
+ * freed using champlain_map_source_desc_free().
+ *
+ * Return value: an allocated copy of @desc.
+ *
+ * Since: 0.4
+ */
+ChamplainMapSourceDesc *
+champlain_map_source_desc_copy (const ChamplainMapSourceDesc *desc)
+{
+  if (G_LIKELY (desc != NULL))
+    return g_slice_dup (ChamplainMapSourceDesc, desc);
+
+  return NULL;
+}
+
+/**
+ * champlain_map_source_desc_free:
+ * @desc: a #ChamplainMapSourceDesc
+ *
+ * Frees a desc structure created with #champlain_map_source_desc_new or
+ * #champlain_map_source_desc_copy
+ *
+ * Since: 0.4
+ */
+void
+champlain_map_source_desc_free (ChamplainMapSourceDesc *desc)
+{
+
+  if (G_UNLIKELY (desc == NULL))
+    return;
+
+  if (G_LIKELY (desc->id != NULL))
+    g_free (desc->id);
+
+  g_slice_free (ChamplainMapSourceDesc, desc);
+}
+
+/**
+ * champlain_map_source_desc_new:
+ * @lat: the latitude
+ * @lon: the longitude
+ *
+ * Return value: a newly allocated #ChamplainMapSourceDesc to be freed with #champlain_map_source_desc_free
+ *
+ * Since: 0.4
+ */
+ChamplainMapSourceDesc *
+champlain_map_source_desc_new ()
+{
+  return g_slice_new (ChamplainMapSourceDesc);
+}
index 32cf5f16b77eae8eace3e563f96eedeecee15003..949a14e0b6b885db853b4ef1268c57797a906fb4 100644 (file)
@@ -24,6 +24,7 @@
 #define CHAMPLAIN_MAP_SOURCE_DESC_H
 
 #include <glib-object.h>
+#include "champlain-map-source.h"
 
 G_BEGIN_DECLS
 
@@ -65,6 +66,15 @@ struct _ChamplainMapSourceDesc {
   gpointer data;
 };
 
+GType champlain_map_source_desc_get_type (void) G_GNUC_CONST;
+#define CHAMPLAIN_TYPE_MAP_SOURCE_DESC (champlain_map_source_desc_get_type ())
+
+ChamplainMapSourceDesc * champlain_map_source_desc_copy (const ChamplainMapSourceDesc *desc);
+
+void champlain_map_source_desc_free (ChamplainMapSourceDesc *desc);
+
+ChamplainMapSourceDesc * champlain_map_source_desc_new (void);
+
 G_END_DECLS
 
 #endif
index 4f314f07e2fa7162d6aeea88d9a59fdc003ee916..041ae967e582ca0c06c8acc0bc8e17563892db08 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
+ * Copyright (C) 2009 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
  *
  * This file is inspired by clutter-color.c which is
  * Copyright (C) 2006 OpenedHand, and has the same license.