added boolean return value indicating whether the cut/copy was successful.

2004-03-10  Michael Natterer  <mitch@gimp.org>

	* 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.
This commit is contained in:
Michael Natterer 2004-03-10 11:44:16 +00:00 committed by Michael Natterer
parent 9bd4c7ac27
commit 991465bdaf
4 changed files with 73 additions and 21 deletions

View File

@ -1,3 +1,12 @@
2004-03-10 Michael Natterer <mitch@gimp.org>
* 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 <sven@gimp.org>
* plug-ins/ifscompose/ifscompose.c: added missing localization for

View File

@ -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 } }
};

View File

@ -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;
}
/**

View File

@ -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 => <<CODE
{
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
success = @{[shift]};
@{[shift]};
}
CODE
);
@ -66,7 +73,8 @@ HELP
&std_pdb_misc;
&inargs('cut from');
&invoke('gimp_edit_cut (gimage, drawable) != NULL');
&outargs('cut');
&invoke('non_empty = gimp_edit_cut (gimage, drawable) != NULL');
}
sub edit_copy {
@ -82,7 +90,8 @@ HELP
&std_pdb_misc;
&inargs('copy from');
&invoke('gimp_edit_copy (gimage, drawable) != NULL');
&outargs('copy');
&invoke('non_empty = gimp_edit_copy (gimage, drawable) != NULL');
}
sub edit_paste {
@ -148,7 +157,7 @@ HELP
&std_pdb_misc;
&inargs('clear from');
&invoke('gimp_edit_clear (gimage, drawable)');
&invoke('success = gimp_edit_clear (gimage, drawable)');
}
sub edit_fill {
@ -171,7 +180,7 @@ HELP
{ name => '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 {