gimp r25598 - in trunk: . app/tools



Author: martinn
Date: Fri May  9 12:46:28 2008
New Revision: 25598
URL: http://svn.gnome.org/viewvc/gimp?rev=25598&view=rev

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

	* 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.
	(gimp_crop_tool_execute): No need to explicitly call
	gimp_crop_tool_update_option_defaults() any longer.


Modified:
   trunk/ChangeLog
   trunk/app/tools/gimpcroptool.c
   trunk/app/tools/gimpcroptool.h

Modified: trunk/app/tools/gimpcroptool.c
==============================================================================
--- trunk/app/tools/gimpcroptool.c	(original)
+++ trunk/app/tools/gimpcroptool.c	Fri May  9 12:46:28 2008
@@ -87,6 +87,7 @@
 static void      gimp_crop_tool_image_changed             (GimpCropTool               *crop_tool,
                                                            GimpImage                  *image,
                                                            GimpContext                *context);
+static void      gimp_crop_tool_image_size_changed        (GimpCropTool               *crop_tool);
 
 
 G_DEFINE_TYPE_WITH_CODE (GimpCropTool, gimp_crop_tool, GIMP_TYPE_DRAW_TOOL,
@@ -155,6 +156,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 *
@@ -186,6 +189,13 @@
                            crop_tool,
                            G_CONNECT_SWAPPED);
 
+  /* Make sure we are connected to "size-changed" for the initial
+   * image.
+   */
+  gimp_crop_tool_image_changed (crop_tool,
+                                gimp_context_get_image (gimp_context),
+                                gimp_context);
+
 
   options = GIMP_CROP_TOOL_GET_OPTIONS (object);
 
@@ -303,9 +313,6 @@
 
       gimp_image_flush (image);
 
-      gimp_crop_tool_update_option_defaults (GIMP_CROP_TOOL (tool),
-                                             TRUE);
-
       return TRUE;
     }
 
@@ -398,6 +405,30 @@
                               GimpImage    *image,
                               GimpContext  *context)
 {
+  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: trunk/app/tools/gimpcroptool.h
==============================================================================
--- trunk/app/tools/gimpcroptool.h	(original)
+++ trunk/app/tools/gimpcroptool.h	Fri May  9 12:46:28 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]