Index: app/core/gimplayer.c
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimplayer.c,v
retrieving revision 1.251
diff -u -p -r1.251 gimplayer.c
--- app/core/gimplayer.c	16 Oct 2006 17:09:07 -0000	1.251
+++ app/core/gimplayer.c	22 Oct 2006 18:32:46 -0000
@@ -56,6 +56,7 @@ enum
   OPACITY_CHANGED,
   MODE_CHANGED,
   LOCK_ALPHA_CHANGED,
+  LOCK_PIXELS_CHANGED,
   MASK_CHANGED,
   LAST_SIGNAL
 };
@@ -65,7 +66,8 @@ enum
   PROP_0,
   PROP_OPACITY,
   PROP_MODE,
-  PROP_LOCK_ALPHA
+  PROP_LOCK_ALPHA,
+  PROP_LOCK_PIXELS
 };
 
 
@@ -210,6 +212,15 @@ gimp_layer_class_init (GimpLayerClass *k
                   gimp_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
 
+  layer_signals[LOCK_PIXELS_CHANGED] =
+    g_signal_new ("lock-pixels-changed",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (GimpLayerClass, lock_pixels_changed),
+                  NULL, NULL,
+                  gimp_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
+
   layer_signals[MASK_CHANGED] =
     g_signal_new ("mask-changed",
                   G_TYPE_FROM_CLASS (klass),
@@ -258,6 +269,7 @@ gimp_layer_class_init (GimpLayerClass *k
   klass->opacity_changed              = NULL;
   klass->mode_changed                 = NULL;
   klass->lock_alpha_changed           = NULL;
+  klass->lock_pixels_changed          = NULL;
   klass->mask_changed                 = NULL;
 
   g_object_class_install_property (object_class, PROP_OPACITY,
@@ -278,14 +290,21 @@ gimp_layer_class_init (GimpLayerClass *k
                                                          NULL, NULL,
                                                          FALSE,
                                                          GIMP_PARAM_READABLE));
+
+  g_object_class_install_property (object_class, PROP_LOCK_PIXELS,
+                                   g_param_spec_boolean ("lock-pixels",
+                                                         NULL, NULL,
+                                                         FALSE,
+                                                         GIMP_PARAM_READABLE));
 }
 
 static void
 gimp_layer_init (GimpLayer *layer)
 {
-  layer->opacity    = GIMP_OPACITY_OPAQUE;
-  layer->mode       = GIMP_NORMAL_MODE;
-  layer->lock_alpha = FALSE;
+  layer->opacity      = GIMP_OPACITY_OPAQUE;
+  layer->mode         = GIMP_NORMAL_MODE;
+  layer->lock_alpha   = FALSE;
+  layer->lock_pixels  = FALSE;
 
   layer->mask       = NULL;
 
@@ -315,6 +334,7 @@ gimp_layer_set_property (GObject      *o
     case PROP_OPACITY:
     case PROP_MODE:
     case PROP_LOCK_ALPHA:
+    case PROP_LOCK_PIXELS:
       g_assert_not_reached ();
       break;
     default:
@@ -342,6 +362,9 @@ gimp_layer_get_property (GObject    *obj
     case PROP_LOCK_ALPHA:
       g_value_set_boolean (value, layer->lock_alpha);
       break;
+    case PROP_LOCK_PIXELS:
+      g_value_set_boolean (value, layer->lock_pixels);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -1890,3 +1913,39 @@ gimp_layer_get_lock_alpha (const GimpLay
 
   return layer->lock_alpha;
 }
+
+void
+gimp_layer_set_lock_pixels (GimpLayer *layer,
+                             gboolean   lock_pixels,
+                             gboolean   push_undo)
+{
+  g_return_if_fail (GIMP_IS_LAYER (layer));
+
+  lock_pixels = lock_pixels ? TRUE : FALSE;
+
+  if (layer->lock_pixels != lock_pixels)
+    {
+      if (push_undo && gimp_item_is_attached (GIMP_ITEM (layer)))
+        {
+          GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
+
+          /* Right now I don't think this should be pushed.
+           * gimp_image_undo_push_layer_lock_pixels (image, NULL, layer);
+           */
+        }
+
+      layer->lock_pixels = lock_pixels;
+
+      g_signal_emit (layer, layer_signals[LOCK_PIXELS_CHANGED], 0);
+      g_object_notify (G_OBJECT (layer), "lock-pixels");
+    }
+}
+
+gboolean
+gimp_layer_get_lock_pixels (const GimpLayer *layer)
+{
+  g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
+
+  return layer->lock_pixels;
+}
+
Index: app/core/gimplayer.h
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimplayer.h,v
retrieving revision 1.78
diff -u -p -r1.78 gimplayer.h
--- app/core/gimplayer.h	14 May 2006 16:24:29 -0000	1.78
+++ app/core/gimplayer.h	22 Oct 2006 18:32:46 -0000
@@ -40,6 +40,7 @@ struct _GimpLayer
   gdouble               opacity;          /*  layer opacity              */
   GimpLayerModeEffects  mode;             /*  layer combination mode     */
   gboolean              lock_alpha;       /*  lock the alpha channel     */
+  gboolean              lock_pixels;      /*  lock the pixels            */
 
   GimpLayerMask        *mask;             /*  possible layer mask        */
 
@@ -60,10 +61,11 @@ struct _GimpLayerClass
 {
   GimpDrawableClass  parent_class;
 
-  void (* opacity_changed)    (GimpLayer *layer);
-  void (* mode_changed)       (GimpLayer *layer);
-  void (* lock_alpha_changed) (GimpLayer *layer);
-  void (* mask_changed)       (GimpLayer *layer);
+  void (* opacity_changed)      (GimpLayer *layer);
+  void (* mode_changed)         (GimpLayer *layer);
+  void (* lock_alpha_changed)   (GimpLayer *layer);
+  void (* lock_pixels_changed)  (GimpLayer *layer);
+  void (* mask_changed)         (GimpLayer *layer);
 };
 
 
@@ -134,6 +136,12 @@ void            gimp_layer_set_lock_alph
                                                 gboolean              lock_alpha,
                                                 gboolean              push_undo);
 gboolean        gimp_layer_get_lock_alpha      (const GimpLayer      *layer);
+
+void            gimp_layer_set_lock_pixels     (GimpLayer            *layer,
+                                                gboolean              lock_alpha,
+                                                gboolean              push_undo);
+gboolean        gimp_layer_get_lock_pixels     (const GimpLayer      *layer);
+
 
 
 #endif /* __GIMP_LAYER_H__ */
Index: app/widgets/gimplayertreeview.c
===================================================================
RCS file: /cvs/gnome/gimp/app/widgets/gimplayertreeview.c,v
retrieving revision 1.119
diff -u -p -r1.119 gimplayertreeview.c
--- app/widgets/gimplayertreeview.c	21 Oct 2006 18:46:47 -0000	1.119
+++ app/widgets/gimplayertreeview.c	22 Oct 2006 18:32:47 -0000
@@ -124,6 +124,9 @@ static void   gimp_layer_tree_view_opaci
 static void   gimp_layer_tree_view_lock_alpha_button_toggled
                                                   (GtkWidget           *widget,
                                                    GimpLayerTreeView   *view);
+static void   gimp_layer_tree_view_lock_pixels_button_toggled
+                                                  (GtkWidget           *widget,
+                                                   GimpLayerTreeView   *view);
 
 static void   gimp_layer_tree_view_layer_signal_handler
                                                   (GimpLayer           *layer,
@@ -295,7 +298,7 @@ gimp_layer_tree_view_init (GimpLayerTree
                     G_CALLBACK (gimp_layer_tree_view_opacity_scale_changed),
                     view);
 
-  /*  Lock alpha toggle  */
+  /*  Lock alpha toggle and lock pixels toggle */
 
   hbox = gtk_hbox_new (FALSE, 6);
 
@@ -318,10 +321,31 @@ gimp_layer_tree_view_init (GimpLayerTree
   gtk_container_add (GTK_CONTAINER (view->lock_alpha_toggle), image);
   gtk_widget_show (image);
 
-  gimp_table_attach_aligned (GTK_TABLE (view->options_box), 0, 2,
-                             _("Lock:"), 0.0, 0.5,
+  view->lock_pixels_toggle = gtk_check_button_new ();
+  gtk_box_pack_start (GTK_BOX (hbox), view->lock_pixels_toggle, FALSE, FALSE, 0);
+  gtk_widget_show (view->lock_pixels_toggle);
+
+  g_signal_connect (view->lock_pixels_toggle, "toggled",
+                    G_CALLBACK (gimp_layer_tree_view_lock_pixels_button_toggled),
+                    view);
+
+  gimp_help_set_help_data (view->lock_pixels_toggle, _("Lock pixels"),
+                           GIMP_HELP_LAYER_DIALOG_LOCK_ALPHA_BUTTON);
+
+  gtk_widget_style_get (GTK_WIDGET (view),
+                        "button-icon-size", &icon_size,
+                        NULL);
+
+  image = gtk_image_new_from_stock (GIMP_STOCK_IMAGE, icon_size);
+  gtk_container_add (GTK_CONTAINER (view->lock_pixels_toggle), image);
+  gtk_widget_show (image);
+
+  gimp_table_attach_aligned (GTK_TABLE (view->options_box), 0, 3,
+                             _("Locks:"), 0.0, 0.5,
                              hbox, 2, FALSE);
 
+
+
   gtk_widget_set_sensitive (view->options_box, FALSE);
 
   view->italic_attrs = pango_attr_list_new ();
@@ -336,10 +360,11 @@ gimp_layer_tree_view_init (GimpLayerTree
   attr->end_index   = -1;
   pango_attr_list_insert (view->bold_attrs, attr);
 
-  view->mode_changed_handler_id       = 0;
-  view->opacity_changed_handler_id    = 0;
-  view->lock_alpha_changed_handler_id = 0;
-  view->mask_changed_handler_id       = 0;
+  view->mode_changed_handler_id        = 0;
+  view->opacity_changed_handler_id     = 0;
+  view->lock_alpha_changed_handler_id  = 0;
+  view->lock_pixels_changed_handler_id = 0;
+  view->mask_changed_handler_id        = 0;
 }
 
 static GObject *
@@ -495,6 +520,8 @@ gimp_layer_tree_view_set_container (Gimp
       gimp_container_remove_handler (old_container,
                                      layer_view->lock_alpha_changed_handler_id);
       gimp_container_remove_handler (old_container,
+                                     layer_view->lock_pixels_changed_handler_id);
+      gimp_container_remove_handler (old_container,
                                      layer_view->mask_changed_handler_id);
       gimp_container_remove_handler (old_container,
                                      layer_view->alpha_changed_handler_id);
@@ -516,6 +543,10 @@ gimp_layer_tree_view_set_container (Gimp
         gimp_container_add_handler (container, "lock-alpha-changed",
                                     G_CALLBACK (gimp_layer_tree_view_layer_signal_handler),
                                     view);
+      layer_view->lock_pixels_changed_handler_id =
+        gimp_container_add_handler (container, "lock-pixels-changed",
+                                    G_CALLBACK (gimp_layer_tree_view_layer_signal_handler),
+                                    view);
       layer_view->mask_changed_handler_id =
         gimp_container_add_handler (container, "mask-changed",
                                     G_CALLBACK (gimp_layer_tree_view_mask_changed),
@@ -1023,6 +1054,45 @@ gimp_layer_tree_view_lock_alpha_button_t
 }
 
 static void
+gimp_layer_tree_view_lock_pixels_button_toggled (GtkWidget         *widget,
+                                                 GimpLayerTreeView *view)
+{
+  GimpImage *image;
+  GimpLayer *layer;
+
+  image = GIMP_ITEM_TREE_VIEW (view)->image;
+
+  layer = (GimpLayer *)
+    GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (image);
+
+  if (layer)
+    {
+      gboolean lock_pixels;
+
+      lock_pixels = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+
+      if (gimp_layer_get_lock_pixels (layer) != lock_pixels)
+        {
+          GimpUndo *undo;
+          gboolean  push_undo = TRUE;
+
+          /*  compress opacity undos  */
+          undo = gimp_image_undo_can_compress (image, GIMP_TYPE_ITEM_UNDO,
+                                               GIMP_UNDO_LAYER_LOCK_ALPHA);
+
+          if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (layer))
+            push_undo = FALSE;
+
+          BLOCK();
+          gimp_layer_set_lock_pixels (layer, lock_pixels, push_undo);
+          UNBLOCK();
+
+          gimp_image_flush (image);
+        }
+    }
+}
+
+static void
 gimp_layer_tree_view_opacity_scale_changed (GtkAdjustment     *adjustment,
                                             GimpLayerTreeView *view)
 {
@@ -1111,6 +1181,19 @@ gimp_layer_tree_view_update_options (Gim
 
       UNBLOCK (view->lock_alpha_toggle,
                gimp_layer_tree_view_lock_alpha_button_toggled);
+    }
+
+  if (layer->lock_pixels !=
+      gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (view->lock_pixels_toggle)))
+    {
+      BLOCK (view->lock_pixels_toggle,
+             gimp_layer_tree_view_lock_pixels_button_toggled);
+
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (view->lock_pixels_toggle),
+                                    layer->lock_pixels);
+
+      UNBLOCK (view->lock_pixels_toggle,
+               gimp_layer_tree_view_lock_pixels_button_toggled);
     }
 
   if (layer->opacity * 100.0 != view->opacity_adjustment->value)
Index: app/widgets/gimplayertreeview.h
===================================================================
RCS file: /cvs/gnome/gimp/app/widgets/gimplayertreeview.h,v
retrieving revision 1.16
diff -u -p -r1.16 gimplayertreeview.h
--- app/widgets/gimplayertreeview.h	10 Jul 2005 21:17:18 -0000	1.16
+++ app/widgets/gimplayertreeview.h	22 Oct 2006 18:32:47 -0000
@@ -44,6 +44,7 @@ struct _GimpLayerTreeView
   GtkWidget            *paint_mode_menu;
   GtkAdjustment        *opacity_adjustment;
   GtkWidget            *lock_alpha_toggle;
+  GtkWidget            *lock_pixels_toggle;
 
   gint                  model_column_mask;
   gint                  model_column_mask_visible;
@@ -57,6 +58,7 @@ struct _GimpLayerTreeView
   GQuark                mode_changed_handler_id;
   GQuark                opacity_changed_handler_id;
   GQuark                lock_alpha_changed_handler_id;
+  GQuark                lock_pixels_changed_handler_id;
   GQuark                mask_changed_handler_id;
   GQuark                alpha_changed_handler_id;
 };
