app, libgimp*, modules, pdb, plug-ins: new GimpParamColor.

This is meant to obsolete GeglParamColor with at least an additional argument
has_alpha which we need in GIMP. It allows to advertize when a parameter wants
an opaque color, which in particular means we know when displaying a GUI to pick
colors with alpha or not.
This commit is contained in:
Jehan 2024-04-19 23:02:29 +02:00
parent cbb333c220
commit 2b27feb2fd
50 changed files with 526 additions and 162 deletions

View file

@ -110,10 +110,10 @@ gimp_cell_renderer_color_class_init (GimpCellRendererColorClass *klass)
cell_class->render = gimp_cell_renderer_color_render;
g_object_class_install_property (object_class, PROP_COLOR,
gegl_param_spec_color ("color",
gimp_param_spec_color ("color",
"Color",
"The displayed color",
NULL,
TRUE, NULL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));

View file

@ -181,10 +181,10 @@ gimp_color_area_class_init (GimpColorAreaClass *klass)
* Since: 2.4
*/
g_object_class_install_property (object_class, PROP_COLOR,
gegl_param_spec_color_from_string ("color",
gimp_param_spec_color_from_string ("color",
"Color",
"The displayed color",
"black",
TRUE, "black",
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
/**

View file

@ -237,10 +237,10 @@ gimp_color_button_class_init (GimpColorButtonClass *klass)
* Since: 2.4
*/
g_object_class_install_property (object_class, PROP_COLOR,
gegl_param_spec_color_from_string ("color",
gimp_param_spec_color_from_string ("color",
"Color",
"The color displayed in the button's color area",
"black",
TRUE, "black",
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
/**

View file

@ -113,10 +113,10 @@ gimp_label_color_class_init (GimpLabelColorClass *klass)
*
* Since: 3.0
**/
object_props[PROP_VALUE] = gegl_param_spec_color_from_string ("value",
object_props[PROP_VALUE] = gimp_param_spec_color_from_string ("value",
"Color",
"The displayed color",
"black",
TRUE, "black",
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT);

View file

@ -167,17 +167,17 @@ gimp_preview_area_class_init (GimpPreviewAreaClass *klass)
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_CHECK_CUSTOM_COLOR1,
gegl_param_spec_color ("check-custom-color1",
gimp_param_spec_color ("check-custom-color1",
_("Custom Checks Color 1"),
"The first color of the checkerboard pattern indicating transparency",
color1_default,
FALSE, color1_default,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_CHECK_CUSTOM_COLOR2,
gegl_param_spec_color ("check-custom-color2",
gimp_param_spec_color ("check-custom-color2",
_("Custom Checks Color 2"),
"The second color of the checkerboard pattern indicating transparency",
color2_default,
FALSE, color2_default,
GIMP_PARAM_READWRITE));
g_object_unref (color1_default);

View file

@ -67,6 +67,11 @@ static GParamSpec * check_param_spec_w (GObject *object,
const gchar *property_name,
GType type,
const gchar *strloc);
static GParamSpec * check_param_specs_w (GObject *object,
const gchar *property_name,
GType type1,
GType type2,
const gchar *strloc);
static gboolean get_numeric_values (GObject *object,
GParamSpec *param_spec,
@ -419,35 +424,10 @@ gimp_prop_int_combo_box_new (GObject *config,
g_return_val_if_fail (property_name != NULL, NULL);
/* Require property is integer valued type: INT or ENUM, and is writeable. */
param_spec = check_param_spec_quiet (config, property_name,
G_TYPE_PARAM_INT, G_STRFUNC);
if (param_spec)
{
param_spec = check_param_spec_w (config, property_name,
G_TYPE_PARAM_INT, G_STRFUNC);
if (! param_spec)
return NULL;
}
else
{
param_spec = check_param_spec_quiet (config, property_name,
G_TYPE_PARAM_ENUM, G_STRFUNC);
if (param_spec)
{
param_spec = check_param_spec_w (config, property_name,
G_TYPE_PARAM_ENUM, G_STRFUNC);
if (! param_spec)
return NULL;
}
else
{
g_warning ("%s: property '%s' of %s is not integer valued.",
G_STRFUNC,
param_spec->name,
g_type_name (param_spec->owner_type));
return NULL;
}
}
param_spec = check_param_specs_w (config, property_name, G_TYPE_PARAM_INT,
G_TYPE_PARAM_ENUM, G_STRFUNC);
if (! param_spec)
return NULL;
combo_box = g_object_new (GIMP_TYPE_INT_COMBO_BOX,
"model", store,
@ -4091,8 +4071,8 @@ gimp_prop_color_area_new (GObject *config,
GtkWidget *area;
GeglColor *color = NULL;
param_spec = check_param_spec_w (config, property_name,
GEGL_TYPE_PARAM_COLOR, G_STRFUNC);
param_spec = check_param_specs_w (config, property_name, GEGL_TYPE_PARAM_COLOR,
GIMP_TYPE_PARAM_COLOR, G_STRFUNC);
if (! param_spec)
return NULL;
@ -4199,8 +4179,8 @@ gimp_prop_color_select_new (GObject *config,
GtkWidget *button;
GeglColor *value = NULL;
param_spec = check_param_spec_w (config, property_name,
GEGL_TYPE_PARAM_COLOR, G_STRFUNC);
param_spec = check_param_specs_w (config, property_name, GEGL_TYPE_PARAM_COLOR,
GIMP_TYPE_PARAM_COLOR, G_STRFUNC);
if (! param_spec)
return NULL;
@ -4247,8 +4227,8 @@ gimp_prop_label_color_new (GObject *config,
const gchar *label;
GeglColor *value;
param_spec = check_param_spec_w (config, property_name,
GEGL_TYPE_PARAM_COLOR, G_STRFUNC);
param_spec = check_param_specs_w (config, property_name, GEGL_TYPE_PARAM_COLOR,
GIMP_TYPE_PARAM_COLOR, G_STRFUNC);
if (! param_spec)
return NULL;
@ -4716,6 +4696,44 @@ check_param_spec_w (GObject *object,
return param_spec;
}
static GParamSpec *
check_param_specs_w (GObject *object,
const gchar *property_name,
GType type1,
GType type2,
const gchar *strloc)
{
GParamSpec *param_spec;
param_spec = check_param_spec_quiet (object, property_name, type1, strloc);
if (param_spec)
{
param_spec = check_param_spec_w (object, property_name, type1, strloc);
if (! param_spec)
return NULL;
}
else
{
param_spec = check_param_spec_quiet (object, property_name, type2, strloc);
if (param_spec)
{
param_spec = check_param_spec_w (object, property_name, type2, strloc);
if (! param_spec)
return NULL;
}
}
if (! param_spec)
g_warning ("%s: property '%s' of %s must be of type %s or %s.",
strloc, property_name,
g_type_name (G_TYPE_FROM_INSTANCE (object)),
g_type_name (type1),
g_type_name (type2));
return param_spec;
}
static gboolean
get_numeric_values (GObject *object,
GParamSpec *param_spec,