mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-22 04:22:29 +00:00
a456ac9bde
2004-07-16 Michael Natterer <mitch@gimp.org> * tools/pdbgen/pdb.pl: include "libgimpbase/gimpbase.h" instead of "libgimpbase/gimpparasite.h" for getting the GimpParasite type. * tools/pdbgen/app.pl * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/image.pdb: removed redundant #includes. * tools/pdbgen/pdb/plug_in.pdb: standardized "success" logic. Consistetly fail if there is no currently queried plugin. * app/pdb/*.c: regenerated.
281 lines
6.3 KiB
Plaintext
281 lines
6.3 KiB
Plaintext
# The GIMP -- an image manipulation program
|
|
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
|
|
|
|
sub pdb_misc {
|
|
$author = $copyright = 'Adam D. Moss';
|
|
$date = '1998';
|
|
}
|
|
|
|
sub image_add_guide {
|
|
my ($desc, $type, $max, $pos) = @_;
|
|
|
|
$blurb = "Add a $desc guide to an image.";
|
|
|
|
$help = <<HELP;
|
|
This procedure adds a $desc guide to an image. It takes the input image and the
|
|
$type-position of the new guide as parameters. It returns the guide ID of the
|
|
new guide.
|
|
HELP
|
|
|
|
&pdb_misc;
|
|
|
|
@inargs = (
|
|
&std_image_arg,
|
|
{ name => "${type}position", type => '0 <= int32',
|
|
desc => "The guide's ${type}-offset from $pos of image",
|
|
alias => 'offset' }
|
|
);
|
|
|
|
@outargs = (
|
|
{ name => 'guide', type => 'guide', init => 1, alias => 'guide_ID',
|
|
desc => 'The new guide' }
|
|
);
|
|
|
|
my $func = substr($desc, 0, 1);
|
|
%invoke = (
|
|
vars => [ 'GimpGuide *guide' ],
|
|
code => <<CODE
|
|
{
|
|
if (offset <= gimage->$max)
|
|
{
|
|
guide = gimp_image_add_${func}guide (gimage, offset, TRUE);
|
|
guide_ID = guide->guide_ID;
|
|
}
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
# The defs
|
|
|
|
sub image_add_hguide {
|
|
&image_add_guide('horizontal', 'y', 'height', 'top');
|
|
}
|
|
|
|
sub image_add_vguide {
|
|
&image_add_guide('vertical', 'x', 'width', 'left');
|
|
}
|
|
|
|
sub image_delete_guide {
|
|
$blurb = 'Deletes a guide from an image.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure takes an image and a guide ID as input and removes the specified
|
|
guide from the specified image.
|
|
HELP
|
|
|
|
&pdb_misc;
|
|
|
|
@inargs = (
|
|
&std_image_arg,
|
|
{ name => 'guide', type => 'guide',
|
|
desc => 'The ID of the guide to be removed' }
|
|
);
|
|
|
|
%invoke = (
|
|
vars => [ 'GList *guides' ],
|
|
code => <<'CODE'
|
|
{
|
|
success = FALSE;
|
|
|
|
for (guides = gimage->guides; guides; guides = g_list_next (guides))
|
|
{
|
|
GimpGuide *g = (GimpGuide *) guides->data;
|
|
|
|
if ((g->guide_ID == guide) && (g->position >= 0))
|
|
{
|
|
gimp_image_remove_guide (gimage, g, TRUE);
|
|
success = TRUE;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub image_find_next_guide {
|
|
$blurb = 'Find next guide on an image.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure takes an image and a guide ID as input and finds the guide ID of
|
|
the successor of the given guide ID in the image's guide list. If the supplied
|
|
guide ID is 0, the procedure will return the first Guide. The procedure will
|
|
return 0 if given the final guide ID as an argument or the image has no guides.
|
|
HELP
|
|
|
|
&pdb_misc;
|
|
|
|
@inargs = (
|
|
&std_image_arg,
|
|
{ name => 'guide', type => 'guide',
|
|
desc => 'The ID of the current guide (0 if first invocation)' }
|
|
);
|
|
|
|
@outargs = (
|
|
{ name => 'next_guide', type => 'guide', init => 1,
|
|
desc => "The next guide's ID" }
|
|
);
|
|
|
|
%invoke = (
|
|
vars => [ 'GList *guides', 'gboolean guide_found' ],
|
|
code => <<'CODE'
|
|
{
|
|
if (gimage->guides != NULL)
|
|
{
|
|
success = FALSE;
|
|
guide_found = FALSE;
|
|
|
|
for (guides = gimage->guides; guides; guides = g_list_next (guides))
|
|
{
|
|
GimpGuide *g = (GimpGuide *) guides->data;
|
|
|
|
if (g->position < 0)
|
|
continue;
|
|
|
|
if (guide == 0) /* init - Return first guide ID in list */
|
|
{
|
|
next_guide = g->guide_ID;
|
|
|
|
guide_found = TRUE;
|
|
break;
|
|
}
|
|
|
|
if (! guide_found)
|
|
{
|
|
if (g->guide_ID == guide)
|
|
guide_found = TRUE;
|
|
}
|
|
else
|
|
{
|
|
next_guide = g->guide_ID;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (guide_found)
|
|
success = TRUE;
|
|
}
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub image_get_guide_orientation {
|
|
$blurb = 'Get orientation of a guide on an image.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure takes an image and a guide ID as input and returns the
|
|
orientations of the guide.
|
|
HELP
|
|
|
|
&pdb_misc;
|
|
|
|
@inargs = (
|
|
&std_image_arg,
|
|
{ name => 'guide', type => 'guide',
|
|
desc => 'The guide' }
|
|
);
|
|
|
|
@outargs = (
|
|
{ name => 'orientation', type => &std_orientation_enum, init => 1,
|
|
desc => "The guide's orientation: { %%desc%% }",
|
|
libdef => 'GIMP_ORIENTATION_UNKNOWN' }
|
|
);
|
|
|
|
%invoke = (
|
|
vars => [ 'GList *guides' ],
|
|
code => <<'CODE'
|
|
{
|
|
success = FALSE;
|
|
|
|
for (guides = gimage->guides; guides; guides = g_list_next (guides))
|
|
{
|
|
GimpGuide *g = (GimpGuide *) guides->data;
|
|
|
|
if ((g->guide_ID == guide) && (g->position >= 0))
|
|
{
|
|
orientation = g->orientation;
|
|
|
|
success = TRUE;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub image_get_guide_position {
|
|
$blurb = 'Get position of a guide on an image.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure takes an image and a guide ID as input and returns the position
|
|
of the guide relative to the top or left of the image.
|
|
HELP
|
|
|
|
&pdb_misc;
|
|
|
|
@inargs = (
|
|
&std_image_arg,
|
|
{ name => 'guide', type => 'guide',
|
|
desc => 'The guide' }
|
|
);
|
|
|
|
@outargs = (
|
|
{ name => 'position', type => 'int32', init => 1, libdef => '-1',
|
|
desc => "The guide's position relative to top or left of image" }
|
|
);
|
|
|
|
%invoke = (
|
|
vars => [ 'GList *guides' ],
|
|
code => <<'CODE'
|
|
{
|
|
success = FALSE;
|
|
|
|
for (guides = gimage->guides; guides; guides = g_list_next (guides))
|
|
{
|
|
GimpGuide *g = (GimpGuide *) guides->data;
|
|
|
|
if ((g->guide_ID == guide) && (g->position >= 0))
|
|
{
|
|
position = g->position;
|
|
|
|
success = TRUE;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
@headers = qw("core/gimpimage-guides.h" "core/gimpimage-undo-push.h");
|
|
|
|
@procs = qw(image_add_hguide image_add_vguide image_delete_guide
|
|
image_find_next_guide image_get_guide_orientation
|
|
image_get_guide_position);
|
|
%exports = (app => [@procs], lib => [@procs]);
|
|
|
|
$desc = 'Guide procedures';
|
|
|
|
1;
|