app, libgimp, pdb, plug-ins: PDB (gimp-group-layer-new) made public.

This commit is contained in:
Jehan 2025-01-20 22:33:48 +01:00
parent 957d76fd14
commit 18d88c207c
8 changed files with 64 additions and 58 deletions

View file

@ -59,17 +59,25 @@ group_layer_new_invoker (GimpProcedure *procedure,
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpImage *image;
const gchar *name;
GimpGroupLayer *group_layer = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
name = g_value_get_string (gimp_value_array_index (args, 1));
if (success)
{
group_layer = GIMP_GROUP_LAYER (gimp_group_layer_new (image));
if (! group_layer)
{
success = FALSE;
}
else if (name != NULL && strlen (name) > 0)
{
gimp_item_rename (GIMP_ITEM (group_layer), name, error);
}
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
@ -128,12 +136,16 @@ register_group_layer_procs (GimpPDB *pdb)
/*
* gimp-group-layer-new
*/
procedure = gimp_procedure_new (group_layer_new_invoker, TRUE, TRUE);
procedure = gimp_procedure_new (group_layer_new_invoker, TRUE, FALSE);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-group-layer-new");
gimp_procedure_set_static_help (procedure,
"Create a new group layer.",
"This procedure creates a new group layer. Attributes such as layer mode and opacity should be set with explicit procedure calls. Add the new group layer (which is a kind of layer) with [method@image.insert_layer].\n"
"This procedure creates a new group layer with a given @name. If @name is %NULL, GIMP will choose a name using its default layer name algorithm.\n"
"\n"
"The new group layer still needs to be added to the image, as this is not automatic. Add the new layer with the [method@Image.insert_layer] method.\n"
"Other attributes such as layer mask, modes and offsets should be set with explicit procedure calls.\n"
"\n"
"Other procedures useful with group layers: [method@image_reorder_item], [method@item.get_parent], [method@item.get_children], [method@item.is_group].",
NULL);
gimp_procedure_set_static_attribution (procedure,
@ -146,6 +158,13 @@ register_group_layer_procs (GimpPDB *pdb)
"The image to which to add the group layer",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("name",
"name",
"The group layer name",
FALSE, TRUE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_group_layer ("group-layer",
"group layer",

View file

@ -73,37 +73,3 @@ gimp_group_layer_get_by_id (gint32 layer_id)
return NULL;
}
/**
* gimp_group_layer_new:
* @image: The image to which to add the layer.
* @name: (nullable): The group layer name.
*
* Create a new group layer.
*
* This procedure creates a new group layer with a given @name. If @name is
* %NULL, GIMP will choose a name using its default layer name algorithm.
*
* The new group layer still needs to be added to the image, as this is
* not automatic. Add the new layer with the [method@Image.insert_layer]
* method.
*
* Other attributes such as layer mask modes, and offsets should be set
* with explicit procedure calls.
*
* Returns: (transfer none): The newly created group layer.
* The object belongs to libgimp and you should not free it.
*
* Since: 3.0
*/
GimpGroupLayer *
gimp_group_layer_new (GimpImage *image,
const gchar *name)
{
GimpGroupLayer *layer = _gimp_group_layer_new (image);
if (name != NULL)
gimp_item_set_name (GIMP_ITEM (layer), name);
return layer;
}

View file

@ -40,9 +40,6 @@ G_DECLARE_FINAL_TYPE (GimpGroupLayer, gimp_group_layer, GIMP, GROUP_LAYER, GimpL
GimpGroupLayer * gimp_group_layer_get_by_id (gint32 layer_id);
GimpGroupLayer * gimp_group_layer_new (GimpImage *image,
const gchar *name) G_GNUC_WARN_UNUSED_RESULT;
G_END_DECLS

View file

@ -37,15 +37,22 @@
/**
* _gimp_group_layer_new:
* gimp_group_layer_new:
* @image: The image to which to add the group layer.
* @name: (nullable): The group layer name.
*
* Create a new group layer.
*
* This procedure creates a new group layer. Attributes such as layer
* mode and opacity should be set with explicit procedure calls. Add
* the new group layer (which is a kind of layer) with
* [method@image.insert_layer].
* This procedure creates a new group layer with a given @name. If
* @name is %NULL, GIMP will choose a name using its default layer name
* algorithm.
*
* The new group layer still needs to be added to the image, as this is
* not automatic. Add the new layer with the
* [method@Image.insert_layer] method.
* Other attributes such as layer mask, modes and offsets should be set
* with explicit procedure calls.
*
* Other procedures useful with group layers:
* [method@image_reorder_item], [method@item.get_parent],
* [method@item.get_children], [method@item.is_group].
@ -55,7 +62,8 @@
* Since: 2.8
**/
GimpGroupLayer *
_gimp_group_layer_new (GimpImage *image)
gimp_group_layer_new (GimpImage *image,
const gchar *name)
{
GimpValueArray *args;
GimpValueArray *return_vals;
@ -63,6 +71,7 @@ _gimp_group_layer_new (GimpImage *image)
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
G_TYPE_STRING, name,
G_TYPE_NONE);
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),

View file

@ -32,7 +32,8 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
G_GNUC_INTERNAL GimpGroupLayer* _gimp_group_layer_new (GimpImage *image);
GimpGroupLayer* gimp_group_layer_new (GimpImage *image,
const gchar *name);
GimpLayer* gimp_group_layer_merge (GimpGroupLayer *group_layer);

View file

@ -19,9 +19,17 @@ sub group_layer_new {
$blurb = 'Create a new group layer.';
$help = <<'HELP';
This procedure creates a new group layer. Attributes such as layer mode
and opacity should be set with explicit procedure calls. Add the new
group layer (which is a kind of layer) with [method@image.insert_layer].
This procedure creates a new group layer with a given @name. If @name is
%NULL, GIMP will choose a name using its default layer name algorithm.
The new group layer still needs to be added to the image, as this is
not automatic. Add the new layer with the [method@Image.insert_layer]
method.
Other attributes such as layer mask, modes and offsets should be set
with explicit procedure calls.
Other procedures useful with group layers: [method@image_reorder_item],
[method@item.get_parent], [method@item.get_children], [method@item.is_group].
@ -29,11 +37,11 @@ HELP
&barak_pdb_misc('2010', '2.8');
$lib_private = 1;
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image to which to add the group layer' }
desc => 'The image to which to add the group layer' },
{ name => 'name', type => 'string', none_ok => 1,
desc => "The group layer name" }
);
@outargs = (
@ -46,7 +54,13 @@ HELP
group_layer = GIMP_GROUP_LAYER (gimp_group_layer_new (image));
if (! group_layer)
{
success = FALSE;
}
else if (name != NULL && strlen (name) > 0)
{
gimp_item_rename (GIMP_ITEM (group_layer), name, error);
}
}
CODE
);

View file

@ -27,8 +27,8 @@
; group-new not throw
; This is setup, not an assert, because we need to capture the group's ID
; Note the ID is not wrapped in list
(define testGroup (gimp-group-layer-new testImage))
(define testGroup2 (gimp-group-layer-new testImage))
(define testGroup (gimp-group-layer-new testImage ""))
(define testGroup2 (gimp-group-layer-new testImage ""))

View file

@ -26,7 +26,7 @@
; group-new not throw
; This is setup, not an assert, because we need to capture the group's ID
; Note the ID is not wrapped in list
(define testGroup (gimp-group-layer-new testImage))
(define testGroup (gimp-group-layer-new testImage ""))