]> git.street.me.uk Git - andy/viking.git/commitdiff
Replace old-vik-map-type by vikmaptype
authorGuilhem Bonnefille <guilhem.bonnefille@gmail.com>
Wed, 4 Mar 2009 22:13:00 +0000 (23:13 +0100)
committerGuilhem Bonnefille <guilhem.bonnefille@gmail.com>
Fri, 27 Mar 2009 11:14:42 +0000 (12:14 +0100)
src/old-vik-map-type.gob [deleted file]
src/vikmapslayer_compat.c
src/vikmaptype.c [new file with mode: 0644]
src/vikmaptype.h [new file with mode: 0644]

diff --git a/src/old-vik-map-type.gob b/src/old-vik-map-type.gob
deleted file mode 100644 (file)
index dd3d947..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-%headertop{
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "vikmapsource.h"
-#include "vikmapslayer_compat.h"
-%}
-
-class Old:Vik:Map:Type from Vik:Map:Source {
-
-  private VikMapsLayer_MapType map_type;
-  public GObject *
-  new_with_id (VikMapsLayer_MapType map_type) {
-         OldVikMapType *ret = GET_NEW;
-         ret->_priv->map_type = map_type;
-         return G_OBJECT (ret);
-  }
-
-  override (Vik:Map:Source) gboolean
-  coord_to_mapcoord ( Vik:Map:Source *self, const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest )
-  {
-    return SELF(self)->_priv->map_type.coord_to_mapcoord (src, xzoom, yzoom, dest);
-  }
-
-  override (Vik:Map:Source) void
-  mapcoord_to_center_coord ( Vik:Map:Source *self, MapCoord *src, VikCoord *dest )
-  {
-    SELF(self)->_priv->map_type.mapcoord_to_center_coord (src, dest);
-  }
-
-  override (Vik:Map:Source) int
-  download ( Vik:Map:Source *self, MapCoord *src, const gchar *dest_fn )
-  {
-    return SELF(self)->_priv->map_type.download(src, dest_fn);
-  }
-
-}
-
index 050ec9aaa67122247a45510ca5d3ee5cc43c657f..a3ca7a8f13e9874938669a54bc3dd43f209dcf30 100644 (file)
 
 #include "vikmapslayer.h"
 #include "vikmapslayer_compat.h"
-#include "old-vik-map-type.h"
+#include "vikmaptype.h"
 
 void maps_layer_register_type ( const char *label, guint id, VikMapsLayer_MapType *map_type )
 {
     g_assert(id == map_type->uniq_id);
-    GObject *object = old_vik_map_type_new_with_id (*map_type);
+    VikMapType *object = vik_map_type_new_with_id (*map_type);
     maps_layer_register_map_source ( label, VIK_MAP_SOURCE (object) );
 }
diff --git a/src/vikmaptype.c b/src/vikmaptype.c
new file mode 100644 (file)
index 0000000..cf7cb3a
--- /dev/null
@@ -0,0 +1,106 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * viking
+ * Copyright (C) Guilhem Bonnefille 2009 <guilhem.bonnefille@gmail.com>
+ * 
+ * viking is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * viking 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 General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "vikmaptype.h"
+#include "vikmapslayer_compat.h"
+
+static gboolean map_type_coord_to_mapcoord (VikMapSource *self, const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest );
+static void map_type_mapcoord_to_center_coord (VikMapSource *self, MapCoord *src, VikCoord *dest);
+static int map_type_download (VikMapSource * self, MapCoord * src, const gchar * dest_fn);
+
+typedef struct _VikMapTypePrivate VikMapTypePrivate;
+struct _VikMapTypePrivate
+{
+       VikMapsLayer_MapType map_type;
+};
+
+#define VIK_MAP_TYPE_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), VIK_TYPE_MAP_TYPE, VikMapTypePrivate))
+
+
+G_DEFINE_TYPE (VikMapType, vik_map_type, VIK_TYPE_MAP_SOURCE);
+
+static void
+vik_map_type_init (VikMapType *object)
+{
+       /* TODO: Add initialization code here */
+}
+
+VikMapType *
+vik_map_type_new_with_id (VikMapsLayer_MapType map_type)
+{
+       VikMapType *ret = (VikMapType *)g_object_new(vik_map_type_get_type(), NULL);
+       VikMapTypePrivate *priv = VIK_MAP_TYPE_PRIVATE(ret);
+       priv->map_type = map_type;
+       return ret;
+}
+
+static void
+vik_map_type_finalize (GObject *object)
+{
+       /* TODO: Add deinitalization code here */
+
+       G_OBJECT_CLASS (vik_map_type_parent_class)->finalize (object);
+}
+
+static void
+vik_map_type_class_init (VikMapTypeClass *klass)
+{
+       GObjectClass* object_class = G_OBJECT_CLASS (klass);
+       VikMapSourceClass* parent_class = VIK_MAP_SOURCE_CLASS (klass);
+
+       /* Overiding methods */
+       parent_class->coord_to_mapcoord =        map_type_coord_to_mapcoord;
+       parent_class->mapcoord_to_center_coord = map_type_mapcoord_to_center_coord;
+       parent_class->download =                 map_type_download;
+
+       g_type_class_add_private (klass, sizeof (VikMapTypePrivate));
+
+       object_class->finalize = vik_map_type_finalize;
+}
+
+static gboolean
+map_type_coord_to_mapcoord (VikMapSource *self, const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest )
+{
+    VikMapTypePrivate *priv = VIK_MAP_TYPE_PRIVATE(self);
+       g_return_val_if_fail (priv != NULL, FALSE);
+
+       return (priv->map_type.coord_to_mapcoord)(src, xzoom, yzoom, dest);
+}
+
+static void
+map_type_mapcoord_to_center_coord (VikMapSource *self, MapCoord *src, VikCoord *dest)
+{
+    VikMapTypePrivate *priv = VIK_MAP_TYPE_PRIVATE(self);
+       g_return_if_fail (self != NULL);
+
+       return (priv->map_type.mapcoord_to_center_coord)(src, dest);
+}
+
+static int
+map_type_download (VikMapSource * self, MapCoord * src, const gchar * dest_fn)
+{
+    VikMapTypePrivate *priv = VIK_MAP_TYPE_PRIVATE(self);
+       g_return_val_if_fail (priv != NULL, 0);
+
+       return (priv->map_type.download)(src, dest_fn);
+}
+
diff --git a/src/vikmaptype.h b/src/vikmaptype.h
new file mode 100644 (file)
index 0000000..d236108
--- /dev/null
@@ -0,0 +1,55 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * viking
+ * Copyright (C) Guilhem Bonnefille 2009 <guilhem.bonnefille@gmail.com>
+ * 
+ * viking is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * viking 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 General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _VIK_MAP_TYPE_H_
+#define _VIK_MAP_TYPE_H_
+
+#include <glib-object.h>
+
+#include "vikmapsource.h"
+#include "vikmapslayer_compat.h"
+
+G_BEGIN_DECLS
+
+#define VIK_TYPE_MAP_TYPE             (vik_map_type_get_type ())
+#define VIK_MAP_TYPE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIK_TYPE_MAP_TYPE, VikMapType))
+#define VIK_MAP_TYPE_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), VIK_TYPE_MAP_TYPE, VikMapTypeClass))
+#define VIK_IS_MAP_TYPE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIK_TYPE_MAP_TYPE))
+#define VIK_IS_MAP_TYPE_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), VIK_TYPE_MAP_TYPE))
+#define VIK_MAP_TYPE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), VIK_TYPE_MAP_TYPE, VikMapTypeClass))
+
+typedef struct _VikMapTypeClass VikMapTypeClass;
+typedef struct _VikMapType VikMapType;
+
+struct _VikMapTypeClass
+{
+       VikMapSourceClass parent_class;
+};
+
+struct _VikMapType
+{
+       VikMapSource parent_instance;
+};
+
+GType vik_map_type_get_type (void) G_GNUC_CONST;
+VikMapType *vik_map_type_new_with_id (VikMapsLayer_MapType map_type);
+
+G_END_DECLS
+
+#endif /* _VIK_MAP_TYPE_H_ */