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

This commit is contained in:
Michael Natterer 2009-08-20 22:43:01 +02:00
parent 0953146be1
commit e95b5d9f72
1 changed files with 21 additions and 5 deletions

View File

@ -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,