[gimp] app: merge the layer, channel and vectors repositioning APIs



commit 314a6ab92674595f5aea8736154a7a6dce639681
Author: Michael Natterer <mitch gimp org>
Date:   Thu Jul 8 18:08:13 2010 +0200

    app: merge the layer, channel and vectors repositioning APIs
    
    into an API based on GimpItem.

 app/actions/channels-commands.c   |    8 +-
 app/actions/layers-commands.c     |    8 +-
 app/actions/vectors-commands.c    |    8 +-
 app/core/gimpchannel.c            |    7 +
 app/core/gimpimage.c              |  431 +++++++++++--------------------------
 app/core/gimpimage.h              |   68 ++-----
 app/core/gimpitem.h               |    9 +
 app/core/gimplayer.c              |    7 +
 app/pdb/image-cmds.c              |   20 +-
 app/vectors/gimpvectors.c         |    7 +
 app/widgets/gimpchanneltreeview.c |    2 -
 app/widgets/gimpitemtreeview.c    |   14 +-
 app/widgets/gimpitemtreeview.h    |   10 -
 app/widgets/gimplayertreeview.c   |    2 -
 app/widgets/gimpvectorstreeview.c |    2 -
 tools/pdbgen/pdb/image.pdb        |   20 +-
 16 files changed, 205 insertions(+), 418 deletions(-)
---
diff --git a/app/actions/channels-commands.c b/app/actions/channels-commands.c
index b6234f7..150c584 100644
--- a/app/actions/channels-commands.c
+++ b/app/actions/channels-commands.c
@@ -181,7 +181,7 @@ channels_raise_cmd_callback (GtkAction *action,
   GimpChannel *channel;
   return_if_no_channel (image, channel, data);
 
-  gimp_image_raise_channel (image, channel, NULL);
+  gimp_image_raise_item (image, GIMP_ITEM (channel), NULL);
   gimp_image_flush (image);
 }
 
@@ -193,7 +193,7 @@ channels_raise_to_top_cmd_callback (GtkAction *action,
   GimpChannel *channel;
   return_if_no_channel (image, channel, data);
 
-  gimp_image_raise_channel_to_top (image, channel);
+  gimp_image_raise_item_to_top (image, GIMP_ITEM (channel));
   gimp_image_flush (image);
 }
 
@@ -205,7 +205,7 @@ channels_lower_cmd_callback (GtkAction *action,
   GimpChannel *channel;
   return_if_no_channel (image, channel, data);
 
-  gimp_image_lower_channel (image, channel, NULL);
+  gimp_image_lower_item (image, GIMP_ITEM (channel), NULL);
   gimp_image_flush (image);
 }
 
@@ -217,7 +217,7 @@ channels_lower_to_bottom_cmd_callback (GtkAction *action,
   GimpChannel *channel;
   return_if_no_channel (image, channel, data);
 
-  gimp_image_lower_channel_to_bottom (image, channel);
+  gimp_image_lower_item_to_bottom (image, GIMP_ITEM (channel));
   gimp_image_flush (image);
 }
 
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index 5616e36..ff1b948 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -416,7 +416,7 @@ layers_raise_cmd_callback (GtkAction *action,
   GimpLayer *layer;
   return_if_no_layer (image, layer, data);
 
-  gimp_image_raise_layer (image, layer, NULL);
+  gimp_image_raise_item (image, GIMP_ITEM (layer), NULL);
   gimp_image_flush (image);
 }
 
@@ -428,7 +428,7 @@ layers_raise_to_top_cmd_callback (GtkAction *action,
   GimpLayer *layer;
   return_if_no_layer (image, layer, data);
 
-  gimp_image_raise_layer_to_top (image, layer);
+  gimp_image_raise_item_to_top (image, GIMP_ITEM (layer));
   gimp_image_flush (image);
 }
 
@@ -440,7 +440,7 @@ layers_lower_cmd_callback (GtkAction *action,
   GimpLayer *layer;
   return_if_no_layer (image, layer, data);
 
-  gimp_image_lower_layer (image, layer, NULL);
+  gimp_image_lower_item (image, GIMP_ITEM (layer), NULL);
   gimp_image_flush (image);
 }
 
@@ -452,7 +452,7 @@ layers_lower_to_bottom_cmd_callback (GtkAction *action,
   GimpLayer *layer;
   return_if_no_layer (image, layer, data);
 
-  gimp_image_lower_layer_to_bottom (image, layer);
+  gimp_image_lower_item_to_bottom (image, GIMP_ITEM (layer));
   gimp_image_flush (image);
 }
 
diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c
index 29bf4c4..be13aa8 100644
--- a/app/actions/vectors-commands.c
+++ b/app/actions/vectors-commands.c
@@ -200,7 +200,7 @@ vectors_raise_cmd_callback (GtkAction *action,
   GimpVectors *vectors;
   return_if_no_vectors (image, vectors, data);
 
-  gimp_image_raise_vectors (image, vectors, NULL);
+  gimp_image_raise_item (image, GIMP_ITEM (vectors), NULL);
   gimp_image_flush (image);
 }
 
@@ -212,7 +212,7 @@ vectors_raise_to_top_cmd_callback (GtkAction *action,
   GimpVectors *vectors;
   return_if_no_vectors (image, vectors, data);
 
-  gimp_image_raise_vectors_to_top (image, vectors);
+  gimp_image_raise_item_to_top (image, GIMP_ITEM (vectors));
   gimp_image_flush (image);
 }
 
@@ -224,7 +224,7 @@ vectors_lower_cmd_callback (GtkAction *action,
   GimpVectors *vectors;
   return_if_no_vectors (image, vectors, data);
 
-  gimp_image_lower_vectors (image, vectors, NULL);
+  gimp_image_lower_item (image, GIMP_ITEM (vectors), NULL);
   gimp_image_flush (image);
 }
 
@@ -236,7 +236,7 @@ vectors_lower_to_bottom_cmd_callback (GtkAction *action,
   GimpVectors *vectors;
   return_if_no_vectors (image, vectors, data);
 
-  gimp_image_lower_vectors_to_bottom (image, vectors);
+  gimp_image_lower_item_to_bottom (image, GIMP_ITEM (vectors));
   gimp_image_flush (image);
 }
 
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index 1edd468..1328071 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -269,6 +269,13 @@ gimp_channel_class_init (GimpChannelClass *klass)
   item_class->rotate_desc          = C_("undo-type", "Rotate Channel");
   item_class->transform_desc       = C_("undo-type", "Transform Channel");
   item_class->stroke_desc          = C_("undo-type", "Stroke Channel");
+  item_class->reorder_desc         = C_("undo-type", "Reorder Channel");
+  item_class->raise_desc           = C_("undo-type", "Raise Channel");
+  item_class->raise_to_top_desc    = C_("undo-type", "Raise Channel to Top");
+  item_class->lower_desc           = C_("undo-type", "Lower Channel");
+  item_class->lower_to_bottom_desc = C_("undo-type", "Lower Channel to Bottom");
+  item_class->raise_failed         = _("Channel cannot be raised higher.");
+  item_class->lower_failed         = _("Channel cannot be lowered more.");
 
   drawable_class->invalidate_boundary   = gimp_channel_invalidate_boundary;
   drawable_class->get_active_components = gimp_channel_get_active_components;
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index bf114ba..c67bf80 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -3246,6 +3246,127 @@ gimp_image_get_vectors_by_name (const GimpImage *image,
 }
 
 
+/*  items  */
+
+gboolean
+gimp_image_reorder_item (GimpImage   *image,
+                         GimpItem    *item,
+                         GimpItem    *new_parent,
+                         gint         new_index,
+                         gboolean     push_undo,
+                         const gchar *undo_desc)
+{
+  GimpItemTree *tree;
+
+  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
+  g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
+  g_return_val_if_fail (gimp_item_get_image (item) == image, FALSE);
+
+  tree = gimp_item_get_tree (item);
+
+  g_return_val_if_fail (tree != NULL, FALSE);
+
+  if (push_undo && ! undo_desc)
+    undo_desc = GIMP_ITEM_GET_CLASS (item)->reorder_desc;
+
+  /*  item and new_parent are type-checked in GimpItemTree
+   */
+  return gimp_item_tree_reorder_item (tree, item,
+                                      new_parent, new_index,
+                                      push_undo, undo_desc);
+}
+
+gboolean
+gimp_image_raise_item (GimpImage *image,
+                       GimpItem  *item,
+                       GError    **error)
+{
+  gint index;
+
+  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
+  g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
+  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+  index = gimp_item_get_index (item);
+
+  g_return_val_if_fail (index != -1, FALSE);
+
+  if (index == 0)
+    {
+      g_set_error_literal (error,  GIMP_ERROR, GIMP_FAILED,
+			   GIMP_ITEM_GET_CLASS (item)->raise_failed);
+      return FALSE;
+    }
+
+  return gimp_image_reorder_item (image, item,
+                                  gimp_item_get_parent (item), index - 1,
+                                  TRUE, GIMP_ITEM_GET_CLASS (item)->raise_desc);
+}
+
+gboolean
+gimp_image_raise_item_to_top (GimpImage *image,
+                              GimpItem  *item)
+{
+  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
+  g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
+
+  return gimp_image_reorder_item (image, item,
+                                  gimp_item_get_parent (item), 0,
+                                  TRUE, GIMP_ITEM_GET_CLASS (item)->raise_to_top_desc);
+}
+
+gboolean
+gimp_image_lower_item (GimpImage *image,
+                       GimpItem  *item,
+                       GError    **error)
+{
+  GimpContainer *container;
+  gint           index;
+
+  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
+  g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
+  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+  container = gimp_item_get_container (item);
+
+  g_return_val_if_fail (container != NULL, FALSE);
+
+  index = gimp_item_get_index (item);
+
+  if (index == gimp_container_get_n_children (container) - 1)
+    {
+      g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
+			   GIMP_ITEM_GET_CLASS (item)->lower_failed);
+      return FALSE;
+    }
+
+  return gimp_image_reorder_item (image, item,
+                                  gimp_item_get_parent (item), index + 1,
+                                  TRUE, GIMP_ITEM_GET_CLASS (item)->lower_desc);
+}
+
+gboolean
+gimp_image_lower_item_to_bottom (GimpImage *image,
+                                  GimpItem *item)
+{
+  GimpContainer *container;
+  gint           length;
+
+  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
+  g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
+
+  container = gimp_item_get_container (item);
+
+  g_return_val_if_fail (container != NULL, FALSE);
+
+  length = gimp_container_get_n_children (container);
+
+  return gimp_image_reorder_item (image, item,
+                                  gimp_item_get_parent (item), length - 1,
+                                  TRUE, GIMP_ITEM_GET_CLASS (item)->lower_to_bottom_desc);
+}
+
+
 /*  layers  */
 
 gboolean
@@ -3484,109 +3605,6 @@ gimp_image_add_layers (GimpImage   *image,
   gimp_image_undo_group_end (image);
 }
 
-gboolean
-gimp_image_raise_layer (GimpImage  *image,
-                        GimpLayer  *layer,
-                        GError    **error)
-{
-  gint index;
-
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-  g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
-  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
-  index = gimp_item_get_index (GIMP_ITEM (layer));
-
-  if (index == 0)
-    {
-      g_set_error_literal (error,  GIMP_ERROR, GIMP_FAILED,
-			   _("Layer cannot be raised higher."));
-      return FALSE;
-    }
-
-  return gimp_image_reorder_layer (image, layer,
-                                   gimp_layer_get_parent (layer), index - 1,
-                                   TRUE, C_("undo-type", "Raise Layer"));
-}
-
-gboolean
-gimp_image_raise_layer_to_top (GimpImage *image,
-                               GimpLayer *layer)
-{
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-  g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
-
-  return gimp_image_reorder_layer (image, layer,
-                                   gimp_layer_get_parent (layer), 0,
-                                   TRUE, C_("undo-type", "Raise Layer to Top"));
-}
-
-gboolean
-gimp_image_lower_layer (GimpImage  *image,
-                        GimpLayer  *layer,
-                        GError    **error)
-{
-  GimpContainer *container;
-  gint           index;
-
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-  g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
-  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
-  container = gimp_item_get_container (GIMP_ITEM (layer));
-
-  index = gimp_item_get_index (GIMP_ITEM (layer));
-
-  if (index == gimp_container_get_n_children (container) - 1)
-    {
-      g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
-			   _("Layer cannot be lowered more."));
-      return FALSE;
-    }
-
-  return gimp_image_reorder_layer (image, layer,
-                                   gimp_layer_get_parent (layer), index + 1,
-                                   TRUE, C_("undo-type", "Lower Layer"));
-}
-
-gboolean
-gimp_image_lower_layer_to_bottom (GimpImage *image,
-                                  GimpLayer *layer)
-{
-  GimpContainer *container;
-  gint           length;
-
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-  g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
-
-  container = gimp_item_get_container (GIMP_ITEM (layer));
-
-  length = gimp_container_get_n_children (container);
-
-  return gimp_image_reorder_layer (image, layer,
-                                   gimp_layer_get_parent (layer), length - 1,
-                                   TRUE, C_("undo-type", "Lower Layer to Bottom"));
-}
-
-gboolean
-gimp_image_reorder_layer (GimpImage   *image,
-                          GimpLayer   *layer,
-                          GimpLayer   *new_parent,
-                          gint         new_index,
-                          gboolean     push_undo,
-                          const gchar *undo_desc)
-{
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-
-  /*  item and new_parent are type-checked in GimpItemTree
-   */
-  return gimp_item_tree_reorder_item (GIMP_IMAGE_GET_PRIVATE (image)->layers,
-                                      (GimpItem *) layer,
-                                      (GimpItem *) new_parent,
-                                      new_index,
-                                      push_undo, undo_desc);
-}
-
 
 /*  channels  */
 
@@ -3684,110 +3702,6 @@ gimp_image_remove_channel (GimpImage   *image,
     gimp_image_undo_group_end (image);
 }
 
-gboolean
-gimp_image_raise_channel (GimpImage    *image,
-                          GimpChannel  *channel,
-                          GError      **error)
-{
-  gint index;
-
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-  g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE);
-  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
-  index = gimp_item_get_index (GIMP_ITEM (channel));
-
-  if (index == 0)
-    {
-      g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
-			   _("Channel cannot be raised higher."));
-      return FALSE;
-    }
-
-  return gimp_image_reorder_channel (image, channel,
-                                     gimp_channel_get_parent (channel), index - 1,
-                                     TRUE, C_("undo-type", "Raise Channel"));
-}
-
-gboolean
-gimp_image_raise_channel_to_top (GimpImage   *image,
-                                 GimpChannel *channel)
-{
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-  g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE);
-
-  return gimp_image_reorder_channel (image, channel,
-                                     gimp_channel_get_parent (channel), 0,
-                                     TRUE, C_("undo-type", "Raise Channel to Top"));
-}
-
-
-gboolean
-gimp_image_lower_channel (GimpImage    *image,
-                          GimpChannel  *channel,
-                          GError      **error)
-{
-  GimpContainer *container;
-  gint           index;
-
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-  g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE);
-  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
-  container = gimp_item_get_container (GIMP_ITEM (channel));
-
-  index = gimp_item_get_index (GIMP_ITEM (channel));
-
-  if (index == gimp_container_get_n_children (container) - 1)
-    {
-      g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
-			   _("Channel cannot be lowered more."));
-      return FALSE;
-    }
-
-  return gimp_image_reorder_channel (image, channel,
-                                     gimp_channel_get_parent (channel), index + 1,
-                                     TRUE, C_("undo-type", "Lower Channel"));
-}
-
-gboolean
-gimp_image_lower_channel_to_bottom (GimpImage   *image,
-                                    GimpChannel *channel)
-{
-  GimpContainer *container;
-  gint           length;
-
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-  g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE);
-
-  container = gimp_item_get_container (GIMP_ITEM (channel));
-
-  length = gimp_container_get_n_children (container);
-
-  return gimp_image_reorder_channel (image, channel,
-                                     gimp_channel_get_parent (channel), length - 1,
-                                     TRUE, C_("undo-type", "Lower Channel to Bottom"));
-}
-
-gboolean
-gimp_image_reorder_channel (GimpImage   *image,
-                            GimpChannel *channel,
-                            GimpChannel *new_parent,
-                            gint         new_index,
-                            gboolean     push_undo,
-                            const gchar *undo_desc)
-{
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-
-  /*  item and new_parent are type-checked in GimpItemTree
-   */
-  return gimp_item_tree_reorder_item (GIMP_IMAGE_GET_PRIVATE (image)->channels,
-                                      (GimpItem *) channel,
-                                      (GimpItem *) new_parent,
-                                      new_index,
-                                      push_undo, undo_desc);
-}
-
 
 /*  vectors  */
 
@@ -3859,109 +3773,6 @@ gimp_image_remove_vectors (GimpImage   *image,
 }
 
 gboolean
-gimp_image_raise_vectors (GimpImage    *image,
-                          GimpVectors  *vectors,
-                          GError      **error)
-{
-  gint index;
-
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-  g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
-  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
-  index = gimp_item_get_index (GIMP_ITEM (vectors));
-
-  if (index == 0)
-    {
-      g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
-			   _("Path cannot be raised higher."));
-      return FALSE;
-    }
-
-  return gimp_image_reorder_vectors (image, vectors,
-                                     gimp_vectors_get_parent (vectors), index - 1,
-                                     TRUE, C_("undo-type", "Raise Path"));
-}
-
-gboolean
-gimp_image_raise_vectors_to_top (GimpImage   *image,
-                                 GimpVectors *vectors)
-{
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-  g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
-
-  return gimp_image_reorder_vectors (image, vectors,
-                                     gimp_vectors_get_parent (vectors), 0,
-                                     TRUE, C_("undo-type", "Raise Path to Top"));
-}
-
-gboolean
-gimp_image_lower_vectors (GimpImage    *image,
-                          GimpVectors  *vectors,
-                          GError      **error)
-{
-  GimpContainer *container;
-  gint           index;
-
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-  g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
-  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
-  container = gimp_item_get_container (GIMP_ITEM (vectors));
-
-  index = gimp_item_get_index (GIMP_ITEM (vectors));
-
-  if (index == gimp_container_get_n_children (container) - 1)
-    {
-      g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
-			   _("Path cannot be lowered more."));
-      return FALSE;
-    }
-
-  return gimp_image_reorder_vectors (image, vectors,
-                                     gimp_vectors_get_parent (vectors), index + 1,
-                                     TRUE, C_("undo-type", "Lower Path"));
-}
-
-gboolean
-gimp_image_lower_vectors_to_bottom (GimpImage   *image,
-                                    GimpVectors *vectors)
-{
-  GimpContainer *container;
-  gint           length;
-
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-  g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
-
-  container = gimp_item_get_container (GIMP_ITEM (vectors));
-
-  length = gimp_container_get_n_children (container);
-
-  return gimp_image_reorder_vectors (image, vectors,
-                                     gimp_vectors_get_parent (vectors), length - 1,
-                                     TRUE, C_("undo-type", "Lower Path to Bottom"));
-}
-
-gboolean
-gimp_image_reorder_vectors (GimpImage   *image,
-                            GimpVectors *vectors,
-                            GimpVectors *new_parent,
-                            gint         new_index,
-                            gboolean     push_undo,
-                            const gchar *undo_desc)
-{
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-
-  /*  item and new_parent are type-checked in GimpItemTree
-   */
-  return gimp_item_tree_reorder_item (GIMP_IMAGE_GET_PRIVATE (image)->vectors,
-                                      (GimpItem *) vectors,
-                                      (GimpItem *) new_parent,
-                                      new_index,
-                                      push_undo, undo_desc);
-}
-
-gboolean
 gimp_image_coords_in_active_pickable (GimpImage        *image,
                                       const GimpCoords *coords,
                                       gboolean          sample_merged,
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index a904659..b792623 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -401,6 +401,23 @@ GimpChannel   * gimp_image_get_channel_by_name   (const GimpImage    *image,
 GimpVectors   * gimp_image_get_vectors_by_name   (const GimpImage    *image,
                                                   const gchar        *name);
 
+gboolean        gimp_image_reorder_item          (GimpImage          *image,
+                                                  GimpItem           *item,
+                                                  GimpItem           *new_parent,
+                                                  gint                new_index,
+                                                  gboolean            push_undo,
+                                                  const gchar        *undo_desc);
+gboolean        gimp_image_raise_item            (GimpImage          *image,
+                                                  GimpItem           *item,
+                                                  GError            **error);
+gboolean        gimp_image_raise_item_to_top     (GimpImage          *image,
+                                                  GimpItem           *item);
+gboolean        gimp_image_lower_item            (GimpImage          *image,
+                                                  GimpItem           *item,
+                                                  GError            **error);
+gboolean        gimp_image_lower_item_to_bottom  (GimpImage          *image,
+                                                  GimpItem           *item);
+
 gboolean        gimp_image_add_layer             (GimpImage          *image,
                                                   GimpLayer          *layer,
                                                   GimpLayer          *parent,
@@ -421,23 +438,6 @@ void            gimp_image_add_layers            (GimpImage          *image,
                                                   gint                height,
                                                   const gchar        *undo_desc);
 
-gboolean        gimp_image_raise_layer           (GimpImage          *image,
-                                                  GimpLayer          *layer,
-                                                  GError            **error);
-gboolean        gimp_image_raise_layer_to_top    (GimpImage          *image,
-                                                  GimpLayer          *layer);
-gboolean        gimp_image_lower_layer           (GimpImage          *image,
-                                                  GimpLayer          *layer,
-                                                  GError            **error);
-gboolean        gimp_image_lower_layer_to_bottom (GimpImage          *image,
-                                                  GimpLayer          *layer);
-gboolean        gimp_image_reorder_layer         (GimpImage          *image,
-                                                  GimpLayer          *layer,
-                                                  GimpLayer          *new_parent,
-                                                  gint                new_index,
-                                                  gboolean            push_undo,
-                                                  const gchar        *undo_desc);
-
 gboolean        gimp_image_add_channel           (GimpImage          *image,
                                                   GimpChannel        *channel,
                                                   GimpChannel        *parent,
@@ -448,23 +448,6 @@ void            gimp_image_remove_channel        (GimpImage          *image,
                                                   gboolean            push_undo,
                                                   GimpChannel        *new_active);
 
-gboolean        gimp_image_raise_channel         (GimpImage          *image,
-                                                  GimpChannel        *channel,
-                                                  GError            **error);
-gboolean        gimp_image_raise_channel_to_top  (GimpImage          *image,
-                                                  GimpChannel        *channel);
-gboolean        gimp_image_lower_channel         (GimpImage          *image,
-                                                  GimpChannel        *channel,
-                                                  GError            **error);
-gboolean      gimp_image_lower_channel_to_bottom (GimpImage          *image,
-                                                  GimpChannel        *channel);
-gboolean        gimp_image_reorder_channel       (GimpImage          *image,
-                                                  GimpChannel        *channel,
-                                                  GimpChannel        *new_parent,
-                                                  gint                new_index,
-                                                  gboolean            push_undo,
-                                                  const gchar        *undo_desc);
-
 gboolean        gimp_image_add_vectors           (GimpImage          *image,
                                                   GimpVectors        *vectors,
                                                   GimpVectors        *parent,
@@ -475,23 +458,6 @@ void            gimp_image_remove_vectors        (GimpImage          *image,
                                                   gboolean            push_undo,
                                                   GimpVectors        *new_active);
 
-gboolean        gimp_image_raise_vectors         (GimpImage          *image,
-                                                  GimpVectors        *vectors,
-                                                  GError            **error);
-gboolean        gimp_image_raise_vectors_to_top  (GimpImage          *image,
-                                                  GimpVectors        *vectors);
-gboolean        gimp_image_lower_vectors         (GimpImage          *image,
-                                                  GimpVectors        *vectors,
-                                                  GError            **error);
-gboolean      gimp_image_lower_vectors_to_bottom (GimpImage          *image,
-                                                  GimpVectors        *vectors);
-gboolean        gimp_image_reorder_vectors       (GimpImage          *image,
-                                                  GimpVectors        *vectors,
-                                                  GimpVectors        *new_parent,
-                                                  gint                new_index,
-                                                  gboolean            push_undo,
-                                                  const gchar        *undo_desc);
-
 gboolean    gimp_image_coords_in_active_pickable (GimpImage          *image,
                                                   const GimpCoords   *coords,
                                                   gboolean            sample_merged,
diff --git a/app/core/gimpitem.h b/app/core/gimpitem.h
index 6b01b87..c1a535c 100644
--- a/app/core/gimpitem.h
+++ b/app/core/gimpitem.h
@@ -133,6 +133,15 @@ struct _GimpItemClass
   const gchar *rotate_desc;
   const gchar *transform_desc;
   const gchar *stroke_desc;
+
+  const gchar *reorder_desc;
+  const gchar *raise_desc;
+  const gchar *raise_to_top_desc;
+  const gchar *lower_desc;
+  const gchar *lower_to_bottom_desc;
+
+  const gchar *raise_failed;
+  const gchar *lower_failed;
 };
 
 
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 25f464d..7b242ac 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -262,6 +262,13 @@ gimp_layer_class_init (GimpLayerClass *klass)
   item_class->flip_desc               = C_("undo-type", "Flip Layer");
   item_class->rotate_desc             = C_("undo-type", "Rotate Layer");
   item_class->transform_desc          = C_("undo-type", "Transform Layer");
+  item_class->reorder_desc            = C_("undo-type", "Reorder Layer");
+  item_class->raise_desc              = C_("undo-type", "Raise Layer");
+  item_class->raise_to_top_desc       = C_("undo-type", "Raise Layer to Top");
+  item_class->lower_desc              = C_("undo-type", "Lower Layer");
+  item_class->lower_to_bottom_desc    = C_("undo-type", "Lower Layer to Bottom");
+  item_class->raise_failed            = _("Layer cannot be raised higher.");
+  item_class->lower_failed            = _("Layer cannot be lowered more.");
 
   drawable_class->estimate_memsize      = gimp_layer_estimate_memsize;
   drawable_class->invalidate_boundary   = gimp_layer_invalidate_boundary;
diff --git a/app/pdb/image-cmds.c b/app/pdb/image-cmds.c
index 3f743fb..74816e6 100644
--- a/app/pdb/image-cmds.c
+++ b/app/pdb/image-cmds.c
@@ -1009,7 +1009,7 @@ image_raise_layer_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      success = gimp_image_raise_layer (image, layer, error);
+      success = gimp_image_raise_item (image, GIMP_ITEM (layer), error);
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -1033,7 +1033,7 @@ image_lower_layer_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      success = gimp_image_lower_layer (image, layer, error);
+      success = gimp_image_lower_item (image, GIMP_ITEM (layer), error);
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -1057,7 +1057,7 @@ image_raise_layer_to_top_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      success = gimp_image_raise_layer_to_top (image, layer);
+      success = gimp_image_raise_item_to_top (image, GIMP_ITEM (layer));
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -1081,7 +1081,7 @@ image_lower_layer_to_bottom_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      success = gimp_image_lower_layer_to_bottom (image, layer);
+      success = gimp_image_lower_item_to_bottom (image, GIMP_ITEM (layer));
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -1203,7 +1203,7 @@ image_raise_channel_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      success = gimp_image_raise_channel (image, channel, error);
+      success = gimp_image_raise_item (image, GIMP_ITEM (channel), error);
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -1227,7 +1227,7 @@ image_lower_channel_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      success = gimp_image_lower_channel (image, channel, error);
+      success = gimp_image_lower_item (image, GIMP_ITEM (channel), error);
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -1349,7 +1349,7 @@ image_raise_vectors_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      success = gimp_image_raise_vectors (image, vectors, error);
+      success = gimp_image_raise_item (image, GIMP_ITEM (vectors), error);
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -1373,7 +1373,7 @@ image_lower_vectors_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      success = gimp_image_lower_vectors (image, vectors, error);
+      success = gimp_image_lower_item (image, GIMP_ITEM (vectors), error);
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -1397,7 +1397,7 @@ image_raise_vectors_to_top_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      success = gimp_image_raise_vectors_to_top (image, vectors);
+      success = gimp_image_raise_item_to_top (image, GIMP_ITEM (vectors));
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -1421,7 +1421,7 @@ image_lower_vectors_to_bottom_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      success = gimp_image_lower_vectors_to_bottom (image, vectors);
+      success = gimp_image_lower_item_to_bottom (image, GIMP_ITEM (vectors));
     }
 
   return gimp_procedure_get_return_values (procedure, success,
diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c
index e570217..a2204f3 100644
--- a/app/vectors/gimpvectors.c
+++ b/app/vectors/gimpvectors.c
@@ -200,6 +200,13 @@ gimp_vectors_class_init (GimpVectorsClass *klass)
   item_class->rotate_desc          = _("Rotate Path");
   item_class->transform_desc       = _("Transform Path");
   item_class->stroke_desc          = _("Stroke Path");
+  item_class->reorder_desc         = C_("undo-type", "Reorder Path");
+  item_class->raise_desc           = C_("undo-type", "Raise Path");
+  item_class->raise_to_top_desc    = C_("undo-type", "Raise Path to Top");
+  item_class->lower_desc           = C_("undo-type", "Lower Path");
+  item_class->lower_to_bottom_desc = C_("undo-type", "Lower Path to Bottom");
+  item_class->raise_failed         = _("Path cannot be raised higher.");
+  item_class->lower_failed         = _("Path cannot be lowered more.");
 
   klass->freeze                    = NULL;
   klass->thaw                      = gimp_vectors_real_thaw;
diff --git a/app/widgets/gimpchanneltreeview.c b/app/widgets/gimpchanneltreeview.c
index be6adbc..623a4ef 100644
--- a/app/widgets/gimpchanneltreeview.c
+++ b/app/widgets/gimpchanneltreeview.c
@@ -115,7 +115,6 @@ gimp_channel_tree_view_class_init (GimpChannelTreeViewClass *klass)
   iv_class->get_container    = gimp_image_get_channels;
   iv_class->get_active_item  = (GimpGetItemFunc) gimp_image_get_active_channel;
   iv_class->set_active_item  = (GimpSetItemFunc) gimp_image_set_active_channel;
-  iv_class->reorder_item     = (GimpReorderItemFunc) gimp_image_reorder_channel;
   iv_class->add_item         = (GimpAddItemFunc) gimp_image_add_channel;
   iv_class->remove_item      = (GimpRemoveItemFunc) gimp_image_remove_channel;
   iv_class->new_item         = gimp_channel_tree_view_item_new;
@@ -131,7 +130,6 @@ gimp_channel_tree_view_class_init (GimpChannelTreeViewClass *klass)
   iv_class->lower_bottom_action = "channels-lower-to-bottom";
   iv_class->duplicate_action    = "channels-duplicate";
   iv_class->delete_action       = "channels-delete";
-  iv_class->reorder_desc        = _("Reorder Channel");
 
   g_type_class_add_private (klass, sizeof (GimpChannelTreeViewPriv));
 }
diff --git a/app/widgets/gimpitemtreeview.c b/app/widgets/gimpitemtreeview.c
index 3c5ee0b..57b8230 100644
--- a/app/widgets/gimpitemtreeview.c
+++ b/app/widgets/gimpitemtreeview.c
@@ -250,7 +250,6 @@ gimp_item_tree_view_class_init (GimpItemTreeViewClass *klass)
   klass->get_container           = NULL;
   klass->get_active_item         = NULL;
   klass->set_active_item         = NULL;
-  klass->reorder_item            = NULL;
   klass->add_item                = NULL;
   klass->remove_item             = NULL;
   klass->new_item                = NULL;
@@ -266,8 +265,6 @@ gimp_item_tree_view_class_init (GimpItemTreeViewClass *klass)
   klass->duplicate_action        = NULL;
   klass->delete_action           = NULL;
 
-  klass->reorder_desc            = NULL;
-
   klass->lock_content_stock_id   = NULL;
   klass->lock_content_tooltip    = NULL;
   klass->lock_content_help_id    = NULL;
@@ -1106,12 +1103,11 @@ gimp_item_tree_view_drop_viewable (GimpContainerTreeView   *tree_view,
             dest_index--;
         }
 
-      item_view_class->reorder_item (item_view->priv->image,
-                                     GIMP_ITEM (src_viewable),
-                                     dest_parent,
-                                     dest_index,
-                                     TRUE,
-                                     item_view_class->reorder_desc);
+      gimp_image_reorder_item (item_view->priv->image,
+                               GIMP_ITEM (src_viewable),
+                               dest_parent,
+                               dest_index,
+                               TRUE, NULL);
     }
 
   gimp_image_flush (item_view->priv->image);
diff --git a/app/widgets/gimpitemtreeview.h b/app/widgets/gimpitemtreeview.h
index f29778c..f9ab1b1 100644
--- a/app/widgets/gimpitemtreeview.h
+++ b/app/widgets/gimpitemtreeview.h
@@ -29,12 +29,6 @@ typedef GimpContainer * (* GimpGetContainerFunc) (const GimpImage *image);
 typedef GimpItem      * (* GimpGetItemFunc)      (const GimpImage *image);
 typedef void            (* GimpSetItemFunc)      (GimpImage       *image,
                                                   GimpItem        *item);
-typedef void            (* GimpReorderItemFunc)  (GimpImage       *image,
-                                                  GimpItem        *item,
-                                                  GimpItem        *new_parent,
-                                                  gint             new_index,
-                                                  gboolean         push_undo,
-                                                  const gchar     *undo_desc);
 typedef void            (* GimpAddItemFunc)      (GimpImage       *image,
                                                   GimpItem        *item,
                                                   GimpItem        *parent,
@@ -80,7 +74,6 @@ struct _GimpItemTreeViewClass
   GimpGetContainerFunc  get_container;
   GimpGetItemFunc       get_active_item;
   GimpSetItemFunc       set_active_item;
-  GimpReorderItemFunc   reorder_item;
   GimpAddItemFunc       add_item;
   GimpRemoveItemFunc    remove_item;
   GimpNewItemFunc       new_item;
@@ -98,9 +91,6 @@ struct _GimpItemTreeViewClass
   const gchar          *duplicate_action;
   const gchar          *delete_action;
 
-  /*  undo descriptions  */
-  const gchar          *reorder_desc;
-
   /*  lock content button appearance  */
   const gchar          *lock_content_stock_id;
   const gchar          *lock_content_tooltip;
diff --git a/app/widgets/gimplayertreeview.c b/app/widgets/gimplayertreeview.c
index 2e2a26e..8a2b0da 100644
--- a/app/widgets/gimplayertreeview.c
+++ b/app/widgets/gimplayertreeview.c
@@ -207,7 +207,6 @@ gimp_layer_tree_view_class_init (GimpLayerTreeViewClass *klass)
   item_view_class->get_container   = gimp_image_get_layers;
   item_view_class->get_active_item = (GimpGetItemFunc) gimp_image_get_active_layer;
   item_view_class->set_active_item = (GimpSetItemFunc) gimp_image_set_active_layer;
-  item_view_class->reorder_item    = (GimpReorderItemFunc) gimp_image_reorder_layer;
   item_view_class->add_item        = (GimpAddItemFunc) gimp_image_add_layer;
   item_view_class->remove_item     = (GimpRemoveItemFunc) gimp_image_remove_layer;
   item_view_class->new_item        = gimp_layer_tree_view_item_new;
@@ -223,7 +222,6 @@ gimp_layer_tree_view_class_init (GimpLayerTreeViewClass *klass)
   item_view_class->lower_bottom_action = "layers-lower-to-bottom";
   item_view_class->duplicate_action    = "layers-duplicate";
   item_view_class->delete_action       = "layers-delete";
-  item_view_class->reorder_desc        = _("Reorder Layer");
 
   g_type_class_add_private (klass, sizeof (GimpLayerTreeViewPriv));
 }
diff --git a/app/widgets/gimpvectorstreeview.c b/app/widgets/gimpvectorstreeview.c
index 8c0a176..8ee7524 100644
--- a/app/widgets/gimpvectorstreeview.c
+++ b/app/widgets/gimpvectorstreeview.c
@@ -97,7 +97,6 @@ gimp_vectors_tree_view_class_init (GimpVectorsTreeViewClass *klass)
   iv_class->get_container   = gimp_image_get_vectors;
   iv_class->get_active_item = (GimpGetItemFunc) gimp_image_get_active_vectors;
   iv_class->set_active_item = (GimpSetItemFunc) gimp_image_set_active_vectors;
-  iv_class->reorder_item    = (GimpReorderItemFunc) gimp_image_reorder_vectors;
   iv_class->add_item        = (GimpAddItemFunc) gimp_image_add_vectors;
   iv_class->remove_item     = (GimpRemoveItemFunc) gimp_image_remove_vectors;
   iv_class->new_item        = gimp_vectors_tree_view_item_new;
@@ -113,7 +112,6 @@ gimp_vectors_tree_view_class_init (GimpVectorsTreeViewClass *klass)
   iv_class->lower_bottom_action   = "vectors-lower-to-bottom";
   iv_class->duplicate_action      = "vectors-duplicate";
   iv_class->delete_action         = "vectors-delete";
-  iv_class->reorder_desc          = _("Reorder path");
   iv_class->lock_content_stock_id = GIMP_STOCK_TOOL_PATH;
   iv_class->lock_content_tooltip  = _("Lock path strokes");
 }
diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb
index 98fcb56..ca562a9 100644
--- a/tools/pdbgen/pdb/image.pdb
+++ b/tools/pdbgen/pdb/image.pdb
@@ -780,7 +780,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  success = gimp_image_raise_layer (image, layer, error);
+  success = gimp_image_raise_item (image, GIMP_ITEM (layer), error);
 }
 CODE
     );
@@ -806,7 +806,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  success = gimp_image_lower_layer (image, layer, error);
+  success = gimp_image_lower_item (image, GIMP_ITEM (layer), error);
 }
 CODE
     );
@@ -835,7 +835,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  success = gimp_image_raise_layer_to_top (image, layer);
+  success = gimp_image_raise_item_to_top (image, GIMP_ITEM (layer));
 }
 CODE
     );
@@ -864,7 +864,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  success = gimp_image_lower_layer_to_bottom (image, layer);
+  success = gimp_image_lower_item_to_bottom (image, GIMP_ITEM (layer));
 }
 CODE
     );
@@ -1174,7 +1174,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  success = gimp_image_raise_channel (image, channel, error);
+  success = gimp_image_raise_item (image, GIMP_ITEM (channel), error);
 }
 CODE
     );
@@ -1201,7 +1201,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  success = gimp_image_lower_channel (image, channel, error);
+  success = gimp_image_lower_item (image, GIMP_ITEM (channel), error);
 }
 CODE
     );
@@ -1398,7 +1398,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  success = gimp_image_raise_vectors (image, vectors, error);
+  success = gimp_image_raise_item (image, GIMP_ITEM (vectors), error);
 }
 CODE
     );
@@ -1425,7 +1425,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  success = gimp_image_lower_vectors (image, vectors, error);
+  success = gimp_image_lower_item (image, GIMP_ITEM (vectors), error);
 }
 CODE
     );
@@ -1454,7 +1454,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  success = gimp_image_raise_vectors_to_top (image, vectors);
+  success = gimp_image_raise_item_to_top (image, GIMP_ITEM (vectors));
 }
 CODE
     );
@@ -1483,7 +1483,7 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  success = gimp_image_lower_vectors_to_bottom (image, vectors);
+  success = gimp_image_lower_item_to_bottom (image, GIMP_ITEM (vectors));
 }
 CODE
     );



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