app: swapping gimp_prop_color_button_new() and gimp_prop_gegl_color_button_new().

Color propwidgets now use GeglColor only.
This commit is contained in:
Jehan 2024-04-18 00:37:20 +02:00
parent 80334f0eba
commit 252f991cfb
9 changed files with 54 additions and 193 deletions

View File

@ -241,13 +241,13 @@ prefs_color_button_add (GObject *config,
*/ */
/*has_alpha = gimp_param_spec_rgb_has_alpha (pspec);*/ /*has_alpha = gimp_param_spec_rgb_has_alpha (pspec);*/
button = gimp_prop_gegl_color_button_new (config, property_name, button = gimp_prop_color_button_new (config, property_name,
title, title,
PREFS_COLOR_BUTTON_WIDTH, PREFS_COLOR_BUTTON_WIDTH,
PREFS_COLOR_BUTTON_HEIGHT, PREFS_COLOR_BUTTON_HEIGHT,
has_alpha ? has_alpha ?
GIMP_COLOR_AREA_SMALL_CHECKS : GIMP_COLOR_AREA_SMALL_CHECKS :
GIMP_COLOR_AREA_FLAT); GIMP_COLOR_AREA_FLAT);
if (button) if (button)
{ {

View File

@ -1346,11 +1346,11 @@ prefs_dialog_new (Gimp *gimp,
_("Mar_k out of gamut colors")); _("Mar_k out of gamut colors"));
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
button = gimp_prop_gegl_color_button_new (color_config, "out-of-gamut-color", button = gimp_prop_color_button_new (color_config, "out-of-gamut-color",
_("Select Warning Color"), _("Select Warning Color"),
PREFS_COLOR_BUTTON_WIDTH, PREFS_COLOR_BUTTON_WIDTH,
PREFS_COLOR_BUTTON_HEIGHT, PREFS_COLOR_BUTTON_HEIGHT,
GIMP_COLOR_AREA_FLAT); GIMP_COLOR_AREA_FLAT);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), gimp_color_panel_set_context (GIMP_COLOR_PANEL (button),

View File

@ -372,12 +372,12 @@ gimp_prop_widget_new_from_pspec (GObject *config,
widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
button = gimp_prop_gegl_color_button_new (config, pspec->name, button = gimp_prop_color_button_new (config, pspec->name,
g_param_spec_get_nick (pspec), g_param_spec_get_nick (pspec),
128, 24, 128, 24,
has_alpha ? has_alpha ?
GIMP_COLOR_AREA_SMALL_CHECKS : GIMP_COLOR_AREA_SMALL_CHECKS :
GIMP_COLOR_AREA_FLAT); GIMP_COLOR_AREA_FLAT);
gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE); gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), context); gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), context);
gtk_box_pack_start (GTK_BOX (widget), button, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (widget), button, TRUE, TRUE, 0);

View File

@ -338,10 +338,10 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
/* mask color */ /* mask color */
button = gimp_prop_gegl_color_button_new (config, "mask-color", button = gimp_prop_color_button_new (config, "mask-color",
NULL, NULL,
128, 24, 128, 24,
GIMP_COLOR_AREA_SMALL_CHECKS); GIMP_COLOR_AREA_SMALL_CHECKS);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), gimp_color_panel_set_context (GIMP_COLOR_PANEL (button),
GIMP_CONTEXT (config)); GIMP_CONTEXT (config));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

View File

@ -842,8 +842,8 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
button, 1); button, 1);
gtk_size_group_add_widget (size_group, button); gtk_size_group_add_widget (size_group, button);
button = gimp_prop_gegl_color_button_new (config, "foreground", _("Text Color"), button = gimp_prop_color_button_new (config, "foreground", _("Text Color"),
40, 24, GIMP_COLOR_AREA_FLAT); 40, 24, GIMP_COLOR_AREA_FLAT);
gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE); gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), gimp_color_panel_set_context (GIMP_COLOR_PANEL (button),
GIMP_CONTEXT (options)); GIMP_CONTEXT (options));

View File

@ -137,11 +137,11 @@ gimp_fill_editor_constructed (GObject *object)
if (editor->use_custom_style) if (editor->use_custom_style)
{ {
color_button = gimp_prop_gegl_color_button_new (G_OBJECT (editor->options), color_button = gimp_prop_color_button_new (G_OBJECT (editor->options),
"foreground", "foreground",
_("Fill Color"), _("Fill Color"),
1, 24, 1, 24,
GIMP_COLOR_AREA_SMALL_CHECKS); GIMP_COLOR_AREA_SMALL_CHECKS);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
GIMP_CONTEXT (editor->options)); GIMP_CONTEXT (editor->options));
gimp_enum_radio_box_add (GTK_BOX (box), color_button, gimp_enum_radio_box_add (GTK_BOX (box), color_button,
@ -149,21 +149,21 @@ gimp_fill_editor_constructed (GObject *object)
} }
else else
{ {
color_button = gimp_prop_gegl_color_button_new (G_OBJECT (editor->options), color_button = gimp_prop_color_button_new (G_OBJECT (editor->options),
"foreground", "foreground",
_("Fill Color"), _("Fill Color"),
1, 24, 1, 24,
GIMP_COLOR_AREA_SMALL_CHECKS); GIMP_COLOR_AREA_SMALL_CHECKS);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
GIMP_CONTEXT (editor->options)); GIMP_CONTEXT (editor->options));
gimp_enum_radio_box_add (GTK_BOX (box), color_button, gimp_enum_radio_box_add (GTK_BOX (box), color_button,
GIMP_FILL_STYLE_FG_COLOR, FALSE); GIMP_FILL_STYLE_FG_COLOR, FALSE);
color_button = gimp_prop_gegl_color_button_new (G_OBJECT (editor->options), color_button = gimp_prop_color_button_new (G_OBJECT (editor->options),
"background", "background",
_("Fill BG Color"), _("Fill BG Color"),
1, 24, 1, 24,
GIMP_COLOR_AREA_SMALL_CHECKS); GIMP_COLOR_AREA_SMALL_CHECKS);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
GIMP_CONTEXT (editor->options)); GIMP_CONTEXT (editor->options));
gimp_enum_radio_box_add (GTK_BOX (box), color_button, gimp_enum_radio_box_add (GTK_BOX (box), color_button,

View File

@ -146,11 +146,11 @@ gimp_grid_editor_constructed (GObject *object)
_("Line _style:"), 0.0, 0.5, _("Line _style:"), 0.0, 0.5,
style, 1); style, 1);
color_button = gimp_prop_gegl_color_button_new (G_OBJECT (editor->grid), "fgcolor", color_button = gimp_prop_color_button_new (G_OBJECT (editor->grid), "fgcolor",
_("Change grid foreground color"), _("Change grid foreground color"),
GRID_EDITOR_COLOR_BUTTON_WIDTH, GRID_EDITOR_COLOR_BUTTON_WIDTH,
GRID_EDITOR_COLOR_BUTTON_HEIGHT, GRID_EDITOR_COLOR_BUTTON_HEIGHT,
GIMP_COLOR_AREA_FLAT); GIMP_COLOR_AREA_FLAT);
gtk_widget_set_halign (color_button, GTK_ALIGN_START); gtk_widget_set_halign (color_button, GTK_ALIGN_START);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
editor->context); editor->context);
@ -158,11 +158,11 @@ gimp_grid_editor_constructed (GObject *object)
_("_Foreground color:"), 0.0, 0.5, _("_Foreground color:"), 0.0, 0.5,
color_button, 1); color_button, 1);
color_button = gimp_prop_gegl_color_button_new (G_OBJECT (editor->grid), "bgcolor", color_button = gimp_prop_color_button_new (G_OBJECT (editor->grid), "bgcolor",
_("Change grid background color"), _("Change grid background color"),
GRID_EDITOR_COLOR_BUTTON_WIDTH, GRID_EDITOR_COLOR_BUTTON_WIDTH,
GRID_EDITOR_COLOR_BUTTON_HEIGHT, GRID_EDITOR_COLOR_BUTTON_HEIGHT,
GIMP_COLOR_AREA_FLAT); GIMP_COLOR_AREA_FLAT);
gtk_widget_set_halign (color_button, GTK_ALIGN_START); gtk_widget_set_halign (color_button, GTK_ALIGN_START);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
editor->context); editor->context);

View File

@ -337,11 +337,6 @@ gimp_prop_layer_mode_box_new (GObject *config,
/* color button */ /* color button */
/******************/ /******************/
static void gimp_prop_color_button_callback (GtkWidget *widget,
GObject *config);
static void gimp_prop_color_button_notify (GObject *config,
GParamSpec *param_spec,
GtkWidget *button);
static void gimp_prop_gegl_color_button_callback (GtkWidget *widget, static void gimp_prop_gegl_color_button_callback (GtkWidget *widget,
GObject *config); GObject *config);
static void gimp_prop_gegl_color_button_notify (GObject *config, static void gimp_prop_gegl_color_button_notify (GObject *config,
@ -351,13 +346,13 @@ static void gimp_prop_gegl_color_button_notify (GObject *config,
/** /**
* gimp_prop_color_button_new: * gimp_prop_color_button_new:
* @config: #GimpConfig object to which property is attached. * @config: #GimpConfig object to which property is attached.
* @property_name: Name of #GimpRGB property. * @property_name: Name of #GeglColor property.
* @title: Title of the #GimpColorPanel that is to be created * @title: Title of the #GimpColorPanel that is to be created
* @width: Width of color button. * @width: Width of color button.
* @height: Height of color button. * @height: Height of color button.
* @type: How transparency is represented. * @type: How transparency is represented.
* *
* Creates a #GimpColorPanel to set and display the value of a #GimpRGB * Creates a #GimpColorPanel to set and display the value of a #GeglColor
* property. Pressing the button brings up a color selector dialog. * property. Pressing the button brings up a color selector dialog.
* If @title is %NULL, the @property_name's nick will be used as label * If @title is %NULL, the @property_name's nick will be used as label
* of the returned widget. * of the returned widget.
@ -373,73 +368,6 @@ gimp_prop_color_button_new (GObject *config,
gint width, gint width,
gint height, gint height,
GimpColorAreaType type) GimpColorAreaType type)
{
GParamSpec *param_spec;
GtkWidget *button;
GeglColor *color;
GimpRGB *value;
param_spec = check_param_spec_w (config, property_name,
GIMP_TYPE_PARAM_RGB, G_STRFUNC);
if (! param_spec)
return NULL;
if (! title)
title = g_param_spec_get_nick (param_spec);
g_object_get (config,
property_name, &value,
NULL);
color = gegl_color_new (NULL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), value);
button = gimp_color_panel_new (title, color, type, width, height);
g_free (value);
g_object_unref (color);
set_param_spec (G_OBJECT (button), button, param_spec);
g_signal_connect (button, "color-changed",
G_CALLBACK (gimp_prop_color_button_callback),
config);
connect_notify (config, property_name,
G_CALLBACK (gimp_prop_color_button_notify),
button);
gimp_widget_set_bound_property (button, config, property_name);
gtk_widget_show (button);
return button;
}
/**
* gimp_prop_gegl_color_button_new:
* @config: #GimpConfig object to which property is attached.
* @property_name: Name of #GeglColor property.
* @title: Title of the #GimpColorPanel that is to be created
* @width: Width of color button.
* @height: Height of color button.
* @type: How transparency is represented.
*
* Creates a #GimpColorPanel to set and display the value of a #GeglColor
* property. Pressing the button brings up a color selector dialog.
* If @title is %NULL, the @property_name's nick will be used as label
* of the returned widget.
*
* TODO: this is meant to replace completely gimp_prop_color_button_new().
*
* Returns: A new #GimpColorPanel widget.
*
* Since GIMP 2.4
*/
GtkWidget *
gimp_prop_gegl_color_button_new (GObject *config,
const gchar *property_name,
const gchar *title,
gint width,
gint height,
GimpColorAreaType type)
{ {
GParamSpec *param_spec; GParamSpec *param_spec;
GtkWidget *button; GtkWidget *button;
@ -476,64 +404,6 @@ gimp_prop_gegl_color_button_new (GObject *config,
return button; return button;
} }
static void
gimp_prop_color_button_callback (GtkWidget *button,
GObject *config)
{
GParamSpec *param_spec;
GeglColor *color;
GimpRGB rgb;
param_spec = get_param_spec (G_OBJECT (button));
if (! param_spec)
return;
color = gimp_color_button_get_color (GIMP_COLOR_BUTTON (button));
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
g_signal_handlers_block_by_func (config,
gimp_prop_color_button_notify,
button);
g_object_set (config,
param_spec->name, &rgb,
NULL);
g_signal_handlers_unblock_by_func (config,
gimp_prop_color_button_notify,
button);
g_object_unref (color);
}
static void
gimp_prop_color_button_notify (GObject *config,
GParamSpec *param_spec,
GtkWidget *button)
{
GeglColor *color;
GimpRGB *rgb;
g_object_get (config,
param_spec->name, &rgb,
NULL);
g_signal_handlers_block_by_func (button,
gimp_prop_color_button_callback,
config);
color = gegl_color_new (NULL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (button), color);
g_object_unref (color);
g_free (rgb);
g_signal_handlers_unblock_by_func (button,
gimp_prop_color_button_callback,
config);
}
static void static void
gimp_prop_gegl_color_button_callback (GtkWidget *button, gimp_prop_gegl_color_button_callback (GtkWidget *button,
GObject *config) GObject *config)
@ -572,14 +442,14 @@ gimp_prop_gegl_color_button_notify (GObject *config,
NULL); NULL);
g_signal_handlers_block_by_func (button, g_signal_handlers_block_by_func (button,
gimp_prop_color_button_callback, gimp_prop_gegl_color_button_callback,
config); config);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (button), color); gimp_color_button_set_color (GIMP_COLOR_BUTTON (button), color);
g_clear_object (&color); g_clear_object (&color);
g_signal_handlers_unblock_by_func (button, g_signal_handlers_unblock_by_func (button,
gimp_prop_color_button_callback, gimp_prop_gegl_color_button_callback,
config); config);
} }

View File

@ -45,18 +45,9 @@ GtkWidget * gimp_prop_layer_mode_box_new (GObject *config,
GimpLayerModeContext context); GimpLayerModeContext context);
/* GimpParamColor */
GtkWidget * gimp_prop_color_button_new (GObject *config,
const gchar *property_name,
const gchar *title,
gint width,
gint height,
GimpColorAreaType type);
/* GeglParamColor */ /* GeglParamColor */
GtkWidget * gimp_prop_gegl_color_button_new (GObject *config, GtkWidget * gimp_prop_color_button_new (GObject *config,
const gchar *property_name, const gchar *property_name,
const gchar *title, const gchar *title,
gint width, gint width,