[gimp/wip/Jehan/classy-GIMP: 35/57] libgimp: nicer API for functions returning a list.



commit b2e35cc1cd5fbea6ea0d5673e7c7ac5eb827d834
Author: Jehan <jehan girinstud io>
Date:   Wed Aug 14 11:08:42 2019 +0200

    libgimp: nicer API for functions returning a list.
    
    I.e.: gimp_image_get_(layers|channels|vectors)(), gimp_image_list() and
    gimp_item_get_children().
    Instead of returning an array of IDs, these will now return a GList with
    the right objects ready to use.

 libgimp/gimpexport.c        | 133 +++++++++-------------
 libgimp/gimpimage.c         | 262 ++++++++++++++++++++++++++++++++++++++++++++
 libgimp/gimpimage.h         |  17 +++
 libgimp/gimpimage_pdb.c     | 174 ++---------------------------
 libgimp/gimpimage_pdb.h     |  17 +--
 libgimp/gimpimagecombobox.c |  31 +++---
 libgimp/gimpitem.c          |  65 +++++++++++
 libgimp/gimpitem.h          |  14 +++
 libgimp/gimpitem_pdb.c      |  56 +---------
 libgimp/gimpitem_pdb.h      |  95 ++++++++--------
 libgimp/gimpitemcombobox.c  |  71 +++++-------
 libgimp/gimpitemcombobox.h  |   2 +-
 pdb/groups/image.pdb        |   4 +
 pdb/groups/item.pdb         |   1 +
 14 files changed, 522 insertions(+), 420 deletions(-)
---
diff --git a/libgimp/gimpexport.c b/libgimp/gimpexport.c
index c9de679e76..02ae7b4483 100644
--- a/libgimp/gimpexport.c
+++ b/libgimp/gimpexport.c
@@ -72,20 +72,15 @@ static void
 export_merge (GimpImage     *image,
               GimpDrawable **drawable)
 {
-  gint32  nlayers;
+  GList  *layers;
+  GList  *iter;
   gint32  nvisible = 0;
-  gint32  i;
-  gint32 *layers;
 
-  layers = gimp_image_get_layers (image, &nlayers);
-  for (i = 0; i < nlayers; i++)
+  layers = gimp_image_get_layers (image);
+  for (iter = layers; iter; iter = iter->next)
     {
-      GimpLayer *layer = GIMP_LAYER (gimp_item_new_by_id (layers[i]));
-
-      if (gimp_item_get_visible (GIMP_ITEM (layer)))
+      if (gimp_item_get_visible (GIMP_ITEM (iter->data)))
         nvisible++;
-
-      g_object_unref (layer);
     }
 
   if (nvisible <= 1)
@@ -114,7 +109,6 @@ export_merge (GimpImage     *image,
     {
       GimpLayer *merged;
 
-      g_free (layers);
       merged = gimp_image_merge_visible_layers (image, GIMP_CLIP_TO_IMAGE);
 
       if (merged != NULL)
@@ -127,7 +121,8 @@ export_merge (GimpImage     *image,
           return;  /* shouldn't happen */
         }
 
-      layers = gimp_image_get_layers (image, &nlayers);
+      g_list_free_full (layers, g_object_unref);
+      layers = gimp_image_get_layers (image);
 
       /*  make sure that the merged drawable matches the image size  */
       if (gimp_drawable_width  (GIMP_DRAWABLE (merged)) != gimp_image_width  (image) ||
@@ -144,18 +139,12 @@ export_merge (GimpImage     *image,
     }
 
   /* remove any remaining (invisible) layers */
-  for (i = 0; i < nlayers; i++)
+  for (iter = layers; iter; iter = iter->next)
     {
-      if (layers[i] != gimp_item_get_id (GIMP_ITEM (*drawable)))
-        {
-          GimpLayer *layer = GIMP_LAYER (gimp_item_new_by_id (layers[i]));
-
-          gimp_image_remove_layer (image, layer);
-
-          g_object_unref (layer);
-        }
+      if (gimp_item_get_id (iter->data) != gimp_item_get_id (GIMP_ITEM (*drawable)))
+        gimp_image_remove_layer (image, iter->data);
     }
-  g_free (layers);
+  g_list_free_full (layers, g_object_unref);
 }
 
 static void
@@ -174,51 +163,41 @@ static void
 export_remove_alpha (GimpImage     *image,
                      GimpDrawable **drawable)
 {
-  gint32  n_layers;
-  gint32 *layers;
-  gint    i;
+  GList  *layers;
+  GList  *iter;
 
-  layers = gimp_image_get_layers (image, &n_layers);
+  layers = gimp_image_get_layers (image);
 
-  for (i = 0; i < n_layers; i++)
+  for (iter = layers; iter; iter = iter->next)
     {
-      GimpLayer *layer;
-
-      layer = GIMP_LAYER (gimp_item_new_by_id (layers[i]));
-      if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
-        gimp_layer_flatten (layer);
-
-      g_object_unref (layer);
+      if (gimp_drawable_has_alpha (GIMP_DRAWABLE (iter->data)))
+        gimp_layer_flatten (iter->data);
     }
 
-  g_free (layers);
+  g_list_free_full (layers, g_object_unref);
 }
 
 static void
 export_apply_masks (GimpImage     *image,
                     GimpDrawable **drawable)
 {
-  gint32  n_layers;
-  gint32 *layers;
-  gint    i;
+  GList  *layers;
+  GList  *iter;
 
-  layers = gimp_image_get_layers (image, &n_layers);
+  layers = gimp_image_get_layers (image);
 
-  for (i = 0; i < n_layers; i++)
+  for (iter = layers; iter; iter = iter->next)
     {
-      GimpLayer     *layer;
       GimpLayerMask *mask;
 
-      layer = GIMP_LAYER (gimp_item_new_by_id (layers[i]));
-      mask = gimp_layer_get_mask (layer);
+      mask = gimp_layer_get_mask (iter->data);
       if (mask)
-        gimp_layer_remove_mask (layer, GIMP_MASK_APPLY);
+        gimp_layer_remove_mask (iter->data, GIMP_MASK_APPLY);
 
-      g_object_unref (layer);
       g_clear_object (&mask);
     }
 
-  g_free (layers);
+  g_list_free_full (layers, g_object_unref);
 }
 
 static void
@@ -239,11 +218,11 @@ static void
 export_convert_indexed (GimpImage     *image,
                         GimpDrawable **drawable)
 {
-  gint32 nlayers;
+  GList *layers;
 
   /* check alpha */
-  g_free (gimp_image_get_layers (image, &nlayers));
-  if (nlayers > 1 || gimp_drawable_has_alpha (*drawable))
+  layers = gimp_image_get_layers (image);
+  if (layers || gimp_drawable_has_alpha (*drawable))
     gimp_image_convert_indexed (image,
                                 GIMP_CONVERT_DITHER_NONE,
                                 GIMP_CONVERT_PALETTE_GENERATE,
@@ -253,6 +232,7 @@ export_convert_indexed (GimpImage     *image,
                                 GIMP_CONVERT_DITHER_NONE,
                                 GIMP_CONVERT_PALETTE_GENERATE,
                                 256, FALSE, FALSE, "");
+  g_list_free_full (layers, g_object_unref);
 }
 
 static void
@@ -272,22 +252,16 @@ static void
 export_add_alpha (GimpImage     *image,
                   GimpDrawable **drawable)
 {
-  gint32  nlayers;
-  gint32  i;
-  gint32 *layers;
+  GList  *layers;
+  GList  *iter;
 
-  layers = gimp_image_get_layers (image, &nlayers);
-  for (i = 0; i < nlayers; i++)
+  layers = gimp_image_get_layers (image);
+  for (iter = layers; iter; iter = iter->next)
     {
-      GimpLayer *layer;
-
-      layer = GIMP_LAYER (gimp_item_new_by_id (layers[i]));
-      if (!gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
-        gimp_layer_add_alpha (GIMP_LAYER (layer));
-
-      g_object_unref (layer);
+      if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (iter->data)))
+        gimp_layer_add_alpha (GIMP_LAYER (iter->data));
     }
-  g_free (layers);
+  g_list_free_full (layers, g_object_unref);
 }
 
 static void
@@ -768,9 +742,8 @@ gimp_export_image (GimpImage             **image,
 {
   GSList            *actions = NULL;
   GimpImageBaseType  type;
-  gint32             i;
-  gint32             n_layers;
-  gint32            *layers;
+  GList             *layers;
+  GList             *iter;
   gboolean           interactive          = FALSE;
   gboolean           added_flatten        = FALSE;
   gboolean           has_layer_masks      = FALSE;
@@ -823,11 +796,11 @@ gimp_export_image (GimpImage             **image,
 
 
   /* check alpha and layer masks */
-  layers = gimp_image_get_layers (*image, &n_layers);
+  layers = gimp_image_get_layers (*image);
 
-  for (i = 0; i < n_layers; i++)
+  for (iter = layers; iter; iter = iter->next)
     {
-      GimpLayer *layer = GIMP_LAYER (gimp_item_new_by_id (layers[i]));
+      GimpLayer *layer = GIMP_LAYER (iter->data);
 
       if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
         {
@@ -851,7 +824,7 @@ gimp_export_image (GimpImage             **image,
           /*  If this is the last layer, it's visible and has no alpha
            *  channel, then the image has a "flat" background
            */
-          if (i == n_layers - 1 && gimp_item_get_visible (GIMP_ITEM (layer)))
+          if (iter->next == NULL && gimp_item_get_visible (GIMP_ITEM (layer)))
             background_has_alpha = FALSE;
 
           if (capabilities & GIMP_EXPORT_NEEDS_ALPHA)
@@ -860,36 +833,32 @@ gimp_export_image (GimpImage             **image,
               break;
             }
         }
-      g_object_unref (layer);
     }
 
   if (! added_flatten)
     {
-      for (i = 0; i < n_layers; i++)
+      for (iter = layers; iter; iter = iter->next)
         {
-          GimpLayer     *layer = GIMP_LAYER (gimp_item_new_by_id (layers[i]));
+          GimpLayer     *layer = GIMP_LAYER (iter->data);
           GimpLayerMask *mask;
 
           mask = gimp_layer_get_mask (layer);
           if (mask)
             has_layer_masks = TRUE;
 
-          g_object_unref (layer);
           g_clear_object (&mask);
         }
     }
 
   if (! added_flatten)
     {
-      GimpLayer *layer = GIMP_LAYER (gimp_item_new_by_id (layers[0]));
-      gint32    *children;
-      gint32     n_children;
+      GimpLayer *layer = GIMP_LAYER (layers->data);
+      GList     *children;
 
-      children = gimp_item_get_children (GIMP_ITEM (layer), &n_children);
-      g_object_unref (layer);
+      children = gimp_item_get_children (GIMP_ITEM (layer));
 
       /* check if layer size != canvas size, opacity != 100%, or offsets != 0 */
-      if (n_layers == 1                     &&
+      if (g_list_length (layers) == 1       &&
           ! children                        &&
           gimp_item_is_layer (GIMP_ITEM (*drawable)) &&
           ! (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYERS))
@@ -919,7 +888,7 @@ gimp_export_image (GimpImage             **image,
             }
         }
       /* check multiple layers */
-      else if (n_layers > 1)
+      else if (layers && layers->next != NULL)
         {
           if (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION)
             {
@@ -955,7 +924,7 @@ gimp_export_image (GimpImage             **image,
             }
         }
 
-      g_free (children);
+      g_list_free_full (children, g_object_unref);
 
       /* check layer masks */
       if (has_layer_masks &&
@@ -963,7 +932,7 @@ gimp_export_image (GimpImage             **image,
         actions = g_slist_prepend (actions, &export_action_apply_masks);
     }
 
-  g_free (layers);
+  g_list_free_full (layers, g_object_unref);
 
   /* check the image type */
   type = gimp_image_base_type (*image);
diff --git a/libgimp/gimpimage.c b/libgimp/gimpimage.c
index bfa6785dd1..fc658a4d9f 100644
--- a/libgimp/gimpimage.c
+++ b/libgimp/gimpimage.c
@@ -158,6 +158,161 @@ gimp_image_new_by_id (gint32 image_id)
   return image;
 }
 
+/**
+ * gimp_image_list:
+ *
+ * Returns the list of images currently open.
+ *
+ * This procedure returns the list of images currently open in GIMP.
+ *
+ * Returns: (element-type GimpImage) (transfer full):
+ *          The list of images currently open.
+ *          The returned value must be freed with:
+ *          g_list_free_full(list, g_object_unref);
+ **/
+GList *
+gimp_image_list (void)
+{
+  GList *images = NULL;
+  gint  *ids;
+  gint   num_images;
+  gint   i;
+
+  ids = _gimp_image_list (&num_images);
+  for (i = 0; i < num_images; i++)
+    {
+      GimpImage *image;
+
+      image = gimp_image_new_by_id (ids[i]);
+
+      images = g_list_prepend (images, image);
+    }
+  images = g_list_reverse (images);
+  g_free (ids);
+
+  return images;
+}
+
+/**
+ * gimp_image_get_layers:
+ * @image: The image.
+ *
+ * Returns the list of layers contained in the specified image.
+ *
+ * This procedure returns the list of layers contained in the specified
+ * image. The order of layers is from topmost to bottommost.
+ *
+ * Returns: (element-type GimpImage) (transfer full):
+ *          The list of layers contained in the image.
+ *          The returned value must be freed with:
+ *          g_list_free_full(list, g_object_unref);
+ *
+ * Since: 3.0
+ **/
+GList *
+gimp_image_get_layers (GimpImage *image)
+{
+  GList *layers = NULL;
+  gint  *ids;
+  gint   num_layers;
+  gint   i;
+
+  ids = _gimp_image_get_layers (image, &num_layers);
+  for (i = 0; i < num_layers; i++)
+    {
+      GimpLayer *layer;
+
+      layer = GIMP_LAYER (gimp_item_new_by_id (ids[i]));
+
+      layers = g_list_prepend (layers, layer);
+    }
+  layers = g_list_reverse (layers);
+  g_free (ids);
+
+  return layers;
+}
+
+/**
+ * gimp_image_get_channels:
+ * @image: The image.
+ *
+ * Returns the list of channels contained in the specified image.
+ *
+ * This procedure returns the list of channels contained in the
+ * specified image. This does not include the selection mask, or layer
+ * masks. The order is from topmost to bottommost. Note that
+ * \"channels\" are custom channels and do not include the image's
+ * color components.
+ *
+ * Returns: (element-type GimpChannel) (transfer full):
+ *          The list of channels contained in the image.
+ *          The returned value must be freed with:
+ *          g_list_free_full(list, g_object_unref);
+ *
+ * Since: 3.0
+ **/
+GList *
+gimp_image_get_channels (GimpImage *image)
+{
+  GList *channels = NULL;
+  gint  *ids;
+  gint   num_channels;
+  gint   i;
+
+  ids = _gimp_image_get_channels (image, &num_channels);
+  for (i = 0; i < num_channels; i++)
+    {
+      GimpChannel *channel;
+
+      channel = GIMP_CHANNEL (gimp_item_new_by_id (ids[i]));
+
+      channels = g_list_prepend (channels, channel);
+    }
+  channels = g_list_reverse (channels);
+  g_free (ids);
+
+  return channels;
+}
+
+/**
+ * gimp_image_get_vectors:
+ * @image: The image.
+ *
+ * Returns the list of vectors contained in the specified image.
+ *
+ * This procedure returns the list of vectors contained in the
+ * specified image.
+ *
+ * Returns: (element-type GimpVectors) (transfer full):
+ *          The list of vectors contained in the image.
+ *          The returned value must be freed with:
+ *          g_list_free_full(list, g_object_unref);
+ *
+ * Since: 3.0
+ **/
+GList *
+gimp_image_get_vectors (GimpImage *image)
+{
+  GList *vectors = NULL;
+  gint  *ids;
+  gint   num_vectors;
+  gint   i;
+
+  ids = _gimp_image_get_vectors (image, &num_vectors);
+  for (i = 0; i < num_vectors; i++)
+    {
+      GimpVectors *path;
+
+      path = GIMP_VECTORS (gimp_item_new_by_id (ids[i]));
+
+      vectors = g_list_prepend (vectors, path);
+    }
+  vectors = g_list_reverse (vectors);
+  g_free (ids);
+
+  return vectors;
+}
+
 /**
  * gimp_image_get_colormap:
  * @image:      The image.
@@ -356,6 +511,113 @@ gimp_image_set_metadata (GimpImage    *image,
 /* Deprecated API. */
 
 
+/**
+ * gimp_image_list_deprecated: (skip)
+ * @num_images: (out): The number of images currently open.
+ *
+ * Returns the list of images currently open.
+ *
+ * This procedure returns the list of images currently open in GIMP.
+ *
+ * Returns: (array length=num_images) (element-type gint32) (transfer full):
+ *          The list of images currently open.
+ *          The returned value must be freed with g_free().
+ **/
+gint *
+gimp_image_list_deprecated (gint *num_images)
+{
+  return _gimp_image_list (num_images);
+}
+
+/**
+ * gimp_image_get_layers_deprecated: (skip)
+ * @image_id: The image id.
+ * @num_layers: (out): The number of layers contained in the image.
+ *
+ * Returns the list of layers contained in the specified image.
+ *
+ * This procedure returns the list of layers contained in the specified
+ * image. The order of layers is from topmost to bottommost.
+ *
+ * Returns: (array length=num_layers) (element-type gint32) (transfer full):
+ *          The list of layers contained in the image.
+ *          The returned value must be freed with g_free().
+ **/
+gint *
+gimp_image_get_layers_deprecated (gint32  image_id,
+                                  gint   *num_layers)
+{
+  GimpImage *image;
+  gint      *layers;
+
+  image  = gimp_image_new_by_id (image_id);
+  layers = _gimp_image_get_layers (image, num_layers);
+  g_object_unref (image);
+
+  return layers;
+}
+
+/**
+ * gimp_image_get_channels_deprecated: (skip)
+ * @image_id: The image.
+ * @num_channels: (out): The number of channels contained in the image.
+ *
+ * Returns the list of channels contained in the specified image.
+ *
+ * This procedure returns the list of channels contained in the
+ * specified image. This does not include the selection mask, or layer
+ * masks. The order is from topmost to bottommost. Note that
+ * \"channels\" are custom channels and do not include the image's
+ * color components.
+ *
+ * Returns: (array length=num_channels):
+ *          The list of channels contained in the image.
+ *          The returned value must be freed with g_free().
+ **/
+gint *
+gimp_image_get_channels_deprecated (gint32  image_id,
+                                    gint   *num_channels)
+{
+  GimpImage *image;
+  gint      *channels;
+
+  image    = gimp_image_new_by_id (image_id);
+  channels = _gimp_image_get_layers (image, num_channels);
+  g_object_unref (image);
+
+  return channels;
+}
+
+/**
+ * gimp_image_get_vectors_deprecated: (skip)
+ * @image_id: The image.
+ * @num_vectors: (out): The number of vectors contained in the image.
+ *
+ * Returns the list of vectors contained in the specified image.
+ *
+ * This procedure returns the list of vectors contained in the
+ * specified image.
+ *
+ * Returns: (array length=num_vectors) (element-type gint32) (transfer full):
+ *          The list of vectors contained in the image.
+ *          The returned value must be freed with g_free().
+ *
+ * Since: 2.4
+ **/
+gint *
+gimp_image_get_vectors_deprecated (gint32  image_id,
+                                   gint   *num_vectors)
+{
+  GimpImage *image;
+  gint      *vectors;
+
+  image   = gimp_image_new_by_id (image_id);
+  vectors = _gimp_image_get_vectors (image, num_vectors);
+  g_object_unref (image);
+
+  return vectors;
+}
+
 /**
  * gimp_image_get_colormap_deprecated: (skip)
  * @image_id:   The image.
diff --git a/libgimp/gimpimage.h b/libgimp/gimpimage.h
index 2334ea89a9..beef38c043 100644
--- a/libgimp/gimpimage.h
+++ b/libgimp/gimpimage.h
@@ -68,9 +68,14 @@ GType          gimp_image_get_type           (void) G_GNUC_CONST;
 gint32         gimp_image_get_id             (GimpImage    *image);
 GimpImage    * gimp_image_new_by_id          (gint32        image_id);
 
+GList        * gimp_image_list               (void);
 
 #ifndef GIMP_DEPRECATED_REPLACE_NEW_API
 
+GList        * gimp_image_get_layers         (GimpImage    *image);
+GList        * gimp_image_get_channels       (GimpImage    *image);
+GList        * gimp_image_get_vectors        (GimpImage    *image);
+
 guchar       * gimp_image_get_colormap       (GimpImage    *image,
                                               gint         *num_colors);
 gboolean       gimp_image_set_colormap       (GimpImage    *image,
@@ -92,6 +97,10 @@ gboolean       gimp_image_set_metadata       (GimpImage    *image,
 
 #else /* GIMP_DEPRECATED_REPLACE_NEW_API */
 
+#define gimp_image_list               gimp_image_list_deprecated
+#define gimp_image_get_layers         gimp_image_get_layers_deprecated
+#define gimp_image_get_channel        gimp_image_get_channels_deprecated
+#define gimp_image_get_vectors        gimp_image_get_vectors_deprecated
 #define gimp_image_get_colormap       gimp_image_get_colormap_deprecated
 #define gimp_image_set_colormap       gimp_image_set_colormap_deprecated
 #define gimp_image_get_thumbnail_data gimp_image_get_thumbnail_data_deprecated
@@ -102,6 +111,14 @@ gboolean       gimp_image_set_metadata       (GimpImage    *image,
 #endif /* GIMP_DEPRECATED_REPLACE_NEW_API */
 
 
+gint         * gimp_image_list_deprecated               (gint          *num_images);
+
+gint         * gimp_image_get_layers_deprecated         (gint32         image_id,
+                                                         gint          *num_layers);
+gint         * gimp_image_get_channels_deprecated       (gint32         image_id,
+                                                         gint          *num_channels);
+gint         * gimp_image_get_vectors_deprecated        (gint32         image_id,
+                                                         gint          *num_vectors);
 guchar       * gimp_image_get_colormap_deprecated       (gint32        image_id,
                                                          gint         *num_colors);
 gboolean       gimp_image_set_colormap_deprecated       (gint32        image_id,
diff --git a/libgimp/gimpimage_pdb.c b/libgimp/gimpimage_pdb.c
index 3f9eb8c5db..8f59ab463c 100644
--- a/libgimp/gimpimage_pdb.c
+++ b/libgimp/gimpimage_pdb.c
@@ -120,7 +120,7 @@ _gimp_image_is_valid (gint32 image_ID)
 }
 
 /**
- * gimp_image_list:
+ * _gimp_image_list:
  * @num_images: (out): The number of images currently open.
  *
  * Returns the list of images currently open.
@@ -132,7 +132,7 @@ _gimp_image_is_valid (gint32 image_ID)
  *          The returned value must be freed with g_free().
  **/
 gint *
-gimp_image_list (gint *num_images)
+_gimp_image_list (gint *num_images)
 {
   GimpPDB        *pdb = gimp_get_pdb ();
   GimpValueArray *args;
@@ -951,7 +951,7 @@ _gimp_image_height (gint32 image_ID)
 }
 
 /**
- * gimp_image_get_layers:
+ * _gimp_image_get_layers:
  * @image: The image.
  * @num_layers: (out): The number of layers contained in the image.
  *
@@ -965,8 +965,8 @@ _gimp_image_height (gint32 image_ID)
  *          The returned value must be freed with g_free().
  **/
 gint *
-gimp_image_get_layers (GimpImage *image,
-                       gint      *num_layers)
+_gimp_image_get_layers (GimpImage *image,
+                        gint      *num_layers)
 {
   GimpPDB        *pdb = gimp_get_pdb ();
   GimpValueArray *args;
@@ -1000,56 +1000,7 @@ gimp_image_get_layers (GimpImage *image,
 }
 
 /**
- * _gimp_image_get_layers: (skip)
- * @image_ID: The image.
- * @num_layers: (out): The number of layers contained in the image.
- *
- * Returns the list of layers contained in the specified image.
- *
- * This procedure returns the list of layers contained in the specified
- * image. The order of layers is from topmost to bottommost.
- *
- * Returns: (array length=num_layers):
- *          The list of layers contained in the image.
- *          The returned value must be freed with g_free().
- **/
-gint *
-_gimp_image_get_layers (gint32  image_ID,
-                        gint   *num_layers)
-{
-  GimpPDB        *pdb = gimp_get_pdb ();
-  GimpValueArray *args;
-  GimpValueArray *return_vals;
-  gint *layer_ids = NULL;
-
-  args = gimp_value_array_new_from_types (NULL,
-                                          GIMP_TYPE_IMAGE_ID, image_ID,
-                                          G_TYPE_NONE);
-
-  if (pdb)
-    return_vals = gimp_pdb_run_procedure_array (pdb,
-                                                "gimp-image-get-layers",
-                                                args);
-  else
-    return_vals = gimp_run_procedure_array ("gimp-image-get-layers",
-                                            args);
-  gimp_value_array_unref (args);
-
-  *num_layers = 0;
-
-  if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    {
-      *num_layers = g_value_get_int (gimp_value_array_index (return_vals, 1));
-      layer_ids = gimp_value_dup_int32_array (gimp_value_array_index (return_vals, 2));
-    }
-
-  gimp_value_array_unref (return_vals);
-
-  return layer_ids;
-}
-
-/**
- * gimp_image_get_channels:
+ * _gimp_image_get_channels:
  * @image: The image.
  * @num_channels: (out): The number of channels contained in the image.
  *
@@ -1066,8 +1017,8 @@ _gimp_image_get_layers (gint32  image_ID,
  *          The returned value must be freed with g_free().
  **/
 gint *
-gimp_image_get_channels (GimpImage *image,
-                         gint      *num_channels)
+_gimp_image_get_channels (GimpImage *image,
+                          gint      *num_channels)
 {
   GimpPDB        *pdb = gimp_get_pdb ();
   GimpValueArray *args;
@@ -1101,59 +1052,7 @@ gimp_image_get_channels (GimpImage *image,
 }
 
 /**
- * _gimp_image_get_channels: (skip)
- * @image_ID: The image.
- * @num_channels: (out): The number of channels contained in the image.
- *
- * Returns the list of channels contained in the specified image.
- *
- * This procedure returns the list of channels contained in the
- * specified image. This does not include the selection mask, or layer
- * masks. The order is from topmost to bottommost. Note that
- * \"channels\" are custom channels and do not include the image's
- * color components.
- *
- * Returns: (array length=num_channels):
- *          The list of channels contained in the image.
- *          The returned value must be freed with g_free().
- **/
-gint *
-_gimp_image_get_channels (gint32  image_ID,
-                          gint   *num_channels)
-{
-  GimpPDB        *pdb = gimp_get_pdb ();
-  GimpValueArray *args;
-  GimpValueArray *return_vals;
-  gint *channel_ids = NULL;
-
-  args = gimp_value_array_new_from_types (NULL,
-                                          GIMP_TYPE_IMAGE_ID, image_ID,
-                                          G_TYPE_NONE);
-
-  if (pdb)
-    return_vals = gimp_pdb_run_procedure_array (pdb,
-                                                "gimp-image-get-channels",
-                                                args);
-  else
-    return_vals = gimp_run_procedure_array ("gimp-image-get-channels",
-                                            args);
-  gimp_value_array_unref (args);
-
-  *num_channels = 0;
-
-  if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    {
-      *num_channels = g_value_get_int (gimp_value_array_index (return_vals, 1));
-      channel_ids = gimp_value_dup_int32_array (gimp_value_array_index (return_vals, 2));
-    }
-
-  gimp_value_array_unref (return_vals);
-
-  return channel_ids;
-}
-
-/**
- * gimp_image_get_vectors:
+ * _gimp_image_get_vectors:
  * @image: The image.
  * @num_vectors: (out): The number of vectors contained in the image.
  *
@@ -1169,8 +1068,8 @@ _gimp_image_get_channels (gint32  image_ID,
  * Since: 2.4
  **/
 gint *
-gimp_image_get_vectors (GimpImage *image,
-                        gint      *num_vectors)
+_gimp_image_get_vectors (GimpImage *image,
+                         gint      *num_vectors)
 {
   GimpPDB        *pdb = gimp_get_pdb ();
   GimpValueArray *args;
@@ -1203,57 +1102,6 @@ gimp_image_get_vectors (GimpImage *image,
   return vector_ids;
 }
 
-/**
- * _gimp_image_get_vectors: (skip)
- * @image_ID: The image.
- * @num_vectors: (out): The number of vectors contained in the image.
- *
- * Returns the list of vectors contained in the specified image.
- *
- * This procedure returns the list of vectors contained in the
- * specified image.
- *
- * Returns: (array length=num_vectors):
- *          The list of vectors contained in the image.
- *          The returned value must be freed with g_free().
- *
- * Since: 2.4
- **/
-gint *
-_gimp_image_get_vectors (gint32  image_ID,
-                         gint   *num_vectors)
-{
-  GimpPDB        *pdb = gimp_get_pdb ();
-  GimpValueArray *args;
-  GimpValueArray *return_vals;
-  gint *vector_ids = NULL;
-
-  args = gimp_value_array_new_from_types (NULL,
-                                          GIMP_TYPE_IMAGE_ID, image_ID,
-                                          G_TYPE_NONE);
-
-  if (pdb)
-    return_vals = gimp_pdb_run_procedure_array (pdb,
-                                                "gimp-image-get-vectors",
-                                                args);
-  else
-    return_vals = gimp_run_procedure_array ("gimp-image-get-vectors",
-                                            args);
-  gimp_value_array_unref (args);
-
-  *num_vectors = 0;
-
-  if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    {
-      *num_vectors = g_value_get_int (gimp_value_array_index (return_vals, 1));
-      vector_ids = gimp_value_dup_int32_array (gimp_value_array_index (return_vals, 2));
-    }
-
-  gimp_value_array_unref (return_vals);
-
-  return vector_ids;
-}
-
 /**
  * gimp_image_get_active_drawable:
  * @image: The image.
diff --git a/libgimp/gimpimage_pdb.h b/libgimp/gimpimage_pdb.h
index 29a450fc04..6c4eef584c 100644
--- a/libgimp/gimpimage_pdb.h
+++ b/libgimp/gimpimage_pdb.h
@@ -32,7 +32,7 @@ G_BEGIN_DECLS
 /* For information look into the C source or the html documentation */
 
 
-gint* gimp_image_list (gint *num_images);
+G_GNUC_INTERNAL gint* _gimp_image_list (gint *num_images);
 
 #ifndef GIMP_DEPRECATED_REPLACE_NEW_API
 
@@ -51,11 +51,11 @@ GimpPrecision            gimp_image_get_precision              (GimpImage
 GimpLayerMode            gimp_image_get_default_new_layer_mode (GimpImage           *image);
 gint                     gimp_image_width                      (GimpImage           *image);
 gint                     gimp_image_height                     (GimpImage           *image);
-gint*                    gimp_image_get_layers                 (GimpImage           *image,
+G_GNUC_INTERNAL gint*    _gimp_image_get_layers                (GimpImage           *image,
                                                                 gint                *num_layers);
-gint*                    gimp_image_get_channels               (GimpImage           *image,
+G_GNUC_INTERNAL gint*    _gimp_image_get_channels              (GimpImage           *image,
                                                                 gint                *num_channels);
-gint*                    gimp_image_get_vectors                (GimpImage           *image,
+G_GNUC_INTERNAL gint*    _gimp_image_get_vectors               (GimpImage           *image,
                                                                 gint                *num_vectors);
 GimpDrawable*            gimp_image_get_active_drawable        (GimpImage           *image);
 gboolean                 gimp_image_unset_active_channel       (GimpImage           *image);
@@ -207,9 +207,6 @@ gchar**                  gimp_image_get_parasite_list          (GimpImage
 #define gimp_image_get_default_new_layer_mode _gimp_image_get_default_new_layer_mode
 #define gimp_image_width _gimp_image_width
 #define gimp_image_height _gimp_image_height
-#define gimp_image_get_layers _gimp_image_get_layers
-#define gimp_image_get_channels _gimp_image_get_channels
-#define gimp_image_get_vectors _gimp_image_get_vectors
 #define gimp_image_get_active_drawable _gimp_image_get_active_drawable
 #define gimp_image_unset_active_channel _gimp_image_unset_active_channel
 #define gimp_image_get_floating_sel _gimp_image_get_floating_sel
@@ -296,12 +293,6 @@ GimpPrecision     _gimp_image_get_precision              (gint32              im
 GimpLayerMode     _gimp_image_get_default_new_layer_mode (gint32              image_ID);
 gint              _gimp_image_width                      (gint32              image_ID);
 gint              _gimp_image_height                     (gint32              image_ID);
-gint*             _gimp_image_get_layers                 (gint32              image_ID,
-                                                          gint               *num_layers);
-gint*             _gimp_image_get_channels               (gint32              image_ID,
-                                                          gint               *num_channels);
-gint*             _gimp_image_get_vectors                (gint32              image_ID,
-                                                          gint               *num_vectors);
 gint32            _gimp_image_get_active_drawable        (gint32              image_ID);
 gboolean          _gimp_image_unset_active_channel       (gint32              image_ID);
 gint32            _gimp_image_get_floating_sel           (gint32              image_ID);
diff --git a/libgimp/gimpimagecombobox.c b/libgimp/gimpimagecombobox.c
index 804f6cb5d7..5beefcc613 100644
--- a/libgimp/gimpimagecombobox.c
+++ b/libgimp/gimpimagecombobox.c
@@ -71,8 +71,7 @@ static void  gimp_image_combo_box_finalize  (GObject                 *object);
 
 static void  gimp_image_combo_box_populate  (GimpImageComboBox       *combo_box);
 static void  gimp_image_combo_box_model_add (GtkListStore            *store,
-                                             gint                     num_images,
-                                             gint32                  *images,
+                                             GList                   *images,
                                              GimpImageConstraintFunc  constraint,
                                              GimpImageConstraintDeprecatedFunc
                                                                       constraint_d,
@@ -181,20 +180,18 @@ gimp_image_combo_box_populate (GimpImageComboBox *combo_box)
 {
   GtkTreeModel *model;
   GtkTreeIter   iter;
-  gint32       *images;
-  gint          num_images;
+  GList        *images;
 
   model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
 
-  images = gimp_image_list (&num_images);
+  images = gimp_image_list ();
 
-  gimp_image_combo_box_model_add (GTK_LIST_STORE (model),
-                                  num_images, images,
+  gimp_image_combo_box_model_add (GTK_LIST_STORE (model), images,
                                   combo_box->constraint,
                                   combo_box->constraint_d,
                                   combo_box->data);
 
-  g_free (images);
+  g_list_free_full (images, g_object_unref);
 
   if (gtk_tree_model_get_iter_first (model, &iter))
     gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
@@ -202,30 +199,29 @@ gimp_image_combo_box_populate (GimpImageComboBox *combo_box)
 
 static void
 gimp_image_combo_box_model_add (GtkListStore            *store,
-                                gint                     num_images,
-                                gint32                  *images,
+                                GList                   *images,
                                 GimpImageConstraintFunc  constraint,
                                 GimpImageConstraintDeprecatedFunc
                                                          constraint_d,
                                 gpointer                 data)
 {
   GtkTreeIter  iter;
-  gint         i;
+  GList       *list;
 
-  for (i = 0; i < num_images; i++)
+  for (list = images; list; list = list->next)
     {
-      GimpImage *image;
+      GimpImage *image    = list->data;
+      gint32     image_id = gimp_image_get_id (image);
 
-      image = gimp_image_new_by_id (images[i]);
       if ((! constraint && ! constraint_d)             ||
           (constraint && (* constraint) (image, data)) ||
-          (constraint_d && (* constraint_d) (images[i], data)))
+          (constraint_d && (* constraint_d) (image_id, data)))
         {
           gchar     *image_name = gimp_image_get_name (image);
           gchar     *label;
           GdkPixbuf *thumb;
 
-          label = g_strdup_printf ("%s-%d", image_name, images[i]);
+          label = g_strdup_printf ("%s-%d", image_name, image_id);
 
           g_free (image_name);
 
@@ -235,7 +231,7 @@ gimp_image_combo_box_model_add (GtkListStore            *store,
 
           gtk_list_store_append (store, &iter);
           gtk_list_store_set (store, &iter,
-                              GIMP_INT_STORE_VALUE,  images[i],
+                              GIMP_INT_STORE_VALUE,  image_id,
                               GIMP_INT_STORE_LABEL,  label,
                               GIMP_INT_STORE_PIXBUF, thumb,
                               -1);
@@ -245,7 +241,6 @@ gimp_image_combo_box_model_add (GtkListStore            *store,
 
           g_free (label);
         }
-      g_object_unref (image);
     }
 }
 
diff --git a/libgimp/gimpitem.c b/libgimp/gimpitem.c
index f629dbbcba..87856d8c7a 100644
--- a/libgimp/gimpitem.c
+++ b/libgimp/gimpitem.c
@@ -163,3 +163,68 @@ gimp_item_new_by_id (gint32 item_id)
 
   return item;
 }
+
+/**
+ * gimp_item_get_children:
+ * @item: The item.
+ *
+ * Returns the item's list of children.
+ *
+ * This procedure returns the list of items which are children of the
+ * specified item. The order is topmost to bottommost.
+ *
+ * Returns: (element-type GimpItem) (transfer full):
+ *          The item's list of children.
+ *          The returned value must be freed with:
+ *          g_list_free_full(list, g_object_unref);
+ *
+ * Since: 3.0
+ **/
+GList *
+gimp_item_get_children (GimpItem *item)
+{
+  GList *children = NULL;
+  gint  *ids;
+  gint   num_items;
+  gint   i;
+
+  ids = _gimp_item_get_children (item, &num_items);
+
+  for (i = 0; i < num_items; i++)
+    children = g_list_prepend (children, gimp_item_new_by_id (ids[i]));
+
+  children = g_list_reverse (children);
+  g_free (ids);
+
+  return children;
+}
+
+/**
+ * gimp_item_get_children_deprecated: (skip)
+ * @item_id: The item.
+ * @num_children: (out): The item's number of children.
+ *
+ * Returns the item's list of children.
+ *
+ * This procedure returns the list of items which are children of the
+ * specified item. The order is topmost to bottommost.
+ *
+ * Returns: (array length=num_children) (element-type gint32) (transfer full):
+ *          The item's list of children.
+ *          The returned value must be freed with g_free().
+ *
+ * Since: 2.8
+ **/
+gint *
+gimp_item_get_children_deprecated (gint32    item_id,
+                                   gint     *num_children)
+{
+  GimpItem *item;
+  gint     *children;
+
+  item     = gimp_item_new_by_id (item_id);
+  children = _gimp_item_get_children (item, num_children);
+  g_object_unref (item);
+
+  return children;
+}
diff --git a/libgimp/gimpitem.h b/libgimp/gimpitem.h
index 4880e72b09..a8085e31d6 100644
--- a/libgimp/gimpitem.h
+++ b/libgimp/gimpitem.h
@@ -69,6 +69,20 @@ GType         gimp_item_get_type     (void) G_GNUC_CONST;
 gint32        gimp_item_get_id       (GimpItem    *item);
 GimpItem    * gimp_item_new_by_id    (gint32       item_id);
 
+#ifndef GIMP_DEPRECATED_REPLACE_NEW_API
+
+GList       * gimp_item_get_children (GimpItem     *item);
+
+#else /* GIMP_DEPRECATED_REPLACE_NEW_API */
+
+#define gimp_item_get_children gimp_item_get_children_deprecated
+
+#endif /* GIMP_DEPRECATED_REPLACE_NEW_API */
+
+
+gint        * gimp_item_get_children_deprecated (gint32  item_id,
+                                                 gint   *num_children);
+
 
 G_END_DECLS
 
diff --git a/libgimp/gimpitem_pdb.c b/libgimp/gimpitem_pdb.c
index dfa4809d4f..c9d698bca2 100644
--- a/libgimp/gimpitem_pdb.c
+++ b/libgimp/gimpitem_pdb.c
@@ -1029,7 +1029,7 @@ _gimp_item_get_parent (gint32 item_ID)
 }
 
 /**
- * gimp_item_get_children:
+ * _gimp_item_get_children:
  * @item: The item.
  * @num_children: (out): The item's number of children.
  *
@@ -1045,8 +1045,8 @@ _gimp_item_get_parent (gint32 item_ID)
  * Since: 2.8
  **/
 gint *
-gimp_item_get_children (GimpItem *item,
-                        gint     *num_children)
+_gimp_item_get_children (GimpItem *item,
+                         gint     *num_children)
 {
   GimpPDB        *pdb = gimp_get_pdb ();
   GimpValueArray *args;
@@ -1079,56 +1079,6 @@ gimp_item_get_children (GimpItem *item,
   return child_ids;
 }
 
-/**
- * _gimp_item_get_children: (skip)
- * @item_ID: The item.
- * @num_children: (out): The item's number of children.
- *
- * Returns the item's list of children.
- *
- * This procedure returns the list of items which are children of the
- * specified item. The order is topmost to bottommost.
- *
- * Returns: (array length=num_children): The item's list of children.
- *          The returned value must be freed with g_free().
- *
- * Since: 2.8
- **/
-gint *
-_gimp_item_get_children (gint32  item_ID,
-                         gint   *num_children)
-{
-  GimpPDB        *pdb = gimp_get_pdb ();
-  GimpValueArray *args;
-  GimpValueArray *return_vals;
-  gint *child_ids = NULL;
-
-  args = gimp_value_array_new_from_types (NULL,
-                                          GIMP_TYPE_ITEM_ID, item_ID,
-                                          G_TYPE_NONE);
-
-  if (pdb)
-    return_vals = gimp_pdb_run_procedure_array (pdb,
-                                                "gimp-item-get-children",
-                                                args);
-  else
-    return_vals = gimp_run_procedure_array ("gimp-item-get-children",
-                                            args);
-  gimp_value_array_unref (args);
-
-  *num_children = 0;
-
-  if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
-    {
-      *num_children = g_value_get_int (gimp_value_array_index (return_vals, 1));
-      child_ids = gimp_value_dup_int32_array (gimp_value_array_index (return_vals, 2));
-    }
-
-  gimp_value_array_unref (return_vals);
-
-  return child_ids;
-}
-
 /**
  * gimp_item_get_expanded:
  * @item: The item.
diff --git a/libgimp/gimpitem_pdb.h b/libgimp/gimpitem_pdb.h
index a76f797dda..4ed8a2ea98 100644
--- a/libgimp/gimpitem_pdb.h
+++ b/libgimp/gimpitem_pdb.h
@@ -36,52 +36,52 @@ G_BEGIN_DECLS
 
 #ifndef GIMP_DEPRECATED_REPLACE_NEW_API
 
-gboolean      gimp_item_is_valid          (GimpItem           *item);
-GimpImage*    gimp_item_get_image         (GimpItem           *item);
-gboolean      gimp_item_delete            (GimpItem           *item);
-gboolean      gimp_item_is_drawable       (GimpItem           *item);
-gboolean      gimp_item_is_layer          (GimpItem           *item);
-gboolean      gimp_item_is_text_layer     (GimpItem           *item);
-gboolean      gimp_item_is_channel        (GimpItem           *item);
-gboolean      gimp_item_is_layer_mask     (GimpItem           *item);
-gboolean      gimp_item_is_selection      (GimpItem           *item);
-gboolean      gimp_item_is_vectors        (GimpItem           *item);
-gboolean      gimp_item_is_group          (GimpItem           *item);
-GimpItem*     gimp_item_get_parent        (GimpItem           *item);
-gint*         gimp_item_get_children      (GimpItem           *item,
-                                           gint               *num_children);
-gboolean      gimp_item_get_expanded      (GimpItem           *item);
-gboolean      gimp_item_set_expanded      (GimpItem           *item,
-                                           gboolean            expanded);
-gchar*        gimp_item_get_name          (GimpItem           *item);
-gboolean      gimp_item_set_name          (GimpItem           *item,
-                                           const gchar        *name);
-gboolean      gimp_item_get_visible       (GimpItem           *item);
-gboolean      gimp_item_set_visible       (GimpItem           *item,
-                                           gboolean            visible);
-gboolean      gimp_item_get_linked        (GimpItem           *item);
-gboolean      gimp_item_set_linked        (GimpItem           *item,
-                                           gboolean            linked);
-gboolean      gimp_item_get_lock_content  (GimpItem           *item);
-gboolean      gimp_item_set_lock_content  (GimpItem           *item,
-                                           gboolean            lock_content);
-gboolean      gimp_item_get_lock_position (GimpItem           *item);
-gboolean      gimp_item_set_lock_position (GimpItem           *item,
-                                           gboolean            lock_position);
-GimpColorTag  gimp_item_get_color_tag     (GimpItem           *item);
-gboolean      gimp_item_set_color_tag     (GimpItem           *item,
-                                           GimpColorTag        color_tag);
-guint         gimp_item_get_tattoo        (GimpItem           *item);
-gboolean      gimp_item_set_tattoo        (GimpItem           *item,
-                                           guint               tattoo);
-gboolean      gimp_item_attach_parasite   (GimpItem           *item,
-                                           const GimpParasite *parasite);
-gboolean      gimp_item_detach_parasite   (GimpItem           *item,
-                                           const gchar        *name);
-GimpParasite* gimp_item_get_parasite      (GimpItem           *item,
-                                           const gchar        *name);
-gchar**       gimp_item_get_parasite_list (GimpItem           *item,
-                                           gint               *num_parasites);
+gboolean              gimp_item_is_valid          (GimpItem           *item);
+GimpImage*            gimp_item_get_image         (GimpItem           *item);
+gboolean              gimp_item_delete            (GimpItem           *item);
+gboolean              gimp_item_is_drawable       (GimpItem           *item);
+gboolean              gimp_item_is_layer          (GimpItem           *item);
+gboolean              gimp_item_is_text_layer     (GimpItem           *item);
+gboolean              gimp_item_is_channel        (GimpItem           *item);
+gboolean              gimp_item_is_layer_mask     (GimpItem           *item);
+gboolean              gimp_item_is_selection      (GimpItem           *item);
+gboolean              gimp_item_is_vectors        (GimpItem           *item);
+gboolean              gimp_item_is_group          (GimpItem           *item);
+GimpItem*             gimp_item_get_parent        (GimpItem           *item);
+G_GNUC_INTERNAL gint* _gimp_item_get_children     (GimpItem           *item,
+                                                   gint               *num_children);
+gboolean              gimp_item_get_expanded      (GimpItem           *item);
+gboolean              gimp_item_set_expanded      (GimpItem           *item,
+                                                   gboolean            expanded);
+gchar*                gimp_item_get_name          (GimpItem           *item);
+gboolean              gimp_item_set_name          (GimpItem           *item,
+                                                   const gchar        *name);
+gboolean              gimp_item_get_visible       (GimpItem           *item);
+gboolean              gimp_item_set_visible       (GimpItem           *item,
+                                                   gboolean            visible);
+gboolean              gimp_item_get_linked        (GimpItem           *item);
+gboolean              gimp_item_set_linked        (GimpItem           *item,
+                                                   gboolean            linked);
+gboolean              gimp_item_get_lock_content  (GimpItem           *item);
+gboolean              gimp_item_set_lock_content  (GimpItem           *item,
+                                                   gboolean            lock_content);
+gboolean              gimp_item_get_lock_position (GimpItem           *item);
+gboolean              gimp_item_set_lock_position (GimpItem           *item,
+                                                   gboolean            lock_position);
+GimpColorTag          gimp_item_get_color_tag     (GimpItem           *item);
+gboolean              gimp_item_set_color_tag     (GimpItem           *item,
+                                                   GimpColorTag        color_tag);
+guint                 gimp_item_get_tattoo        (GimpItem           *item);
+gboolean              gimp_item_set_tattoo        (GimpItem           *item,
+                                                   guint               tattoo);
+gboolean              gimp_item_attach_parasite   (GimpItem           *item,
+                                                   const GimpParasite *parasite);
+gboolean              gimp_item_detach_parasite   (GimpItem           *item,
+                                                   const gchar        *name);
+GimpParasite*         gimp_item_get_parasite      (GimpItem           *item,
+                                                   const gchar        *name);
+gchar**               gimp_item_get_parasite_list (GimpItem           *item,
+                                                   gint               *num_parasites);
 
 #else /* GIMP_DEPRECATED_REPLACE_NEW_API */
 
@@ -97,7 +97,6 @@ gchar**       gimp_item_get_parasite_list (GimpItem           *item,
 #define gimp_item_is_vectors _gimp_item_is_vectors
 #define gimp_item_is_group _gimp_item_is_group
 #define gimp_item_get_parent _gimp_item_get_parent
-#define gimp_item_get_children _gimp_item_get_children
 #define gimp_item_get_expanded _gimp_item_get_expanded
 #define gimp_item_set_expanded _gimp_item_set_expanded
 #define gimp_item_get_name _gimp_item_get_name
@@ -138,8 +137,6 @@ gboolean      _gimp_item_is_selection      (gint32              item_ID);
 gboolean      _gimp_item_is_vectors        (gint32              item_ID);
 gboolean      _gimp_item_is_group          (gint32              item_ID);
 gint32        _gimp_item_get_parent        (gint32              item_ID);
-gint*         _gimp_item_get_children      (gint32              item_ID,
-                                            gint               *num_children);
 gboolean      _gimp_item_get_expanded      (gint32              item_ID);
 gboolean      _gimp_item_set_expanded      (gint32              item_ID,
                                             gboolean            expanded);
diff --git a/libgimp/gimpitemcombobox.c b/libgimp/gimpitemcombobox.c
index 758afba3ce..397a040d67 100644
--- a/libgimp/gimpitemcombobox.c
+++ b/libgimp/gimpitemcombobox.c
@@ -119,8 +119,7 @@ static void  gimp_item_combo_box_populate  (GimpIntComboBox            *combo_bo
 static void  gimp_item_combo_box_model_add (GimpIntComboBox            *combo_box,
                                             GtkListStore               *store,
                                             GimpImage                  *image,
-                                            gint                        num_items,
-                                            gint32                     *items,
+                                            GList                      *items,
                                             gint                        tree_level);
 
 static void  gimp_item_combo_box_drag_data_received (GtkWidget         *widget,
@@ -389,52 +388,46 @@ gimp_item_combo_box_populate (GimpIntComboBox *combo_box)
 {
   GtkTreeModel *model;
   GtkTreeIter   iter;
-  gint32       *images;
-  gint          num_images;
-  gint          i;
+  GList        *images;
+  GList        *list;
 
   model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
 
-  images = gimp_image_list (&num_images);
+  images = gimp_image_list ();
 
-  for (i = 0; i < num_images; i++)
+  for (list = images; list; list = list->next)
     {
-      GimpImage *image;
-      gint32    *items;
-      gint       num_items;
-
-      image = gimp_image_new_by_id (images[i]);
+      GimpImage *image = list->data;
+      GList     *items;
 
       if (GIMP_IS_DRAWABLE_COMBO_BOX (combo_box) ||
           GIMP_IS_LAYER_COMBO_BOX (combo_box))
         {
-          items = gimp_image_get_layers (image, &num_items);
+          items = gimp_image_get_layers (image);
           gimp_item_combo_box_model_add (combo_box, GTK_LIST_STORE (model),
-                                         image, num_items, items, 0);
-          g_free (items);
+                                         image, items, 0);
+          g_list_free_full (items, g_object_unref);
         }
 
       if (GIMP_IS_DRAWABLE_COMBO_BOX (combo_box) ||
           GIMP_IS_CHANNEL_COMBO_BOX (combo_box))
         {
-          items = gimp_image_get_channels (image, &num_items);
+          items = gimp_image_get_channels (image);
           gimp_item_combo_box_model_add (combo_box, GTK_LIST_STORE (model),
-                                         image, num_items, items, 0);
-          g_free (items);
+                                         image, items, 0);
+          g_list_free_full (items, g_object_unref);
         }
 
       if (GIMP_IS_VECTORS_COMBO_BOX (combo_box))
         {
-          items = gimp_image_get_vectors (image, &num_items);
+          items = gimp_image_get_vectors (image);
           gimp_item_combo_box_model_add (combo_box, GTK_LIST_STORE (model),
-                                         image, num_items, items, 0);
-          g_free (items);
+                                         image, items, 0);
+          g_list_free_full (items, g_object_unref);
         }
-
-      g_object_unref (image);
     }
 
-  g_free (images);
+  g_list_free_full (images, g_object_unref);
 
   if (gtk_tree_model_get_iter_first (model, &iter))
     gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
@@ -444,13 +437,12 @@ static void
 gimp_item_combo_box_model_add (GimpIntComboBox *combo_box,
                                GtkListStore    *store,
                                GimpImage       *image,
-                               gint             num_items,
-                               gint32          *items,
+                               GList           *items,
                                gint             tree_level)
 {
   GimpItemComboBoxPrivate *private = GET_PRIVATE (combo_box);
   GtkTreeIter              iter;
-  gint                     i;
+  GList                   *list;
   gchar                   *indent;
 
   if (tree_level > 0)
@@ -465,13 +457,14 @@ gimp_item_combo_box_model_add (GimpIntComboBox *combo_box,
       indent = g_strdup ("");
     }
 
-  for (i = 0; i < num_items; i++)
+  for (list = items; list; list = list->next)
     {
-      GimpItem *item = gimp_item_new_by_id (items[i]);
+      GimpItem *item    = list->data;
+      gint32    item_id = gimp_item_get_id (item);
 
       if ((! private->constraint && ! private->constraint_d)                                ||
-          (private->constraint && (* private->constraint) (image, items[i], private->data)) ||
-          (private->constraint_d && (* private->constraint_d) (gimp_image_get_id (image), items[i], 
private->data)))
+          (private->constraint && (* private->constraint) (image, item, private->data)) ||
+          (private->constraint_d && (* private->constraint_d) (gimp_image_get_id (image), item_id, 
private->data)))
         {
           gchar     *image_name = gimp_image_get_name (image);
           gchar     *item_name  = gimp_item_get_name (item);
@@ -481,7 +474,7 @@ gimp_item_combo_box_model_add (GimpIntComboBox *combo_box,
           label = g_strdup_printf ("%s%s-%d / %s-%d",
                                    indent, image_name,
                                    gimp_image_get_id (image),
-                                   item_name, items[i]);
+                                   item_name, item_id);
 
           g_free (item_name);
           g_free (image_name);
@@ -495,7 +488,7 @@ gimp_item_combo_box_model_add (GimpIntComboBox *combo_box,
 
           gtk_list_store_append (store, &iter);
           gtk_list_store_set (store, &iter,
-                              GIMP_INT_STORE_VALUE,  items[i],
+                              GIMP_INT_STORE_VALUE,  item_id,
                               GIMP_INT_STORE_LABEL,  label,
                               GIMP_INT_STORE_PIXBUF, thumb,
                               -1);
@@ -508,18 +501,14 @@ gimp_item_combo_box_model_add (GimpIntComboBox *combo_box,
 
       if (gimp_item_is_group (item))
         {
-          gint32 *children;
-          gint    n_children;
+          GList *children;
 
-          children = gimp_item_get_children (item, &n_children);
+          children = gimp_item_get_children (item);
           gimp_item_combo_box_model_add (combo_box, store,
-                                         image,
-                                         n_children, children,
+                                         image, children,
                                          tree_level + 1);
-          g_free (children);
+          g_list_free_full (children, g_object_unref);
         }
-
-      g_object_unref (item);
     }
 
   g_free (indent);
diff --git a/libgimp/gimpitemcombobox.h b/libgimp/gimpitemcombobox.h
index f5b92527b5..907ab5ccfd 100644
--- a/libgimp/gimpitemcombobox.h
+++ b/libgimp/gimpitemcombobox.h
@@ -58,7 +58,7 @@ GType       gimp_vectors_combo_box_get_type  (void) G_GNUC_CONST;
 #ifndef GIMP_DEPRECATED_REPLACE_NEW_API
 
 typedef gboolean (* GimpItemConstraintFunc) (GimpImage *image,
-                                             gint32     item_id,
+                                             GimpItem  *item,
                                              gpointer   data);
 
 GtkWidget * gimp_drawable_combo_box_new (GimpItemConstraintFunc constraint,
diff --git a/pdb/groups/image.pdb b/pdb/groups/image.pdb
index 90bdbefe21..da70000175 100644
--- a/pdb/groups/image.pdb
+++ b/pdb/groups/image.pdb
@@ -53,6 +53,7 @@ This procedure returns the list of images currently open in GIMP.
 HELP
 
     &std_pdb_misc;
+    $lib_private = 1;
 
     @outargs = (
         { name => 'image_ids', type => 'int32array',
@@ -246,6 +247,7 @@ The order of layers is from topmost to bottommost.
 HELP
 
     &std_pdb_misc;
+    $lib_private = 1;
 
     @inargs = (
         { name => 'image', type => 'image',
@@ -291,6 +293,7 @@ include the image's color components.
 HELP
 
     &std_pdb_misc;
+    $lib_private = 1;
 
     @inargs = (
         { name => 'image', type => 'image',
@@ -333,6 +336,7 @@ This procedure returns the list of vectors contained in the specified image.
 HELP
 
     &simon_pdb_misc('2005', '2.4');
+    $lib_private = 1;
 
     @inargs = (
         { name => 'image', type => 'image',
diff --git a/pdb/groups/item.pdb b/pdb/groups/item.pdb
index 37f2e11e91..a19aa0051c 100644
--- a/pdb/groups/item.pdb
+++ b/pdb/groups/item.pdb
@@ -375,6 +375,7 @@ item. The order is topmost to bottommost.
 HELP
 
     &mitch_pdb_misc('2010', '2.8');
+    $lib_private = 1;
 
     @inargs = (
        { name => 'item', type => 'item',


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