From 5fd153d15c59f0c4e2fa97d67d88c87f5c57c271 Mon Sep 17 00:00:00 2001
From: Andrea Zagli <azagli@libero.it>
Date: Wed, 19 Aug 2009 18:15:25 +0200
Subject: [PATCH] The zoom follows the mouse.

---
 src/gtkgis.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/gtkgis.c b/src/gtkgis.c
index 8db9edd..b0cae17 100644
--- a/src/gtkgis.c
+++ b/src/gtkgis.c
@@ -1336,12 +1336,30 @@ gtk_gis_scroll_event (GtkWidget *widget,
 	GtkGis *gtkgis;
 	GtkGisScale *scale;
 
+	GtkAllocation allocation;
+
+	gdouble canvas_x;
+	gdouble canvas_y;
+
+	gdouble new_canvas_x;
+	gdouble new_canvas_y;
+
 	g_return_val_if_fail (IS_GTK_GIS (widget), FALSE);
 	g_return_val_if_fail (event != NULL, FALSE);
 
 	gtkgis = GTK_GIS (widget);
 	priv = GTK_GIS_GET_PRIVATE (gtkgis);
 
+	allocation = priv->canvas->allocation;
+
+	canvas_x = (0 - allocation.x) + event->x;
+	canvas_y = (0 - allocation.y) + event->y;
+
+	new_canvas_x = canvas_x;
+	new_canvas_y = canvas_y;
+
+	goo_canvas_convert_from_pixels (GOO_CANVAS (priv->canvas), &new_canvas_x, &new_canvas_y);
+
 	scale = gtk_gis_get_scale (gtkgis);
 
 	if (event->direction == GDK_SCROLL_UP)
@@ -1359,6 +1377,13 @@ gtk_gis_scroll_event (GtkWidget *widget,
 
 	gtk_gis_set_scale (gtkgis, scale);
 
+	/* returns to the mouse */
+	goo_canvas_convert_to_pixels (GOO_CANVAS (priv->canvas), &new_canvas_x, &new_canvas_y);
+
+	gtk_layout_move (GTK_LAYOUT (priv->scroll_win), priv->canvas,
+	                 allocation.x - (new_canvas_x - canvas_x),
+	                 allocation.y - (new_canvas_y - canvas_y));
+
 	return TRUE;
 }
 
-- 
2.49.0