From 045c818d0e2927e7dc04dec6a73865f48b1be2f1 Mon Sep 17 00:00:00 2001 From: Jehan Date: Mon, 9 Mar 2026 14:15:03 +0100 Subject: [PATCH] Issue #15962: initialize Levels dialog in Perceptual. Unlike for Curves (commit 7b4f0993e8), we cannot just change the "trc" default of "gimp:levels", because then it could break any existing script, made during the 3.0 series, which was applying this filter on layers. Instead, the "trc" stays linear by default for the op, but the tool's dialog will override it to perceptual. When we'll have implemented proper op versioning, we will be able to change the default. --- app/operations/gimplevelsconfig.c | 5 +++++ app/tools/gimplevelstool.c | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/operations/gimplevelsconfig.c b/app/operations/gimplevelsconfig.c index d88f358999..d1783d2091 100644 --- a/app/operations/gimplevelsconfig.c +++ b/app/operations/gimplevelsconfig.c @@ -106,6 +106,11 @@ gimp_levels_config_class_init (GimpLevelsConfigClass *klass) viewable_class->default_icon_name = "gimp-tool-levels"; + /* "trc" should default to GIMP_TRC_PERCEPTUAL (cf. #15962). + * We cannot change it until we implement GEGL op versioning. + * In GIMP 3.0, calling this op from the public API was always run in + * linear (#15681). + */ GIMP_CONFIG_PROP_ENUM (object_class, PROP_TRC, "trc", _("Tone Reproduction Curve"), diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c index a1185c11fb..4dd861bb2d 100644 --- a/app/tools/gimplevelstool.c +++ b/app/tools/gimplevelstool.c @@ -407,6 +407,13 @@ gimp_levels_tool_dialog (GimpFilterTool *filter_tool) gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0); /* The linear/perceptual radio buttons */ + /* XXX: override the default to Perceptual for the time being, until + * we are able to change "gimp:levels" default for "trc" directly. + * See #15962. + */ + g_object_set (config, + "trc", GIMP_TRC_PERCEPTUAL, + NULL); hbox2 = gimp_prop_enum_icon_box_new (G_OBJECT (config), "trc", "gimp-color-space", -1, -1); @@ -668,6 +675,12 @@ gimp_levels_tool_reset (GimpFilterTool *filter_tool) g_object_set (filter_tool->config, "channel", channel, NULL); + /* XXX: the tool defaults to Perceptual, unlike the op. + * See #15962. + */ + g_object_set (filter_tool->config, + "trc", GIMP_TRC_PERCEPTUAL, + NULL); } static void