From: Pierre-Luc Beaudoin Date: Fri, 12 Jun 2009 04:51:52 +0000 (-0400) Subject: Register ChamplainMapSourceDesc as a G_TYPE_BOXED X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2762557b862b99ee4b195b99a0eec91118cf9055;p=libchamplain Register ChamplainMapSourceDesc as a G_TYPE_BOXED --- 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 + * + * 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 +#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 + * Copyright (C) 2009 Pierre-Luc Beaudoin * * This file is inspired by clutter-color.c which is * Copyright (C) 2006 OpenedHand, and has the same license.