[gimp/goat-invasion: 232/325] app: remove the legacy levels cruft



commit 2c611d211c76b14aaf018fddd4691071376f6b31
Author: Michael Natterer <mitch gimp org>
Date:   Fri Mar 23 10:25:34 2012 +0100

    app: remove the legacy levels cruft

 app/base/Makefile.am           |    2 -
 app/base/base-types.h          |    1 -
 app/base/levels.c              |  113 --------------------------------------
 app/base/levels.h              |   41 --------------
 app/core/gimpdrawable-levels.c |  116 ++++------------------------------------
 app/core/gimpdrawable-levels.h |    9 ---
 app/gegl/gimplevelsconfig.c    |   37 -------------
 app/gegl/gimplevelsconfig.h    |    6 --
 app/pdb/color-cmds.c           |   67 ++++++++++++++---------
 app/tools/gimplevelstool.c     |   38 +-------------
 app/tools/gimplevelstool.h     |    1 -
 libgimp/gimpcolor_pdb.c        |    4 +-
 tools/pdbgen/pdb/color.pdb     |   70 ++++++++++++++----------
 13 files changed, 93 insertions(+), 412 deletions(-)
---
diff --git a/app/base/Makefile.am b/app/base/Makefile.am
index 0381afa..5a0cff3 100644
--- a/app/base/Makefile.am
+++ b/app/base/Makefile.am
@@ -32,8 +32,6 @@ libappbase_a_SOURCES = \
 	gimplut.h		\
 	hue-saturation.c	\
 	hue-saturation.h	\
-	levels.c		\
-	levels.h		\
 	lut-funcs.c		\
 	lut-funcs.h		\
 	pixel-processor.c	\
diff --git a/app/base/base-types.h b/app/base/base-types.h
index 41c2752..5f3887f 100644
--- a/app/base/base-types.h
+++ b/app/base/base-types.h
@@ -52,7 +52,6 @@ typedef struct _GimpLut             GimpLut;
 
 typedef struct _ColorBalance        ColorBalance;
 typedef struct _HueSaturation       HueSaturation;
-typedef struct _Levels              Levels;
 typedef struct _Threshold           Threshold;
 
 typedef struct _PixelRegionIterator PixelRegionIterator;
diff --git a/app/core/gimpdrawable-levels.c b/app/core/gimpdrawable-levels.c
index 623af95..42e795f 100644
--- a/app/core/gimpdrawable-levels.c
+++ b/app/core/gimpdrawable-levels.c
@@ -22,15 +22,9 @@
 #include "core-types.h"
 
 #include "base/gimphistogram.h"
-#include "base/gimplut.h"
-#include "base/levels.h"
 
 #include "gegl/gimplevelsconfig.h"
 
-/* temp */
-#include "gimp.h"
-#include "gimpimage.h"
-
 #include "gimpdrawable.h"
 #include "gimpdrawable-histogram.h"
 #include "gimpdrawable-levels.h"
@@ -41,74 +35,17 @@
 #include "gimp-intl.h"
 
 
-/*  local function prototypes  */
-
-static void   gimp_drawable_levels_internal (GimpDrawable     *drawable,
-                                             GimpProgress     *progress,
-                                             GimpLevelsConfig *config);
-
-
 /*  public functions  */
 
 void
-gimp_drawable_levels (GimpDrawable *drawable,
-                      GimpProgress *progress,
-                      gint32        channel,
-                      gint32        low_input,
-                      gint32        high_input,
-                      gdouble       gamma,
-                      gint32        low_output,
-                      gint32        high_output)
-{
-  GimpLevelsConfig *config;
-
-  g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
-  g_return_if_fail (! gimp_drawable_is_indexed (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 (channel >= GIMP_HISTOGRAM_VALUE &&
-                    channel <= GIMP_HISTOGRAM_ALPHA);
-  g_return_if_fail (low_input   >= 0   && low_input   <= 255);
-  g_return_if_fail (high_input  >= 0   && high_input  <= 255);
-  g_return_if_fail (gamma       >= 0.1 && gamma       <= 10.0);
-  g_return_if_fail (low_output  >= 0   && low_output  <= 255);
-  g_return_if_fail (high_output >= 0   && high_output <= 255);
-
-  if (channel == GIMP_HISTOGRAM_ALPHA)
-    g_return_if_fail (gimp_drawable_has_alpha (drawable));
-
-  if (gimp_drawable_is_gray (drawable))
-    g_return_if_fail (channel == GIMP_HISTOGRAM_VALUE ||
-                      channel == GIMP_HISTOGRAM_ALPHA);
-
-  config = g_object_new (GIMP_TYPE_LEVELS_CONFIG, NULL);
-
-  g_object_set (config,
-                "channel", channel,
-                NULL);
-
-  g_object_set (config,
-                "low-input",   low_input   / 255.0,
-                "high-input",  high_input  / 255.0,
-                "gamma",       gamma,
-                "low-output",  low_output  / 255.0,
-                "high-output", high_output / 255.0,
-                NULL);
-
-  gimp_drawable_levels_internal (drawable, progress, config);
-
-  g_object_unref (config);
-}
-
-void
 gimp_drawable_levels_stretch (GimpDrawable *drawable,
                               GimpProgress *progress)
 {
   GimpLevelsConfig *config;
   GimpHistogram    *histogram;
+  GeglNode         *levels;
 
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
-  g_return_if_fail (! gimp_drawable_is_indexed (drawable));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
   g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
 
@@ -125,48 +62,17 @@ gimp_drawable_levels_stretch (GimpDrawable *drawable,
 
   gimp_histogram_unref (histogram);
 
-  gimp_drawable_levels_internal (drawable, progress, config);
-
-  g_object_unref (config);
-}
+  levels = g_object_new (GEGL_TYPE_NODE,
+                         "operation", "gimp:levels",
+                         NULL);
 
+  gegl_node_set (levels,
+                 "config", config,
+                 NULL);
 
-/*  private functions  */
+  gimp_drawable_apply_operation (drawable, progress, _("Levels"),
+                                 levels, TRUE);
 
-static void
-gimp_drawable_levels_internal (GimpDrawable     *drawable,
-                               GimpProgress     *progress,
-                               GimpLevelsConfig *config)
-{
-  if (gimp_use_gegl (gimp_item_get_image (GIMP_ITEM (drawable))->gimp))
-    {
-      GeglNode *levels;
-
-      levels = g_object_new (GEGL_TYPE_NODE,
-                             "operation", "gimp:levels",
-                             NULL);
-
-      gegl_node_set (levels,
-                     "config", config,
-                     NULL);
-
-      gimp_drawable_apply_operation (drawable, progress, _("Levels"),
-                                     levels, TRUE);
-
-      g_object_unref (levels);
-    }
-  else
-    {
-      Levels   levels;
-      GimpLut *lut = gimp_lut_new ();
-
-      gimp_levels_config_to_cruft (config, &levels,
-                                   gimp_drawable_is_rgb (drawable));
-      gimp_lut_setup (lut,
-                      (GimpLutFunc) levels_lut_func, &levels,
-                      gimp_drawable_bytes (drawable));
-
-      gimp_drawable_process_lut (drawable, progress, _("Levels"), lut);
-      gimp_lut_free (lut);
-    }
+  g_object_unref (levels);
+  g_object_unref (config);
 }
diff --git a/app/core/gimpdrawable-levels.h b/app/core/gimpdrawable-levels.h
index de2c268..c7889eb 100644
--- a/app/core/gimpdrawable-levels.h
+++ b/app/core/gimpdrawable-levels.h
@@ -19,15 +19,6 @@
 #define __GIMP_DRAWABLE_LEVELS_H__
 
 
-void   gimp_drawable_levels         (GimpDrawable *drawable,
-                                     GimpProgress *progress,
-                                     gint32        channel,
-                                     gint32        low_input,
-                                     gint32        high_input,
-                                     gdouble       gamma,
-                                     gint32        low_output,
-                                     gint32        high_output);
-
 void   gimp_drawable_levels_stretch (GimpDrawable *drawable,
                                      GimpProgress *progress);
 
diff --git a/app/gegl/gimplevelsconfig.c b/app/gegl/gimplevelsconfig.c
index d78240c..f05af73 100644
--- a/app/gegl/gimplevelsconfig.c
+++ b/app/gegl/gimplevelsconfig.c
@@ -35,9 +35,6 @@
 
 #include "base/gimphistogram.h"
 
-/*  temp cruft  */
-#include "base/levels.h"
-
 #include "core/gimpcurve.h"
 
 #include "gimpcurvesconfig.h"
@@ -816,37 +813,3 @@ gimp_levels_config_save_cruft (GimpLevelsConfig  *config,
 
   return TRUE;
 }
-
-
-/*  temp cruft  */
-
-void
-gimp_levels_config_to_cruft (GimpLevelsConfig *config,
-                             Levels           *cruft,
-                             gboolean          is_color)
-{
-  GimpHistogramChannel channel;
-
-  g_return_if_fail (GIMP_IS_LEVELS_CONFIG (config));
-  g_return_if_fail (cruft != NULL);
-
-  for (channel = GIMP_HISTOGRAM_VALUE;
-       channel <= GIMP_HISTOGRAM_ALPHA;
-       channel++)
-    {
-      cruft->gamma[channel]       = config->gamma[channel];
-      cruft->low_input[channel]   = config->low_input[channel]   * 255.999;
-      cruft->high_input[channel]  = config->high_input[channel]  * 255.999;
-      cruft->low_output[channel]  = config->low_output[channel]  * 255.999;
-      cruft->high_output[channel] = config->high_output[channel] * 255.999;
-    }
-
-  if (! is_color)
-    {
-      cruft->gamma[1]       = cruft->gamma[GIMP_HISTOGRAM_ALPHA];
-      cruft->low_input[1]   = cruft->low_input[GIMP_HISTOGRAM_ALPHA];
-      cruft->high_input[1]  = cruft->high_input[GIMP_HISTOGRAM_ALPHA];
-      cruft->low_output[1]  = cruft->low_output[GIMP_HISTOGRAM_ALPHA];
-      cruft->high_output[1] = cruft->high_output[GIMP_HISTOGRAM_ALPHA];
-    }
-}
diff --git a/app/gegl/gimplevelsconfig.h b/app/gegl/gimplevelsconfig.h
index 581fd1a..752d5cc 100644
--- a/app/gegl/gimplevelsconfig.h
+++ b/app/gegl/gimplevelsconfig.h
@@ -83,10 +83,4 @@ gboolean   gimp_levels_config_save_cruft       (GimpLevelsConfig      *config,
                                                 GError               **error);
 
 
-/*  temp cruft  */
-void       gimp_levels_config_to_cruft         (GimpLevelsConfig      *config,
-                                                Levels                *cruft,
-                                                gboolean               is_color);
-
-
 #endif /* __GIMP_LEVELS_CONFIG_H__ */
diff --git a/app/pdb/color-cmds.c b/app/pdb/color-cmds.c
index 67c71a9..ec9104a 100644
--- a/app/pdb/color-cmds.c
+++ b/app/pdb/color-cmds.c
@@ -36,6 +36,7 @@
 #include "gegl/gimpcolorizeconfig.h"
 #include "gegl/gimpcurvesconfig.h"
 #include "gegl/gimpdesaturateconfig.h"
+#include "gegl/gimplevelsconfig.h"
 #include "gegl/gimpposterizeconfig.h"
 #include "gegl/gimpthresholdconfig.h"
 
@@ -116,21 +117,33 @@ levels_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) ||
-          (! gimp_drawable_has_alpha (drawable) &&
-           channel == GIMP_HISTOGRAM_ALPHA) ||
-          (gimp_drawable_is_gray (drawable) &&
-           channel != GIMP_HISTOGRAM_VALUE && channel != GIMP_HISTOGRAM_ALPHA))
-        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_has_alpha (drawable) || channel != GIMP_HISTOGRAM_ALPHA) &&
+          (! gimp_drawable_is_gray (drawable) ||
+           channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
+        {
+          GObject *config = g_object_new (GIMP_TYPE_LEVELS_CONFIG,
+                                          "channel", channel,
+                                          NULL);
 
-      if (success)
-        gimp_drawable_levels (drawable, progress,
-                              channel,
-                              low_input, high_input,
-                              gamma,
-                              low_output, high_output);
+          g_object_set (config,
+                        "low-input",   low_input   / 255.0,
+                        "high-input",  high_input  / 255.0,
+                        "gamma",       gamma,
+                        "low-output",  low_output  / 255.0,
+                        "high-output", high_output / 255.0,
+                        NULL);
+
+          gimp_drawable_apply_operation_by_name (drawable, progress,
+                                                 C_("undo-type", "Levels"),
+                                                 "gimp:levels",
+                                                 config, TRUE);
+
+          g_object_unref (config);
+        }
+      else
+        success = TRUE;
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -152,13 +165,13 @@ levels_auto_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))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+        {
+          gimp_drawable_levels_stretch (drawable, progress);
+        }
+      else
         success = FALSE;
-
-      if (success)
-        gimp_drawable_levels_stretch (drawable, progress);
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -180,13 +193,13 @@ levels_stretch_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))
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+        {
+          gimp_drawable_levels_stretch (drawable, progress);
+        }
+      else
         success = FALSE;
-
-      if (success)
-        gimp_drawable_levels_stretch (drawable, progress);
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -837,7 +850,7 @@ register_color_procs (GimpPDB *pdb)
   gimp_procedure_set_static_strings (procedure,
                                      "gimp-levels-stretch",
                                      "Automatically modifies intensity levels in the specified drawable.",
-                                     "This procedure allows intensity levels in the specified drawable to be remapped according to a set of guessed parameters. It is equivalent to clicking the \"Auto\" button in the Levels tool. This procedure is only valid on RGB color and grayscale images. It will not operate on indexed drawables.",
+                                     "This procedure allows intensity levels in the specified drawable to be remapped according to a set of guessed parameters. It is equivalent to clicking the \"Auto\" button in the Levels tool.",
                                      "Joao S.O. Bueno, Shawn Willden",
                                      "Joao S.O. Bueno, Shawn Willden",
                                      "2003",
diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c
index e592d13..6e5e774 100644
--- a/app/tools/gimplevelstool.c
+++ b/app/tools/gimplevelstool.c
@@ -31,8 +31,6 @@
 #include "tools-types.h"
 
 #include "base/gimphistogram.h"
-#include "base/gimplut.h"
-#include "base/levels.h"
 
 #include "gegl/gimplevelsconfig.h"
 #include "gegl/gimpoperationlevels.h"
@@ -82,7 +80,6 @@ static void       gimp_levels_tool_color_picked   (GimpColorTool     *color_tool
 
 static GeglNode * gimp_levels_tool_get_operation  (GimpImageMapTool  *im_tool,
                                                    GObject          **config);
-static void       gimp_levels_tool_map            (GimpImageMapTool  *im_tool);
 static void       gimp_levels_tool_dialog         (GimpImageMapTool  *im_tool);
 static void       gimp_levels_tool_dialog_unmap   (GtkWidget         *dialog,
                                                    GimpLevelsTool    *tool);
@@ -175,7 +172,6 @@ gimp_levels_tool_class_init (GimpLevelsToolClass *klass)
   im_tool_class->export_dialog_title = _("Export Levels");
 
   im_tool_class->get_operation       = gimp_levels_tool_get_operation;
-  im_tool_class->map                 = gimp_levels_tool_map;
   im_tool_class->dialog              = gimp_levels_tool_dialog;
   im_tool_class->reset               = gimp_levels_tool_reset;
   im_tool_class->settings_import     = gimp_levels_tool_settings_import;
@@ -185,14 +181,7 @@ gimp_levels_tool_class_init (GimpLevelsToolClass *klass)
 static void
 gimp_levels_tool_init (GimpLevelsTool *tool)
 {
-  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
-
-  tool->lut           = gimp_lut_new ();
-  tool->histogram     = gimp_histogram_new ();
-  tool->active_picker = NULL;
-
-  im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
-  im_tool->apply_data = tool->lut;
+  tool->histogram = gimp_histogram_new ();
 }
 
 static void
@@ -200,8 +189,6 @@ gimp_levels_tool_finalize (GObject *object)
 {
   GimpLevelsTool *tool = GIMP_LEVELS_TOOL (object);
 
-  gimp_lut_free (tool->lut);
-
   if (tool->histogram)
     {
       gimp_histogram_unref (tool->histogram);
@@ -223,13 +210,6 @@ gimp_levels_tool_initialize (GimpTool     *tool,
   if (! drawable)
     return FALSE;
 
-  if (gimp_drawable_is_indexed (drawable))
-    {
-      g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
-			   _("Levels does not operate on indexed layers."));
-      return FALSE;
-    }
-
   gimp_config_reset (GIMP_CONFIG (l_tool->config));
 
   if (l_tool->active_picker)
@@ -277,22 +257,6 @@ gimp_levels_tool_get_operation (GimpImageMapTool  *im_tool,
   return node;
 }
 
-static void
-gimp_levels_tool_map (GimpImageMapTool *image_map_tool)
-{
-  GimpLevelsTool *tool     = GIMP_LEVELS_TOOL (image_map_tool);
-  GimpDrawable   *drawable = image_map_tool->drawable;
-  Levels          levels;
-
-  gimp_levels_config_to_cruft (tool->config, &levels,
-                               gimp_drawable_is_rgb (drawable));
-
-  gimp_lut_setup (tool->lut,
-                  (GimpLutFunc) levels_lut_func,
-                  &levels,
-                  gimp_drawable_bytes (drawable));
-}
-
 
 /*******************/
 /*  Levels dialog  */
diff --git a/app/tools/gimplevelstool.h b/app/tools/gimplevelstool.h
index 3967259..a436718 100644
--- a/app/tools/gimplevelstool.h
+++ b/app/tools/gimplevelstool.h
@@ -38,7 +38,6 @@ struct _GimpLevelsTool
   GimpImageMapTool      parent_instance;
 
   GimpLevelsConfig     *config;
-  GimpLut              *lut;
 
   /* dialog */
   GimpHistogram        *histogram;
diff --git a/libgimp/gimpcolor_pdb.c b/libgimp/gimpcolor_pdb.c
index c7028c9..78e8324 100644
--- a/libgimp/gimpcolor_pdb.c
+++ b/libgimp/gimpcolor_pdb.c
@@ -167,9 +167,7 @@ gimp_levels_auto (gint32 drawable_ID)
  *
  * This procedure allows intensity levels in the specified drawable to
  * be remapped according to a set of guessed parameters. It is
- * equivalent to clicking the \"Auto\" button in the Levels tool. This
- * procedure is only valid on RGB color and grayscale images. It will
- * not operate on indexed drawables.
+ * equivalent to clicking the \"Auto\" button in the Levels tool.
  *
  * Returns: TRUE on success.
  **/
diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb
index 9c615e1..6f72f26 100644
--- a/tools/pdbgen/pdb/color.pdb
+++ b/tools/pdbgen/pdb/color.pdb
@@ -100,24 +100,36 @@ HELP
     );
 
     %invoke = (
-	headers => [ qw("core/gimpdrawable-levels.h") ],
+	headers => [ qw("gegl/gimplevelsconfig.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) ||
-      (! gimp_drawable_has_alpha (drawable) &&
-       channel == GIMP_HISTOGRAM_ALPHA) ||
-      (gimp_drawable_is_gray (drawable) &&
-       channel != GIMP_HISTOGRAM_VALUE && channel != GIMP_HISTOGRAM_ALPHA))
-    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_has_alpha (drawable) || channel != GIMP_HISTOGRAM_ALPHA) &&
+      (! gimp_drawable_is_gray (drawable) ||
+       channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
+    {
+      GObject *config = g_object_new (GIMP_TYPE_LEVELS_CONFIG,
+                                      "channel", channel,
+                                      NULL);
 
-  if (success)
-    gimp_drawable_levels (drawable, progress,
-                          channel,
-                          low_input, high_input,
-                          gamma,
-                          low_output, high_output);
+      g_object_set (config,
+                    "low-input",   low_input   / 255.0,
+                    "high-input",  high_input  / 255.0,
+                    "gamma",       gamma,
+                    "low-output",  low_output  / 255.0,
+                    "high-output", high_output / 255.0,
+                    NULL);
+
+      gimp_drawable_apply_operation_by_name (drawable, progress,
+                                             C_("undo-type", "Levels"),
+                                             "gimp:levels",
+                                             config, TRUE);
+
+      g_object_unref (config);
+    }
+  else
+    success = TRUE;
 }
 CODE
     );
@@ -129,9 +141,7 @@ sub levels_stretch {
     $help = <<'HELP';
 This procedure allows intensity levels in the specified drawable to be
 remapped according to a set of guessed parameters. It is equivalent to
-clicking the "Auto" button in the Levels tool. This procedure is
-only valid on RGB color and grayscale images. It will not operate on
-indexed drawables.
+clicking the "Auto" button in the Levels tool.
 HELP
 
     $author = $copyright = 'Joao S.O. Bueno, Shawn Willden';
@@ -146,13 +156,13 @@ HELP
         headers => [ qw("core/gimpdrawable-levels.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))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+      gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+    {
+      gimp_drawable_levels_stretch (drawable, progress);
+    }
+  else
     success = FALSE;
-
-  if (success)
-    gimp_drawable_levels_stretch (drawable, progress);
 }
 CODE
     );
@@ -170,13 +180,13 @@ sub levels_auto {
         headers => [ qw("core/gimpdrawable-levels.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))
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+      gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+    {
+      gimp_drawable_levels_stretch (drawable, progress);
+    }
+  else
     success = FALSE;
-
-  if (success)
-    gimp_drawable_levels_stretch (drawable, progress);
 }
 CODE
     );



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