Fixed error Private struct size == 0.
authorAndrea Zagli <azagli@libero.it>
Sun, 28 Jun 2009 17:47:51 +0000 (19:47 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 28 Jun 2009 17:47:51 +0000 (19:47 +0200)
13 files changed:
src/geometry.c
src/geometryline.c
src/geometrypoint.c
src/geometrypolygon.c
src/geometrypolygon.h
src/geometryraster.c
src/layer.c
src/layer.h
src/layersgroup.c
src/layersource.c
src/layersourcepostgis.c
src/layersourceshp.c
tests/test1.gtkgis

index b0bd855da204a0626548f071e559846ac2cfc0e9..78a3f0eec5860c4d83428be8ea28784e388cefad 100644 (file)
@@ -40,47 +40,21 @@ static void gtk_gis_geometry_get_property (GObject *object,
                                      GParamSpec *pspec);
 
 
-#define GTK_GIS_GEOMETRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_GIS_GEOMETRY, GtkGisGeometryPrivate))
+/*#define GTK_GIS_GEOMETRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_GIS_GEOMETRY, GtkGisGeometryPrivate))
 
 typedef struct _GtkGisGeometryPrivate GtkGisGeometryPrivate;
 struct _GtkGisGeometryPrivate
        {
-       };
+       };*/
 
-GType
-gtk_gis_geometry_get_type (void)
-{
-       static GType gtk_gis_geometry_type = 0;
-
-       if (!gtk_gis_geometry_type)
-               {
-                       static const GTypeInfo gtk_gis_geometry_info =
-                       {
-                               sizeof (GtkGisGeometryClass),
-                               NULL,   /* base_init */
-                               NULL,   /* base_finalize */
-                               (GClassInitFunc) gtk_gis_geometry_class_init,
-                               NULL,   /* class_finalize */
-                               NULL,   /* class_data */
-                               sizeof (GtkGisGeometry),
-                               0,      /* n_preallocs */
-                               (GInstanceInitFunc) gtk_gis_geometry_init,
-                               NULL
-                       };
-
-                       gtk_gis_geometry_type = g_type_register_static (G_TYPE_OBJECT, "GtkGisGeometry",
-                                                                 &gtk_gis_geometry_info, 0);
-               }
-
-       return gtk_gis_geometry_type;
-}
+G_DEFINE_TYPE (GtkGisGeometry, gtk_gis_geometry, G_TYPE_OBJECT)
 
 static void
 gtk_gis_geometry_class_init (GtkGisGeometryClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-       g_type_class_add_private (object_class, sizeof (GtkGisGeometryPrivate));
+       /*g_type_class_add_private (object_class, sizeof (GtkGisGeometryPrivate));*/
 
        object_class->set_property = gtk_gis_geometry_set_property;
        object_class->get_property = gtk_gis_geometry_get_property;
@@ -89,7 +63,7 @@ gtk_gis_geometry_class_init (GtkGisGeometryClass *klass)
 static void
 gtk_gis_geometry_init (GtkGisGeometry *gtk_gis_geometry)
 {
-       GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (gtk_gis_geometry);
+       /*GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (gtk_gis_geometry);*/
 }
 
 static void
@@ -97,7 +71,7 @@ gtk_gis_geometry_set_property (GObject *object, guint property_id, const GValue
 {
        GtkGisGeometry *gtk_gis_geometry = GTK_GIS_GEOMETRY (object);
 
-       GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (gtk_gis_geometry);
+       /*GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (gtk_gis_geometry);*/
 
        switch (property_id)
                {
@@ -112,7 +86,7 @@ gtk_gis_geometry_get_property (GObject *object, guint property_id, GValue *value
 {
        GtkGisGeometry *gtk_gis_geometry = GTK_GIS_GEOMETRY (object);
 
-       GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (gtk_gis_geometry);
+       /*GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (gtk_gis_geometry);*/
 
        switch (property_id)
                {
index 11fdebafb07fb613f62d341ab71952d19cca1346..c2cd977702bc69556a69af5f6bf0a2dfdeceef8b 100644 (file)
@@ -79,11 +79,11 @@ gtk_gis_geometry_line_init (GtkGisGeometryLine *gtk_gis_geometry_line)
 GtkGisGeometry
 *gtk_gis_geometry_line_new ()
 {
-       GtkGisGeometry *gtk_gis_geometry_line;
+       GtkGisGeometry *line;
 
-       gtk_gis_geometry_line = g_object_new (gtk_gis_geometry_line_get_type (), NULL);
+       line = g_object_new (gtk_gis_geometry_line_get_type (), NULL);
 
-       return gtk_gis_geometry_line;
+       return line;
 }
 
 /**
@@ -97,7 +97,7 @@ GtkGisGeometry
 GtkGisGeometry
 *gtk_gis_geometry_line_new_from_array (GPtrArray *points)
 {
-       GtkGisGeometry *line;
+       GtkGisGeometry *line = NULL;
        GtkGisGeometryLinePrivate *priv;
 
        line = gtk_gis_geometry_line_new ();
index f35226749cbbd5b3a078f2dfd7e1450fe46df85e..8647b296ddb20fcfcca1d7d85d12d4e73dfd1e15 100644 (file)
@@ -48,33 +48,7 @@ struct _GtkGisGeometryPointPrivate
                GtkGisPoint point;
        };
 
-GType
-gtk_gis_geometry_point_get_type (void)
-{
-       static GType gtk_gis_geometry_point_type = 0;
-
-       if (!gtk_gis_geometry_point_type)
-               {
-                       static const GTypeInfo gtk_gis_geometry_point_info =
-                       {
-                               sizeof (GtkGisGeometryPointClass),
-                               NULL,   /* base_init */
-                               NULL,   /* base_finalize */
-                               (GClassInitFunc) gtk_gis_geometry_point_class_init,
-                               NULL,   /* class_finalize */
-                               NULL,   /* class_data */
-                               sizeof (GtkGisGeometryPoint),
-                               0,      /* n_preallocs */
-                               (GInstanceInitFunc) gtk_gis_geometry_point_init,
-                               NULL
-                       };
-
-                       gtk_gis_geometry_point_type = g_type_register_static (TYPE_GTK_GIS_GEOMETRY, "GtkGisGeometryPoint",
-                                                                 &gtk_gis_geometry_point_info, 0);
-               }
-
-       return gtk_gis_geometry_point_type;
-}
+G_DEFINE_TYPE (GtkGisGeometryPoint, gtk_gis_geometry_point, TYPE_GTK_GIS_GEOMETRY)
 
 static void
 gtk_gis_geometry_point_class_init (GtkGisGeometryPointClass *klass)
index 6d79aa85c1c70bdbce8fbd387ed54fa51d7912c5..01bc588cb878c1e6a928a01607d69a548f720d0f 100644 (file)
@@ -115,12 +115,16 @@ GtkGisGeometry
 GtkGisGeometry
 *gtk_gis_geometry_polygon_new_from_array (GPtrArray *points)
 {
-       GtkGisGeometry *polygon;
-       GtkGisGeometry *line;
+       GtkGisGeometry *polygon = NULL;
+       GtkGisGeometry *line = NULL;
 
        line = gtk_gis_geometry_line_new_from_array (points);
 
-       gtk_gis_geometry_polygon_add_line (GTK_GIS_GEOMETRY_POLYGON (polygon), GTK_GIS_GEOMETRY_LINE (line));
+       if (line != NULL)
+               {
+                       polygon = gtk_gis_geometry_polygon_new ();
+                       gtk_gis_geometry_polygon_add_line (GTK_GIS_GEOMETRY_POLYGON (polygon), GTK_GIS_GEOMETRY_LINE (line));
+               }
 
        return polygon;
 }
index a1ecbd84e66bb2425f6bfd806652f4477083cebf..0b6e008c94fc0e7ae4b295170c212b683be3b393 100644 (file)
@@ -20,7 +20,6 @@
 #ifndef __GTK_GIS_GEOMETRY_POLYGON_H__
 #define __GTK_GIS_GEOMETRY_POLYGON_H__
 
-#include "geometry.h"
 #include "geometryline.h"
 
 G_BEGIN_DECLS
index 9979a0c075b8e3c1da5d05c2219bd14616b28811..9d52f9d077d141a6092e4b43d8628354f4ede873 100644 (file)
@@ -47,33 +47,7 @@ struct _GtkGisGeometryRasterPrivate
        {
        };
 
-GType
-gtk_gis_geometry_raster_get_type (void)
-{
-       static GType gtk_gis_geometry_raster_type = 0;
-
-       if (!gtk_gis_geometry_raster_type)
-               {
-                       static const GTypeInfo gtk_gis_geometry_raster_info =
-                       {
-                               sizeof (GtkGisGeometryRasterClass),
-                               NULL,   /* base_init */
-                               NULL,   /* base_finalize */
-                               (GClassInitFunc) gtk_gis_geometry_raster_class_init,
-                               NULL,   /* class_finalize */
-                               NULL,   /* class_data */
-                               sizeof (GtkGisGeometryRaster),
-                               0,      /* n_preallocs */
-                               (GInstanceInitFunc) gtk_gis_geometry_raster_init,
-                               NULL
-                       };
-
-                       gtk_gis_geometry_raster_type = g_type_register_static (TYPE_GTK_GIS_GEOMETRY, "GtkGisGeometryRaster",
-                                                                 &gtk_gis_geometry_raster_info, 0);
-               }
-
-       return gtk_gis_geometry_raster_type;
-}
+G_DEFINE_TYPE (GtkGisGeometryRaster, gtk_gis_geometry_raster, TYPE_GTK_GIS_GEOMETRY)
 
 static void
 gtk_gis_geometry_raster_class_init (GtkGisGeometryRasterClass *klass)
index 9f7b42dde411977578a6d256e7c16843283c0cd1..66c88f8f532a6bccefa1ac17980b366b6d7771bf 100644 (file)
@@ -56,33 +56,7 @@ struct _GtkGisLayerPrivate
                gboolean editable;
        };
 
-GType
-gtk_gis_layer_get_type (void)
-{
-       static GType gtk_gis_layer_type = 0;
-
-       if (!gtk_gis_layer_type)
-               {
-                       static const GTypeInfo gtk_gis_layer_info =
-                       {
-                               sizeof (GtkGisLayerClass),
-                               NULL,   /* base_init */
-                               NULL,   /* base_finalize */
-                               (GClassInitFunc) gtk_gis_layer_class_init,
-                               NULL,   /* class_finalize */
-                               NULL,   /* class_data */
-                               sizeof (GtkGisLayer),
-                               0,      /* n_preallocs */
-                               (GInstanceInitFunc) gtk_gis_layer_init,
-                               NULL
-                       };
-
-                       gtk_gis_layer_type = g_type_register_static (G_TYPE_OBJECT, "GtkGisLayer",
-                                                                 &gtk_gis_layer_info, 0);
-               }
-
-       return gtk_gis_layer_type;
-}
+G_DEFINE_TYPE (GtkGisLayer, gtk_gis_layer, G_TYPE_OBJECT)
 
 static void
 gtk_gis_layer_class_init (GtkGisLayerClass *klass)
@@ -113,7 +87,7 @@ gtk_gis_layer_init (GtkGisLayer *gtk_gis_layer)
  */
 GtkGisLayer
 *gtk_gis_layer_new (GtkGisLayerSource *source,
-                    gchar *name,
+                    const gchar *name,
                     GtkGisLayerGeometryType geometry_type)
 {
        GtkGisLayer *gtk_gis_layer;
@@ -143,17 +117,20 @@ GtkGisLayer
  */
 GtkGisLayer
 *gtk_gis_layer_new_from_source (GtkGisLayerSource *source,
-                                gchar *name)
+                                const gchar *name)
 {
-       GtkGisLayer *layer;
+       GtkGisLayer *layer = NULL;
 
-       GtkGisLayerGeometryType type;
+       GtkGisLayerGeometryType type = -1;
 
        type = gtk_gis_layer_source_get_layer_geometry_type (source, name);
 
-       layer = gtk_gis_layer_new (source, name, type);
+       if (type >= 0)
+               {
+                       layer = gtk_gis_layer_new (source, name, type);
 
-       gtk_gis_layer_fill_from_source (layer);
+                       gtk_gis_layer_fill_from_source (layer);
+               }
 
        return layer;
 }
index 5e9f3f684a6e14a62122412080a109689bbd5425..a89b7c4fcb908c8268f24626d713b9f66dde2220 100644 (file)
@@ -56,11 +56,11 @@ GType gtk_gis_layer_get_type (void) G_GNUC_CONST;
 
 
 GtkGisLayer *gtk_gis_layer_new (GtkGisLayerSource *source,
-                                gchar *name,
+                                const gchar *name,
                                 GtkGisLayerGeometryType geometry_type);
 
 GtkGisLayer *gtk_gis_layer_new_from_source (GtkGisLayerSource *source,
-                                            gchar *name);
+                                            const gchar *name);
 
 gchar *gtk_gis_layer_get_name (GtkGisLayer *layer);
 
index 1a4b236dfc756dfef7036f5b4d14083476c884a3..bc9ba505da0ec54ee572c92ba79660065f81cb4c 100644 (file)
@@ -47,33 +47,7 @@ struct _GtkGisLayersGroupPrivate
                GList *layers;
        };
 
-GType
-gtk_gis_layers_group_get_type (void)
-{
-       static GType gtk_gis_layers_group_type = 0;
-
-       if (!gtk_gis_layers_group_type)
-               {
-                       static const GTypeInfo gtk_gis_layers_group_info =
-                       {
-                               sizeof (GtkGisLayersGroupClass),
-                               NULL,   /* base_init */
-                               NULL,   /* base_finalize */
-                               (GClassInitFunc) gtk_gis_layers_group_class_init,
-                               NULL,   /* class_finalize */
-                               NULL,   /* class_data */
-                               sizeof (GtkGisLayersGroup),
-                               0,      /* n_preallocs */
-                               (GInstanceInitFunc) gtk_gis_layers_group_init,
-                               NULL
-                       };
-
-                       gtk_gis_layers_group_type = g_type_register_static (G_TYPE_OBJECT, "GtkGisLayersGroup",
-                                                                 &gtk_gis_layers_group_info, 0);
-               }
-
-       return gtk_gis_layers_group_type;
-}
+G_DEFINE_TYPE (GtkGisLayersGroup, gtk_gis_layers_group, G_TYPE_OBJECT)
 
 static void
 gtk_gis_layers_group_class_init (GtkGisLayersGroupClass *klass)
index 91a88abc0d433cd617cb5531a7670f0e3794f3d5..b40d53cefcf011193c8432442f66c59b98715c41 100644 (file)
 #include <ogr_core.h>
 
 #include "layersource.h"
+#include "geometry.h"
 #include "geometryline.h"
 #include "geometrypoint.h"
 #include "geometrypolygon.h"
+#include "geometryraster.h"
 
 static void gtk_gis_layer_source_class_init (GtkGisLayerSourceClass *klass);
 static void gtk_gis_layer_source_init (GtkGisLayerSource *gtk_gis_layer_source);
@@ -76,7 +78,7 @@ gtk_gis_layer_source_init (GtkGisLayerSource *gtk_gis_layer_source)
 
 static void
 gtk_gis_layer_source_set_ogr_datasource (GtkGisLayerSource *source,
-                                          OGRDataSourceH datasource)
+                                         OGRDataSourceH datasource)
 {
        GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
 
@@ -91,7 +93,7 @@ gtk_gis_layer_source_set_ogr_datasource (GtkGisLayerSource *source,
  *
  * Loads the #GtkGisLayerSource from the disk.
  *
- * Returns: .
+ * Returns: a #GList of #GtkGeometry objects.
  */
 GList
 *gtk_gis_layer_source_get_geometries (GtkGisLayerSource *source,
@@ -168,7 +170,6 @@ GList
 
                                                        for (i_geometry = 0; i_geometry < num_geometries; i_geometry++)
                                                                {
-
                                                                        gint points;
                                                                        gint point;
                                                                        GPtrArray *gar_points;
index b0ce11301ab44175b64a125a8bc56dc5cd612ac6..398b467cfba4d29ae4a9763883e8bf4d8f6d4a34 100644 (file)
@@ -46,33 +46,7 @@ struct _GtkGisLayerSourcePostgisPrivate
                gchar *password;
        };
 
-GType
-gtk_gis_layer_source_postgis_get_type (void)
-{
-       static GType gtk_gis_layer_source_postgis_type = 0;
-
-       if (!gtk_gis_layer_source_postgis_type)
-               {
-                       static const GTypeInfo gtk_gis_layer_source_postgis_info =
-                       {
-                               sizeof (GtkGisLayerSourcePostgisClass),
-                               NULL,   /* base_init */
-                               NULL,   /* base_finalize */
-                               (GClassInitFunc) gtk_gis_layer_source_postgis_class_init,
-                               NULL,   /* class_finalize */
-                               NULL,   /* class_data */
-                               sizeof (GtkGisLayerSourcePostgis),
-                               0,      /* n_preallocs */
-                               (GInstanceInitFunc) gtk_gis_layer_source_postgis_init,
-                               NULL
-                       };
-
-                       gtk_gis_layer_source_postgis_type = g_type_register_static (TYPE_GTK_GIS_LAYER_SOURCE, "GtkGisLayerSourcePostgis",
-                                                                 &gtk_gis_layer_source_postgis_info, 0);
-               }
-
-       return gtk_gis_layer_source_postgis_type;
-}
+G_DEFINE_TYPE (GtkGisLayerSourcePostgis, gtk_gis_layer_source_postgis, TYPE_GTK_GIS_LAYER_SOURCE)
 
 static void
 gtk_gis_layer_source_postgis_class_init (GtkGisLayerSourcePostgisClass *klass)
index 5132a51488da463e7a769bbf5fe64e698212424f..127f692f1cfd66154e8f0a4cbe7a756e1c001556 100644 (file)
@@ -50,33 +50,7 @@ struct _GtkGisLayerSourceShpPrivate
                gchar *filename;
        };
 
-GType
-gtk_gis_layer_source_shp_get_type (void)
-{
-       static GType gtk_gis_layer_source_shp_type = 0;
-
-       if (!gtk_gis_layer_source_shp_type)
-               {
-                       static const GTypeInfo gtk_gis_layer_source_shp_info =
-                       {
-                               sizeof (GtkGisLayerSourceShpClass),
-                               NULL,   /* base_init */
-                               NULL,   /* base_finalize */
-                               (GClassInitFunc) gtk_gis_layer_source_shp_class_init,
-                               NULL,   /* class_finalize */
-                               NULL,   /* class_data */
-                               sizeof (GtkGisLayerSourceShp),
-                               0,      /* n_preallocs */
-                               (GInstanceInitFunc) gtk_gis_layer_source_shp_init,
-                               NULL
-                       };
-
-                       gtk_gis_layer_source_shp_type = g_type_register_static (TYPE_GTK_GIS_LAYER_SOURCE, "GtkGisLayerSourceShp",
-                                                                 &gtk_gis_layer_source_shp_info, 0);
-               }
-
-       return gtk_gis_layer_source_shp_type;
-}
+G_DEFINE_TYPE (GtkGisLayerSourceShp, gtk_gis_layer_source_shp, TYPE_GTK_GIS_LAYER_SOURCE)
 
 static void
 gtk_gis_layer_source_shp_class_init (GtkGisLayerSourceShpClass *klass)
index bf96191aaca97617f73d274dc19df96508c2c39c..eb25c76cefa417502ed458f35418863d94cf45c2 100644 (file)
@@ -8,19 +8,19 @@
 
        <!--<layer name="airports">
                <source>
-                       <shape filename="samples/airports.shp" />
+                       <shape filename="/home/andreaz/files/c/libgtkgis/tests/samples/airports.shp" />
                </source>
        </layer>
 
        <layer name="railroads">
                <source>
-                       <shape filename="samples/railroads.shp" />
+                       <shape filename="/home/andreaz/files/c/libgtkgis/tests/samples/railroads.shp" />
                </source>
        </layer>
 
        <layer name="rivers">
                <source>
-                       <shape filename="samples/rivers.shp" />
+                       <shape filename="/home/andreaz/files/c/libgtkgis/tests/samples/rivers.shp" />
                </source>
        </layer>-->