gimp r27623 - in trunk: . app/core



Author: mitch
Date: Tue Nov 11 21:14:52 2008
New Revision: 27623
URL: http://svn.gnome.org/viewvc/gimp?rev=27623&view=rev

Log:
2008-11-11  Michael Natterer  <mitch gimp org>

	* app/core/gimpitem.c: add read-only "offset-x" and "offset-y"
	properties. Call gimp_item_set_offset() from all places that set
	offset_x and offset_y in this file. Freeze and thaw GObject
	notification around all calls to virtual functions which might
	emit notify. Add missing notifications whenever width and height
	change.

	* app/core/gimpimage-rotate.c: use gimp_item_set_offset() instead
	of setting the values manually.



Modified:
   trunk/ChangeLog
   trunk/app/core/gimpimage-rotate.c
   trunk/app/core/gimpitem.c

Modified: trunk/app/core/gimpimage-rotate.c
==============================================================================
--- trunk/app/core/gimpimage-rotate.c	(original)
+++ trunk/app/core/gimpimage-rotate.c	Tue Nov 11 21:14:52 2008
@@ -122,8 +122,7 @@
 
       gimp_item_rotate (item, context, rotate_type, center_x, center_y, FALSE);
 
-      item->offset_x = 0;
-      item->offset_y = 0;
+      gimp_item_set_offset (item, 0, 0);
 
       if (progress)
         gimp_progress_set_value (progress, progress_current++ / progress_max);
@@ -138,10 +137,13 @@
 
       gimp_item_rotate (item, context, rotate_type, center_x, center_y, FALSE);
 
-      item->width    = new_image_width;
-      item->height   = new_image_height;
-      item->offset_x = 0;
-      item->offset_y = 0;
+      item->width  = new_image_width;
+      item->height = new_image_height;
+
+      g_object_notify (G_OBJECT (item), "width");
+      g_object_notify (G_OBJECT (item), "height");
+
+      gimp_item_set_offset (item, 0, 0);
 
       gimp_item_translate (item,
                            (new_image_width  - gimp_image_get_width  (image)) / 2,
@@ -159,8 +161,7 @@
     gimp_item_rotate (GIMP_ITEM (mask), context,
                       rotate_type, center_x, center_y, FALSE);
 
-    GIMP_ITEM (mask)->offset_x = 0;
-    GIMP_ITEM (mask)->offset_y = 0;
+    gimp_item_set_offset (GIMP_ITEM (mask), 0, 0);
 
     if (progress)
       gimp_progress_set_value (progress, progress_current++ / progress_max);

Modified: trunk/app/core/gimpitem.c
==============================================================================
--- trunk/app/core/gimpitem.c	(original)
+++ trunk/app/core/gimpitem.c	Tue Nov 11 21:14:52 2008
@@ -58,7 +58,9 @@
   PROP_0,
   PROP_ID,
   PROP_WIDTH,
-  PROP_HEIGHT
+  PROP_HEIGHT,
+  PROP_OFFSET_X,
+  PROP_OFFSET_Y
 };
 
 
@@ -199,6 +201,18 @@
                                    g_param_spec_int ("height", NULL, NULL,
                                                      1, GIMP_MAX_IMAGE_SIZE, 1,
                                                      GIMP_PARAM_READABLE));
+
+  g_object_class_install_property (object_class, PROP_OFFSET_X,
+                                   g_param_spec_int ("offset-x", NULL, NULL,
+                                                     -GIMP_MAX_IMAGE_SIZE,
+                                                     GIMP_MAX_IMAGE_SIZE, 0,
+                                                     GIMP_PARAM_READABLE));
+
+  g_object_class_install_property (object_class, PROP_OFFSET_Y,
+                                   g_param_spec_int ("offset-y", NULL, NULL,
+                                                     -GIMP_MAX_IMAGE_SIZE,
+                                                     GIMP_MAX_IMAGE_SIZE, 0,
+                                                     GIMP_PARAM_READABLE));
 }
 
 static void
@@ -254,6 +268,13 @@
     case PROP_HEIGHT:
       g_value_set_int (value, item->height);
       break;
+    case PROP_OFFSET_X:
+      g_value_set_int (value, item->offset_x);
+      break;
+    case PROP_OFFSET_Y:
+      g_value_set_int (value, item->offset_y);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -408,10 +429,9 @@
                           gint      offset_y,
                           gboolean  push_undo)
 {
-  item->offset_x += offset_x;
-  item->offset_y += offset_y;
-
-  gimp_item_sync_offset_node (item);
+  gimp_item_set_offset (item,
+                        item->offset_x + offset_x,
+                        item->offset_y + offset_y);
 }
 
 static void
@@ -423,13 +443,19 @@
                       GimpInterpolationType  interpolation,
                       GimpProgress          *progress)
 {
-  item->width    = new_width;
-  item->height   = new_height;
-  item->offset_x = new_offset_x;
-  item->offset_y = new_offset_y;
+  if (item->width != new_width)
+    {
+      item->width = new_width;
+      g_object_notify (G_OBJECT (item), "width");
+    }
+
+  if (item->height != new_height)
+    {
+      item->height = new_height;
+      g_object_notify (G_OBJECT (item), "height");
+    }
 
-  g_object_notify (G_OBJECT (item), "width");
-  g_object_notify (G_OBJECT (item), "height");
+  gimp_item_set_offset (item, new_offset_x, new_offset_y);
 }
 
 static void
@@ -440,13 +466,21 @@
                        gint         offset_x,
                        gint         offset_y)
 {
-  item->offset_x = item->offset_x - offset_x;
-  item->offset_y = item->offset_y - offset_y;
-  item->width    = new_width;
-  item->height   = new_height;
+  if (item->width != new_width)
+    {
+      item->width = new_width;
+      g_object_notify (G_OBJECT (item), "width");
+    }
 
-  g_object_notify (G_OBJECT (item), "width");
-  g_object_notify (G_OBJECT (item), "height");
+  if (item->height != new_height)
+    {
+      item->height = new_height;
+      g_object_notify (G_OBJECT (item), "height");
+    }
+
+  gimp_item_set_offset (item,
+                        item->offset_x - offset_x,
+                        item->offset_y - offset_y);
 }
 
 static GeglNode *
@@ -548,13 +582,19 @@
       g_object_notify (G_OBJECT (item), "id");
     }
 
-  item->width    = width;
-  item->height   = height;
-  item->offset_x = offset_x;
-  item->offset_y = offset_y;
+  if (item->width != width)
+    {
+      item->width = width;
+      g_object_notify (G_OBJECT (item), "width");
+    }
 
-  g_object_notify (G_OBJECT (item), "width");
-  g_object_notify (G_OBJECT (item), "height");
+  if (item->height != height)
+    {
+      item->height = height;
+      g_object_notify (G_OBJECT (item), "height");
+    }
+
+  gimp_item_set_offset (item, offset_x, offset_y);
 
   if (name)
     gimp_object_set_name (GIMP_OBJECT (item), name);
@@ -713,10 +753,23 @@
 {
   g_return_if_fail (GIMP_IS_ITEM (item));
 
-  item->offset_x = offset_x;
-  item->offset_y = offset_y;
+  g_object_freeze_notify (G_OBJECT (item));
+
+  if (item->offset_x != offset_x)
+    {
+      item->offset_x = offset_x;
+      g_object_notify (G_OBJECT (item), "offset-x");
+    }
+
+  if (item->offset_y != offset_y)
+    {
+      item->offset_y = offset_y;
+      g_object_notify (G_OBJECT (item), "offset-y");
+    }
 
   gimp_item_sync_offset_node (item);
+
+  g_object_thaw_notify (G_OBJECT (item));
 }
 
 /**
@@ -817,9 +870,13 @@
     gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_SCALE,
                                  item_class->scale_desc);
 
+  g_object_freeze_notify (G_OBJECT (item));
+
   item_class->scale (item, new_width, new_height, new_offset_x, new_offset_y,
                      interpolation, progress);
 
+  g_object_thaw_notify (G_OBJECT (item));
+
   if (gimp_item_is_attached (item))
     gimp_image_undo_group_end (image);
 }
@@ -984,8 +1041,12 @@
     gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
                                  item_class->resize_desc);
 
+  g_object_freeze_notify (G_OBJECT (item));
+
   item_class->resize (item, context, new_width, new_height, offset_x, offset_y);
 
+  g_object_thaw_notify (G_OBJECT (item));
+
   if (gimp_item_is_attached (item))
     gimp_image_undo_group_end (image);
 }
@@ -1010,8 +1071,12 @@
   gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
                                item_class->flip_desc);
 
+  g_object_freeze_notify (G_OBJECT (item));
+
   item_class->flip (item, context, flip_type, axis, clip_result);
 
+  g_object_thaw_notify (G_OBJECT (item));
+
   gimp_image_undo_group_end (image);
 }
 
@@ -1036,9 +1101,13 @@
   gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
                                item_class->rotate_desc);
 
+  g_object_freeze_notify (G_OBJECT (item));
+
   item_class->rotate (item, context, rotate_type, center_x, center_y,
                       clip_result);
 
+  g_object_thaw_notify (G_OBJECT (item));
+
   gimp_image_undo_group_end (image);
 }
 
@@ -1067,9 +1136,13 @@
   gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
                                item_class->transform_desc);
 
+  g_object_freeze_notify (G_OBJECT (item));
+
   item_class->transform (item, context, matrix, direction, interpolation,
                          recursion_level, clip_result, progress);
 
+  g_object_thaw_notify (G_OBJECT (item));
+
   gimp_image_undo_group_end (image);
 }
 
@@ -1139,11 +1212,12 @@
     {
       GeglNode *node = gimp_item_get_node (item);
 
-      item->offset_node = gegl_node_new_child (node,
-                                               "operation", "gegl:shift",
-                                               "x",         (gdouble) item->offset_x,
-                                               "y",         (gdouble) item->offset_y,
-                                               NULL);
+      item->offset_node =
+        gegl_node_new_child (node,
+                             "operation", "gegl:shift",
+                             "x",         (gdouble) item->offset_x,
+                             "y",         (gdouble) item->offset_y,
+                             NULL);
     }
 
   return item->offset_node;



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