[gimp] plug-ins: remove plug-in cubism and add a PDB compat proc for it



commit fc38bc300eae25cf3e884c2a3fedf74d5fe3abd8
Author: Michael Natterer <mitch gimp org>
Date:   Sun May 19 22:38:03 2013 +0200

    plug-ins: remove plug-in cubism and add a PDB compat proc for it

 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/cubism.c            |  878 -----------------------------------
 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 |   70 +++
 9 files changed, 188 insertions(+), 902 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 60e4ad6..7724eb4 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 685 procedures registered total */
+/* 686 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 912836a..a705fe6 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -196,6 +196,69 @@ plug_in_colortoalpha_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+plug_in_cubism_invoker (GimpProcedure         *procedure,
+                        Gimp                  *gimp,
+                        GimpContext           *context,
+                        GimpProgress          *progress,
+                        const GimpValueArray  *args,
+                        GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  gdouble tile_size;
+  gdouble tile_saturation;
+  gint32 bg_color;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  tile_size = g_value_get_double (gimp_value_array_index (args, 3));
+  tile_saturation = g_value_get_double (gimp_value_array_index (args, 4));
+  bg_color = 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))
+        {
+          GimpRGB    color;
+          GeglColor *gegl_color;
+          GeglNode  *node;
+
+          if (bg_color)
+            {
+              gimp_context_get_background (context, &color);
+              gimp_rgb_set_alpha (&color, 0.0);
+            }
+          else
+            {
+              gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0);
+            }
+
+          gegl_color = gimp_gegl_color_new (&color);
+
+          node = gegl_node_new_child (NULL,
+                                      "operation",       "gegl:cubism",
+                                      "tile-size",       tile_size,
+                                      "tile-saturation", tile_saturation,
+                                      "bg-color",        gegl_color,
+                                      NULL);
+          g_object_unref (gegl_color);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Cubism"),
+                                         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,
@@ -783,6 +846,60 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-plug-in-cubism
+   */
+  procedure = gimp_procedure_new (plug_in_cubism_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-cubism");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-cubism",
+                                     "Convert the image into randomly rotated square blobs",
+                                     "Convert the image into randomly rotated square blobs.",
+                                     "Compatibility procedure. Please see 'gegl:cubism' for credits.",
+                                     "Compatibility procedure. Please see 'gegl:cubism' 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,
+                               g_param_spec_double ("tile-size",
+                                                    "tile size",
+                                                    "Average diameter of each tile (in pixels)",
+                                                    0.0, 100.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("tile-saturation",
+                                                    "tile saturation",
+                                                    "Expand tiles by this amount",
+                                                    0.0, 10.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("bg-color",
+                                                      "bg color",
+                                                      "Background color { BLACK (0), BG (1) }",
+                                                      0, 1, 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 68e1695..aecdcef 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -60,8 +60,6 @@
 /convolution-matrix.exe
 /crop-zealous
 /crop-zealous.exe
-/cubism
-/cubism.exe
 /curve-bend
 /curve-bend.exe
 /decompose
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 30d1962..6c0a0ab 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -73,7 +73,6 @@ libexec_PROGRAMS = \
        contrast-stretch-hsv \
        convolution-matrix \
        crop-zealous \
-       cubism \
        curve-bend \
        decompose \
        deinterlace \
@@ -697,23 +696,6 @@ crop_zealous_LDADD = \
        $(INTLLIBS)             \
        $(crop_zealous_RC)
 
-cubism_SOURCES = \
-       cubism.c
-
-cubism_LDADD = \
-       $(libgimpui)            \
-       $(libgimpwidgets)       \
-       $(libgimpmodule)        \
-       $(libgimp)              \
-       $(libgimpmath)          \
-       $(libgimpconfig)        \
-       $(libgimpcolor)         \
-       $(libgimpbase)          \
-       $(GTK_LIBS)             \
-       $(RT_LIBS)              \
-       $(INTLLIBS)             \
-       $(cubism_RC)
-
 curve_bend_SOURCES = \
        curve-bend.c
 
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index e599d67..265d26a 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -27,7 +27,6 @@ contrast_stretch_RC = contrast-stretch.rc.o
 contrast_stretch_hsv_RC = contrast-stretch-hsv.rc.o
 convolution_matrix_RC = convolution-matrix.rc.o
 crop_zealous_RC = crop-zealous.rc.o
-cubism_RC = cubism.rc.o
 curve_bend_RC = curve-bend.rc.o
 decompose_RC = decompose.rc.o
 deinterlace_RC = deinterlace.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index b02d721..0b98271 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -28,7 +28,6 @@
     'contrast-stretch-hsv' => {},
     'convolution-matrix' => { ui => 1 },
     'crop-zealous' => {},
-    'cubism' => { ui => 1 },
     'curve-bend' => { ui => 1 },
     'decompose' => { ui => 1 },
     'deinterlace' => { ui => 1 },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index 411e9be..86708ea 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -35,7 +35,6 @@ plug-ins/common/contrast-stretch.c
 plug-ins/common/contrast-stretch-hsv.c
 plug-ins/common/convolution-matrix.c
 plug-ins/common/crop-zealous.c
-plug-ins/common/cubism.c
 plug-ins/common/curve-bend.c
 plug-ins/common/decompose.c
 plug-ins/common/deinterlace.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index 20b7996..3758475 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -175,6 +175,75 @@ CODE
     );
 }
 
+sub plug_in_cubism {
+    $blurb = 'Convert the image into randomly rotated square blobs';
+
+    $help = <<'HELP';
+Convert the image into randomly rotated square blobs.
+HELP
+
+    &std_pdb_compat('gegl:cubism');
+    $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 => 'tile_size', type => '0.0 <= float <= 100.0',
+         desc => 'Average diameter of each tile (in pixels)' },
+       { name => 'tile_saturation', type => '0.0 <= float <= 10.0',
+         desc => 'Expand tiles by this amount' },
+       { name => 'bg_color', type => '0 <= int32 <= 1',
+         desc => 'Background color { BLACK (0), BG (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))
+    {
+      GimpRGB    color;
+      GeglColor *gegl_color;
+      GeglNode  *node;
+
+      if (bg_color)
+        {
+          gimp_context_get_background (context, &color);
+          gimp_rgb_set_alpha (&color, 0.0);
+        }
+      else
+        {
+          gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0);
+        }
+
+      gegl_color = gimp_gegl_color_new (&color);
+
+      node = gegl_node_new_child (NULL,
+                                  "operation",       "gegl:cubism",
+                                  "tile-size",       tile_size,
+                                  "tile-saturation", tile_saturation,
+                                  "bg-color",        gegl_color,
+                                  NULL);
+      g_object_unref (gegl_color);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Cubism"),
+                                     node);
+
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub plug_in_pixelize {
     $blurb = 'Simplify image into an array of solid-colored squares';
 
@@ -735,6 +804,7 @@ CODE
 @procs = qw(plug_in_autocrop
             plug_in_autocrop_layer
             plug_in_colortoalpha
+           plug_in_cubism
             plug_in_pixelize
             plug_in_pixelize2
             plug_in_polar_coords


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