mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 01:13:24 +00:00
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:
parent
70b8e49e01
commit
a50759cda8
19 changed files with 23 additions and 666 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue