[gimp] plug-ins, pdb: remove the edge plug-in and add a PDB compat procedure



commit 573f0f69bbad6c06b18fd90c833132034912e423
Author: Michael Natterer <mitch gimp org>
Date:   Tue Mar 3 23:18:53 2015 +0100

    plug-ins, pdb: remove the edge plug-in and add a PDB compat procedure

 app/pdb/internal-procs.c            |    2 +-
 app/pdb/plug-in-compat-cmds.c       |  117 +++++
 plug-ins/common/.gitignore          |    2 -
 plug-ins/common/Makefile.am         |   18 -
 plug-ins/common/edge.c              |  838 -----------------------------------
 plug-ins/common/gimprc.common       |    1 -
 plug-ins/common/plugin-defs.pl      |    1 -
 po-plug-ins/POTFILES.in             |    1 -
 tools/pdbgen/pdb/plug_in_compat.pdb |   73 +++
 9 files changed, 191 insertions(+), 862 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 64d0540..0a1a3e3 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 753 procedures registered total */
+/* 754 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 f6347ee..fd67260 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -1033,6 +1033,69 @@ plug_in_diffraction_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+plug_in_edge_invoker (GimpProcedure         *procedure,
+                      Gimp                  *gimp,
+                      GimpContext           *context,
+                      GimpProgress          *progress,
+                      const GimpValueArray  *args,
+                      GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  gdouble amount;
+  gint32 warpmode;
+  gint32 edgemode;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  amount = g_value_get_double (gimp_value_array_index (args, 3));
+  warpmode = g_value_get_int (gimp_value_array_index (args, 4));
+  edgemode = g_value_get_int (gimp_value_array_index (args, 5));
+
+  if (success)
+    {
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+                                     GIMP_PDB_ITEM_CONTENT, error) &&
+          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+        {
+          GeglNode        *node;
+          GeglAbyssPolicy  border_behavior = GEGL_ABYSS_NONE;
+
+          switch (warpmode)
+            {
+            case 1:
+              border_behavior = GEGL_ABYSS_LOOP;
+              break;
+
+            case 2:
+              border_behavior = GEGL_ABYSS_CLAMP;
+              break;
+
+            case 3:
+              border_behavior = GEGL_ABYSS_BLACK;
+              break;
+            }
+
+          node = gegl_node_new_child (NULL,
+                                      "operation",       "gegl:edge",
+                                      "algorihm",        edgemode,
+                                      "amount",          amount,
+                                      "border-behavior", border_behavior,
+                                      NULL);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Edge"),
+                                         node);
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 plug_in_engrave_invoker (GimpProcedure         *procedure,
                          Gimp                  *gimp,
                          GimpContext           *context,
@@ -4137,6 +4200,60 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-plug-in-edge
+   */
+  procedure = gimp_procedure_new (plug_in_edge_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-edge");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-edge",
+                                     "Several simple methods for detecting edges",
+                                     "Perform edge detection on the contents of the specified drawable. 
AMOUNT is an arbitrary constant, WRAPMODE is like displace plug-in (useful for tilable image). EDGEMODE sets 
the kind of matrix transform applied to the pixels, SOBEL was the method used in older versions.",
+                                     "Compatibility procedure. Please see 'gegl:edge' for credits.",
+                                     "Compatibility procedure. Please see 'gegl:edge' for credits.",
+                                     "2015",
+                                     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,
+                               g_param_spec_double ("amount",
+                                                    "amount",
+                                                    "Edge detection amount",
+                                                    1.0, 10.0, 1.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("warpmode",
+                                                      "warpmode",
+                                                      "Edge detection behavior { WRAP (1), SMEAR (2), BLACK 
(3) }",
+                                                      1, 3, 1,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("edgemode",
+                                                      "edgemode",
+                                                      "Edge detection algorithm { SOBEL (0), PREWITT (1), 
GRADIENT (2), ROBERTS (3), DIFFERENTIAL (4), LAPLACE (5) }",
+                                                      0, 5, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-plug-in-engrave
    */
   procedure = gimp_procedure_new (plug_in_engrave_invoker);
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index 7e21b99..fd4019b 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -52,8 +52,6 @@
 /destripe.exe
 /displace
 /displace.exe
-/edge
-/edge.exe
 /edge-dog
 /edge-dog.exe
 /edge-neon
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 2be1122..2ae4121 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -69,7 +69,6 @@ libexec_PROGRAMS = \
        despeckle \
        destripe \
        displace \
-       edge \
        edge-dog \
        edge-neon \
        emboss \
@@ -602,23 +601,6 @@ displace_LDADD = \
        $(INTLLIBS)             \
        $(displace_RC)
 
-edge_SOURCES = \
-       edge.c
-
-edge_LDADD = \
-       $(libgimpui)            \
-       $(libgimpwidgets)       \
-       $(libgimpmodule)        \
-       $(libgimp)              \
-       $(libgimpmath)          \
-       $(libgimpconfig)        \
-       $(libgimpcolor)         \
-       $(libgimpbase)          \
-       $(GTK_LIBS)             \
-       $(RT_LIBS)              \
-       $(INTLLIBS)             \
-       $(edge_RC)
-
 edge_dog_SOURCES = \
        edge-dog.c
 
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index 1078c0a..fd28ea1 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -23,7 +23,6 @@ depth_merge_RC = depth-merge.rc.o
 despeckle_RC = despeckle.rc.o
 destripe_RC = destripe.rc.o
 displace_RC = displace.rc.o
-edge_RC = edge.rc.o
 edge_dog_RC = edge-dog.rc.o
 edge_neon_RC = edge-neon.rc.o
 emboss_RC = emboss.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index df42d6e..39aa7a2 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -24,7 +24,6 @@
     'despeckle' => { ui => 1 },
     'destripe' => { ui => 1 },
     'displace' => { ui => 1 },
-    'edge' => { ui => 1 },
     'edge-dog' => { ui => 1 },
     'edge-neon' => { ui => 1 },
     'emboss' => { ui => 1 },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index 90fc65e..346f5e5 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -28,7 +28,6 @@ plug-ins/common/depth-merge.c
 plug-ins/common/despeckle.c
 plug-ins/common/destripe.c
 plug-ins/common/displace.c
-plug-ins/common/edge.c
 plug-ins/common/edge-dog.c
 plug-ins/common/edge-neon.c
 plug-ins/common/emboss.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index be942e2..17b1eb4 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -942,6 +942,78 @@ CODE
     );
 }
 
+sub plug_in_edge {
+    $blurb = 'Several simple methods for detecting edges';
+
+    $help = <<'HELP';
+Perform edge detection on the contents of the specified drawable.
+AMOUNT is an arbitrary constant, WRAPMODE is like displace plug-in
+(useful for tilable image). EDGEMODE sets the kind of matrix transform
+applied to the pixels, SOBEL was the method used in older versions.
+HELP
+
+    &std_pdb_compat('gegl:edge');
+    $date = '2015';
+
+    @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 => 'amount', type => '1.0 <= float <= 10.0',
+          desc => 'Edge detection amount' },
+        { name => 'warpmode', type => '1 <= int32 <= 3',
+          desc => 'Edge detection behavior { WRAP (1), SMEAR (2), BLACK (3) }' },
+        { name => 'edgemode', type => '0 <= int32 <= 5',
+          desc => 'Edge detection algorithm { SOBEL (0), PREWITT (1), GRADIENT (2), ROBERTS (3), 
DIFFERENTIAL (4), LAPLACE (5) }' }
+    );
+
+    %invoke = (
+        code => <<'CODE'
+{
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+                                 GIMP_PDB_ITEM_CONTENT, error) &&
+      gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+    {
+      GeglNode        *node;
+      GeglAbyssPolicy  border_behavior = GEGL_ABYSS_NONE;
+
+      switch (warpmode)
+        {
+       case 1:
+         border_behavior = GEGL_ABYSS_LOOP;
+         break;
+
+        case 2:
+         border_behavior = GEGL_ABYSS_CLAMP;
+         break;
+
+        case 3:
+         border_behavior = GEGL_ABYSS_BLACK;
+         break;
+       }
+
+      node = gegl_node_new_child (NULL,
+                                  "operation",       "gegl:edge",
+                                  "algorihm",        edgemode,
+                                  "amount",          amount,
+                                  "border-behavior", border_behavior,
+                                  NULL);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Edge"),
+                                     node);
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub plug_in_engrave {
     $blurb = 'Simulate an antique engraving';
 
@@ -3761,6 +3833,7 @@ CODE
             plug_in_cubism
             plug_in_deinterlace
             plug_in_diffraction
+            plug_in_edge
             plug_in_engrave
             plug_in_exchange
             plug_in_flarefx


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]