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



commit e6703aa6b8d9d8dbb1f4e9b6ee6cf669826453e4
Author: Michael Natterer <mitch gimp org>
Date:   Thu Apr 30 17:17:19 2015 -0400

    plug-ins, pdb: remove the papertile plug-in and add a PDB compat proc

 app/pdb/internal-procs.c            |    2 +-
 app/pdb/plug-in-compat-cmds.c       |  175 +++++++
 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/tile-paper.c        |  952 -----------------------------------
 po-plug-ins/POTFILES.in             |    1 -
 tools/pdbgen/pdb/plug_in_compat.pdb |   99 ++++
 9 files changed, 275 insertions(+), 976 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 0a1a3e3..de885f7 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 754 procedures registered total */
+/* 755 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 fd67260..d1a3c37 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -2024,6 +2024,96 @@ plug_in_nova_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+plug_in_papertile_invoker (GimpProcedure         *procedure,
+                           Gimp                  *gimp,
+                           GimpContext           *context,
+                           GimpProgress          *progress,
+                           const GimpValueArray  *args,
+                           GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  gint32 tile_size;
+  gdouble move_max;
+  gint32 fractional_type;
+  gboolean wrap_around;
+  gboolean centering;
+  gint32 background_type;
+  GimpRGB background_color;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  tile_size = g_value_get_int (gimp_value_array_index (args, 3));
+  move_max = g_value_get_double (gimp_value_array_index (args, 4));
+  fractional_type = g_value_get_int (gimp_value_array_index (args, 5));
+  wrap_around = g_value_get_boolean (gimp_value_array_index (args, 6));
+  centering = g_value_get_boolean (gimp_value_array_index (args, 7));
+  background_type = g_value_get_int (gimp_value_array_index (args, 8));
+  gimp_value_get_rgb (gimp_value_array_index (args, 9), &background_color);
+
+  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;
+          GimpRGB    color;
+          GeglColor *gegl_color;
+          gint       bg_type;
+
+          switch (background_type)
+            {
+            default:
+              bg_type = background_type;
+              gimp_rgba_set (&color, 0.0, 0.0, 1.0, 1.0);
+              break;
+
+            case 3:
+              bg_type = 3;
+              gimp_context_get_foreground (context, &color);
+              break;
+
+            case 4:
+              bg_type = 3;
+              gimp_context_get_background (context, &color);
+              break;
+
+            case 5:
+              bg_type = 3;
+              color = background_color;
+              break;
+            }
+
+          gegl_color = gimp_gegl_color_new (&color);
+
+          node = gegl_node_new_child (NULL,
+                                      "operation",       "gegl:tile-paper",
+                                      "tile-width",      tile_size,
+                                      "tile-height",     tile_size,
+                                      "move-rate",       move_max,
+                                      "bg-color",        gegl_color,
+                                      "centering",       centering,
+                                      "wrap-around",     wrap_around,
+                                      "background-type", bg_type,
+                                      "fractional-type", fractional_type,
+                                      NULL);
+
+          g_object_unref (gegl_color);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Paper Tile"),
+                                         node);
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 plug_in_pixelize_invoker (GimpProcedure         *procedure,
                           Gimp                  *gimp,
                           GimpContext           *context,
@@ -5311,6 +5401,91 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-plug-in-papertile
+   */
+  procedure = gimp_procedure_new (plug_in_papertile_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-papertile");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-papertile",
+                                     "Cut image into paper tiles, and slide them",
+                                     "This plug-in cuts an image into paper tiles and slides each paper 
tile.",
+                                     "Compatibility procedure. Please see 'gegl:tile-paper' for credits.",
+                                     "Compatibility procedure. Please see 'gegl:tile-paper' 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,
+                               gimp_param_spec_int32 ("tile-size",
+                                                      "tile size",
+                                                      "Tile size (pixels)",
+                                                      G_MININT32, G_MAXINT32, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("move-max",
+                                                    "move max",
+                                                    "Max move rate (%)",
+                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("fractional-type",
+                                                      "fractional type",
+                                                      "Fractional type { BACKGROUND (0), IGNORE (1), FORCE 
(2) }",
+                                                      0, 2, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_boolean ("wrap-around",
+                                                     "wrap around",
+                                                     "Wrap around",
+                                                     FALSE,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_boolean ("centering",
+                                                     "centering",
+                                                     "Centering",
+                                                     FALSE,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("background-type",
+                                                      "background type",
+                                                      "Background type { TRANSPARENT (0), INVERTED (1), 
IMAGE (2), FG (3), BG (4), COLOR (5) }",
+                                                      0, 5, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_rgb ("background-color",
+                                                    "background color",
+                                                    "Background color (for background-type == 5)",
+                                                    FALSE,
+                                                    NULL,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("background-alpha",
+                                                      "background alpha",
+                                                      "Background alpha (unused)",
+                                                      G_MININT32, G_MAXINT32, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-plug-in-pixelize
    */
   procedure = gimp_procedure_new (plug_in_pixelize_invoker);
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index fd4019b..5038140 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -188,8 +188,6 @@
 /sphere-designer.exe
 /tile
 /tile.exe
-/tile-paper
-/tile-paper.exe
 /tile-small
 /tile-small.exe
 /unit-editor
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 2ae4121..dc489a5 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -137,7 +137,6 @@ libexec_PROGRAMS = \
        sparkle \
        sphere-designer \
        tile \
-       tile-paper \
        tile-small \
        unit-editor \
        unsharp-mask \
@@ -1820,23 +1819,6 @@ tile_LDADD = \
        $(INTLLIBS)             \
        $(tile_RC)
 
-tile_paper_SOURCES = \
-       tile-paper.c
-
-tile_paper_LDADD = \
-       $(libgimpui)            \
-       $(libgimpwidgets)       \
-       $(libgimpmodule)        \
-       $(libgimp)              \
-       $(libgimpmath)          \
-       $(libgimpconfig)        \
-       $(libgimpcolor)         \
-       $(libgimpbase)          \
-       $(GTK_LIBS)             \
-       $(RT_LIBS)              \
-       $(INTLLIBS)             \
-       $(tile_paper_RC)
-
 tile_small_SOURCES = \
        tile-small.c
 
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index fd28ea1..56d8ef7 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -91,7 +91,6 @@ softglow_RC = softglow.rc.o
 sparkle_RC = sparkle.rc.o
 sphere_designer_RC = sphere-designer.rc.o
 tile_RC = tile.rc.o
-tile_paper_RC = tile-paper.rc.o
 tile_small_RC = tile-small.rc.o
 unit_editor_RC = unit-editor.rc.o
 unsharp_mask_RC = unsharp-mask.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 39aa7a2..a9e615c 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -92,7 +92,6 @@
     'sparkle' => { ui => 1 },
     'sphere-designer' => { ui => 1 },
     'tile' => { ui => 1 },
-    'tile-paper' => { ui => 1 },
     'tile-small' => { ui => 1 },
     'unit-editor' => { ui => 1 },
     'unsharp-mask' => { ui => 1 },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index 346f5e5..376879e 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -96,7 +96,6 @@ plug-ins/common/softglow.c
 plug-ins/common/sparkle.c
 plug-ins/common/sphere-designer.c
 plug-ins/common/tile.c
-plug-ins/common/tile-paper.c
 plug-ins/common/tile-small.c
 plug-ins/common/unit-editor.c
 plug-ins/common/unsharp-mask.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index 17b1eb4..0c26d37 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -2086,6 +2086,104 @@ CODE
     );
 }
 
+sub plug_in_papertile {
+    $blurb = 'Cut image into paper tiles, and slide them';
+
+    $help = <<'HELP';
+This plug-in cuts an image into paper tiles and slides each paper tile.
+HELP
+
+    &std_pdb_compat('gegl:tile-paper');
+    $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 => 'tile_size', type => 'int32',
+          desc => 'Tile size (pixels)' },
+        { name => 'move_max', type => 'float',
+          desc => 'Max move rate (%)' },
+       { name => 'fractional_type', type => '0 <= int32 <= 2',
+         desc => 'Fractional type { BACKGROUND (0), IGNORE (1), FORCE (2) }' },
+        { name => 'wrap_around', type => 'boolean',
+          desc => 'Wrap around' },
+        { name => 'centering', type => 'boolean',
+          desc => 'Centering' },
+        { name => 'background_type', type => '0 <= int32 <= 5',
+          desc => 'Background type { TRANSPARENT (0), INVERTED (1), IMAGE (2), FG (3), BG (4), COLOR (5) }' 
},
+        { name => 'background_color', type => 'color',
+          desc => 'Background color (for background-type == 5)' },
+        { name => 'background_alpha', type => 'int32', dead => 1,
+          desc => 'Background alpha (unused)' }
+    );
+
+    %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;
+      GimpRGB    color;
+      GeglColor *gegl_color;
+      gint       bg_type;
+
+      switch (background_type)
+        {
+        default:
+          bg_type = background_type;
+          gimp_rgba_set (&color, 0.0, 0.0, 1.0, 1.0);
+          break;
+
+        case 3:
+          bg_type = 3;
+          gimp_context_get_foreground (context, &color);
+         break;
+
+       case 4:
+          bg_type = 3;
+          gimp_context_get_background (context, &color);
+         break;
+
+       case 5:
+          bg_type = 3;
+          color = background_color;
+         break;
+        }
+
+      gegl_color = gimp_gegl_color_new (&color);
+
+      node = gegl_node_new_child (NULL,
+                                  "operation",       "gegl:tile-paper",
+                                  "tile-width",      tile_size,
+                                  "tile-height",     tile_size,
+                                  "move-rate",       move_max,
+                                  "bg-color",        gegl_color,
+                                  "centering",       centering,
+                                  "wrap-around",     wrap_around,
+                                  "background-type", bg_type,
+                                  "fractional-type", fractional_type,
+                                  NULL);
+
+      g_object_unref (gegl_color);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Paper Tile"),
+                                     node);
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub plug_in_pixelize {
     $blurb = 'Simplify image into an array of solid-colored squares';
 
@@ -3852,6 +3950,7 @@ CODE
             plug_in_mblur_inward
             plug_in_mosaic
             plug_in_nova
+            plug_in_papertile
             plug_in_pixelize
             plug_in_pixelize2
             plug_in_plasma


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