[gimp] Bug 677823 - Shift + mouse click to link all layers does not work



commit 67b5a509b6c830e59f0f9edaae78899afc0ec1c8
Author: Michael Natterer <mitch gimp org>
Date:   Tue Jun 12 21:39:40 2012 +0200

    Bug 677823 - Shift + mouse click to link all layers does not work
    
    This got lost during layer group porting, reimplement it, but restrict
    "all layers" to the clicked layer's branch in the tree.

 app/core/gimpitem-exclusive.c  |   91 +++++++++++++++++++++++++++++++++++++++-
 app/core/gimpitem-exclusive.h  |    2 +
 app/widgets/gimpitemtreeview.c |    2 +-
 3 files changed, 92 insertions(+), 3 deletions(-)
---
diff --git a/app/core/gimpitem-exclusive.c b/app/core/gimpitem-exclusive.c
index aa504b0..fa2b56c 100644
--- a/app/core/gimpitem-exclusive.c
+++ b/app/core/gimpitem-exclusive.c
@@ -70,7 +70,7 @@ gimp_item_toggle_exclusive_visible (GimpItem    *item,
       undo = gimp_image_undo_can_compress (image, GIMP_TYPE_UNDO_STACK,
                                            GIMP_UNDO_GROUP_ITEM_VISIBILITY);
 
-      if (undo && (g_object_get_data (G_OBJECT (undo), "exclusive-item") ==
+      if (undo && (g_object_get_data (G_OBJECT (undo), "exclusive-visible-item") ==
                    (gpointer) item))
         push_undo = FALSE;
 
@@ -84,7 +84,7 @@ gimp_item_toggle_exclusive_visible (GimpItem    *item,
                                                    GIMP_UNDO_GROUP_ITEM_VISIBILITY);
 
               if (undo)
-                g_object_set_data (G_OBJECT (undo), "exclusive-item",
+                g_object_set_data (G_OBJECT (undo), "exclusive-visible-item",
                                    (gpointer) item);
             }
 
@@ -125,6 +125,93 @@ gimp_item_toggle_exclusive_visible (GimpItem    *item,
   g_list_free (ancestry);
 }
 
+void
+gimp_item_toggle_exclusive_linked (GimpItem    *item,
+                                   GimpContext *context)
+{
+  GList *on  = NULL;
+  GList *off = NULL;
+  GList *list;
+
+  g_return_if_fail (GIMP_IS_ITEM (item));
+  g_return_if_fail (gimp_item_is_attached (item));
+  g_return_if_fail (GIMP_IS_CONTEXT (context));
+
+  for (list = gimp_item_get_container_iter (item);
+       list;
+       list = g_list_next (list))
+    {
+      GimpItem *other = list->data;
+
+      if (other != item)
+        {
+          if (gimp_item_get_linked (other))
+            on = g_list_prepend (on, other);
+          else
+            off = g_list_prepend (off, other);
+        }
+    }
+
+  if (on || off || ! gimp_item_get_linked (item))
+    {
+      GimpImage *image = gimp_item_get_image (item);
+      GimpUndo  *undo;
+      gboolean   push_undo = TRUE;
+
+      undo = gimp_image_undo_can_compress (image, GIMP_TYPE_UNDO_STACK,
+                                           GIMP_UNDO_GROUP_ITEM_LINKED);
+
+      if (undo && (g_object_get_data (G_OBJECT (undo), "exclusive-linked-item") ==
+                   (gpointer) item))
+        push_undo = FALSE;
+
+      if (push_undo)
+        {
+          if (gimp_image_undo_group_start (image,
+                                           GIMP_UNDO_GROUP_ITEM_LINKED,
+                                           _("Set Item Exclusive Linked")))
+            {
+              undo = gimp_image_undo_can_compress (image, GIMP_TYPE_UNDO_STACK,
+                                                   GIMP_UNDO_GROUP_ITEM_LINKED);
+
+              if (undo)
+                g_object_set_data (G_OBJECT (undo), "exclusive-linked-item",
+                                   (gpointer) item);
+            }
+
+          gimp_image_undo_push_item_linked (image, NULL, item);
+
+          for (list = on; list; list = g_list_next (list))
+            gimp_image_undo_push_item_linked (image, NULL, list->data);
+
+          for (list = off; list; list = g_list_next (list))
+            gimp_image_undo_push_item_linked (image, NULL, list->data);
+
+          gimp_image_undo_group_end (image);
+        }
+      else
+        {
+          gimp_undo_refresh_preview (undo, context);
+        }
+
+      if (off || ! gimp_item_get_linked (item))
+        {
+          gimp_item_set_linked (item, TRUE, FALSE);
+
+          for (list = off; list; list = g_list_next (list))
+            gimp_item_set_linked (list->data, TRUE, FALSE);
+        }
+      else
+        {
+          for (list = on; list; list = g_list_next (list))
+            gimp_item_set_linked (list->data, FALSE, FALSE);
+        }
+
+      g_list_free (on);
+      g_list_free (off);
+    }
+}
+
 
 /*  private functions  */
 
diff --git a/app/core/gimpitem-exclusive.h b/app/core/gimpitem-exclusive.h
index 932c89e..da160f8 100644
--- a/app/core/gimpitem-exclusive.h
+++ b/app/core/gimpitem-exclusive.h
@@ -24,6 +24,8 @@
 
 void   gimp_item_toggle_exclusive_visible (GimpItem    *item,
                                            GimpContext *context);
+void   gimp_item_toggle_exclusive_linked  (GimpItem    *item,
+                                           GimpContext *context);
 
 
 #endif /* __GIMP_ITEM_EXCLUSIVE_H__ */
diff --git a/app/widgets/gimpitemtreeview.c b/app/widgets/gimpitemtreeview.c
index 7400e0e..4caa6c8 100644
--- a/app/widgets/gimpitemtreeview.c
+++ b/app/widgets/gimpitemtreeview.c
@@ -1491,7 +1491,7 @@ gimp_item_tree_view_toggle_clicked (GtkCellRendererToggle *toggle,
 
     case GIMP_UNDO_ITEM_LINKED:
       setter     = gimp_item_set_linked;
-      exclusive  = NULL;
+      exclusive  = gimp_item_toggle_exclusive_linked;
       break;
 
     default:



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