From 258344031cce40d254cf5b32ae0f51422cc92e77 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Sat, 10 May 2025 14:18:41 +0000 Subject: [PATCH] widgets: Allow color dialogues to not match the image mode For some GUI elements, we may not want to restrict the color options to the image mode (for instance, grid colors on a grayscale or indexed image). This patch adds a "user_context_aware" boolean to GimpColorPanel so it can be passed on to set the same boolean already in GimpColorDialog. This allows GUI elements like GimpGridEditor to optionally give full color choices to users, independent of the image mode. --- app/widgets/gimpcolorpanel.c | 17 ++++++++++++++--- app/widgets/gimpcolorpanel.h | 6 ++++++ app/widgets/gimpgrideditor.c | 4 ++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/widgets/gimpcolorpanel.c b/app/widgets/gimpcolorpanel.c index 2efd9b4295..e369f9e2cb 100644 --- a/app/widgets/gimpcolorpanel.c +++ b/app/widgets/gimpcolorpanel.c @@ -101,8 +101,9 @@ gimp_color_panel_class_init (GimpColorPanelClass *klass) static void gimp_color_panel_init (GimpColorPanel *panel) { - panel->context = NULL; - panel->color_dialog = NULL; + panel->context = NULL; + panel->color_dialog = NULL; + panel->user_context_aware = TRUE; } static void @@ -183,7 +184,8 @@ gimp_color_panel_clicked (GtkButton *button) GimpColorButton *color_button = GIMP_COLOR_BUTTON (button); panel->color_dialog = - gimp_color_dialog_new (NULL, panel->context, TRUE, + gimp_color_dialog_new (NULL, panel->context, + panel->user_context_aware, gimp_color_button_get_title (color_button), NULL, NULL, GTK_WIDGET (button), @@ -275,6 +277,15 @@ gimp_color_panel_set_context (GimpColorPanel *panel, context->gimp->config->color_management); } +void +gimp_color_panel_set_user_context_aware (GimpColorPanel *panel, + gboolean user_context_aware) +{ + g_return_if_fail (GIMP_IS_COLOR_PANEL (panel)); + + panel->user_context_aware = user_context_aware; +} + void gimp_color_panel_dialog_response (GimpColorPanel *panel, GimpColorDialogState state) diff --git a/app/widgets/gimpcolorpanel.h b/app/widgets/gimpcolorpanel.h index ca7a684bc7..b5b319c13d 100644 --- a/app/widgets/gimpcolorpanel.h +++ b/app/widgets/gimpcolorpanel.h @@ -35,6 +35,8 @@ struct _GimpColorPanel GimpContext *context; GtkWidget *color_dialog; + + gboolean user_context_aware; }; struct _GimpColorPanelClass @@ -58,6 +60,10 @@ GtkWidget * gimp_color_panel_new (const gchar *title, void gimp_color_panel_set_context (GimpColorPanel *panel, GimpContext *context); +void gimp_color_panel_set_user_context_aware + (GimpColorPanel *panel, + gboolean user_context_aware); + void gimp_color_panel_dialog_response (GimpColorPanel *panel, GimpColorDialogState state); diff --git a/app/widgets/gimpgrideditor.c b/app/widgets/gimpgrideditor.c index 1a26835167..9db1861857 100644 --- a/app/widgets/gimpgrideditor.c +++ b/app/widgets/gimpgrideditor.c @@ -154,6 +154,8 @@ gimp_grid_editor_constructed (GObject *object) gtk_widget_set_halign (color_button, GTK_ALIGN_START); gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), editor->context); + gimp_color_panel_set_user_context_aware (GIMP_COLOR_PANEL (color_button), + FALSE); gimp_grid_attach_aligned (GTK_GRID (grid), 0, 1, _("_Foreground color:"), 0.0, 0.5, color_button, 1); @@ -166,6 +168,8 @@ gimp_grid_editor_constructed (GObject *object) gtk_widget_set_halign (color_button, GTK_ALIGN_START); gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), editor->context); + gimp_color_panel_set_user_context_aware (GIMP_COLOR_PANEL (color_button), + FALSE); gimp_grid_attach_aligned (GTK_GRID (grid), 0, 2, _("_Background color:"), 0.0, 0.5, color_button, 1);