app, libgimp*, pdb, plug-ins: remove GimpRGB support in GIMP protocol.

There are no plug-ins which uses GimpRGB for procedure argument, nor is there
any base PDB procedure. We don't pass this type anymore through from/to
core/plug-ins. So let's clean the whole code out as a next step to get rid of
GimpRGB from our codebase!
This commit is contained in:
Jehan 2024-04-19 14:34:22 +02:00
parent 70b8e49e01
commit a50759cda8
19 changed files with 23 additions and 666 deletions

View File

@ -446,16 +446,15 @@ dump_describe_param (GParamSpec *param_spec)
param_spec->name);
}
if (GIMP_IS_PARAM_SPEC_RGB (param_spec))
if (GEGL_IS_PARAM_SPEC_COLOR (param_spec))
{
if (gimp_param_spec_rgb_has_alpha (param_spec))
values =
"The color is specified in the form (color-rgba red green blue "
"alpha) with channel values as floats in the range of 0.0 to 1.0.";
/* TODO: implement has_alpha parameter to color parameters. */
#if 0
if (gimp_param_spec_color_has_alpha (param_spec))
values = "The color is specified as opaque GeglColor (any Alpha channel is ignored).";
else
values =
"The color is specified in the form (color-rgb red green blue) "
"with channel values as floats in the range of 0.0 to 1.0.";
#endif
values = "The color is specified as GeglColor.";
}
else if (GIMP_IS_PARAM_SPEC_MEMSIZE (param_spec))
{

View File

@ -115,7 +115,6 @@ static void
gimp_display_config_class_init (GimpDisplayConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpRGB xor_rgb = { 0, 0, 0, 0 };
GeglColor *color = gegl_color_new (NULL);
object_class->finalize = gimp_display_config_finalize;
@ -379,12 +378,12 @@ gimp_display_config_class_init (GimpDisplayConfigClass *klass)
GIMP_PARAM_STATIC_STRINGS |
GIMP_CONFIG_PARAM_IGNORE);
GIMP_CONFIG_PROP_RGB (object_class, PROP_XOR_COLOR,
"xor-color",
NULL, NULL,
FALSE, &xor_rgb,
GIMP_PARAM_STATIC_STRINGS |
GIMP_CONFIG_PARAM_IGNORE);
GIMP_CONFIG_PROP_COLOR (object_class, PROP_XOR_COLOR,
"xor-color",
NULL, NULL,
color,
GIMP_PARAM_STATIC_STRINGS |
GIMP_CONFIG_PARAM_IGNORE);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_PERFECT_MOUSE,
"perfect-mouse",

View File

@ -907,27 +907,6 @@ plug_in_proc_arg_deserialize (GScanner *scanner,
}
break;
case GP_PARAM_DEF_TYPE_COLOR:
if (! gimp_scanner_parse_int (scanner,
&param_def.meta.m_color.has_alpha))
{
token = G_TOKEN_INT;
goto error;
}
if (! gimp_scanner_parse_float (scanner,
&param_def.meta.m_color.default_val.r) ||
! gimp_scanner_parse_float (scanner,
&param_def.meta.m_color.default_val.g) ||
! gimp_scanner_parse_float (scanner,
&param_def.meta.m_color.default_val.b) ||
! gimp_scanner_parse_float (scanner,
&param_def.meta.m_color.default_val.a))
{
token = G_TOKEN_FLOAT;
goto error;
}
break;
case GP_PARAM_DEF_TYPE_GEGL_COLOR:
{
GPParamColor *default_val = NULL;
@ -1052,7 +1031,6 @@ plug_in_proc_arg_deserialize (GScanner *scanner,
}
break;
case GP_PARAM_DEF_TYPE_COLOR:
case GP_PARAM_DEF_TYPE_ID:
break;
@ -1201,20 +1179,6 @@ plug_in_rc_write_proc_arg (GimpConfigWriter *writer,
param_def.meta.m_string.default_val);
break;
case GP_PARAM_DEF_TYPE_COLOR:
g_ascii_dtostr (buf[0], sizeof (buf[0]),
param_def.meta.m_color.default_val.r);
g_ascii_dtostr (buf[1], sizeof (buf[1]),
param_def.meta.m_color.default_val.g),
g_ascii_dtostr (buf[2], sizeof (buf[2]),
param_def.meta.m_color.default_val.b);
g_ascii_dtostr (buf[3], sizeof (buf[3]),
param_def.meta.m_color.default_val.a);
gimp_config_writer_printf (writer, "%d %s %s %s %s",
param_def.meta.m_color.has_alpha,
buf[0], buf[1], buf[2], buf[3]);
break;
case GP_PARAM_DEF_TYPE_GEGL_COLOR:
{
gint bpp = 0;

View File

@ -56,11 +56,6 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
! strcmp (param_def->value_type_name, "GFile"))
return g_param_spec_object (name, nick, blurb, G_TYPE_FILE, flags);
if (! strcmp (param_def->type_name, "GParamBoxed") &&
! strcmp (param_def->value_type_name, "GimpRGB"))
/* Unfortunately this type loses default and alpha info. */
return gimp_param_spec_rgb (name, nick, blurb, TRUE, NULL, flags);
if (! strcmp (param_def->type_name, "GParamBoxed") &&
! strcmp (param_def->value_type_name, "GStrv"))
return g_param_spec_boxed (name, nick, blurb, G_TYPE_STRV, flags);
@ -156,14 +151,6 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
flags);
break;
case GP_PARAM_DEF_TYPE_COLOR:
if (! strcmp (param_def->type_name, "GimpParamRGB"))
return gimp_param_spec_rgb (name, nick, blurb,
param_def->meta.m_color.has_alpha,
&param_def->meta.m_color.default_val,
flags);
break;
case GP_PARAM_DEF_TYPE_GEGL_COLOR:
if (! strcmp (param_def->type_name, "GeglParamColor"))
{
@ -409,24 +396,14 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
param_def->meta.m_string.default_val = gsspec->default_value;
}
else if (pspec_type == GIMP_TYPE_PARAM_RGB)
{
param_def->param_def_type = GP_PARAM_DEF_TYPE_COLOR;
param_def->meta.m_color.has_alpha =
gimp_param_spec_rgb_has_alpha (pspec);
gimp_param_spec_rgb_get_default (pspec,
&param_def->meta.m_color.default_val);
}
else if (GEGL_IS_PARAM_SPEC_COLOR (pspec))
{
GPParamColor *default_val = NULL;
GeglColor *default_color;
param_def->param_def_type = GP_PARAM_DEF_TYPE_GEGL_COLOR;
param_def->param_def_type = GP_PARAM_DEF_TYPE_GEGL_COLOR;
/* TODO: no no-alpha support for the time being. */
param_def->meta.m_color.has_alpha = TRUE;
/*param_def->meta.m_gegl_color.has_alpha = TRUE;*/
default_color = gegl_param_spec_color_get_default (pspec);
if (default_color != NULL)
@ -755,10 +732,6 @@ gimp_gp_param_to_value (gpointer gimp,
g_value_take_object (value, color);
}
else if (GIMP_VALUE_HOLDS_RGB (value))
{
gimp_value_set_rgb (value, &param->data.d_color);
}
else if (GIMP_VALUE_HOLDS_PARASITE (value))
{
g_value_set_boxed (value, &param->data.d_parasite);
@ -1063,12 +1036,6 @@ gimp_value_to_gp_param (const GValue *value,
param->data.d_string = file ? g_file_get_uri (file) : NULL;
}
else if (GIMP_VALUE_HOLDS_RGB (value))
{
param->param_type = GP_PARAM_TYPE_COLOR;
gimp_value_get_rgb (value, &param->data.d_color);
}
else if (GIMP_VALUE_HOLDS_COLOR (value))
{
GeglColor *color;
@ -1357,9 +1324,6 @@ _gimp_gp_params_free (GPParam *params,
g_free (params[i].data.d_string);
break;
case GP_PARAM_TYPE_COLOR:
break;
case GP_PARAM_TYPE_GEGL_COLOR:
break;

View File

@ -319,33 +319,6 @@ G_BEGIN_DECLS
g_value_set_object (gimp_value_array_index (args, n), value)
/* rgb */
#define GIMP_PROC_ARG_RGB(procedure, name, nick, blurb, has_alpha, default, flags) \
gimp_procedure_add_argument (procedure,\
gimp_param_spec_rgb (name, nick, blurb,\
has_alpha, default, \
flags))
#define GIMP_PROC_AUX_ARG_RGB(procedure, name, nick, blurb, has_alpha, default, flags) \
gimp_procedure_add_aux_argument (procedure,\
gimp_param_spec_rgb (name, nick, blurb,\
has_alpha, default, \
flags))
#define GIMP_PROC_VAL_RGB(procedure, name, nick, blurb, has_alpha, default, flags) \
gimp_procedure_add_return_value (procedure,\
gimp_param_spec_rgb (name, nick, blurb,\
has_alpha, default, \
flags))
#define GIMP_VALUES_GET_RGB(args, n, value) \
gimp_value_get_rgb (gimp_value_array_index (args, n), value)
#define GIMP_VALUES_SET_RGB(args, n, value) \
gimp_value_set_rgb (gimp_value_array_index (args, n), value)
/* parasite */
#define GIMP_PROC_ARG_PARASITE(procedure, name, nick, blurb, flags) \

View File

@ -883,16 +883,16 @@ gimp_procedure_dialog_get_widget (GimpProcedureDialog *dialog,
/**
* gimp_procedure_dialog_get_color_widget:
* @dialog: the associated #GimpProcedureDialog.
* @property: name of the #GimpRGB property to build a widget for. It
* @property: name of the #GeglColor property to build a widget for. It
* must be a property of the #GimpProcedure @dialog has been
* created for.
* @editable: whether the color can be edited or is only for display.
* @type: the #GimpColorAreaType.
*
* Creates a new widget for @property which must necessarily be a
* #GimpRGB property.
* #GeglColor property.
* This must be used instead of gimp_procedure_dialog_get_widget() when
* you want a #GimpLabelColor which is not customizable for an RGB
* you want a #GimpLabelColor which is not customizable for a color
* property, or when to set a specific @type.
*
* If a widget has already been created for this procedure, it will be
@ -928,7 +928,7 @@ gimp_procedure_dialog_get_color_widget (GimpProcedureDialog *dialog,
return NULL;
}
if (G_PARAM_SPEC_TYPE (pspec) == GIMP_TYPE_PARAM_RGB)
if (G_PARAM_SPEC_TYPE (pspec) == GEGL_TYPE_PARAM_COLOR)
{
widget = gimp_prop_label_color_new (G_OBJECT (dialog->priv->config),
property, editable);
@ -953,7 +953,6 @@ gimp_procedure_dialog_get_color_widget (GimpProcedureDialog *dialog,
gimp_help_set_help_data (label, tooltip, NULL);
}
gimp_procedure_dialog_check_mnemonic (dialog, widget, property, NULL);
g_hash_table_insert (dialog->priv->widgets, g_strdup (property), widget);
if (g_object_is_floating (widget))

View File

@ -1216,16 +1216,6 @@ _gp_param_def_read (GIOChannel *channel,
return FALSE;
break;
case GP_PARAM_DEF_TYPE_COLOR:
if (! _gimp_wire_read_int32 (channel,
(guint32 *) &param_def->meta.m_color.has_alpha, 1,
user_data) ||
! _gimp_wire_read_color (channel,
&param_def->meta.m_color.default_val, 1,
user_data))
return FALSE;
break;
case GP_PARAM_DEF_TYPE_GEGL_COLOR:
{
GPParamColor *default_val = NULL;
@ -1332,7 +1322,6 @@ _gp_param_def_destroy (GPParamDef *param_def)
g_free (param_def->meta.m_gegl_color.default_val);
break;
case GP_PARAM_DEF_TYPE_COLOR:
case GP_PARAM_DEF_TYPE_ID:
break;
@ -1566,16 +1555,6 @@ _gp_param_def_write (GIOChannel *channel,
return FALSE;
break;
case GP_PARAM_DEF_TYPE_COLOR:
if (! _gimp_wire_write_int32 (channel,
(guint32 *) &param_def->meta.m_color.has_alpha, 1,
user_data) ||
! _gimp_wire_write_color (channel,
&param_def->meta.m_color.default_val, 1,
user_data))
return FALSE;
break;
case GP_PARAM_DEF_TYPE_GEGL_COLOR:
{
GBytes *pixel_data = NULL;
@ -1824,13 +1803,6 @@ _gp_params_read (GIOChannel *channel,
goto cleanup;
break;
case GP_PARAM_TYPE_COLOR:
if (! _gimp_wire_read_color (channel,
&(*params)[i].data.d_color, 1,
user_data))
goto cleanup;
break;
case GP_PARAM_TYPE_GEGL_COLOR:
/* Read the color data. */
if (! _gimp_wire_read_int32 (channel,
@ -2151,13 +2123,6 @@ _gp_params_write (GIOChannel *channel,
return;
break;
case GP_PARAM_TYPE_COLOR:
if (! _gimp_wire_write_color (channel,
&params[i].data.d_color, 1,
user_data))
return;
break;
case GP_PARAM_TYPE_GEGL_COLOR:
if (! _gimp_wire_write_int32 (channel,
(const guint32 *) &params[i].data.d_gegl_color.size, 1,
@ -2327,9 +2292,6 @@ _gp_params_destroy (GPParam *params,
g_free (params[i].data.d_string);
break;
case GP_PARAM_TYPE_COLOR:
break;
case GP_PARAM_TYPE_GEGL_COLOR:
g_free (params[i].data.d_gegl_color.encoding);
g_free (params[i].data.d_gegl_color.profile_data);

View File

@ -26,7 +26,7 @@ G_BEGIN_DECLS
/* Increment every time the protocol changes
*/
#define GIMP_PROTOCOL_VERSION 0x0111
#define GIMP_PROTOCOL_VERSION 0x0112
enum
@ -56,7 +56,6 @@ typedef enum
GP_PARAM_DEF_TYPE_BOOLEAN,
GP_PARAM_DEF_TYPE_FLOAT,
GP_PARAM_DEF_TYPE_STRING,
GP_PARAM_DEF_TYPE_COLOR,
GP_PARAM_DEF_TYPE_GEGL_COLOR,
GP_PARAM_DEF_TYPE_ID,
GP_PARAM_DEF_TYPE_ID_ARRAY
@ -70,7 +69,6 @@ typedef enum
GP_PARAM_TYPE_STRV,
GP_PARAM_TYPE_BYTES,
GP_PARAM_TYPE_FILE,
GP_PARAM_TYPE_COLOR,
GP_PARAM_TYPE_GEGL_COLOR,
GP_PARAM_TYPE_COLOR_ARRAY,
GP_PARAM_TYPE_PARASITE,
@ -93,7 +91,6 @@ typedef struct _GPParamDefFloat GPParamDefFloat;
typedef struct _GPParamDefString GPParamDefString;
typedef struct _GPParamDefChoice GPParamDefChoice;
typedef struct _GPParamStrv GPParamStrv;
typedef struct _GPParamDefColor GPParamDefColor;
typedef struct _GPParamDefGeglColor GPParamDefGeglColor;
typedef struct _GPParamDefID GPParamDefID;
typedef struct _GPParamDefIDArray GPParamDefIDArray;
@ -204,12 +201,6 @@ struct _GPParamDefString
gchar *default_val;
};
struct _GPParamDefColor
{
gint32 has_alpha;
GimpRGB default_val;
};
struct _GPParamDefGeglColor
{
gint32 has_alpha;
@ -250,7 +241,6 @@ struct _GPParamDef
GPParamDefBoolean m_boolean;
GPParamDefFloat m_float;
GPParamDefString m_string;
GPParamDefColor m_color;
GPParamDefGeglColor m_gegl_color;
GPParamDefID m_id;
GPParamDefIDArray m_id_array;

View File

@ -479,18 +479,6 @@ _gimp_wire_read_string (GIOChannel *channel,
return TRUE;
}
gboolean
_gimp_wire_read_color (GIOChannel *channel,
GimpRGB *data,
gint count,
gpointer user_data)
{
g_return_val_if_fail (count >= 0, FALSE);
return _gimp_wire_read_double (channel,
(gdouble *) data, 4 * count, user_data);
}
gboolean
_gimp_wire_read_gegl_color (GIOChannel *channel,
GBytes **pixel_data,
@ -714,18 +702,6 @@ _gimp_wire_write_string (GIOChannel *channel,
return TRUE;
}
gboolean
_gimp_wire_write_color (GIOChannel *channel,
const GimpRGB *data,
gint count,
gpointer user_data)
{
g_return_val_if_fail (count >= 0, FALSE);
return _gimp_wire_write_double (channel,
(gdouble *) data, 4 * count, user_data);
}
gboolean
_gimp_wire_write_gegl_color (GIOChannel *channel,
GBytes **pixel_data,

View File

@ -107,10 +107,6 @@ G_GNUC_INTERNAL gboolean _gimp_wire_read_string (GIOChannel *channel,
gchar **data,
gint count,
gpointer user_data);
G_GNUC_INTERNAL gboolean _gimp_wire_read_color (GIOChannel *channel,
GimpRGB *data,
gint count,
gpointer user_data);
G_GNUC_INTERNAL gboolean
_gimp_wire_read_gegl_color (GIOChannel *channel,
GBytes **pixel_data,
@ -142,10 +138,6 @@ G_GNUC_INTERNAL gboolean _gimp_wire_write_string (GIOChannel *channel,
gchar **data,
gint count,
gpointer user_data);
G_GNUC_INTERNAL gboolean _gimp_wire_write_color (GIOChannel *channel,
const GimpRGB *data,
gint count,
gpointer user_data);
G_GNUC_INTERNAL gboolean
_gimp_wire_write_gegl_color (GIOChannel *channel,
GBytes **pixel_data,

View File

@ -80,10 +80,6 @@ EXPORTS
gimp_hsv_set
gimp_hsv_to_rgb
gimp_hsva_set
gimp_param_rgb_get_type
gimp_param_spec_rgb
gimp_param_spec_rgb_get_default
gimp_param_spec_rgb_has_alpha
gimp_pixbuf_create_buffer
gimp_pixbuf_get_format
gimp_pixbuf_get_icc_profile
@ -122,5 +118,3 @@ EXPORTS
gimp_rgba_set_pixel
gimp_rgba_set_uchar
gimp_rgba_subtract
gimp_value_get_rgb
gimp_value_set_rgb

View File

@ -45,29 +45,6 @@ static GimpRGB * gimp_rgb_copy (const GimpRGB *rgb);
G_DEFINE_BOXED_TYPE (GimpRGB, gimp_rgb, gimp_rgb_copy, g_free)
void
gimp_value_get_rgb (const GValue *value,
GimpRGB *rgb)
{
g_return_if_fail (GIMP_VALUE_HOLDS_RGB (value));
g_return_if_fail (rgb != NULL);
if (value->data[0].v_pointer)
*rgb = *((GimpRGB *) value->data[0].v_pointer);
else
gimp_rgba_set (rgb, 0.0, 0.0, 0.0, 1.0);
}
void
gimp_value_set_rgb (GValue *value,
const GimpRGB *rgb)
{
g_return_if_fail (GIMP_VALUE_HOLDS_RGB (value));
g_return_if_fail (rgb != NULL);
g_value_set_boxed (value, rgb);
}
static GimpRGB *
gimp_rgb_copy (const GimpRGB *rgb)
{
@ -577,238 +554,3 @@ gimp_rgba_distance (const GimpRGB *rgba1,
fabs (rgba1->b - rgba2->b) +
fabs (rgba1->a - rgba2->a));
}
/*
* GIMP_TYPE_PARAM_RGB
*/
#define GIMP_PARAM_SPEC_RGB(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_RGB, GimpParamSpecRGB))
struct _GimpParamSpecRGB
{
GParamSpecBoxed parent_instance;
gboolean has_alpha;
gboolean validate; /* change this to enable [0.0...1.0] */
GimpRGB default_value;
};
static void gimp_param_rgb_class_init (GParamSpecClass *class);
static void gimp_param_rgb_init (GParamSpec *pspec);
static void gimp_param_rgb_set_default (GParamSpec *pspec,
GValue *value);
static gboolean gimp_param_rgb_validate (GParamSpec *pspec,
GValue *value);
static gint gimp_param_rgb_values_cmp (GParamSpec *pspec,
const GValue *value1,
const GValue *value2);
/**
* gimp_param_rgb_get_type:
*
* Reveals the object type
*
* Returns: the #GType for a GimpParamRGB object
*
* Since: 2.4
**/
GType
gimp_param_rgb_get_type (void)
{
static GType spec_type = 0;
if (! spec_type)
{
const GTypeInfo type_info =
{
sizeof (GParamSpecClass),
NULL, NULL,
(GClassInitFunc) gimp_param_rgb_class_init,
NULL, NULL,
sizeof (GimpParamSpecRGB),
0,
(GInstanceInitFunc) gimp_param_rgb_init
};
spec_type = g_type_register_static (G_TYPE_PARAM_BOXED,
"GimpParamRGB",
&type_info, 0);
}
return spec_type;
}
static void
gimp_param_rgb_class_init (GParamSpecClass *class)
{
class->value_type = GIMP_TYPE_RGB;
class->value_set_default = gimp_param_rgb_set_default;
class->value_validate = gimp_param_rgb_validate;
class->values_cmp = gimp_param_rgb_values_cmp;
}
static void
gimp_param_rgb_init (GParamSpec *pspec)
{
GimpParamSpecRGB *cspec = GIMP_PARAM_SPEC_RGB (pspec);
gimp_rgba_set (&cspec->default_value, 0.0, 0.0, 0.0, 1.0);
}
static void
gimp_param_rgb_set_default (GParamSpec *pspec,
GValue *value)
{
GimpParamSpecRGB *cspec = GIMP_PARAM_SPEC_RGB (pspec);
g_value_set_static_boxed (value, &cspec->default_value);
}
static gboolean
gimp_param_rgb_validate (GParamSpec *pspec,
GValue *value)
{
GimpParamSpecRGB *rgb_spec = GIMP_PARAM_SPEC_RGB (pspec);
GimpRGB *rgb = value->data[0].v_pointer;
if (rgb_spec->validate && rgb)
{
GimpRGB oval = *rgb;
gimp_rgb_clamp (rgb);
return (oval.r != rgb->r ||
oval.g != rgb->g ||
oval.b != rgb->b ||
(rgb_spec->has_alpha && oval.a != rgb->a));
}
return FALSE;
}
static gint
gimp_param_rgb_values_cmp (GParamSpec *pspec,
const GValue *value1,
const GValue *value2)
{
GimpRGB *rgb1 = value1->data[0].v_pointer;
GimpRGB *rgb2 = value2->data[0].v_pointer;
/* try to return at least *something*, it's useless anyway... */
if (! rgb1)
{
return rgb2 != NULL ? -1 : 0;
}
else if (! rgb2)
{
return rgb1 != NULL;
}
else
{
guint32 int1 = 0;
guint32 int2 = 0;
if (GIMP_PARAM_SPEC_RGB (pspec)->has_alpha)
{
gimp_rgba_get_uchar (rgb1,
((guchar *) &int1) + 0,
((guchar *) &int1) + 1,
((guchar *) &int1) + 2,
((guchar *) &int1) + 3);
gimp_rgba_get_uchar (rgb2,
((guchar *) &int2) + 0,
((guchar *) &int2) + 1,
((guchar *) &int2) + 2,
((guchar *) &int2) + 3);
}
else
{
gimp_rgb_get_uchar (rgb1,
((guchar *) &int1) + 0,
((guchar *) &int1) + 1,
((guchar *) &int1) + 2);
gimp_rgb_get_uchar (rgb2,
((guchar *) &int2) + 0,
((guchar *) &int2) + 1,
((guchar *) &int2) + 2);
}
return int1 - int2;
}
}
/**
* gimp_param_spec_rgb:
* @name: Canonical name of the param
* @nick: Nickname of the param
* @blurb: Brief description of param.
* @has_alpha: %TRUE if the alpha channel has relevance.
* @default_value: Value to use if none is assigned.
* @flags: a combination of #GParamFlags
*
* Creates a param spec to hold an #GimpRGB value.
* See g_param_spec_internal() for more information.
*
* Returns: (transfer full): a newly allocated #GParamSpec instance
*
* Since: 2.4
**/
GParamSpec *
gimp_param_spec_rgb (const gchar *name,
const gchar *nick,
const gchar *blurb,
gboolean has_alpha,
const GimpRGB *default_value,
GParamFlags flags)
{
GimpParamSpecRGB *cspec;
cspec = g_param_spec_internal (GIMP_TYPE_PARAM_RGB,
name, nick, blurb, flags);
cspec->has_alpha = has_alpha;
if (default_value)
cspec->default_value = *default_value;
else
gimp_rgba_set (&cspec->default_value, 0.0, 0.0, 0.0, 1.0);
return G_PARAM_SPEC (cspec);
}
/**
* gimp_param_spec_rgb_get_default:
* @pspec: a #GimpParamSpecRGB.
* @default_value: return location for @pspec's default value
*
* Returns the @pspec's default color value.
*
* Since: 2.10.14
**/
void
gimp_param_spec_rgb_get_default (GParamSpec *pspec,
GimpRGB *default_value)
{
g_return_if_fail (GIMP_IS_PARAM_SPEC_RGB (pspec));
g_return_if_fail (default_value != NULL);
*default_value = GIMP_PARAM_SPEC_RGB (pspec)->default_value;
}
/**
* gimp_param_spec_rgb_has_alpha:
* @pspec: a #GParamSpec to hold an #GimpRGB value.
*
* Returns: %TRUE if the alpha channel is relevant.
*
* Since: 2.4
**/
gboolean
gimp_param_spec_rgb_has_alpha (GParamSpec *pspec)
{
g_return_val_if_fail (GIMP_IS_PARAM_SPEC_RGB (pspec), FALSE);
return GIMP_PARAM_SPEC_RGB (pspec)->has_alpha;
}

View File

@ -37,34 +37,6 @@ G_BEGIN_DECLS
GType gimp_rgb_get_type (void) G_GNUC_CONST;
void gimp_value_get_rgb (const GValue *value,
GimpRGB *rgb);
void gimp_value_set_rgb (GValue *value,
const GimpRGB *rgb);
/*
* GIMP_TYPE_PARAM_RGB
*/
#define GIMP_TYPE_PARAM_RGB (gimp_param_rgb_get_type ())
#define GIMP_IS_PARAM_SPEC_RGB(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_RGB))
typedef struct _GimpParamSpecRGB GimpParamSpecRGB;
GType gimp_param_rgb_get_type (void) G_GNUC_CONST;
GParamSpec * gimp_param_spec_rgb (const gchar *name,
const gchar *nick,
const gchar *blurb,
gboolean has_alpha,
const GimpRGB *default_value,
GParamFlags flags);
void gimp_param_spec_rgb_get_default (GParamSpec *pspec,
GimpRGB *default_value);
gboolean gimp_param_spec_rgb_has_alpha (GParamSpec *pspec);
/* RGB and RGBA color types and operations taken from LibGCK */

View File

@ -249,35 +249,6 @@ gimp_config_param_spec_duplicate (GParamSpec *pspec)
spec->default_value,
flags);
}
else if (GIMP_IS_PARAM_SPEC_RGB (pspec))
{
GimpRGB color;
gimp_param_spec_rgb_get_default (pspec, &color);
copy = gimp_param_spec_rgb (name, nick, blurb,
gimp_param_spec_rgb_has_alpha (pspec),
&color,
flags);
}
/* In some cases, such as some GIR bindings, creating a GimpRGB
* argument is impossible (or at least I have not found how, at least
* in the Python binding which is doing some weird shortcuts when
* handling GValue and param specs. So instead, the parameter appears
* as a Boxed param with a GimpRGB value type.
*/
else if (G_IS_PARAM_SPEC_BOXED (pspec) &&
G_PARAM_SPEC_VALUE_TYPE (pspec) == GIMP_TYPE_RGB)
{
GValue *value;
GimpRGB color;
value = (GValue *) g_param_spec_get_default_value (pspec);
gimp_value_get_rgb (value, &color);
copy = gimp_param_spec_rgb (name, nick, blurb,
TRUE, &color, flags);
}
else if (GEGL_IS_PARAM_SPEC_COLOR (pspec))
{
GeglColor *color;

View File

@ -170,12 +170,6 @@ G_BEGIN_DECLS
path_type, default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_PROP_RGB(class, id, name, nick, blurb, has_alpha, default, flags) \
g_object_class_install_property (class, id,\
gimp_param_spec_rgb (name, nick, blurb,\
has_alpha, default, \
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_PROP_MATRIX2(class, id, name, nick, blurb, default, flags) \
g_object_class_install_property (class, id,\
gimp_param_spec_matrix2 (name, nick, blurb,\

View File

@ -49,11 +49,6 @@
**/
static gboolean gimp_config_serialize_rgb (const GValue *value,
GString *str,
gboolean has_alpha);
/**
* gimp_config_serialize_properties:
* @config: a #GimpConfig.
@ -302,6 +297,8 @@ gimp_config_serialize_property (GimpConfig *config,
else if (GIMP_VALUE_HOLDS_COLOR (&value))
{
GeglColor *color = g_value_get_object (&value);
/* TODO: serialize has_alpha. */
/*gboolean has_alpha = gimp_param_spec_color_has_alpha (param_spec);*/
gboolean free_color = FALSE;
gimp_config_writer_open (writer, param_spec->name);
@ -415,13 +412,7 @@ gimp_config_serialize_property (GimpConfig *config,
{
GString *str = g_string_new (NULL);
if (GIMP_VALUE_HOLDS_RGB (&value))
{
gboolean has_alpha = gimp_param_spec_rgb_has_alpha (param_spec);
success = gimp_config_serialize_rgb (&value, str, has_alpha);
}
else if (G_VALUE_TYPE (&value) == G_TYPE_STRV)
if (G_VALUE_TYPE (&value) == G_TYPE_STRV)
{
success = gimp_config_serialize_strv (&value, str);
}
@ -565,11 +556,6 @@ gimp_config_serialize_value (const GValue *value,
return TRUE;
}
if (GIMP_VALUE_HOLDS_RGB (value))
{
return gimp_config_serialize_rgb (value, str, TRUE);
}
if (GIMP_VALUE_HOLDS_MATRIX2 (value))
{
GimpMatrix2 *trafo;
@ -680,39 +666,3 @@ gimp_config_serialize_value (const GValue *value,
return FALSE;
}
static gboolean
gimp_config_serialize_rgb (const GValue *value,
GString *str,
gboolean has_alpha)
{
GimpRGB *rgb;
rgb = g_value_get_boxed (value);
if (rgb)
{
gchar buf[4][G_ASCII_DTOSTR_BUF_SIZE];
g_ascii_dtostr (buf[0], G_ASCII_DTOSTR_BUF_SIZE, rgb->r);
g_ascii_dtostr (buf[1], G_ASCII_DTOSTR_BUF_SIZE, rgb->g);
g_ascii_dtostr (buf[2], G_ASCII_DTOSTR_BUF_SIZE, rgb->b);
if (has_alpha)
{
g_ascii_dtostr (buf[3], G_ASCII_DTOSTR_BUF_SIZE, rgb->a);
g_string_append_printf (str, "(color-rgba %s %s %s %s)",
buf[0], buf[1], buf[2], buf[3]);
}
else
{
g_string_append_printf (str, "(color-rgb %s %s %s)",
buf[0], buf[1], buf[2]);
}
return TRUE;
}
return FALSE;
}

View File

@ -262,18 +262,6 @@ package Gimp::CodeGen::pdb;
set_value_func => 'gimp_value_set_object_array ($value, GIMP_TYPE_PATTERN, (GObject **) $var, $var_len)',
take_value_func => 'gimp_value_take_object_array ($value, GIMP_TYPE_PATTERN, (GObject **) $var, $var_len)' },
color => { name => 'COLOR',
gtype => 'GIMP_TYPE_RGB',
type => 'GimpRGB ',
const_type => 'GimpRGB ',
struct => 1,
init_value => '{ 0.0, 0.0, 0.0, 1.0 }',
get_value_func => 'gimp_value_get_rgb ($value, &$var)',
dup_value_func => 'GIMP_VALUES_GET_RGB ($value, &$var)',
set_value_func => 'gimp_value_set_rgb ($value, $var)',
take_value_func => 'gimp_value_set_rgb ($value, &$var)',
headers => [ qw(<cairo.h> "libgimpcolor/gimpcolor.h") ] },
geglcolor => { name => 'GEGLCOLOR',
gtype => 'GEGL_TYPE_COLOR',
type => 'GeglColor *',

View File

@ -526,28 +526,6 @@ marshal_returned_PDB_value (scheme *sc,
result = list;
}
else if (GIMP_VALUE_HOLDS_RGB (value))
{
GimpRGB v;
guchar r, g, b;
gpointer temp_val;
gimp_value_get_rgb (value, &v);
gimp_rgb_get_uchar (&v, &r, &g, &b);
temp_val = sc->vptr->cons
(sc,
sc->vptr->mk_integer (sc, r),
sc->vptr->cons
(sc,
sc->vptr->mk_integer (sc, g),
sc->vptr->cons
(sc,
sc->vptr->mk_integer (sc, b),
sc->NIL)));
result = temp_val;
}
else if (GIMP_VALUE_HOLDS_COLOR_ARRAY (value))
{
/* unlike RBG_ARRAY, gimp_value_get_color_array (value) is not defined */

View File

@ -1186,56 +1186,6 @@ script_fu_marshal_procedure_call (scheme *sc,
debug_vector (sc, vector, "%f");
}
}
else if (GIMP_VALUE_HOLDS_RGB (&value))
{
GimpRGB color;
if (sc->vptr->is_string (sc->vptr->pair_car (a)))
{
gchar *color_string = sc->vptr->string_value (sc->vptr->pair_car (a));
if (! gimp_rgb_parse_css (&color, color_string, -1))
return script_type_error (sc, "color string", i, proc_name);
gimp_rgb_set_alpha (&color, 1.0);
gimp_value_set_rgb (&value, &color);
}
else if (sc->vptr->is_list (sc, sc->vptr->pair_car (a)) &&
sc->vptr->list_length (sc, sc->vptr->pair_car (a)) == 3)
{
pointer color_list;
guchar r = 0, g = 0, b = 0;
color_list = sc->vptr->pair_car (a);
if (sc->vptr->is_number (sc->vptr->pair_car (color_list)))
r = CLAMP (sc->vptr->ivalue (sc->vptr->pair_car (color_list)),
0, 255);
else
return script_type_error_in_container (
sc, "numeric", i, 0, proc_name, 0);
color_list = sc->vptr->pair_cdr (color_list);
if (sc->vptr->is_number (sc->vptr->pair_car (color_list)))
g = CLAMP (sc->vptr->ivalue (sc->vptr->pair_car (color_list)),
0, 255);
else
return script_type_error_in_container (
sc, "numeric", i, 1, proc_name, 0);
color_list = sc->vptr->pair_cdr (color_list);
if (sc->vptr->is_number (sc->vptr->pair_car (color_list)))
b = CLAMP (sc->vptr->ivalue (sc->vptr->pair_car (color_list)),
0, 255);
else
return script_type_error_in_container (sc, "numeric", i, 2, proc_name, 0);
gimp_rgba_set_uchar (&color, r, g, b, 255);
gimp_value_set_rgb (&value, &color);
g_debug ("(%d %d %d)", r, g, b);
}
else
return script_type_error (sc, "color string or list", i, proc_name);
}
else if (GIMP_VALUE_HOLDS_COLOR (&value))
{
GeglColor *color = NULL;