[gimp/goat-invasion: 442/526] app: use the new functions added with the last commit



commit 3d2e30d215fc46e8657f502f298644bc891583a1
Author: Michael Natterer <mitch gimp org>
Date:   Sat Apr 7 02:27:58 2012 +0200

    app: use the new functions added with the last commit

 app/core/gimpdrawable.c       |   64 +++-------------------------------------
 app/pdb/drawable-cmds.c       |    4 ++-
 tools/pdbgen/pdb/drawable.pdb |    4 ++-
 3 files changed, 11 insertions(+), 61 deletions(-)
---
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index aa78364..fd3fa11 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -1632,25 +1632,7 @@ gimp_drawable_type (const GimpDrawable *drawable)
 
   format = gegl_buffer_get_format (drawable->private->buffer);
 
-  if (format == babl_format ("Y' u8"))
-    return GIMP_GRAY_IMAGE;
-  else if (format == babl_format ("Y'A u8"))
-    return GIMP_GRAYA_IMAGE;
-  else if (format == babl_format ("R'G'B' u8"))
-    return GIMP_RGB_IMAGE;
-  else if (format == babl_format ("R'G'B'A u8"))
-    return GIMP_RGBA_IMAGE;
-  else
-    {
-      GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
-
-      if (format == gimp_image_get_format (image, GIMP_INDEXED_IMAGE))
-        return GIMP_INDEXED_IMAGE;
-      if (format == gimp_image_get_format (image, GIMP_INDEXEDA_IMAGE))
-        return GIMP_INDEXEDA_IMAGE;
-    }
-
-  g_return_val_if_reached (-1);
+  return gimp_babl_format_get_image_type (format);
 }
 
 GimpImageType
@@ -1670,67 +1652,31 @@ gimp_drawable_get_base_type (const GimpDrawable *drawable)
 
   format = gegl_buffer_get_format (drawable->private->buffer);
 
-  if (format == babl_format ("Y' u8") ||
-      format == babl_format ("Y'A u8"))
-    {
-      return GIMP_GRAY;
-    }
-  else if (format == babl_format ("R'G'B' u8") ||
-           format == babl_format ("R'G'B'A u8"))
-    {
-      return GIMP_RGB;
-    }
-  else
-    {
-      GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
-
-      if (format == gimp_image_get_format (image, GIMP_INDEXED_IMAGE) ||
-          format == gimp_image_get_format (image, GIMP_INDEXEDA_IMAGE))
-        {
-          return GIMP_INDEXED;
-        }
-    }
-
-  g_return_val_if_reached (-1);
+  return gimp_babl_format_get_base_type (format);
 }
 
 gboolean
 gimp_drawable_is_rgb (const GimpDrawable *drawable)
 {
-  GimpImageType type;
-
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
 
-  type = gimp_drawable_type (drawable);
-
-  return (type == GIMP_RGB_IMAGE ||
-          type == GIMP_RGBA_IMAGE);
+  return (gimp_drawable_get_base_type (drawable) == GIMP_RGB);
 }
 
 gboolean
 gimp_drawable_is_gray (const GimpDrawable *drawable)
 {
-  GimpImageType type;
-
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
 
-  type = gimp_drawable_type (drawable);
-
-  return (type == GIMP_GRAY_IMAGE ||
-          type == GIMP_GRAYA_IMAGE);
+  return (gimp_drawable_get_base_type (drawable) == GIMP_GRAY);
 }
 
 gboolean
 gimp_drawable_is_indexed (const GimpDrawable *drawable)
 {
-  GimpImageType type;
-
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
 
-  type = gimp_drawable_type (drawable);
-
-  return (type == GIMP_INDEXED_IMAGE ||
-          type == GIMP_INDEXEDA_IMAGE);
+  return (gimp_drawable_get_base_type (drawable) == GIMP_INDEXED);
 }
 
 gint
diff --git a/app/pdb/drawable-cmds.c b/app/pdb/drawable-cmds.c
index 958d161..711ac49 100644
--- a/app/pdb/drawable-cmds.c
+++ b/app/pdb/drawable-cmds.c
@@ -92,7 +92,9 @@ drawable_type_with_alpha_invoker (GimpProcedure      *procedure,
 
   if (success)
     {
-      type_with_alpha = gimp_drawable_type_with_alpha (drawable);
+      const Babl *format = gimp_drawable_get_format_with_alpha (drawable);
+
+      type_with_alpha = gimp_babl_format_get_image_type (format);
     }
 
   return_vals = gimp_procedure_get_return_values (procedure, success,
diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb
index 1c905db..f52468c 100644
--- a/tools/pdbgen/pdb/drawable.pdb
+++ b/tools/pdbgen/pdb/drawable.pdb
@@ -347,7 +347,9 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  type_with_alpha = gimp_drawable_type_with_alpha (drawable);
+  const Babl *format = gimp_drawable_get_format_with_alpha (drawable);
+
+  type_with_alpha = gimp_babl_format_get_image_type (format);
 }
 CODE
     );



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