mirror of https://github.com/GNOME/gimp.git
libgimp*: get rid of GimpObjectArray and GimpParamSpecObjectArray.
These have now been completely replace with the new GimpCoreObjectArray.
This commit is contained in:
parent
e97572af98
commit
4137dce97b
|
@ -432,7 +432,6 @@ gimp_main (GType plug_in_type,
|
|||
GIMP_TYPE_ARRAY, GIMP_TYPE_PARAM_ARRAY,
|
||||
GIMP_TYPE_INT32_ARRAY, GIMP_TYPE_PARAM_INT32_ARRAY,
|
||||
GIMP_TYPE_FLOAT_ARRAY, GIMP_TYPE_PARAM_FLOAT_ARRAY,
|
||||
GIMP_TYPE_OBJECT_ARRAY, GIMP_TYPE_PARAM_OBJECT_ARRAY,
|
||||
GIMP_TYPE_CORE_OBJECT_ARRAY, GIMP_TYPE_PARAM_CORE_OBJECT_ARRAY,
|
||||
|
||||
GIMP_TYPE_DISPLAY, GIMP_TYPE_PARAM_DISPLAY,
|
||||
|
|
|
@ -840,9 +840,6 @@ EXPORTS
|
|||
gimp_procedure_add_layer_mask_return_value
|
||||
gimp_procedure_add_layer_return_value
|
||||
gimp_procedure_add_menu_path
|
||||
gimp_procedure_add_object_array_argument
|
||||
gimp_procedure_add_object_array_aux_argument
|
||||
gimp_procedure_add_object_array_return_value
|
||||
gimp_procedure_add_palette_argument
|
||||
gimp_procedure_add_palette_aux_argument
|
||||
gimp_procedure_add_palette_return_value
|
||||
|
|
|
@ -281,8 +281,8 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
|
|||
break;
|
||||
|
||||
case GP_PARAM_DEF_TYPE_ID_ARRAY:
|
||||
if (! strcmp (param_def->type_name, "GimpParamObjectArray"))
|
||||
return gimp_param_spec_object_array (name, nick, blurb,
|
||||
if (! strcmp (param_def->type_name, "GimpParamCoreObjectArray"))
|
||||
return gimp_param_spec_core_object_array (name, nick, blurb,
|
||||
g_type_from_name (param_def->meta.m_id_array.type_name),
|
||||
flags);
|
||||
break;
|
||||
|
@ -520,13 +520,6 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
|
|||
param_def->meta.m_id_array.type_name =
|
||||
(gchar *) g_type_name (GIMP_PARAM_SPEC_CORE_OBJECT_ARRAY (pspec)->object_type);
|
||||
}
|
||||
else if (GIMP_IS_PARAM_SPEC_OBJECT_ARRAY (pspec))
|
||||
{
|
||||
param_def->param_def_type = GP_PARAM_DEF_TYPE_ID_ARRAY;
|
||||
|
||||
param_def->meta.m_id_array.type_name =
|
||||
(gchar *) g_type_name (GIMP_PARAM_SPEC_OBJECT_ARRAY (pspec)->object_type);
|
||||
}
|
||||
else if (pspec_type == GIMP_TYPE_PARAM_EXPORT_OPTIONS)
|
||||
{
|
||||
GimpParamSpecExportOptions *eospec = GIMP_PARAM_SPEC_EXPORT_OPTIONS (pspec);
|
||||
|
@ -963,70 +956,6 @@ gimp_gp_param_to_value (gpointer gimp,
|
|||
*/
|
||||
g_value_set_boxed (value, objects);
|
||||
}
|
||||
else if (GIMP_VALUE_HOLDS_OBJECT_ARRAY (value))
|
||||
{
|
||||
GType object_type = G_TYPE_INVALID;
|
||||
GObject **objects;
|
||||
gint i;
|
||||
|
||||
/* Get type of the array elements. */
|
||||
if (param->data.d_id_array.type_name != NULL)
|
||||
{
|
||||
/* An empty array from a NULL has an arbitrary type_name set earlier. */
|
||||
object_type = g_type_from_name (param->data.d_id_array.type_name);
|
||||
}
|
||||
else if (pspec != NULL)
|
||||
{
|
||||
object_type = GIMP_PARAM_SPEC_OBJECT_ARRAY (pspec)->object_type;
|
||||
}
|
||||
/* Else object-type is G_TYPE_INVALID*/
|
||||
|
||||
/* GimpObjectArray requires declared element type derived from GObject.
|
||||
* Even when empty.
|
||||
* When not, return without setting the gvalue.
|
||||
* Not necessarily an error, when the plugin does not use the gvalue.
|
||||
*/
|
||||
if (!g_type_is_a (object_type, G_TYPE_OBJECT))
|
||||
{
|
||||
g_warning ("%s returning NULL for GimpObjectArray", G_STRFUNC);
|
||||
return;
|
||||
}
|
||||
|
||||
/* size might be zero. */
|
||||
|
||||
objects = g_new (GObject *, param->data.d_id_array.size);
|
||||
|
||||
for (i = 0; i < param->data.d_id_array.size; i++)
|
||||
{
|
||||
gint id = param->data.d_id_array.data[i];
|
||||
|
||||
if (object_type == GIMP_TYPE_IMAGE)
|
||||
{
|
||||
objects[i] = (GObject *) get_image_by_id (gimp, id);
|
||||
}
|
||||
else if (g_type_is_a (object_type, GIMP_TYPE_ITEM))
|
||||
{
|
||||
objects[i] = (GObject *) get_item_by_id (gimp, id);
|
||||
}
|
||||
else if (g_type_is_a (object_type, GIMP_TYPE_DISPLAY))
|
||||
{
|
||||
objects[i] = (GObject *) get_display_by_id (gimp, id);
|
||||
}
|
||||
else if (g_type_is_a (object_type, GIMP_TYPE_RESOURCE))
|
||||
{
|
||||
objects[i] = (GObject *) get_resource_by_id (id);
|
||||
}
|
||||
|
||||
if (objects[i])
|
||||
g_object_ref (objects[i]);
|
||||
}
|
||||
|
||||
/* Even when size is zero, set gvalue to an empty GimpObjectArray object,
|
||||
* having a valid but possibly arbitrary type of its elements.
|
||||
*/
|
||||
gimp_value_take_object_array (value, object_type, objects,
|
||||
param->data.d_id_array.size);
|
||||
}
|
||||
else if (GIMP_VALUE_HOLDS_IMAGE (value))
|
||||
{
|
||||
g_value_set_object (value, get_image_by_id (gimp, param->data.d_int));
|
||||
|
@ -1528,71 +1457,6 @@ gimp_value_to_gp_param (const GValue *value,
|
|||
param->data.d_id_array.data = NULL;
|
||||
}
|
||||
}
|
||||
else if (GIMP_VALUE_HOLDS_OBJECT_ARRAY (value))
|
||||
{
|
||||
GimpObjectArray *array = g_value_get_boxed (value);
|
||||
|
||||
param->param_type = GP_PARAM_TYPE_ID_ARRAY;
|
||||
|
||||
if (array)
|
||||
{
|
||||
gint i;
|
||||
|
||||
if (full_copy)
|
||||
param->data.d_id_array.type_name =
|
||||
g_strdup (g_type_name (array->object_type));
|
||||
else
|
||||
param->data.d_id_array.type_name =
|
||||
(gchar *) g_type_name (array->object_type);
|
||||
|
||||
param->data.d_id_array.size = array->length;
|
||||
|
||||
/* must be free'd also for full_copy == FALSE */
|
||||
param->data.d_id_array.data = g_new (gint32, array->length);
|
||||
|
||||
for (i = 0; i < array->length; i++)
|
||||
{
|
||||
if (GIMP_IS_IMAGE (array->data[i]))
|
||||
{
|
||||
param->data.d_id_array.data[i] =
|
||||
gimp_image_get_id (GIMP_IMAGE (array->data[i]));
|
||||
}
|
||||
else if (GIMP_IS_ITEM (array->data[i]))
|
||||
{
|
||||
param->data.d_id_array.data[i] =
|
||||
gimp_item_get_id (GIMP_ITEM (array->data[i]));
|
||||
}
|
||||
else if (GIMP_IS_DISPLAY (array->data[i]))
|
||||
{
|
||||
param->data.d_id_array.data[i] =
|
||||
gimp_display_get_id (GIMP_DISPLAY (array->data[i]));
|
||||
}
|
||||
else if (GIMP_IS_RESOURCE (array->data[i]))
|
||||
{
|
||||
param->data.d_id_array.data[i] = get_resource_id (array->data[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
param->data.d_id_array.data[i] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* GValue intended to hold GimpObjectArray is NULL.
|
||||
* For convenience, we allow this, meaning empty.
|
||||
*/
|
||||
param->data.d_id_array.size = 0;
|
||||
param->data.d_id_array.data = NULL;
|
||||
/* Arbitrarily say elements are type Drawable.
|
||||
* We must have a type to create an empty GimpObjectArray.
|
||||
*/
|
||||
if (full_copy)
|
||||
param->data.d_id_array.type_name = g_strdup ("GimpDrawable");
|
||||
else
|
||||
param->data.d_id_array.type_name = "GimpDrawable";
|
||||
}
|
||||
}
|
||||
else if (GIMP_VALUE_HOLDS_IMAGE (value))
|
||||
{
|
||||
GimpImage *image = g_value_get_object (value);
|
||||
|
|
|
@ -1416,84 +1416,6 @@ gimp_procedure_add_core_object_array_return_value (GimpProcedure *procedure,
|
|||
object_type, flags));
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_procedure_add_object_array_argument:
|
||||
* @procedure: the #GimpProcedure.
|
||||
* @name: the name of the argument to be created.
|
||||
* @nick: the label used in #GimpProcedureDialog.
|
||||
* @blurb: a more detailed help description.
|
||||
* @object_type the type of object stored in the array
|
||||
* @flags: argument flags.
|
||||
*
|
||||
* Add a new object array argument to @procedure.
|
||||
*
|
||||
* Since: 3.0
|
||||
**/
|
||||
void
|
||||
gimp_procedure_add_object_array_argument (GimpProcedure *procedure,
|
||||
const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
GType object_type,
|
||||
GParamFlags flags)
|
||||
{
|
||||
_gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_object_array (name, nick, blurb,
|
||||
object_type, flags));
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_procedure_add_object_array_aux_argument:
|
||||
* @procedure: the #GimpProcedure.
|
||||
* @name: the name of the argument to be created.
|
||||
* @nick: the label used in #GimpProcedureDialog.
|
||||
* @blurb: a more detailed help description.
|
||||
* @object_type the type of object stored in the array
|
||||
* @flags: argument flags.
|
||||
*
|
||||
* Add a new object array auxiliary argument to @procedure.
|
||||
*
|
||||
* Since: 3.0
|
||||
**/
|
||||
void
|
||||
gimp_procedure_add_object_array_aux_argument (GimpProcedure *procedure,
|
||||
const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
GType object_type,
|
||||
GParamFlags flags)
|
||||
{
|
||||
_gimp_procedure_add_aux_argument (procedure,
|
||||
gimp_param_spec_object_array (name, nick, blurb,
|
||||
object_type, flags));
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_procedure_add_object_array_return_value:
|
||||
* @procedure: the #GimpProcedure.
|
||||
* @name: the name of the argument to be created.
|
||||
* @nick: the label used in #GimpProcedureDialog.
|
||||
* @blurb: a more detailed help description.
|
||||
* @object_type the type of object stored in the array
|
||||
* @flags: argument flags.
|
||||
*
|
||||
* Add a new object array return value to @procedure.
|
||||
*
|
||||
* Since: 3.0
|
||||
**/
|
||||
void
|
||||
gimp_procedure_add_object_array_return_value (GimpProcedure *procedure,
|
||||
const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
GType object_type,
|
||||
GParamFlags flags)
|
||||
{
|
||||
_gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_object_array (name, nick, blurb,
|
||||
object_type, flags));
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_procedure_add_display_argument:
|
||||
* @procedure: the #GimpProcedure.
|
||||
|
|
|
@ -241,21 +241,6 @@ G_BEGIN_DECLS
|
|||
g_value_take_boxed (gimp_value_array_index (args, n), (gconstpointer) value)
|
||||
|
||||
|
||||
#define GIMP_VALUES_GET_OBJECT_ARRAY(args, n) \
|
||||
(gpointer) gimp_value_get_object_array (gimp_value_array_index (args, n))
|
||||
|
||||
#define GIMP_VALUES_DUP_OBJECT_ARRAY(args, n) \
|
||||
(gpointer) gimp_value_dup_object_array (gimp_value_array_index (args, n))
|
||||
|
||||
#define GIMP_VALUES_SET_OBJECT_ARRAY(args, n, object_type, value, length) \
|
||||
gimp_value_set_object_array (gimp_value_array_index (args, n),\
|
||||
object_type, (gpointer) value, length)
|
||||
|
||||
#define GIMP_VALUES_TAKE_OBJECT_ARRAY(args, n, object_type, value, length) \
|
||||
gimp_value_take_object_array (gimp_value_array_index (args, n),\
|
||||
object_type, (gpointer) value, length)
|
||||
|
||||
|
||||
/* display */
|
||||
|
||||
#define GIMP_VALUES_GET_DISPLAY(args, n) \
|
||||
|
@ -788,25 +773,6 @@ void gimp_procedure_add_core_object_array_return_value (GimpProcedure *procedure
|
|||
GType object_type,
|
||||
GParamFlags flags);
|
||||
|
||||
void gimp_procedure_add_object_array_argument (GimpProcedure *procedure,
|
||||
const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
GType object_type,
|
||||
GParamFlags flags);
|
||||
void gimp_procedure_add_object_array_aux_argument (GimpProcedure *procedure,
|
||||
const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
GType object_type,
|
||||
GParamFlags flags);
|
||||
void gimp_procedure_add_object_array_return_value (GimpProcedure *procedure,
|
||||
const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
GType object_type,
|
||||
GParamFlags flags);
|
||||
|
||||
void gimp_procedure_add_display_argument (GimpProcedure *procedure,
|
||||
const gchar *name,
|
||||
const gchar *nick,
|
||||
|
|
|
@ -118,10 +118,6 @@ EXPORTS
|
|||
gimp_metadata_set_resolution
|
||||
gimp_micro_version
|
||||
gimp_minor_version
|
||||
gimp_object_array_copy
|
||||
gimp_object_array_free
|
||||
gimp_object_array_get_type
|
||||
gimp_object_array_new
|
||||
gimp_offset_type_get_type
|
||||
gimp_orientation_type_get_type
|
||||
gimp_paint_application_mode_get_type
|
||||
|
@ -132,7 +128,6 @@ EXPORTS
|
|||
gimp_param_float_array_get_type
|
||||
gimp_param_int32_array_get_type
|
||||
gimp_param_memsize_get_type
|
||||
gimp_param_object_array_get_type
|
||||
gimp_param_object_get_type
|
||||
gimp_param_parasite_get_type
|
||||
gimp_param_spec_array
|
||||
|
@ -142,7 +137,6 @@ EXPORTS
|
|||
gimp_param_spec_float_array
|
||||
gimp_param_spec_int32_array
|
||||
gimp_param_spec_memsize
|
||||
gimp_param_spec_object_array
|
||||
gimp_param_spec_object_duplicate
|
||||
gimp_param_spec_object_get_default
|
||||
gimp_param_spec_object_has_default
|
||||
|
@ -251,19 +245,14 @@ EXPORTS
|
|||
gimp_value_array_unref
|
||||
gimp_value_dup_float_array
|
||||
gimp_value_dup_int32_array
|
||||
gimp_value_dup_object_array
|
||||
gimp_value_get_float_array
|
||||
gimp_value_get_int32_array
|
||||
gimp_value_get_object_array
|
||||
gimp_value_set_float_array
|
||||
gimp_value_set_int32_array
|
||||
gimp_value_set_object_array
|
||||
gimp_value_set_static_float_array
|
||||
gimp_value_set_static_int32_array
|
||||
gimp_value_set_static_object_array
|
||||
gimp_value_take_float_array
|
||||
gimp_value_take_int32_array
|
||||
gimp_value_take_object_array
|
||||
gimp_wire_clear_error
|
||||
gimp_wire_destroy
|
||||
gimp_wire_error
|
||||
|
|
|
@ -1079,378 +1079,3 @@ gimp_param_spec_core_object_array (const gchar *name,
|
|||
|
||||
return G_PARAM_SPEC (array_spec);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_OBJECT_ARRAY
|
||||
*/
|
||||
|
||||
/**
|
||||
* gimp_object_array_new:
|
||||
* @data: (array length=length) (transfer none): an array of objects.
|
||||
* @object_type: the array will hold objects of this type
|
||||
* @length: the length of @data.
|
||||
* @static_data: whether the objects in @data are static objects and don't
|
||||
* need to be copied.
|
||||
*
|
||||
* Creates a new #GimpObjectArray containing object pointers, of size @length.
|
||||
*
|
||||
* If @static_data is %TRUE, @data is used as-is.
|
||||
*
|
||||
* If @static_data is %FALSE, the object and array will be re-allocated,
|
||||
* hence you are expected to free your input data after.
|
||||
*
|
||||
* Returns: (transfer full): a new #GimpObjectArray.
|
||||
*/
|
||||
GimpObjectArray *
|
||||
gimp_object_array_new (GType object_type,
|
||||
GObject **data,
|
||||
gsize length,
|
||||
gboolean static_data)
|
||||
{
|
||||
GimpObjectArray *array;
|
||||
|
||||
g_return_val_if_fail (g_type_is_a (object_type, G_TYPE_OBJECT), NULL);
|
||||
g_return_val_if_fail ((data == NULL && length == 0) ||
|
||||
(data != NULL && length > 0), NULL);
|
||||
|
||||
array = g_slice_new0 (GimpObjectArray);
|
||||
|
||||
array->object_type = object_type;
|
||||
|
||||
if (! static_data && data)
|
||||
{
|
||||
GObject **tmp = g_new0 (GObject *, length);
|
||||
gsize i;
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
tmp[i] = g_object_ref (data[i]);
|
||||
|
||||
array->data = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
array->data = data;
|
||||
}
|
||||
|
||||
array->length = length;
|
||||
array->static_data = static_data;
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_object_array_copy:
|
||||
* @array: an original #GimpObjectArray of objects.
|
||||
*
|
||||
* Creates a new #GimpObjectArray containing a deep copy of @array.
|
||||
*
|
||||
* Returns: (transfer full): a new #GimpObjectArray.
|
||||
**/
|
||||
GimpObjectArray *
|
||||
gimp_object_array_copy (const GimpObjectArray *array)
|
||||
{
|
||||
if (array)
|
||||
return gimp_object_array_new (array->object_type,
|
||||
array->data,
|
||||
array->length, FALSE);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_object_array_free (GimpObjectArray *array)
|
||||
{
|
||||
if (array)
|
||||
{
|
||||
if (! array->static_data)
|
||||
{
|
||||
GObject **tmp = array->data;
|
||||
gsize i;
|
||||
|
||||
for (i = 0; i < array->length; i++)
|
||||
g_object_unref (tmp[i]);
|
||||
|
||||
g_free (array->data);
|
||||
}
|
||||
|
||||
g_slice_free (GimpObjectArray, array);
|
||||
}
|
||||
}
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GimpObjectArray, gimp_object_array, gimp_object_array_copy, gimp_object_array_free)
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_PARAM_OBJECT_ARRAY
|
||||
*/
|
||||
|
||||
static void gimp_param_object_array_class_init (GParamSpecClass *klass);
|
||||
static void gimp_param_object_array_init (GParamSpec *pspec);
|
||||
static gboolean gimp_param_object_array_validate (GParamSpec *pspec,
|
||||
GValue *value);
|
||||
static gint gimp_param_object_array_values_cmp (GParamSpec *pspec,
|
||||
const GValue *value1,
|
||||
const GValue *value2);
|
||||
|
||||
GType
|
||||
gimp_param_object_array_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (! type)
|
||||
{
|
||||
const GTypeInfo info =
|
||||
{
|
||||
sizeof (GParamSpecClass),
|
||||
NULL, NULL,
|
||||
(GClassInitFunc) gimp_param_object_array_class_init,
|
||||
NULL, NULL,
|
||||
sizeof (GimpParamSpecObjectArray),
|
||||
0,
|
||||
(GInstanceInitFunc) gimp_param_object_array_init
|
||||
};
|
||||
|
||||
type = g_type_register_static (G_TYPE_PARAM_BOXED,
|
||||
"GimpParamObjectArray", &info, 0);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_param_object_array_class_init (GParamSpecClass *klass)
|
||||
{
|
||||
klass->value_type = GIMP_TYPE_OBJECT_ARRAY;
|
||||
klass->value_validate = gimp_param_object_array_validate;
|
||||
klass->values_cmp = gimp_param_object_array_values_cmp;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_param_object_array_init (GParamSpec *pspec)
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_param_object_array_validate (GParamSpec *pspec,
|
||||
GValue *value)
|
||||
{
|
||||
GimpParamSpecObjectArray *array_spec = GIMP_PARAM_SPEC_OBJECT_ARRAY (pspec);
|
||||
GimpObjectArray *array = value->data[0].v_pointer;
|
||||
|
||||
if (array)
|
||||
{
|
||||
gsize i;
|
||||
|
||||
if ((array->data == NULL && array->length != 0) ||
|
||||
(array->data != NULL && array->length == 0))
|
||||
{
|
||||
g_value_set_boxed (value, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (! g_type_is_a (array->object_type, array_spec->object_type))
|
||||
{
|
||||
g_value_set_boxed (value, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for (i = 0; i < array->length; i++)
|
||||
{
|
||||
if (array->data[i] && ! g_type_is_a (G_OBJECT_TYPE (array->data[i]),
|
||||
array_spec->object_type))
|
||||
{
|
||||
g_value_set_boxed (value, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gimp_param_object_array_values_cmp (GParamSpec *pspec,
|
||||
const GValue *value1,
|
||||
const GValue *value2)
|
||||
{
|
||||
GimpObjectArray *array1 = value1->data[0].v_pointer;
|
||||
GimpObjectArray *array2 = value2->data[0].v_pointer;
|
||||
|
||||
/* try to return at least *something*, it's useless anyway... */
|
||||
|
||||
if (! array1)
|
||||
return array2 != NULL ? -1 : 0;
|
||||
else if (! array2)
|
||||
return array1 != NULL ? 1 : 0;
|
||||
else if (array1->length < array2->length)
|
||||
return -1;
|
||||
else if (array1->length > array2->length)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_param_spec_object_array:
|
||||
* @name: Canonical name of the property specified.
|
||||
* @nick: Nick name of the property specified.
|
||||
* @blurb: Description of the property specified.
|
||||
* @object_type: GType of the array's elements.
|
||||
* @flags: Flags for the property specified.
|
||||
*
|
||||
* Creates a new #GimpParamSpecObjectArray specifying a
|
||||
* [type@ObjectArray] property.
|
||||
*
|
||||
* See g_param_spec_internal() for details on property names.
|
||||
*
|
||||
* Returns: (transfer floating): The newly created #GimpParamSpecObjectArray.
|
||||
*
|
||||
* Since: 3.0
|
||||
**/
|
||||
GParamSpec *
|
||||
gimp_param_spec_object_array (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
GType object_type,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GimpParamSpecObjectArray *array_spec;
|
||||
|
||||
g_return_val_if_fail (g_type_is_a (object_type, G_TYPE_OBJECT), NULL);
|
||||
|
||||
array_spec = g_param_spec_internal (GIMP_TYPE_PARAM_OBJECT_ARRAY,
|
||||
name, nick, blurb, flags);
|
||||
|
||||
g_return_val_if_fail (array_spec, NULL);
|
||||
|
||||
array_spec->object_type = object_type;
|
||||
|
||||
return G_PARAM_SPEC (array_spec);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_value_get_object_array:
|
||||
* @value: a #GValue holding a object #GimpObjectArray.
|
||||
*
|
||||
* Returns: (transfer none): the internal array of objects.
|
||||
*/
|
||||
GObject **
|
||||
gimp_value_get_object_array (const GValue *value)
|
||||
{
|
||||
GimpObjectArray *array;
|
||||
|
||||
g_return_val_if_fail (GIMP_VALUE_HOLDS_OBJECT_ARRAY (value), NULL);
|
||||
|
||||
array = value->data[0].v_pointer;
|
||||
|
||||
if (array)
|
||||
return array->data;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_value_dup_object_array:
|
||||
* @value: a #GValue holding a object #GimpObjectArray.
|
||||
*
|
||||
* Returns: (transfer full): a deep copy of the array of objects.
|
||||
*/
|
||||
GObject **
|
||||
gimp_value_dup_object_array (const GValue *value)
|
||||
{
|
||||
GimpObjectArray *array;
|
||||
|
||||
g_return_val_if_fail (GIMP_VALUE_HOLDS_OBJECT_ARRAY (value), NULL);
|
||||
|
||||
array = value->data[0].v_pointer;
|
||||
|
||||
if (array)
|
||||
{
|
||||
GObject **ret = g_memdup2 (array->data, (array->length) * sizeof (GObject *));
|
||||
gsize i;
|
||||
|
||||
for (i = 0; i < array->length; i++)
|
||||
g_object_ref (ret[i]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_value_set_object_array:
|
||||
* @value: A valid value of type %GIMP_TYPE_OBJECT_ARRAY
|
||||
* @object_type: The #GType of the object elements
|
||||
* @data: (array length=length): A #GObject array
|
||||
* @length: The number of elements in @data
|
||||
*
|
||||
* Sets the contents of @value to @data.
|
||||
*/
|
||||
void
|
||||
gimp_value_set_object_array (GValue *value,
|
||||
GType object_type,
|
||||
GObject **data,
|
||||
gsize length)
|
||||
{
|
||||
GimpObjectArray *array;
|
||||
|
||||
g_return_if_fail (GIMP_VALUE_HOLDS_OBJECT_ARRAY (value));
|
||||
g_return_if_fail (g_type_is_a (object_type, G_TYPE_OBJECT));
|
||||
|
||||
array = gimp_object_array_new (object_type, data, length, FALSE);
|
||||
|
||||
g_value_take_boxed (value, array);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_value_set_static_object_array:
|
||||
* @value: A valid value of type %GIMP_TYPE_OBJECT_ARRAY
|
||||
* @object_type: The #GType of the object elements
|
||||
* @data: (array length=length): A #GObject array
|
||||
* @length: The number of elements in @data
|
||||
*
|
||||
* Sets the contents of @value to @data, without copying the data.
|
||||
*/
|
||||
void
|
||||
gimp_value_set_static_object_array (GValue *value,
|
||||
GType object_type,
|
||||
GObject **data,
|
||||
gsize length)
|
||||
{
|
||||
GimpObjectArray *array;
|
||||
|
||||
g_return_if_fail (GIMP_VALUE_HOLDS_OBJECT_ARRAY (value));
|
||||
g_return_if_fail (g_type_is_a (object_type, G_TYPE_OBJECT));
|
||||
|
||||
array = gimp_object_array_new (object_type, data, length, TRUE);
|
||||
|
||||
g_value_take_boxed (value, array);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_value_take_object_array:
|
||||
* @value: A valid value of type %GIMP_TYPE_OBJECT_ARRAY
|
||||
* @object_type: The #GType of the object elements
|
||||
* @data: (transfer full) (array length=length): A #GObject array
|
||||
* @length: The number of elements in @data
|
||||
*
|
||||
* Sets the contents of @value to @data, and takes ownership of @data.
|
||||
*/
|
||||
void
|
||||
gimp_value_take_object_array (GValue *value,
|
||||
GType object_type,
|
||||
GObject **data,
|
||||
gsize length)
|
||||
{
|
||||
GimpObjectArray *array;
|
||||
|
||||
g_return_if_fail (GIMP_VALUE_HOLDS_OBJECT_ARRAY (value));
|
||||
g_return_if_fail (g_type_is_a (object_type, G_TYPE_OBJECT));
|
||||
|
||||
array = gimp_object_array_new (object_type, data, length, TRUE);
|
||||
array->static_data = FALSE;
|
||||
|
||||
g_value_take_boxed (value, array);
|
||||
}
|
||||
|
|
|
@ -399,81 +399,6 @@ GParamSpec * gimp_param_spec_core_object_array (const gchar *name,
|
|||
GParamFlags flags);
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_OBJECT_ARRAY
|
||||
*/
|
||||
|
||||
/**
|
||||
* GimpObjectArray:
|
||||
* @object_type: #GType of the contained objects.
|
||||
* @data: (array length=length): pointer to the array's data.
|
||||
* @length: length of @data, in number of objects.
|
||||
* @static_data: whether @data points to statically allocated memory.
|
||||
**/
|
||||
typedef struct _GimpObjectArray GimpObjectArray;
|
||||
|
||||
struct _GimpObjectArray
|
||||
{
|
||||
GType object_type;
|
||||
GObject **data;
|
||||
gsize length;
|
||||
gboolean static_data;
|
||||
};
|
||||
|
||||
GimpObjectArray * gimp_object_array_new (GType object_type,
|
||||
GObject **data,
|
||||
gsize length,
|
||||
gboolean static_data);
|
||||
GimpObjectArray * gimp_object_array_copy (const GimpObjectArray *array);
|
||||
void gimp_object_array_free (GimpObjectArray *array);
|
||||
|
||||
#define GIMP_TYPE_OBJECT_ARRAY (gimp_object_array_get_type ())
|
||||
#define GIMP_VALUE_HOLDS_OBJECT_ARRAY(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GIMP_TYPE_OBJECT_ARRAY))
|
||||
|
||||
GType gimp_object_array_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_PARAM_OBJECT_ARRAY
|
||||
*/
|
||||
|
||||
#define GIMP_TYPE_PARAM_OBJECT_ARRAY (gimp_param_object_array_get_type ())
|
||||
#define GIMP_PARAM_SPEC_OBJECT_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_OBJECT_ARRAY, GimpParamSpecObjectArray))
|
||||
#define GIMP_IS_PARAM_SPEC_OBJECT_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_OBJECT_ARRAY))
|
||||
|
||||
typedef struct _GimpParamSpecObjectArray GimpParamSpecObjectArray;
|
||||
|
||||
struct _GimpParamSpecObjectArray
|
||||
{
|
||||
GParamSpecBoxed parent_instance;
|
||||
|
||||
GType object_type;
|
||||
};
|
||||
|
||||
GType gimp_param_object_array_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GParamSpec * gimp_param_spec_object_array (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
GType object_type,
|
||||
GParamFlags flags);
|
||||
|
||||
GObject ** gimp_value_get_object_array (const GValue *value);
|
||||
GObject ** gimp_value_dup_object_array (const GValue *value);
|
||||
void gimp_value_set_object_array (GValue *value,
|
||||
GType object_type,
|
||||
GObject **data,
|
||||
gsize length);
|
||||
void gimp_value_set_static_object_array (GValue *value,
|
||||
GType object_type,
|
||||
GObject **data,
|
||||
gsize length);
|
||||
void gimp_value_take_object_array (GValue *value,
|
||||
GType object_type,
|
||||
GObject **data,
|
||||
gsize length);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_PARAM_SPECS_H__ */
|
||||
|
|
|
@ -302,14 +302,6 @@ gimp_config_param_spec_duplicate (GParamSpec *pspec)
|
|||
spec->object_type,
|
||||
flags);
|
||||
}
|
||||
else if (GIMP_IS_PARAM_SPEC_OBJECT_ARRAY (pspec))
|
||||
{
|
||||
GimpParamSpecObjectArray *spec = GIMP_PARAM_SPEC_OBJECT_ARRAY (pspec);
|
||||
|
||||
copy = gimp_param_spec_object_array (name, nick, blurb,
|
||||
spec->object_type,
|
||||
flags);
|
||||
}
|
||||
else if (GIMP_IS_PARAM_SPEC_EXPORT_OPTIONS (pspec))
|
||||
{
|
||||
GimpParamSpecExportOptions *spec = GIMP_PARAM_SPEC_EXPORT_OPTIONS (pspec);
|
||||
|
|
Loading…
Reference in New Issue