app, libgimp, pdb: imagearray PDB type as GimpCoreObjectArray.
This commit is contained in:
parent
64f9c71ad5
commit
08fd3a3f0d
9 changed files with 41 additions and 71 deletions
|
|
@ -113,27 +113,20 @@ get_images_invoker (GimpProcedure *procedure,
|
|||
GError **error)
|
||||
{
|
||||
GimpValueArray *return_vals;
|
||||
gint num_images = 0;
|
||||
GimpImage **images = NULL;
|
||||
|
||||
GList *list = gimp_get_image_iter (gimp);
|
||||
gsize num_images;
|
||||
gint i;
|
||||
|
||||
num_images = g_list_length (list);
|
||||
images = g_new0 (GimpImage *, num_images + 1);
|
||||
|
||||
if (num_images)
|
||||
{
|
||||
gint i;
|
||||
|
||||
images = g_new (GimpImage *, num_images);
|
||||
|
||||
for (i = 0; i < num_images; i++, list = g_list_next (list))
|
||||
images[i] = g_object_ref (list->data);
|
||||
}
|
||||
for (i = 0; i < num_images; i++, list = g_list_next (list))
|
||||
images[i] = 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_object_array (gimp_value_array_index (return_vals, 2), GIMP_TYPE_IMAGE, (GObject **) images, num_images);
|
||||
g_value_take_boxed (gimp_value_array_index (return_vals, 1), images);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
|
@ -3077,17 +3070,11 @@ register_image_procs (GimpPDB *pdb)
|
|||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996");
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("num-images",
|
||||
"num images",
|
||||
"The number of images currently open",
|
||||
0, G_MAXINT32, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_object_array ("images",
|
||||
"images",
|
||||
"The list of images currently open.",
|
||||
GIMP_TYPE_IMAGE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_param_spec_core_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);
|
||||
|
||||
|
|
|
|||
|
|
@ -201,13 +201,12 @@ GList *
|
|||
gimp_list_images (void)
|
||||
{
|
||||
GimpImage **images;
|
||||
gint num_images;
|
||||
GList *list = NULL;
|
||||
gint i;
|
||||
|
||||
images = gimp_get_images (&num_images);
|
||||
images = gimp_get_images ();
|
||||
|
||||
for (i = 0; i < num_images; i++)
|
||||
for (i = 0; images[i] != NULL; i++)
|
||||
list = g_list_prepend (list, images[i]);
|
||||
|
||||
g_free (images);
|
||||
|
|
|
|||
|
|
@ -76,18 +76,16 @@ gimp_image_id_is_valid (gint image_id)
|
|||
|
||||
/**
|
||||
* gimp_get_images:
|
||||
* @num_images: (out): The number of images currently open.
|
||||
*
|
||||
* Returns the list of images currently open.
|
||||
*
|
||||
* This procedure returns the list of images currently open in GIMP.
|
||||
*
|
||||
* Returns: (array length=num_images) (element-type GimpImage) (transfer container):
|
||||
* Returns: (element-type GimpImage) (array zero-terminated=1) (transfer container):
|
||||
* The list of images currently open.
|
||||
* The returned value must be freed with g_free().
|
||||
**/
|
||||
GimpImage **
|
||||
gimp_get_images (gint *num_images)
|
||||
gimp_get_images (void)
|
||||
{
|
||||
GimpValueArray *args;
|
||||
GimpValueArray *return_vals;
|
||||
|
|
@ -101,13 +99,8 @@ gimp_get_images (gint *num_images)
|
|||
args);
|
||||
gimp_value_array_unref (args);
|
||||
|
||||
*num_images = 0;
|
||||
|
||||
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
*num_images = GIMP_VALUES_GET_INT (return_vals, 1);
|
||||
{ GimpObjectArray *a = g_value_get_boxed (gimp_value_array_index (return_vals, 2)); if (a) images = g_memdup2 (a->data, a->length * sizeof (gpointer)); };
|
||||
}
|
||||
images = g_value_dup_boxed (gimp_value_array_index (return_vals, 1));
|
||||
|
||||
gimp_value_array_unref (return_vals);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ G_BEGIN_DECLS
|
|||
|
||||
|
||||
gboolean gimp_image_id_is_valid (gint image_id);
|
||||
GimpImage** gimp_get_images (gint *num_images);
|
||||
GimpImage** gimp_get_images (void);
|
||||
GimpImage* gimp_image_new (gint width,
|
||||
gint height,
|
||||
GimpImageBaseType type);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ gimp_c_test_run (GimpProcedure *procedure,
|
|||
GimpLayer *export_layer;
|
||||
GimpExportOptions *options;
|
||||
GimpExportReturn delete;
|
||||
gint n_images;
|
||||
gboolean identical_buffers;
|
||||
|
||||
new_image = gimp_image_new (NEW_IMAGE_WIDTH, NEW_IMAGE_HEIGHT, GIMP_RGB);
|
||||
|
|
@ -42,8 +41,8 @@ gimp_c_test_run (GimpProcedure *procedure,
|
|||
NULL);
|
||||
|
||||
GIMP_TEST_START("Verify start state (1)");
|
||||
images = gimp_get_images (&n_images);
|
||||
GIMP_TEST_END(n_images == 1 && images[0] == new_image);
|
||||
images = gimp_get_images ();
|
||||
GIMP_TEST_END(gimp_core_object_array_get_length ((GObject **) images) == 1 && images[0] == new_image);
|
||||
g_free (images);
|
||||
|
||||
GIMP_TEST_START("Verify start state (2)");
|
||||
|
|
@ -55,8 +54,8 @@ gimp_c_test_run (GimpProcedure *procedure,
|
|||
|
||||
GIMP_TEST_START("gimp_export_options_get_image() created a new image");
|
||||
delete = gimp_export_options_get_image (options, &new_image);
|
||||
images = gimp_get_images (&n_images);
|
||||
GIMP_TEST_END(delete == GIMP_EXPORT_EXPORT && n_images == 2 && new_image != original_image);
|
||||
images = gimp_get_images ();
|
||||
GIMP_TEST_END(delete == GIMP_EXPORT_EXPORT && gimp_core_object_array_get_length ((GObject **) images) == 2 && new_image != original_image);
|
||||
g_free (images);
|
||||
|
||||
GIMP_TEST_START("The new image has a single layer");
|
||||
|
|
|
|||
|
|
@ -16,15 +16,14 @@ gimp_c_test_run (GimpProcedure *procedure,
|
|||
GimpImage **images;
|
||||
GimpImage *new_image;
|
||||
GimpTextLayer *text_layer;
|
||||
gint n_images;
|
||||
|
||||
GIMP_TEST_START("gimp_image_new()");
|
||||
new_image = gimp_image_new (NEW_IMAGE_WIDTH, NEW_IMAGE_HEIGHT, GIMP_RGB);
|
||||
GIMP_TEST_END(GIMP_IS_IMAGE (new_image));
|
||||
|
||||
GIMP_TEST_START("gimp_get_images()");
|
||||
images = gimp_get_images (&n_images);
|
||||
GIMP_TEST_END(n_images == 1 && images[0] == new_image);
|
||||
images = gimp_get_images ();
|
||||
GIMP_TEST_END(gimp_core_object_array_get_length ((GObject **) images) == 1 && images[0] == new_image);
|
||||
g_free (images);
|
||||
|
||||
GIMP_TEST_START("gimp_text_layer_new() with point unit");
|
||||
|
|
|
|||
10
pdb/app.pl
10
pdb/app.pl
|
|
@ -682,11 +682,11 @@ CODE
|
|||
}
|
||||
elsif ($pdbtype eq 'imagearray') {
|
||||
$pspec = <<CODE;
|
||||
gimp_param_spec_object_array ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_IMAGE,
|
||||
$flags)
|
||||
gimp_param_spec_core_object_array ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_IMAGE,
|
||||
$flags)
|
||||
CODE
|
||||
}
|
||||
elsif ($pdbtype eq 'itemarray') {
|
||||
|
|
|
|||
|
|
@ -56,27 +56,21 @@ HELP
|
|||
|
||||
@outargs = (
|
||||
{ name => 'images', type => 'imagearray',
|
||||
desc => 'The list of images currently open.',
|
||||
array => { name => 'num_images',
|
||||
desc => 'The number of images currently open' } }
|
||||
desc => 'The list of images currently open.' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<CODE
|
||||
{
|
||||
GList *list = gimp_get_image_iter (gimp);
|
||||
gsize num_images;
|
||||
gint i;
|
||||
|
||||
num_images = g_list_length (list);
|
||||
images = g_new0 (GimpImage *, num_images + 1);
|
||||
|
||||
if (num_images)
|
||||
{
|
||||
gint i;
|
||||
|
||||
images = g_new (GimpImage *, num_images);
|
||||
|
||||
for (i = 0; i < num_images; i++, list = g_list_next (list))
|
||||
images[i] = g_object_ref (list->data);
|
||||
}
|
||||
for (i = 0; i < num_images; i++, list = g_list_next (list))
|
||||
images[i] = list->data;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
|
|
|||
15
pdb/pdb.pl
15
pdb/pdb.pl
|
|
@ -110,17 +110,16 @@ package Gimp::CodeGen::pdb;
|
|||
take_value_func => 'g_value_take_boxed ($value, $var)' },
|
||||
|
||||
imagearray => { name => 'IMAGEARRAY',
|
||||
gtype => 'GIMP_TYPE_OBJECT_ARRAY',
|
||||
gtype => 'GIMP_TYPE_CORE_OBJECT_ARRAY',
|
||||
type => 'GimpImage **',
|
||||
const_type => 'const GimpImage **',
|
||||
array => 1,
|
||||
init_value => 'NULL',
|
||||
in_annotate => '(element-type GimpImage)',
|
||||
out_annotate => '(element-type GimpImage) (transfer container)',
|
||||
get_value_func => '$var = (const GimpImage **) gimp_value_get_object_array ($value)',
|
||||
dup_value_func => '{ GimpObjectArray *a = g_value_get_boxed (gimp_value_array_index ($value)); if (a) $var = g_memdup2 (a->data, a->length * sizeof (gpointer)); }',
|
||||
set_value_func => 'gimp_value_set_object_array ($value, GIMP_TYPE_IMAGE, (GObject **) $var, $var_len)',
|
||||
take_value_func => 'gimp_value_take_object_array ($value, GIMP_TYPE_IMAGE, (GObject **) $var, $var_len)' },
|
||||
in_annotate => '(element-type GimpImage) (array zero-terminated=1)',
|
||||
out_annotate => '(element-type GimpImage) (array zero-terminated=1) (transfer container)',
|
||||
get_value_func => '$var = g_value_get_boxed ($value)',
|
||||
dup_value_func => '$var = g_value_dup_boxed (gimp_value_array_index ($value))',
|
||||
set_value_func => 'g_value_set_boxed ($value, $var)',
|
||||
take_value_func => 'g_value_take_boxed ($value, $var)' },
|
||||
|
||||
itemarray => { name => 'ITEMARRAY',
|
||||
gtype => 'GIMP_TYPE_CORE_OBJECT_ARRAY',
|
||||
|
|
|
|||
Loading…
Reference in a new issue