static void gtk_gis_class_init (GtkGisClass *klass);
static void gtk_gis_init (GtkGis *gtk_gis);
+static void gtk_gis_destroy (GtkObject *object);
+
static void gtk_gis_add (GtkContainer *container,
GtkWidget *widget);
GValue *value,
GParamSpec *pspec);
+static void gtk_gis_size_request (GtkWidget *widget,
+ GtkRequisition *requisition);
+static void gtk_gis_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
+
#define GTK_GIS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_GIS, GtkGisPrivate))
GtkWidget *canvas;
GooCanvasItem *canvas_root;
- GList *layer_groups;
+ GList *layers_groups;
GList *layers;
GtkGisLayerExtent extent;
static void
gtk_gis_class_init (GtkGisClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkObjectClass *object_class = (GtkObjectClass*) klass;
GtkWidgetClass *widget_class = (GtkWidgetClass*) klass;
GtkContainerClass *container_class = (GtkContainerClass*) klass;
g_type_class_add_private (object_class, sizeof (GtkGisPrivate));
- object_class->set_property = gtk_gis_set_property;
- object_class->get_property = gtk_gis_get_property;
+ gobject_class->set_property = gtk_gis_set_property;
+ gobject_class->get_property = gtk_gis_get_property;
+
+ object_class->destroy = gtk_gis_destroy;
+
+ widget_class->size_request = gtk_gis_size_request;
+ widget_class->size_allocate = gtk_gis_size_allocate;
container_class->add = gtk_gis_add;
}
priv->layers = g_list_remove (priv->layers, layer);
}
+static void
+gtk_gis_destroy (GtkObject *object)
+{
+ GtkGis *gtkgis = GTK_GIS (object);
+ GtkGisPrivate *priv = GTK_GIS_GET_PRIVATE (gtkgis);
+
+ /* TO DO */
+ /* free each layers_groups before */
+ g_list_free (priv->layers_groups);
+
+ /* TO DO */
+ /* free each layers before */
+ g_list_free (priv->layers);
+
+ GTK_OBJECT_CLASS (gtk_gis_parent_class)->destroy (object);
+}
+
static void
gtk_gis_add (GtkContainer *container,
GtkWidget *child)
break;
}
}
+
+static void
+gtk_gis_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ GtkGis *gtkgis;
+ GtkBin *bin;
+ GtkRequisition child_requisition;
+
+ g_return_if_fail (IS_GTK_GIS (widget));
+ g_return_if_fail (requisition != NULL);
+
+ gtkgis = GTK_GIS (widget);
+ bin = GTK_BIN (gtkgis);
+
+ requisition->width = 0;
+ requisition->height = 0;
+
+ if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
+ {
+ gtk_widget_size_request (bin->child, &child_requisition);
+ requisition->width += child_requisition.width;
+ requisition->height += child_requisition.height;
+ }
+
+ requisition->width += GTK_CONTAINER (widget)->border_width * 2;
+ requisition->height += GTK_CONTAINER (widget)->border_width * 2;
+}
+
+static void
+gtk_gis_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GtkGis *gtkgis;
+ GtkGisPrivate *priv;
+ GtkBin *bin;
+ GtkAllocation relative_allocation;
+ GtkAllocation child_allocation;
+
+ g_return_if_fail (IS_GTK_GIS (widget));
+ g_return_if_fail (allocation != NULL);
+
+ gtkgis = GTK_GIS (widget);
+ bin = GTK_BIN (gtkgis);
+
+ priv = GTK_GIS_GET_PRIVATE (gtkgis);
+
+ widget->allocation = *allocation;
+
+ relative_allocation.x = GTK_CONTAINER (widget)->border_width;
+ relative_allocation.y = GTK_CONTAINER (widget)->border_width;
+ relative_allocation.width = MAX (1, (gint)widget->allocation.width - relative_allocation.x * 2);
+ relative_allocation.height = MAX (1, (gint)widget->allocation.height - relative_allocation.y * 2);
+
+ if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
+ {
+ child_allocation.x = relative_allocation.x + allocation->x;
+ child_allocation.y = relative_allocation.y + allocation->y;
+ child_allocation.width = relative_allocation.width;
+ child_allocation.height = relative_allocation.height;
+
+ gtk_widget_size_allocate (bin->child, &child_allocation);
+ }
+}
+