mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 09:23:24 +00:00
app, libgimp*, pdb, plug-ins: change itemarray PDB type to use GimpCoreObjectArray.
This commit is contained in:
parent
38c2cd3b15
commit
318f7451cd
11 changed files with 85 additions and 104 deletions
|
@ -464,7 +464,6 @@ item_get_children_invoker (GimpProcedure *procedure,
|
|||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
GimpItem *item;
|
||||
gint num_children = 0;
|
||||
GimpItem **children = NULL;
|
||||
|
||||
item = g_value_get_object (gimp_value_array_index (args, 0));
|
||||
|
@ -475,36 +474,29 @@ item_get_children_invoker (GimpProcedure *procedure,
|
|||
|
||||
if (container)
|
||||
{
|
||||
num_children = gimp_container_get_n_children (container);
|
||||
|
||||
if (num_children)
|
||||
{
|
||||
gsize num_children = gimp_container_get_n_children (container);
|
||||
GList *list;
|
||||
gint i;
|
||||
|
||||
children = g_new (GimpItem *, num_children);
|
||||
children = g_new0 (GimpItem *, num_children + 1);
|
||||
|
||||
for (list = GIMP_LIST (container)->queue->head, i = 0;
|
||||
list;
|
||||
list = g_list_next (list), i++)
|
||||
list; list = g_list_next (list), i++)
|
||||
{
|
||||
children[i] = g_object_ref (list->data);
|
||||
}
|
||||
children[i] = list->data;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
{
|
||||
g_value_set_int (gimp_value_array_index (return_vals, 1), num_children);
|
||||
gimp_value_take_object_array (gimp_value_array_index (return_vals, 2), GIMP_TYPE_ITEM, (GObject **) children, num_children);
|
||||
}
|
||||
g_value_take_boxed (gimp_value_array_index (return_vals, 1), children);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
@ -1485,13 +1477,7 @@ register_item_procs (GimpPDB *pdb)
|
|||
FALSE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("num-children",
|
||||
"num children",
|
||||
"The item's number of children",
|
||||
0, G_MAXINT32, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_object_array ("children",
|
||||
gimp_param_spec_core_object_array ("children",
|
||||
"children",
|
||||
"The item's list of children",
|
||||
GIMP_TYPE_ITEM,
|
||||
|
|
|
@ -373,13 +373,13 @@ GList *
|
|||
gimp_item_list_children (GimpItem *item)
|
||||
{
|
||||
GimpItem **children;
|
||||
gint num_children;
|
||||
GList *list = NULL;
|
||||
gint i;
|
||||
|
||||
children = gimp_item_get_children (item, &num_children);
|
||||
children = gimp_item_get_children (item);
|
||||
|
||||
for (i = 0; i < num_children; i++)
|
||||
if (children)
|
||||
for (i = 0; children[i] != NULL; i++)
|
||||
list = g_list_prepend (list, children[i]);
|
||||
|
||||
g_free (children);
|
||||
|
|
|
@ -560,22 +560,19 @@ gimp_item_get_parent (GimpItem *item)
|
|||
/**
|
||||
* gimp_item_get_children:
|
||||
* @item: The item.
|
||||
* @num_children: (out): The item's number of children.
|
||||
*
|
||||
* Returns the item's list of children.
|
||||
*
|
||||
* This procedure returns the list of items which are children of the
|
||||
* specified item. The order is topmost to bottommost.
|
||||
*
|
||||
* Returns: (array length=num_children) (element-type GimpItem) (transfer container):
|
||||
* Returns: (element-type GimpItem) (array zero-terminated=1) (transfer container):
|
||||
* The item's list of children.
|
||||
* The returned value must be freed with g_free().
|
||||
*
|
||||
* Since: 2.8
|
||||
**/
|
||||
GimpItem **
|
||||
gimp_item_get_children (GimpItem *item,
|
||||
gint *num_children)
|
||||
gimp_item_get_children (GimpItem *item)
|
||||
{
|
||||
GimpValueArray *args;
|
||||
GimpValueArray *return_vals;
|
||||
|
@ -590,13 +587,8 @@ gimp_item_get_children (GimpItem *item,
|
|||
args);
|
||||
gimp_value_array_unref (args);
|
||||
|
||||
*num_children = 0;
|
||||
|
||||
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
*num_children = GIMP_VALUES_GET_INT (return_vals, 1);
|
||||
{ GimpObjectArray *a = g_value_get_boxed (gimp_value_array_index (return_vals, 2)); if (a) children = g_memdup2 (a->data, a->length * sizeof (gpointer)); };
|
||||
}
|
||||
children = g_value_dup_boxed (gimp_value_array_index (return_vals, 1));
|
||||
|
||||
gimp_value_array_unref (return_vals);
|
||||
|
||||
|
|
|
@ -45,8 +45,7 @@ GimpImage* gimp_item_get_image (GimpItem *item);
|
|||
gboolean gimp_item_delete (GimpItem *item);
|
||||
gboolean gimp_item_is_group (GimpItem *item);
|
||||
GimpItem* gimp_item_get_parent (GimpItem *item);
|
||||
GimpItem** gimp_item_get_children (GimpItem *item,
|
||||
gint *num_children);
|
||||
GimpItem** gimp_item_get_children (GimpItem *item);
|
||||
gboolean gimp_item_get_expanded (GimpItem *item);
|
||||
gboolean gimp_item_set_expanded (GimpItem *item,
|
||||
gboolean expanded);
|
||||
|
|
|
@ -38,6 +38,7 @@ EXPORTS
|
|||
gimp_component_type_get_type
|
||||
gimp_convert_palette_type_get_type
|
||||
gimp_convolve_type_get_type
|
||||
gimp_core_object_array_get_length
|
||||
gimp_core_object_array_get_type
|
||||
gimp_cpu_accel_get_support
|
||||
gimp_cpu_accel_set_use
|
||||
|
|
|
@ -870,7 +870,6 @@ gimp_color_array_get_length (GimpColorArray array)
|
|||
*/
|
||||
|
||||
static GimpCoreObjectArray gimp_core_object_array_copy (GimpCoreObjectArray array);
|
||||
static gsize gimp_core_object_array_get_length (GimpCoreObjectArray array);
|
||||
|
||||
GType
|
||||
gimp_core_object_array_get_type (void)
|
||||
|
@ -890,6 +889,23 @@ gimp_core_object_array_get_type (void)
|
|||
return static_g_define_type_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_core_object_array_get_length:
|
||||
* @array: a %NULL-terminated array of objects.
|
||||
*
|
||||
* Returns: the number of [class@GObject.Object] in @array.
|
||||
**/
|
||||
gsize
|
||||
gimp_core_object_array_get_length (GObject **array)
|
||||
{
|
||||
gsize length = 0;
|
||||
|
||||
while (array && array[length] != NULL)
|
||||
length++;
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_core_object_array_copy:
|
||||
* @array: an array of core_objects.
|
||||
|
@ -918,23 +934,6 @@ gimp_core_object_array_copy (GimpCoreObjectArray array)
|
|||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_core_object_array_get_length:
|
||||
* @array: an array of core_objects.
|
||||
*
|
||||
* Returns: the number of [class@GObject.Object] in @array.
|
||||
**/
|
||||
static gsize
|
||||
gimp_core_object_array_get_length (GimpCoreObjectArray array)
|
||||
{
|
||||
gsize length = 0;
|
||||
|
||||
while (array && array[length] != NULL)
|
||||
length++;
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_PARAM_CORE_OBJECT_ARRAY
|
||||
|
|
|
@ -359,7 +359,8 @@ gint gimp_color_array_get_length (GimpColorArray array);
|
|||
* The reason of existence for this alias is to have common arrays of
|
||||
* objects as a boxed type easy to use as plug-in's procedure argument.
|
||||
*
|
||||
* You should never have to interact with this type directly.
|
||||
* You should never have to interact with this type directly, though
|
||||
* [func@Gimp.core_object_array_get_length] might be convenient.
|
||||
*
|
||||
* Since: 3.0
|
||||
*/
|
||||
|
@ -369,6 +370,7 @@ typedef GObject** GimpCoreObjectArray;
|
|||
#define GIMP_VALUE_HOLDS_CORE_OBJECT_ARRAY(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GIMP_TYPE_CORE_OBJECT_ARRAY))
|
||||
|
||||
GType gimp_core_object_array_get_type (void) G_GNUC_CONST;
|
||||
gsize gimp_core_object_array_get_length (GObject **array);
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -691,7 +691,7 @@ CODE
|
|||
}
|
||||
elsif ($pdbtype eq 'itemarray') {
|
||||
$pspec = <<CODE;
|
||||
gimp_param_spec_object_array ("$name",
|
||||
gimp_param_spec_core_object_array ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_ITEM,
|
||||
|
|
|
@ -491,9 +491,7 @@ HELP
|
|||
|
||||
@outargs = (
|
||||
{ name => 'children', type => 'itemarray',
|
||||
desc => "The item's list of children",
|
||||
array => { name => 'num_children',
|
||||
desc => "The item's number of children" } }
|
||||
desc => "The item's list of children" }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
|
@ -503,26 +501,22 @@ HELP
|
|||
|
||||
if (container)
|
||||
{
|
||||
num_children = gimp_container_get_n_children (container);
|
||||
|
||||
if (num_children)
|
||||
{
|
||||
gsize num_children = gimp_container_get_n_children (container);
|
||||
GList *list;
|
||||
gint i;
|
||||
|
||||
children = g_new (GimpItem *, num_children);
|
||||
children = g_new0 (GimpItem *, num_children + 1);
|
||||
|
||||
for (list = GIMP_LIST (container)->queue->head, i = 0;
|
||||
list;
|
||||
list = g_list_next (list), i++)
|
||||
list; list = g_list_next (list), i++)
|
||||
{
|
||||
children[i] = g_object_ref (list->data);
|
||||
}
|
||||
children[i] = list->data;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
|
||||
}
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
|
15
pdb/pdb.pl
15
pdb/pdb.pl
|
@ -123,17 +123,16 @@ package Gimp::CodeGen::pdb;
|
|||
take_value_func => 'gimp_value_take_object_array ($value, GIMP_TYPE_IMAGE, (GObject **) $var, $var_len)' },
|
||||
|
||||
itemarray => { name => 'ITEMARRAY',
|
||||
gtype => 'GIMP_TYPE_OBJECT_ARRAY',
|
||||
gtype => 'GIMP_TYPE_CORE_OBJECT_ARRAY',
|
||||
type => 'GimpItem **',
|
||||
const_type => 'const GimpItem **',
|
||||
array => 1,
|
||||
init_value => 'NULL',
|
||||
in_annotate => '(element-type GimpItem)',
|
||||
out_annotate => '(element-type GimpItem) (transfer container)',
|
||||
get_value_func => '$var = (const GimpItem **) 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_ITEM, (GObject **) $var, $var_len)',
|
||||
take_value_func => 'gimp_value_take_object_array ($value, GIMP_TYPE_ITEM, (GObject **) $var, $var_len)' },
|
||||
in_annotate => '(element-type GimpItem) (array zero-terminated=1)',
|
||||
out_annotate => '(element-type GimpItem) (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)' },
|
||||
|
||||
drawablearray => { name => 'DRAWABLEARRAY',
|
||||
gtype => 'GIMP_TYPE_CORE_OBJECT_ARRAY',
|
||||
|
|
|
@ -944,8 +944,15 @@ gui_single (GimpProcedure *procedure,
|
|||
/* Enable "layers-as-pages" if more than one layer, or there's a single
|
||||
* layer group has more than one layer */
|
||||
layers = gimp_image_get_layers (multi_page.images[0], &n_layers);
|
||||
|
||||
if (n_layers == 1 && gimp_item_is_group (GIMP_ITEM (layers[0])))
|
||||
g_free (gimp_item_get_children (GIMP_ITEM (layers[0]), &n_layers));
|
||||
{
|
||||
GimpItem **children;
|
||||
|
||||
children = gimp_item_get_children (GIMP_ITEM (layers[0]));
|
||||
n_layers = gimp_core_object_array_get_length ((GObject **) children);
|
||||
g_free (children);
|
||||
}
|
||||
g_free (layers);
|
||||
|
||||
gtk_widget_set_sensitive (widget, n_layers > 1);
|
||||
|
@ -1853,11 +1860,13 @@ draw_layer (GimpLayer **layers,
|
|||
if (gimp_item_is_group (GIMP_ITEM (layer)))
|
||||
{
|
||||
GimpItem **children;
|
||||
gint children_num;
|
||||
gint children_num = 0;
|
||||
gint i;
|
||||
|
||||
children = gimp_item_get_children (GIMP_ITEM (layer), &children_num);
|
||||
for (i = 0; i < children_num; i++)
|
||||
children = gimp_item_get_children (GIMP_ITEM (layer));
|
||||
children_num = gimp_core_object_array_get_length ((GObject **) children);
|
||||
|
||||
for (i = 0; children[i] != NULL; i++)
|
||||
{
|
||||
if (! draw_layer ((GimpLayer **) children, children_num,
|
||||
config, single_image, i,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue