1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 01:12:40 +02:00

app: properly forbid paint tools to draw on link layers and forbid…

… filter tools to merge filters, both on link and vector layers.
This commit is contained in:
Jehan
2025-08-30 09:54:10 +02:00
parent 9a780bc7d4
commit 38c379cd92
4 changed files with 56 additions and 28 deletions

View File

@@ -931,6 +931,15 @@ gimp_link_layer_set_transform (GimpLinkLayer *layer,
return rendered;
}
gboolean
gimp_item_is_link_layer (GimpItem *item)
{
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
return (GIMP_IS_LINK_LAYER (item) &&
gimp_link_layer_is_monitored (GIMP_LINK_LAYER (item)));
}
void
gimp_link_layer_set_xcf_flags (GimpLinkLayer *layer,
guint32 flags)

View File

@@ -78,6 +78,8 @@ gboolean gimp_link_layer_set_transform (GimpLinkLayer *layer,
GimpInterpolationType interpolation_type,
gboolean push_undo);
gboolean gimp_item_is_link_layer (GimpItem *item);
/* Only to be used for XCF loading/saving. */
guint32 gimp_link_layer_get_xcf_flags (GimpLinkLayer *layer);

View File

@@ -57,6 +57,7 @@
#include "core/gimpimage-undo-push.h"
#include "core/gimplayer.h"
#include "core/gimplayermask.h"
#include "core/gimplinklayer.h"
#include "core/gimplist.h"
#include "core/gimppickable.h"
#include "core/gimpprogress.h"
@@ -64,6 +65,8 @@
#include "core/gimpsettings.h"
#include "core/gimptoolinfo.h"
#include "path/gimpvectorlayer.h"
#include "widgets/gimplayermodebox.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpsettingsbox.h"
@@ -422,14 +425,17 @@ gimp_filter_tool_initialize (GimpTool *tool,
/* TODO: Once we can serialize GimpDrawable, remove so that filters with
* aux nodes can be non-destructive */
if (gegl_node_has_pad (filter_tool->operation, "aux") ||
if (gegl_node_has_pad (filter_tool->operation, "aux") ||
(g_strcmp0 (operation_name, "gegl:gegl") == 0 &&
g_getenv ("GIMP_ALLOW_GEGL_GRAPH_LAYER_EFFECT") == NULL))
g_getenv ("GIMP_ALLOW_GEGL_GRAPH_LAYER_EFFECT") == NULL) ||
gimp_item_is_vector_layer (GIMP_ITEM (drawable)) ||
gimp_item_is_link_layer (GIMP_ITEM (drawable)))
{
GParamSpec *param_spec;
GObject *obj = G_OBJECT (tool_info->tool_options);
gchar *tooltip;
const gchar *disabled_reason;
gboolean show_merge;
param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (obj),
"merge-filter");
@@ -437,11 +443,17 @@ gimp_filter_tool_initialize (GimpTool *tool,
toggle =
gtk_check_button_new_with_mnemonic (g_param_spec_get_nick (param_spec));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), TRUE);
show_merge = (! gimp_item_is_vector_layer (GIMP_ITEM (drawable)) &&
! gimp_item_is_link_layer (GIMP_ITEM (drawable)));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), show_merge);
gtk_widget_set_sensitive (toggle, FALSE);
if (gegl_node_has_pad (filter_tool->operation, "aux"))
disabled_reason = _("Disabled because this filter depends on another image.");
else if (gimp_item_is_vector_layer (GIMP_ITEM (drawable)))
disabled_reason = _("Disabled because filters cannot be merged on vector layers.");
else if (gimp_item_is_link_layer (GIMP_ITEM (drawable)))
disabled_reason = _("Disabled because filters cannot be merged on link layers.");
else
disabled_reason = _("Disabled because GEGL Graph is unsafe.\nFor development purpose, "
"set environment variable GIMP_ALLOW_GEGL_GRAPH_LAYER_EFFECT.");
@@ -586,8 +598,10 @@ gimp_filter_tool_control (GimpTool *tool,
g_free (operation_name);
}
/* Ensure that filters applied to group layers are non-destructive */
if (GIMP_IS_GROUP_LAYER (drawable))
/* Ensure that filters applied to group, vector or link layers are non-destructive */
if (GIMP_IS_GROUP_LAYER (drawable) ||
gimp_item_is_vector_layer (GIMP_ITEM (drawable)) ||
gimp_item_is_link_layer (GIMP_ITEM (drawable)))
non_destructive = TRUE;
gimp_filter_tool_commit (filter_tool, non_destructive);
@@ -1552,6 +1566,9 @@ gimp_filter_tool_create_filter (GimpFilterTool *filter_tool)
merge_filter = options->merge_filter;
if (gegl_node_has_pad (filter_tool->operation, "aux"))
merge_filter = TRUE;
else if (gimp_item_is_vector_layer (GIMP_ITEM (drawable)) ||
gimp_item_is_link_layer (GIMP_ITEM (drawable)))
merge_filter = FALSE;
g_object_set (filter_tool->filter,
"to-be-merged", merge_filter,

View File

@@ -34,6 +34,7 @@
#include "core/gimperror.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "core/gimplinklayer.h"
#include "core/gimppaintinfo.h"
#include "core/gimpprojection.h"
#include "core/gimptoolinfo.h"
@@ -326,36 +327,35 @@ gimp_paint_tool_button_press (GimpTool *tool,
return;
}
if (gimp_item_is_content_locked (GIMP_ITEM (drawable), &locked_item))
if (gimp_item_is_vector_layer (GIMP_ITEM (drawable)) ||
gimp_item_is_link_layer (GIMP_ITEM (drawable)) ||
gimp_item_is_content_locked (GIMP_ITEM (drawable), &locked_item))
{
gboolean constrain_only;
/* Allow pixel-locked layers to be set as sources */
/* Allow vector/link or pixel-locaked layers to be set as sources */
constrain_only = (state & gimp_get_constrain_behavior_mask () &&
! (state & gimp_get_extend_selection_mask ()));
if (! (GIMP_IS_SOURCE_TOOL (tool) && constrain_only))
{
gimp_tool_message_literal (tool, display,
_("The selected item's pixels are locked."));
gimp_tools_blink_lock_box (display->gimp, locked_item);
g_list_free (drawables);
return;
}
}
if (gimp_item_is_vector_layer (GIMP_ITEM (drawable)))
{
gboolean constrain_only;
/* Allow vector layers to be set as sources */
constrain_only = (state & gimp_get_constrain_behavior_mask () &&
! (state & gimp_get_extend_selection_mask ()));
if (! (GIMP_IS_SOURCE_TOOL (tool) && constrain_only))
{
gimp_tool_message_literal (tool, display,
_("Vector layers must be rasterized "
"before they can be painted on."));
if (gimp_item_is_link_layer (GIMP_ITEM (drawable)))
{
gimp_tool_message_literal (tool, display,
_("Link layers must be rasterized "
"before they can be painted on."));
}
else if (gimp_item_is_vector_layer (GIMP_ITEM (drawable)))
{
gimp_tool_message_literal (tool, display,
_("Vector layers must be rasterized "
"before they can be painted on."));
}
else
{
gimp_tool_message_literal (tool, display,
_("The selected item's pixels are locked."));
gimp_tools_blink_lock_box (display->gimp, locked_item);
}
g_list_free (drawables);
return;