From 25d14ad53a028feac7e2a39a364a031dabb62bd0 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Tue, 8 Oct 2002 03:24:53 +0000 Subject: [PATCH] Added cursor position to status bar. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@151 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/src/window.c | 47 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/glabels2/src/window.c b/glabels2/src/window.c index 35c25332..8d5a5b7c 100644 --- a/glabels2/src/window.c +++ b/glabels2/src/window.c @@ -26,6 +26,7 @@ #include "window.h" #include "util.h" #include "xml-label.h" +#include "prefs.h" #include "debug.h" @@ -66,9 +67,14 @@ static gboolean window_delete_event_cb (glWindow *window, static void selection_changed_cb (glView *view, glWindow *window); -static void zoom_changed_cb (glView *view, - gdouble zoom, - glWindow *window); +static void zoom_changed_cb (glView *view, + gdouble zoom, + glWindow *window); + +static void pointer_moved_cb (glView *view, + gdouble x, + gdouble y, + glWindow *window); static void name_changed_cb (glLabel *label, glWindow *window); @@ -331,6 +337,9 @@ gl_window_set_label (glWindow *window, g_signal_connect (G_OBJECT(window->view), "zoom_changed", G_CALLBACK(zoom_changed_cb), window); + g_signal_connect (G_OBJECT(window->view), "pointer_moved", + G_CALLBACK(pointer_moved_cb), window); + g_signal_connect (G_OBJECT(label), "name_changed", G_CALLBACK(name_changed_cb), window); @@ -423,7 +432,7 @@ selection_changed_cb (glView *view, /*---------------------------------------------------------------------------*/ static void zoom_changed_cb (glView *view, - gdouble zoom, + gdouble zoom, glWindow *window) { gchar *string; @@ -440,6 +449,36 @@ zoom_changed_cb (glView *view, gl_debug (DEBUG_WINDOW, "END"); } +/*---------------------------------------------------------------------------*/ +/* PRIVATE. View "pointer moved" callback. */ +/*---------------------------------------------------------------------------*/ +static void +pointer_moved_cb (glView *view, + gdouble x, + gdouble y, + glWindow *window) +{ + gchar *string; + gdouble units_per_point; + gint units_precision; + + gl_debug (DEBUG_WINDOW, "START"); + + g_return_if_fail (view && GL_IS_VIEW (view)); + g_return_if_fail (window && GL_IS_WINDOW (window)); + + units_per_point = gl_prefs_get_units_per_point (); + units_precision = gl_prefs_get_units_precision (); + + string = g_strdup_printf ("%.*f, %.*f", + units_precision, x*units_per_point, + units_precision, y*units_per_point); + gtk_label_set_text (GTK_LABEL(window->cursor_info), string); + g_free (string); + + gl_debug (DEBUG_WINDOW, "END"); +} + /*---------------------------------------------------------------------------*/ /* PRIVATE. Label "name changed" callback. */ /*---------------------------------------------------------------------------*/ -- 2.39.5