pdb: add support for omitting the "gimp-" prefix from the procedure name

if the procedure's group is "plug_in_compat". Add new procedure
plug-in-pixelize2.
This commit is contained in:
Michael Natterer 2012-03-31 21:57:47 +02:00
parent 66fa85ad27
commit 70fc975e45
4 changed files with 156 additions and 6 deletions

View File

@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 664 procedures registered total */
/* 665 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)

View File

@ -78,6 +78,49 @@ plug_in_pixelize_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GValueArray *
plug_in_pixelize2_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gint32 pixel_width;
gint32 pixel_height;
drawable = gimp_value_get_drawable (&args->values[2], gimp);
pixel_width = g_value_get_int (&args->values[3]);
pixel_height = g_value_get_int (&args->values[4]);
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gegl:pixelise",
"size-x", pixel_width,
"size-y", pixel_height,
NULL);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Pixelize"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_plug_in_compat_procs (GimpPDB *pdb)
{
@ -88,9 +131,9 @@ register_plug_in_compat_procs (GimpPDB *pdb)
*/
procedure = gimp_procedure_new (plug_in_pixelize_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-plug-in-pixelize");
"plug-in-pixelize");
gimp_procedure_set_static_strings (procedure,
"gimp-plug-in-pixelize",
"plug-in-pixelize",
"Simplify image into an array of solid-colored squares",
"Pixelize the contents of the specified drawable with specified pixelizing width.",
"Spencer Kimball & Peter Mattis",
@ -124,4 +167,52 @@ register_plug_in_compat_procs (GimpPDB *pdb)
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-pixelize2
*/
procedure = gimp_procedure_new (plug_in_pixelize2_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-pixelize2");
gimp_procedure_set_static_strings (procedure,
"plug-in-pixelize2",
"Simplify image into an array of solid-colored rectangles",
"Pixelize the contents of the specified drawable with specified pixelizing width and height.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1997",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("run-mode",
"run mode",
"The run mode",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"Input image (unused)",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"Input drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("pixel-width",
"pixel width",
"Pixel width (the decrease in horizontal resolution)",
1, GIMP_MAX_IMAGE_SIZE, 1,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("pixel-height",
"pixel height",
"Pixel height (the decrease in vertical resolution)",
1, GIMP_MAX_IMAGE_SIZE, 1,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

View File

@ -574,10 +574,18 @@ sub generate {
my $help = $proc->{help};
my $procedure_name;
local $success = 0;
$help =~ s/gimp(\w+)\(\s*\)/"'gimp".canonicalize($1)."'"/ge;
if ($proc->{group} eq "plug_in_compat") {
$procedure_name = "$proc->{canonical_name}";
} else {
$procedure_name = "gimp-$proc->{canonical_name}";
}
$out->{pcount}++; $total++;
$out->{register} .= <<CODE;
@ -587,9 +595,9 @@ sub generate {
*/
procedure = gimp_procedure_new (${name}_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-$proc->{canonical_name}");
"$procedure_name");
gimp_procedure_set_static_strings (procedure,
"gimp-$proc->{canonical_name}",
"$procedure_name",
@{[ &quotewrap($proc->{blurb}, 2) ]},
@{[ &quotewrap($help, 2) ]},
"$proc->{author}",

View File

@ -64,6 +64,56 @@ CODE
);
}
sub plug_in_pixelize2 {
$blurb = 'Simplify image into an array of solid-colored rectangles';
$help = <<'HELP';
Pixelize the contents of the specified drawable with specified
pixelizing width and height.
HELP
&std_pdb_misc;
$date = '1997';
@inargs = (
{ name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
desc => 'The run mode' },
{ name => 'image', type => 'image', dead => 1,
desc => 'Input image (unused)' },
{ name => 'drawable', type => 'drawable',
desc => 'Input drawable' },
{ name => 'pixel_width', type => '1 <= int32 <= GIMP_MAX_IMAGE_SIZE',
desc => 'Pixel width (the decrease in horizontal resolution)' },
{ name => 'pixel_height', type => '1 <= int32 <= GIMP_MAX_IMAGE_SIZE',
desc => 'Pixel height (the decrease in vertical resolution)' }
);
%invoke = (
code => <<'CODE'
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gegl:pixelise",
"size-x", pixel_width,
"size-y", pixel_height,
NULL);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Pixelize"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
CODE
);
}
@headers = qw("libgimpbase/gimpbase.h"
"core/gimpdrawable.h"
@ -71,7 +121,8 @@ CODE
"gimppdb-utils.h"
"gimp-intl.h");
@procs = qw(plug_in_pixelize);
@procs = qw(plug_in_pixelize
plug_in_pixelize2);
%exports = (app => [@procs], lib => []);