]> git.sur5r.net Git - glabels/commitdiff
Added cursor position to status bar.
authorJim Evins <evins@snaught.com>
Tue, 8 Oct 2002 03:24:53 +0000 (03:24 +0000)
committerJim Evins <evins@snaught.com>
Tue, 8 Oct 2002 03:24:53 +0000 (03:24 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@151 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/window.c

index 35c2533217ef45383537294cc04255ef4f2787c3..8d5a5b7c23a30155a791928865e742791209d5a4 100644 (file)
@@ -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.                                  */
 /*---------------------------------------------------------------------------*/