[gimp/wip/Jehan/layers-dockable-refresh: 99/105] app, devel-docs, libgimp, pdb: get rid of gimp_item_linked_translate().




commit 10d76a02909b9ceca30f336dc38ff6a8c0c115f5
Author: Jehan <jehan girinstud io>
Date:   Wed Dec 15 23:14:28 2021 +0100

    app, devel-docs, libgimp, pdb: get rid of gimp_item_linked_translate().
    
    Similarly to the previous commit, we get rid of "item link" code for
    translating items.

 app/core/gimpimage-item-list.c    | 12 ++++++++++++
 app/core/gimpitem-linked.c        | 27 ---------------------------
 app/core/gimpitem-linked.h        |  4 ----
 app/gimpcore.def                  |  1 -
 app/pdb/item-transform-cmds.c     | 15 ++-------------
 app/pdb/layer-cmds.c              |  9 +--------
 app/tools/gimpeditselectiontool.c | 37 +++++--------------------------------
 devel-docs/app/app-sections.txt   |  1 -
 libgimp/gimpitemtransform_pdb.c   |  5 -----
 pdb/groups/item_transform.pdb     | 17 +----------------
 pdb/groups/layer.pdb              |  9 +--------
 11 files changed, 22 insertions(+), 115 deletions(-)
---
diff --git a/app/core/gimpimage-item-list.c b/app/core/gimpimage-item-list.c
index 5c368bcb3e..445a8a50ea 100644
--- a/app/core/gimpimage-item-list.c
+++ b/app/core/gimpimage-item-list.c
@@ -444,6 +444,18 @@ gimp_image_item_list_remove_children (GList          *list,
   return list;
 }
 
+/**
+ * gimp_image_item_list_filter:
+ * @image:
+ * @items: the original list of #GimpItem-s.
+ *
+ * Filter @list by modifying it directly (so the original list should
+ * not be used anymore, only its result), removing all children items
+ * with ancestors also in @list.
+ *
+ * Returns: the modified @list where all items which have an ancestor in
+ *          @list have been removed.
+ */
 GList *
 gimp_image_item_list_filter (GList *list)
 {
diff --git a/app/core/gimpitem-linked.c b/app/core/gimpitem-linked.c
index 46ea087e5d..25613a88ac 100644
--- a/app/core/gimpitem-linked.c
+++ b/app/core/gimpitem-linked.c
@@ -69,33 +69,6 @@ gimp_item_linked_is_locked (GimpItem *item)
   return locked;
 }
 
-void
-gimp_item_linked_translate (GimpItem *item,
-                            gint      offset_x,
-                            gint      offset_y,
-                            gboolean  push_undo)
-{
-  GimpImage *image;
-  GList     *items;
-
-  g_return_if_fail (GIMP_IS_ITEM (item));
-  g_return_if_fail (gimp_item_get_linked (item) == TRUE);
-  g_return_if_fail (gimp_item_is_attached (item));
-
-  image = gimp_item_get_image (item);
-
-  items = gimp_image_item_list_get_list (image,
-                                         GIMP_ITEM_TYPE_ALL,
-                                         GIMP_ITEM_SET_LINKED);
-
-  items = gimp_image_item_list_filter (items);
-
-  gimp_image_item_list_translate (gimp_item_get_image (item), items,
-                                  offset_x, offset_y, push_undo);
-
-  g_list_free (items);
-}
-
 void
 gimp_item_linked_rotate (GimpItem         *item,
                          GimpContext      *context,
diff --git a/app/core/gimpitem-linked.h b/app/core/gimpitem-linked.h
index ab5c1fd4c2..e6d5be3cb4 100644
--- a/app/core/gimpitem-linked.h
+++ b/app/core/gimpitem-linked.h
@@ -21,10 +21,6 @@
 
 gboolean gimp_item_linked_is_locked (GimpItem               *item);
 
-void     gimp_item_linked_translate (GimpItem               *item,
-                                     gint                    offset_x,
-                                     gint                    offset_y,
-                                     gboolean                push_undo);
 void     gimp_item_linked_rotate    (GimpItem               *item,
                                      GimpContext            *context,
                                      GimpRotationType        rotate_type,
diff --git a/app/gimpcore.def b/app/gimpcore.def
index 360cb708da..eb645397e4 100644
--- a/app/gimpcore.def
+++ b/app/gimpcore.def
@@ -402,7 +402,6 @@ EXPORTS
        gimp_item_is_text_layer
        gimp_item_linked_rotate
        gimp_item_linked_transform
-       gimp_item_linked_translate
        gimp_item_offsets
        gimp_item_rename
        gimp_item_resize
diff --git a/app/pdb/item-transform-cmds.c b/app/pdb/item-transform-cmds.c
index bf0d27ddd4..c72688d1f6 100644
--- a/app/pdb/item-transform-cmds.c
+++ b/app/pdb/item-transform-cmds.c
@@ -70,16 +70,7 @@ item_transform_translate_invoker (GimpProcedure         *procedure,
     {
       if (gimp_pdb_item_is_modifiable (item,
                                        GIMP_PDB_ITEM_POSITION, error))
-        {
-          if (gimp_item_get_linked (item) && gimp_item_is_attached (item))
-            {
-              gimp_item_linked_translate (item, off_x, off_y, TRUE);
-            }
-          else
-            {
-              gimp_item_translate (item, off_x, off_y, TRUE);
-            }
-        }
+        gimp_item_translate (item, off_x, off_y, TRUE);
       else
         success = FALSE;
     }
@@ -1024,9 +1015,7 @@ register_item_transform_procs (GimpPDB *pdb)
                                "gimp-item-transform-translate");
   gimp_procedure_set_static_help (procedure,
                                   "Translate the item by the specified offsets.",
-                                  "This procedure translates the item by the amounts specified in the off_x 
and off_y arguments. These can be negative, and are considered offsets from the current position. The offsets 
will be rounded to the nearest pixel unless the item is a path.\n"
-                                     "\n"
-                                     "If the item is attached to an image and has its linked flag set to 
TRUE, all additional items contained in the image which have the linked flag set to TRUE will also be 
translated by the specified offsets.",
+                                  "This procedure translates the item by the amounts specified in the off_x 
and off_y arguments. These can be negative, and are considered offsets from the current position. The offsets 
will be rounded to the nearest pixel unless the item is a path.",
                                   NULL);
   gimp_procedure_set_static_attribution (procedure,
                                          "Michael Natterer <mitch gimp org>",
diff --git a/app/pdb/layer-cmds.c b/app/pdb/layer-cmds.c
index 131fc40411..fff2a13ccb 100644
--- a/app/pdb/layer-cmds.c
+++ b/app/pdb/layer-cmds.c
@@ -518,14 +518,7 @@ layer_set_offsets_invoker (GimpProcedure         *procedure,
           offx -= offset_x;
           offy -= offset_y;
 
-          if (gimp_item_get_linked (GIMP_ITEM (layer)))
-            {
-              gimp_item_linked_translate (GIMP_ITEM (layer), offx, offy, TRUE);
-            }
-          else
-            {
-              gimp_item_translate (GIMP_ITEM (layer), offx, offy, TRUE);
-            }
+          gimp_item_translate (GIMP_ITEM (layer), offx, offy, TRUE);
         }
       else
         success = FALSE;
diff --git a/app/tools/gimpeditselectiontool.c b/app/tools/gimpeditselectiontool.c
index a12197f7c7..a57887da80 100644
--- a/app/tools/gimpeditselectiontool.c
+++ b/app/tools/gimpeditselectiontool.c
@@ -38,7 +38,6 @@
 #include "core/gimpimage-guides.h"
 #include "core/gimpimage-item-list.h"
 #include "core/gimpimage-undo.h"
-#include "core/gimpitem-linked.h"
 #include "core/gimplayer.h"
 #include "core/gimplayermask.h"
 #include "core/gimpprojection.h"
@@ -329,7 +328,7 @@ gimp_edit_selection_tool_start (GimpTool          *parent_tool,
       case GIMP_TRANSLATE_MODE_CHANNEL:
       case GIMP_TRANSLATE_MODE_MASK:
       case GIMP_TRANSLATE_MODE_LAYER_MASK:
-        edit_select->delayed_items = gimp_image_item_list_linked (image, selected_items);
+        edit_select->delayed_items = gimp_image_item_list_filter (g_list_copy (selected_items));
         gimp_image_item_list_bounds (image, edit_select->delayed_items, &x, &y, &w, &h);
         x += off_x;
         y += off_y;
@@ -348,7 +347,7 @@ gimp_edit_selection_tool_start (GimpTool          *parent_tool,
       case GIMP_TRANSLATE_MODE_LAYER:
       case GIMP_TRANSLATE_MODE_FLOATING_SEL:
       case GIMP_TRANSLATE_MODE_VECTORS:
-        edit_select->live_items = gimp_image_item_list_linked (image, selected_items);
+        edit_select->live_items = gimp_image_item_list_filter (g_list_copy (selected_items));
         gimp_image_item_list_bounds (image, edit_select->live_items, &x, &y, &w, &h);
         break;
       }
@@ -710,7 +709,7 @@ gimp_edit_selection_tool_draw (GimpDrawTool *draw_tool)
           GList *translate_items;
           gint   x, y, w, h;
 
-          translate_items = gimp_image_item_list_linked (image, selected_items);
+          translate_items = gimp_image_item_list_filter (g_list_copy (selected_items));
           gimp_image_item_list_bounds (image, translate_items, &x, &y, &w, &h);
           g_list_free (translate_items);
 
@@ -1227,34 +1226,8 @@ gimp_edit_selection_tool_translate (GimpTool          *tool,
         }
     }
 
-  switch (edit_mode)
-    {
-    case GIMP_TRANSLATE_MODE_LAYER_MASK:
-    case GIMP_TRANSLATE_MODE_MASK:
-      for (iter = selected_items; iter; iter = iter->next)
-        gimp_item_translate (iter->data, inc_x, inc_y, push_undo);
-      break;
-
-    case GIMP_TRANSLATE_MODE_MASK_TO_LAYER:
-    case GIMP_TRANSLATE_MODE_MASK_COPY_TO_LAYER:
-      /*  this won't happen  */
-      break;
-
-    case GIMP_TRANSLATE_MODE_VECTORS:
-    case GIMP_TRANSLATE_MODE_CHANNEL:
-    case GIMP_TRANSLATE_MODE_LAYER:
-      for (iter = selected_items; iter; iter = iter->next)
-        if (gimp_item_get_linked (iter->data))
-          gimp_item_linked_translate (iter->data, inc_x, inc_y, push_undo);
-        else
-          gimp_item_translate (iter->data, inc_x, inc_y, push_undo);
-      break;
-
-    case GIMP_TRANSLATE_MODE_FLOATING_SEL:
-      for (iter = selected_items; iter; iter = iter->next)
-        gimp_item_translate (iter->data, inc_x, inc_y, push_undo);
-      break;
-    }
+  gimp_image_item_list_translate (gimp_item_get_image (selected_items->data),
+                                  selected_items, inc_x, inc_y, push_undo);
 
   if (push_undo)
     gimp_image_undo_group_end (image);
diff --git a/devel-docs/app/app-sections.txt b/devel-docs/app/app-sections.txt
index 9baac6ab34..e468de9526 100644
--- a/devel-docs/app/app-sections.txt
+++ b/devel-docs/app/app-sections.txt
@@ -11422,7 +11422,6 @@ gimp_item_toggle_exclusive_visible
 <SECTION>
 <FILE>gimpitem-linked</FILE>
 <TITLE>GimpItem-linked</TITLE>
-gimp_item_linked_translate
 gimp_item_linked_rotate
 gimp_item_linked_transform
 </SECTION>
diff --git a/libgimp/gimpitemtransform_pdb.c b/libgimp/gimpitemtransform_pdb.c
index ba18942265..8db5546264 100644
--- a/libgimp/gimpitemtransform_pdb.c
+++ b/libgimp/gimpitemtransform_pdb.c
@@ -47,11 +47,6 @@
  * offsets from the current position. The offsets will be rounded to
  * the nearest pixel unless the item is a path.
  *
- * If the item is attached to an image and has its linked flag set to
- * TRUE, all additional items contained in the image which have the
- * linked flag set to TRUE will also be translated by the specified
- * offsets.
- *
  * Returns: (transfer none): The translated item.
  *
  * Since: 2.10
diff --git a/pdb/groups/item_transform.pdb b/pdb/groups/item_transform.pdb
index 174df6d396..3314ffce70 100644
--- a/pdb/groups/item_transform.pdb
+++ b/pdb/groups/item_transform.pdb
@@ -118,12 +118,6 @@ This procedure translates the item by the amounts specified in the
 off_x and off_y arguments. These can be negative, and are considered
 offsets from the current position. The offsets will be rounded to the
 nearest pixel unless the item is a path.
-
-
-If the item is attached to an image and has its linked flag set to
-TRUE, all additional items contained in the image which have the
-linked flag set to TRUE will also be translated by the specified
-offsets.
 HELP
 
     &mitch_pdb_misc('2018', '2.10');
@@ -147,16 +141,7 @@ HELP
 {
   if (gimp_pdb_item_is_modifiable (item,
                                    GIMP_PDB_ITEM_POSITION, error))
-    {
-      if (gimp_item_get_linked (item) && gimp_item_is_attached (item))
-        {
-          gimp_item_linked_translate (item, off_x, off_y, TRUE);
-        }
-      else
-        {
-          gimp_item_translate (item, off_x, off_y, TRUE);
-        }
-    }
+    gimp_item_translate (item, off_x, off_y, TRUE);
   else
     success = FALSE;
 }
diff --git a/pdb/groups/layer.pdb b/pdb/groups/layer.pdb
index 71b03b59a0..690a2af1d9 100644
--- a/pdb/groups/layer.pdb
+++ b/pdb/groups/layer.pdb
@@ -678,14 +678,7 @@ HELP
       offx -= offset_x;
       offy -= offset_y;
 
-      if (gimp_item_get_linked (GIMP_ITEM (layer)))
-        {
-          gimp_item_linked_translate (GIMP_ITEM (layer), offx, offy, TRUE);
-        }
-      else
-        {
-          gimp_item_translate (GIMP_ITEM (layer), offx, offy, TRUE);
-        }
+      gimp_item_translate (GIMP_ITEM (layer), offx, offy, TRUE);
     }
   else
     success = FALSE;


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