[gimp] Add lowlevel accessor gimp_item_set_size()



commit ce5d591336cbea031042d2c384c70aef8d0eefb4
Author: Michael Natterer <mitch gimp org>
Date:   Wed Aug 26 13:00:13 2009 +0200

    Add lowlevel accessor gimp_item_set_size()
    
    Sets the "width" and "height" properties and emits notifications and
    "size-changed" if anything has changed. This in only to be used by
    functions that actually resize the item, it does not scale/resize
    anything.

 app/core/gimpitem.c |   30 ++++++++++++++++++++++++++++++
 app/core/gimpitem.h |    3 +++
 2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpitem.c b/app/core/gimpitem.c
index 16944cc..191e42b 100644
--- a/app/core/gimpitem.c
+++ b/app/core/gimpitem.c
@@ -830,6 +830,36 @@ gimp_item_get_height (const GimpItem *item)
   return item->height;
 }
 
+void
+gimp_item_set_size (GimpItem *item,
+                    gint      width,
+                    gint      height)
+{
+  g_return_if_fail (GIMP_IS_ITEM (item));
+
+  if (item->width  != width ||
+      item->height != height)
+    {
+      g_object_freeze_notify (G_OBJECT (item));
+
+      if (item->width != width)
+        {
+          item->width = width;
+          g_object_notify (G_OBJECT (item), "width");
+        }
+
+      if (item->height != height)
+        {
+          item->height = height;
+          g_object_notify (G_OBJECT (item), "height");
+        }
+
+      g_object_thaw_notify (G_OBJECT (item));
+
+      gimp_viewable_size_changed (GIMP_VIEWABLE (item));
+    }
+}
+
 /**
  * gimp_item_get_offset:
  * @item:     The #GimpItem to check.
diff --git a/app/core/gimpitem.h b/app/core/gimpitem.h
index 1e36ec4..b45864c 100644
--- a/app/core/gimpitem.h
+++ b/app/core/gimpitem.h
@@ -165,6 +165,9 @@ gboolean        gimp_item_rename             (GimpItem           *item,
 
 gint            gimp_item_get_width          (const GimpItem     *item);
 gint            gimp_item_get_height         (const GimpItem     *item);
+void            gimp_item_set_size           (GimpItem           *item,
+                                              gint                width,
+                                              gint                height);
 
 void            gimp_item_get_offset         (const GimpItem     *item,
                                               gint               *offset_x,



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