[libchamplain] Register ChamplainMapSourceDesc as a G_TYPE_BOXED
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: svn-commits-list gnome org
- Subject: [libchamplain] Register ChamplainMapSourceDesc as a G_TYPE_BOXED
- Date: Fri, 12 Jun 2009 01:00:33 -0400 (EDT)
commit 2762557b862b99ee4b195b99a0eec91118cf9055
Author: Pierre-Luc Beaudoin <pierre-luc pierlux com>
Date: Fri Jun 12 00:51:52 2009 -0400
Register ChamplainMapSourceDesc as a G_TYPE_BOXED
champlain/Makefile.am | 1 +
champlain/champlain-map-source-desc.c | 99 +++++++++++++++++++++++++++++++++
champlain/champlain-map-source-desc.h | 10 +++
champlain/champlain-point.c | 2 +-
4 files changed, 111 insertions(+), 1 deletions(-)
---
diff --git a/champlain/Makefile.am b/champlain/Makefile.am
index c9922ae..70a5df0 100644
--- a/champlain/Makefile.am
+++ b/champlain/Makefile.am
@@ -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
index 0000000..cfeaeca
--- /dev/null
+++ b/champlain/champlain-map-source-desc.c
@@ -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);
+}
diff --git a/champlain/champlain-map-source-desc.h b/champlain/champlain-map-source-desc.h
index 32cf5f1..949a14e 100644
--- a/champlain/champlain-map-source-desc.h
+++ b/champlain/champlain-map-source-desc.h
@@ -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
diff --git a/champlain/champlain-point.c b/champlain/champlain-point.c
index 4f314f0..041ae96 100644
--- a/champlain/champlain-point.c
+++ b/champlain/champlain-point.c
@@ -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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]