Added functions to easily determine the position of a

2006-11-22  Simon Budig  <simon@gimp.org>

	* tools/pdbgen/pdb/image.pdb: Added functions to easily determine
	the position of a layer/channel/vectors object in its respective
	stack.

	* libgimp/gimp.def: added new symbols

	* app/pdb/image_cmds.c
	* app/pdb/internal_procs.c
	* libgimp/gimpimage_pdb.[ch]: regenerated.
This commit is contained in:
Simon Budig 2006-11-22 22:36:24 +00:00 committed by Simon Budig
parent d27db948d7
commit ff68bde625
7 changed files with 439 additions and 2 deletions

View File

@ -1,3 +1,15 @@
2006-11-22 Simon Budig <simon@gimp.org>
* tools/pdbgen/pdb/image.pdb: Added functions to easily determine
the position of a layer/channel/vectors object in its respective
stack.
* libgimp/gimp.def: added new symbols
* app/pdb/image_cmds.c
* app/pdb/internal_procs.c
* libgimp/gimpimage_pdb.[ch]: regenerated.
2006-11-22 Simon Budig <simon@gimp.org>
* app/tools/gimpvectortool.c: Enable scrolling while dragging

View File

@ -831,6 +831,38 @@ image_remove_layer_invoker (GimpProcedure *procedure,
return gimp_procedure_get_return_values (procedure, success);
}
static GValueArray *
image_get_layer_position_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpImage *image;
GimpLayer *layer;
gint32 position = 0;
image = gimp_value_get_image (&args->values[0], gimp);
layer = gimp_value_get_layer (&args->values[1], gimp);
if (success)
{
position = gimp_container_get_child_index (GIMP_CONTAINER (image->layers),
GIMP_OBJECT (layer));
if (position < 0)
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_set_int (&return_vals->values[1], position);
return return_vals;
}
static GValueArray *
image_raise_layer_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -1012,6 +1044,38 @@ image_lower_channel_invoker (GimpProcedure *procedure,
return gimp_procedure_get_return_values (procedure, success);
}
static GValueArray *
image_get_channel_position_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpImage *image;
GimpChannel *channel;
gint32 position = 0;
image = gimp_value_get_image (&args->values[0], gimp);
channel = gimp_value_get_channel (&args->values[1], gimp);
if (success)
{
position = gimp_container_get_child_index (GIMP_CONTAINER (image->channels),
GIMP_OBJECT (channel));
if (position < 0)
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_set_int (&return_vals->values[1], position);
return return_vals;
}
static GValueArray *
image_add_vectors_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -1149,6 +1213,38 @@ image_lower_vectors_to_bottom_invoker (GimpProcedure *procedure,
return gimp_procedure_get_return_values (procedure, success);
}
static GValueArray *
image_get_vectors_position_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpImage *image;
GimpVectors *vectors;
gint32 position = 0;
image = gimp_value_get_image (&args->values[0], gimp);
vectors = gimp_value_get_vectors (&args->values[1], gimp);
if (success)
{
position = gimp_container_get_child_index (GIMP_CONTAINER (image->vectors),
GIMP_OBJECT (vectors));
if (position < 0)
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_set_int (&return_vals->values[1], position);
return return_vals;
}
static GValueArray *
image_flatten_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -2953,6 +3049,40 @@ register_image_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-get-layer-position
*/
procedure = gimp_procedure_new (image_get_layer_position_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-image-get-layer-position");
gimp_procedure_set_static_strings (procedure,
"gimp-image-get-layer-position",
"Returns the position of the layer in the layer stack.",
"This procedure determines the positioin of the specified layer in the images layer stack. If the layer doesn't exist in the image, an error is returned.",
"Simon Budig",
"Simon Budig",
"&image_get_layer_position",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The image",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_layer_id ("layer",
"layer",
"The layer",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32 ("position",
"position",
"The position of the layer in the layer stack",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-raise-layer
*/
@ -3183,6 +3313,40 @@ register_image_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-get-channel-position
*/
procedure = gimp_procedure_new (image_get_channel_position_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-image-get-channel-position");
gimp_procedure_set_static_strings (procedure,
"gimp-image-get-channel-position",
"Returns the position of the channel in the channel stack.",
"This procedure determines the positioin of the specified channel in the images channel stack. If the channel doesn't exist in the image, an error is returned.",
"Simon Budig",
"Simon Budig",
"&image_get_channel_position",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The image",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_channel_id ("channel",
"channel",
"The channel",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32 ("position",
"position",
"The position of the channel in the channel stack",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-add-vectors
*/
@ -3357,6 +3521,40 @@ register_image_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-get-vectors-position
*/
procedure = gimp_procedure_new (image_get_vectors_position_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-image-get-vectors-position");
gimp_procedure_set_static_strings (procedure,
"gimp-image-get-vectors-position",
"Returns the position of the vectors object in the vectors objects stack.",
"This procedure determines the positioin of the specified vectors object in the images vectors object stack. If the vectors object doesn't exist in the image, an error is returned.",
"Simon Budig",
"Simon Budig",
"&image_get_vectors_position",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The image",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_vectors_id ("vectors",
"vectors",
"The vectors object",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32 ("position",
"position",
"The position of the vectors object in the vectors stack",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-flatten
*/

View File

@ -29,7 +29,7 @@
#include "internal_procs.h"
/* 541 procedures registered total */
/* 544 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)

View File

@ -312,6 +312,7 @@ EXPORTS
gimp_image_get_active_layer
gimp_image_get_active_vectors
gimp_image_get_channel_by_tattoo
gimp_image_get_channel_position
gimp_image_get_channels
gimp_image_get_cmap
gimp_image_get_colormap
@ -322,6 +323,7 @@ EXPORTS
gimp_image_get_guide_orientation
gimp_image_get_guide_position
gimp_image_get_layer_by_tattoo
gimp_image_get_layer_position
gimp_image_get_layers
gimp_image_get_name
gimp_image_get_resolution
@ -330,6 +332,7 @@ EXPORTS
gimp_image_get_thumbnail_data
gimp_image_get_unit
gimp_image_get_vectors
gimp_image_get_vectors_position
gimp_image_grid_get_background_color
gimp_image_grid_get_foreground_color
gimp_image_grid_get_offset
@ -635,11 +638,14 @@ EXPORTS
gimp_vectors_set_tattoo
gimp_vectors_set_visible
gimp_vectors_stroke_close
gimp_vectors_stroke_flip
gimp_vectors_stroke_flip_free
gimp_vectors_stroke_get_length
gimp_vectors_stroke_get_point_at_dist
gimp_vectors_stroke_get_points
gimp_vectors_stroke_interpolate
gimp_vectors_stroke_new_from_points
gimp_vectors_stroke_rotate
gimp_vectors_stroke_scale
gimp_vectors_stroke_translate
gimp_vectors_to_selection

View File

@ -961,6 +961,41 @@ gimp_image_remove_layer (gint32 image_ID,
return success;
}
/**
* gimp_image_get_layer_position:
* @image_ID: The image.
* @layer_ID: The layer.
*
* Returns the position of the layer in the layer stack.
*
* This procedure determines the positioin of the specified layer in
* the images layer stack. If the layer doesn't exist in the image, an
* error is returned.
*
* Returns: The position of the layer in the layer stack.
*/
gint
gimp_image_get_layer_position (gint32 image_ID,
gint32 layer_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gint position = 0;
return_vals = gimp_run_procedure ("gimp-image-get-layer-position",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_LAYER, layer_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
position = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return position;
}
/**
* gimp_image_raise_layer:
* @image_ID: The image.
@ -1236,6 +1271,41 @@ gimp_image_lower_channel (gint32 image_ID,
return success;
}
/**
* gimp_image_get_channel_position:
* @image_ID: The image.
* @channel_ID: The channel.
*
* Returns the position of the channel in the channel stack.
*
* This procedure determines the positioin of the specified channel in
* the images channel stack. If the channel doesn't exist in the image,
* an error is returned.
*
* Returns: The position of the channel in the channel stack.
*/
gint
gimp_image_get_channel_position (gint32 image_ID,
gint32 channel_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gint position = 0;
return_vals = gimp_run_procedure ("gimp-image-get-channel-position",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_CHANNEL, channel_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
position = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return position;
}
/**
* gimp_image_add_vectors:
* @image_ID: The image.
@ -1454,6 +1524,42 @@ gimp_image_lower_vectors_to_bottom (gint32 image_ID,
return success;
}
/**
* gimp_image_get_vectors_position:
* @image_ID: The image.
* @vectors_ID: The vectors object.
*
* Returns the position of the vectors object in the vectors objects
* stack.
*
* This procedure determines the positioin of the specified vectors
* object in the images vectors object stack. If the vectors object
* doesn't exist in the image, an error is returned.
*
* Returns: The position of the vectors object in the vectors stack.
*/
gint
gimp_image_get_vectors_position (gint32 image_ID,
gint32 vectors_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gint position = 0;
return_vals = gimp_run_procedure ("gimp-image-get-vectors-position",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_VECTORS, vectors_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
position = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return position;
}
/**
* gimp_image_flatten:
* @image_ID: The image.

View File

@ -83,6 +83,8 @@ gboolean gimp_image_add_layer (gint32
gint position);
gboolean gimp_image_remove_layer (gint32 image_ID,
gint32 layer_ID);
gint gimp_image_get_layer_position (gint32 image_ID,
gint32 layer_ID);
gboolean gimp_image_raise_layer (gint32 image_ID,
gint32 layer_ID);
gboolean gimp_image_lower_layer (gint32 image_ID,
@ -100,6 +102,8 @@ gboolean gimp_image_raise_channel (gint32
gint32 channel_ID);
gboolean gimp_image_lower_channel (gint32 image_ID,
gint32 channel_ID);
gint gimp_image_get_channel_position (gint32 image_ID,
gint32 channel_ID);
gboolean gimp_image_add_vectors (gint32 image_ID,
gint32 vectors_ID,
gint position);
@ -113,6 +117,8 @@ gboolean gimp_image_raise_vectors_to_top (gint32
gint32 vectors_ID);
gboolean gimp_image_lower_vectors_to_bottom (gint32 image_ID,
gint32 vectors_ID);
gint gimp_image_get_vectors_position (gint32 image_ID,
gint32 vectors_ID);
gint32 gimp_image_flatten (gint32 image_ID);
gint32 gimp_image_merge_visible_layers (gint32 image_ID,
GimpMergeType merge_type);

View File

@ -941,6 +941,41 @@ CODE
);
}
sub image_get_layer_position {
$blurb = 'Returns the position of the layer in the layer stack.';
$help = <<'HELP';
This procedure determines the positioin of the specified layer in the images
layer stack. If the layer doesn't exist in the image, an error is returned.
HELP
&simon_pdb_misc;
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
{ name => 'layer', type => 'layer',
desc => 'The layer' }
);
@outargs = (
{ name => 'position', type => 'int32',
desc => "The position of the layer in the layer stack" }
);
%invoke = (
code => <<'CODE'
{
position = gimp_container_get_child_index (GIMP_CONTAINER (image->layers),
GIMP_OBJECT (layer));
if (position < 0)
success = FALSE;
}
CODE
);
}
sub image_add_layer_mask {
&std_pdb_deprecated ('gimp-layer-add-mask');
@ -1096,6 +1131,41 @@ CODE
);
}
sub image_get_channel_position {
$blurb = 'Returns the position of the channel in the channel stack.';
$help = <<'HELP';
This procedure determines the positioin of the specified channel in the images
channel stack. If the channel doesn't exist in the image, an error is returned.
HELP
&simon_pdb_misc;
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
{ name => 'channel', type => 'channel',
desc => 'The channel' }
);
@outargs = (
{ name => 'position', type => 'int32',
desc => "The position of the channel in the channel stack" }
);
%invoke = (
code => <<'CODE'
{
position = gimp_container_get_child_index (GIMP_CONTAINER (image->channels),
GIMP_OBJECT (channel));
if (position < 0)
success = FALSE;
}
CODE
);
}
sub image_add_vectors {
$blurb = 'Add the specified vectors object to the image.';
@ -1264,6 +1334,42 @@ CODE
);
}
sub image_get_vectors_position {
$blurb = 'Returns the position of the vectors object in the vectors objects stack.';
$help = <<'HELP';
This procedure determines the positioin of the specified vectors object in the
images vectors object stack. If the vectors object doesn't exist in the image,
an error is returned.
HELP
&simon_pdb_misc;
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
{ name => 'vectors', type => 'vectors',
desc => 'The vectors object' }
);
@outargs = (
{ name => 'position', type => 'int32',
desc => "The position of the vectors object in the vectors stack" }
);
%invoke = (
code => <<'CODE'
{
position = gimp_container_get_child_index (GIMP_CONTAINER (image->vectors),
GIMP_OBJECT (vectors));
if (position < 0)
success = FALSE;
}
CODE
);
}
sub image_get_active_drawable {
$blurb = "Get the image's active drawable";
@ -2434,13 +2540,16 @@ CODE
image_get_floating_sel image_floating_sel_attached_to
image_pick_color image_pick_correlate_layer
image_add_layer image_remove_layer
image_get_layer_position
image_raise_layer image_lower_layer
image_raise_layer_to_top image_lower_layer_to_bottom
image_add_channel image_remove_channel
image_raise_channel image_lower_channel
image_get_channel_position
image_add_vectors image_remove_vectors
image_raise_vectors image_lower_vectors
image_raise_vectors_to_top image_lower_vectors_to_bottom
image_get_vectors_position
image_flatten image_merge_visible_layers image_merge_down
image_add_layer_mask image_remove_layer_mask
image_get_colormap image_set_colormap
@ -2461,7 +2570,7 @@ CODE
image_get_channel_by_tattoo
image_get_vectors_by_tattoo);
%exports = (app => [@procs], lib => [@procs[0..41,44..70]]);
%exports = (app => [@procs], lib => [@procs[0..44,47..73]]);
$desc = 'Image';