From 548d2e041d47df3e3f295b2b16edd30e8b57af4c Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Wed, 15 Sep 2010 21:18:47 +0200 Subject: [PATCH] pdb: clean up gimp-layer-group-new There is no need to wrap it with a function with identical signature. Also move it next to the other layer-new functions. --- app/pdb/layer-cmds.c | 122 ++++++++++++++++++------------------- libgimp/gimplayer.c | 19 ------ libgimp/gimplayer.h | 1 - libgimp/gimplayer_pdb.c | 70 ++++++++++----------- libgimp/gimplayer_pdb.h | 2 +- tools/pdbgen/pdb/layer.pdb | 70 ++++++++++----------- 6 files changed, 132 insertions(+), 152 deletions(-) diff --git a/app/pdb/layer-cmds.c b/app/pdb/layer-cmds.c index 31f24bd340..6ba8d7f7bd 100644 --- a/app/pdb/layer-cmds.c +++ b/app/pdb/layer-cmds.c @@ -178,6 +178,38 @@ layer_new_from_drawable_invoker (GimpProcedure *procedure, return return_vals; } +static GValueArray * +layer_group_new_invoker (GimpProcedure *procedure, + Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + const GValueArray *args, + GError **error) +{ + gboolean success = TRUE; + GValueArray *return_vals; + GimpImage *image; + GimpLayer *layer_group = NULL; + + image = gimp_value_get_image (&args->values[0], gimp); + + if (success) + { + layer_group = gimp_group_layer_new (image); + + if (! layer_group) + success = FALSE; + } + + return_vals = gimp_procedure_get_return_values (procedure, success, + error ? *error : NULL); + + if (success) + gimp_value_set_layer (&return_vals->values[1], layer_group); + + return return_vals; +} + static GValueArray * layer_copy_invoker (GimpProcedure *procedure, Gimp *gimp, @@ -1027,38 +1059,6 @@ layer_set_mode_invoker (GimpProcedure *procedure, error ? *error : NULL); } -static GValueArray * -layer_group_new_invoker (GimpProcedure *procedure, - Gimp *gimp, - GimpContext *context, - GimpProgress *progress, - const GValueArray *args, - GError **error) -{ - gboolean success = TRUE; - GValueArray *return_vals; - GimpImage *image; - GimpLayer *layer_group = NULL; - - image = gimp_value_get_image (&args->values[0], gimp); - - if (success) - { - layer_group = gimp_group_layer_new (image); - - if (! layer_group) - success = FALSE; - } - - return_vals = gimp_procedure_get_return_values (procedure, success, - error ? *error : NULL); - - if (success) - gimp_value_set_layer (&return_vals->values[1], layer_group); - - return return_vals; -} - void register_layer_procs (GimpPDB *pdb) { @@ -1209,6 +1209,35 @@ register_layer_procs (GimpPDB *pdb) gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); + /* + * gimp-layer-group-new + */ + procedure = gimp_procedure_new (layer_group_new_invoker); + gimp_object_set_static_name (GIMP_OBJECT (procedure), + "gimp-layer-group-new"); + gimp_procedure_set_static_strings (procedure, + "gimp-layer-group-new", + "Create a new layer group.", + "This procedure creates a new layer group. Attributes such as layer mode and opacity should be set with explicit procedure calls. Add the new layer group (which is a kind of layer) with the 'gimp-image-insert-layer' command.", + "Barak Itkin ", + "Barak Itkin", + "2010", + NULL); + gimp_procedure_add_argument (procedure, + gimp_param_spec_image_id ("image", + "image", + "The image to which to add the layer group", + pdb->gimp, FALSE, + GIMP_PARAM_READWRITE)); + gimp_procedure_add_return_value (procedure, + gimp_param_spec_layer_id ("layer-group", + "layer group", + "The newly created layer group", + pdb->gimp, FALSE, + GIMP_PARAM_READWRITE)); + gimp_pdb_register_procedure (pdb, procedure); + g_object_unref (procedure); + /* * gimp-layer-copy */ @@ -2050,33 +2079,4 @@ register_layer_procs (GimpPDB *pdb) GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); - - /* - * gimp-layer-group-new - */ - procedure = gimp_procedure_new (layer_group_new_invoker); - gimp_object_set_static_name (GIMP_OBJECT (procedure), - "gimp-layer-group-new"); - gimp_procedure_set_static_strings (procedure, - "gimp-layer-group-new", - "Create a new layer group.", - "This procedure creates a new layer group. Attributes such as layer mode and opacity should be set with explicit procedure calls. Add the new layer group (which is a kind of layer) with the 'gimp-image-insert-layer' command.", - "Barak Itkin ", - "Barak Itkin", - "2010", - NULL); - gimp_procedure_add_argument (procedure, - gimp_param_spec_image_id ("image", - "image", - "The image to which to add the layer group", - pdb->gimp, FALSE, - GIMP_PARAM_READWRITE)); - gimp_procedure_add_return_value (procedure, - gimp_param_spec_layer_id ("layer-group", - "layer group", - "The newly created layer group", - pdb->gimp, FALSE, - GIMP_PARAM_READWRITE)); - gimp_pdb_register_procedure (pdb, procedure); - g_object_unref (procedure); } diff --git a/libgimp/gimplayer.c b/libgimp/gimplayer.c index 6774c708b6..9680b7987e 100644 --- a/libgimp/gimplayer.c +++ b/libgimp/gimplayer.c @@ -82,25 +82,6 @@ gimp_layer_copy (gint32 layer_ID) return _gimp_layer_copy (layer_ID, FALSE); } -/** - * gimp_layer_group_new: - * @image_ID: The image to which to add the layer. - * - * Create a new layer group. - * - * This procedure creates a new layer group. Attributes such as layer - * mode and opacity should be set with explicit procedure calls. Add - * the new layer group (which is a kind of layer) with the - * gimp_image_insert_layer() command. - * - * Returns: The newly created layer group. - */ -gint32 -gimp_layer_group_new (gint32 image_ID) -{ - return _gimp_layer_group_new (image_ID); -} - /** * gimp_layer_get_preserve_trans: * @layer_ID: The layer. diff --git a/libgimp/gimplayer.h b/libgimp/gimplayer.h index a3fcd5bad6..6f8fd4871f 100644 --- a/libgimp/gimplayer.h +++ b/libgimp/gimplayer.h @@ -34,7 +34,6 @@ gint32 gimp_layer_new (gint32 image_ID, gdouble opacity, GimpLayerModeEffects mode); gint32 gimp_layer_copy (gint32 layer_ID); -gint32 gimp_layer_group_new (gint32 image_ID); #ifndef GIMP_DISABLE_DEPRECATED diff --git a/libgimp/gimplayer_pdb.c b/libgimp/gimplayer_pdb.c index 15e455775b..7c85377431 100644 --- a/libgimp/gimplayer_pdb.c +++ b/libgimp/gimplayer_pdb.c @@ -166,6 +166,41 @@ gimp_layer_new_from_drawable (gint32 drawable_ID, return layer_copy_ID; } +/** + * gimp_layer_group_new: + * @image_ID: The image to which to add the layer group. + * + * Create a new layer group. + * + * This procedure creates a new layer group. Attributes such as layer + * mode and opacity should be set with explicit procedure calls. Add + * the new layer group (which is a kind of layer) with the + * gimp_image_insert_layer() command. + * + * Returns: The newly created layer group. + * + * Since: GIMP 2.8 + */ +gint32 +gimp_layer_group_new (gint32 image_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 layer_group_ID = -1; + + return_vals = gimp_run_procedure ("gimp-layer-group-new", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + layer_group_ID = return_vals[1].data.d_layer; + + gimp_destroy_params (return_vals, nreturn_vals); + + return layer_group_ID; +} + /** * _gimp_layer_copy: * @layer_ID: The layer to copy. @@ -1110,38 +1145,3 @@ gimp_layer_set_mode (gint32 layer_ID, return success; } - -/** - * _gimp_layer_group_new: - * @image_ID: The image to which to add the layer group. - * - * Create a new layer group. - * - * This procedure creates a new layer group. Attributes such as layer - * mode and opacity should be set with explicit procedure calls. Add - * the new layer group (which is a kind of layer) with the - * gimp_image_insert_layer() command. - * - * Returns: The newly created layer group. - * - * Since: GIMP 2.8 - */ -gint32 -_gimp_layer_group_new (gint32 image_ID) -{ - GimpParam *return_vals; - gint nreturn_vals; - gint32 layer_group_ID = -1; - - return_vals = gimp_run_procedure ("gimp-layer-group-new", - &nreturn_vals, - GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_END); - - if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - layer_group_ID = return_vals[1].data.d_layer; - - gimp_destroy_params (return_vals, nreturn_vals); - - return layer_group_ID; -} diff --git a/libgimp/gimplayer_pdb.h b/libgimp/gimplayer_pdb.h index ea263555b6..80dc102c15 100644 --- a/libgimp/gimplayer_pdb.h +++ b/libgimp/gimplayer_pdb.h @@ -40,6 +40,7 @@ gint32 gimp_layer_new_from_visible (gint32 i const gchar *name); gint32 gimp_layer_new_from_drawable (gint32 drawable_ID, gint32 dest_image_ID); +gint32 gimp_layer_group_new (gint32 image_ID); G_GNUC_INTERNAL gint32 _gimp_layer_copy (gint32 layer_ID, gboolean add_alpha); gboolean gimp_layer_add_alpha (gint32 layer_ID); @@ -92,7 +93,6 @@ gboolean gimp_layer_set_opacity (gint32 l GimpLayerModeEffects gimp_layer_get_mode (gint32 layer_ID); gboolean gimp_layer_set_mode (gint32 layer_ID, GimpLayerModeEffects mode); -G_GNUC_INTERNAL gint32 _gimp_layer_group_new (gint32 image_ID); G_END_DECLS diff --git a/tools/pdbgen/pdb/layer.pdb b/tools/pdbgen/pdb/layer.pdb index b424bd756b..0d32a73931 100644 --- a/tools/pdbgen/pdb/layer.pdb +++ b/tools/pdbgen/pdb/layer.pdb @@ -159,6 +159,39 @@ CODE ); } +sub layer_group_new { + $blurb = 'Create a new layer group.'; + + $help = <<'HELP'; +This procedure creates a new layer group. Attributes such as layer mode +and opacity should be set with explicit procedure calls. Add the new +layer group (which is a kind of layer) with the +gimp_image_insert_layer() command. +HELP + + &barak_pdb_misc('2010', '2.8'); + + @inargs = ( + { name => 'image', type => 'image', + desc => 'The image to which to add the layer group' } + ); + + @outargs = ( + { name => 'layer_group', type => 'layer', + desc => 'The newly created layer group' } + ); + %invoke = ( + code => <<'CODE' +{ + layer_group = gimp_group_layer_new (image); + + if (! layer_group) + success = FALSE; +} +CODE + ); +} + sub layer_copy { $blurb = 'Copy a layer.'; @@ -1071,39 +1104,6 @@ CODE ); } -sub layer_group_new { - $blurb = 'Create a new layer group.'; - - $help = <<'HELP'; -This procedure creates a new layer group. Attributes such as layer mode -and opacity should be set with explicit procedure calls. Add the new -layer group (which is a kind of layer) with the -gimp_image_insert_layer() command. -HELP - - &barak_pdb_misc('2010', '2.8'); - - @inargs = ( - { name => 'image', type => 'image', - desc => 'The image to which to add the layer group' } - ); - - @outargs = ( - { name => 'layer_group', type => 'layer', wrap => 1, - desc => 'The newly created layer group' } - ); - %invoke = ( - code => <<'CODE' -{ - layer_group = gimp_group_layer_new (image); - - if (! layer_group) - success = FALSE; -} -CODE - ); -} - @headers = qw("libgimpbase/gimpbase.h" "config/gimpcoreconfig.h" "core/gimp.h" @@ -1117,6 +1117,7 @@ CODE @procs = qw(layer_new layer_new_from_visible layer_new_from_drawable + layer_group_new layer_copy layer_add_alpha layer_flatten @@ -1134,8 +1135,7 @@ CODE layer_get_show_mask layer_set_show_mask layer_get_edit_mask layer_set_edit_mask layer_get_opacity layer_set_opacity - layer_get_mode layer_set_mode - layer_group_new); + layer_get_mode layer_set_mode); %exports = (app => [@procs], lib => [@procs]);