From 9417565ea2f3ac97676a4a8b38704366e42c6e05 Mon Sep 17 00:00:00 2001 From: Jehan Date: Tue, 3 Feb 2026 12:15:14 +0100 Subject: [PATCH] Issue #15575: add arg to color button prop widget to choose context awareness. In particular, for indexed images, color choice will happen within the colormap. The following uses are made context-aware: * Test tool options color; * Fill colors. These other uses will not be context-aware: * Padding, quick-mask and padding colors; * Out-of-gamut colors; * Generically generated color buttons (e.g. in filter dialogs); * Foreground selection's mask color; * Grid colors. --- app/dialogs/preferences-dialog-utils.c | 2 +- app/dialogs/preferences-dialog.c | 2 +- app/propgui/gimppropgui.c | 2 +- app/tools/gimpforegroundselectoptions.c | 2 +- app/tools/gimptextoptions.c | 2 +- app/widgets/gimpfilleditor.c | 6 +++--- app/widgets/gimpgrideditor.c | 2 ++ app/widgets/gimppropwidgets.c | 4 ++++ app/widgets/gimppropwidgets.h | 1 + 9 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/dialogs/preferences-dialog-utils.c b/app/dialogs/preferences-dialog-utils.c index 9ad9535d50..61d6fc97ae 100644 --- a/app/dialogs/preferences-dialog-utils.c +++ b/app/dialogs/preferences-dialog-utils.c @@ -241,7 +241,7 @@ prefs_color_button_add (GObject *config, has_alpha = gimp_param_spec_color_has_alpha (pspec); button = gimp_prop_color_button_new (config, property_name, - title, + title, FALSE, PREFS_COLOR_BUTTON_WIDTH, PREFS_COLOR_BUTTON_HEIGHT, has_alpha ? diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index 854295209f..c886263e3e 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -1452,7 +1452,7 @@ prefs_dialog_new (Gimp *gimp, gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); button = gimp_prop_color_button_new (color_config, "out-of-gamut-color", - _("Select Warning Color"), + _("Select Warning Color"), FALSE, PREFS_COLOR_BUTTON_WIDTH, PREFS_COLOR_BUTTON_HEIGHT, GIMP_COLOR_AREA_FLAT); diff --git a/app/propgui/gimppropgui.c b/app/propgui/gimppropgui.c index 20ab68a71f..11273f15f5 100644 --- a/app/propgui/gimppropgui.c +++ b/app/propgui/gimppropgui.c @@ -373,7 +373,7 @@ gimp_prop_widget_new_from_pspec (GObject *config, button = gimp_prop_color_button_new (config, pspec->name, g_param_spec_get_nick (pspec), - 128, 24, + FALSE, 128, 24, has_alpha ? GIMP_COLOR_AREA_SMALL_CHECKS : GIMP_COLOR_AREA_FLAT); diff --git a/app/tools/gimpforegroundselectoptions.c b/app/tools/gimpforegroundselectoptions.c index 055237035e..43bf8a7716 100644 --- a/app/tools/gimpforegroundselectoptions.c +++ b/app/tools/gimpforegroundselectoptions.c @@ -339,7 +339,7 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options) /* mask color */ button = gimp_prop_color_button_new (config, "mask-color", - NULL, + NULL, FALSE, 128, 24, GIMP_COLOR_AREA_SMALL_CHECKS); gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), diff --git a/app/tools/gimptextoptions.c b/app/tools/gimptextoptions.c index 7562edf209..d1d3f84ec1 100644 --- a/app/tools/gimptextoptions.c +++ b/app/tools/gimptextoptions.c @@ -859,7 +859,7 @@ gimp_text_options_gui (GimpToolOptions *tool_options) gtk_size_group_add_widget (size_group, button); button = gimp_prop_color_button_new (config, "foreground", _("Text Color"), - 40, 24, GIMP_COLOR_AREA_FLAT); + TRUE, 40, 24, GIMP_COLOR_AREA_FLAT); gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE); gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), GIMP_CONTEXT (options)); diff --git a/app/widgets/gimpfilleditor.c b/app/widgets/gimpfilleditor.c index 663e6c5c1c..68e2b7d8fe 100644 --- a/app/widgets/gimpfilleditor.c +++ b/app/widgets/gimpfilleditor.c @@ -143,7 +143,7 @@ gimp_fill_editor_constructed (GObject *object) { color_button = gimp_prop_color_button_new (G_OBJECT (editor->options), "foreground", - _("Fill Color"), + _("Fill Color"), TRUE, 1, 24, GIMP_COLOR_AREA_SMALL_CHECKS); gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), @@ -162,7 +162,7 @@ gimp_fill_editor_constructed (GObject *object) { color_button = gimp_prop_color_button_new (G_OBJECT (editor->options), "foreground", - _("Fill Color"), + _("Fill Color"), TRUE, 1, 24, GIMP_COLOR_AREA_SMALL_CHECKS); gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), @@ -173,7 +173,7 @@ gimp_fill_editor_constructed (GObject *object) color_button = gimp_prop_color_button_new (G_OBJECT (editor->options), "background", - _("Fill BG Color"), + _("Fill BG Color"), TRUE, 1, 24, GIMP_COLOR_AREA_SMALL_CHECKS); gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), diff --git a/app/widgets/gimpgrideditor.c b/app/widgets/gimpgrideditor.c index 9db1861857..c68b9e2c29 100644 --- a/app/widgets/gimpgrideditor.c +++ b/app/widgets/gimpgrideditor.c @@ -148,6 +148,7 @@ gimp_grid_editor_constructed (GObject *object) color_button = gimp_prop_color_button_new (G_OBJECT (editor->grid), "fgcolor", _("Change grid foreground color"), + FALSE, GRID_EDITOR_COLOR_BUTTON_WIDTH, GRID_EDITOR_COLOR_BUTTON_HEIGHT, GIMP_COLOR_AREA_FLAT); @@ -162,6 +163,7 @@ gimp_grid_editor_constructed (GObject *object) color_button = gimp_prop_color_button_new (G_OBJECT (editor->grid), "bgcolor", _("Change grid background color"), + FALSE, GRID_EDITOR_COLOR_BUTTON_WIDTH, GRID_EDITOR_COLOR_BUTTON_HEIGHT, GIMP_COLOR_AREA_FLAT); diff --git a/app/widgets/gimppropwidgets.c b/app/widgets/gimppropwidgets.c index 082cd7d4ae..89283b3192 100644 --- a/app/widgets/gimppropwidgets.c +++ b/app/widgets/gimppropwidgets.c @@ -347,6 +347,7 @@ static void gimp_prop_gegl_color_button_notify (GObject *config, * gimp_prop_color_button_new: * @config: #GimpConfig object to which property is attached. * @property_name: Name of #GeglColor property. + * @user_context_aware: whether color selection should be context-aware. * @title: Title of the #GimpColorPanel that is to be created * @width: Width of color button. * @height: Height of color button. @@ -365,6 +366,7 @@ GtkWidget * gimp_prop_color_button_new (GObject *config, const gchar *property_name, const gchar *title, + gboolean user_context_aware, gint width, gint height, GimpColorAreaType type) @@ -386,6 +388,8 @@ gimp_prop_color_button_new (GObject *config, NULL); button = gimp_color_panel_new (title, color, type, width, height); + gimp_color_panel_set_user_context_aware (GIMP_COLOR_PANEL (button), + user_context_aware); g_clear_object (&color); set_param_spec (G_OBJECT (button), button, param_spec); diff --git a/app/widgets/gimppropwidgets.h b/app/widgets/gimppropwidgets.h index a9256bd470..4b00304230 100644 --- a/app/widgets/gimppropwidgets.h +++ b/app/widgets/gimppropwidgets.h @@ -49,6 +49,7 @@ GtkWidget * gimp_prop_layer_mode_box_new (GObject *config, GtkWidget * gimp_prop_color_button_new (GObject *config, const gchar *property_name, const gchar *title, + gboolean user_context_aware, gint width, gint height, GimpColorAreaType type);