improved error handling.

2008-04-04  Sven Neumann  <sven@gimp.org>

	* tools/pdbgen/pdb/image.pdb: improved error handling.

	* app/pdb/image_cmds.c: regenerated.


svn path=/trunk/; revision=25355
This commit is contained in:
Sven Neumann 2008-04-04 07:11:13 +00:00 committed by Sven Neumann
parent 54e8c482d1
commit 472fa72b12
4 changed files with 71 additions and 43 deletions

View file

@ -1,3 +1,9 @@
2008-04-04 Sven Neumann <sven@gimp.org>
* tools/pdbgen/pdb/image.pdb: improved error handling.
* app/pdb/image_cmds.c: regenerated.
2008-04-04 Sven Neumann <sven@gimp.org>
* app/pdb/gimppdb-utils.[ch]: added utility functions to check the

View file

@ -364,8 +364,8 @@ gimp_pdb_image_is_base_type (GimpImage *image,
return TRUE;
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_INVALID_ARGUMENT,
_("Image '%s' (%d) is of type %s, "
"but an image of type %s is expected"),
_("Image '%s' (%d) is of type '%s', "
"but an image of type '%s' is expected"),
gimp_object_get_name (GIMP_OBJECT (image)),
gimp_image_get_ID (image),
gimp_pdb_enum_value_get_nick (GIMP_TYPE_IMAGE_BASE_TYPE,
@ -387,7 +387,7 @@ gimp_pdb_image_is_not_base_type (GimpImage *image,
return TRUE;
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_INVALID_ARGUMENT,
_("Image '%s' (%d) is already of type %s"),
_("Image '%s' (%d) is already of type '%s'"),
gimp_object_get_name (GIMP_OBJECT (image)),
gimp_image_get_ID (image),
gimp_pdb_enum_value_get_nick (GIMP_TYPE_IMAGE_BASE_TYPE, type));

View file

@ -54,6 +54,7 @@
#include "gimppdb.h"
#include "gimppdberror.h"
#include "gimppdb-utils.h"
#include "gimpprocedure.h"
#include "internal_procs.h"
@ -841,15 +842,25 @@ image_add_layer_invoker (GimpProcedure *procedure,
if (success)
{
if (! g_object_is_floating (layer) ||
GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (layer))) !=
gimp_image_base_type (image))
success = gimp_pdb_image_is_base_type (image,
GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (layer))),
error);
if (success)
{
success = FALSE;
}
else
{
success = gimp_image_add_layer (image, layer, MAX (position, -1));
if (g_object_is_floating (layer))
{
success = gimp_image_add_layer (image, layer, MAX (position, -1));
}
else
{
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_INVALID_ARGUMENT,
_("Layer '%s' (%d) has already been added to an image"),
gimp_object_get_name (GIMP_OBJECT (layer)),
gimp_item_get_ID (GIMP_ITEM (layer)));
success = FALSE;
}
}
}
@ -1847,11 +1858,11 @@ image_get_component_active_invoker (GimpProcedure *procedure,
if (success)
{
if (component == GIMP_GRAY_CHANNEL)
success = gimp_image_base_type (image) == GIMP_GRAY;
success = gimp_pdb_image_is_base_type (image, GIMP_GRAY, error);
else if (component == GIMP_INDEXED_CHANNEL)
success = gimp_image_base_type (image) == GIMP_INDEXED;
success = gimp_pdb_image_is_base_type (image, GIMP_INDEXED, error);
else
success = gimp_image_base_type (image) == GIMP_RGB;
success = gimp_pdb_image_is_base_type (image, GIMP_RGB, error);
if (success)
active = gimp_image_get_component_active (image, component);
@ -1885,11 +1896,11 @@ image_set_component_active_invoker (GimpProcedure *procedure,
if (success)
{
if (component == GIMP_GRAY_CHANNEL)
success = gimp_image_base_type (image) == GIMP_GRAY;
success = gimp_pdb_image_is_base_type (image, GIMP_GRAY, error);
else if (component == GIMP_INDEXED_CHANNEL)
success = gimp_image_base_type (image) == GIMP_INDEXED;
success = gimp_pdb_image_is_base_type (image, GIMP_INDEXED, error);
else
success = gimp_image_base_type (image) == GIMP_RGB;
success = gimp_pdb_image_is_base_type (image, GIMP_RGB, error);
if (success)
gimp_image_set_component_active (image, component, active);
@ -1918,11 +1929,11 @@ image_get_component_visible_invoker (GimpProcedure *procedure,
if (success)
{
if (component == GIMP_GRAY_CHANNEL)
success = gimp_image_base_type (image) == GIMP_GRAY;
success = gimp_pdb_image_is_base_type (image, GIMP_GRAY, error);
else if (component == GIMP_INDEXED_CHANNEL)
success = gimp_image_base_type (image) == GIMP_INDEXED;
success = gimp_pdb_image_is_base_type (image, GIMP_INDEXED, error);
else
success = gimp_image_base_type (image) == GIMP_RGB;
success = gimp_pdb_image_is_base_type (image, GIMP_RGB, error);
if (success)
visible = gimp_image_get_component_visible (image, component);
@ -1956,11 +1967,11 @@ image_set_component_visible_invoker (GimpProcedure *procedure,
if (success)
{
if (component == GIMP_GRAY_CHANNEL)
success = gimp_image_base_type (image) == GIMP_GRAY;
success = gimp_pdb_image_is_base_type (image, GIMP_GRAY, error);
else if (component == GIMP_INDEXED_CHANNEL)
success = gimp_image_base_type (image) == GIMP_INDEXED;
success = gimp_pdb_image_is_base_type (image, GIMP_INDEXED, error);
else
success = gimp_image_base_type (image) == GIMP_RGB;
success = gimp_pdb_image_is_base_type (image, GIMP_RGB, error);
if (success)
gimp_image_set_component_visible (image, component, visible);

View file

@ -963,15 +963,25 @@ HELP
$invoke{code} = <<'CODE';
{
if (! g_object_is_floating (layer) ||
GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (layer))) !=
gimp_image_base_type (image))
success = gimp_pdb_image_is_base_type (image,
GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (layer))),
error);
if (success)
{
success = FALSE;
}
else
{
success = gimp_image_add_layer (image, layer, MAX (position, -1));
if (g_object_is_floating (layer))
{
success = gimp_image_add_layer (image, layer, MAX (position, -1));
}
else
{
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_INVALID_ARGUMENT,
_("Layer '%s' (%d) has already been added to an image"),
gimp_object_get_name (GIMP_OBJECT (layer)),
gimp_item_get_ID (GIMP_ITEM (layer)));
success = FALSE;
}
}
}
CODE
@ -1936,11 +1946,11 @@ HELP
code => <<'CODE'
{
if (component == GIMP_GRAY_CHANNEL)
success = gimp_image_base_type (image) == GIMP_GRAY;
success = gimp_pdb_image_is_base_type (image, GIMP_GRAY, error);
else if (component == GIMP_INDEXED_CHANNEL)
success = gimp_image_base_type (image) == GIMP_INDEXED;
success = gimp_pdb_image_is_base_type (image, GIMP_INDEXED, error);
else
success = gimp_image_base_type (image) == GIMP_RGB;
success = gimp_pdb_image_is_base_type (image, GIMP_RGB, error);
if (success)
active = gimp_image_get_component_active (image, component);
@ -1974,11 +1984,11 @@ HELP
code => <<'CODE'
{
if (component == GIMP_GRAY_CHANNEL)
success = gimp_image_base_type (image) == GIMP_GRAY;
success = gimp_pdb_image_is_base_type (image, GIMP_GRAY, error);
else if (component == GIMP_INDEXED_CHANNEL)
success = gimp_image_base_type (image) == GIMP_INDEXED;
success = gimp_pdb_image_is_base_type (image, GIMP_INDEXED, error);
else
success = gimp_image_base_type (image) == GIMP_RGB;
success = gimp_pdb_image_is_base_type (image, GIMP_RGB, error);
if (success)
gimp_image_set_component_active (image, component, active);
@ -2015,11 +2025,11 @@ HELP
code => <<'CODE'
{
if (component == GIMP_GRAY_CHANNEL)
success = gimp_image_base_type (image) == GIMP_GRAY;
success = gimp_pdb_image_is_base_type (image, GIMP_GRAY, error);
else if (component == GIMP_INDEXED_CHANNEL)
success = gimp_image_base_type (image) == GIMP_INDEXED;
success = gimp_pdb_image_is_base_type (image, GIMP_INDEXED, error);
else
success = gimp_image_base_type (image) == GIMP_RGB;
success = gimp_pdb_image_is_base_type (image, GIMP_RGB, error);
if (success)
visible = gimp_image_get_component_visible (image, component);
@ -2053,11 +2063,11 @@ HELP
code => <<'CODE'
{
if (component == GIMP_GRAY_CHANNEL)
success = gimp_image_base_type (image) == GIMP_GRAY;
success = gimp_pdb_image_is_base_type (image, GIMP_GRAY, error);
else if (component == GIMP_INDEXED_CHANNEL)
success = gimp_image_base_type (image) == GIMP_INDEXED;
success = gimp_pdb_image_is_base_type (image, GIMP_INDEXED, error);
else
success = gimp_image_base_type (image) == GIMP_RGB;
success = gimp_pdb_image_is_base_type (image, GIMP_RGB, error);
if (success)
gimp_image_set_component_visible (image, component, visible);
@ -2551,6 +2561,7 @@ CODE
"core/gimplist.h"
"core/gimpunit.h"
"gimppdberror.h"
"gimppdb-utils.h"
"gimp-intl.h");
@procs = qw(image_is_valid