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



commit a4a0ec9598c47574e00ac39e873df04df85e252e
Author: Michael Natterer <mitch gimp org>
Date:   Fri Sep 4 00:31:37 2015 +0200

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

 app/pdb/internal-procs.c            |    2 +-
 app/pdb/plug-in-compat-cmds.c       |  145 +++++++
 configure.ac                        |    1 -
 plug-ins/Makefile.am                |    1 -
 plug-ins/maze/.gitignore            |    7 -
 plug-ins/maze/Makefile.am           |   53 ---
 plug-ins/maze/maze-algorithms.c     |  646 ------------------------------
 plug-ins/maze/maze-algorithms.h     |   41 --
 plug-ins/maze/maze-dialog.c         |  709 ---------------------------------
 plug-ins/maze/maze-dialog.h         |   24 --
 plug-ins/maze/maze-utils.c          |  155 -------
 plug-ins/maze/maze-utils.h          |   31 --
 plug-ins/maze/maze.c                |  751 -----------------------------------
 plug-ins/maze/maze.h                |   68 ----
 po-plug-ins/POTFILES.in             |    4 -
 tools/pdbgen/pdb/plug_in_compat.pdb |   79 ++++
 16 files changed, 225 insertions(+), 2492 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 11ed674..4ab48f8 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 772 procedures registered total */
+/* 773 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 3557d1f..a0a3a78 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -2398,6 +2398,73 @@ plug_in_make_seamless_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+plug_in_maze_invoker (GimpProcedure         *procedure,
+                      Gimp                  *gimp,
+                      GimpContext           *context,
+                      GimpProgress          *progress,
+                      const GimpValueArray  *args,
+                      GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  gint16 width;
+  gint16 height;
+  guint8 tileable;
+  guint8 algorithm;
+  gint32 seed;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  width = g_value_get_int (gimp_value_array_index (args, 3));
+  height = g_value_get_int (gimp_value_array_index (args, 4));
+  tileable = g_value_get_uint (gimp_value_array_index (args, 5));
+  algorithm = g_value_get_uint (gimp_value_array_index (args, 6));
+  seed = g_value_get_int (gimp_value_array_index (args, 7));
+
+  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;
+          GeglColor *fg_color;
+          GeglColor *bg_color;
+          GimpRGB    color;
+
+          gimp_context_get_foreground (context, &color);
+          fg_color = gimp_gegl_color_new (&color);
+
+          gimp_context_get_background (context, &color);
+          bg_color = gimp_gegl_color_new (&color);
+
+          node =  gegl_node_new_child (NULL,
+                                       "operation",      "gegl:maze",
+                                       "x",              width,
+                                       "y",              height,
+                                       "algorithm-type", algorithm,
+                                       "tilable",        tileable,
+                                       "seed",           seed,
+                                       "fg-color",       fg_color,
+                                       "bg-color",       bg_color,
+                                       NULL);
+
+          g_object_unref (fg_color);
+          g_object_unref (bg_color);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Maze"),
+                                        node);
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 plug_in_mblur_invoker (GimpProcedure         *procedure,
                        Gimp                  *gimp,
                        GimpContext           *context,
@@ -6453,6 +6520,84 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-plug-in-maze
+   */
+  procedure = gimp_procedure_new (plug_in_maze_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-maze");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-maze",
+                                     "Draw a labyrinth",
+                                     "Generates a maze using either the depth-first search method or Prim's 
algorithm. Can make tileable mazes too.",
+                                     "Compatibility procedure. Please see 'gegl:maze' for credits.",
+                                     "Compatibility procedure. Please see 'gegl:maze' 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_int16 ("width",
+                                                      "width",
+                                                      "Width of the passages",
+                                                      1, 1024, 1,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int16 ("height",
+                                                      "height",
+                                                      "Height of the passages",
+                                                      1, 1024, 1,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int8 ("tileable",
+                                                     "tileable",
+                                                     "Tileable maze? (TRUE or FALSE)",
+                                                     0, 1, 0,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int8 ("algorithm",
+                                                     "algorithm",
+                                                     "Generation algorithm (0 = DEPTH FIRST, 1 = PRIM'S 
ALGORITHM)",
+                                                     0, 1, 0,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("seed",
+                                                      "seed",
+                                                      "Random Seed",
+                                                      G_MININT32, G_MAXINT32, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int16 ("multiple",
+                                                      "multiple",
+                                                      "Multiple (use 57)",
+                                                      G_MININT16, G_MAXINT16, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int16 ("offset",
+                                                      "offset",
+                                                      "Offset (use 1)",
+                                                      G_MININT16, G_MAXINT16, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-plug-in-mblur
    */
   procedure = gimp_procedure_new (plug_in_mblur_invoker);
diff --git a/configure.ac b/configure.ac
index f29a5a4..e2335c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2312,7 +2312,6 @@ plug-ins/imagemap/images/Makefile
 plug-ins/lighting/Makefile
 plug-ins/lighting/images/Makefile
 plug-ins/map-object/Makefile
-plug-ins/maze/Makefile
 plug-ins/pagecurl/Makefile
 plug-ins/print/Makefile
 plug-ins/pygimp/Makefile
diff --git a/plug-ins/Makefile.am b/plug-ins/Makefile.am
index bcc3e26..cc017bd 100644
--- a/plug-ins/Makefile.am
+++ b/plug-ins/Makefile.am
@@ -52,7 +52,6 @@ SUBDIRS = \
        imagemap                \
        lighting                \
        map-object              \
-       maze                    \
        pagecurl                \
        $(print)                \
        selection-to-path       \
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index 847d0bd..561f452 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -211,10 +211,6 @@ plug-ins/lighting/lighting-ui.c
 plug-ins/map-object/map-object-apply.c
 plug-ins/map-object/map-object-main.c
 plug-ins/map-object/map-object-ui.c
-plug-ins/maze/maze-algorithms.c
-plug-ins/maze/maze-dialog.c
-plug-ins/maze/maze.c
-plug-ins/maze/maze.h
 plug-ins/pagecurl/pagecurl.c
 plug-ins/print/print-draw-page.c
 plug-ins/print/print-page-layout.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index d31b767..c0064b0 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -2338,6 +2338,84 @@ CODE
     );
 }
 
+sub plug_in_maze {
+    $blurb = 'Draw a labyrinth';
+
+    $help = <<'HELP';
+Generates a maze using either the depth-first search method or Prim's
+algorithm.  Can make tileable mazes too.
+HELP
+
+    &std_pdb_compat('gegl:maze');
+    $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 => 'width', type => '1 <= int16 <= 1024',
+         desc => 'Width of the passages' },
+       { name => 'height', type => '1 <= int16 <= 1024',
+         desc => 'Height of the passages' },
+       { name => 'tileable', type => '0 <= int8 <= 1',
+         desc => 'Tileable maze? (TRUE or FALSE)' },
+       { name => 'algorithm', type => '0 <= int8 <= 1',
+         desc => 'Generation algorithm (0 = DEPTH FIRST, 1 = PRIM\'S ALGORITHM)' },
+       { name => 'seed', type => 'int32',
+         desc => 'Random Seed' },
+       { name => 'multiple', type => 'int16', dead => 1,
+         desc => 'Multiple (use 57)' },
+       { name => 'offset', type => 'int16', dead => 1,
+         desc => 'Offset (use 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;
+      GeglColor *fg_color;
+      GeglColor *bg_color;
+      GimpRGB    color;
+
+      gimp_context_get_foreground (context, &color);
+      fg_color = gimp_gegl_color_new (&color);
+
+      gimp_context_get_background (context, &color);
+      bg_color = gimp_gegl_color_new (&color);
+
+      node =  gegl_node_new_child (NULL,
+                                   "operation",      "gegl:maze",
+                                   "x",              width,
+                                   "y",              height,
+                                   "algorithm-type", algorithm,
+                                   "tilable",        tileable,
+                                   "seed",           seed,
+                                   "fg-color",       fg_color,
+                                   "bg-color",       bg_color,
+                                   NULL);
+
+      g_object_unref (fg_color);
+      g_object_unref (bg_color);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Maze"),
+                                    node);
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub plug_in_mblur {
     $blurb = 'Simulate movement using directional blur';
 
@@ -4779,6 +4857,7 @@ CODE
             plug_in_laplace
             plug_in_lens_distortion
             plug_in_make_seamless
+            plug_in_maze
             plug_in_mblur
             plug_in_mblur_inward
             plug_in_mosaic


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