+ return VIK_LAYER_TOOL_ACK;
+}
+
+static VikLayerToolFuncStatus ruler_move (VikLayer *vl, GdkEventButton *event, ruler_tool_state_t *s)
+{
+ VikViewport *vvp = s->vvp;
+ VikWindow *vw = s->vw;
+
+ struct LatLon ll;
+ VikCoord coord;
+ gchar *temp;
+
+ if ( s->has_oldcoord ) {
+ int oldx, oldy, w1, h1, w2, h2;
+ static GdkPixmap *buf = NULL;
+ w1 = vik_viewport_get_width(vvp);
+ h1 = vik_viewport_get_height(vvp);
+ if (!buf) {
+ buf = gdk_pixmap_new ( GTK_WIDGET(vvp)->window, w1, h1, -1 );
+ }
+ gdk_drawable_get_size(buf, &w2, &h2);
+ if (w1 != w2 || h1 != h2) {
+ g_object_unref ( G_OBJECT ( buf ) );
+ buf = gdk_pixmap_new ( GTK_WIDGET(vvp)->window, w1, h1, -1 );
+ }
+
+ vik_viewport_screen_to_coord ( vvp, (gint) event->x, (gint) event->y, &coord );
+ vik_coord_to_latlon ( &coord, &ll );
+ vik_viewport_coord_to_screen ( vvp, &s->oldcoord, &oldx, &oldy );
+
+ gdk_draw_drawable (buf, GTK_WIDGET(vvp)->style->black_gc,
+ vik_viewport_get_pixmap(vvp), 0, 0, 0, 0, -1, -1);
+ draw_ruler(vvp, buf, GTK_WIDGET(vvp)->style->black_gc, oldx, oldy, event->x, event->y, vik_coord_diff( &coord, &(s->oldcoord)) );
+ if (draw_buf_done) {
+ static gpointer pass_along[3];
+ pass_along[0] = GTK_WIDGET(vvp)->window;
+ pass_along[1] = GTK_WIDGET(vvp)->style->black_gc;
+ pass_along[2] = buf;
+ g_idle_add_full (G_PRIORITY_HIGH_IDLE + 10, draw_buf, pass_along, NULL);
+ draw_buf_done = FALSE;
+ }
+
+ temp = g_strdup_printf ( "%f %f DIFF %f meters", ll.lat, ll.lon, vik_coord_diff( &coord, &(s->oldcoord) ) );
+ vik_statusbar_set_message ( vw->viking_vs, 3, temp );
+ g_free ( temp );
+ }
+ return VIK_LAYER_TOOL_ACK;
+}
+
+static VikLayerToolFuncStatus ruler_release (VikLayer *vl, GdkEventButton *event, ruler_tool_state_t *s)
+{
+ return VIK_LAYER_TOOL_ACK;
+}
+
+static void ruler_deactivate (VikLayer *vl, ruler_tool_state_t *s)
+{
+ draw_update ( s->vw );
+}
+
+static VikToolInterface ruler_tool =
+ { "Ruler",
+ (VikToolConstructorFunc) ruler_create,
+ (VikToolDestructorFunc) ruler_destroy,
+ (VikToolActivationFunc) NULL,
+ (VikToolActivationFunc) ruler_deactivate,
+ (VikToolMouseFunc) ruler_click,
+ (VikToolMouseFunc) ruler_move,
+ (VikToolMouseFunc) ruler_release };
+/*** end ruler code ********************************************************/
+
+
+
+/********************************************************************************
+ ** Zoom tool code
+ ********************************************************************************/
+static gpointer zoomtool_create (VikWindow *vw, VikViewport *vvp)
+{
+ return vw;
+}
+
+static VikLayerToolFuncStatus zoomtool_click (VikLayer *vl, GdkEventButton *event, VikWindow *vw)
+{
+ vw->modified = TRUE;
+ vik_viewport_set_center_screen ( vw->viking_vvp, (gint) event->x, (gint) event->y );
+ if ( event->button == 1 )
+ vik_viewport_zoom_in (vw->viking_vvp);
+ else if ( event->button == 3 )
+ vik_viewport_zoom_out (vw->viking_vvp);
+ draw_update ( vw );
+ return VIK_LAYER_TOOL_ACK;