From 991465bdaf05a16d01fea7928f1de7d95c061862 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Wed, 10 Mar 2004 11:44:16 +0000 Subject: [PATCH] added boolean return value indicating whether the cut/copy was successful. 2004-03-10 Michael Natterer * tools/pdbgen/pdb/edit.pdb (edit_cut, edit_copy): added boolean return value indicating whether the cut/copy was successful. Fixes bug #136489. * app/pdb/edit_cmds.c * libgimp/gimpedit_pdb.c: regenerated. --- ChangeLog | 9 ++++++++ app/pdb/edit_cmds.c | 48 ++++++++++++++++++++++++++++++++------- libgimp/gimpedit_pdb.c | 18 ++++++++------- tools/pdbgen/pdb/edit.pdb | 19 ++++++++++++---- 4 files changed, 73 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index f8f9f00890..d608c07b5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-03-10 Michael Natterer + + * tools/pdbgen/pdb/edit.pdb (edit_cut, edit_copy): added boolean + return value indicating whether the cut/copy was successful. + Fixes bug #136489. + + * app/pdb/edit_cmds.c + * libgimp/gimpedit_pdb.c: regenerated. + 2004-03-10 Sven Neumann * plug-ins/ifscompose/ifscompose.c: added missing localization for diff --git a/app/pdb/edit_cmds.c b/app/pdb/edit_cmds.c index df08363f10..72cae59e7f 100644 --- a/app/pdb/edit_cmds.c +++ b/app/pdb/edit_cmds.c @@ -66,7 +66,9 @@ edit_cut_invoker (Gimp *gimp, Argument *args) { gboolean success = TRUE; + Argument *return_args; GimpDrawable *drawable; + gboolean non_empty = FALSE; GimpImage *gimage; drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); @@ -76,10 +78,15 @@ edit_cut_invoker (Gimp *gimp, if (success) { gimage = gimp_item_get_image (GIMP_ITEM (drawable)); - success = gimp_edit_cut (gimage, drawable) != NULL; + non_empty = gimp_edit_cut (gimage, drawable) != NULL; } - return procedural_db_return_args (&edit_cut_proc, success); + return_args = procedural_db_return_args (&edit_cut_proc, success); + + if (success) + return_args[1].value.pdb_int = non_empty; + + return return_args; } static ProcArg edit_cut_inargs[] = @@ -91,6 +98,15 @@ static ProcArg edit_cut_inargs[] = } }; +static ProcArg edit_cut_outargs[] = +{ + { + GIMP_PDB_INT32, + "non_empty", + "TRUE if the cut was successful, FALSE if the selection contained only transparent pixels" + } +}; + static ProcRecord edit_cut_proc = { "gimp_edit_cut", @@ -102,8 +118,8 @@ static ProcRecord edit_cut_proc = GIMP_INTERNAL, 1, edit_cut_inargs, - 0, - NULL, + 1, + edit_cut_outargs, { { edit_cut_invoker } } }; @@ -112,7 +128,9 @@ edit_copy_invoker (Gimp *gimp, Argument *args) { gboolean success = TRUE; + Argument *return_args; GimpDrawable *drawable; + gboolean non_empty = FALSE; GimpImage *gimage; drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); @@ -122,10 +140,15 @@ edit_copy_invoker (Gimp *gimp, if (success) { gimage = gimp_item_get_image (GIMP_ITEM (drawable)); - success = gimp_edit_copy (gimage, drawable) != NULL; + non_empty = gimp_edit_copy (gimage, drawable) != NULL; } - return procedural_db_return_args (&edit_copy_proc, success); + return_args = procedural_db_return_args (&edit_copy_proc, success); + + if (success) + return_args[1].value.pdb_int = non_empty; + + return return_args; } static ProcArg edit_copy_inargs[] = @@ -137,6 +160,15 @@ static ProcArg edit_copy_inargs[] = } }; +static ProcArg edit_copy_outargs[] = +{ + { + GIMP_PDB_INT32, + "non_empty", + "TRUE if the copy was successful, FALSE if the selection contained only transparent pixels" + } +}; + static ProcRecord edit_copy_proc = { "gimp_edit_copy", @@ -148,8 +180,8 @@ static ProcRecord edit_copy_proc = GIMP_INTERNAL, 1, edit_copy_inargs, - 0, - NULL, + 1, + edit_copy_outargs, { { edit_copy_invoker } } }; diff --git a/libgimp/gimpedit_pdb.c b/libgimp/gimpedit_pdb.c index a51431fcbe..b62453e36b 100644 --- a/libgimp/gimpedit_pdb.c +++ b/libgimp/gimpedit_pdb.c @@ -38,25 +38,26 @@ * specified drawable will be removed and its contents stored in the * internal GIMP edit buffer. * - * Returns: TRUE on success. + * Returns: TRUE if the cut was successful, FALSE if the selection contained only transparent pixels. */ gboolean gimp_edit_cut (gint32 drawable_ID) { GimpParam *return_vals; gint nreturn_vals; - gboolean success = TRUE; + gboolean non_empty = FALSE; return_vals = gimp_run_procedure ("gimp_edit_cut", &nreturn_vals, GIMP_PDB_DRAWABLE, drawable_ID, GIMP_PDB_END); - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + non_empty = return_vals[1].data.d_int32; gimp_destroy_params (return_vals, nreturn_vals); - return success; + return non_empty; } /** @@ -72,25 +73,26 @@ gimp_edit_cut (gint32 drawable_ID) * specified drawable's contents will be stored in the internal GIMP * edit buffer. * - * Returns: TRUE on success. + * Returns: TRUE if the copy was successful, FALSE if the selection contained only transparent pixels. */ gboolean gimp_edit_copy (gint32 drawable_ID) { GimpParam *return_vals; gint nreturn_vals; - gboolean success = TRUE; + gboolean non_empty = FALSE; return_vals = gimp_run_procedure ("gimp_edit_copy", &nreturn_vals, GIMP_PDB_DRAWABLE, drawable_ID, GIMP_PDB_END); - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + non_empty = return_vals[1].data.d_int32; gimp_destroy_params (return_vals, nreturn_vals); - return success; + return non_empty; } /** diff --git a/tools/pdbgen/pdb/edit.pdb b/tools/pdbgen/pdb/edit.pdb index cc43b611a4..b0a7a0bc4b 100644 --- a/tools/pdbgen/pdb/edit.pdb +++ b/tools/pdbgen/pdb/edit.pdb @@ -25,6 +25,13 @@ sub inargs { ); } +sub outargs { + @outargs = ( + { name => 'non_empty', type => 'boolean', init => 1, + desc => "TRUE if the @{[shift]} was successful, FALSE if the selection contained only transparent pixels" } + ); +} + sub drawable_arg () {{ name => 'drawable', type => 'drawable', @@ -45,7 +52,7 @@ sub invoke { code => < 'fill_type', type => 'enum GimpFillType', desc => 'The type of fill: %%desc%%' } ); - &invoke('gimp_edit_fill (gimage, drawable, (GimpFillType) fill_type)'); + &invoke('success = gimp_edit_fill (gimage, drawable, (GimpFillType) fill_type)'); } sub edit_bucket_fill {