Commit f6e5ecb2 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/core/gimp-edit.c app/core/gimpdrawable-blend.c

2004-11-11  Michael Natterer  <mitch@gimp.org>

	* app/core/gimp-edit.c
	* app/core/gimpdrawable-blend.c
	* app/core/gimpdrawable-bucket-fill.c
	* app/core/gimpitem.c (gimp_item_stroke): added precondition
	checks for gimp_item_is_attached() and removed checks for
	gimp_item_get_image() to actually return an image (because it
	always returns an image).

	* tools/pdbgen/pdb/edit.pdb: let all wrappers fail if the drawable
	is not attached.

	* app/pdb/edit_cmds.c: regenerated.
parent 5f2ca28c
2004-11-11 Michael Natterer <mitch@gimp.org>
* app/core/gimp-edit.c
* app/core/gimpdrawable-blend.c
* app/core/gimpdrawable-bucket-fill.c
* app/core/gimpitem.c (gimp_item_stroke): added precondition
checks for gimp_item_is_attached() and removed checks for
gimp_item_get_image() to actually return an image (because it
always returns an image).
* tools/pdbgen/pdb/edit.pdb: let all wrappers fail if the drawable
is not attached.
* app/pdb/edit_cmds.c: regenerated.
2004-11-11 Michael Natterer <mitch@gimp.org>
* plug-ins/script-fu/scripts/add-bevel.scm
......
......@@ -70,6 +70,7 @@ gimp_edit_cut (GimpImage *gimage,
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
return gimp_edit_extract (gimage, drawable, context, TRUE);
......@@ -82,6 +83,7 @@ gimp_edit_copy (GimpImage *gimage,
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
return gimp_edit_extract (gimage, drawable, context, FALSE);
......@@ -274,6 +276,7 @@ gimp_edit_clear (GimpImage *gimage,
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
return gimp_edit_fill_internal (gimage, drawable, context,
......@@ -291,6 +294,7 @@ gimp_edit_fill (GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
switch (fill_type)
......
......@@ -194,13 +194,12 @@ gimp_drawable_blend (GimpDrawable *drawable,
gint x, y, width, height;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_if_fail (GIMP_IS_IMAGE (gimage));
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
return;
......
......@@ -63,12 +63,11 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
GimpPattern *pattern = NULL;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (GIMP_IS_CONTEXT (context));
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_if_fail (GIMP_IS_IMAGE (gimage));
if (fill_mode == GIMP_FG_BUCKET_FILL)
{
gimp_context_get_foreground (context, &color);
......@@ -129,6 +128,7 @@ gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
gboolean selection;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (fill_mode != GIMP_PATTERN_BUCKET_FILL ||
GIMP_IS_PATTERN (pattern));
g_return_if_fail (fill_mode == GIMP_PATTERN_BUCKET_FILL ||
......@@ -136,8 +136,6 @@ gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_if_fail (GIMP_IS_IMAGE (gimage));
bytes = gimp_drawable_bytes (drawable);
selection = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
......
......@@ -977,7 +977,9 @@ gimp_item_stroke (GimpItem *item,
gboolean retval = FALSE;
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
g_return_val_if_fail (gimp_item_is_attached (item), FALSE);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (GIMP_IS_STROKE_DESC (stroke_desc), FALSE);
......
......@@ -70,7 +70,6 @@ edit_cut_invoker (Gimp *gimp,
Argument *return_args;
GimpDrawable *drawable;
gboolean non_empty = FALSE;
GimpImage *gimage;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
......@@ -78,8 +77,14 @@ edit_cut_invoker (Gimp *gimp,
if (success)
{
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
non_empty = gimp_edit_cut (gimage, drawable, context) != NULL;
success = gimp_item_is_attached (GIMP_ITEM (drawable));
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
non_empty = gimp_edit_cut (gimage, drawable, context) != NULL;
}
}
return_args = procedural_db_return_args (&edit_cut_proc, success);
......@@ -135,7 +140,6 @@ edit_copy_invoker (Gimp *gimp,
Argument *return_args;
GimpDrawable *drawable;
gboolean non_empty = FALSE;
GimpImage *gimage;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
......@@ -143,8 +147,14 @@ edit_copy_invoker (Gimp *gimp,
if (success)
{
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
non_empty = gimp_edit_copy (gimage, drawable, context) != NULL;
success = gimp_item_is_attached (GIMP_ITEM (drawable));
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
non_empty = gimp_edit_copy (gimage, drawable, context) != NULL;
}
}
return_args = procedural_db_return_args (&edit_copy_proc, success);
......@@ -279,7 +289,6 @@ edit_clear_invoker (Gimp *gimp,
{
gboolean success = TRUE;
GimpDrawable *drawable;
GimpImage *gimage;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
......@@ -287,8 +296,14 @@ edit_clear_invoker (Gimp *gimp,
if (success)
{
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
success = gimp_edit_clear (gimage, drawable, context);
success = gimp_item_is_attached (GIMP_ITEM (drawable));
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
success = gimp_edit_clear (gimage, drawable, context);
}
}
return procedural_db_return_args (&edit_clear_proc, success);
......@@ -329,7 +344,6 @@ edit_fill_invoker (Gimp *gimp,
gboolean success = TRUE;
GimpDrawable *drawable;
gint32 fill_type;
GimpImage *gimage;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
......@@ -341,8 +355,14 @@ edit_fill_invoker (Gimp *gimp,
if (success)
{
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
success = gimp_edit_fill (gimage, drawable, context, (GimpFillType) fill_type);
success = gimp_item_is_attached (GIMP_ITEM (drawable));
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
success = gimp_edit_fill (gimage, drawable, context, (GimpFillType) fill_type);
}
}
return procedural_db_return_args (&edit_fill_proc, success);
......@@ -423,15 +443,12 @@ edit_bucket_fill_invoker (Gimp *gimp,
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
success = gimp_item_is_attached (GIMP_ITEM (drawable));
if (! gimage)
{
success = FALSE;
}
else
if (success)
{
gboolean do_seed_fill;
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
gboolean do_seed_fill;
do_seed_fill = gimp_channel_is_empty (gimp_image_get_mask (gimage));
......@@ -583,11 +600,9 @@ edit_blend_invoker (Gimp *gimp,
if (success)
{
if (! gimp_item_get_image (GIMP_ITEM (drawable)))
{
success = FALSE;
}
else
success = gimp_item_is_attached (GIMP_ITEM (drawable));
if (success)
{
if (progress)
gimp_progress_start (progress, _("Blending..."), FALSE);
......@@ -728,15 +743,20 @@ edit_stroke_invoker (Gimp *gimp,
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpStrokeDesc *desc = gimp_stroke_desc_new (gimp, context);
success = gimp_item_is_attached (GIMP_ITEM (drawable));
g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpStrokeDesc *desc = gimp_stroke_desc_new (gimp, context);
g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
drawable, context, desc, TRUE);
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
drawable, context, desc, TRUE);
g_object_unref (desc);
g_object_unref (desc);
}
}
return procedural_db_return_args (&edit_stroke_proc, success);
......
......@@ -47,11 +47,16 @@ sub sample_merged_arg () {{
# Common invoker for checking for image/drawable consistency
sub invoke {
%invoke = (
vars => [ 'GimpImage *gimage' ],
code => <<CODE
{
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
@{[shift]};
success = gimp_item_is_attached (GIMP_ITEM (drawable));
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
@{[shift]};
}
}
CODE
);
......@@ -234,15 +239,12 @@ HELP
"core/gimpchannel.h") ],
code => <<'CODE'
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
success = gimp_item_is_attached (GIMP_ITEM (drawable));
if (! gimage)
{
success = FALSE;
}
else
if (success)
{
gboolean do_seed_fill;
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
gboolean do_seed_fill;
do_seed_fill = gimp_channel_is_empty (gimp_image_get_mask (gimage));
......@@ -313,11 +315,9 @@ HELP
headers => [ qw("core/gimpdrawable-blend.h") ],
code => <<'CODE'
{
if (! gimp_item_get_image (GIMP_ITEM (drawable)))
{
success = FALSE;
}
else
success = gimp_item_is_attached (GIMP_ITEM (drawable));
if (success)
{
if (progress)
gimp_progress_start (progress, _("Blending..."), FALSE);
......@@ -358,15 +358,20 @@ HELP
headers => [ qw("core/gimpstrokedesc.h") ],
code => <<'CODE'
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpStrokeDesc *desc = gimp_stroke_desc_new (gimp, context);
success = gimp_item_is_attached (GIMP_ITEM (drawable));
g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpStrokeDesc *desc = gimp_stroke_desc_new (gimp, context);
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
drawable, context, desc, TRUE);
g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
g_object_unref (desc);
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
drawable, context, desc, TRUE);
g_object_unref (desc);
}
}
CODE
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment