[gimp] plug-ins, pdb: remove shift plug-in and add a PDB compat procedure for it



commit a77d9223df873f9ecd996e5c12c807a59f73fdd6
Author: Michael Natterer <mitch gimp org>
Date:   Mon May 27 02:34:04 2013 +0200

    plug-ins, pdb: remove shift plug-in and add a PDB compat procedure for it

 app/pdb/internal-procs.c            |    2 +-
 app/pdb/plug-in-compat-cmds.c       |   92 +++++++
 plug-ins/common/.gitignore          |    2 -
 plug-ins/common/Makefile.am         |   18 --
 plug-ins/common/gimprc.common       |    1 -
 plug-ins/common/plugin-defs.pl      |    1 -
 plug-ins/common/shift.c             |  450 -----------------------------------
 po-plug-ins/POTFILES.in             |    1 -
 tools/pdbgen/pdb/plug_in_compat.pdb |   52 ++++
 9 files changed, 145 insertions(+), 474 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 7724eb4..bb2acd2 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 686 procedures registered total */
+/* 687 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 a705fe6..1a9c8ad 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -646,6 +646,50 @@ plug_in_semiflatten_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+plug_in_shift_invoker (GimpProcedure         *procedure,
+                       Gimp                  *gimp,
+                       GimpContext           *context,
+                       GimpProgress          *progress,
+                       const GimpValueArray  *args,
+                       GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  gint32 shift_amount;
+  gint32 orientation;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  shift_amount = g_value_get_int (gimp_value_array_index (args, 3));
+  orientation = g_value_get_int (gimp_value_array_index (args, 4));
+
+  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 =
+            gegl_node_new_child (NULL,
+                                 "operation", "gegl:shift",
+                                 "shift",     shift_amount / 2,
+                                 "direction", orientation ? 0 : 1,
+                                 NULL);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Shift"),
+                                         node);
+
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 plug_in_threshold_alpha_invoker (GimpProcedure         *procedure,
                                  Gimp                  *gimp,
                                  GimpContext           *context,
@@ -1314,6 +1358,54 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-plug-in-shift
+   */
+  procedure = gimp_procedure_new (plug_in_shift_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-shift");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-shift",
+                                     "Shift each row or column of pixels by a random amount",
+                                     "Shifts the pixels of the specified drawable. Each row or column will 
be displaced a random value of pixels.",
+                                     "Compatibility procedure. Please see 'gegl:shift' for credits.",
+                                     "Compatibility procedure. Please see 'gegl:shift' for credits.",
+                                     "2013",
+                                     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 ("shift-amount",
+                                                      "shift amount",
+                                                      "Shift amount",
+                                                      0, 200, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("orientation",
+                                                      "orientation",
+                                                      "Orientation { ORIENTATION-VERTICAL (0), 
ORIENTATION-HORIZONTAL (1) }",
+                                                      0, 1, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-plug-in-threshold-alpha
    */
   procedure = gimp_procedure_new (plug_in_threshold_alpha_invoker);
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index aecdcef..e8d18be 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -232,8 +232,6 @@
 /screenshot.exe
 /sharpen
 /sharpen.exe
-/shift
-/shift.exe
 /sinus
 /sinus.exe
 /smooth-palette
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 6c0a0ab..ddad3b6 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -159,7 +159,6 @@ libexec_PROGRAMS = \
        sample-colorize \
        $(SCREENSHOT) \
        sharpen \
-       shift \
        sinus \
        smooth-palette \
        softglow \
@@ -2203,23 +2202,6 @@ sharpen_LDADD = \
        $(INTLLIBS)             \
        $(sharpen_RC)
 
-shift_SOURCES = \
-       shift.c
-
-shift_LDADD = \
-       $(libgimpui)            \
-       $(libgimpwidgets)       \
-       $(libgimpmodule)        \
-       $(libgimp)              \
-       $(libgimpmath)          \
-       $(libgimpconfig)        \
-       $(libgimpcolor)         \
-       $(libgimpbase)          \
-       $(GTK_LIBS)             \
-       $(RT_LIBS)              \
-       $(INTLLIBS)             \
-       $(shift_RC)
-
 sinus_SOURCES = \
        sinus.c
 
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index 265d26a..b0755cf 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -113,7 +113,6 @@ rotate_RC = rotate.rc.o
 sample_colorize_RC = sample-colorize.rc.o
 screenshot_RC = screenshot.rc.o
 sharpen_RC = sharpen.rc.o
-shift_RC = shift.rc.o
 sinus_RC = sinus.rc.o
 smooth_palette_RC = smooth-palette.rc.o
 softglow_RC = softglow.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 0b98271..f5e4354 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -114,7 +114,6 @@
     'sample-colorize' => { ui => 1 },
     'screenshot' => { ui => 1, optional => 1, libs => 'SCREENSHOT_LIBS', cflags => 'XFIXES_CFLAGS', gegl => 
1 },
     'sharpen' => { ui => 1 },
-    'shift' => { ui => 1 },
     'sinus' => { ui => 1 },
     'smooth-palette' => { ui => 1 },
     'softglow' => { ui => 1 },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index 86708ea..c9be367 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -121,7 +121,6 @@ plug-ins/common/rotate.c
 plug-ins/common/sample-colorize.c
 plug-ins/common/screenshot.c
 plug-ins/common/sharpen.c
-plug-ins/common/shift.c
 plug-ins/common/sinus.c
 plug-ins/common/smooth-palette.c
 plug-ins/common/softglow.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index 3758475..4b4c0ee 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -692,6 +692,57 @@ CODE
     );
 }
 
+sub plug_in_shift {
+    $blurb = 'Shift each row or column of pixels by a random amount';
+
+    $help = <<'HELP';
+Shifts the pixels of the specified drawable. Each row or column will
+be displaced a random value of pixels.
+HELP
+
+    &std_pdb_compat('gegl:shift');
+    $date = '2013';
+
+    @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 => 'shift_amount', type => '0 <= int32 <= 200',
+         desc => 'Shift amount' },
+       { name => 'orientation', type => '0 <= int32 <= 1',
+         desc => 'Orientation { ORIENTATION-VERTICAL (0), ORIENTATION-HORIZONTAL (1) }' }
+    );
+
+    %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 =
+        gegl_node_new_child (NULL,
+                             "operation", "gegl:shift",
+                             "shift",     shift_amount / 2,
+                             "direction", orientation ? 0 : 1,
+                             NULL);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Shift"),
+                                     node);
+
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub plug_in_threshold_alpha {
     $blurb = 'Make transparency all-or-nothing';
 
@@ -813,6 +864,7 @@ CODE
             plug_in_randomize_pick
             plug_in_randomize_slur
             plug_in_semiflatten
+            plug_in_shift
             plug_in_threshold_alpha
             plug_in_vinvert);
 


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