gimp r26529 - in trunk: . app/display
- From: martinn svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26529 - in trunk: . app/display
- Date: Wed, 13 Aug 2008 17:36:29 +0000 (UTC)
Author: martinn
Date: Wed Aug 13 17:36:29 2008
New Revision: 26529
URL: http://svn.gnome.org/viewvc/gimp?rev=26529&view=rev
Log:
2008-08-13 Martin Nordholts <martinn svn gnome org>
* app/display/gimpdisplayshell-scale.c
(gimp_display_shell_scale_image_is_within_viewport): New function.
* app/display/gimpdisplayshell.c (gimp_display_shell_new): When
the zoom button is toggled, implicitly do a View -> Fit Image in
Window if the (scaled) image is within the viewport.
Modified:
trunk/ChangeLog
trunk/app/display/gimpdisplayshell-scale.c
trunk/app/display/gimpdisplayshell-scale.h
trunk/app/display/gimpdisplayshell.c
Modified: trunk/app/display/gimpdisplayshell-scale.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scale.c (original)
+++ trunk/app/display/gimpdisplayshell-scale.c Wed Aug 13 17:36:29 2008
@@ -38,6 +38,7 @@
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
+#include "gimpdisplayshell-draw.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-scroll.h"
#include "gimpdisplayshell-title.h"
@@ -446,6 +447,30 @@
}
/**
+ * gimp_display_shell_scale_image_is_within_viewport:
+ * @shell:
+ *
+ * Returns: %TRUE if the (scaled) image is smaller than and within the
+ * viewport.
+ **/
+gboolean
+gimp_display_shell_scale_image_is_within_viewport (GimpDisplayShell *shell)
+{
+ gint sw, sh;
+
+ g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
+
+ gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
+
+ return sw < shell->disp_width &&
+ sh < shell->disp_height &&
+ shell->offset_x < 0 &&
+ shell->offset_y < 0 &&
+ shell->offset_x > sw - shell->disp_width &&
+ shell->offset_y > sh - shell->disp_height;
+}
+
+/**
* gimp_display_shell_scale_fill:
* @shell: the #GimpDisplayShell
*
Modified: trunk/app/display/gimpdisplayshell-scale.h
==============================================================================
--- trunk/app/display/gimpdisplayshell-scale.h (original)
+++ trunk/app/display/gimpdisplayshell-scale.h Wed Aug 13 17:36:29 2008
@@ -20,42 +20,43 @@
#define __GIMP_DISPLAY_SHELL_SCALE_H__
-void gimp_display_shell_update_scrollbars_and_rulers (GimpDisplayShell *shell);
+void gimp_display_shell_update_scrollbars_and_rulers (GimpDisplayShell *shell);
-gboolean gimp_display_shell_scale_revert (GimpDisplayShell *shell);
-gboolean gimp_display_shell_scale_can_revert (GimpDisplayShell *shell);
+gboolean gimp_display_shell_scale_revert (GimpDisplayShell *shell);
+gboolean gimp_display_shell_scale_can_revert (GimpDisplayShell *shell);
-void gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *shell,
- gboolean dot_for_dot);
+void gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *shell,
+ gboolean dot_for_dot);
-void gimp_display_shell_scale (GimpDisplayShell *shell,
- GimpZoomType zoom_type,
- gdouble scale);
-void gimp_display_shell_scale_to (GimpDisplayShell *shell,
- GimpZoomType zoom_type,
- gdouble scale,
- gdouble x,
- gdouble y);
-void gimp_display_shell_scale_fit_in (GimpDisplayShell *shell);
-void gimp_display_shell_scale_fill (GimpDisplayShell *shell);
-void gimp_display_shell_scale_handle_zoom_revert (GimpDisplayShell *shell);
-void gimp_display_shell_scale_by_values (GimpDisplayShell *shell,
- gdouble scale,
- gint offset_x,
- gint offset_y,
- gboolean resize_window);
-void gimp_display_shell_scale_shrink_wrap (GimpDisplayShell *shell,
- gboolean grow_only);
-
-void gimp_display_shell_scale_resize (GimpDisplayShell *shell,
- gboolean resize_window,
- gboolean grow_only);
-void gimp_display_shell_set_initial_scale (GimpDisplayShell *shell,
- gdouble scale,
- gint *display_width,
- gint *display_height);
+void gimp_display_shell_scale (GimpDisplayShell *shell,
+ GimpZoomType zoom_type,
+ gdouble scale);
+void gimp_display_shell_scale_to (GimpDisplayShell *shell,
+ GimpZoomType zoom_type,
+ gdouble scale,
+ gdouble x,
+ gdouble y);
+void gimp_display_shell_scale_fit_in (GimpDisplayShell *shell);
+gboolean gimp_display_shell_scale_image_is_within_viewport (GimpDisplayShell *shell);
+void gimp_display_shell_scale_fill (GimpDisplayShell *shell);
+void gimp_display_shell_scale_handle_zoom_revert (GimpDisplayShell *shell);
+void gimp_display_shell_scale_by_values (GimpDisplayShell *shell,
+ gdouble scale,
+ gint offset_x,
+ gint offset_y,
+ gboolean resize_window);
+void gimp_display_shell_scale_shrink_wrap (GimpDisplayShell *shell,
+ gboolean grow_only);
+
+void gimp_display_shell_scale_resize (GimpDisplayShell *shell,
+ gboolean resize_window,
+ gboolean grow_only);
+void gimp_display_shell_set_initial_scale (GimpDisplayShell *shell,
+ gdouble scale,
+ gint *display_width,
+ gint *display_height);
-void gimp_display_shell_scale_dialog (GimpDisplayShell *shell);
+void gimp_display_shell_scale_dialog (GimpDisplayShell *shell);
#endif /* __GIMP_DISPLAY_SHELL_SCALE_H__ */
Modified: trunk/app/display/gimpdisplayshell.c
==============================================================================
--- trunk/app/display/gimpdisplayshell.c (original)
+++ trunk/app/display/gimpdisplayshell.c Wed Aug 13 17:36:29 2008
@@ -718,6 +718,21 @@
return NULL;
}
+static void
+gimp_display_shell_zoom_button_callback (GimpDisplayShell *shell,
+ GtkWidget *zoom_button)
+{
+ shell->zoom_on_resize =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (zoom_button));
+
+ if (shell->zoom_on_resize &&
+ gimp_display_shell_scale_image_is_within_viewport (shell))
+ {
+ /* Implicitly make a View -> Fit Image in Window */
+ gimp_display_shell_scale_fit_in (shell);
+ }
+}
+
/* public functions */
@@ -1079,9 +1094,9 @@
_("Zoom image when window size changes"),
GIMP_HELP_IMAGE_WINDOW_ZOOM_FOLLOW_BUTTON);
- g_signal_connect (shell->zoom_button, "toggled",
- G_CALLBACK (gimp_toggle_button_update),
- &shell->zoom_on_resize);
+ g_signal_connect_swapped (shell->zoom_button, "toggled",
+ G_CALLBACK (gimp_display_shell_zoom_button_callback),
+ shell);
/* create the contents of the lower_hbox *********************************/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]