added new procedure 'gimp-layer-new-from-visible'.

2008-08-07  Sven Neumann  <sven@gimp.org>

	* tools/pdbgen/pdb/layer.pdb: added new procedure
	'gimp-layer-new-from-visible'.

	* app/pdb/layer-cmds.c
	* app/pdb/internal-procs.c
	* libgimp/gimplayer_pdb.[ch]: regenerated.

	* libgimp/gimp.def: updated.


svn path=/trunk/; revision=26422
This commit is contained in:
Sven Neumann 2008-08-07 16:09:39 +00:00 committed by Sven Neumann
parent 1c7a427e61
commit a29da323b6
7 changed files with 233 additions and 51 deletions

View File

@ -1,3 +1,14 @@
2008-08-07 Sven Neumann <sven@gimp.org>
* tools/pdbgen/pdb/layer.pdb: added new procedure
'gimp-layer-new-from-visible'.
* app/pdb/layer-cmds.c
* app/pdb/internal-procs.c
* libgimp/gimplayer_pdb.[ch]: regenerated.
* libgimp/gimp.def: updated.
2008-08-07 Sven Neumann <sven@gimp.org> 2008-08-07 Sven Neumann <sven@gimp.org>
* app/actions/layers-actions.c * app/actions/layers-actions.c

View File

@ -29,7 +29,7 @@
#include "internal-procs.h" #include "internal-procs.h"
/* 588 procedures registered total */ /* 589 procedures registered total */
void void
internal_procs_init (GimpPDB *pdb) internal_procs_init (GimpPDB *pdb)

View File

@ -35,6 +35,7 @@
#include "core/gimplayer.h" #include "core/gimplayer.h"
#include "core/gimplayermask.h" #include "core/gimplayermask.h"
#include "core/gimpparamspecs.h" #include "core/gimpparamspecs.h"
#include "core/gimpprojection.h"
#include "gimppdb.h" #include "gimppdb.h"
#include "gimppdb-utils.h" #include "gimppdb-utils.h"
@ -88,6 +89,44 @@ layer_new_invoker (GimpProcedure *procedure,
return return_vals; return return_vals;
} }
static GValueArray *
layer_new_from_visible_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpImage *image;
GimpImage *dest_image;
const gchar *name;
GimpLayer *layer = NULL;
image = gimp_value_get_image (&args->values[0], gimp);
dest_image = gimp_value_get_image (&args->values[1], gimp);
name = g_value_get_string (&args->values[2]);
if (success)
{
GimpProjection *projection = gimp_image_get_projection (image);
layer = gimp_layer_new_from_tiles (gimp_projection_get_tiles (projection),
dest_image,
gimp_projection_get_image_type (projection),
name,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
gimp_value_set_layer (&return_vals->values[1], layer);
return return_vals;
}
static GValueArray * static GValueArray *
layer_new_from_drawable_invoker (GimpProcedure *procedure, layer_new_from_drawable_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
@ -957,6 +996,48 @@ register_layer_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
/*
* gimp-layer-new-from-visible
*/
procedure = gimp_procedure_new (layer_new_from_visible_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-layer-new-from-visible");
gimp_procedure_set_static_strings (procedure,
"gimp-layer-new-from-visible",
"Create a new layer from what is visible in an image.",
"This procedure creates a new layer from what is visible in the given image. The new layer still needs to be added to the destination image, as this is not automatic. Add the new layer with the 'gimp-image-add-layer' command. Other attributes such as layer mask modes, and offsets should be set with explicit procedure calls.",
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2008",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The source image from where the content is copied",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("dest-image",
"dest image",
"The destination image to which to add the layer",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("name",
"name",
"The layer name",
FALSE, TRUE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_layer_id ("layer",
"layer",
"The newly created layer",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/* /*
* gimp-layer-new-from-drawable * gimp-layer-new-from-drawable
*/ */

View File

@ -423,6 +423,7 @@ EXPORTS
gimp_layer_mode_effects_get_type gimp_layer_mode_effects_get_type
gimp_layer_new gimp_layer_new
gimp_layer_new_from_drawable gimp_layer_new_from_drawable
gimp_layer_new_from_visible
gimp_layer_remove_mask gimp_layer_remove_mask
gimp_layer_resize gimp_layer_resize
gimp_layer_resize_to_image_size gimp_layer_resize_to_image_size

View File

@ -78,6 +78,48 @@ _gimp_layer_new (gint32 image_ID,
return layer_ID; return layer_ID;
} }
/**
* gimp_layer_new_from_visible:
* @image_ID: The source image from where the content is copied.
* @dest_image_ID: The destination image to which to add the layer.
* @name: The layer name.
*
* Create a new layer from what is visible in an image.
*
* This procedure creates a new layer from what is visible in the given
* image. The new layer still needs to be added to the destination
* image, as this is not automatic. Add the new layer with the
* gimp_image_add_layer() command. Other attributes such as layer mask
* modes, and offsets should be set with explicit procedure calls.
*
* Returns: The newly created layer.
*
* Since: GIMP 2.6
*/
gint32
gimp_layer_new_from_visible (gint32 image_ID,
gint32 dest_image_ID,
const gchar *name)
{
GimpParam *return_vals;
gint nreturn_vals;
gint32 layer_ID = -1;
return_vals = gimp_run_procedure ("gimp-layer-new-from-visible",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_IMAGE, dest_image_ID,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
layer_ID = return_vals[1].data.d_layer;
gimp_destroy_params (return_vals, nreturn_vals);
return layer_ID;
}
/** /**
* gimp_layer_new_from_drawable: * gimp_layer_new_from_drawable:
* @drawable_ID: The source drawable from where the new layer is copied. * @drawable_ID: The source drawable from where the new layer is copied.

View File

@ -36,6 +36,9 @@ G_GNUC_INTERNAL gint32 _gimp_layer_new (gint32 im
const gchar *name, const gchar *name,
gdouble opacity, gdouble opacity,
GimpLayerModeEffects mode); GimpLayerModeEffects mode);
gint32 gimp_layer_new_from_visible (gint32 image_ID,
gint32 dest_image_ID,
const gchar *name);
gint32 gimp_layer_new_from_drawable (gint32 drawable_ID, gint32 gimp_layer_new_from_drawable (gint32 drawable_ID,
gint32 dest_image_ID); gint32 dest_image_ID);
G_GNUC_INTERNAL gint32 _gimp_layer_copy (gint32 layer_ID, G_GNUC_INTERNAL gint32 _gimp_layer_copy (gint32 layer_ID,

View File

@ -65,6 +65,97 @@ CODE
); );
} }
sub layer_new_from_visible {
$blurb = 'Create a new layer from what is visible in an image.';
$help = <<'HELP';
This procedure creates a new layer from what is visible in the given image.
The new layer still needs to be added to the destination image, as this is
not automatic. Add the new layer with the gimp_image_add_layer() command.
Other attributes such as layer mask modes, and offsets should be set with
explicit procedure calls.
HELP
&neo_pdb_misc('2008', '2.6');
@inargs = (
{ name => 'image', type => 'image',
desc => 'The source image from where the content is copied' },
{ name => 'dest_image', type => 'image',
desc => 'The destination image to which to add the layer' },
{ name => 'name', type => 'string',
desc => 'The layer name', null_ok => 1 }
);
@outargs = (
{ name => 'layer', type => 'layer',
desc => 'The newly created layer' }
);
%invoke = (
code => <<'CODE'
{
GimpProjection *projection = gimp_image_get_projection (image);
layer = gimp_layer_new_from_tiles (gimp_projection_get_tiles (projection),
dest_image,
gimp_projection_get_image_type (projection),
name,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
}
CODE
);
}
sub layer_new_from_drawable {
$blurb = 'Create a new layer by copying an existing drawable.';
$help = <<'HELP';
This procedure creates a new layer as a copy of the specified drawable. The
new layer still needs to be added to the image, as this is not automatic. Add
the new layer with the gimp_image_add_layer() command. Other attributes such
as layer mask modes, and offsets should be set with explicit procedure calls.
HELP
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The source drawable from where the new layer is copied' },
{ name => 'dest_image', type => 'image',
desc => 'The destination image to which to add the layer' }
);
@outargs = (
{ name => 'layer_copy', type => 'layer',
desc => 'The newly copied layer' }
);
%invoke = (
code => <<'CODE'
{
GType new_type;
GimpItem *new_item;
if (GIMP_IS_LAYER (drawable))
new_type = G_TYPE_FROM_INSTANCE (drawable);
else
new_type = GIMP_TYPE_LAYER;
if (dest_image == gimp_item_get_image (GIMP_ITEM (drawable)))
new_item = gimp_item_duplicate (GIMP_ITEM (drawable), new_type);
else
new_item = gimp_item_convert (GIMP_ITEM (drawable), dest_image, new_type);
if (new_item)
layer_copy = GIMP_LAYER (new_item);
else
success = FALSE;
}
CODE
);
}
sub layer_copy { sub layer_copy {
$blurb = 'Copy a layer.'; $blurb = 'Copy a layer.';
@ -124,7 +215,7 @@ layer mask still needs to be added to the layer. This can be done with a call
to gimp_layer_add_mask(). to gimp_layer_add_mask().
HELP HELP
&std_pdb_misc; &std_pdb_misc();
@inargs = ( @inargs = (
{ name => 'layer', type => 'layer', { name => 'layer', type => 'layer',
@ -558,55 +649,6 @@ CODE
); );
} }
sub layer_new_from_drawable {
$blurb = 'Create a new layer by copying an existing drawable.';
$help = <<'HELP';
This procedure creates a new layer as a copy of the specified drawable. The
new layer still needs to be added to the image, as this is not automatic. Add
the new layer with the gimp_image_add_layer() command. Other attributes such
as layer mask modes, and offsets should be set with explicit procedure calls.
HELP
&std_pdb_misc;
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The source drawable from where the new layer is copied' },
{ name => 'dest_image', type => 'image',
desc => 'The destination image to which to add the layer' }
);
@outargs = (
{ name => 'layer_copy', type => 'layer',
desc => 'The newly copied layer' }
);
%invoke = (
code => <<'CODE'
{
GType new_type;
GimpItem *new_item;
if (GIMP_IS_LAYER (drawable))
new_type = G_TYPE_FROM_INSTANCE (drawable);
else
new_type = GIMP_TYPE_LAYER;
if (dest_image == gimp_item_get_image (GIMP_ITEM (drawable)))
new_item = gimp_item_duplicate (GIMP_ITEM (drawable), new_type);
else
new_item = gimp_item_convert (GIMP_ITEM (drawable), dest_image, new_type);
if (new_item)
layer_copy = GIMP_LAYER (new_item);
else
success = FALSE;
}
CODE
);
}
sub layer_get_lock_alpha { sub layer_get_lock_alpha {
$blurb = 'Get the lock alpha channel setting of the specified layer.'; $blurb = 'Get the lock alpha channel setting of the specified layer.';
@ -953,10 +995,12 @@ CODE
"core/gimp.h" "core/gimp.h"
"core/gimpimage-undo.h" "core/gimpimage-undo.h"
"core/gimpitem-linked.h" "core/gimpitem-linked.h"
"core/gimpprojection.h"
"gimppdb-utils.h" "gimppdb-utils.h"
"gimp-intl.h"); "gimp-intl.h");
@procs = qw(layer_new @procs = qw(layer_new
layer_new_from_visible
layer_new_from_drawable layer_new_from_drawable
layer_copy layer_copy
layer_add_alpha layer_add_alpha