From 1f137406c3c09ff8206d8357a619d282725fa96f Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 14 Apr 2005 13:01:34 +0000 Subject: [PATCH] don't call gimp_display_shell_scale() if the display isn't completely 2005-04-14 Sven Neumann * app/display/gimpdisplayshell.c (gimp_display_shell_set_property): don't call gimp_display_shell_scale() if the display isn't completely setup yet. * app/display/gimpdisplayshell-scale.c (gimp_display_shell_scale): hack around to find out whether we should pass the pointer location or the center of the display to gimp_display_shell_scale_to(). --- ChangeLog | 10 ++++++++++ app/display/gimpdisplayshell-scale.c | 17 ++++++++++++----- app/display/gimpdisplayshell.c | 7 +++++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index e07d781e0a..11fad89a43 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-04-14 Sven Neumann + + * app/display/gimpdisplayshell.c (gimp_display_shell_set_property): + don't call gimp_display_shell_scale() if the display isn't + completely setup yet. + + * app/display/gimpdisplayshell-scale.c (gimp_display_shell_scale): + hack around to find out whether we should pass the pointer location + or the center of the display to gimp_display_shell_scale_to(). + 2005-04-14 Sven Neumann * app/display/gimpdisplayshell-scale.c (gimp_display_shell_scale): diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c index 3b79cc853d..6e7e8b8701 100644 --- a/app/display/gimpdisplayshell-scale.c +++ b/app/display/gimpdisplayshell-scale.c @@ -359,23 +359,30 @@ gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *shell, * @zoom_type: whether to zoom in, our or to a specific scale * @scale: ignored unless @zoom_type == %GIMP_ZOOM_TO * - * This function calls gimp_display_shell_scale_to() using the - * position of the mouse pointer as coordinates. + * This function calls gimp_display_shell_scale_to(). It tries to be + * smart whether to use the position of the mouse pointer or the + * center of the display as coordinates.+ **/ void gimp_display_shell_scale (GimpDisplayShell *shell, GimpZoomType zoom_type, gdouble new_scale) { - gint x, y; + GdkEvent *event; + gint x, y; g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + g_return_if_fail (shell->canvas != NULL); x = shell->disp_width / 2; y = shell->disp_height / 2; - if (shell->canvas) - gtk_widget_get_pointer (GTK_WIDGET (shell->canvas), &x, &y); + event = gtk_get_current_event (); + + if (! event || gtk_get_event_widget (event) == GTK_WIDGET (shell)) + { + gtk_widget_get_pointer (shell->canvas, &x, &y); + } gimp_display_shell_scale_to (shell, zoom_type, new_scale, x, y); } diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index b14216f88c..b2377186b1 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -431,8 +431,11 @@ gimp_display_shell_set_property (GObject *object, switch (property_id) { case PROP_SCALE: - gimp_display_shell_scale (shell, - GIMP_ZOOM_TO, g_value_get_double (value)); + if (shell->canvas) + gimp_display_shell_scale (shell, + GIMP_ZOOM_TO, g_value_get_double (value)); + else + shell->scale = g_value_get_double (value); break; case PROP_UNIT: gimp_display_shell_set_unit (shell, g_value_get_int (value));