From 608c6e669e6e169b92522131768dedf4f608b4f5 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Wed, 26 Nov 2003 04:39:56 +0000 Subject: [PATCH] Only act on zoom changes (modifying canvas scale and emitting signal) if the new level is actually different. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@353 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/src/view.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/glabels2/src/view.c b/glabels2/src/view.c index 60e987b5..fe3f4dff 100644 --- a/glabels2/src/view.c +++ b/glabels2/src/view.c @@ -467,6 +467,8 @@ get_home_scale (glView *view) screen = gtk_widget_get_screen (GTK_WIDGET (view->canvas)); + gl_debug (DEBUG_VIEW, "Screen = %p", screen); + screen_width_pixels = gdk_screen_get_width (screen); screen_width_mm = gdk_screen_get_width_mm (screen); screen_height_pixels = gdk_screen_get_height (screen); @@ -3124,12 +3126,16 @@ set_zoom_real (glView *view, zoom = MAX (zoom, zooms[N_ZOOMS-1]); gl_debug (DEBUG_VIEW, "Limitted zoom: %g", zoom); - view->zoom = zoom; - view->zoom_to_fit_flag = zoom_to_fit_flag; - gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (view->canvas), - zoom*view->home_scale); + if ( zoom != view->zoom ) { - g_signal_emit (G_OBJECT(view), signals[ZOOM_CHANGED], 0, zoom); + view->zoom = zoom; + view->zoom_to_fit_flag = zoom_to_fit_flag; + gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (view->canvas), + zoom*view->home_scale); + + g_signal_emit (G_OBJECT(view), signals[ZOOM_CHANGED], 0, zoom); + + } gl_debug (DEBUG_VIEW, "END"); @@ -3142,10 +3148,14 @@ set_zoom_real (glView *view, static void size_allocate_cb (glView *view) { + gl_debug (DEBUG_VIEW, "START"); + if (view->zoom_to_fit_flag) { /* Maintain best fit zoom */ gl_view_zoom_to_fit (view); } + + gl_debug (DEBUG_VIEW, "END"); } @@ -3156,6 +3166,8 @@ size_allocate_cb (glView *view) static void screen_changed_cb (glView *view) { + gl_debug (DEBUG_VIEW, "START"); + view->home_scale = get_home_scale (view); gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (view->canvas), @@ -3165,6 +3177,8 @@ screen_changed_cb (glView *view) /* Maintain best fit zoom */ gl_view_zoom_to_fit (view); } + + gl_debug (DEBUG_VIEW, "END"); } -- 2.39.5