gimp r25600 - in branches/gimp-2-4: . app/tools



Author: martinn
Date: Sat May 10 07:11:51 2008
New Revision: 25600
URL: http://svn.gnome.org/viewvc/gimp?rev=25600&view=rev

Log:
2008-05-10  Martin Nordholts  <martinn svn gnome org>

	Merged from trunk:

	* app/tools/gimpcroptool.[ch]: Keep track of the current image and
	manage a subscription to "size-changed" so that default aspect
	ratio is properly updated. (Bug #532057.)
	(gimp_crop_tool_execute): No need to explicitly call
	gimp_crop_tool_update_option_defaults() any longer.


Modified:
   branches/gimp-2-4/ChangeLog
   branches/gimp-2-4/app/tools/gimpcroptool.c
   branches/gimp-2-4/app/tools/gimpcroptool.h

Modified: branches/gimp-2-4/app/tools/gimpcroptool.c
==============================================================================
--- branches/gimp-2-4/app/tools/gimpcroptool.c	(original)
+++ branches/gimp-2-4/app/tools/gimpcroptool.c	Sat May 10 07:11:51 2008
@@ -93,6 +93,8 @@
                                                   GimpImage             *image,
                                                   GimpCropTool          *crop_tool);
 
+static void   gimp_crop_tool_image_size_changed  (GimpCropTool          *crop_tool);
+
 
 G_DEFINE_TYPE_WITH_CODE (GimpCropTool, gimp_crop_tool, GIMP_TYPE_DRAW_TOOL,
                          G_IMPLEMENT_INTERFACE (GIMP_TYPE_RECTANGLE_TOOL,
@@ -158,6 +160,8 @@
 
   gimp_tool_control_set_wants_click (tool->control, TRUE);
   gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_CROP);
+
+  crop_tool->current_image = NULL;
 }
 
 static GObject *
@@ -188,6 +192,13 @@
                            G_CALLBACK (gimp_crop_tool_image_changed),
                            crop_tool, 0);
 
+  /* Make sure we are connected to "size-changed" for the initial
+   * image.
+   */
+  gimp_crop_tool_image_changed (gimp_context,
+                                gimp_context_get_image (gimp_context),
+                                crop_tool);
+
 
   options = GIMP_CROP_TOOL_GET_OPTIONS (object);
 
@@ -305,9 +316,6 @@
 
       gimp_image_flush (image);
 
-      gimp_crop_tool_update_option_defaults (GIMP_CROP_TOOL (tool),
-                                             TRUE);
-
       return TRUE;
     }
 
@@ -400,6 +408,30 @@
                               GimpImage    *image,
                               GimpCropTool *crop_tool)
 {
+  if (crop_tool->current_image)
+    {
+      g_signal_handlers_disconnect_by_func (crop_tool->current_image,
+                                            gimp_crop_tool_image_size_changed,
+                                            NULL);
+    }
+
+  if (image)
+    {
+      g_signal_connect_object (image, "size-changed",
+                               G_CALLBACK (gimp_crop_tool_image_size_changed),
+                               crop_tool,
+                               G_CONNECT_SWAPPED);
+    }
+
+  crop_tool->current_image = image;
+
   gimp_crop_tool_update_option_defaults (GIMP_CROP_TOOL (crop_tool),
                                          FALSE);
 }
+
+static void
+gimp_crop_tool_image_size_changed (GimpCropTool *crop_tool)
+{
+  gimp_crop_tool_update_option_defaults (crop_tool,
+                                         FALSE);
+}

Modified: branches/gimp-2-4/app/tools/gimpcroptool.h
==============================================================================
--- branches/gimp-2-4/app/tools/gimpcroptool.h	(original)
+++ branches/gimp-2-4/app/tools/gimpcroptool.h	Sat May 10 07:11:51 2008
@@ -39,6 +39,8 @@
 struct _GimpCropTool
 {
   GimpDrawTool  parent_instance;
+
+  GimpImage    *current_image;
 };
 
 struct _GimpCropToolClass



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]