[gimp] Refuse to convert layer trees to indexed



commit 84b02fb97837692d040382717730646a45be1349
Author: Michael Natterer <mitch gimp org>
Date:   Mon Sep 7 21:09:24 2009 +0200

    Refuse to convert layer trees to indexed

 app/actions/image-actions.c  |   21 ++++++++++++++-------
 app/pdb/convert-cmds.c       |    4 +++-
 tools/pdbgen/pdb/convert.pdb |    4 +++-
 3 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/app/actions/image-actions.c b/app/actions/image-actions.c
index d45da6a..9a5737e 100644
--- a/app/actions/image-actions.c
+++ b/app/actions/image-actions.c
@@ -30,6 +30,7 @@
 #include "core/gimpchannel.h"
 #include "core/gimpcontext.h"
 #include "core/gimpimage.h"
+#include "core/gimpitemstack.h"
 
 #include "widgets/gimpactiongroup.h"
 #include "widgets/gimphelp-ids.h"
@@ -218,15 +219,17 @@ void
 image_actions_update (GimpActionGroup *group,
                       gpointer         data)
 {
-  GimpImage *image = action_data_get_image (data);
-  gboolean   fs    = FALSE;
-  gboolean   aux   = FALSE;
-  gboolean   lp    = FALSE;
-  gboolean   sel   = FALSE;
+  GimpImage *image  = action_data_get_image (data);
+  gboolean   fs     = FALSE;
+  gboolean   aux    = FALSE;
+  gboolean   lp     = FALSE;
+  gboolean   sel    = FALSE;
+  gboolean   groups = FALSE;
 
   if (image)
     {
-      const gchar *action = NULL;
+      GimpContainer *layers;
+      const gchar   *action = NULL;
 
       switch (gimp_image_base_type (image))
         {
@@ -249,6 +252,10 @@ image_actions_update (GimpActionGroup *group,
       aux = (gimp_image_get_active_channel (image) != NULL);
       lp  = ! gimp_image_is_empty (image);
       sel = ! gimp_channel_is_empty (gimp_image_get_mask (image));
+
+      layers = gimp_image_get_layers (image);
+
+      groups = ! gimp_item_stack_is_flat (GIMP_ITEM_STACK (layers));
     }
 
 #define SET_SENSITIVE(action,condition) \
@@ -256,7 +263,7 @@ image_actions_update (GimpActionGroup *group,
 
   SET_SENSITIVE ("image-convert-rgb",       image);
   SET_SENSITIVE ("image-convert-grayscale", image);
-  SET_SENSITIVE ("image-convert-indexed",   image);
+  SET_SENSITIVE ("image-convert-indexed",   image && !groups);
 
   SET_SENSITIVE ("image-flip-horizontal", image);
   SET_SENSITIVE ("image-flip-vertical",   image);
diff --git a/app/pdb/convert-cmds.c b/app/pdb/convert-cmds.c
index 6ae44fb..bb67d4f 100644
--- a/app/pdb/convert-cmds.c
+++ b/app/pdb/convert-cmds.c
@@ -25,6 +25,7 @@
 
 #include "core/gimpimage-convert.h"
 #include "core/gimpimage.h"
+#include "core/gimpitemstack.h"
 #include "core/gimppalette.h"
 #include "core/gimpparamspecs.h"
 
@@ -128,7 +129,8 @@ image_convert_indexed_invoker (GimpProcedure      *procedure,
     {
       GimpPalette *pal = NULL;
 
-      if (gimp_pdb_image_is_not_base_type (image, GIMP_INDEXED, error))
+      if (gimp_pdb_image_is_not_base_type (image, GIMP_INDEXED, error) &&
+          gimp_item_stack_is_flat (GIMP_ITEM_STACK (gimp_image_get_layers (image))))
         {
           switch (palette_type)
             {
diff --git a/tools/pdbgen/pdb/convert.pdb b/tools/pdbgen/pdb/convert.pdb
index 8f2d636..35100b2 100644
--- a/tools/pdbgen/pdb/convert.pdb
+++ b/tools/pdbgen/pdb/convert.pdb
@@ -130,7 +130,8 @@ HELP
 {
   GimpPalette *pal = NULL;
 
-  if (gimp_pdb_image_is_not_base_type (image, GIMP_INDEXED, error))
+  if (gimp_pdb_image_is_not_base_type (image, GIMP_INDEXED, error) &&
+      gimp_item_stack_is_flat (GIMP_ITEM_STACK (gimp_image_get_layers (image))))
     {
       switch (palette_type)
 	{
@@ -208,6 +209,7 @@ CODE
 
 @headers = qw("core/gimpimage.h"
               "core/gimpimage-convert.h"
+              "core/gimpitemstack.h"
               "core/gimppalette.h"
               "gimppdberror.h"
               "gimppdb-utils.h"



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