[gimp/goat-invasion: 14/241] app: remove the pointless core wrappers for the below simplified color stuff



commit 83f3446519a3e408d140c877902222f3c566b61e
Author: Michael Natterer <mitch gimp org>
Date:   Wed Mar 14 01:35:54 2012 +0100

    app: remove the pointless core wrappers for the below simplified color stuff
    
    Instead, provide gimp_drawable_apply_operation_with_config() and call
    that from the PDB wrappers directly.

 app/actions/drawable-commands.c    |    1 -
 app/core/Makefile.am               |    8 --
 app/core/gimpdrawable-colorize.c   |   68 -------------------
 app/core/gimpdrawable-colorize.h   |   29 --------
 app/core/gimpdrawable-desaturate.c |   64 ------------------
 app/core/gimpdrawable-desaturate.h |   27 --------
 app/core/gimpdrawable-operation.c  |   32 +++++++++
 app/core/gimpdrawable-operation.h  |   28 +++++---
 app/core/gimpdrawable-posterize.c  |   64 ------------------
 app/core/gimpdrawable-posterize.h  |   27 --------
 app/core/gimpdrawable-threshold.c  |   66 -------------------
 app/core/gimpdrawable-threshold.h  |   28 --------
 app/pdb/color-cmds.c               |  125 +++++++++++++++++++++++++-----------
 tools/pdbgen/pdb/color.pdb         |  127 +++++++++++++++++++++++++-----------
 14 files changed, 226 insertions(+), 468 deletions(-)
---
diff --git a/app/actions/drawable-commands.c b/app/actions/drawable-commands.c
index 4847cc4..b0e5eb4 100644
--- a/app/actions/drawable-commands.c
+++ b/app/actions/drawable-commands.c
@@ -25,7 +25,6 @@
 #include "actions-types.h"
 
 #include "core/gimp.h"
-#include "core/gimpdrawable-desaturate.h"
 #include "core/gimpdrawable-equalize.h"
 #include "core/gimpdrawable-invert.h"
 #include "core/gimpdrawable-levels.h"
diff --git a/app/core/Makefile.am b/app/core/Makefile.am
index a879932..b98a0d0 100644
--- a/app/core/Makefile.am
+++ b/app/core/Makefile.am
@@ -126,16 +126,12 @@ libappcore_a_sources = \
 	gimpdrawable-bucket-fill.h		\
 	gimpdrawable-color-balance.c		\
 	gimpdrawable-color-balance.h		\
-	gimpdrawable-colorize.c			\
-	gimpdrawable-colorize.h			\
 	gimpdrawable-combine.c			\
 	gimpdrawable-combine.h			\
 	gimpdrawable-convert.c			\
 	gimpdrawable-convert.h			\
 	gimpdrawable-curves.c			\
 	gimpdrawable-curves.h			\
-	gimpdrawable-desaturate.c		\
-	gimpdrawable-desaturate.h		\
 	gimpdrawable-equalize.c			\
 	gimpdrawable-equalize.h			\
 	gimpdrawable-foreground-extract.c	\
@@ -152,8 +148,6 @@ libappcore_a_sources = \
 	gimpdrawable-offset.h			\
 	gimpdrawable-operation.c		\
 	gimpdrawable-operation.h		\
-	gimpdrawable-posterize.c		\
-	gimpdrawable-posterize.h		\
 	gimpdrawable-preview.c			\
 	gimpdrawable-preview.h			\
 	gimpdrawable-private.h			\
@@ -163,8 +157,6 @@ libappcore_a_sources = \
 	gimpdrawable-shadow.h			\
 	gimpdrawable-stroke.c			\
 	gimpdrawable-stroke.h			\
-	gimpdrawable-threshold.c		\
-	gimpdrawable-threshold.h		\
 	gimpdrawable-transform.c		\
 	gimpdrawable-transform.h		\
 	gimpdrawablemodundo.c			\
diff --git a/app/core/gimpdrawable-operation.c b/app/core/gimpdrawable-operation.c
index a186c5a..1d14bb5 100644
--- a/app/core/gimpdrawable-operation.c
+++ b/app/core/gimpdrawable-operation.c
@@ -33,6 +33,7 @@
 #include "gimpdrawable.h"
 #include "gimpdrawable-operation.h"
 #include "gimpdrawable-shadow.h"
+#include "gimpimagemapconfig.h"
 #include "gimpprogress.h"
 
 
@@ -87,6 +88,37 @@ gimp_drawable_apply_operation (GimpDrawable *drawable,
 }
 
 void
+gimp_drawable_apply_operation_with_config (GimpDrawable *drawable,
+                                           GimpProgress *progress,
+                                           const gchar  *undo_desc,
+                                           const gchar  *operation_type,
+                                           GObject      *config,
+                                           gboolean      linear)
+{
+  GeglNode *node;
+
+  g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
+  g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
+  g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
+  g_return_if_fail (undo_desc != NULL);
+  g_return_if_fail (operation_type != NULL);
+  g_return_if_fail (GIMP_IS_IMAGE_MAP_CONFIG (config));
+
+  node = g_object_new (GEGL_TYPE_NODE,
+                       "operation", operation_type,
+                       NULL);
+
+  gegl_node_set (node,
+                 "config", config,
+                 NULL);
+
+  gimp_drawable_apply_operation (drawable, progress, undo_desc,
+                                 node, TRUE);
+
+  g_object_unref (node);
+}
+
+void
 gimp_drawable_apply_operation_to_tiles (GimpDrawable *drawable,
                                         GimpProgress *progress,
                                         const gchar  *undo_desc,
diff --git a/app/core/gimpdrawable-operation.h b/app/core/gimpdrawable-operation.h
index 798680b..8997c31 100644
--- a/app/core/gimpdrawable-operation.h
+++ b/app/core/gimpdrawable-operation.h
@@ -24,18 +24,24 @@
 #define __GIMP_DRAWABLE_OPERATION_H__
 
 
-void   gimp_drawable_apply_operation          (GimpDrawable *drawable,
-                                               GimpProgress *progress,
-                                               const gchar  *undo_desc,
-                                               GeglNode     *operation,
-                                               gboolean      linear);
+void   gimp_drawable_apply_operation             (GimpDrawable *drawable,
+                                                  GimpProgress *progress,
+                                                  const gchar  *undo_desc,
+                                                  GeglNode     *operation,
+                                                  gboolean      linear);
+void   gimp_drawable_apply_operation_with_config (GimpDrawable *drawable,
+                                                  GimpProgress *progress,
+                                                  const gchar  *undo_desc,
+                                                  const gchar  *operation_type,
+                                                  GObject      *config,
+                                                  gboolean      linear);
 
-void   gimp_drawable_apply_operation_to_tiles (GimpDrawable *drawable,
-                                               GimpProgress *progress,
-                                               const gchar  *undo_desc,
-                                               GeglNode     *operation,
-                                               gboolean      linear,
-                                               TileManager  *new_tiles);
+void   gimp_drawable_apply_operation_to_tiles    (GimpDrawable *drawable,
+                                                  GimpProgress *progress,
+                                                  const gchar  *undo_desc,
+                                                  GeglNode     *operation,
+                                                  gboolean      linear,
+                                                  TileManager  *new_tiles);
 
 
 #endif /* __GIMP_DRAWABLE_OPERATION_H__ */
diff --git a/app/pdb/color-cmds.c b/app/pdb/color-cmds.c
index 033f293..bc5ff7a 100644
--- a/app/pdb/color-cmds.c
+++ b/app/pdb/color-cmds.c
@@ -26,18 +26,19 @@
 #include "base/gimphistogram.h"
 #include "core/gimpdrawable-brightness-contrast.h"
 #include "core/gimpdrawable-color-balance.h"
-#include "core/gimpdrawable-colorize.h"
 #include "core/gimpdrawable-curves.h"
-#include "core/gimpdrawable-desaturate.h"
 #include "core/gimpdrawable-equalize.h"
 #include "core/gimpdrawable-histogram.h"
 #include "core/gimpdrawable-hue-saturation.h"
 #include "core/gimpdrawable-invert.h"
 #include "core/gimpdrawable-levels.h"
-#include "core/gimpdrawable-posterize.h"
-#include "core/gimpdrawable-threshold.h"
+#include "core/gimpdrawable-operation.h"
 #include "core/gimpdrawable.h"
 #include "core/gimpparamspecs.h"
+#include "gegl/gimpcolorizeconfig.h"
+#include "gegl/gimpdesaturateconfig.h"
+#include "gegl/gimpposterizeconfig.h"
+#include "gegl/gimpthresholdconfig.h"
 
 #include "gimppdb.h"
 #include "gimppdb-utils.h"
@@ -201,13 +202,23 @@ posterize_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
-          ! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
-          gimp_drawable_is_indexed (drawable))
-        success = FALSE;
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+          ! gimp_drawable_is_indexed (drawable))
+        {
+          GObject *config = g_object_new (GIMP_TYPE_POSTERIZE_CONFIG,
+                                          "levels", levels,
+                                          NULL);
 
-      if (success)
-        gimp_drawable_posterize (drawable, progress, levels);
+          gimp_drawable_apply_operation_with_config (drawable, progress,
+                                                     _("Posterize"),
+                                                     "gimp:posterize",
+                                                     config, TRUE);
+
+          g_object_unref (config);
+        }
+      else
+        success = FALSE;
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -229,13 +240,23 @@ desaturate_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
-          ! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
-          ! gimp_drawable_is_rgb (drawable))
-        success = FALSE;
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+          gimp_drawable_is_rgb (drawable))
+        {
+          GObject *config = g_object_new (GIMP_TYPE_DESATURATE_CONFIG,
+                                          "mode", GIMP_DESATURATE_LIGHTNESS,
+                                          NULL);
 
-      if (success)
-        gimp_drawable_desaturate (drawable, progress, GIMP_DESATURATE_LIGHTNESS);
+          gimp_drawable_apply_operation_with_config (drawable, progress,
+                                                     _("Desaturate"),
+                                                     "gimp:desaturate",
+                                                     config, TRUE);
+
+          g_object_unref (config);
+        }
+      else
+        success = FALSE;
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -259,13 +280,23 @@ desaturate_full_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
-          ! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
-          ! gimp_drawable_is_rgb (drawable))
-        success = FALSE;
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+          gimp_drawable_is_rgb (drawable))
+        {
+          GObject *config = g_object_new (GIMP_TYPE_DESATURATE_CONFIG,
+                                          "mode", desaturate_mode,
+                                          NULL);
 
-      if (success)
-        gimp_drawable_desaturate (drawable, progress, desaturate_mode);
+          gimp_drawable_apply_operation_with_config (drawable, progress,
+                                                     _("Desaturate"),
+                                                     "gimp:desaturate",
+                                                     config, TRUE);
+
+          g_object_unref (config);
+        }
+      else
+        success = FALSE;
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -470,14 +501,25 @@ colorize_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
-          ! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
-          ! gimp_drawable_is_rgb (drawable))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+          gimp_drawable_is_rgb (drawable))
+        {
+          GObject *config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG,
+                                          "hue",        hue        / 360.0,
+                                          "saturation", saturation / 100.0,
+                                          "lightness",  lightness  / 100.0,
+                                          NULL);
+
+          gimp_drawable_apply_operation_with_config (drawable, progress,
+                                                     C_("undo-type", "Colorize"),
+                                                     "gimp:colorize",
+                                                     config, TRUE);
+
+          g_object_unref (config);
+        }
+      else
         success = FALSE;
-
-      if (success)
-        gimp_drawable_colorize (drawable, progress,
-                                hue, saturation, lightness);
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -613,15 +655,24 @@ threshold_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
-          ! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
-          gimp_drawable_is_indexed (drawable) ||
-          (low_threshold > high_threshold))
-        success = FALSE;
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+          ! gimp_drawable_is_indexed (drawable))
+        {
+          GObject *config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG,
+                                          "low",  low_threshold  / 255.0,
+                                          "high", high_threshold / 255.0,
+                                          NULL);
 
-      if (success)
-        gimp_drawable_threshold (drawable, progress,
-                                 low_threshold, high_threshold);
+          gimp_drawable_apply_operation_with_config (drawable, progress,
+                                                     _("Threshold"),
+                                                     "gimp:threshold",
+                                                     config, TRUE);
+
+          g_object_unref (config);
+        }
+      else
+        success = FALSE;
     }
 
   return gimp_procedure_get_return_values (procedure, success,
diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb
index 788ec25..fc1c17a 100644
--- a/tools/pdbgen/pdb/color.pdb
+++ b/tools/pdbgen/pdb/color.pdb
@@ -192,16 +192,26 @@ HELP
     );
 
     %invoke = (
-        headers => [ qw("core/gimpdrawable-posterize.h") ],
+        headers => [ qw("gegl/gimpposterizeconfig.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
-      ! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
-      gimp_drawable_is_indexed (drawable))
-    success = FALSE;
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+      gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+      ! gimp_drawable_is_indexed (drawable))
+    {
+      GObject *config = g_object_new (GIMP_TYPE_POSTERIZE_CONFIG,
+                                      "levels", levels,
+                                      NULL);
 
-  if (success)
-    gimp_drawable_posterize (drawable, progress, levels);
+      gimp_drawable_apply_operation_with_config (drawable, progress,
+                                                 _("Posterize"),
+                                                 "gimp:posterize",
+                                                 config, TRUE);
+
+      g_object_unref (config);
+    }
+  else
+    success = FALSE;
 }
 CODE
     );
@@ -223,16 +233,26 @@ HELP
     );
 
     %invoke = (
-	headers => [ qw("core/gimpdrawable-desaturate.h") ],
+	headers => [ qw("gegl/gimpdesaturateconfig.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
-      ! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
-      ! gimp_drawable_is_rgb (drawable))
-    success = FALSE;
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+      gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+      gimp_drawable_is_rgb (drawable))
+    {
+      GObject *config = g_object_new (GIMP_TYPE_DESATURATE_CONFIG,
+                                      "mode", GIMP_DESATURATE_LIGHTNESS,
+                                      NULL);
 
-  if (success)
-    gimp_drawable_desaturate (drawable, progress, GIMP_DESATURATE_LIGHTNESS);
+      gimp_drawable_apply_operation_with_config (drawable, progress,
+                                                 _("Desaturate"),
+                                                 "gimp:desaturate",
+                                                 config, TRUE);
+
+      g_object_unref (config);
+    }
+  else
+    success = FALSE;
 }
 CODE
     );
@@ -261,16 +281,26 @@ HELP
     );
 
     %invoke = (
-	headers => [ qw("core/gimpdrawable-desaturate.h") ],
+	headers => [ qw("gegl/gimpdesaturateconfig.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
-      ! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
-      ! gimp_drawable_is_rgb (drawable))
-    success = FALSE;
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+      gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+      gimp_drawable_is_rgb (drawable))
+    {
+      GObject *config = g_object_new (GIMP_TYPE_DESATURATE_CONFIG,
+                                      "mode", desaturate_mode,
+                                      NULL);
 
-  if (success)
-    gimp_drawable_desaturate (drawable, progress, desaturate_mode);
+      gimp_drawable_apply_operation_with_config (drawable, progress,
+                                                 _("Desaturate"),
+                                                 "gimp:desaturate",
+                                                 config, TRUE);
+
+      g_object_unref (config);
+    }
+  else
+    success = FALSE;
 }
 CODE
     );
@@ -514,17 +544,28 @@ HELP
     );
 
     %invoke = (
-	headers => [ qw("core/gimpdrawable-colorize.h") ],
+	headers => [ qw("gegl/gimpcolorizeconfig.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
-      ! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
-      ! gimp_drawable_is_rgb (drawable))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+      gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+      gimp_drawable_is_rgb (drawable))
+    {
+      GObject *config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG,
+                                      "hue",        hue        / 360.0,
+                                      "saturation", saturation / 100.0,
+                                      "lightness",  lightness  / 100.0,
+                                      NULL);
+
+      gimp_drawable_apply_operation_with_config (drawable, progress,
+                                                 C_("undo-type", "Colorize"),
+                                                 "gimp:colorize",
+                                                 config, TRUE);
+
+      g_object_unref (config);
+    }
+  else
     success = FALSE;
-
-  if (success)
-    gimp_drawable_colorize (drawable, progress,
-                            hue, saturation, lightness);
 }
 CODE
     );
@@ -680,18 +721,27 @@ HELP
     );
 
     %invoke = (
-	headers => [ qw("core/gimpdrawable-threshold.h") ],
+	headers => [ qw("gegl/gimpthresholdconfig.h") ],
 	code => <<'CODE'
 {
-  if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
-      ! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
-      gimp_drawable_is_indexed (drawable) ||
-      (low_threshold > high_threshold))
-    success = FALSE;
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+      gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+      ! gimp_drawable_is_indexed (drawable))
+    {
+      GObject *config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG,
+                                      "low",  low_threshold  / 255.0,
+                                      "high", high_threshold / 255.0,
+                                      NULL);
 
-  if (success)
-    gimp_drawable_threshold (drawable, progress,
-                             low_threshold, high_threshold);
+      gimp_drawable_apply_operation_with_config (drawable, progress,
+                                                 _("Threshold"),
+                                                 "gimp:threshold",
+                                                 config, TRUE);
+
+      g_object_unref (config);
+    }
+  else
+    success = FALSE;
 }
 CODE
     );
@@ -699,6 +749,7 @@ CODE
 
 
 @headers = qw("core/gimpdrawable.h"
+              "core/gimpdrawable-operation.h"
               "gimppdb-utils.h"
               "gimp-intl.h");
 



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