39
39
#include "gimpparasite.h"
47
gimp_parasite_get_type (void)
49
static GType type = 0;
52
type = g_boxed_type_register_static ("GimpParasite",
53
(GBoxedCopyFunc) gimp_parasite_copy,
54
(GBoxedFreeFunc) gimp_parasite_free);
61
* GIMP_TYPE_PARAM_PARASITE
64
#define GIMP_PARAM_SPEC_PARASITE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_PARASITE, GimpParamSpecParasite))
66
typedef struct _GimpParamSpecParasite GimpParamSpecParasite;
68
struct _GimpParamSpecParasite
70
GParamSpecBoxed parent_instance;
73
static void gimp_param_parasite_class_init (GParamSpecClass *class);
74
static void gimp_param_parasite_init (GParamSpec *pspec);
75
static gboolean gimp_param_parasite_validate (GParamSpec *pspec,
77
static gint gimp_param_parasite_values_cmp (GParamSpec *pspec,
79
const GValue *value2);
82
gimp_param_parasite_get_type (void)
84
static GType type = 0;
88
const GTypeInfo type_info =
90
sizeof (GParamSpecClass),
92
(GClassInitFunc) gimp_param_parasite_class_init,
94
sizeof (GimpParamSpecParasite),
96
(GInstanceInitFunc) gimp_param_parasite_init
99
type = g_type_register_static (G_TYPE_PARAM_BOXED,
108
gimp_param_parasite_class_init (GParamSpecClass *class)
110
class->value_type = GIMP_TYPE_PARASITE;
111
class->value_validate = gimp_param_parasite_validate;
112
class->values_cmp = gimp_param_parasite_values_cmp;
116
gimp_param_parasite_init (GParamSpec *pspec)
121
gimp_param_parasite_validate (GParamSpec *pspec,
124
GimpParasite *parasite = value->data[0].v_pointer;
130
else if (parasite->name == NULL ||
131
! g_utf8_validate (parasite->name, -1, NULL) ||
132
(parasite->size == 0 && parasite->data != NULL) ||
133
(parasite->size > 0 && parasite->data == NULL))
135
g_value_set_boxed (value, NULL);
143
gimp_param_parasite_values_cmp (GParamSpec *pspec,
144
const GValue *value1,
145
const GValue *value2)
147
GimpParasite *parasite1 = value1->data[0].v_pointer;
148
GimpParasite *parasite2 = value2->data[0].v_pointer;
150
/* try to return at least *something*, it's useless anyway... */
153
return parasite2 != NULL ? -1 : 0;
154
else if (! parasite2)
155
return parasite1 != NULL;
157
return gimp_parasite_compare (parasite1, parasite2);
161
gimp_param_spec_parasite (const gchar *name,
166
GimpParamSpecParasite *parasite_spec;
168
parasite_spec = g_param_spec_internal (GIMP_TYPE_PARAM_PARASITE,
169
name, nick, blurb, flags);
171
return G_PARAM_SPEC (parasite_spec);
44
177
gimp_parasite_print (GimpParasite *parasite)