[gimp/goat-invasion: 362/608] pdb: add support for omitting the "gimp-" prefix from the procedure name
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 362/608] pdb: add support for omitting the "gimp-" prefix from the procedure name
- Date: Fri, 27 Apr 2012 20:55:49 +0000 (UTC)
commit 01a31ce9f39489d8badf6560f4737e21b8f6a1fb
Author: Michael Natterer <mitch gimp org>
Date: Sat Mar 31 21:57:47 2012 +0200
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.
app/pdb/internal-procs.c | 2 +-
app/pdb/plug-in-compat-cmds.c | 95 ++++++++++++++++++++++++++++++++++-
tools/pdbgen/app.pl | 12 ++++-
tools/pdbgen/pdb/plug_in_compat.pdb | 53 +++++++++++++++++++-
4 files changed, 156 insertions(+), 6 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index d81e0aa..3543e22 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
#include "internal-procs.h"
-/* 664 procedures registered total */
+/* 665 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
diff --git a/app/pdb/plug-in-compat-cmds.c b/app/pdb/plug-in-compat-cmds.c
index 9a05016..7a189bf 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -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);
}
diff --git a/tools/pdbgen/app.pl b/tools/pdbgen/app.pl
index ce8e893..fd7911f 100644
--- a/tools/pdbgen/app.pl
+++ b/tools/pdbgen/app.pl
@@ -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",
@{[ "ewrap($proc->{blurb}, 2) ]},
@{[ "ewrap($help, 2) ]},
"$proc->{author}",
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index 95ef09b..df7fba3 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -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 => []);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]