Commit f764fd0f authored by Michael Natterer's avatar Michael Natterer 😴

pdb, libgimp: change all generated ID array return values to object arrays

and remove the manual libgimp wrappers which now have the same
signature as the generated functions.
parent ccd516c5
Pipeline #111866 passed with stages
in 13 minutes and 9 seconds
......@@ -195,7 +195,7 @@ file_load_layers_invoker (GimpProcedure *procedure,
GimpImage *image;
const gchar *filename;
gint num_layers = 0;
gint32 *layer_ids = NULL;
GimpLayer **layers = NULL;
run_mode = g_value_get_enum (gimp_value_array_index (args, 0));
image = g_value_get_object (gimp_value_array_index (args, 1));
......@@ -207,12 +207,12 @@ file_load_layers_invoker (GimpProcedure *procedure,
if (file)
{
GList *layers;
GList *layer_list;
GimpPDBStatusType status;
layers = file_open_layers (gimp, context, progress,
image, FALSE,
file, run_mode, NULL, &status, error);
layer_list = file_open_layers (gimp, context, progress,
image, FALSE,
file, run_mode, NULL, &status, error);
g_object_unref (file);
......@@ -221,16 +221,18 @@ file_load_layers_invoker (GimpProcedure *procedure,
GList *list;
gint i;
num_layers = g_list_length (layers);
num_layers = g_list_length (layer_list);
layer_ids = g_new (gint32, num_layers);
layers = g_new (GimpLayer *, num_layers);
for (i = 0, list = layers;
for (i = 0, list = layer_list;
i < num_layers;
i++, list = g_list_next (list))
layer_ids[i] = gimp_item_get_id (GIMP_ITEM (list->data));
{
layers[i] = g_object_ref (list->data);
}
g_list_free (layers);
g_list_free (layer_list);
}
else
success = FALSE;
......@@ -245,7 +247,7 @@ file_load_layers_invoker (GimpProcedure *procedure,
if (success)
{
g_value_set_int (gimp_value_array_index (return_vals, 1), num_layers);
gimp_value_take_int32_array (gimp_value_array_index (return_vals, 2), layer_ids, num_layers);
gimp_value_take_object_array (gimp_value_array_index (return_vals, 2), GIMP_TYPE_LAYER, (GObject **) layers, num_layers);
}
return return_vals;
......@@ -754,10 +756,11 @@ register_fileops_procs (GimpPDB *pdb)
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32_array ("layer-ids",
"layer ids",
"The list of loaded layers",
GIMP_PARAM_READWRITE));
gimp_param_spec_object_array ("layers",
"layers",
"The list of loaded layers",
GIMP_TYPE_LAYER,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
......
......@@ -108,7 +108,7 @@ image_id_is_valid_invoker (GimpProcedure *procedure,
}
static GimpValueArray *
image_list_invoker (GimpProcedure *procedure,
get_images_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
......@@ -117,7 +117,7 @@ image_list_invoker (GimpProcedure *procedure,
{
GimpValueArray *return_vals;
gint num_images = 0;
gint32 *image_ids = NULL;
GimpImage **images = NULL;
GList *list = gimp_get_image_iter (gimp);
......@@ -127,16 +127,16 @@ image_list_invoker (GimpProcedure *procedure,
{
gint i;
image_ids = g_new (gint32, num_images);
images = g_new (GimpImage *, num_images);
for (i = 0; i < num_images; i++, list = g_list_next (list))
image_ids[i] = gimp_image_get_id (GIMP_IMAGE (list->data));
images[i] = g_object_ref (list->data);
}
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_int (gimp_value_array_index (return_vals, 1), num_images);
gimp_value_take_int32_array (gimp_value_array_index (return_vals, 2), image_ids, num_images);
gimp_value_take_object_array (gimp_value_array_index (return_vals, 2), GIMP_TYPE_IMAGE, (GObject **) images, num_images);
return return_vals;
}
......@@ -435,7 +435,7 @@ image_get_layers_invoker (GimpProcedure *procedure,
GimpValueArray *return_vals;
GimpImage *image;
gint num_layers = 0;
gint32 *layer_ids = NULL;
GimpLayer **layers = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
......@@ -449,10 +449,10 @@ image_get_layers_invoker (GimpProcedure *procedure,
{
gint i;
layer_ids = g_new (gint32, num_layers);
layers = g_new (GimpLayer *, num_layers);
for (i = 0; i < num_layers; i++, list = g_list_next (list))
layer_ids[i] = gimp_item_get_id (GIMP_ITEM (list->data));
layers[i] = g_object_ref (list->data);
}
}
......@@ -462,7 +462,7 @@ image_get_layers_invoker (GimpProcedure *procedure,
if (success)
{
g_value_set_int (gimp_value_array_index (return_vals, 1), num_layers);
gimp_value_take_int32_array (gimp_value_array_index (return_vals, 2), layer_ids, num_layers);
gimp_value_take_object_array (gimp_value_array_index (return_vals, 2), GIMP_TYPE_LAYER, (GObject **) layers, num_layers);
}
return return_vals;
......@@ -480,7 +480,7 @@ image_get_channels_invoker (GimpProcedure *procedure,
GimpValueArray *return_vals;
GimpImage *image;
gint num_channels = 0;
gint32 *channel_ids = NULL;
GimpChannel **channels = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
......@@ -494,10 +494,10 @@ image_get_channels_invoker (GimpProcedure *procedure,
{
gint i;
channel_ids = g_new (gint32, num_channels);
channels = g_new (GimpChannel *, num_channels);
for (i = 0; i < num_channels; i++, list = g_list_next (list))
channel_ids[i] = gimp_item_get_id (GIMP_ITEM (list->data));
channels[i] = g_object_ref (list->data);
}
}
......@@ -507,7 +507,7 @@ image_get_channels_invoker (GimpProcedure *procedure,
if (success)
{
g_value_set_int (gimp_value_array_index (return_vals, 1), num_channels);
gimp_value_take_int32_array (gimp_value_array_index (return_vals, 2), channel_ids, num_channels);
gimp_value_take_object_array (gimp_value_array_index (return_vals, 2), GIMP_TYPE_CHANNEL, (GObject **) channels, num_channels);
}
return return_vals;
......@@ -525,7 +525,7 @@ image_get_vectors_invoker (GimpProcedure *procedure,
GimpValueArray *return_vals;
GimpImage *image;
gint num_vectors = 0;
gint32 *vector_ids = NULL;
GimpVectors **vectors = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
......@@ -539,10 +539,10 @@ image_get_vectors_invoker (GimpProcedure *procedure,
{
gint i;
vector_ids = g_new (gint32, num_vectors);
vectors = g_new (GimpVectors *, num_vectors);
for (i = 0; i < num_vectors; i++, list = g_list_next (list))
vector_ids[i] = gimp_item_get_id (GIMP_ITEM (list->data));
vectors[i] = g_object_ref (list->data);
}
}
......@@ -552,7 +552,7 @@ image_get_vectors_invoker (GimpProcedure *procedure,
if (success)
{
g_value_set_int (gimp_value_array_index (return_vals, 1), num_vectors);
gimp_value_take_int32_array (gimp_value_array_index (return_vals, 2), vector_ids, num_vectors);
gimp_value_take_object_array (gimp_value_array_index (return_vals, 2), GIMP_TYPE_VECTORS, (GObject **) vectors, num_vectors);
}
return return_vals;
......@@ -2800,11 +2800,11 @@ register_image_procs (GimpPDB *pdb)
g_object_unref (procedure);
/*
* gimp-image-list
* gimp-get-images
*/
procedure = gimp_procedure_new (image_list_invoker);
procedure = gimp_procedure_new (get_images_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-image-list");
"gimp-get-images");
gimp_procedure_set_static_strings (procedure,
"Returns the list of images currently open.",
"This procedure returns the list of images currently open in GIMP.",
......@@ -2819,10 +2819,11 @@ register_image_procs (GimpPDB *pdb)
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32_array ("image-ids",
"image ids",
"The list of images currently open.",
GIMP_PARAM_READWRITE));
gimp_param_spec_object_array ("images",
"images",
"The list of images currently open.",
GIMP_TYPE_IMAGE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
......@@ -3136,10 +3137,11 @@ register_image_procs (GimpPDB *pdb)
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32_array ("layer-ids",
"layer ids",
"The list of layers contained in the image.",
GIMP_PARAM_READWRITE));
gimp_param_spec_object_array ("layers",
"layers",
"The list of layers contained in the image.",
GIMP_TYPE_LAYER,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
......@@ -3169,10 +3171,11 @@ register_image_procs (GimpPDB *pdb)
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32_array ("channel-ids",
"channel ids",
"The list of channels contained in the image.",
GIMP_PARAM_READWRITE));
gimp_param_spec_object_array ("channels",
"channels",
"The list of channels contained in the image.",
GIMP_TYPE_CHANNEL,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
......@@ -3202,10 +3205,11 @@ register_image_procs (GimpPDB *pdb)
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32_array ("vector-ids",
"vector ids",
"The list of vectors contained in the image.",
GIMP_PARAM_READWRITE));
gimp_param_spec_object_array ("vectors",
"vectors",
"The list of vectors contained in the image.",
GIMP_TYPE_VECTORS,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
......
......@@ -431,30 +431,30 @@ item_get_children_invoker (GimpProcedure *procedure,
GimpValueArray *return_vals;
GimpItem *item;
gint num_children = 0;
gint32 *child_ids = NULL;
GimpItem **children = NULL;
item = g_value_get_object (gimp_value_array_index (args, 0));
if (success)
{
GimpContainer *children = gimp_viewable_get_children (GIMP_VIEWABLE (item));
GimpContainer *container = gimp_viewable_get_children (GIMP_VIEWABLE (item));
if (children)
if (container)
{
num_children = gimp_container_get_n_children (children);
num_children = gimp_container_get_n_children (container);
if (num_children)
{
GList *list;
gint i;
child_ids = g_new (gint32, num_children);
children = g_new (GimpItem *, num_children);
for (list = GIMP_LIST (children)->queue->head, i = 0;
for (list = GIMP_LIST (container)->queue->head, i = 0;
list;
list = g_list_next (list), i++)
{
child_ids[i] = gimp_item_get_id (GIMP_ITEM (list->data));
children[i] = g_object_ref (list->data);
}
}
}
......@@ -469,7 +469,7 @@ item_get_children_invoker (GimpProcedure *procedure,
if (success)
{
g_value_set_int (gimp_value_array_index (return_vals, 1), num_children);
gimp_value_take_int32_array (gimp_value_array_index (return_vals, 2), child_ids, num_children);
gimp_value_take_object_array (gimp_value_array_index (return_vals, 2), GIMP_TYPE_ITEM, (GObject **) children, num_children);
}
return return_vals;
......@@ -1384,10 +1384,11 @@ register_item_procs (GimpPDB *pdb)
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32_array ("child-ids",
"child ids",
"The item's list of children",
GIMP_PARAM_READWRITE));
gimp_param_spec_object_array ("children",
"children",
"The item's list of children",
GIMP_TYPE_ITEM,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
......
......@@ -1114,7 +1114,7 @@ vectors_import_from_file_invoker (GimpProcedure *procedure,
gboolean merge;
gboolean scale;
gint num_vectors = 0;
gint32 *vectors_ids = NULL;
GimpVectors **vectors = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
filename = g_value_get_string (gimp_value_array_index (args, 1));
......@@ -1142,11 +1142,14 @@ vectors_import_from_file_invoker (GimpProcedure *procedure,
GList *list;
gint i;
vectors_ids = g_new (gint32, num_vectors);
vectors = g_new (GimpVectors *, num_vectors);
list = vectors_list;
for (i = 0; i < num_vectors; i++, list = g_list_next (list))
vectors_ids[i] = gimp_item_get_id (GIMP_ITEM (list->data));
for (i = 0, list = vectors_list;
i < num_vectors;
i++, list = g_list_next (list))
{
vectors[i] = g_object_ref (list->data);
}
g_list_free (vectors_list);
}
......@@ -1159,7 +1162,7 @@ vectors_import_from_file_invoker (GimpProcedure *procedure,
if (success)
{
g_value_set_int (gimp_value_array_index (return_vals, 1), num_vectors);
gimp_value_take_int32_array (gimp_value_array_index (return_vals, 2), vectors_ids, num_vectors);
gimp_value_take_object_array (gimp_value_array_index (return_vals, 2), GIMP_TYPE_VECTORS, (GObject **) vectors, num_vectors);
}
return return_vals;
......@@ -1181,7 +1184,7 @@ vectors_import_from_string_invoker (GimpProcedure *procedure,
gboolean merge;
gboolean scale;
gint num_vectors = 0;
gint32 *vectors_ids = NULL;
GimpVectors **vectors = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
string = g_value_get_string (gimp_value_array_index (args, 1));
......@@ -1191,7 +1194,7 @@ vectors_import_from_string_invoker (GimpProcedure *procedure,
if (success)
{
GList *list, *vectors_list = NULL;
GList *vectors_list = NULL;
/* FIXME tree */
success = gimp_vectors_import_buffer (image, string, length,
......@@ -1204,13 +1207,17 @@ vectors_import_from_string_invoker (GimpProcedure *procedure,
if (num_vectors)
{
gint i;
GList *list;
gint i;
vectors_ids = g_new (gint32, num_vectors);
vectors = g_new (GimpVectors *, num_vectors);
list = vectors_list;
for (i = 0; i < num_vectors; i++, list = g_list_next (list))
vectors_ids[i] = gimp_item_get_id (GIMP_ITEM (list->data));
for (i = 0, list = vectors_list;
i < num_vectors;
i++, list = g_list_next (list))
{
vectors[i] = g_object_ref (list->data);
}
g_list_free (vectors_list);
}
......@@ -1223,7 +1230,7 @@ vectors_import_from_string_invoker (GimpProcedure *procedure,
if (success)
{
g_value_set_int (gimp_value_array_index (return_vals, 1), num_vectors);
gimp_value_take_int32_array (gimp_value_array_index (return_vals, 2), vectors_ids, num_vectors);
gimp_value_take_object_array (gimp_value_array_index (return_vals, 2), GIMP_TYPE_VECTORS, (GObject **) vectors, num_vectors);
}
return return_vals;
......@@ -2262,10 +2269,11 @@ register_vectors_procs (GimpPDB *pdb)
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32_array ("vectors-ids",
"vectors ids",
"The list of newly created vectors",
GIMP_PARAM_READWRITE));
gimp_param_spec_object_array ("vectors",
"vectors",
"The list of newly created vectors",
GIMP_TYPE_VECTORS,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
......@@ -2320,10 +2328,11 @@ register_vectors_procs (GimpPDB *pdb)
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32_array ("vectors-ids",
"vectors ids",
"The list of newly created vectors",
GIMP_PARAM_READWRITE));
gimp_param_spec_object_array ("vectors",
"vectors",
"The list of newly created vectors",
GIMP_TYPE_VECTORS,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
......
......@@ -139,13 +139,13 @@ gimp_file_load_layer (GimpRunMode run_mode,
* needs to be added to the existing image with
* gimp_image_insert_layer().
*
* Returns: (array length=num_layers) (element-type gint32) (transfer full):
* Returns: (array length=num_layers) (element-type GimpLayer) (transfer container):
* The list of loaded layers.
* The returned value must be freed with g_free().
*
* Since: 2.4
**/
gint *
GimpLayer **
gimp_file_load_layers (GimpRunMode run_mode,
GimpImage *image,
const gchar *filename,
......@@ -153,7 +153,7 @@ gimp_file_load_layers (GimpRunMode run_mode,
{
GimpValueArray *args;
GimpValueArray *return_vals;
gint *layer_ids = NULL;
GimpLayer **layers = NULL;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_RUN_MODE, run_mode,
......@@ -171,12 +171,12 @@ gimp_file_load_layers (GimpRunMode run_mode,
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
{
*num_layers = GIMP_VALUES_GET_INT (return_vals, 1);
layer_ids = GIMP_VALUES_DUP_INT32_ARRAY (return_vals, 2);
layers = GIMP_VALUES_DUP_OBJECT_ARRAY (return_vals, 2);
}
gimp_value_array_unref (return_vals);
return layer_ids;
return layers;
}
/**
......
......@@ -38,7 +38,7 @@ GimpImage* gimp_file_load (GimpRunMode run
GimpLayer* gimp_file_load_layer (GimpRunMode run_mode,
GimpImage *image,
const gchar *filename);
gint* gimp_file_load_layers (GimpRunMode run_mode,
GimpLayer** gimp_file_load_layers (GimpRunMode run_mode,
GimpImage *image,
const gchar *filename,
gint *num_layers);
......
......@@ -186,40 +186,6 @@ gimp_image_is_valid (GimpImage *image)
return gimp_image_id_is_valid (gimp_image_get_id (image));
}
/**
* gimp_get_images:
* @num_images: (out): The number of images in the returned array.
*
* Returns the list of images currently open.
*
* This procedure returns the list of images currently open in GIMP.
*
* Returns: (array length=num_images) (transfer container):
* The list of images currently open.
* The returned array must be freed with g_free(). Image
* elements belong to libgimp and must not be freed.
*
* Since: 3.0
**/
GimpImage **
gimp_get_images (gint *num_images)
{
GimpImage **images;
gint *ids;
gint i;
ids = _gimp_image_list (num_images);
images = g_new (GimpImage *, *num_images);
for (i = 0; i < *num_images; i++)
images[i] = gimp_image_get_by_id (ids[i]);
g_free (ids);
return images;
}
/**
* gimp_list_images:
*
......@@ -237,127 +203,19 @@ gimp_get_images (gint *num_images)
GList *
gimp_list_images (void)
{
GList *images = NULL;
gint *ids;
gint num_images;
gint i;
ids = _gimp_image_list (&num_images);
for (i = 0; i < num_images; i++)
images = g_list_prepend (images, gimp_image_get_by_id (ids[i]));
g_free (ids);
return g_list_reverse (images);
}
/**
* gimp_image_get_layers:
* @image: The image.
* @num_layers: (out): The number of layers in the returned array.
*
* Returns the list of layers contained in the specified image.
*
* This procedure returns the list of layers contained in the specified
* image. The order of layers is from topmost to bottommost.
*
* Returns: (array length=num_layers) (transfer container):
* The list of layers contained in the image.
* The returned array must be freed with g_free(). Layer
* elements belong to libgimp and must not be freed.
**/
GimpLayer **
gimp_image_get_layers (GimpImage *image,
gint *num_layers)
{
GimpLayer **layers;
gint *ids;
GimpImage **images;
gint num_images;
GList *list = NULL;
gint i;
ids = _gimp_image_get_layers (image, num_layers);
layers = g_new (GimpLayer *, *num_layers);
for (i = 0; i < *num_layers; i++)
layers[i] = gimp_layer_get_by_id (ids[i]);
images = gimp_get_images (&num_images);
g_free (ids);
return layers;
}
/**
* gimp_image_get_channels:
* @image: The image.
* @num_channels: (out): The number of channels in the returned array.
*
* Returns the list of channels contained in the specified image.
*
* This procedure returns the list of channels contained in the
* specified image. This does not include the selection mask, or layer
* masks. The order is from topmost to bottommost. Note that
* "channels" are custom channels and do not include the image's color
* components.
*
* Returns: (array length=num_channels) (transfer container):
* The list of channels contained in the image.
* The returned array must be freed with g_free(). Channel
* elements belong to libgimp and must not be freed.
**/
GimpChannel **
gimp_image_get_channels (GimpImage *image,
gint *num_channels)
{
GimpChannel **channels;
gint *ids;
gint i;
ids = _gimp_image_get_channels (image, num_channels);
channels = g_new (GimpChannel *, *num_channels);
for (i = 0; i < *num_channels; i++)
channels[i] = gimp_channel_get_by_id (ids[i]);
g_free (ids);
return channels;
}
/**
* gimp_image_get_vectors:
* @image: The image.
* @num_vectors: (out): The number of vectors in the returned array.
*
* Returns the list of vectors contained in the specified image.
*
* This procedure returns the list of vectors contained in the
* specified image.
*
* Returns: (array length=num_vectors) (transfer container):
* The list of vectors contained in the image.
* The returned array must be freed with g_free(). Vectors
* elements belong to libgimp and must not be freed.
**/
GimpVectors **
gimp_image_get_vectors (GimpImage *image,
gint *num_vectors)
{
GimpVectors **vectors;
gint *ids;
gint i;
ids = _gimp_image_get_vectors (image, num_vectors);
vectors = g_new (GimpVectors *, *num_vectors);
for (i = 0; i < *num_vectors; i++)
vectors[i] = gimp_vectors_get_by_id (ids[i]);
for (i = 0; i < num_images; i++)
list = g_list_prepend (list, images[i]);
g_free (ids);
g_free (images);
return vectors;
return g_list_reverse (list);
}
/**
......@@ -379,19 +237,19 @@ gimp_image_get_vectors (GimpImage *image,
GList *
gimp_image_list_layers (GimpImage *image)
{
GList *layers = NULL;
gint *ids;
gint num_layers;
gint i;
GimpLayer **layers;
gint num_layers;
GList *list = NULL;
gint i;
ids = _gimp_image_get_layers (image, &num_layers);
layers = gimp_image_get_layers (image, &num_layers);
for (i = 0; i < num_layers; i++)
layers = g_list_prepend (layers, gimp_layer_get_by_id (ids[i]));
list = g_list_prepend (list, layers[i]);
g_free (ids);
g_free (layers);
return g_list_reverse (layers);
return g_list_reverse (list);
}
/**
......@@ -416,19 +274,19 @@ gimp_image_list_layers (GimpImage *image)
GList *
gimp_image_list_channels (GimpImage *image)
{
GList *channels = NULL;
gint *ids;
gint num_channels;
gint i;
GimpChannel **channels;
gint num_channels;
GList *list = NULL;
gint i;
ids = _gimp_image_get_channels (image, &num_channels);
channels = gimp_image_get_channels (image, &num_channels);