[gimp] When cropping the active layer, error out if there is none or it is locked



commit e95b5d9f723eebedcfeb01f7329dd5fa0a4e0375
Author: Michael Natterer <mitch gimp org>
Date:   Thu Aug 20 22:43:01 2009 +0200

    When cropping the active layer, error out if there is none or it is locked

 app/tools/gimpcroptool.c |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c
index 6738f4f..b2092e7 100644
--- a/app/tools/gimpcroptool.c
+++ b/app/tools/gimpcroptool.c
@@ -309,13 +309,10 @@ gimp_crop_tool_execute (GimpRectangleTool  *rectangle,
                         gint                w,
                         gint                h)
 {
-  GimpTool        *tool;
-  GimpCropOptions *options;
+  GimpTool        *tool    = GIMP_TOOL (rectangle);
+  GimpCropOptions *options = GIMP_CROP_TOOL_GET_OPTIONS (tool);
   GimpImage       *image;
 
-  tool    = GIMP_TOOL (rectangle);
-  options = GIMP_CROP_TOOL_GET_OPTIONS (tool);
-
   gimp_tool_pop_status (tool, tool->display);
 
   image = tool->display->image;
@@ -323,6 +320,25 @@ gimp_crop_tool_execute (GimpRectangleTool  *rectangle,
   /* if rectangle exists, crop it */
   if (w > 0 && h > 0)
     {
+      if (options->layer_only)
+        {
+          GimpLayer *layer = gimp_image_get_active_layer (image);
+
+          if (! layer)
+            {
+              gimp_tool_message_literal (tool, tool->display,
+                                         _("There is no active layer to crop."));
+              return FALSE;
+            }
+
+          if (gimp_item_get_lock_content (GIMP_ITEM (layer)))
+            {
+              gimp_tool_message_literal (tool, tool->display,
+                                         _("The active layer's pixels are locked."));
+              return FALSE;
+            }
+        }
+
       gimp_image_crop (image, GIMP_CONTEXT (options),
                        x, y, w + x, h + y,
                        options->layer_only,



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