[gimp] Use gimp_image_set_size() instead of setting width and height manually



commit ea3358145164beb58f1befc66e0909a8b4a293b3
Author: Michael Natterer <mitch gimp org>
Date:   Wed Aug 26 13:03:40 2009 +0200

    Use gimp_image_set_size() instead of setting width and height manually
    
    This also (really this time) fixes nested group layers. There were
    cases when the outer group layer didn't properly resize itself because
    gimp_drawable_set_tiles() on the inner group layer failed to emit
    notify::width and notify::height.

 app/core/gimpdrawable.c          |   12 +++---------
 app/core/gimpimage-rotate.c      |    7 +------
 app/text/gimptextlayer-xcf.c     |    7 ++++---
 app/vectors/gimpvectors.c        |    5 +++--
 app/vectors/gimpvectorsmodundo.c |    7 ++++---
 5 files changed, 15 insertions(+), 23 deletions(-)
---
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 7705cf5..aed50cf 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -756,15 +756,9 @@ gimp_drawable_real_set_tiles (GimpDrawable *drawable,
   drawable->has_alpha      = GIMP_IMAGE_TYPE_HAS_ALPHA (type);
 
   gimp_item_set_offset (item, offset_x, offset_y);
-
-  if (gimp_item_get_width  (item) != tile_manager_width (tiles) ||
-      gimp_item_get_height (item) != tile_manager_height (tiles))
-    {
-      item->width  = tile_manager_width (tiles);
-      item->height = tile_manager_height (tiles);
-
-      gimp_viewable_size_changed (GIMP_VIEWABLE (drawable));
-    }
+  gimp_item_set_size (item,
+                      tile_manager_width  (tiles),
+                      tile_manager_height (tiles));
 
   if (old_has_alpha != gimp_drawable_has_alpha (drawable))
     gimp_drawable_alpha_changed (drawable);
diff --git a/app/core/gimpimage-rotate.c b/app/core/gimpimage-rotate.c
index ab22188..ec035be 100644
--- a/app/core/gimpimage-rotate.c
+++ b/app/core/gimpimage-rotate.c
@@ -139,13 +139,8 @@ gimp_image_rotate (GimpImage        *image,
 
       gimp_item_rotate (item, context, rotate_type, center_x, center_y, FALSE);
 
-      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_set_size (item, new_image_width, new_image_height);
 
       gimp_item_translate (item,
                            (new_image_width  - gimp_image_get_width  (image)) / 2,
diff --git a/app/text/gimptextlayer-xcf.c b/app/text/gimptextlayer-xcf.c
index bacff22..d010704 100644
--- a/app/text/gimptextlayer-xcf.c
+++ b/app/text/gimptextlayer-xcf.c
@@ -207,12 +207,13 @@ gimp_text_layer_from_layer (GimpLayer *layer,
   item->parasites = GIMP_ITEM (layer)->parasites;
   GIMP_ITEM (layer)->parasites = NULL;
 
-  item->width  = gimp_item_get_width (GIMP_ITEM (layer));
-  item->height = gimp_item_get_height (GIMP_ITEM (layer));
-
   gimp_item_get_offset (GIMP_ITEM (layer), &offset_x, &offset_y);
   gimp_item_set_offset (item, offset_x, offset_y);
 
+  gimp_item_set_size (item,
+                      gimp_item_get_width  (GIMP_ITEM (layer)),
+                      gimp_item_get_height (GIMP_ITEM (layer)));
+
   gimp_item_set_visible (item, gimp_item_get_visible (GIMP_ITEM (layer)), FALSE);
   gimp_item_set_linked  (item, gimp_item_get_linked  (GIMP_ITEM (layer)), FALSE);
 
diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c
index 5548b1c..e90b991 100644
--- a/app/vectors/gimpvectors.c
+++ b/app/vectors/gimpvectors.c
@@ -310,8 +310,9 @@ static void
 gimp_vectors_convert (GimpItem  *item,
                       GimpImage *dest_image)
 {
-  item->width  = gimp_image_get_width  (dest_image);
-  item->height = gimp_image_get_height (dest_image);
+  gimp_item_set_size (item,
+                      gimp_image_get_width  (dest_image),
+                      gimp_image_get_height (dest_image));
 
   GIMP_ITEM_CLASS (parent_class)->convert (item, dest_image);
 }
diff --git a/app/vectors/gimpvectorsmodundo.c b/app/vectors/gimpvectorsmodundo.c
index 9d85338..63cc23c 100644
--- a/app/vectors/gimpvectorsmodundo.c
+++ b/app/vectors/gimpvectorsmodundo.c
@@ -125,12 +125,13 @@ gimp_vectors_mod_undo_pop (GimpUndo            *undo,
 
   gimp_vectors_copy_strokes (temp, vectors);
 
-  GIMP_ITEM (vectors)->width  = gimp_item_get_width  (GIMP_ITEM (temp));
-  GIMP_ITEM (vectors)->height = gimp_item_get_height (GIMP_ITEM (temp));
-
   gimp_item_get_offset (GIMP_ITEM (temp), &offset_x, &offset_y);
   gimp_item_set_offset (GIMP_ITEM (vectors), offset_x, offset_y);
 
+  gimp_item_set_size (GIMP_ITEM (vectors),
+                      gimp_item_get_width  (GIMP_ITEM (temp)),
+                      gimp_item_get_height (GIMP_ITEM (temp)));
+
   g_object_unref (temp);
 
   gimp_vectors_thaw (vectors);



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