X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/71cea316bc59b175f891ae7eff259742e013563e..ae341715def192766a721bc47d8f3987a89bda10:/src/vikmaptype.c diff --git a/src/vikmaptype.c b/src/vikmaptype.c index 63a3a774..8e30b315 100644 --- a/src/vikmaptype.c +++ b/src/vikmaptype.c @@ -1,7 +1,7 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * viking - * Copyright (C) Guilhem Bonnefille 2009 + * Copyright (C) 2009, Guilhem Bonnefille * * 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 @@ -16,6 +16,15 @@ * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ + + /** + * SECTION:vikmaptype + * @short_description: the adapter class to support old map source declaration + * + * The #VikMapType class handles is an adapter to allow to reuse + * old map source (see #VikMapsLayer_MapType). + */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -30,7 +39,9 @@ static guint16 map_type_get_tilesize_y (VikMapSource *self); static VikViewportDrawMode map_type_get_drawmode (VikMapSource *self); 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); +static int map_type_download (VikMapSource * self, MapCoord * src, const gchar * dest_fn, void * handle); +static void * map_type_download_handle_init (VikMapSource * self); +static void map_type_download_handle_cleanup (VikMapSource * self, void * handle); typedef struct _VikMapTypePrivate VikMapTypePrivate; struct _VikMapTypePrivate @@ -86,6 +97,8 @@ vik_map_type_class_init (VikMapTypeClass *klass) 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; + parent_class->download_handle_init = map_type_download_handle_init; + parent_class->download_handle_cleanup = map_type_download_handle_cleanup; g_type_class_add_private (klass, sizeof (VikMapTypePrivate)); @@ -152,15 +165,33 @@ map_type_mapcoord_to_center_coord (VikMapSource *self, MapCoord *src, VikCoord * VikMapTypePrivate *priv = VIK_MAP_TYPE_PRIVATE(self); g_return_if_fail (self != NULL); - return (priv->map_type.mapcoord_to_center_coord)(src, dest); + (priv->map_type.mapcoord_to_center_coord)(src, dest); } static int -map_type_download (VikMapSource * self, MapCoord * src, const gchar * dest_fn) +map_type_download (VikMapSource * self, MapCoord * src, const gchar * dest_fn, void * handle) +{ + VikMapTypePrivate *priv = VIK_MAP_TYPE_PRIVATE(self); + g_return_val_if_fail (priv != NULL, 0); + + return (priv->map_type.download)(src, dest_fn, handle); +} + +static void * +map_type_download_handle_init (VikMapSource * self) { VikMapTypePrivate *priv = VIK_MAP_TYPE_PRIVATE(self); g_return_val_if_fail (priv != NULL, 0); - return (priv->map_type.download)(src, dest_fn); + return (priv->map_type.download_handle_init)(); +} + +static void +map_type_download_handle_cleanup (VikMapSource * self, void * handle) +{ + VikMapTypePrivate *priv = VIK_MAP_TYPE_PRIVATE(self); + g_return_if_fail ( priv != NULL ); + + (priv->map_type.download_handle_cleanup)(handle); }