gimp r24584 - in branches/weskaggs: . app app/actions app/config app/core app/display app/file app/gegl app/gegl/gegl app/gegl/gegl/buffer app/gegl/gegl/graph app/pdb app/text app/tools app/vectors app/widgets data/images desktop libgimp libgimpbase libgimpwidgets modules plug-ins plug-ins/common plug-ins/psd plug-ins/pygimp plug-ins/script-fu/ftx po tools/pdbgen/pdb



Author: weskaggs
Date: Thu Jan 10 03:08:46 2008
New Revision: 24584
URL: http://svn.gnome.org/viewvc/gimp?rev=24584&view=rev

Log:
 Bill Skaggs  <weskaggs primate ucdavis edu>

	merge 24519:24583 from trunk.


Added:
   branches/weskaggs/app/gegl/gegl/graph/
      - copied from r24583, /trunk/app/gegl/gegl/graph/
   branches/weskaggs/app/gegl/gimpoperationcolorize.c
      - copied unchanged from r24583, /trunk/app/gegl/gimpoperationcolorize.c
   branches/weskaggs/app/gegl/gimpoperationcolorize.h
      - copied unchanged from r24583, /trunk/app/gegl/gimpoperationcolorize.h
   branches/weskaggs/app/gegl/gimpoperationlevels.c
      - copied unchanged from r24583, /trunk/app/gegl/gimpoperationlevels.c
   branches/weskaggs/app/gegl/gimpoperationlevels.h
      - copied unchanged from r24583, /trunk/app/gegl/gimpoperationlevels.h
   branches/weskaggs/app/gegl/gimpoperationposterize.c
      - copied unchanged from r24583, /trunk/app/gegl/gimpoperationposterize.c
   branches/weskaggs/app/gegl/gimpoperationposterize.h
      - copied unchanged from r24583, /trunk/app/gegl/gimpoperationposterize.h
   branches/weskaggs/app/gegl/makefile.msc
      - copied unchanged from r24583, /trunk/app/gegl/makefile.msc
   branches/weskaggs/data/images/wilber-devel.png
      - copied unchanged from r24583, /trunk/data/images/wilber-devel.png
   branches/weskaggs/libgimpwidgets/wilber-22.png
      - copied unchanged from r24583, /trunk/libgimpwidgets/wilber-22.png
   branches/weskaggs/libgimpwidgets/wilber-256.png
      - copied unchanged from r24583, /trunk/libgimpwidgets/wilber-256.png
Removed:
   branches/weskaggs/desktop/gimp.applications.in
   branches/weskaggs/desktop/gimp.keys.in
Modified:
   branches/weskaggs/ChangeLog
   branches/weskaggs/INSTALL
   branches/weskaggs/app/actions/channels-commands.c
   branches/weskaggs/app/actions/layers-commands.c
   branches/weskaggs/app/actions/vectors-commands.c
   branches/weskaggs/app/config/gimpcoreconfig.c
   branches/weskaggs/app/config/gimpcoreconfig.h
   branches/weskaggs/app/config/gimpdisplayconfig.c
   branches/weskaggs/app/core/core-types.h
   branches/weskaggs/app/core/gimpchannel.c
   branches/weskaggs/app/core/gimpdrawable-desaturate.c
   branches/weskaggs/app/core/gimpdrawable-invert.c
   branches/weskaggs/app/core/gimpdrawable.c
   branches/weskaggs/app/core/gimpimage-duplicate.c
   branches/weskaggs/app/core/gimpimage-merge.c
   branches/weskaggs/app/core/gimpimage-quick-mask.c
   branches/weskaggs/app/core/gimpimagemap.c
   branches/weskaggs/app/core/gimpimagemap.h
   branches/weskaggs/app/core/gimpitem.c
   branches/weskaggs/app/core/gimpitem.h
   branches/weskaggs/app/core/gimplayer.c
   branches/weskaggs/app/core/gimplayermask.c
   branches/weskaggs/app/core/gimpselection.c
   branches/weskaggs/app/core/makefile.msc
   branches/weskaggs/app/display/gimpcanvas.c
   branches/weskaggs/app/display/gimpcanvas.h
   branches/weskaggs/app/display/gimpdisplayshell-dnd.c
   branches/weskaggs/app/display/gimpdisplayshell-selection.c
   branches/weskaggs/app/display/makefile.msc
   branches/weskaggs/app/file/file-open.c
   branches/weskaggs/app/gegl/Makefile.am
   branches/weskaggs/app/gegl/gegl-types.h
   branches/weskaggs/app/gegl/gegl/buffer/gegl-buffer-types.h
   branches/weskaggs/app/gegl/gegl/gegl-operation-filter.h
   branches/weskaggs/app/gegl/gegl/gegl-operation-point-filter.h
   branches/weskaggs/app/gegl/gegl/gegl-operation-sink.h
   branches/weskaggs/app/gegl/gegl/gegl-operation-source.h
   branches/weskaggs/app/gegl/gegl/gegl-operation.h
   branches/weskaggs/app/gegl/gegl/gegl-types.h
   branches/weskaggs/app/gegl/gimp-gegl.c
   branches/weskaggs/app/gegl/gimpoperationtilesink.c
   branches/weskaggs/app/gegl/gimpoperationtilesource.c
   branches/weskaggs/app/gimpcore.def
   branches/weskaggs/app/makefile.msc
   branches/weskaggs/app/pdb/Makefile.am
   branches/weskaggs/app/pdb/channel_cmds.c
   branches/weskaggs/app/pdb/color_cmds.c
   branches/weskaggs/app/pdb/layer_cmds.c
   branches/weskaggs/app/pdb/makefile.msc
   branches/weskaggs/app/text/gimptextlayer.c
   branches/weskaggs/app/tools/gimpbrightnesscontrasttool.c
   branches/weskaggs/app/tools/gimpcolorbalancetool.c
   branches/weskaggs/app/tools/gimpcolorizetool.c
   branches/weskaggs/app/tools/gimpcurvestool.c
   branches/weskaggs/app/tools/gimphuesaturationtool.c
   branches/weskaggs/app/tools/gimpimagemaptool.c
   branches/weskaggs/app/tools/gimpimagemaptool.h
   branches/weskaggs/app/tools/gimplevelstool.c
   branches/weskaggs/app/tools/gimpposterizetool.c
   branches/weskaggs/app/tools/gimprotatetool.c
   branches/weskaggs/app/tools/gimpthresholdtool.c
   branches/weskaggs/app/tools/makefile.msc
   branches/weskaggs/app/vectors/gimpvectors.c
   branches/weskaggs/app/vectors/gimpvectorsmodundo.c
   branches/weskaggs/app/widgets/gimpchanneltreeview.c
   branches/weskaggs/app/widgets/gimpitemtreeview.c
   branches/weskaggs/app/widgets/gimplayertreeview.c
   branches/weskaggs/app/widgets/gimptoolbox-dnd.c
   branches/weskaggs/app/widgets/gimptoolbox.c
   branches/weskaggs/app/widgets/makefile.msc
   branches/weskaggs/app/widgets/widgets-types.h
   branches/weskaggs/configure.in
   branches/weskaggs/data/images/gimp-logo.png
   branches/weskaggs/data/images/wilber-devel-icon.png
   branches/weskaggs/data/images/wilber-icon.png
   branches/weskaggs/desktop/   (props changed)
   branches/weskaggs/desktop/Makefile.am
   branches/weskaggs/desktop/gimp.desktop.in.in
   branches/weskaggs/libgimp/gimpunitcache.c
   branches/weskaggs/libgimpbase/gimpchecks.c
   branches/weskaggs/libgimpbase/gimpdatafiles.h
   branches/weskaggs/libgimpwidgets/gimpcolorscales.c
   branches/weskaggs/libgimpwidgets/gimpmemsizeentry.c
   branches/weskaggs/libgimpwidgets/gimppageselector.c
   branches/weskaggs/libgimpwidgets/makefile.msc
   branches/weskaggs/libgimpwidgets/wilber-32.png
   branches/weskaggs/libgimpwidgets/wilber-48.png
   branches/weskaggs/libgimpwidgets/wilber-64.png
   branches/weskaggs/modules/cdisplay_colorblind.c
   branches/weskaggs/modules/cdisplay_gamma.c
   branches/weskaggs/modules/cdisplay_highcontrast.c
   branches/weskaggs/modules/cdisplay_lcms.c
   branches/weskaggs/modules/cdisplay_proof.c
   branches/weskaggs/modules/colorsel_cmyk.c
   branches/weskaggs/modules/colorsel_cmyk_lcms.c
   branches/weskaggs/modules/colorsel_triangle.c
   branches/weskaggs/modules/colorsel_water.c
   branches/weskaggs/modules/controller_dx_dinput.c
   branches/weskaggs/modules/controller_linux_input.c
   branches/weskaggs/modules/controller_midi.c
   branches/weskaggs/plug-ins/Makefile.am
   branches/weskaggs/plug-ins/common/convmatrix.c
   branches/weskaggs/plug-ins/common/tile.c
   branches/weskaggs/plug-ins/psd/psd-image-res-load.c
   branches/weskaggs/plug-ins/psd/psd-image-res-load.h
   branches/weskaggs/plug-ins/psd/psd-layer-res-load.c
   branches/weskaggs/plug-ins/psd/psd-layer-res-load.h
   branches/weskaggs/plug-ins/psd/psd-load.c
   branches/weskaggs/plug-ins/psd/psd-thumb-load.c
   branches/weskaggs/plug-ins/psd/psd-util.c
   branches/weskaggs/plug-ins/psd/psd-util.h
   branches/weskaggs/plug-ins/psd/psd.c
   branches/weskaggs/plug-ins/psd/psd.h
   branches/weskaggs/plug-ins/pygimp/pygimp-image.c
   branches/weskaggs/plug-ins/pygimp/pygimp-vectors.c
   branches/weskaggs/plug-ins/script-fu/ftx/ftx.c
   branches/weskaggs/po/ChangeLog
   branches/weskaggs/po/cs.po
   branches/weskaggs/tools/pdbgen/pdb/channel.pdb
   branches/weskaggs/tools/pdbgen/pdb/color.pdb
   branches/weskaggs/tools/pdbgen/pdb/layer.pdb

Modified: branches/weskaggs/INSTALL
==============================================================================
--- branches/weskaggs/INSTALL	(original)
+++ branches/weskaggs/INSTALL	Thu Jan 10 03:08:46 2008
@@ -173,11 +173,14 @@
   --without-alsa.  If you don't want to compile ALSA support into the
      MIDI input controller module, you can use the --without-alsa option.
 
+  --without-dbus.  If you want to build without D-Bus support, you can
+     pass --without-dbus to the configure script.
+
   --without-linux-input.  If you don't want to compile the Linux Input
      controller module, you can use the --without-linux-input option.
 
-  --without-dbus.  If you want to build without D-Bus support, you can
-     pass --without-dbus to the configure script.
+  --without-hal.  If you want to build the Linux Input controller module
+     without HAL support, you can use the --without-hal option.
 
   --with-gif-compression=[lzw|rle|none].  Allows to tune the compression
      algorithm used by the GIF plug-in. If you are afraid of Unisys' LZW

Modified: branches/weskaggs/app/actions/channels-commands.c
==============================================================================
--- branches/weskaggs/app/actions/channels-commands.c	(original)
+++ branches/weskaggs/app/actions/channels-commands.c	Thu Jan 10 03:08:46 2008
@@ -259,8 +259,7 @@
 
       new_channel =
         GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (channel),
-                                           G_TYPE_FROM_INSTANCE (channel),
-                                           TRUE));
+                                           G_TYPE_FROM_INSTANCE (channel)));
     }
 
   gimp_image_add_channel (image, new_channel, -1);
@@ -339,8 +338,7 @@
 
           new_channel =
             GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (selection),
-                                               GIMP_TYPE_CHANNEL,
-                                               FALSE));
+                                               GIMP_TYPE_CHANNEL));
 
           gimp_object_set_name (GIMP_OBJECT (new_channel), channel_name);
           gimp_channel_set_color (new_channel, &channel_color, FALSE);

Modified: branches/weskaggs/app/actions/layers-commands.c
==============================================================================
--- branches/weskaggs/app/actions/layers-commands.c	(original)
+++ branches/weskaggs/app/actions/layers-commands.c	Thu Jan 10 03:08:46 2008
@@ -414,10 +414,8 @@
   GimpLayer *new_layer;
   return_if_no_layer (image, layer, data);
 
-  new_layer =
-    GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (layer),
-                                     G_TYPE_FROM_INSTANCE (layer),
-                                     TRUE));
+  new_layer = GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (layer),
+                                               G_TYPE_FROM_INSTANCE (layer)));
   gimp_image_add_layer (image, new_layer, -1);
 
   gimp_image_flush (image);

Modified: branches/weskaggs/app/actions/vectors-commands.c
==============================================================================
--- branches/weskaggs/app/actions/vectors-commands.c	(original)
+++ branches/weskaggs/app/actions/vectors-commands.c	Thu Jan 10 03:08:46 2008
@@ -249,10 +249,8 @@
   GimpVectors *new_vectors;
   return_if_no_vectors (image, vectors, data);
 
-  new_vectors =
-    GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
-                                       G_TYPE_FROM_INSTANCE (vectors),
-                                       TRUE));
+  new_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
+                                                   G_TYPE_FROM_INSTANCE (vectors)));
   gimp_image_add_vectors (image, new_vectors, -1);
   gimp_image_flush (image);
 }

Modified: branches/weskaggs/app/config/gimpcoreconfig.c
==============================================================================
--- branches/weskaggs/app/config/gimpcoreconfig.c	(original)
+++ branches/weskaggs/app/config/gimpcoreconfig.c	Thu Jan 10 03:08:46 2008
@@ -89,7 +89,8 @@
   PROP_MIN_COLORS,
   PROP_COLOR_MANAGEMENT,
   PROP_COLOR_PROFILE_POLICY,
-  PROP_SAVE_DOCUMENT_HISTORY
+  PROP_SAVE_DOCUMENT_HISTORY,
+  PROP_USE_GEGL
 };
 
 
@@ -358,6 +359,15 @@
                                     SAVE_DOCUMENT_HISTORY_BLURB,
                                     TRUE,
                                     GIMP_PARAM_STATIC_STRINGS);
+
+  /*  not serialized  */
+  g_object_class_install_property (object_class, PROP_USE_GEGL,
+                                   g_param_spec_boolean ("use-gegl",
+                                                         "Use GEGL",
+                                                         "Use GEGL",
+                                                         TRUE,
+                                                         GIMP_PARAM_READWRITE |
+                                                         G_PARAM_CONSTRUCT));
 }
 
 static void
@@ -578,6 +588,9 @@
     case PROP_SAVE_DOCUMENT_HISTORY:
       core_config->save_document_history = g_value_get_boolean (value);
       break;
+    case PROP_USE_GEGL:
+      core_config->use_gegl = g_value_get_boolean (value);
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -718,6 +731,9 @@
     case PROP_SAVE_DOCUMENT_HISTORY:
       g_value_set_boolean (value, core_config->save_document_history);
       break;
+    case PROP_USE_GEGL:
+      g_value_set_boolean (value, core_config->use_gegl);
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);

Modified: branches/weskaggs/app/config/gimpcoreconfig.h
==============================================================================
--- branches/weskaggs/app/config/gimpcoreconfig.h	(original)
+++ branches/weskaggs/app/config/gimpcoreconfig.h	Thu Jan 10 03:08:46 2008
@@ -81,6 +81,7 @@
   GimpColorConfig        *color_management;
   GimpColorProfilePolicy  color_profile_policy;
   gboolean                save_document_history;
+  gboolean                use_gegl;
 };
 
 struct _GimpCoreConfigClass

Modified: branches/weskaggs/app/config/gimpdisplayconfig.c
==============================================================================
--- branches/weskaggs/app/config/gimpdisplayconfig.c	(original)
+++ branches/weskaggs/app/config/gimpdisplayconfig.c	Thu Jan 10 03:08:46 2008
@@ -38,8 +38,9 @@
 #include "gimp-intl.h"
 
 
-#define DEFAULT_ACTIVATE_ON_FOCUS   TRUE
-#define DEFAULT_MONITOR_RESOLUTION  96.0
+#define DEFAULT_ACTIVATE_ON_FOCUS    TRUE
+#define DEFAULT_MONITOR_RESOLUTION   96.0
+#define DEFAULT_MARCHING_ANTS_SPEED  200
 
 enum
 {
@@ -125,7 +126,7 @@
   GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_MARCHING_ANTS_SPEED,
                                 "marching-ants-speed",
                                 MARCHING_ANTS_SPEED_BLURB,
-                                10, 1000, 100,
+                                10, 1000, DEFAULT_MARCHING_ANTS_SPEED,
                                 GIMP_PARAM_STATIC_STRINGS);
   GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_RESIZE_WINDOWS_ON_ZOOM,
                                     "resize-windows-on-zoom",

Modified: branches/weskaggs/app/core/core-types.h
==============================================================================
--- branches/weskaggs/app/core/core-types.h	(original)
+++ branches/weskaggs/app/core/core-types.h	Thu Jan 10 03:08:46 2008
@@ -23,7 +23,7 @@
 #include "libgimpmodule/gimpmoduletypes.h"
 #include "libgimpthumb/gimpthumb-types.h"
 
-#include "base/base-types.h"
+#include "gegl/gegl-types.h"
 
 #include "core/core-enums.h"
 
@@ -165,15 +165,19 @@
 
 /*  functions  */
 
-typedef void     (* GimpInitStatusFunc)   (const gchar      *text1,
-                                           const gchar      *text2,
-                                           gdouble           percentage);
-
-typedef gboolean (* GimpObjectFilterFunc) (const GimpObject *object,
-                                           gpointer          user_data);
-
-typedef gint64   (* GimpMemsizeFunc)      (gpointer          instance,
-                                           gint64           *gui_size);
+typedef void     (* GimpInitStatusFunc)    (const gchar      *text1,
+                                            const gchar      *text2,
+                                            gdouble           percentage);
+
+typedef gboolean (* GimpObjectFilterFunc)  (const GimpObject *object,
+                                            gpointer          user_data);
+
+typedef gint64   (* GimpMemsizeFunc)       (gpointer          instance,
+                                            gint64           *gui_size);
+
+typedef void     (* GimpImageMapApplyFunc) (gpointer          apply_data,
+                                            PixelRegion      *srcPR,
+                                            PixelRegion      *destPR);
 
 
 /*  structs  */

Modified: branches/weskaggs/app/core/gimpchannel.c
==============================================================================
--- branches/weskaggs/app/core/gimpchannel.c	(original)
+++ branches/weskaggs/app/core/gimpchannel.c	Thu Jan 10 03:08:46 2008
@@ -77,8 +77,7 @@
 
 static gboolean   gimp_channel_is_attached   (GimpItem         *item);
 static GimpItem * gimp_channel_duplicate     (GimpItem         *item,
-                                              GType             new_type,
-                                              gboolean          add_alpha);
+                                              GType             new_type);
 static void       gimp_channel_convert       (GimpItem         *item,
                                               GimpImage        *dest_image);
 static void       gimp_channel_translate     (GimpItem         *item,
@@ -376,18 +375,13 @@
 
 static GimpItem *
 gimp_channel_duplicate (GimpItem *item,
-                        GType     new_type,
-                        gboolean  add_alpha)
+                        GType     new_type)
 {
   GimpItem *new_item;
 
   g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
 
-  if (g_type_is_a (new_type, GIMP_TYPE_CHANNEL))
-    add_alpha = FALSE;
-
-  new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
-                                                        add_alpha);
+  new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type);
 
   if (GIMP_IS_CHANNEL (new_item))
     {

Modified: branches/weskaggs/app/core/gimpdrawable-desaturate.c
==============================================================================
--- branches/weskaggs/app/core/gimpdrawable-desaturate.c	(original)
+++ branches/weskaggs/app/core/gimpdrawable-desaturate.c	Thu Jan 10 03:08:46 2008
@@ -27,6 +27,11 @@
 #include "base/pixel-processor.h"
 #include "base/pixel-region.h"
 
+/* temp */
+#include "config/gimpcoreconfig.h"
+#include "gimp.h"
+#include "gimpimage.h"
+
 #include "gimpdrawable.h"
 #include "gimpdrawable-desaturate.h"
 #include "gimpdrawable-operation.h"
@@ -34,9 +39,6 @@
 #include "gimp-intl.h"
 
 
-static gboolean enable_gegl = TRUE;
-
-
 static void  desaturate_region_lightness  (gpointer     data,
                                            PixelRegion *srcPR,
                                            PixelRegion *destPR);
@@ -58,7 +60,7 @@
   g_return_if_fail (gimp_drawable_is_rgb (drawable));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
 
-  if (enable_gegl)
+  if (GIMP_ITEM (drawable)->image->gimp->config->use_gegl)
     {
       GeglNode *desaturate;
 

Modified: branches/weskaggs/app/core/gimpdrawable-invert.c
==============================================================================
--- branches/weskaggs/app/core/gimpdrawable-invert.c	(original)
+++ branches/weskaggs/app/core/gimpdrawable-invert.c	Thu Jan 10 03:08:46 2008
@@ -27,6 +27,11 @@
 #include "base/pixel-processor.h"
 #include "base/pixel-region.h"
 
+/* temp */
+#include "config/gimpcoreconfig.h"
+#include "gimp.h"
+#include "gimpimage.h"
+
 #include "gimpdrawable.h"
 #include "gimpdrawable-invert.h"
 #include "gimpdrawable-operation.h"
@@ -35,9 +40,6 @@
 #include "gimp-intl.h"
 
 
-static gboolean enable_gegl = TRUE;
-
-
 void
 gimp_drawable_invert (GimpDrawable *drawable,
                       GimpProgress *progress)
@@ -46,7 +48,7 @@
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
   g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
 
-  if (enable_gegl)
+  if (GIMP_ITEM (drawable)->image->gimp->config->use_gegl)
     {
       GeglNode *invert;
 

Modified: branches/weskaggs/app/core/gimpdrawable.c
==============================================================================
--- branches/weskaggs/app/core/gimpdrawable.c	(original)
+++ branches/weskaggs/app/core/gimpdrawable.c	Thu Jan 10 03:08:46 2008
@@ -75,8 +75,7 @@
 static void       gimp_drawable_invalidate_preview (GimpViewable      *viewable);
 
 static GimpItem * gimp_drawable_duplicate          (GimpItem          *item,
-                                                    GType              new_type,
-                                                    gboolean           add_alpha);
+                                                    GType              new_type);
 static void       gimp_drawable_translate          (GimpItem          *item,
                                                     gint               offset_x,
                                                     gint               offset_y,
@@ -307,36 +306,28 @@
 
 static GimpItem *
 gimp_drawable_duplicate (GimpItem *item,
-                         GType     new_type,
-                         gboolean  add_alpha)
+                         GType     new_type)
 {
   GimpItem *new_item;
 
   g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
 
-  new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
-                                                        add_alpha);
+  new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type);
 
   if (GIMP_IS_DRAWABLE (new_item))
     {
       GimpDrawable  *drawable     = GIMP_DRAWABLE (item);
       GimpDrawable  *new_drawable = GIMP_DRAWABLE (new_item);
-      GimpImageType  new_image_type;
       PixelRegion    srcPR;
       PixelRegion    destPR;
 
-      if (add_alpha)
-        new_image_type = gimp_drawable_type_with_alpha (drawable);
-      else
-        new_image_type = gimp_drawable_type (drawable);
-
       gimp_drawable_configure (new_drawable,
                                gimp_item_get_image (item),
                                item->offset_x,
                                item->offset_y,
                                gimp_item_width  (item),
                                gimp_item_height (item),
-                               new_image_type,
+                               gimp_drawable_type (drawable),
                                GIMP_OBJECT (new_drawable)->name);
 
       pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
@@ -350,10 +341,7 @@
                          gimp_item_height (new_item),
                          TRUE);
 
-      if (new_image_type == drawable->type)
-        copy_region (&srcPR, &destPR);
-      else
-        add_alpha_region (&srcPR, &destPR);
+      copy_region (&srcPR, &destPR);
     }
 
   return new_item;

Modified: branches/weskaggs/app/core/gimpimage-duplicate.c
==============================================================================
--- branches/weskaggs/app/core/gimpimage-duplicate.c	(original)
+++ branches/weskaggs/app/core/gimpimage-duplicate.c	Thu Jan 10 03:08:46 2008
@@ -114,8 +114,7 @@
 
       new_layer = GIMP_LAYER (gimp_item_convert (GIMP_ITEM (layer),
                                                  new_image,
-                                                 G_TYPE_FROM_INSTANCE (layer),
-                                                 FALSE));
+                                                 G_TYPE_FROM_INSTANCE (layer)));
 
       /*  Make sure the copied layer doesn't say: "<old layer> copy"  */
       gimp_object_set_name (GIMP_OBJECT (new_layer),
@@ -149,11 +148,9 @@
       GimpChannel *channel = list->data;
       GimpChannel *new_channel;
 
-      new_channel =
-        GIMP_CHANNEL (gimp_item_convert (GIMP_ITEM (channel),
-                                         new_image,
-                                         G_TYPE_FROM_INSTANCE (channel),
-                                         FALSE));
+      new_channel = GIMP_CHANNEL (gimp_item_convert (GIMP_ITEM (channel),
+                                                     new_image,
+                                                     G_TYPE_FROM_INSTANCE (channel)));
 
       /*  Make sure the copied channel doesn't say: "<old channel> copy"  */
       gimp_object_set_name (GIMP_OBJECT (new_channel),
@@ -176,11 +173,9 @@
       GimpVectors *vectors = list->data;
       GimpVectors *new_vectors;
 
-      new_vectors =
-        GIMP_VECTORS (gimp_item_convert (GIMP_ITEM (vectors),
-                                         new_image,
-                                         G_TYPE_FROM_INSTANCE (vectors),
-                                         FALSE));
+      new_vectors = GIMP_VECTORS (gimp_item_convert (GIMP_ITEM (vectors),
+                                                     new_image,
+                                                     G_TYPE_FROM_INSTANCE (vectors)));
 
       /*  Make sure the copied vectors doesn't say: "<old vectors> copy"  */
       gimp_object_set_name (GIMP_OBJECT (new_vectors),

Modified: branches/weskaggs/app/core/gimpimage-merge.c
==============================================================================
--- branches/weskaggs/app/core/gimpimage-merge.c	(original)
+++ branches/weskaggs/app/core/gimpimage-merge.c	Thu Jan 10 03:08:46 2008
@@ -257,10 +257,8 @@
       vectors = GIMP_VECTORS (cur_item->data);
 
       name = g_strdup (gimp_object_get_name (GIMP_OBJECT (vectors)));
-      target_vectors = GIMP_VECTORS (
-                            gimp_item_duplicate (GIMP_ITEM (vectors),
-                                                 GIMP_TYPE_VECTORS,
-                                                 FALSE));
+      target_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
+                                                          GIMP_TYPE_VECTORS));
       pos = gimp_image_get_vectors_index (image, vectors);
       gimp_image_remove_vectors (image, vectors);
       cur_item = cur_item->next;

Modified: branches/weskaggs/app/core/gimpimage-quick-mask.c
==============================================================================
--- branches/weskaggs/app/core/gimpimage-quick-mask.c	(original)
+++ branches/weskaggs/app/core/gimpimage-quick-mask.c	Thu Jan 10 03:08:46 2008
@@ -104,8 +104,7 @@
               /* if selection */
 
               mask = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (selection),
-                                                        GIMP_TYPE_CHANNEL,
-                                                        FALSE));
+                                                        GIMP_TYPE_CHANNEL));
 
               /* Clear the selection */
               gimp_channel_clear (selection, NULL, TRUE);

Modified: branches/weskaggs/app/core/gimpimagemap.c
==============================================================================
--- branches/weskaggs/app/core/gimpimagemap.c	(original)
+++ branches/weskaggs/app/core/gimpimagemap.c	Thu Jan 10 03:08:46 2008
@@ -36,6 +36,11 @@
 #include "gimppickable.h"
 #include "gimpviewable.h"
 
+#ifdef __GNUC__
+#warning FIXME: gegl_node_add_child() needs to be public
+#endif
+GeglNode * gegl_node_add_child (GeglNode *self,
+                                GeglNode *child);
 
 enum
 {
@@ -290,15 +295,18 @@
 }
 
 GimpImageMap *
-gimp_image_map_new (GimpDrawable *drawable,
-                    const gchar  *undo_desc,
-                    GeglNode     *operation)
+gimp_image_map_new (GimpDrawable          *drawable,
+                    const gchar           *undo_desc,
+                    GeglNode              *operation,
+                    GimpImageMapApplyFunc  apply_func,
+                    gpointer               apply_data)
 {
   GimpImageMap *image_map;
 
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
   g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
   g_return_val_if_fail (operation == NULL || GEGL_IS_NODE (operation), NULL);
+  g_return_val_if_fail (operation != NULL || apply_func != NULL, NULL);
 
   image_map = g_object_new (GIMP_TYPE_IMAGE_MAP, NULL);
 
@@ -308,25 +316,25 @@
   if (operation)
     image_map->operation = g_object_ref (operation);
 
+  image_map->apply_func = apply_func;
+  image_map->apply_data = apply_data;
+
   gimp_viewable_preview_freeze (GIMP_VIEWABLE (drawable));
 
   return image_map;
 }
 
 void
-gimp_image_map_apply (GimpImageMap          *image_map,
-                      GimpImageMapApplyFunc  apply_func,
-                      gpointer               apply_data)
+gimp_image_map_apply (GimpImageMap        *image_map,
+                      const GeglRectangle *visible)
 {
   GeglRectangle rect;
-  gint          undo_offset_x, undo_offset_y;
-  gint          undo_width, undo_height;
+  gint          undo_offset_x;
+  gint          undo_offset_y;
+  gint          undo_width;
+  gint          undo_height;
 
   g_return_if_fail (GIMP_IS_IMAGE_MAP (image_map));
-  g_return_if_fail (apply_func != NULL);
-
-  image_map->apply_func = apply_func;
-  image_map->apply_data = apply_data;
 
   /*  If we're still working, remove the timer  */
   if (image_map->idle_id)
@@ -419,8 +427,6 @@
     {
       if (! image_map->gegl)
         {
-          GObject *sink_operation;
-
           image_map->gegl = gegl_node_new ();
 
           image_map->input =
@@ -433,9 +439,6 @@
                                  "operation", "shift",
                                  NULL);
 
-#ifdef __GNUC__
-#warning FIXME: gegl_node_add_child() needs to be public
-#endif
           gegl_node_add_child (image_map->gegl, image_map->operation);
 
           image_map->output =
@@ -443,15 +446,19 @@
                                  "operation", "gimp-tilemanager-sink",
                                  NULL);
 
-          g_object_get (image_map->output,
-                        "gegl-operation", &sink_operation,
-                        NULL);
-
-          g_signal_connect (sink_operation, "data-written",
-                            G_CALLBACK (gimp_image_map_data_written),
-                            image_map);
+          {
+            GObject *sink_operation;
+
+            g_object_get (image_map->output,
+                          "gegl-operation", &sink_operation,
+                          NULL);
+
+            g_signal_connect (sink_operation, "data-written",
+                              G_CALLBACK (gimp_image_map_data_written),
+                              image_map);
 
-          g_object_unref (sink_operation);
+            g_object_unref (sink_operation);
+          }
 
           gegl_node_link_many (image_map->input,
                                image_map->shift,
@@ -462,6 +469,7 @@
 
       gegl_node_set (image_map->input,
                      "tile-manager", image_map->undo_tiles,
+                     "linear",       TRUE,
                      NULL);
 
       gegl_node_set (image_map->shift,
@@ -470,8 +478,8 @@
                      NULL);
 
       gegl_node_set (image_map->output,
-                     "tile-manager",
-                     gimp_drawable_get_shadow_tiles (image_map->drawable),
+                     "tile-manager", gimp_drawable_get_shadow_tiles (image_map->drawable),
+                     "linear",       TRUE,
                      NULL);
 
       image_map->processor = gegl_node_new_processor (image_map->output,

Modified: branches/weskaggs/app/core/gimpimagemap.h
==============================================================================
--- branches/weskaggs/app/core/gimpimagemap.h	(original)
+++ branches/weskaggs/app/core/gimpimagemap.h	Thu Jan 10 03:08:46 2008
@@ -23,11 +23,6 @@
 #include "gimpobject.h"
 
 
-typedef void (* GimpImageMapApplyFunc) (gpointer     data,
-                                        PixelRegion *srcPR,
-                                        PixelRegion *destPR);
-
-
 #define GIMP_TYPE_IMAGE_MAP            (gimp_image_map_get_type ())
 #define GIMP_IMAGE_MAP(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_IMAGE_MAP, GimpImageMap))
 #define GIMP_IMAGE_MAP_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_IMAGE_MAP, GimpImageMapClass))
@@ -57,11 +52,12 @@
 
 GimpImageMap * gimp_image_map_new          (GimpDrawable          *drawable,
                                             const gchar           *undo_desc,
-                                            GeglNode              *operation);
-
-void           gimp_image_map_apply        (GimpImageMap          *image_map,
+                                            GeglNode              *operation,
                                             GimpImageMapApplyFunc  apply_func,
                                             gpointer               apply_data);
+
+void           gimp_image_map_apply        (GimpImageMap          *image_map,
+                                            const GeglRectangle   *visible);
 void           gimp_image_map_commit       (GimpImageMap          *image_map);
 void           gimp_image_map_clear        (GimpImageMap          *image_map);
 void           gimp_image_map_abort        (GimpImageMap          *image_map);

Modified: branches/weskaggs/app/core/gimpitem.c
==============================================================================
--- branches/weskaggs/app/core/gimpitem.c	(original)
+++ branches/weskaggs/app/core/gimpitem.c	Thu Jan 10 03:08:46 2008
@@ -78,8 +78,7 @@
                                                gint64        *gui_size);
 
 static GimpItem * gimp_item_real_duplicate    (GimpItem      *item,
-                                               GType          new_type,
-                                               gboolean       add_alpha);
+                                               GType          new_type);
 static void       gimp_item_real_convert      (GimpItem      *item,
                                                GimpImage     *dest_image);
 static gboolean   gimp_item_real_rename       (GimpItem      *item,
@@ -289,8 +288,7 @@
 
 static GimpItem *
 gimp_item_real_duplicate (GimpItem *item,
-                          GType     new_type,
-                          gboolean  add_alpha)
+                          GType     new_type)
 {
   GimpItem *new_item;
   gchar    *new_name;
@@ -525,22 +523,20 @@
 
 /**
  * gimp_item_duplicate:
- * @item:      The #GimpItem to duplicate.
- * @new_type:  The type to make the new item.
- * @add_alpha: #TRUE if an alpha channel should be added to the new item.
+ * @item:     The #GimpItem to duplicate.
+ * @new_type: The type to make the new item.
  *
  * Returns: the newly created item.
  */
 GimpItem *
 gimp_item_duplicate (GimpItem *item,
-                     GType     new_type,
-                     gboolean  add_alpha)
+                     GType     new_type)
 {
   g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
   g_return_val_if_fail (GIMP_IS_IMAGE (item->image), NULL);
   g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_ITEM), NULL);
 
-  return GIMP_ITEM_GET_CLASS (item)->duplicate (item, new_type, add_alpha);
+  return GIMP_ITEM_GET_CLASS (item)->duplicate (item, new_type);
 }
 
 /**
@@ -548,15 +544,13 @@
  * @item:       The #GimpItem to convert.
  * @dest_image: The #GimpImage in which to place the converted item.
  * @new_type:   The type to convert the item to.
- * @add_alpha:  #TRUE if an alpha channel should be added to the converted item.
  *
  * Returns: the new item that results from the conversion.
  */
 GimpItem *
 gimp_item_convert (GimpItem  *item,
                    GimpImage *dest_image,
-                   GType      new_type,
-                   gboolean   add_alpha)
+                   GType      new_type)
 {
   GimpItem *new_item;
 
@@ -565,7 +559,7 @@
   g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
   g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_ITEM), NULL);
 
-  new_item = gimp_item_duplicate (item, new_type, add_alpha);
+  new_item = gimp_item_duplicate (item, new_type);
 
   if (new_item)
     GIMP_ITEM_GET_CLASS (new_item)->convert (new_item, dest_image);

Modified: branches/weskaggs/app/core/gimpitem.h
==============================================================================
--- branches/weskaggs/app/core/gimpitem.h	(original)
+++ branches/weskaggs/app/core/gimpitem.h	Thu Jan 10 03:08:46 2008
@@ -65,8 +65,7 @@
   /*  virtual functions  */
   gboolean   (* is_attached)  (GimpItem               *item);
   GimpItem * (* duplicate)    (GimpItem               *item,
-                               GType                   new_type,
-                               gboolean                add_alpha);
+                               GType                   new_type);
   void       (* convert)      (GimpItem               *item,
                                GimpImage              *dest_image);
   gboolean   (* rename)       (GimpItem               *item,
@@ -142,12 +141,10 @@
                                             gint                height,
                                             const gchar        *name);
 GimpItem      * gimp_item_duplicate        (GimpItem           *item,
-                                            GType               new_type,
-                                            gboolean            add_alpha);
+                                            GType               new_type);
 GimpItem      * gimp_item_convert          (GimpItem           *item,
                                             GimpImage          *dest_image,
-                                            GType               new_type,
-                                            gboolean            add_alpha);
+                                            GType               new_type);
 
 gboolean        gimp_item_rename           (GimpItem           *item,
                                             const gchar        *new_name,

Modified: branches/weskaggs/app/core/gimplayer.c
==============================================================================
--- branches/weskaggs/app/core/gimplayer.c	(original)
+++ branches/weskaggs/app/core/gimplayer.c	Thu Jan 10 03:08:46 2008
@@ -93,8 +93,7 @@
 static void       gimp_layer_removed            (GimpItem           *item);
 static gboolean   gimp_layer_is_attached        (GimpItem           *item);
 static GimpItem * gimp_layer_duplicate          (GimpItem           *item,
-                                                 GType               new_type,
-                                                 gboolean            add_alpha);
+                                                 GType               new_type);
 static void       gimp_layer_convert            (GimpItem           *item,
                                                  GimpImage          *dest_image);
 static gboolean   gimp_layer_rename             (GimpItem           *item,
@@ -156,10 +155,10 @@
                                                  gint                y);
 
 static void       gimp_layer_transform_color    (GimpImage          *image,
-                                                 PixelRegion        *layerPR,
-                                                 PixelRegion        *bufPR,
-                                                 GimpImageType       dest_type,
-                                                 GimpImageType       src_type);
+                                                 PixelRegion        *srcPR,
+                                                 GimpImageType       src_type,
+                                                 PixelRegion        *destPR,
+                                                 GimpImageType       dest_type);
 
 static void       gimp_layer_layer_mask_update  (GimpDrawable       *layer_mask,
                                                  gint                x,
@@ -512,15 +511,13 @@
 
 static GimpItem *
 gimp_layer_duplicate (GimpItem *item,
-                      GType     new_type,
-                      gboolean  add_alpha)
+                      GType     new_type)
 {
   GimpItem *new_item;
 
   g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
 
-  new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
-                                                        add_alpha);
+  new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type);
 
   if (GIMP_IS_LAYER (new_item))
     {
@@ -537,11 +534,11 @@
       /*  duplicate the layer mask if necessary  */
       if (layer->mask)
         {
-          GimpItem *new_mask =
-            gimp_item_duplicate (GIMP_ITEM (layer->mask),
-                                 G_TYPE_FROM_INSTANCE (layer->mask),
-                                 FALSE);
-          gimp_layer_add_mask (new_layer, GIMP_LAYER_MASK (new_mask), FALSE);
+          GimpItem *mask;
+
+          mask = gimp_item_duplicate (GIMP_ITEM (layer->mask),
+                                      G_TYPE_FROM_INSTANCE (layer->mask));
+          gimp_layer_add_mask (new_layer, GIMP_LAYER_MASK (mask), FALSE);
         }
     }
 
@@ -570,7 +567,7 @@
       if (gimp_drawable_has_alpha (drawable))
         new_type = GIMP_IMAGE_TYPE_WITH_ALPHA (new_type);
 
-      new_tiles = tile_manager_new (gimp_item_width (item),
+      new_tiles = tile_manager_new (gimp_item_width  (item),
                                     gimp_item_height (item),
                                     GIMP_IMAGE_TYPE_BYTES (new_type));
 
@@ -595,19 +592,18 @@
 
             pixel_region_init (&layerPR, gimp_drawable_get_tiles (drawable),
                                0, 0,
-                               gimp_item_width (item),
+                               gimp_item_width  (item),
                                gimp_item_height (item),
                                FALSE);
             pixel_region_init (&newPR, new_tiles,
                                0, 0,
-                               gimp_item_width (item),
+                               gimp_item_width  (item),
                                gimp_item_height (item),
                                TRUE);
 
             gimp_layer_transform_color (dest_image,
-                                        &newPR, &layerPR,
-                                        new_type,
-                                        gimp_drawable_type (drawable));
+                                        &layerPR, gimp_drawable_type (drawable),
+                                        &newPR,   new_type);
           }
           break;
         }
@@ -912,43 +908,43 @@
 
 static void
 gimp_layer_transform_color (GimpImage     *image,
-                            PixelRegion   *layerPR,
-                            PixelRegion   *bufPR,
-                            GimpImageType  dest_type,
-                            GimpImageType  src_type)
+                            PixelRegion   *srcPR,
+                            GimpImageType  src_type,
+                            PixelRegion   *destPR,
+                            GimpImageType  dest_type)
 {
   GimpImageBaseType base_type = GIMP_IMAGE_TYPE_BASE_TYPE (src_type);
   gboolean          alpha     = GIMP_IMAGE_TYPE_HAS_ALPHA (src_type);
   gpointer          pr;
 
-  for (pr = pixel_regions_register (2, layerPR, bufPR);
+  for (pr = pixel_regions_register (2, srcPR, destPR);
        pr != NULL;
        pr = pixel_regions_process (pr))
     {
-      const guchar *src  = bufPR->data;
-      guchar       *dest = layerPR->data;
-      gint          h    = layerPR->h;
+      const guchar *src  = srcPR->data;
+      guchar       *dest = destPR->data;
+      gint          h    = destPR->h;
 
       while (h--)
         {
           const guchar *s = src;
           guchar       *d = dest;
-          gint i;
+          gint          i;
 
-          for (i = 0; i < layerPR->w; i++)
+          for (i = 0; i < destPR->w; i++)
             {
               gimp_image_transform_color (image, dest_type, d, base_type, s);
 
               /*  alpha channel  */
-              d[layerPR->bytes - 1] = (alpha ?
-                                       s[bufPR->bytes - 1] : OPAQUE_OPACITY);
+              d[destPR->bytes - 1] = (alpha ?
+                                      s[srcPR->bytes - 1] : OPAQUE_OPACITY);
 
-              s += bufPR->bytes;
-              d += layerPR->bytes;
+              s += srcPR->bytes;
+              d += destPR->bytes;
             }
 
-          src  += bufPR->rowstride;
-          dest += layerPR->rowstride;
+          src  += srcPR->rowstride;
+          dest += destPR->rowstride;
         }
     }
 }
@@ -1170,8 +1166,9 @@
           break;
         case GIMP_GRAY_IMAGE:
         case GIMP_GRAYA_IMAGE:
-          gimp_layer_transform_color (dest_image, &layerPR, region,
-                                      type, src_type);
+          gimp_layer_transform_color (dest_image,
+                                      region,   src_type,
+                                      &layerPR, type);
           break;
         default:
           g_warning ("%s: unhandled type conversion", G_STRFUNC);
@@ -1196,8 +1193,9 @@
         {
         case GIMP_RGB_IMAGE:
         case GIMP_RGBA_IMAGE:
-          gimp_layer_transform_color (dest_image, &layerPR, region,
-                                      type, src_type);
+          gimp_layer_transform_color (dest_image,
+                                      region,   src_type,
+                                      &layerPR, type);
           break;
         case GIMP_GRAYA_IMAGE:
           copy_region (region, &layerPR);
@@ -1220,13 +1218,11 @@
         {
         case GIMP_RGB_IMAGE:
         case GIMP_RGBA_IMAGE:
-          gimp_layer_transform_color (dest_image, &layerPR, region,
-                                      type, src_type);
-          break;
         case GIMP_GRAY_IMAGE:
         case GIMP_GRAYA_IMAGE:
-          gimp_layer_transform_color (dest_image, &layerPR, region,
-                                      type, src_type);
+          gimp_layer_transform_color (dest_image,
+                                      region,   src_type,
+                                      &layerPR, type);
           break;
         default:
           g_warning ("%s: unhandled type conversion", G_STRFUNC);

Modified: branches/weskaggs/app/core/gimplayermask.c
==============================================================================
--- branches/weskaggs/app/core/gimplayermask.c	(original)
+++ branches/weskaggs/app/core/gimplayermask.c	Thu Jan 10 03:08:46 2008
@@ -47,13 +47,13 @@
 
 static gboolean   gimp_layer_mask_is_attached  (GimpItem     *item);
 static GimpItem * gimp_layer_mask_duplicate    (GimpItem     *item,
-                                                GType         new_type,
-                                                gboolean      add_alpha);
+                                                GType         new_type);
 static gboolean   gimp_layer_mask_rename       (GimpItem     *item,
                                                 const gchar  *new_name,
                                                 const gchar  *undo_desc,
                                                 GError      **error);
 
+static void       gimp_layer_mask_real_edit_changed (GimpLayerMask *layer_mask);
 
 G_DEFINE_TYPE (GimpLayerMask, gimp_layer_mask, GIMP_TYPE_CHANNEL)
 
@@ -97,6 +97,8 @@
 
   viewable_class->default_stock_id = "gimp-layer-mask";
 
+  klass->edit_changed        = gimp_layer_mask_real_edit_changed;
+
   item_class->is_attached    = gimp_layer_mask_is_attached;
   item_class->duplicate      = gimp_layer_mask_duplicate;
   item_class->rename         = gimp_layer_mask_rename;
@@ -126,15 +128,13 @@
 
 static GimpItem *
 gimp_layer_mask_duplicate (GimpItem *item,
-                           GType     new_type,
-                           gboolean  add_alpha)
+                           GType     new_type)
 {
   GimpItem *new_item;
 
   g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
 
-  new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
-                                                        add_alpha);
+  new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type);
 
   if (GIMP_IS_LAYER_MASK (new_item))
     {
@@ -281,6 +281,13 @@
   return layer_mask->edit_mask;
 }
 
+static void
+gimp_layer_mask_real_edit_changed (GimpLayerMask *layer_mask)
+{
+  gimp_image_selection_control (GIMP_ITEM (layer_mask)->image,
+                                GIMP_SELECTION_LAYER_ON);
+}
+
 void
 gimp_layer_mask_set_show (GimpLayerMask *layer_mask,
                           gboolean       show,

Modified: branches/weskaggs/app/core/gimpselection.c
==============================================================================
--- branches/weskaggs/app/core/gimpselection.c	(original)
+++ branches/weskaggs/app/core/gimpselection.c	Thu Jan 10 03:08:46 2008
@@ -582,8 +582,7 @@
   image = gimp_item_get_image (GIMP_ITEM (selection));
 
   new_channel = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (selection),
-                                                   GIMP_TYPE_CHANNEL,
-                                                   FALSE));
+                                                   GIMP_TYPE_CHANNEL));
 
   /*  saved selections are not visible by default  */
   gimp_item_set_visible (GIMP_ITEM (new_channel), FALSE, FALSE);

Modified: branches/weskaggs/app/core/makefile.msc
==============================================================================
--- branches/weskaggs/app/core/makefile.msc	(original)
+++ branches/weskaggs/app/core/makefile.msc	Thu Jan 10 03:08:46 2008
@@ -9,7 +9,7 @@
 
 PKG_LINK = \
 	$(GLIB_LIBS) $(GTK_PIXBUF_LIBS) $(INTL_LIBS) $(LIBART_LIBS) \
-	$(PANGOWIN32_LIBS) $(GDK_PIXBUF_LIBS) \
+	$(PANGOWIN32_LIBS) $(GDK_PIXBUF_LIBS) $(GEGL_LIBS) \
 #	$(PANGOFT2_LIBS) \
 	\
 	..\..\regexrepl\regexrepl.lib \
@@ -68,6 +68,7 @@
 	gimpcontext.obj \
 	gimpcoords.obj \
 	gimpcurve.obj \
+	gimpcurve-load.obj \
 	gimpcurve-save.obj \
 	gimpdashpattern.obj \
 	gimpdata.obj \
@@ -84,6 +85,7 @@
 	gimpdrawable-invert.obj \
 	gimpdrawable-levels.obj \
 	gimpdrawable-offset.obj \
+	gimpdrawable-operation.obj \
 	gimpdrawable-preview.obj \
 	gimpdrawable-stroke.obj \
 	gimpdrawable-transform.obj \
@@ -191,6 +193,7 @@
 	-I$(PRJ_TOP)/app \
 	$(GTK2_CFLAGS) \
 	$(LIBART_CFLAGS) \
+	$(GEGL_CFLAGS)
 
 DEFINES = \
 	-DGIMP_COMPILATION \

Modified: branches/weskaggs/app/display/gimpcanvas.c
==============================================================================
--- branches/weskaggs/app/display/gimpcanvas.c	(original)
+++ branches/weskaggs/app/display/gimpcanvas.c	Thu Jan 10 03:08:46 2008
@@ -347,6 +347,7 @@
     case GIMP_CANVAS_STYLE_LAYER_BOUNDARY:
     case GIMP_CANVAS_STYLE_GUIDE_NORMAL:
     case GIMP_CANVAS_STYLE_GUIDE_ACTIVE:
+    case GIMP_CANVAS_STYLE_LAYER_MASK_ACTIVE:
       mask |= GDK_GC_CAP_STYLE | GDK_GC_FILL | GDK_GC_STIPPLE;
       values.cap_style = GDK_CAP_NOT_LAST;
       values.fill      = GDK_OPAQUE_STIPPLED;
@@ -433,6 +434,16 @@
       bg.blue  = 0x0;
       break;
 
+    case GIMP_CANVAS_STYLE_LAYER_MASK_ACTIVE:
+      fg.red   = 0x0;
+      fg.green = 0x0;
+      fg.blue  = 0x0;
+
+      bg.red   = 0x0;
+      bg.green = 0xffff;
+      bg.blue  = 0x0;
+      break;
+
     case GIMP_CANVAS_STYLE_SAMPLE_POINT_NORMAL:
       fg.red   = 0x0;
       fg.green = 0x7f7f;

Modified: branches/weskaggs/app/display/gimpcanvas.h
==============================================================================
--- branches/weskaggs/app/display/gimpcanvas.h	(original)
+++ branches/weskaggs/app/display/gimpcanvas.h	Thu Jan 10 03:08:46 2008
@@ -38,6 +38,7 @@
   GIMP_CANVAS_STYLE_GUIDE_ACTIVE,
   GIMP_CANVAS_STYLE_SAMPLE_POINT_NORMAL,
   GIMP_CANVAS_STYLE_SAMPLE_POINT_ACTIVE,
+  GIMP_CANVAS_STYLE_LAYER_MASK_ACTIVE,
   GIMP_CANVAS_STYLE_CUSTOM,
   GIMP_CANVAS_NUM_STYLES
 } GimpCanvasStyle;

Modified: branches/weskaggs/app/display/gimpdisplayshell-dnd.c
==============================================================================
--- branches/weskaggs/app/display/gimpdisplayshell-dnd.c	(original)
+++ branches/weskaggs/app/display/gimpdisplayshell-dnd.c	Thu Jan 10 03:08:46 2008
@@ -204,7 +204,7 @@
   else
     new_type = GIMP_TYPE_LAYER;
 
-  new_item = gimp_item_convert (GIMP_ITEM (viewable), image, new_type, TRUE);
+  new_item = gimp_item_convert (GIMP_ITEM (viewable), image, new_type);
 
   if (new_item)
     {
@@ -256,8 +256,8 @@
   if (gimp_image_is_scratch (image))
     return;
 
-  new_item = gimp_item_convert (GIMP_ITEM (viewable), image,
-                                G_TYPE_FROM_INSTANCE (viewable), TRUE);
+  new_item = gimp_item_convert (GIMP_ITEM (viewable),
+                                image, G_TYPE_FROM_INSTANCE (viewable));
 
   if (new_item)
     {
@@ -514,9 +514,8 @@
 
   channel = gimp_channel_new_from_component (image, component, NULL, NULL);
 
-  new_item = gimp_item_convert (GIMP_ITEM (channel), dest_image,
-                                GIMP_TYPE_LAYER, TRUE);
-
+  new_item = gimp_item_convert (GIMP_ITEM (channel),
+                                dest_image, GIMP_TYPE_LAYER);
   g_object_unref (channel);
 
   if (new_item)

Modified: branches/weskaggs/app/display/gimpdisplayshell-selection.c
==============================================================================
--- branches/weskaggs/app/display/gimpdisplayshell-selection.c	(original)
+++ branches/weskaggs/app/display/gimpdisplayshell-selection.c	Thu Jan 10 03:08:46 2008
@@ -28,6 +28,7 @@
 
 #include "core/gimp.h"
 #include "core/gimpchannel.h"
+#include "core/gimplayermask.h"
 #include "core/gimpimage.h"
 
 #include "gimpcanvas.h"
@@ -75,6 +76,7 @@
 static void      selection_draw           (Selection      *selection);
 static void      selection_undraw         (Selection      *selection);
 static void      selection_layer_undraw   (Selection      *selection);
+static void      selection_layer_draw     (Selection      *selection);
 
 static void      selection_add_point      (GdkPoint       *points[8],
                                            gint            max_npoints[8],
@@ -178,6 +180,10 @@
           selection_layer_undraw (selection);
           break;
 
+        case GIMP_SELECTION_LAYER_ON:
+          selection_layer_draw (selection);
+          break;
+
         case GIMP_SELECTION_ON:
           selection_start (selection);
           break;
@@ -366,10 +372,14 @@
 static void
 selection_layer_draw (Selection *selection)
 {
-  GimpCanvas *canvas = GIMP_CANVAS (selection->shell->canvas);
+  GimpCanvas   *canvas   = GIMP_CANVAS (selection->shell->canvas);
+  GimpImage    *image    = selection->shell->display->image;
+  GimpDrawable *drawable = gimp_image_get_active_drawable (image);
 
   if (selection->segs_layer)
-    gimp_canvas_draw_segments (canvas, GIMP_CANVAS_STYLE_LAYER_BOUNDARY,
+    gimp_canvas_draw_segments (canvas, GIMP_IS_LAYER_MASK (drawable) ?
+                               GIMP_CANVAS_STYLE_LAYER_MASK_ACTIVE:
+                               GIMP_CANVAS_STYLE_LAYER_BOUNDARY,
                                selection->segs_layer,
                                selection->num_segs_layer);
 }
@@ -697,9 +707,10 @@
 
 
       if (selection->segs_in)
-        selection->timeout = g_timeout_add (config->marching_ants_speed,
-                                            (GSourceFunc) selection_timeout,
-                                            selection);
+        selection->timeout = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
+                                                 config->marching_ants_speed,
+                                                 (GSourceFunc) selection_timeout,
+                                                  selection, NULL);
     }
 
   return FALSE;

Modified: branches/weskaggs/app/display/makefile.msc
==============================================================================
--- branches/weskaggs/app/display/makefile.msc	(original)
+++ branches/weskaggs/app/display/makefile.msc	Thu Jan 10 03:08:46 2008
@@ -13,7 +13,7 @@
 	-FImsvc_recommended_pragmas.h \
 	-I$(PRJ_TOP) \
 	-I$(PRJ_TOP)/app \
-	$(GTK2_CFLAGS) \
+	$(GTK2_CFLAGS)
 
 DEFINES = \
 	-DG_LOG_DOMAIN=\"Gimp-Display\"

Modified: branches/weskaggs/app/file/file-open.c
==============================================================================
--- branches/weskaggs/app/file/file-open.c	(original)
+++ branches/weskaggs/app/file/file-open.c	Thu Jan 10 03:08:46 2008
@@ -67,7 +67,6 @@
 #include "plug-in/gimppluginerror.h"
 #include "plug-in/plug-in-icc-profile.h"
 
-
 #include "file-open.h"
 #include "file-procedure.h"
 #include "file-utils.h"
@@ -77,6 +76,9 @@
 
 static void  file_open_sanitize_image       (GimpImage    *image,
                                              gboolean      as_new);
+static void  file_open_convert_items        (GimpImage    *dest_image,
+                                             const gchar  *basename,
+                                             GList        *items);
 static void  file_open_handle_color_profile (GimpImage    *image,
                                              GimpContext  *context,
                                              GimpProgress *progress,
@@ -411,7 +413,7 @@
 
       gimp_image_undo_disable (new_image);
 
-      for (list = GIMP_LIST (new_image->layers)->list;
+      for (list = GIMP_LIST (gimp_image_get_layers (new_image))->list;
            list;
            list = g_list_next (list))
         {
@@ -443,31 +445,7 @@
         {
           gchar *basename = file_utils_uri_display_basename (uri);
 
-          for (list = layers; list; list = g_list_next (list))
-            {
-              GimpLayer *layer = list->data;
-              GimpItem  *item;
-
-              item = gimp_item_convert (GIMP_ITEM (layer), dest_image,
-                                        G_TYPE_FROM_INSTANCE (layer),
-                                        TRUE);
-
-              if (layers->next == NULL)
-                {
-                  gimp_object_set_name (GIMP_OBJECT (item), basename);
-                }
-              else
-                {
-                  gchar *name;
-
-                  name = g_strdup_printf ("%s - %s", basename,
-                                          gimp_object_get_name (GIMP_OBJECT (layer)));
-                  gimp_object_take_name (GIMP_OBJECT (item), name);
-                }
-
-              list->data = item;
-            }
-
+          file_open_convert_items (dest_image, basename, layers);
           g_free (basename);
 
           gimp_document_list_add_uri (GIMP_DOCUMENT_LIST (gimp->documents),
@@ -481,7 +459,7 @@
           g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                        _("Image doesn't contain any layers"));
           *status = GIMP_PDB_EXECUTION_ERROR;
-       }
+        }
 
       g_object_unref (new_image);
     }
@@ -631,6 +609,37 @@
   gimp_image_invalidate_channel_previews (image);
 }
 
+/* Converts items from one image to another */
+static void
+file_open_convert_items (GimpImage   *dest_image,
+                         const gchar *basename,
+                         GList       *items)
+{
+  GList *list;
+
+  for (list = items; list; list = g_list_next (list))
+    {
+      GimpItem *src = list->data;
+      GimpItem *item;
+
+      item = gimp_item_convert (src, dest_image, G_TYPE_FROM_INSTANCE (src));
+
+      if (g_list_length (items) == 1)
+        {
+          gimp_object_set_name (GIMP_OBJECT (item), basename);
+        }
+      else
+        {
+          gchar *name = g_strdup_printf ("%s - %s", basename,
+                                         GIMP_OBJECT (src)->name);
+
+          gimp_object_take_name (GIMP_OBJECT (item), name);
+        }
+
+      list->data = item;
+    }
+}
+
 static void
 file_open_profile_apply_rgb (GimpImage    *image,
                              GimpContext  *context,

Modified: branches/weskaggs/app/gegl/Makefile.am
==============================================================================
--- branches/weskaggs/app/gegl/Makefile.am	(original)
+++ branches/weskaggs/app/gegl/Makefile.am	Thu Jan 10 03:08:46 2008
@@ -7,8 +7,14 @@
 	gimp-gegl.h			\
 	gimp-gegl-utils.c		\
 	gimp-gegl-utils.h		\
+	gimpoperationcolorize.c		\
+	gimpoperationcolorize.h		\
 	gimpoperationdesaturate.c	\
 	gimpoperationdesaturate.h	\
+	gimpoperationlevels.c		\
+	gimpoperationlevels.h		\
+	gimpoperationposterize.c	\
+	gimpoperationposterize.h	\
 	gimpoperationthreshold.c	\
 	gimpoperationthreshold.h	\
 	gimpoperationtilesink.c		\
@@ -22,6 +28,5 @@
 	-I$(top_srcdir)		\
 	-I$(top_builddir)/app	\
 	-I$(top_srcdir)/app	\
-	$(GTK_CFLAGS)		\
 	$(GEGL_CFLAGS)		\
 	-I$(includedir)

Modified: branches/weskaggs/app/gegl/gegl-types.h
==============================================================================
--- branches/weskaggs/app/gegl/gegl-types.h	(original)
+++ branches/weskaggs/app/gegl/gegl-types.h	Thu Jan 10 03:08:46 2008
@@ -25,7 +25,10 @@
 #include "base/base-types.h"
 
 
+typedef struct _GimpOperationColorize   GimpOperationColorize;
 typedef struct _GimpOperationDesaturate GimpOperationDesaturate;
+typedef struct _GimpOperationLevels     GimpOperationLevels;
+typedef struct _GimpOperationPosterize  GimpOperationPosterize;
 typedef struct _GimpOperationThreshold  GimpOperationThreshold;
 typedef struct _GimpOperationTileSink   GimpOperationTileSink;
 typedef struct _GimpOperationTileSource GimpOperationTileSource;

Modified: branches/weskaggs/app/gegl/gegl/buffer/gegl-buffer-types.h
==============================================================================
--- branches/weskaggs/app/gegl/gegl/buffer/gegl-buffer-types.h	(original)
+++ branches/weskaggs/app/gegl/gegl/buffer/gegl-buffer-types.h	Thu Jan 10 03:08:46 2008
@@ -15,8 +15,9 @@
  *
  * Copyright 2006,2007 Ãyvind KolÃs <pippin gimp org>
  */
-#ifndef _GEGL_BUFFER_TYPES_H
-#define _GEGL_BUFFER_TYPES_H
+
+#ifndef __GEGL_BUFFER_TYPES_H__
+#define __GEGL_BUFFER_TYPES_H__
 
 typedef struct _GeglSampler              GeglSampler;
 
@@ -38,7 +39,7 @@
 typedef struct _GeglStorage              GeglStorage;
 typedef struct _GeglStorageClass         GeglStorageClass;
 
-#ifndef _GEGL_BUFFER_H
+#ifndef __GEGL_BUFFER_H__
 typedef struct _GeglBuffer               GeglBuffer;
 #endif
 typedef struct _GeglBufferClass          GeglBufferClass;

Modified: branches/weskaggs/app/gegl/gegl/gegl-operation-filter.h
==============================================================================
--- branches/weskaggs/app/gegl/gegl/gegl-operation-filter.h	(original)
+++ branches/weskaggs/app/gegl/gegl/gegl-operation-filter.h	Thu Jan 10 03:08:46 2008
@@ -15,8 +15,9 @@
  *
  * Copyright 2006 Ãyvind KolÃs
  */
-#ifndef _GEGL_OPERATION_FILTER_H
-#define _GEGL_OPERATION_FILTER_H
+
+#ifndef __GEGL_OPERATION_FILTER_H__
+#define __GEGL_OPERATION_FILTER_H__
 
 #include <glib-object.h>
 #include "gegl-types.h"
@@ -24,10 +25,12 @@
 
 G_BEGIN_DECLS
 
-#define GEGL_TYPE_OPERATION_FILTER           (gegl_operation_filter_get_type ())
-#define GEGL_OPERATION_FILTER(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_OPERATION_FILTER, GeglOperationFilter))
-#define GEGL_OPERATION_FILTER_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass),  GEGL_TYPE_OPERATION_FILTER, GeglOperationFilterClass))
-#define GEGL_OPERATION_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),  GEGL_TYPE_OPERATION_FILTER, GeglOperationFilterClass))
+#define GEGL_TYPE_OPERATION_FILTER            (gegl_operation_filter_get_type ())
+#define GEGL_OPERATION_FILTER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_OPERATION_FILTER, GeglOperationFilter))
+#define GEGL_OPERATION_FILTER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GEGL_TYPE_OPERATION_FILTER, GeglOperationFilterClass))
+#define GEGL_IS_OPERATION_FILTER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_OPERATION_FILTER))
+#define GEGL_IS_OPERATION_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GEGL_TYPE_OPERATION_FILTER))
+#define GEGL_OPERATION_FILTER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GEGL_TYPE_OPERATION_FILTER, GeglOperationFilterClass))
 
 typedef struct _GeglOperationFilter  GeglOperationFilter;
 struct _GeglOperationFilter
@@ -40,8 +43,9 @@
 {
   GeglOperationClass parent_class;
 
-  gboolean (* process) (GeglOperation *self,
-                        gpointer       context_id);
+  gboolean (* process) (GeglOperation       *self,
+                        GeglNodeContext     *context,
+                        const GeglRectangle *result);
 };
 
 GType gegl_operation_filter_get_type (void) G_GNUC_CONST;

Modified: branches/weskaggs/app/gegl/gegl/gegl-operation-point-filter.h
==============================================================================
--- branches/weskaggs/app/gegl/gegl/gegl-operation-point-filter.h	(original)
+++ branches/weskaggs/app/gegl/gegl/gegl-operation-point-filter.h	Thu Jan 10 03:08:46 2008
@@ -15,19 +15,20 @@
  *
  * Copyright 2006 Ãyvind KolÃs
  */
-#ifndef _GEGL_OPERATION_POINT_FILTER_H
-#define _GEGL_OPERATION_POINT_FILTER_H
 
-#include <glib-object.h>
-#include "gegl-types.h"
+#ifndef __GEGL_OPERATION_POINT_FILTER_H__
+#define __GEGL_OPERATION_POINT_FILTER_H__
+
 #include "gegl-operation-filter.h"
 
 G_BEGIN_DECLS
 
-#define GEGL_TYPE_OPERATION_POINT_FILTER           (gegl_operation_point_filter_get_type ())
-#define GEGL_OPERATION_POINT_FILTER(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_OPERATION_POINT_FILTER, GeglOperationPointFilter))
-#define GEGL_OPERATION_POINT_FILTER_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass),  GEGL_TYPE_OPERATION_POINT_FILTER, GeglOperationPointFilterClass))
-#define GEGL_OPERATION_POINT_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),  GEGL_TYPE_OPERATION_POINT_FILTER, GeglOperationPointFilterClass))
+#define GEGL_TYPE_OPERATION_POINT_FILTER            (gegl_operation_point_filter_get_type ())
+#define GEGL_OPERATION_POINT_FILTER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_OPERATION_POINT_FILTER, GeglOperationPointFilter))
+#define GEGL_OPERATION_POINT_FILTER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GEGL_TYPE_OPERATION_POINT_FILTER, GeglOperationPointFilterClass))
+#define GEGL_IS_OPERATION_POINT_FILTER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_OPERATION_POINT_FILTER))
+#define GEGL_IS_OPERATION_POINT_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GEGL_TYPE_OPERATION_POINT_FILTER))
+#define GEGL_OPERATION_POINT_FILTER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GEGL_TYPE_OPERATION_POINT_FILTER, GeglOperationPointFilterClass))
 
 typedef struct _GeglOperationPointFilter  GeglOperationPointFilter;
 struct _GeglOperationPointFilter
@@ -44,7 +45,6 @@
                         void          *in_buf,    /* input buffer */
                         void          *out_buf,   /* output buffer */
                         glong          samples);  /* number of samples   */
-
 };
 
 GType gegl_operation_point_filter_get_type (void) G_GNUC_CONST;

Modified: branches/weskaggs/app/gegl/gegl/gegl-operation-sink.h
==============================================================================
--- branches/weskaggs/app/gegl/gegl/gegl-operation-sink.h	(original)
+++ branches/weskaggs/app/gegl/gegl/gegl-operation-sink.h	Thu Jan 10 03:08:46 2008
@@ -15,11 +15,10 @@
  *
  * Copyright 2006 Ãyvind KolÃs
  */
-#ifndef _GEGL_OPERATION_SINK_H
-#define _GEGL_OPERATION_SINK_H
 
-#include <glib-object.h>
-#include "gegl-types.h"
+#ifndef __GEGL_OPERATION_SINK_H__
+#define __GEGL_OPERATION_SINK_H__
+
 #include "gegl-operation.h"
 
 G_BEGIN_DECLS
@@ -27,9 +26,9 @@
 #define GEGL_TYPE_OPERATION_SINK            (gegl_operation_sink_get_type ())
 #define GEGL_OPERATION_SINK(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_OPERATION_SINK, GeglOperationSink))
 #define GEGL_OPERATION_SINK_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GEGL_TYPE_OPERATION_SINK, GeglOperationSinkClass))
-#define GEGL_OPERATION_SINK_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GEGL_TYPE_OPERATION_SINK, GeglOperationSinkClass))
 #define GEGL_IS_OPERATION_SINK(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_OPERATION_SINK))
 #define GEGL_IS_OPERATION_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GEGL_TYPE_OPERATION_SINK))
+#define GEGL_OPERATION_SINK_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GEGL_TYPE_OPERATION_SINK, GeglOperationSinkClass))
 
 typedef struct _GeglOperationSink  GeglOperationSink;
 struct _GeglOperationSink
@@ -44,8 +43,9 @@
 
   gboolean           needs_full;
 
-  gboolean (* process) (GeglOperation *self,
-                        gpointer       context_id);
+  gboolean (* process) (GeglOperation       *self,
+                        GeglBuffer          *input,
+                        const GeglRectangle *result);
 };
 
 GType    gegl_operation_sink_get_type   (void) G_GNUC_CONST;

Modified: branches/weskaggs/app/gegl/gegl/gegl-operation-source.h
==============================================================================
--- branches/weskaggs/app/gegl/gegl/gegl-operation-source.h	(original)
+++ branches/weskaggs/app/gegl/gegl/gegl-operation-source.h	Thu Jan 10 03:08:46 2008
@@ -15,19 +15,20 @@
  *
  * Copyright 2006 Ãyvind KolÃs
  */
+
 #ifndef __GEGL_OPERATION_SOURCE_H__
 #define __GEGL_OPERATION_SOURCE_H__
 
-#include <glib-object.h>
-#include "gegl-types.h"
 #include "gegl-operation.h"
 
 G_BEGIN_DECLS
 
-#define GEGL_TYPE_OPERATION_SOURCE               (gegl_operation_source_get_type ())
-#define GEGL_OPERATION_SOURCE(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_OPERATION_SOURCE, GeglOperationSource))
-#define GEGL_OPERATION_SOURCE_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass),  GEGL_TYPE_OPERATION_SOURCE, GeglOperationSourceClass))
-#define GEGL_OPERATION_SOURCE_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj),  GEGL_TYPE_OPERATION_SOURCE, GeglOperationSourceClass))
+#define GEGL_TYPE_OPERATION_SOURCE            (gegl_operation_source_get_type ())
+#define GEGL_OPERATION_SOURCE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_OPERATION_SOURCE, GeglOperationSource))
+#define GEGL_OPERATION_SOURCE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GEGL_TYPE_OPERATION_SOURCE, GeglOperationSourceClass))
+#define GEGL_IS_OPERATION_SOURCE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_OPERATION_SOURCE, GeglOperationSource))
+#define GEGL_IS_OPERATION_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GEGL_TYPE_OPERATION_SOURCE, GeglOperationSourceClass))
+#define GEGL_OPERATION_SOURCE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GEGL_TYPE_OPERATION_SOURCE, GeglOperationSourceClass))
 
 typedef struct _GeglOperationSource  GeglOperationSource;
 struct _GeglOperationSource
@@ -40,8 +41,10 @@
 {
   GeglOperationClass parent_class;
 
-  gboolean (*process) (GeglOperation *self,
-                       gpointer       context_id);
+  gboolean (* process) (GeglOperation       *self,
+                        GeglNodeContext     *context,
+                        GeglBuffer          *output,
+                        const GeglRectangle *result);
 };
 
 GType gegl_operation_source_get_type (void) G_GNUC_CONST;

Modified: branches/weskaggs/app/gegl/gegl/gegl-operation.h
==============================================================================
--- branches/weskaggs/app/gegl/gegl/gegl-operation.h	(original)
+++ branches/weskaggs/app/gegl/gegl/gegl-operation.h	Thu Jan 10 03:08:46 2008
@@ -20,13 +20,13 @@
 #ifndef __GEGL_OPERATION_H__
 #define __GEGL_OPERATION_H__
 
+#include <glib-object.h>
+#include <babl/babl.h>
 #include "gegl-types.h"
 #include "buffer/gegl-buffer-types.h"
-#include <babl/babl.h>
 
 G_BEGIN_DECLS
 
-
 #define GEGL_TYPE_OPERATION            (gegl_operation_get_type ())
 #define GEGL_OPERATION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_OPERATION, GeglOperation))
 #define GEGL_OPERATION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GEGL_TYPE_OPERATION, GeglOperationClass))
@@ -74,8 +74,7 @@
   /* prepare the node for processing (all properties will be set) override this
    * if you are creating a meta operation (using the node as a GeglGraph).
    */
-  void            (*prepare)              (GeglOperation *operation,
-                                           gpointer       context_id);
+  void            (*prepare)              (GeglOperation *operation);
 
   /* Returns a bounding rectangle for the data that is defined by this op. (is
    * already implemented in GeglOperationPointFilter and
@@ -88,9 +87,9 @@
    * graph. A default implementation of this, if not provided should probably
    * be to report that the entire defined region is dirtied.
    */
-  GeglRectangle   (*compute_affected_region)  (GeglOperation *operation,
-                                               const gchar   *input_pad,
-                                               GeglRectangle  region);
+  GeglRectangle   (*compute_affected_region)  (GeglOperation       *operation,
+                                               const gchar         *input_pad,
+                                               const GeglRectangle *input_region);
 
   /* computes the rectangle needed to be correctly computed in a buffer
    * on the named input_pad, for a given result rectangle
@@ -108,53 +107,41 @@
 
   /* Returns the node providing data for a specific location
    */
-  GeglNode*       (*detect)               (GeglOperation *operation,
-                                           gint           x,
-                                           gint           y);
-
-  /* do the actual processing needed to put GeglBuffers on the output pad */
-  gboolean        (*process)              (GeglOperation *operation,
-                                           gpointer       context_id,
-                                           const gchar   *output_pad);
-
+  GeglNode*       (*detect)                (GeglOperation       *operation,
+                                            gint                 x,
+                                            gint                 y);
+
+  gboolean        (*process)               (GeglOperation       *operation,
+                                            GeglNodeContext     *context,
+                                            const gchar         *output_pad,
+                                            const GeglRectangle *result_rect);
 };
 
 /* returns|registers the gtype for GeglOperation */
 GType           gegl_operation_get_type             (void) G_GNUC_CONST;
 
-/* returns the ROI passed to _this_ operation */
-const GeglRectangle *
-                gegl_operation_get_requested_region (GeglOperation *operation,
-                                                     gpointer       context_id);
-
 /* retrieves the bounding box of a connected input */
 GeglRectangle * gegl_operation_source_get_defined_region (GeglOperation *operation,
                                                           const gchar   *pad_name);
 
-/* retrieves the node providing data to a named input pad */
-GeglNode      * gegl_operation_get_source_node      (GeglOperation *operation,
-                                                     const gchar   *pad_name);
 
 /* sets the ROI needed to be computed on one of the sources */
-void            gegl_operation_set_source_region    (GeglOperation *operation,
-                                                     gpointer       context_id,
-                                                     const gchar   *pad_name,
-                                                     GeglRectangle *region);
+void            gegl_operation_set_source_region    (GeglOperation       *operation,
+                                                     gpointer             context_id,
+                                                     const gchar         *pad_name,
+                                                     const GeglRectangle *region);
 
-/* returns the bounding box of the buffer that needs to be computed */
-const GeglRectangle * gegl_operation_result_rect    (GeglOperation *operation,
-                                                     gpointer       context_id);
-
-/* returns the bounding box of the buffer needed for computation */
-const GeglRectangle * gegl_operation_need_rect      (GeglOperation *operation,
-                                                     gpointer       context_id);
 
 /* virtual method invokers that depends only on the set properties of a
  * operation|node
  */
+
+/* retrieves the node providing data to a named input pad */
+GeglNode      * gegl_operation_get_source_node      (GeglOperation *operation,
+                                                     const gchar   *pad_name);
 GeglRectangle   gegl_operation_compute_affected_region (GeglOperation *operation,
                                                      const gchar   *input_pad,
-                                                     GeglRectangle  region);
+                                                     const GeglRectangle *input_region);
 GeglRectangle   gegl_operation_get_defined_region   (GeglOperation *operation);
 GeglRectangle   gegl_operation_adjust_result_region (GeglOperation *operation,
                                                      const GeglRectangle *roi);
@@ -169,30 +156,16 @@
 
 
 /* virtual method invokers that change behavior based on the roi being computed,
- * needs a context_id being based that is used for storing dynamic data.
- */
-
-void            gegl_operation_attach               (GeglOperation *operation,
-                                                     GeglNode      *node);
-void            gegl_operation_prepare              (GeglOperation *operation,
-                                                     gpointer       context_id);
-gboolean        gegl_operation_process              (GeglOperation *operation,
-                                                     gpointer       context_id,
-                                                     const gchar   *output_pad);
-
-
-/* retrieve the buffer that we are going to write into, it will be of the
- * dimensions retrieved through the rectangle computation, and of the format
- * currently specified on the associated nodes, "property_name" pad.
+ * needs a context_id being based that is used for storing context data.
  */
-GeglBuffer    * gegl_operation_get_target           (GeglOperation *operation,
-                                                     gpointer       context_id,
-                                                     const gchar   *property_name);
 
-
-GeglBuffer    * gegl_operation_get_source            (GeglOperation *operation,
-                                                      gpointer       context_id,
-                                                      const gchar   *property_name);
+void            gegl_operation_attach               (GeglOperation       *operation,
+                                                     GeglNode            *node);
+void            gegl_operation_prepare              (GeglOperation       *operation);
+gboolean        gegl_operation_process              (GeglOperation       *operation,
+                                                     GeglNodeContext     *context,
+                                                     const gchar         *output_pad,
+                                                     const GeglRectangle *result_rect);
 
 gchar        ** gegl_list_operations                (guint *n_operations_p);
 GParamSpec   ** gegl_list_properties                (const gchar *operation_type,
@@ -204,7 +177,8 @@
 
 /* create a pad for a specified property for this operation, this method is
  * to be called from the attach method of operations, most operations do not
- * have to care about this since a super class will do it for them.
+ * have to care about this since a super class like filter, sink, source or
+ * composer already does so.
  */
 void       gegl_operation_create_pad                (GeglOperation *operation,
                                                      GParamSpec    *param_spec);
@@ -214,42 +188,15 @@
  * turn into a global mechanism) */
 void       gegl_operation_set_format                (GeglOperation *operation,
                                                      const gchar   *pad_name,
-                                                     Babl          *format);
+                                                     const Babl    *format);
+const Babl * gegl_operation_get_format              (GeglOperation *operation,
+                                                     const gchar   *pad_name);
 
 /* Used to look up the gtype when changing the type of operation associated
  * a GeglNode using just a string with the registered name.
  */
 GType      gegl_operation_gtype_from_name           (const gchar *name);
 
-
-
-
-
-/* set a dynamic named instance for this node, this function takes over ownership
- * of the reference (mostly used to set the "output" GeglBuffer) for operations
- */
-void            gegl_operation_set_data             (GeglOperation *operation,
-                                                     gpointer       context_id,
-                                                     const gchar   *property_name,
-                                                     GObject       *data);
-
-
-/*************************
- *  The following is internal GEGL functions, declared in the header for now, should.
- *  be removed when the operation API is made public.
- */
-
-
-/* retrieve a gobject previously set dynamically on an operation */
-GObject       * gegl_operation_get_data             (GeglOperation *operation,
-                                                     gpointer       context_id,
-                                                     const gchar   *property_name);
-
-
-GeglBuffer    * gegl_operation_get_source           (GeglOperation *operation,
-                                                     gpointer       context_id,
-                                                     const gchar   *pad_name);
-
 gboolean gegl_operation_calc_source_regions  (GeglOperation *operation,
                                               gpointer       context_id);
 

Modified: branches/weskaggs/app/gegl/gegl/gegl-types.h
==============================================================================
--- branches/weskaggs/app/gegl/gegl/gegl-types.h	(original)
+++ branches/weskaggs/app/gegl/gegl/gegl-types.h	Thu Jan 10 03:08:46 2008
@@ -34,10 +34,10 @@
 typedef struct _GeglHaveVisitor      GeglHaveVisitor;
 typedef struct _GeglNeedVisitor      GeglNeedVisitor;
 typedef struct _GeglNode             GeglNode;
-typedef struct _GeglNodeDynamic      GeglNodeDynamic;
+typedef struct _GeglNodeContext      GeglNodeContext;
 typedef struct _GeglOperation        GeglOperation;
 typedef struct _GeglPad              GeglPad;
-typedef struct _GeglVector             GeglVector;
+typedef struct _GeglVector           GeglVector;
 typedef struct _GeglProcessor        GeglProcessor;
 typedef struct _GeglPrepareVisitor   GeglPrepareVisitor;
 typedef struct _GeglVisitable        GeglVisitable; /* dummy typedef */

Modified: branches/weskaggs/app/gegl/gimp-gegl.c
==============================================================================
--- branches/weskaggs/app/gegl/gimp-gegl.c	(original)
+++ branches/weskaggs/app/gegl/gimp-gegl.c	Thu Jan 10 03:08:46 2008
@@ -27,7 +27,10 @@
 #include "gegl-types.h"
 
 #include "gimp-gegl.h"
+#include "gimpoperationcolorize.h"
 #include "gimpoperationdesaturate.h"
+#include "gimpoperationlevels.h"
+#include "gimpoperationposterize.h"
 #include "gimpoperationthreshold.h"
 #include "gimpoperationtilesink.h"
 #include "gimpoperationtilesource.h"
@@ -36,7 +39,10 @@
 void
 gimp_gegl_init (void)
 {
+  g_type_class_ref (GIMP_TYPE_OPERATION_COLORIZE);
   g_type_class_ref (GIMP_TYPE_OPERATION_DESATURATE);
+  g_type_class_ref (GIMP_TYPE_OPERATION_LEVELS);
+  g_type_class_ref (GIMP_TYPE_OPERATION_POSTERIZE);
   g_type_class_ref (GIMP_TYPE_OPERATION_THRESHOLD);
   g_type_class_ref (GIMP_TYPE_OPERATION_TILE_SINK);
   g_type_class_ref (GIMP_TYPE_OPERATION_TILE_SOURCE);

Modified: branches/weskaggs/app/gegl/gimpoperationtilesink.c
==============================================================================
--- branches/weskaggs/app/gegl/gimpoperationtilesink.c	(original)
+++ branches/weskaggs/app/gegl/gimpoperationtilesink.c	Thu Jan 10 03:08:46 2008
@@ -26,6 +26,7 @@
 #include <glib-object.h>
 
 #include "gegl/gegl-types.h"
+#include "gegl/graph/gegl-node-context.h"
 #include <gegl/buffer/gegl-buffer.h>
 
 #include "gegl-types.h"
@@ -34,8 +35,6 @@
 #include "base/tile-manager.h"
 #include "base/pixel-region.h"
 
-#include "core/gimpmarshal.h"
-
 #include "gimp-gegl-utils.h"
 #include "gimpoperationtilesink.h"
 
@@ -65,7 +64,8 @@
                                                        GParamSpec    *pspec);
 
 static gboolean gimp_operation_tile_sink_process      (GeglOperation *operation,
-                                                       gpointer       context_id);
+                                                       GeglBuffer          *input,
+                                                       const GeglRectangle *result);
 
 
 G_DEFINE_TYPE (GimpOperationTileSink, gimp_operation_tile_sink,
@@ -89,7 +89,7 @@
                   G_SIGNAL_RUN_FIRST,
                   G_STRUCT_OFFSET (GimpOperationTileSinkClass, data_written),
                   NULL, NULL,
-                  gimp_marshal_VOID__POINTER,
+                  g_cclosure_marshal_VOID__POINTER,
                   G_TYPE_NONE, 1,
                   G_TYPE_POINTER);
 
@@ -190,33 +190,27 @@
 }
 
 static gboolean
-gimp_operation_tile_sink_process (GeglOperation *operation,
-                                  gpointer       context_id)
+gimp_operation_tile_sink_process (GeglOperation       *operation,
+                                  GeglBuffer          *input,
+                                  const GeglRectangle *result)
 {
   GimpOperationTileSink *self = GIMP_OPERATION_TILE_SINK (operation);
 
   if (self->tile_manager)
     {
-      GeglBuffer          *input;
-      const Babl          *format;
-      const GeglRectangle *extent;
-      PixelRegion          destPR;
-      const guint          bpp = tile_manager_bpp (self->tile_manager);
-      gpointer             pr;
-
-      extent = gegl_operation_result_rect (operation, context_id);
+      const Babl  *format;
+      PixelRegion  destPR;
+      guint        bpp = tile_manager_bpp (self->tile_manager);
+      gpointer     pr;
 
       if (self->linear)
         format = gimp_bpp_to_babl_format_linear (bpp);
       else
         format = gimp_bpp_to_babl_format (bpp);
 
-      input = GEGL_BUFFER (gegl_operation_get_data (operation, context_id,
-                                                    "input"));
-
       pixel_region_init (&destPR, self->tile_manager,
-                         extent->x, extent->y,
-                         extent->width, extent->height,
+                         result->x,     result->y,
+                         result->width, result->height,
                          TRUE);
 
       for (pr = pixel_regions_register (1, &destPR);
@@ -230,7 +224,7 @@
         }
 
       g_signal_emit (operation, tile_sink_signals[DATA_WRITTEN], 0,
-                     extent);
+                     result);
     }
   else
     {

Modified: branches/weskaggs/app/gegl/gimpoperationtilesource.c
==============================================================================
--- branches/weskaggs/app/gegl/gimpoperationtilesource.c	(original)
+++ branches/weskaggs/app/gegl/gimpoperationtilesource.c	Thu Jan 10 03:08:46 2008
@@ -34,6 +34,7 @@
 #include "base/pixel-region.h"
 
 #include "gimp-gegl-utils.h"
+#include "gegl/graph/gegl-node-context.h"
 #include "gimpoperationtilesource.h"
 
 
@@ -55,11 +56,13 @@
                                                          const GValue  *value,
                                                          GParamSpec    *pspec);
 
+static void     gimp_operation_tile_source_prepare      (GeglOperation *operation);
 static GeglRectangle
           gimp_operation_tile_source_get_defined_region (GeglOperation *operation);
-
 static gboolean gimp_operation_tile_source_process      (GeglOperation *operation,
-                                                         gpointer       context_id);
+                                                         GeglNodeContext *context,
+                                                         GeglBuffer          *output,
+                                                         const GeglRectangle *result);
 
 
 G_DEFINE_TYPE (GimpOperationTileSource, gimp_operation_tile_source,
@@ -79,6 +82,7 @@
   object_class->set_property          = gimp_operation_tile_source_set_property;
   object_class->get_property          = gimp_operation_tile_source_get_property;
 
+  operation_class->prepare            = gimp_operation_tile_source_prepare;
   operation_class->get_defined_region = gimp_operation_tile_source_get_defined_region;
   operation_class->adjust_result_region = NULL; /* the default source is
                                                  expanding to agressivly
@@ -177,6 +181,25 @@
     }
 }
 
+static void
+gimp_operation_tile_source_prepare (GeglOperation *operation)
+{
+  GimpOperationTileSource *self = GIMP_OPERATION_TILE_SOURCE (operation);
+
+  if (self->tile_manager)
+    {
+      const Babl *format;
+      guint       bpp = tile_manager_bpp (self->tile_manager);
+
+      if (self->linear)
+        format = gimp_bpp_to_babl_format_linear (bpp);
+      else
+        format = gimp_bpp_to_babl_format (bpp);
+
+      gegl_operation_set_format (operation, "output", format);
+    }
+}
+
 static GeglRectangle
 gimp_operation_tile_source_get_defined_region (GeglOperation *operation)
 {
@@ -195,32 +218,24 @@
 }
 
 static gboolean
-gimp_operation_tile_source_process (GeglOperation *operation,
-                                    gpointer       context_id)
+gimp_operation_tile_source_process (GeglOperation       *operation,
+                                    GeglNodeContext     *context,
+                                    GeglBuffer          *output,
+                                    const GeglRectangle *result)
 {
   GimpOperationTileSource *self = GIMP_OPERATION_TILE_SOURCE (operation);
 
   if (self->tile_manager)
     {
-      GeglBuffer          *output;
-      const Babl          *format;
-      const GeglRectangle *extent;
-      PixelRegion          srcPR;
-      const guint          bpp = tile_manager_bpp (self->tile_manager);
-      gpointer             pr;
+      const Babl  *format;
+      PixelRegion  srcPR;
+      gpointer     pr;
 
-      extent = gegl_operation_result_rect (operation, context_id);
-
-      if (self->linear)
-        format = gimp_bpp_to_babl_format_linear (bpp);
-      else
-        format = gimp_bpp_to_babl_format (bpp);
-
-      output = gegl_buffer_new (extent, format);
+      format = gegl_operation_get_format (operation, "output");
 
       pixel_region_init (&srcPR, self->tile_manager,
-                         extent->x, extent->y,
-                         extent->width, extent->height,
+                         result->x,     result->y,
+                         result->width, result->height,
                          FALSE);
 
       for (pr = pixel_regions_register (1, &srcPR);
@@ -231,9 +246,6 @@
 
           gegl_buffer_set (output, &rect, format, srcPR.data, srcPR.rowstride);
         }
-
-      gegl_operation_set_data (operation, context_id,
-                               "output", G_OBJECT (output));
     }
 
   return TRUE;

Modified: branches/weskaggs/app/gimpcore.def
==============================================================================
--- branches/weskaggs/app/gimpcore.def	(original)
+++ branches/weskaggs/app/gimpcore.def	Thu Jan 10 03:08:46 2008
@@ -512,7 +512,6 @@
 	gimp_projection_flush_now
 	gimp_projection_get_bytes
 	gimp_projection_get_image_type
-	gimp_projection_get_opacity
 	gimp_projection_get_tiles
 	gimp_rc_get_type
 	gimp_rc_new
@@ -927,3 +926,7 @@
 gimp_curve_set_curve
 gimp_curve_set_curve_type
 gimp_curve_get_closest_point
+gimp_gegl_init
+gimp_image_get_guides
+gimp_image_get_sample_points
+gimp_plug_in_manager_get_menu_branches

Modified: branches/weskaggs/app/makefile.msc
==============================================================================
--- branches/weskaggs/app/makefile.msc	(original)
+++ branches/weskaggs/app/makefile.msc	Thu Jan 10 03:08:46 2008
@@ -46,6 +46,7 @@
 	config/appconfig.lib \
 	core/appcore.lib \
 	file/appfile.lib \
+	gegl/appgegl.lib \
 	paint/apppaint.lib \
 	paint-funcs/apppaint-funcs.lib \
 	pdb/apppdb.lib \
@@ -72,6 +73,7 @@
 	$(LIBART_LIBS) \
 	$(PANGOWIN32_LIBS) \
 	$(PANGOCAIRO_LIBS) \
+	$(GEGL_LIBS) $(BABL_LIBS) \
 !IFNDEF PANGO_WIN32_EXTENDED
 	$(PANGOFT2_LIBS) \
 	$(FREETYPE2_LIBS) \
@@ -87,6 +89,7 @@
 	-I$(top_srcdir) \
 	-I$(top_srcdir)/app \
 	$(GTK2_CFLAGS) \
+	$(GEGL_CFLAGS) \
 !IFNDEF PANGO_WIN32_EXTENDED
 	$(FONTCONFIG_CFLAGS) \
 	$(FREETYPE2_CFLAGS) \

Modified: branches/weskaggs/app/pdb/Makefile.am
==============================================================================
--- branches/weskaggs/app/pdb/Makefile.am	(original)
+++ branches/weskaggs/app/pdb/Makefile.am	Thu Jan 10 03:08:46 2008
@@ -77,6 +77,7 @@
 	-I$(top_builddir)/app	\
 	-I$(top_srcdir)/app	\
 	$(GDK_PIXBUF_CFLAGS)	\
+	$(GEGL_CFLAGS)		\
 	$(GLIB_CFLAGS)		\
 	-I$(includedir)
 

Modified: branches/weskaggs/app/pdb/channel_cmds.c
==============================================================================
--- branches/weskaggs/app/pdb/channel_cmds.c	(original)
+++ branches/weskaggs/app/pdb/channel_cmds.c	Thu Jan 10 03:08:46 2008
@@ -140,7 +140,7 @@
   if (success)
     {
       channel_copy = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (channel),
-                                   G_TYPE_FROM_INSTANCE (channel), FALSE));
+                                   G_TYPE_FROM_INSTANCE (channel)));
 
       if (! channel_copy)
         success = FALSE;

Modified: branches/weskaggs/app/pdb/color_cmds.c
==============================================================================
--- branches/weskaggs/app/pdb/color_cmds.c	(original)
+++ branches/weskaggs/app/pdb/color_cmds.c	Thu Jan 10 03:08:46 2008
@@ -20,6 +20,7 @@
 
 #include "config.h"
 
+#include <gegl.h>
 
 #include <glib-object.h>
 
@@ -34,11 +35,11 @@
 #include "base/gimphistogram.h"
 #include "base/gimplut.h"
 #include "base/hue-saturation.h"
-#include "base/levels.h"
 #include "base/lut-funcs.h"
 #include "base/pixel-processor.h"
 #include "base/pixel-region.h"
 #include "base/threshold.h"
+#include "config/gimpcoreconfig.h"
 #include "core/gimp.h"
 #include "core/gimpcurve.h"
 #include "core/gimpdrawable-desaturate.h"
@@ -46,6 +47,7 @@
 #include "core/gimpdrawable-histogram.h"
 #include "core/gimpdrawable-invert.h"
 #include "core/gimpdrawable-levels.h"
+#include "core/gimpdrawable-operation.h"
 #include "core/gimpdrawable.h"
 #include "core/gimpimage.h"
 #include "gimp-intl.h"
@@ -78,6 +80,26 @@
 
       if (success)
         {
+      if (gimp->config->use_gegl)
+        {
+          GeglNode *node = g_object_new (GEGL_TYPE_NODE,
+                                         "operation",  "brightness-contrast",
+                                         NULL);
+
+          gegl_node_set (node,
+                         "brightness", brightness / 127.0,
+                         "contrast",   (contrast < 0 ?
+                                        (contrast + 127.0) / 127.0 :
+                                        contrast * 4.0 / 127.0 + 1),
+                         NULL);
+
+          gimp_drawable_apply_operation (drawable, node, TRUE,
+                                         progress, _("Brightness-Contrast"));
+
+          g_object_unref (node);
+        }
+      else
+        {
           gint x, y, width, height;
 
           /* The application should occur only within selection bounds */
@@ -105,6 +127,7 @@
               gimp_drawable_update (drawable, x, y, width, height);
             }
         }
+        }
     }
 
   return gimp_procedure_get_return_values (procedure, success);
@@ -231,6 +254,23 @@
 
       if (success)
         {
+      if (gimp->config->use_gegl)
+        {
+          GeglNode *node = g_object_new (GEGL_TYPE_NODE,
+                                         "operation", "gimp-posterize",
+                                         NULL);
+
+          gegl_node_set (node,
+                         "levels", levels,
+                         NULL);
+
+          gimp_drawable_apply_operation (drawable, node, TRUE,
+                                         progress, _("Levels"));
+
+          g_object_unref (node);
+        }
+      else
+        {
           gint x, y, width, height;
 
           /* The application should occur only within selection bounds */
@@ -256,6 +296,7 @@
               gimp_drawable_update (drawable, x, y, width, height);
             }
         }
+        }
     }
 
   return gimp_procedure_get_return_values (procedure, success);
@@ -634,6 +675,25 @@
 
       if (success)
         {
+      if (gimp->config->use_gegl)
+        {
+          GeglNode *node = g_object_new (GEGL_TYPE_NODE,
+                                         "operation", "gimp-colorize",
+                                         NULL);
+
+          gegl_node_set (node,
+                         "hue",        hue,
+                         "saturation", saturation,
+                         "lightness",  lightness,
+                         NULL);
+
+          gimp_drawable_apply_operation (drawable, node, TRUE,
+                                         progress, _("Colorize"));
+
+          g_object_unref (node);
+        }
+      else
+        {
           gint x, y, width, height;
 
           /* The application should occur only within selection bounds */
@@ -662,6 +722,7 @@
               gimp_drawable_update (drawable, x, y, width, height);
             }
         }
+        }
     }
 
   return gimp_procedure_get_return_values (procedure, success);
@@ -828,6 +889,24 @@
 
       if (success)
         {
+      if (gimp->config->use_gegl)
+        {
+          GeglNode *node = g_object_new (GEGL_TYPE_NODE,
+                                         "operation", "gimp-threshold",
+                                         NULL);
+
+          gegl_node_set (node,
+                         "low",  low_threshold  / 255.0,
+                         "high", high_threshold / 255.0,
+                         NULL);
+
+          gimp_drawable_apply_operation (drawable, node, TRUE,
+                                         progress, _("Threshold"));
+
+          g_object_unref (node);
+        }
+      else
+        {
           gint x, y, width, height;
 
           /* The application should occur only within selection bounds */
@@ -852,6 +931,7 @@
               gimp_drawable_update (drawable, x, y, width, height);
             }
         }
+        }
     }
 
   return gimp_procedure_get_return_values (procedure, success);

Modified: branches/weskaggs/app/pdb/layer_cmds.c
==============================================================================
--- branches/weskaggs/app/pdb/layer_cmds.c	(original)
+++ branches/weskaggs/app/pdb/layer_cmds.c	Thu Jan 10 03:08:46 2008
@@ -115,9 +115,9 @@
         new_type = GIMP_TYPE_LAYER;
 
       if (dest_image == gimp_item_get_image (GIMP_ITEM (drawable)))
-        new_item = gimp_item_duplicate (GIMP_ITEM (drawable), new_type, TRUE);
+        new_item = gimp_item_duplicate (GIMP_ITEM (drawable), new_type);
       else
-        new_item = gimp_item_convert (GIMP_ITEM (drawable), dest_image, new_type, TRUE);
+        new_item = gimp_item_convert (GIMP_ITEM (drawable), dest_image, new_type);
 
       if (new_item)
         layer_copy = GIMP_LAYER (new_item);
@@ -153,10 +153,16 @@
   if (success)
     {
       layer_copy = GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (layer),
-                                                    G_TYPE_FROM_INSTANCE (layer),
-                                                    add_alpha));
-      if (! layer_copy)
-        success = FALSE;
+                                                    G_TYPE_FROM_INSTANCE (layer)));
+      if (layer_copy)
+        {
+          if (add_alpha)
+            gimp_layer_add_alpha (layer_copy);
+        }
+      else
+        {
+          success = FALSE;
+        }
     }
 
   return_vals = gimp_procedure_get_return_values (procedure, success);

Modified: branches/weskaggs/app/pdb/makefile.msc
==============================================================================
--- branches/weskaggs/app/pdb/makefile.msc	(original)
+++ branches/weskaggs/app/pdb/makefile.msc	Thu Jan 10 03:08:46 2008
@@ -80,6 +80,7 @@
 	vectors_cmds.obj \
 	\
 	gimppdb.obj \
+	gimppdb-utils.obj \
 	gimppdberror.obj \
 	\
 	gimp-pdb-compat.obj \

Modified: branches/weskaggs/app/text/gimptextlayer.c
==============================================================================
--- branches/weskaggs/app/text/gimptextlayer.c	(original)
+++ branches/weskaggs/app/text/gimptextlayer.c	Thu Jan 10 03:08:46 2008
@@ -75,8 +75,7 @@
                                                   gint64          *gui_size);
 
 static GimpItem * gimp_text_layer_duplicate      (GimpItem        *item,
-                                                  GType            new_type,
-                                                  gboolean         add_alpha);
+                                                  GType            new_type);
 static gboolean   gimp_text_layer_rename         (GimpItem        *item,
                                                   const gchar     *new_name,
                                                   const gchar     *undo_desc,
@@ -239,16 +238,13 @@
 
 static GimpItem *
 gimp_text_layer_duplicate (GimpItem *item,
-                           GType     new_type,
-                           gboolean  add_alpha)
+                           GType     new_type)
 {
   GimpItem *new_item;
 
   g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
 
-  new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item,
-                                                        new_type,
-                                                        add_alpha);
+  new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type);
 
   if (GIMP_IS_TEXT_LAYER (new_item))
     {

Modified: branches/weskaggs/app/tools/gimpbrightnesscontrasttool.c
==============================================================================
--- branches/weskaggs/app/tools/gimpbrightnesscontrasttool.c	(original)
+++ branches/weskaggs/app/tools/gimpbrightnesscontrasttool.c	Thu Jan 10 03:08:46 2008
@@ -130,9 +130,14 @@
 static void
 gimp_brightness_contrast_tool_init (GimpBrightnessContrastTool *bc_tool)
 {
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (bc_tool);
+
   bc_tool->brightness = 0.0;
   bc_tool->contrast   = 0.0;
   bc_tool->lut        = gimp_lut_new ();
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
+  im_tool->apply_data = bc_tool->lut;
 }
 
 static void
@@ -197,7 +202,7 @@
       gdouble brightness;
       gdouble contrast;
 
-      brightness = bc_tool->brightness / 127.0;
+      brightness = bc_tool->brightness / 256.0;
       contrast   = (bc_tool->contrast < 0 ?
                     (bc_tool->contrast + 127.0) / 127.0 :
                     bc_tool->contrast * 4.0 / 127.0 + 1);
@@ -212,9 +217,6 @@
                                  bc_tool->brightness / 255.0,
                                  bc_tool->contrast / 127.0,
                                  gimp_drawable_bytes (im_tool->drawable));
-  gimp_image_map_apply (im_tool->image_map,
-                        (GimpImageMapApplyFunc) gimp_lut_process,
-                        bc_tool->lut);
 }
 
 

Modified: branches/weskaggs/app/tools/gimpcolorbalancetool.c
==============================================================================
--- branches/weskaggs/app/tools/gimpcolorbalancetool.c	(original)
+++ branches/weskaggs/app/tools/gimpcolorbalancetool.c	Thu Jan 10 03:08:46 2008
@@ -111,10 +111,15 @@
 static void
 gimp_color_balance_tool_init (GimpColorBalanceTool *cb_tool)
 {
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (cb_tool);
+
   cb_tool->color_balance = g_slice_new0 (ColorBalance);
   cb_tool->transfer_mode = GIMP_MIDTONES;
 
   color_balance_init (cb_tool->color_balance);
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) color_balance;
+  im_tool->apply_data = cb_tool->color_balance;
 }
 
 static void
@@ -164,9 +169,6 @@
   GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
 
   color_balance_create_lookup_tables (cb_tool->color_balance);
-  gimp_image_map_apply (im_tool->image_map,
-                        (GimpImageMapApplyFunc) color_balance,
-                        cb_tool->color_balance);
 }
 
 

Modified: branches/weskaggs/app/tools/gimpcolorizetool.c
==============================================================================
--- branches/weskaggs/app/tools/gimpcolorizetool.c	(original)
+++ branches/weskaggs/app/tools/gimpcolorizetool.c	Thu Jan 10 03:08:46 2008
@@ -42,29 +42,28 @@
 
 
 #define SLIDER_WIDTH 200
-#define DA_WIDTH      40
-#define DA_HEIGHT     20
 
 
 /*  local function prototypes  */
 
-static void     gimp_colorize_tool_finalize    (GObject          *object);
+static void       gimp_colorize_tool_finalize      (GObject          *object);
 
-static gboolean gimp_colorize_tool_initialize  (GimpTool         *tool,
-                                                GimpDisplay      *display,
-                                                GError          **error);
-
-static void     gimp_colorize_tool_map         (GimpImageMapTool *im_tool);
-static void     gimp_colorize_tool_dialog      (GimpImageMapTool *im_tool);
-static void     gimp_colorize_tool_reset       (GimpImageMapTool *im_tool);
-
-static void     colorize_update_sliders        (GimpColorizeTool *col_tool);
-static void     colorize_hue_changed           (GtkAdjustment    *adj,
-                                                GimpColorizeTool *col_tool);
-static void     colorize_saturation_changed    (GtkAdjustment    *adj,
-                                                GimpColorizeTool *col_tool);
-static void     colorize_lightness_changed     (GtkAdjustment    *adj,
-                                                GimpColorizeTool *col_tool);
+static gboolean   gimp_colorize_tool_initialize    (GimpTool         *tool,
+                                                    GimpDisplay      *display,
+                                                    GError          **error);
+
+static GeglNode * gimp_colorize_tool_get_operation (GimpImageMapTool  *im_tool);
+static void       gimp_colorize_tool_map           (GimpImageMapTool *im_tool);
+static void       gimp_colorize_tool_dialog        (GimpImageMapTool *im_tool);
+static void       gimp_colorize_tool_reset         (GimpImageMapTool *im_tool);
+
+static void       colorize_update_sliders          (GimpColorizeTool *col_tool);
+static void       colorize_hue_changed             (GtkAdjustment    *adj,
+                                                    GimpColorizeTool *col_tool);
+static void       colorize_saturation_changed      (GtkAdjustment    *adj,
+                                                    GimpColorizeTool *col_tool);
+static void       colorize_lightness_changed       (GtkAdjustment    *adj,
+                                                    GimpColorizeTool *col_tool);
 
 
 G_DEFINE_TYPE (GimpColorizeTool, gimp_colorize_tool, GIMP_TYPE_IMAGE_MAP_TOOL)
@@ -95,23 +94,29 @@
   GimpToolClass         *tool_class    = GIMP_TOOL_CLASS (klass);
   GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
 
-  object_class->finalize    = gimp_colorize_tool_finalize;
+  object_class->finalize       = gimp_colorize_tool_finalize;
 
-  tool_class->initialize    = gimp_colorize_tool_initialize;
+  tool_class->initialize       = gimp_colorize_tool_initialize;
 
-  im_tool_class->shell_desc = _("Colorize the Image");
+  im_tool_class->shell_desc    = _("Colorize the Image");
 
-  im_tool_class->map        = gimp_colorize_tool_map;
-  im_tool_class->dialog     = gimp_colorize_tool_dialog;
-  im_tool_class->reset      = gimp_colorize_tool_reset;
+  im_tool_class->get_operation = gimp_colorize_tool_get_operation;
+  im_tool_class->map           = gimp_colorize_tool_map;
+  im_tool_class->dialog        = gimp_colorize_tool_dialog;
+  im_tool_class->reset         = gimp_colorize_tool_reset;
 }
 
 static void
 gimp_colorize_tool_init (GimpColorizeTool *col_tool)
 {
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (col_tool);
+
   col_tool->colorize = g_slice_new0 (Colorize);
 
   colorize_init (col_tool->colorize);
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) colorize;
+  im_tool->apply_data = col_tool->colorize;
 }
 
 static void
@@ -143,7 +148,6 @@
     }
 
   colorize_init (col_tool->colorize);
-  colorize_calculate (col_tool->colorize);
 
   GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
 
@@ -154,14 +158,29 @@
   return TRUE;
 }
 
+static GeglNode *
+gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool)
+{
+  return g_object_new (GEGL_TYPE_NODE,
+                       "operation", "gimp-colorize",
+                       NULL);
+}
+
 static void
 gimp_colorize_tool_map (GimpImageMapTool *image_map_tool)
 {
   GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
 
-  gimp_image_map_apply (image_map_tool->image_map,
-                        (GimpImageMapApplyFunc) colorize,
-                        col_tool->colorize);
+  if (image_map_tool->operation)
+    {
+      gegl_node_set (image_map_tool->operation,
+                     "hue",        col_tool->colorize->hue,
+                     "saturation", col_tool->colorize->saturation,
+                     "lightness",  col_tool->colorize->lightness,
+                     NULL);
+    }
+
+  colorize_calculate (col_tool->colorize);
 }
 
 
@@ -244,7 +263,6 @@
   GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
 
   colorize_init (col_tool->colorize);
-  colorize_calculate (col_tool->colorize);
 
   colorize_update_sliders (col_tool);
 }
@@ -267,7 +285,6 @@
   if (col_tool->colorize->hue != adjustment->value)
     {
       col_tool->colorize->hue = adjustment->value;
-      colorize_calculate (col_tool->colorize);
 
       gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
     }
@@ -280,7 +297,6 @@
   if (col_tool->colorize->saturation != adjustment->value)
     {
       col_tool->colorize->saturation = adjustment->value;
-      colorize_calculate (col_tool->colorize);
 
       gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
     }
@@ -293,7 +309,6 @@
   if (col_tool->colorize->lightness != adjustment->value)
     {
       col_tool->colorize->lightness = adjustment->value;
-      colorize_calculate (col_tool->colorize);
 
       gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
     }

Modified: branches/weskaggs/app/tools/gimpcurvestool.c
==============================================================================
--- branches/weskaggs/app/tools/gimpcurvestool.c	(original)
+++ branches/weskaggs/app/tools/gimpcurvestool.c	Thu Jan 10 03:08:46 2008
@@ -171,7 +171,8 @@
 static void
 gimp_curves_tool_init (GimpCurvesTool *tool)
 {
-  gint i;
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
+  gint              i;
 
   for (i = 0; i < G_N_ELEMENTS (tool->curve); i++)
     {
@@ -187,6 +188,9 @@
 
   for (i = 0; i < G_N_ELEMENTS (tool->col_value); i++)
     tool->col_value[i] = -1;
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
+  im_tool->apply_data = tool->lut;
 }
 
 static void
@@ -411,10 +415,6 @@
                   (GimpLutFunc) curves_lut_func,
                   &curves,
                   gimp_drawable_bytes (image_map_tool->drawable));
-
-  gimp_image_map_apply (image_map_tool->image_map,
-                        (GimpImageMapApplyFunc) gimp_lut_process,
-                        tool->lut);
 }
 
 

Modified: branches/weskaggs/app/tools/gimphuesaturationtool.c
==============================================================================
--- branches/weskaggs/app/tools/gimphuesaturationtool.c	(original)
+++ branches/weskaggs/app/tools/gimphuesaturationtool.c	Thu Jan 10 03:08:46 2008
@@ -129,10 +129,15 @@
 static void
 gimp_hue_saturation_tool_init (GimpHueSaturationTool *hs_tool)
 {
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (hs_tool);
+
   hs_tool->hue_saturation = g_slice_new0 (HueSaturation);
   hs_tool->hue_partition  = GIMP_ALL_HUES;
 
   hue_saturation_init (hs_tool->hue_saturation);
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) hue_saturation;
+  im_tool->apply_data = hs_tool->hue_saturation;
 }
 
 static void
@@ -179,11 +184,6 @@
 static void
 gimp_hue_saturation_tool_map (GimpImageMapTool *image_map_tool)
 {
-  GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
-
-  gimp_image_map_apply (image_map_tool->image_map,
-                        (GimpImageMapApplyFunc) hue_saturation,
-                        hs_tool->hue_saturation);
 }
 
 

Modified: branches/weskaggs/app/tools/gimpimagemaptool.c
==============================================================================
--- branches/weskaggs/app/tools/gimpimagemaptool.c	(original)
+++ branches/weskaggs/app/tools/gimpimagemaptool.c	Thu Jan 10 03:08:46 2008
@@ -30,6 +30,9 @@
 
 #include "tools-types.h"
 
+/* temp */
+#include "config/gimpcoreconfig.h"
+
 #include "core/gimp.h"
 #include "core/gimpcontext.h"
 #include "core/gimpdrawable.h"
@@ -46,6 +49,8 @@
 #include "widgets/gimpwidgets-utils.h"
 
 #include "display/gimpdisplay.h"
+#include "display/gimpdisplayshell.h"
+#include "display/gimpdisplayshell-transform.h"
 
 #include "gimpcoloroptions.h"
 #include "gimpimagemaptool.h"
@@ -104,7 +109,8 @@
 static void     gimp_image_map_tool_notify_preview   (GObject          *config,
                                                       GParamSpec       *pspec,
                                                       GimpImageMapTool *im_tool);
-static void     gimp_image_map_tool_gegl_toggled     (GtkWidget        *toggle,
+static void     gimp_image_map_tool_gegl_notify      (GObject          *config,
+                                                      const GParamSpec *pspec,
                                                       GimpImageMapTool *im_tool);
 
 
@@ -135,6 +141,7 @@
   klass->save_dialog_title = NULL;
   klass->save_button_tip   = NULL;
 
+  klass->get_operation     = NULL;
   klass->map               = NULL;
   klass->dialog            = NULL;
   klass->reset             = NULL;
@@ -155,13 +162,15 @@
                                      GIMP_DIRTY_DRAWABLE        |
                                      GIMP_DIRTY_SELECTION);
 
-  image_map_tool->drawable  = NULL;
-  image_map_tool->image_map = NULL;
-
-  image_map_tool->shell       = NULL;
-  image_map_tool->main_vbox   = NULL;
-  image_map_tool->load_button = NULL;
-  image_map_tool->save_button = NULL;
+  image_map_tool->drawable        = NULL;
+  image_map_tool->operation       = NULL;
+  image_map_tool->image_map       = NULL;
+
+  image_map_tool->shell           = NULL;
+  image_map_tool->main_vbox       = NULL;
+  image_map_tool->load_button     = NULL;
+  image_map_tool->save_button     = NULL;
+  image_map_tool->settings_dialog = NULL;
 }
 
 static void
@@ -251,23 +260,6 @@
                                G_CALLBACK (gimp_image_map_tool_notify_preview),
                                image_map_tool, 0);
 
-      if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool)->get_operation)
-        {
-          image_map_tool->use_gegl = TRUE;
-
-          toggle = gtk_check_button_new_with_label ("Use GEGL");
-          gtk_box_pack_end (GTK_BOX (image_map_tool->main_vbox), toggle,
-                            FALSE, FALSE, 0);
-          gtk_widget_show (toggle);
-
-          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
-                                        image_map_tool->use_gegl);
-
-          g_signal_connect (toggle, "toggled",
-                            G_CALLBACK (gimp_image_map_tool_gegl_toggled),
-                            image_map_tool);
-        }
-
       if (klass->load_dialog_title)
         {
           image_map_tool->load_button =
@@ -330,6 +322,11 @@
       gimp_image_map_tool_dialog (image_map_tool);
 
       gtk_widget_show (vbox);
+
+      if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool)->get_operation)
+        g_signal_connect_object (tool_info->gimp->config, "notify::use-gegl",
+                                 G_CALLBACK (gimp_image_map_tool_gegl_notify),
+                                 image_map_tool, 0);
     }
 
   drawable = gimp_image_get_active_drawable (display->image);
@@ -426,7 +423,33 @@
 static void
 gimp_image_map_tool_map (GimpImageMapTool *tool)
 {
+  GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (GIMP_TOOL (tool)->display->shell);
+  GimpItem         *item  = GIMP_ITEM (tool->drawable);
+  gint              x, y;
+  gint              w, h;
+  gint              off_x, off_y;
+  GeglRectangle     visible;
+
   GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->map (tool);
+
+  gimp_display_shell_untransform_viewport (shell, &x, &y, &w, &h);
+
+  gimp_item_offsets (item, &off_x, &off_y);
+
+  gimp_rectangle_intersect (x, y, w, h,
+                            off_x,
+                            off_y,
+                            gimp_item_width  (item),
+                            gimp_item_height (item),
+                            &visible.x,
+                            &visible.y,
+                            &visible.width,
+                            &visible.height);
+
+  visible.x -= off_x;
+  visible.y -= off_y;
+
+  gimp_image_map_apply (tool->image_map, &visible);
 }
 
 static void
@@ -444,7 +467,7 @@
 static void
 gimp_image_map_tool_create_map (GimpImageMapTool *tool)
 {
-  GeglNode *operation = NULL;
+  GimpCoreConfig *config = GIMP_TOOL (tool)->tool_info->gimp->config;
 
   if (tool->image_map)
     {
@@ -452,12 +475,16 @@
       g_object_unref (tool->image_map);
     }
 
-  if (tool->use_gegl && ! tool->operation)
+  if (config->use_gegl && ! tool->operation &&
+      GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->get_operation)
     tool->operation = GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->get_operation (tool);
 
   tool->image_map = gimp_image_map_new (tool->drawable,
                                         GIMP_TOOL (tool)->tool_info->blurb,
-                                        tool->operation);
+                                        config->use_gegl ?
+                                        tool->operation : NULL,
+                                        tool->apply_func,
+                                        tool->apply_data);
 
   g_signal_connect (tool->image_map, "flush",
                     G_CALLBACK (gimp_image_map_tool_flush),
@@ -846,16 +873,18 @@
 }
 
 static void
-gimp_image_map_tool_gegl_toggled (GtkWidget        *toggle,
-                                  GimpImageMapTool *im_tool)
+gimp_image_map_tool_gegl_notify (GObject          *config,
+                                 const GParamSpec *pspec,
+                                 GimpImageMapTool *im_tool)
 {
-  im_tool->use_gegl = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (toggle));
-
-  gimp_tool_control_set_preserve (GIMP_TOOL (im_tool)->control, TRUE);
+  if (im_tool->image_map)
+    {
+      gimp_tool_control_set_preserve (GIMP_TOOL (im_tool)->control, TRUE);
 
-  gimp_image_map_tool_create_map (im_tool);
+      gimp_image_map_tool_create_map (im_tool);
 
-  gimp_tool_control_set_preserve (GIMP_TOOL (im_tool)->control, FALSE);
+      gimp_tool_control_set_preserve (GIMP_TOOL (im_tool)->control, FALSE);
 
-  gimp_image_map_tool_preview (im_tool);
+      gimp_image_map_tool_preview (im_tool);
+    }
 }

Modified: branches/weskaggs/app/tools/gimpimagemaptool.h
==============================================================================
--- branches/weskaggs/app/tools/gimpimagemaptool.h	(original)
+++ branches/weskaggs/app/tools/gimpimagemaptool.h	Thu Jan 10 03:08:46 2008
@@ -41,23 +41,24 @@
 
 struct _GimpImageMapTool
 {
-  GimpColorTool  parent_instance;
+  GimpColorTool          parent_instance;
 
-  GimpDrawable  *drawable;
-  GeglNode      *operation;
-  GimpImageMap  *image_map;
+  GimpDrawable          *drawable;
+
+  GeglNode              *operation;
+  GimpImageMapApplyFunc  apply_func;
+  gpointer               apply_data;
+
+  GimpImageMap          *image_map;
 
   /* dialog */
-  GtkWidget     *shell;
-  GtkWidget     *main_vbox;
-  GtkWidget     *load_button;
-  GtkWidget     *save_button;
+  GtkWidget             *shell;
+  GtkWidget             *main_vbox;
+  GtkWidget             *load_button;
+  GtkWidget             *save_button;
 
   /* settings file dialog */
-  GtkWidget     *settings_dialog;
-
-  /* temp hack */
-  gboolean       use_gegl;
+  GtkWidget             *settings_dialog;
 };
 
 struct _GimpImageMapToolClass

Modified: branches/weskaggs/app/tools/gimplevelstool.c
==============================================================================
--- branches/weskaggs/app/tools/gimplevelstool.c	(original)
+++ branches/weskaggs/app/tools/gimplevelstool.c	Thu Jan 10 03:08:46 2008
@@ -68,56 +68,57 @@
 
 /*  local function prototypes  */
 
-static void     gimp_levels_tool_finalize       (GObject           *object);
+static void       gimp_levels_tool_finalize       (GObject           *object);
 
-static gboolean gimp_levels_tool_initialize     (GimpTool          *tool,
-                                                 GimpDisplay       *display,
-                                                 GError           **error);
-
-static void     gimp_levels_tool_color_picked   (GimpColorTool     *color_tool,
-                                                 GimpColorPickState pick_state,
-                                                 GimpImageType      sample_type,
-                                                 GimpRGB           *color,
-                                                 gint               color_index);
-
-static void     gimp_levels_tool_map            (GimpImageMapTool  *image_map_tool);
-static void     gimp_levels_tool_dialog         (GimpImageMapTool  *image_map_tool);
-static void     gimp_levels_tool_dialog_unmap   (GtkWidget         *dialog,
-                                                 GimpLevelsTool    *tool);
-static void     gimp_levels_tool_reset          (GimpImageMapTool  *image_map_tool);
-static gboolean gimp_levels_tool_settings_load  (GimpImageMapTool  *image_mao_tool,
-                                                 gpointer           fp,
-                                                 GError           **error);
-static gboolean gimp_levels_tool_settings_save  (GimpImageMapTool  *image_map_tool,
-                                                 gpointer           fp);
-
-static void     levels_update_adjustments       (GimpLevelsTool    *tool);
-static void     levels_update_input_bar         (GimpLevelsTool    *tool);
-
-static void     levels_channel_callback         (GtkWidget         *widget,
-                                                 GimpLevelsTool    *tool);
-static void     levels_channel_reset_callback   (GtkWidget         *widget,
-                                                 GimpLevelsTool    *tool);
-
-static gboolean levels_menu_sensitivity         (gint               value,
-                                                 gpointer           data);
-
-static void     levels_stretch_callback         (GtkWidget         *widget,
-                                                 GimpLevelsTool    *tool);
-static void     levels_low_input_changed        (GtkAdjustment     *adjustment,
-                                                 GimpLevelsTool    *tool);
-static void     levels_gamma_changed            (GtkAdjustment     *adjustment,
-                                                 GimpLevelsTool    *tool);
-static void     levels_linear_gamma_changed     (GtkAdjustment     *adjustment,
-                                                 GimpLevelsTool    *tool);
-static void     levels_high_input_changed       (GtkAdjustment     *adjustment,
-                                                 GimpLevelsTool    *tool);
-static void     levels_low_output_changed       (GtkAdjustment     *adjustment,
-                                                 GimpLevelsTool    *tool);
-static void     levels_high_output_changed      (GtkAdjustment     *adjustment,
-                                                 GimpLevelsTool    *tool);
-static void     levels_input_picker_toggled     (GtkWidget         *widget,
-                                                 GimpLevelsTool    *tool);
+static gboolean   gimp_levels_tool_initialize     (GimpTool          *tool,
+                                                   GimpDisplay       *display,
+                                                   GError           **error);
+
+static void       gimp_levels_tool_color_picked   (GimpColorTool     *color_tool,
+                                                   GimpColorPickState pick_state,
+                                                   GimpImageType      sample_type,
+                                                   GimpRGB           *color,
+                                                   gint               color_index);
+
+static GeglNode * gimp_levels_tool_get_operation  (GimpImageMapTool  *im_tool);
+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);
+static void       gimp_levels_tool_reset          (GimpImageMapTool  *im_tool);
+static gboolean   gimp_levels_tool_settings_load  (GimpImageMapTool  *im_tool,
+                                                   gpointer           fp,
+                                                   GError           **error);
+static gboolean   gimp_levels_tool_settings_save  (GimpImageMapTool  *im_tool,
+                                                   gpointer           fp);
+
+static void       levels_update_adjustments       (GimpLevelsTool    *tool);
+static void       levels_update_input_bar         (GimpLevelsTool    *tool);
+
+static void       levels_channel_callback         (GtkWidget         *widget,
+                                                   GimpLevelsTool    *tool);
+static void       levels_channel_reset_callback   (GtkWidget         *widget,
+                                                   GimpLevelsTool    *tool);
+
+static gboolean   levels_menu_sensitivity         (gint               value,
+                                                   gpointer           data);
+
+static void       levels_stretch_callback         (GtkWidget         *widget,
+                                                   GimpLevelsTool    *tool);
+static void       levels_low_input_changed        (GtkAdjustment     *adjustment,
+                                                   GimpLevelsTool    *tool);
+static void       levels_gamma_changed            (GtkAdjustment     *adjustment,
+                                                   GimpLevelsTool    *tool);
+static void       levels_linear_gamma_changed     (GtkAdjustment     *adjustment,
+                                                   GimpLevelsTool    *tool);
+static void       levels_high_input_changed       (GtkAdjustment     *adjustment,
+                                                   GimpLevelsTool    *tool);
+static void       levels_low_output_changed       (GtkAdjustment     *adjustment,
+                                                   GimpLevelsTool    *tool);
+static void       levels_high_output_changed      (GtkAdjustment     *adjustment,
+                                                   GimpLevelsTool    *tool);
+static void       levels_input_picker_toggled     (GtkWidget         *widget,
+                                                   GimpLevelsTool    *tool);
 
 
 G_DEFINE_TYPE (GimpLevelsTool, gimp_levels_tool, GIMP_TYPE_IMAGE_MAP_TOOL)
@@ -163,6 +164,7 @@
   im_tool_class->save_dialog_title = _("Save Levels");
   im_tool_class->save_button_tip   = _("Save levels settings to file");
 
+  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;
@@ -173,6 +175,8 @@
 static void
 gimp_levels_tool_init (GimpLevelsTool *tool)
 {
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
+
   tool->lut           = gimp_lut_new ();
   tool->levels        = g_slice_new0 (Levels);
   tool->hist          = NULL;
@@ -180,6 +184,9 @@
   tool->active_picker = NULL;
 
   levels_init (tool->levels);
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
+  im_tool->apply_data = tool->lut;
 }
 
 static void
@@ -251,19 +258,56 @@
   return TRUE;
 }
 
+static GeglNode *
+gimp_levels_tool_get_operation (GimpImageMapTool *im_tool)
+{
+  return g_object_new (GEGL_TYPE_NODE,
+                       "operation", "gimp-levels",
+                       NULL);
+}
+
 static void
 gimp_levels_tool_map (GimpImageMapTool *image_map_tool)
 {
   GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
 
+  if (image_map_tool->operation)
+    {
+      Levels               *levels = tool->levels;
+      GimpHistogramChannel  channel;
+
+      for (channel = GIMP_HISTOGRAM_VALUE;
+           channel <= GIMP_HISTOGRAM_ALPHA;
+           channel++)
+        {
+          /* FIXME: hack */
+          if (! tool->color && channel == 1)
+            gegl_node_set (image_map_tool->operation,
+                           "channel", GIMP_HISTOGRAM_ALPHA,
+                           NULL);
+          else
+            gegl_node_set (image_map_tool->operation,
+                           "channel", channel,
+                           NULL);
+
+          gegl_node_set (image_map_tool->operation,
+                         "gamma",       levels->gamma[channel],
+                         "low-input",   levels->low_input[channel]   / 255.0,
+                         "high-input",  levels->high_input[channel]  / 255.0,
+                         "low-output",  levels->low_output[channel]  / 255.0,
+                         "high-output", levels->high_output[channel] / 255.0,
+                         NULL);
+
+          /* FIXME: hack */
+          if (! tool->color && channel == 1)
+            break;
+        }
+    }
+
   gimp_lut_setup (tool->lut,
                   (GimpLutFunc) levels_lut_func,
                   tool->levels,
                   gimp_drawable_bytes (image_map_tool->drawable));
-
-  gimp_image_map_apply (image_map_tool->image_map,
-                        (GimpImageMapApplyFunc) gimp_lut_process,
-                        tool->lut);
 }
 
 

Modified: branches/weskaggs/app/tools/gimpposterizetool.c
==============================================================================
--- branches/weskaggs/app/tools/gimpposterizetool.c	(original)
+++ branches/weskaggs/app/tools/gimpposterizetool.c	Thu Jan 10 03:08:46 2008
@@ -47,18 +47,19 @@
 #define SLIDER_WIDTH 200
 
 
-static void     gimp_posterize_tool_finalize       (GObject           *object);
+static void       gimp_posterize_tool_finalize       (GObject           *object);
 
-static gboolean gimp_posterize_tool_initialize     (GimpTool          *tool,
-                                                    GimpDisplay       *display,
-                                                    GError           **error);
-
-static void     gimp_posterize_tool_map            (GimpImageMapTool  *im_tool);
-static void     gimp_posterize_tool_dialog         (GimpImageMapTool  *im_tool);
-static void     gimp_posterize_tool_reset          (GimpImageMapTool  *im_tool);
+static gboolean   gimp_posterize_tool_initialize     (GimpTool          *tool,
+                                                      GimpDisplay       *display,
+                                                      GError           **error);
+
+static GeglNode * gimp_posterize_tool_get_operation  (GimpImageMapTool  *im_tool);
+static void       gimp_posterize_tool_map            (GimpImageMapTool  *im_tool);
+static void       gimp_posterize_tool_dialog         (GimpImageMapTool  *im_tool);
+static void       gimp_posterize_tool_reset          (GimpImageMapTool  *im_tool);
 
-static void     posterize_levels_adjustment_update (GtkAdjustment     *adjustment,
-                                                    GimpPosterizeTool *posterize_tool);
+static void       gimp_posterize_tool_levels_changed (GtkAdjustment     *adjustment,
+                                                      GimpPosterizeTool *posterize_tool);
 
 
 G_DEFINE_TYPE (GimpPosterizeTool, gimp_posterize_tool,
@@ -90,22 +91,28 @@
   GimpToolClass         *tool_class    = GIMP_TOOL_CLASS (klass);
   GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
 
-  object_class->finalize    = gimp_posterize_tool_finalize;
+  object_class->finalize       = gimp_posterize_tool_finalize;
 
-  tool_class->initialize    = gimp_posterize_tool_initialize;
+  tool_class->initialize       = gimp_posterize_tool_initialize;
 
-  im_tool_class->shell_desc = _("Posterize (Reduce Number of Colors)");
+  im_tool_class->shell_desc    = _("Posterize (Reduce Number of Colors)");
 
-  im_tool_class->map        = gimp_posterize_tool_map;
-  im_tool_class->dialog     = gimp_posterize_tool_dialog;
-  im_tool_class->reset      = gimp_posterize_tool_reset;
+  im_tool_class->get_operation = gimp_posterize_tool_get_operation;
+  im_tool_class->map           = gimp_posterize_tool_map;
+  im_tool_class->dialog        = gimp_posterize_tool_dialog;
+  im_tool_class->reset         = gimp_posterize_tool_reset;
 }
 
 static void
 gimp_posterize_tool_init (GimpPosterizeTool *posterize_tool)
 {
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (posterize_tool);
+
   posterize_tool->levels = POSTERIZE_DEFAULT_LEVELS;
   posterize_tool->lut    = gimp_lut_new ();
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
+  im_tool->apply_data = posterize_tool->lut;
 }
 
 static void
@@ -154,17 +161,29 @@
   return TRUE;
 }
 
+static GeglNode *
+gimp_posterize_tool_get_operation (GimpImageMapTool *im_tool)
+{
+  return g_object_new (GEGL_TYPE_NODE,
+                       "operation", "gimp-posterize",
+                       NULL);
+}
+
 static void
 gimp_posterize_tool_map (GimpImageMapTool *image_map_tool)
 {
   GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
 
+  if (image_map_tool->operation)
+    {
+      gegl_node_set (image_map_tool->operation,
+                     "levels", posterize_tool->levels,
+                     NULL);
+    }
+
   posterize_lut_setup (posterize_tool->lut,
                        posterize_tool->levels,
                        gimp_drawable_bytes (image_map_tool->drawable));
-  gimp_image_map_apply (image_map_tool->image_map,
-                        (GimpImageMapApplyFunc) gimp_lut_process,
-                        posterize_tool->lut);
 }
 
 
@@ -198,7 +217,7 @@
   gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
 
   g_signal_connect (posterize_tool->levels_data, "value-changed",
-                    G_CALLBACK (posterize_levels_adjustment_update),
+                    G_CALLBACK (gimp_posterize_tool_levels_changed),
                     posterize_tool);
 }
 
@@ -214,7 +233,7 @@
 }
 
 static void
-posterize_levels_adjustment_update (GtkAdjustment     *adjustment,
+gimp_posterize_tool_levels_changed (GtkAdjustment     *adjustment,
                                     GimpPosterizeTool *posterize_tool)
 {
   if (posterize_tool->levels != adjustment->value)

Modified: branches/weskaggs/app/tools/gimprotatetool.c
==============================================================================
--- branches/weskaggs/app/tools/gimprotatetool.c	(original)
+++ branches/weskaggs/app/tools/gimprotatetool.c	Thu Jan 10 03:08:46 2008
@@ -283,21 +283,19 @@
   /*  limit the angle to between -180 and 180 degrees  */
   if (tr_tool->trans_info[REAL_ANGLE] < - G_PI)
     {
-      tr_tool->trans_info[REAL_ANGLE] =
-        2.0 * G_PI + tr_tool->trans_info[REAL_ANGLE];
+      tr_tool->trans_info[REAL_ANGLE] += 2.0 * G_PI;
     }
   else if (tr_tool->trans_info[REAL_ANGLE] > G_PI)
     {
-      tr_tool->trans_info[REAL_ANGLE] =
-        tr_tool->trans_info[REAL_ANGLE] - 2.0 * G_PI;
+      tr_tool->trans_info[REAL_ANGLE] -= 2.0 * G_PI;
     }
 
   /*  constrain the angle to 15-degree multiples if ctrl is held down  */
   if (options->constrain)
     {
       tr_tool->trans_info[ANGLE] =
-        FIFTEEN_DEG * (int) ((tr_tool->trans_info[REAL_ANGLE] +
-                              FIFTEEN_DEG / 2.0) / FIFTEEN_DEG);
+        FIFTEEN_DEG * (gint) ((tr_tool->trans_info[REAL_ANGLE] +
+                               FIFTEEN_DEG / 2.0) / FIFTEEN_DEG);
     }
   else
     {
@@ -331,7 +329,7 @@
     {
       gimp_draw_tool_pause (GIMP_DRAW_TOOL (tr_tool));
 
-      tr_tool->trans_info[ANGLE] = value;
+      tr_tool->trans_info[REAL_ANGLE] = tr_tool->trans_info[ANGLE] = value;
 
       gimp_transform_tool_recalc (tr_tool, GIMP_TOOL (tr_tool)->display);
 

Modified: branches/weskaggs/app/tools/gimpthresholdtool.c
==============================================================================
--- branches/weskaggs/app/tools/gimpthresholdtool.c	(original)
+++ branches/weskaggs/app/tools/gimpthresholdtool.c	Thu Jan 10 03:08:46 2008
@@ -111,11 +111,16 @@
 static void
 gimp_threshold_tool_init (GimpThresholdTool *t_tool)
 {
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (t_tool);
+
   t_tool->threshold = g_slice_new0 (Threshold);
   t_tool->hist      = NULL;
 
   t_tool->threshold->low_threshold  = 127;
   t_tool->threshold->high_threshold = 255;
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) threshold;
+  im_tool->apply_data = t_tool->threshold;
 }
 
 static void
@@ -200,10 +205,6 @@
                      "high", t_tool->threshold->high_threshold / 255.0,
                      NULL);
     }
-
-  gimp_image_map_apply (image_map_tool->image_map,
-                        (GimpImageMapApplyFunc) threshold,
-                        t_tool->threshold);
 }
 
 

Modified: branches/weskaggs/app/tools/makefile.msc
==============================================================================
--- branches/weskaggs/app/tools/makefile.msc	(original)
+++ branches/weskaggs/app/tools/makefile.msc	Thu Jan 10 03:08:46 2008
@@ -114,6 +114,7 @@
 	-I$(top_srcdir) \
 	-I$(top_srcdir)/app \
 	$(GTK2_CFLAGS) $(FREETYPE2_CFLAGS) \
+	$(GEGL_CFLAGS) \
 	-I$(includedir)
 	
 all : \

Modified: branches/weskaggs/app/vectors/gimpvectors.c
==============================================================================
--- branches/weskaggs/app/vectors/gimpvectors.c	(original)
+++ branches/weskaggs/app/vectors/gimpvectors.c	Thu Jan 10 03:08:46 2008
@@ -65,8 +65,7 @@
 
 static gboolean   gimp_vectors_is_attached  (GimpItem         *item);
 static GimpItem * gimp_vectors_duplicate    (GimpItem         *item,
-                                             GType             new_type,
-                                             gboolean          add_alpha);
+                                             GType             new_type);
 static void       gimp_vectors_convert      (GimpItem         *item,
                                              GimpImage        *dest_image);
 static void       gimp_vectors_translate    (GimpItem         *item,
@@ -271,15 +270,13 @@
 
 static GimpItem *
 gimp_vectors_duplicate (GimpItem *item,
-                        GType     new_type,
-                        gboolean  add_alpha)
+                        GType     new_type)
 {
   GimpItem *new_item;
 
   g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_VECTORS), NULL);
 
-  new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
-                                                        add_alpha);
+  new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type);
 
   if (GIMP_IS_VECTORS (new_item))
     {

Modified: branches/weskaggs/app/vectors/gimpvectorsmodundo.c
==============================================================================
--- branches/weskaggs/app/vectors/gimpvectorsmodundo.c	(original)
+++ branches/weskaggs/app/vectors/gimpvectorsmodundo.c	Thu Jan 10 03:08:46 2008
@@ -84,8 +84,7 @@
 
   vectors_mod_undo->vectors =
     GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
-                                       G_TYPE_FROM_INSTANCE (vectors),
-                                       FALSE));
+                                       G_TYPE_FROM_INSTANCE (vectors)));
 
   return object;
 }
@@ -119,8 +118,7 @@
 
   vectors_mod_undo->vectors =
     GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
-                                       G_TYPE_FROM_INSTANCE (vectors),
-                                       FALSE));
+                                       G_TYPE_FROM_INSTANCE (vectors)));
 
   gimp_vectors_freeze (vectors);
 

Modified: branches/weskaggs/app/widgets/gimpchanneltreeview.c
==============================================================================
--- branches/weskaggs/app/widgets/gimpchanneltreeview.c	(original)
+++ branches/weskaggs/app/widgets/gimpchanneltreeview.c	Thu Jan 10 03:08:46 2008
@@ -207,7 +207,7 @@
 
       new_item = gimp_item_convert (GIMP_ITEM (src_viewable),
                                     item_view->image,
-                                    item_view_class->item_type, FALSE);
+                                    item_view_class->item_type);
 
       gimp_item_set_linked (new_item, FALSE, FALSE);
 

Modified: branches/weskaggs/app/widgets/gimpitemtreeview.c
==============================================================================
--- branches/weskaggs/app/widgets/gimpitemtreeview.c	(original)
+++ branches/weskaggs/app/widgets/gimpitemtreeview.c	Thu Jan 10 03:08:46 2008
@@ -736,7 +736,7 @@
         dest_index++;
 
       new_item = gimp_item_convert (GIMP_ITEM (src_viewable),
-                                    item_view->image, item_type, TRUE);
+                                    item_view->image, item_type);
 
       gimp_item_set_linked (new_item, FALSE, FALSE);
 

Modified: branches/weskaggs/app/widgets/gimplayertreeview.c
==============================================================================
--- branches/weskaggs/app/widgets/gimplayertreeview.c	(original)
+++ branches/weskaggs/app/widgets/gimplayertreeview.c	Thu Jan 10 03:08:46 2008
@@ -764,7 +764,7 @@
   channel = gimp_channel_new_from_component (src_image, component, NULL, NULL);
 
   new_item = gimp_item_convert (GIMP_ITEM (channel), item_view->image,
-                                GIMP_TYPE_LAYER, TRUE);
+                                GIMP_TYPE_LAYER);
 
   g_object_unref (channel);
 

Modified: branches/weskaggs/app/widgets/gimptoolbox-dnd.c
==============================================================================
--- branches/weskaggs/app/widgets/gimptoolbox-dnd.c	(original)
+++ branches/weskaggs/app/widgets/gimptoolbox-dnd.c	Thu Jan 10 03:08:46 2008
@@ -185,8 +185,8 @@
   else
     new_type = GIMP_TYPE_LAYER;
 
-  new_layer = GIMP_LAYER (gimp_item_convert (GIMP_ITEM (drawable), new_image,
-                                             new_type, FALSE));
+  new_layer = GIMP_LAYER (gimp_item_convert (GIMP_ITEM (drawable),
+                                             new_image, new_type));
 
   gimp_object_set_name (GIMP_OBJECT (new_layer),
                         gimp_object_get_name (GIMP_OBJECT (drawable)));
@@ -276,9 +276,8 @@
 
   channel = gimp_channel_new_from_component (image, component, NULL, NULL);
 
-  new_layer = GIMP_LAYER (gimp_item_convert (GIMP_ITEM (channel), new_image,
-                                             GIMP_TYPE_LAYER, FALSE));
-
+  new_layer = GIMP_LAYER (gimp_item_convert (GIMP_ITEM (channel),
+                                             new_image, GIMP_TYPE_LAYER));
   g_object_unref (channel);
 
   gimp_enum_get_value (GIMP_TYPE_CHANNEL_TYPE, component,

Modified: branches/weskaggs/app/widgets/gimptoolbox.c
==============================================================================
--- branches/weskaggs/app/widgets/gimptoolbox.c	(original)
+++ branches/weskaggs/app/widgets/gimptoolbox.c	Thu Jan 10 03:08:46 2008
@@ -286,6 +286,15 @@
                            G_CALLBACK (toolbox_area_notify),
                            toolbox->image_area, 0);
 
+  {
+    GtkWidget *button;
+
+    button = gimp_prop_check_button_new (G_OBJECT (config), "use-gegl",
+                                         "Use GEGL");
+    gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+    gtk_widget_show (button);
+  }
+
   g_signal_connect_object (context, "tool-changed",
                            G_CALLBACK (toolbox_tool_changed),
                            toolbox->tool_wbox,

Modified: branches/weskaggs/app/widgets/makefile.msc
==============================================================================
--- branches/weskaggs/app/widgets/makefile.msc	(original)
+++ branches/weskaggs/app/widgets/makefile.msc	Thu Jan 10 03:08:46 2008
@@ -35,7 +35,6 @@
 	gimpbrushfactoryview.obj \
 	gimpbrushselect.obj \
 	gimpbufferview.obj \
-	gimpcairo-utils.obj \
 	gimpcellrendererdashes.obj \
 	gimpcellrendererviewable.obj \
 	gimpchanneltreeview.obj \

Modified: branches/weskaggs/app/widgets/widgets-types.h
==============================================================================
--- branches/weskaggs/app/widgets/widgets-types.h	(original)
+++ branches/weskaggs/app/widgets/widgets-types.h	Thu Jan 10 03:08:46 2008
@@ -127,6 +127,7 @@
 /*  misc dialogs  */
 
 typedef struct _GimpColorDialog              GimpColorDialog;
+typedef struct _GimpDataChooserDialog        GimpDataChooserDialog;
 typedef struct _GimpErrorDialog              GimpErrorDialog;
 typedef struct _GimpFileDialog               GimpFileDialog;
 typedef struct _GimpMessageDialog            GimpMessageDialog;

Modified: branches/weskaggs/configure.in
==============================================================================
--- branches/weskaggs/configure.in	(original)
+++ branches/weskaggs/configure.in	Thu Jan 10 03:08:46 2008
@@ -940,6 +940,15 @@
 AM_CONDITIONAL(TOOLBOX_MENU, test "x$enable_toolbox_menu" = "xyes")
 
 
+############
+# MIME types
+############
+
+# The list of MIME types that are supported by plug-ins that are compiled
+# unconditionally:
+MIME_TYPES="application/postscript;application/pdf;image/bmp;image/g3fax;image/gif;image/x-fits;image/pcx;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-psd;image/x-sgi;image/x-tga;image/x-xbitmap;image/x-xwindowdump;image/x-xcf;image/x-compressed-xcf"
+
+
 ###################
 # Check for libtiff
 ###################
@@ -964,11 +973,15 @@
   fi
 
   if test "x$with_libtiff" != xno && test -z "$LIBTIFF"; then
-     AC_MSG_ERROR([
+    AC_MSG_ERROR([
 *** Checks for TIFF libary failed. You can build without it by passing
 *** --without-libtiff to configure but you won't be able to use TIFFs then.])
   fi
 
+  if test "x$have_libtiff" = xyes; then
+    MIME_TYPES="$MIME_TYPES;image/tiff"
+  fi
+
 AC_SUBST(TIFF_LOAD)
 AC_SUBST(TIFF_SAVE)
 AC_SUBST(LIBTIFF)
@@ -978,6 +991,8 @@
 # Check for libjpeg
 ###################
 
+jpeg_ok=no
+
 AC_ARG_WITH(libjpeg,  [  --without-libjpeg       build without JPEG support])
   if test "x$with_libjpeg" != xno && test -z "$LIBJPEG"; then
     AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
@@ -1007,14 +1022,19 @@
   fi
 
   if test "x$with_libjpeg" != xno && test -z "$LIBJPEG"; then
-     AC_MSG_ERROR([
+    AC_MSG_ERROR([
 *** Checks for JPEG library failed. You can build without it by passing
 *** --without-libjpeg to configure but you won't be able to use JPEGs then.])
   fi
 
-AC_SUBST(JPEG)
+  if test "x$jpeg_ok" = xyes; then
+    MIME_TYPES="$MIME_TYPES;image/jpeg"
+  fi
+
+AM_CONDITIONAL(BUILD_JPEG, test "x$jpeg_ok" = xyes)
 AC_SUBST(LIBJPEG)
 
+
 ## xjt does build, but it is more confusing than useful on Win32,
 ## as it wants to run tar, mv and bzip2, which seldom are available
 AM_CONDITIONAL(BUILD_XJT, test "x$jpeg_ok" = xyes && test "x$os_win32" = xno)
@@ -1040,6 +1060,10 @@
     [have_zlib="no (ZLIB library not found)"])
 fi
 
+if test "x$have_zlib" = xyes; then
+  MIME_TYPES="$MIME_TYPES;image/x-psd"
+fi
+
 AC_SUBST(LIBZ)
 AC_SUBST(PSP)
 
@@ -1061,6 +1085,10 @@
 *** --without-libpng to configure but you won't be able to use PNGs then.])])
 fi
 
+if test "x$have_libpng" = xyes; then
+  MIME_TYPES="$MIME_TYPES;image/png;image/x-icon"
+fi
+
 AC_SUBST(PNG)
 AC_SUBST(LIBPNG)
 
@@ -1152,6 +1180,10 @@
 CFLAGS="$gimp_save_CFLAGS"
 LDFLAGS="$gimp_save_LDFLAGS"
 
+if test "x$have_libxpm" = xyes; then
+  MIME_TYPES="$MIME_TYPES;image/x-xpixmap"
+fi
+
 AC_SUBST(XPM)
 AC_SUBST(LIBXPM)
 
@@ -1193,6 +1225,10 @@
    have_librsvg="no (librsvg support disabled)"
 fi
 
+if test "x$have_librsvg" = xyes; then
+  MIME_TYPES="$MIME_TYPES;image/svg+xml"
+fi
+
 AC_SUBST(SVG)
 AC_SUBST(LIBSVG)
 
@@ -1329,6 +1365,11 @@
 else
   have_libwmf="no (libwmf not found)"
 fi
+
+if test "x$have_libwmf" = xyes; then
+  MIME_TYPES="$MIME_TYPES;image/x-wmf"
+fi
+
 AC_SUBST(LIBWMF)
 AC_SUBST(WMF_CFLAGS)
 AC_SUBST(WMF)
@@ -1471,9 +1512,16 @@
 # Check for libhal (Hardware Abstraction Layer)
 ###############################################
 
+AC_ARG_WITH(hal,   [  --without-hal           build without HAL support])
+
 have_libhal=no
 
-if test "x$have_linux_input" = xyes && test "x$have_dbus_glib" = xyes; then
+if test "x$with_hal" = xno; then
+  have_libhal="no (disabled)"
+fi
+
+if test "x$have_linux_input" = xyes && test "x$have_dbus_glib" = xyes &&
+    test "x$with_hal" != xno; then
   PKG_CHECK_MODULES(HAL, hal >= libhal_required_version,
     have_libhal=yes,
     AC_MSG_RESULT([no])
@@ -1600,7 +1648,7 @@
 
 
 #########################################
-# Check whether script_fu should be built
+# Check whether Script-Fu should be built
 #########################################
 
 have_script_fu=yes
@@ -1702,7 +1750,7 @@
 
 
 #########################################
-# Allow to configure the gimp environment
+# Allow to configure the GIMP environment
 #########################################
 
 AC_ARG_ENABLE(default-binary, [  --enable-default-binary install this as the default gimp binary (default=gimp_stable)], , enable_default_binary=gimp_stable)
@@ -1761,6 +1809,8 @@
 GIMP_MKENUMS="\$(PERL) \$(top_srcdir)/tools/gimp-mkenums"
 AC_SUBST(GIMP_MKENUMS)
 
+AC_SUBST(MIME_TYPES)
+
 
 #########################
 # Disable deprecated APIs
@@ -1969,9 +2019,7 @@
 data/patterns/Makefile
 data/tips/Makefile
 desktop/Makefile
-desktop/gimp.applications
 desktop/gimp.desktop.in
-desktop/gimp.keys
 etc/Makefile
 m4macros/Makefile
 po/Makefile.in

Modified: branches/weskaggs/data/images/gimp-logo.png
==============================================================================
Binary files. No diff available.

Modified: branches/weskaggs/data/images/wilber-devel-icon.png
==============================================================================
Binary files. No diff available.

Modified: branches/weskaggs/data/images/wilber-icon.png
==============================================================================
Binary files. No diff available.

Modified: branches/weskaggs/desktop/Makefile.am
==============================================================================
--- branches/weskaggs/desktop/Makefile.am	(original)
+++ branches/weskaggs/desktop/Makefile.am	Thu Jan 10 03:08:46 2008
@@ -9,12 +9,6 @@
 applicationsdir = $(DESKTOP_DATADIR)/applications
 applications_DATA = $(desktop_files)
 
-mimeinfodir = $(DESKTOP_DATADIR)/mime-info
-mimeinfo_DATA = gimp.keys
-
-registrydir = $(DESKTOP_DATADIR)/application-registry
-registry_DATA = gimp.applications
-
 
 icons16dir = $(DESKTOP_DATADIR)/icons/hicolor/16x16/apps
 icons16_DATA = 16x16/gimp.png
@@ -46,9 +40,7 @@
 
 
 EXTRA_DIST = \
-	gimp.applications.in	\
 	gimp.desktop.in.in	\
-	gimp.keys.in		\
 	16x16/gimp.png		\
 	22x22/gimp.png		\
 	24x24/gimp.png		\

Modified: branches/weskaggs/desktop/gimp.desktop.in.in
==============================================================================
--- branches/weskaggs/desktop/gimp.desktop.in.in	(original)
+++ branches/weskaggs/desktop/gimp.desktop.in.in	Thu Jan 10 03:08:46 2008
@@ -16,4 +16,4 @@
 X-GNOME-Bugzilla-Version= GIMP_VERSION@
 X-GNOME-Bugzilla-OtherBinaries=gimp- GIMP_APP_VERSION@
 StartupNotify=true
-MimeType=image/bmp;image/g3fax;image/gif;image/jpeg;image/jpg;image/pjpeg;image/png;image/tiff;image/x-bmp;image/x-compressed-xcf;image/x-fits;image/x-gray;image/x-pcx;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-psd;image/x-sgi;image/x-sun-raster;image/x-tga;image/x-xbitmap;image/x-xcf;image/x-xpixmap;image/x-xwindowdump;
+MimeType= MIME_TYPES@

Modified: branches/weskaggs/libgimp/gimpunitcache.c
==============================================================================
--- branches/weskaggs/libgimp/gimpunitcache.c	(original)
+++ branches/weskaggs/libgimp/gimpunitcache.c	Thu Jan 10 03:08:46 2008
@@ -133,8 +133,6 @@
 gboolean
 _gimp_unit_cache_get_deletion_flag (GimpUnit unit)
 {
-  g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, TRUE);
-
   if (unit < GIMP_UNIT_END)
     return FALSE;
 
@@ -145,8 +143,6 @@
 _gimp_unit_cache_set_deletion_flag (GimpUnit unit,
                                     gboolean deletion_flag)
 {
-  g_return_if_fail (unit >= GIMP_UNIT_PIXEL);
-
   if (unit < GIMP_UNIT_END)
     return;
 
@@ -185,8 +181,6 @@
 const gchar *
 _gimp_unit_cache_get_identifier (GimpUnit unit)
 {
-  g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, NULL);
-
   if (unit == GIMP_UNIT_PERCENT)
     return gimp_unit_percent.identifier;
 
@@ -199,8 +193,6 @@
 const gchar *
 _gimp_unit_cache_get_symbol (GimpUnit unit)
 {
-  g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, NULL);
-
   if (unit == GIMP_UNIT_PERCENT)
     return gimp_unit_percent.symbol;
 
@@ -213,8 +205,6 @@
 const gchar *
 _gimp_unit_cache_get_abbreviation (GimpUnit unit)
 {
-  g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, NULL);
-
   if (unit == GIMP_UNIT_PERCENT)
     return gimp_unit_percent.abbreviation;
 
@@ -227,8 +217,6 @@
 const gchar *
 _gimp_unit_cache_get_singular (GimpUnit unit)
 {
-  g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, NULL);
-
   if (unit == GIMP_UNIT_PERCENT)
     return gettext (gimp_unit_percent.singular);
 
@@ -241,8 +229,6 @@
 const gchar *
 _gimp_unit_cache_get_plural (GimpUnit unit)
 {
-  g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, NULL);
-
   if (unit == GIMP_UNIT_PERCENT)
     return gettext (gimp_unit_percent.plural);
 

Modified: branches/weskaggs/libgimpbase/gimpchecks.c
==============================================================================
--- branches/weskaggs/libgimpbase/gimpchecks.c	(original)
+++ branches/weskaggs/libgimpbase/gimpchecks.c	Thu Jan 10 03:08:46 2008
@@ -55,7 +55,7 @@
       {   0,   0 }   /*  BLACK_ONLY    */
     };
 
-  type = CLAMP (type, 0, 5);
+  type = MIN (type, 5);
 
   if (light)
     *light = shades[type][1];

Modified: branches/weskaggs/libgimpbase/gimpdatafiles.h
==============================================================================
--- branches/weskaggs/libgimpbase/gimpdatafiles.h	(original)
+++ branches/weskaggs/libgimpbase/gimpdatafiles.h	Thu Jan 10 03:08:46 2008
@@ -30,9 +30,9 @@
 
 struct _GimpDatafileData
 {
-  const gchar *filename;
-  const gchar *dirname;
-  const gchar *basename;
+  gchar *filename;
+  gchar *dirname;
+  gchar *basename;
 
   time_t       atime;
   time_t       mtime;

Modified: branches/weskaggs/libgimpwidgets/gimpcolorscales.c
==============================================================================
--- branches/weskaggs/libgimpwidgets/gimpcolorscales.c	(original)
+++ branches/weskaggs/libgimpwidgets/gimpcolorscales.c	Thu Jan 10 03:08:46 2008
@@ -267,7 +267,7 @@
 {
   GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
 
-  if (channel >= 0 && channel < 7)
+  if (channel < 7)
     {
       g_signal_handlers_block_by_func (scales->toggles[channel],
                                        gimp_color_scales_toggle_update,

Modified: branches/weskaggs/libgimpwidgets/gimpmemsizeentry.c
==============================================================================
--- branches/weskaggs/libgimpwidgets/gimpmemsizeentry.c	(original)
+++ branches/weskaggs/libgimpwidgets/gimpmemsizeentry.c	Thu Jan 10 03:08:46 2008
@@ -172,8 +172,8 @@
 
   for (shift = 30; shift > 10; shift -= 10)
     {
-      if (value > ((guint64) 1 << shift) &&
-          value % ((guint64) 1 << shift) == 0)
+      if (value > (G_GUINT64_CONSTANT (1) << shift) &&
+          value % (G_GUINT64_CONSTANT (1) << shift) == 0)
         break;
     }
 
@@ -237,8 +237,8 @@
 
   for (shift = 30; shift > 10; shift -= 10)
     {
-      if (value > ((guint64) 1 << shift) &&
-          value % ((guint64) 1 << shift) == 0)
+      if (value > (G_GUINT64_CONSTANT (1) << shift) &&
+          value % (G_GUINT64_CONSTANT (1) << shift) == 0)
         break;
     }
 

Modified: branches/weskaggs/libgimpwidgets/gimppageselector.c
==============================================================================
--- branches/weskaggs/libgimpwidgets/gimppageselector.c	(original)
+++ branches/weskaggs/libgimpwidgets/gimppageselector.c	Thu Jan 10 03:08:46 2008
@@ -559,8 +559,7 @@
   GimpPageSelectorPrivate *priv;
 
   g_return_if_fail (GIMP_IS_PAGE_SELECTOR (selector));
-  g_return_if_fail (target >= GIMP_PAGE_SELECTOR_TARGET_LAYERS &&
-                    target <= GIMP_PAGE_SELECTOR_TARGET_IMAGES);
+  g_return_if_fail (target <= GIMP_PAGE_SELECTOR_TARGET_IMAGES);
 
   priv = GIMP_PAGE_SELECTOR_GET_PRIVATE (selector);
 

Modified: branches/weskaggs/libgimpwidgets/makefile.msc
==============================================================================
--- branches/weskaggs/libgimpwidgets/makefile.msc	(original)
+++ branches/weskaggs/libgimpwidgets/makefile.msc	Thu Jan 10 03:08:46 2008
@@ -17,7 +17,7 @@
 DEPCFLAGS = \
 	-FImsvc_recommended_pragmas.h \
 	$(GLIB_CFLAGS) $(GTK2_CFLAGS) $(INTL_CFLAGS)
-DEPLIBS = $(GLIB_LIBS) $(GTK2_LIBS) $(INTL_LIBS)
+DEPLIBS = $(GLIB_LIBS) $(GTK2_LIBS) $(INTL_LIBS) $(CAIRO_LIBS)
 
 all : \
 	..\config.h \
@@ -34,6 +34,7 @@
 OBJECTS = \
 	gimpbrowser.obj \
 	gimpbutton.obj \
+	gimpcairo-utils.obj \
 	gimpcellrenderercolor.obj \
 	gimpcellrenderertoggle.obj \
 	gimpchainbutton.obj \

Modified: branches/weskaggs/libgimpwidgets/wilber-32.png
==============================================================================
Binary files. No diff available.

Modified: branches/weskaggs/libgimpwidgets/wilber-48.png
==============================================================================
Binary files. No diff available.

Modified: branches/weskaggs/libgimpwidgets/wilber-64.png
==============================================================================
Binary files. No diff available.

Modified: branches/weskaggs/modules/cdisplay_colorblind.c
==============================================================================
--- branches/weskaggs/modules/cdisplay_colorblind.c	(original)
+++ branches/weskaggs/modules/cdisplay_colorblind.c	Thu Jan 10 03:08:46 2008
@@ -48,7 +48,7 @@
 } ColorblindDeficiency;
 
 #define CDISPLAY_TYPE_COLORBLIND_DEFICIENCY (cdisplay_colorblind_deficiency_type)
-static GType  cdisplay_colorblind_deficiency_get_type (GTypeModule *module);
+static GType  cdisplay_colorblind_deficiency_register_type (GTypeModule *module);
 
 static const GEnumValue enum_values[] =
 {
@@ -76,7 +76,7 @@
 #define COLOR_CACHE_SIZE    1021
 
 
-#define CDISPLAY_TYPE_COLORBLIND            (cdisplay_colorblind_type)
+#define CDISPLAY_TYPE_COLORBLIND            (cdisplay_colorblind_get_type ())
 #define CDISPLAY_COLORBLIND(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CDISPLAY_TYPE_COLORBLIND, CdisplayColorblind))
 #define CDISPLAY_COLORBLIND_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CDISPLAY_TYPE_COLORBLIND, CdisplayColorblindClass))
 #define CDISPLAY_IS_COLORBLIND(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CDISPLAY_TYPE_COLORBLIND))
@@ -113,9 +113,7 @@
 };
 
 
-static GType       cdisplay_colorblind_get_type   (GTypeModule              *module);
-static void        cdisplay_colorblind_class_init (CdisplayColorblindClass  *klass);
-static void        cdisplay_colorblind_init       (CdisplayColorblind       *colorblind);
+GType              cdisplay_colorblind_get_type      (void);
 
 static void        cdisplay_colorblind_set_property  (GObject               *object,
                                                       guint                  property_id,
@@ -205,9 +203,11 @@
   "January 22, 2003"
 };
 
-static GType                  cdisplay_colorblind_type            = 0;
-static GType                  cdisplay_colorblind_deficiency_type = 0;
-static GimpColorDisplayClass *parent_class                        = NULL;
+
+G_DEFINE_DYNAMIC_TYPE (CdisplayColorblind, cdisplay_colorblind,
+                       GIMP_TYPE_COLOR_DISPLAY)
+
+static GType cdisplay_colorblind_deficiency_type = 0;
 
 
 G_MODULE_EXPORT const GimpModuleInfo *
@@ -219,43 +219,14 @@
 G_MODULE_EXPORT gboolean
 gimp_module_register (GTypeModule *module)
 {
-  cdisplay_colorblind_get_type (module);
-  cdisplay_colorblind_deficiency_get_type (module);
+  cdisplay_colorblind_register_type (module);
+  cdisplay_colorblind_deficiency_register_type (module);
 
   return TRUE;
 }
 
 static GType
-cdisplay_colorblind_get_type (GTypeModule *module)
-{
-  if (! cdisplay_colorblind_type)
-    {
-      const GTypeInfo display_info =
-      {
-        sizeof (CdisplayColorblindClass),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) cdisplay_colorblind_class_init,
-        NULL,           /* class_finalize */
-        NULL,           /* class_data     */
-        sizeof (CdisplayColorblind),
-        0,              /* n_preallocs    */
-        (GInstanceInitFunc) cdisplay_colorblind_init,
-      };
-
-      cdisplay_colorblind_type =
-        g_type_module_register_type (module,
-                                     GIMP_TYPE_COLOR_DISPLAY,
-                                     "CdisplayColorblind",
-                                     &display_info, 0);
-    }
-
-  return cdisplay_colorblind_type;
-}
-
-
-static GType
-cdisplay_colorblind_deficiency_get_type (GTypeModule *module)
+cdisplay_colorblind_deficiency_register_type (GTypeModule *module)
 {
   if (! cdisplay_colorblind_deficiency_type)
     {
@@ -278,8 +249,6 @@
   GObjectClass          *object_class  = G_OBJECT_CLASS (klass);
   GimpColorDisplayClass *display_class = GIMP_COLOR_DISPLAY_CLASS (klass);
 
-  parent_class = g_type_class_peek_parent (klass);
-
   object_class->get_property = cdisplay_colorblind_get_property;
   object_class->set_property = cdisplay_colorblind_set_property;
 
@@ -299,6 +268,11 @@
 }
 
 static void
+cdisplay_colorblind_class_finalize (CdisplayColorblindClass *klass)
+{
+}
+
+static void
 cdisplay_colorblind_init (CdisplayColorblind *colorblind)
 {
   gint i;
@@ -320,6 +294,7 @@
     case PROP_DEFICIENCY:
       g_value_set_enum (value, colorblind->deficiency);
       break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -340,6 +315,7 @@
       cdisplay_colorblind_set_deficiency (colorblind,
                                           g_value_get_enum (value));
       break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;

Modified: branches/weskaggs/modules/cdisplay_gamma.c
==============================================================================
--- branches/weskaggs/modules/cdisplay_gamma.c	(original)
+++ branches/weskaggs/modules/cdisplay_gamma.c	Thu Jan 10 03:08:46 2008
@@ -31,7 +31,7 @@
 #define DEFAULT_GAMMA 1.0
 
 
-#define CDISPLAY_TYPE_GAMMA            (cdisplay_gamma_type)
+#define CDISPLAY_TYPE_GAMMA            (cdisplay_gamma_get_type ())
 #define CDISPLAY_GAMMA(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CDISPLAY_TYPE_GAMMA, CdisplayGamma))
 #define CDISPLAY_GAMMA_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CDISPLAY_TYPE_GAMMA, CdisplayGammaClass))
 #define CDISPLAY_IS_GAMMA(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CDISPLAY_TYPE_GAMMA))
@@ -62,8 +62,7 @@
 };
 
 
-static GType       cdisplay_gamma_get_type     (GTypeModule        *module);
-static void        cdisplay_gamma_class_init   (CdisplayGammaClass *klass);
+GType              cdisplay_gamma_get_type     (void);
 
 static void        cdisplay_gamma_set_property (GObject            *object,
                                                 guint               property_id,
@@ -95,8 +94,8 @@
   "October 14, 2000"
 };
 
-static GType                  cdisplay_gamma_type = 0;
-static GimpColorDisplayClass *parent_class        = NULL;
+G_DEFINE_DYNAMIC_TYPE (CdisplayGamma, cdisplay_gamma,
+                       GIMP_TYPE_COLOR_DISPLAY)
 
 
 G_MODULE_EXPORT const GimpModuleInfo *
@@ -108,47 +107,17 @@
 G_MODULE_EXPORT gboolean
 gimp_module_register (GTypeModule *module)
 {
-  cdisplay_gamma_get_type (module);
+  cdisplay_gamma_register_type (module);
 
   return TRUE;
 }
 
-static GType
-cdisplay_gamma_get_type (GTypeModule *module)
-{
-  if (! cdisplay_gamma_type)
-    {
-      const GTypeInfo display_info =
-      {
-        sizeof (CdisplayGammaClass),
-        (GBaseInitFunc)     NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc)    cdisplay_gamma_class_init,
-        NULL,           /* class_finalize */
-        NULL,           /* class_data     */
-        sizeof (CdisplayGamma),
-        0,              /* n_preallocs    */
-        NULL            /* instance_init  */
-      };
-
-      cdisplay_gamma_type =
-        g_type_module_register_type (module,
-                                     GIMP_TYPE_COLOR_DISPLAY,
-                                     "CdisplayGamma",
-                                     &display_info, 0);
-    }
-
-  return cdisplay_gamma_type;
-}
-
 static void
 cdisplay_gamma_class_init (CdisplayGammaClass *klass)
 {
   GObjectClass          *object_class  = G_OBJECT_CLASS (klass);
   GimpColorDisplayClass *display_class = GIMP_COLOR_DISPLAY_CLASS (klass);
 
-  parent_class = g_type_class_peek_parent (klass);
-
   object_class->get_property = cdisplay_gamma_get_property;
   object_class->set_property = cdisplay_gamma_set_property;
 
@@ -166,6 +135,16 @@
 }
 
 static void
+cdisplay_gamma_class_finalize (CdisplayGammaClass *klass)
+{
+}
+
+static void
+cdisplay_gamma_init (CdisplayGamma *gamma)
+{
+}
+
+static void
 cdisplay_gamma_get_property (GObject    *object,
                              guint       property_id,
                              GValue     *value,

Modified: branches/weskaggs/modules/cdisplay_highcontrast.c
==============================================================================
--- branches/weskaggs/modules/cdisplay_highcontrast.c	(original)
+++ branches/weskaggs/modules/cdisplay_highcontrast.c	Thu Jan 10 03:08:46 2008
@@ -31,7 +31,7 @@
 #define DEFAULT_CONTRAST 1.0
 
 
-#define CDISPLAY_TYPE_CONTRAST            (cdisplay_contrast_type)
+#define CDISPLAY_TYPE_CONTRAST            (cdisplay_contrast_get_type ())
 #define CDISPLAY_CONTRAST(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CDISPLAY_TYPE_CONTRAST, CdisplayContrast))
 #define CDISPLAY_CONTRAST_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CDISPLAY_TYPE_CONTRAST, CdisplayContrastClass))
 #define CDISPLAY_IS_CONTRAST(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CDISPLAY_TYPE_CONTRAST))
@@ -62,8 +62,7 @@
 };
 
 
-static GType       cdisplay_contrast_get_type     (GTypeModule           *module);
-static void        cdisplay_contrast_class_init   (CdisplayContrastClass *klass);
+GType              cdisplay_contrast_get_type     (void);
 
 static void        cdisplay_contrast_set_property (GObject          *object,
                                                    guint             property_id,
@@ -95,8 +94,8 @@
   "October 14, 2000"
 };
 
-static GType                  cdisplay_contrast_type = 0;
-static GimpColorDisplayClass *parent_class        = NULL;
+G_DEFINE_DYNAMIC_TYPE (CdisplayContrast, cdisplay_contrast,
+                       GIMP_TYPE_COLOR_DISPLAY)
 
 
 G_MODULE_EXPORT const GimpModuleInfo *
@@ -108,47 +107,17 @@
 G_MODULE_EXPORT gboolean
 gimp_module_register (GTypeModule *module)
 {
-  cdisplay_contrast_get_type (module);
+  cdisplay_contrast_register_type (module);
 
   return TRUE;
 }
 
-static GType
-cdisplay_contrast_get_type (GTypeModule *module)
-{
-  if (! cdisplay_contrast_type)
-    {
-      const GTypeInfo display_info =
-      {
-        sizeof (CdisplayContrastClass),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) cdisplay_contrast_class_init,
-        NULL,           /* class_finalize */
-        NULL,           /* class_data     */
-        sizeof (CdisplayContrast),
-        0,              /* n_preallocs    */
-        NULL            /* instance_init  */
-      };
-
-      cdisplay_contrast_type =
-        g_type_module_register_type (module,
-                                     GIMP_TYPE_COLOR_DISPLAY,
-                                     "CdisplayContrast",
-                                     &display_info, 0);
-    }
-
-  return cdisplay_contrast_type;
-}
-
 static void
 cdisplay_contrast_class_init (CdisplayContrastClass *klass)
 {
   GObjectClass          *object_class  = G_OBJECT_CLASS (klass);
   GimpColorDisplayClass *display_class = GIMP_COLOR_DISPLAY_CLASS (klass);
 
-  parent_class = g_type_class_peek_parent (klass);
-
   object_class->get_property = cdisplay_contrast_get_property;
   object_class->set_property = cdisplay_contrast_set_property;
 
@@ -166,6 +135,16 @@
 }
 
 static void
+cdisplay_contrast_class_finalize (CdisplayContrastClass *klass)
+{
+}
+
+static void
+cdisplay_contrast_init (CdisplayContrast *contrast)
+{
+}
+
+static void
 cdisplay_contrast_get_property (GObject    *object,
                                 guint       property_id,
                                 GValue     *value,

Modified: branches/weskaggs/modules/cdisplay_lcms.c
==============================================================================
--- branches/weskaggs/modules/cdisplay_lcms.c	(original)
+++ branches/weskaggs/modules/cdisplay_lcms.c	Thu Jan 10 03:08:46 2008
@@ -49,7 +49,7 @@
 #include "libgimp/libgimp-intl.h"
 
 
-#define CDISPLAY_TYPE_LCMS            (cdisplay_lcms_type)
+#define CDISPLAY_TYPE_LCMS            (cdisplay_lcms_get_type ())
 #define CDISPLAY_LCMS(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CDISPLAY_TYPE_LCMS, CdisplayLcms))
 #define CDISPLAY_LCMS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CDISPLAY_TYPE_LCMS, CdisplayLcmsClass))
 #define CDISPLAY_IS_LCMS(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CDISPLAY_TYPE_LCMS))
@@ -72,9 +72,8 @@
 };
 
 
-static GType        cdisplay_lcms_get_type     (GTypeModule       *module);
-static void         cdisplay_lcms_class_init   (CdisplayLcmsClass *klass);
-static void         cdisplay_lcms_init         (CdisplayLcms      *lcms);
+GType               cdisplay_lcms_get_type     (void);
+
 static void         cdisplay_lcms_finalize     (GObject           *object);
 
 static GtkWidget  * cdisplay_lcms_configure    (GimpColorDisplay  *display);
@@ -111,9 +110,8 @@
   "2005 - 2007"
 };
 
-static GType                  cdisplay_lcms_type = 0;
-static GimpColorDisplayClass *parent_class       = NULL;
-
+G_DEFINE_DYNAMIC_TYPE (CdisplayLcms, cdisplay_lcms,
+                       GIMP_TYPE_COLOR_DISPLAY)
 
 G_MODULE_EXPORT const GimpModuleInfo *
 gimp_module_query (GTypeModule *module)
@@ -124,45 +122,17 @@
 G_MODULE_EXPORT gboolean
 gimp_module_register (GTypeModule *module)
 {
-  cdisplay_lcms_get_type (module);
+  cdisplay_lcms_register_type (module);
 
   return TRUE;
 }
 
-static GType
-cdisplay_lcms_get_type (GTypeModule *module)
-{
-  if (! cdisplay_lcms_type)
-    {
-      const GTypeInfo display_info =
-      {
-        sizeof (CdisplayLcmsClass),
-        (GBaseInitFunc)     NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) cdisplay_lcms_class_init,
-        NULL,                   /* class_finalize */
-        NULL,                   /* class_data     */
-        sizeof (CdisplayLcms),
-        0,                      /* n_preallocs    */
-        (GInstanceInitFunc) cdisplay_lcms_init,
-      };
-
-       cdisplay_lcms_type =
-        g_type_module_register_type (module, GIMP_TYPE_COLOR_DISPLAY,
-                                     "CdisplayLcms", &display_info, 0);
-    }
-
-  return cdisplay_lcms_type;
-}
-
 static void
 cdisplay_lcms_class_init (CdisplayLcmsClass *klass)
 {
   GObjectClass          *object_class  = G_OBJECT_CLASS (klass);
   GimpColorDisplayClass *display_class = GIMP_COLOR_DISPLAY_CLASS (klass);
 
-  parent_class = g_type_class_peek_parent (klass);
-
   object_class->finalize = cdisplay_lcms_finalize;
 
   display_class->name        = _("Color Management");
@@ -177,6 +147,11 @@
 }
 
 static void
+cdisplay_lcms_class_finalize (CdisplayLcmsClass *klass)
+{
+}
+
+static void
 cdisplay_lcms_init (CdisplayLcms *lcms)
 {
   lcms->transform = NULL;
@@ -193,7 +168,7 @@
       lcms->transform = NULL;
     }
 
-  G_OBJECT_CLASS (parent_class)->finalize (object);
+  G_OBJECT_CLASS (cdisplay_lcms_parent_class)->finalize (object);
 }
 
 static void

Modified: branches/weskaggs/modules/cdisplay_proof.c
==============================================================================
--- branches/weskaggs/modules/cdisplay_proof.c	(original)
+++ branches/weskaggs/modules/cdisplay_proof.c	Thu Jan 10 03:08:46 2008
@@ -36,7 +36,7 @@
 
 #include "libgimp/libgimp-intl.h"
 
-#define CDISPLAY_TYPE_PROOF            (cdisplay_proof_type)
+#define CDISPLAY_TYPE_PROOF            (cdisplay_proof_get_type ())
 #define CDISPLAY_PROOF(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CDISPLAY_TYPE_PROOF, CdisplayProof))
 #define CDISPLAY_PROOF_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CDISPLAY_TYPE_PROOF, CdisplayProofClass))
 #define CDISPLAY_IS_PROOF(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CDISPLAY_TYPE_PROOF))
@@ -72,9 +72,7 @@
 };
 
 
-static GType       cdisplay_proof_get_type     (GTypeModule        *module);
-static void        cdisplay_proof_class_init   (CdisplayProofClass *klass);
-static void        cdisplay_proof_init         (CdisplayProof      *proof);
+GType              cdisplay_proof_get_type     (void);
 
 static void        cdisplay_proof_finalize     (GObject          *object);
 static void        cdisplay_proof_get_property (GObject          *object,
@@ -107,9 +105,8 @@
   "November 14, 2003"
 };
 
-static GType                  cdisplay_proof_type = 0;
-static GimpColorDisplayClass *parent_class        = NULL;
-
+G_DEFINE_DYNAMIC_TYPE (CdisplayProof, cdisplay_proof,
+                       GIMP_TYPE_COLOR_DISPLAY)
 
 G_MODULE_EXPORT const GimpModuleInfo *
 gimp_module_query (GTypeModule *module)
@@ -120,45 +117,17 @@
 G_MODULE_EXPORT gboolean
 gimp_module_register (GTypeModule *module)
 {
-  cdisplay_proof_get_type (module);
+  cdisplay_proof_register_type (module);
 
   return TRUE;
 }
 
-static GType
-cdisplay_proof_get_type (GTypeModule *module)
-{
-  if (! cdisplay_proof_type)
-    {
-      const GTypeInfo display_info =
-      {
-        sizeof (CdisplayProofClass),
-        (GBaseInitFunc)     NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) cdisplay_proof_class_init,
-        NULL,                   /* class_finalize */
-        NULL,                   /* class_data     */
-        sizeof (CdisplayProof),
-        0,                      /* n_preallocs    */
-        (GInstanceInitFunc) cdisplay_proof_init,
-      };
-
-       cdisplay_proof_type =
-        g_type_module_register_type (module, GIMP_TYPE_COLOR_DISPLAY,
-                                     "CdisplayProof", &display_info, 0);
-    }
-
-  return cdisplay_proof_type;
-}
-
 static void
 cdisplay_proof_class_init (CdisplayProofClass *klass)
 {
   GObjectClass          *object_class  = G_OBJECT_CLASS (klass);
   GimpColorDisplayClass *display_class = GIMP_COLOR_DISPLAY_CLASS (klass);
 
-  parent_class = g_type_class_peek_parent (klass);
-
   object_class->finalize     = cdisplay_proof_finalize;
   object_class->get_property = cdisplay_proof_get_property;
   object_class->set_property = cdisplay_proof_set_property;
@@ -189,6 +158,11 @@
 }
 
 static void
+cdisplay_proof_class_finalize (CdisplayProofClass *klass)
+{
+}
+
+static void
 cdisplay_proof_init (CdisplayProof *proof)
 {
   proof->transform = NULL;
@@ -205,13 +179,14 @@
       g_free (proof->profile);
       proof->profile = NULL;
     }
+
   if (proof->transform)
     {
       cmsDeleteTransform (proof->transform);
       proof->transform = NULL;
     }
 
-  G_OBJECT_CLASS (parent_class)->finalize (object);
+  G_OBJECT_CLASS (cdisplay_proof_parent_class)->finalize (object);
 }
 
 static void

Modified: branches/weskaggs/modules/colorsel_cmyk.c
==============================================================================
--- branches/weskaggs/modules/colorsel_cmyk.c	(original)
+++ branches/weskaggs/modules/colorsel_cmyk.c	Thu Jan 10 03:08:46 2008
@@ -29,7 +29,7 @@
 
 /* definitions and variables */
 
-#define COLORSEL_TYPE_CMYK            (colorsel_cmyk_type)
+#define COLORSEL_TYPE_CMYK            (colorsel_cmyk_get_type ())
 #define COLORSEL_CMYK(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), COLORSEL_TYPE_CMYK, ColorselCmyk))
 #define COLORSEL_CMYK_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), COLORSEL_TYPE_CMYK, ColorselCmykClass))
 #define COLORSEL_IS_CMYK(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COLORSEL_TYPE_CMYK))
@@ -54,9 +54,7 @@
 };
 
 
-static GType  colorsel_cmyk_get_type   (GTypeModule       *module);
-static void   colorsel_cmyk_class_init (ColorselCmykClass *klass);
-static void   colorsel_cmyk_init       (ColorselCmyk      *cmyk);
+GType         colorsel_cmyk_get_type       (void);
 
 static void   colorsel_cmyk_set_color      (GimpColorSelector *selector,
                                             const GimpRGB     *rgb,
@@ -77,7 +75,9 @@
   "July 2003"
 };
 
-static GType colorsel_cmyk_type = 0;
+
+G_DEFINE_DYNAMIC_TYPE (ColorselCmyk, colorsel_cmyk,
+                       GIMP_TYPE_COLOR_SELECTOR)
 
 
 G_MODULE_EXPORT const GimpModuleInfo *
@@ -89,39 +89,11 @@
 G_MODULE_EXPORT gboolean
 gimp_module_register (GTypeModule *module)
 {
-  colorsel_cmyk_get_type (module);
+  colorsel_cmyk_register_type (module);
 
   return TRUE;
 }
 
-static GType
-colorsel_cmyk_get_type (GTypeModule *module)
-{
-  if (! colorsel_cmyk_type)
-    {
-      const GTypeInfo select_info =
-      {
-        sizeof (ColorselCmykClass),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) colorsel_cmyk_class_init,
-        NULL,           /* class_finalize */
-        NULL,           /* class_data     */
-        sizeof (ColorselCmyk),
-        0,              /* n_preallocs    */
-        (GInstanceInitFunc) colorsel_cmyk_init,
-      };
-
-      colorsel_cmyk_type =
-        g_type_module_register_type (module,
-                                     GIMP_TYPE_COLOR_SELECTOR,
-                                     "ColorselCmyk",
-                                     &select_info, 0);
-    }
-
-  return colorsel_cmyk_type;
-}
-
 static void
 colorsel_cmyk_class_init (ColorselCmykClass *klass)
 {
@@ -134,6 +106,11 @@
 }
 
 static void
+colorsel_cmyk_class_finalize (ColorselCmykClass *klass)
+{
+}
+
+static void
 colorsel_cmyk_init (ColorselCmyk *module)
 {
   GtkWidget *table;

Modified: branches/weskaggs/modules/colorsel_cmyk_lcms.c
==============================================================================
--- branches/weskaggs/modules/colorsel_cmyk_lcms.c	(original)
+++ branches/weskaggs/modules/colorsel_cmyk_lcms.c	Thu Jan 10 03:08:46 2008
@@ -156,6 +156,8 @@
   selector_class->stock_id   = GTK_STOCK_PRINT;  /* FIXME */
   selector_class->set_color  = colorsel_cmyk_set_color;
   selector_class->set_config = colorsel_cmyk_set_config;
+
+  cmsErrorAction (LCMS_ERROR_IGNORE);
 }
 
 static void

Modified: branches/weskaggs/modules/colorsel_triangle.c
==============================================================================
--- branches/weskaggs/modules/colorsel_triangle.c	(original)
+++ branches/weskaggs/modules/colorsel_triangle.c	Thu Jan 10 03:08:46 2008
@@ -42,7 +42,7 @@
                        GDK_BUTTON_MOTION_MASK )
 
 
-#define COLORSEL_TYPE_TRIANGLE            (colorsel_triangle_type)
+#define COLORSEL_TYPE_TRIANGLE            (colorsel_triangle_get_type ())
 #define COLORSEL_TRIANGLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), COLORSEL_TYPE_TRIANGLE, ColorselTriangle))
 #define COLORSEL_TRIANGLE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), COLORSEL_TYPE_TRIANGLE, ColorselTriangleClass))
 #define COLORSEL_IS_TRIANGLE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COLORSEL_TYPE_TRIANGLE))
@@ -70,15 +70,13 @@
 };
 
 
-static GType      colorsel_triangle_get_type   (GTypeModule           *module);
-static void       colorsel_triangle_class_init (ColorselTriangleClass *klass);
-static void       colorsel_triangle_init       (ColorselTriangle      *triangle);
+GType              colorsel_triangle_get_type       (void);
 
-static void       colorsel_triangle_set_color       (GimpColorSelector *selector,
+static void        colorsel_triangle_set_color      (GimpColorSelector *selector,
                                                      const GimpRGB     *rgb,
                                                      const GimpHSV     *hsv);
 
-static void       colorsel_xy_to_triangle_buf       (gint              x,
+static void        colorsel_xy_to_triangle_buf      (gint              x,
                                                      gint              y,
                                                      gdouble           hue,
                                                      guchar           *buf,
@@ -89,12 +87,12 @@
                                                      gint              hx,
                                                      gint              hy);
 
-static GtkWidget *colorsel_triangle_create_preview  (ColorselTriangle *triangle);
-static void       colorsel_triangle_update_preview  (ColorselTriangle *triangle);
-static void       colorsel_triangle_size_allocate   (GtkWidget        *widget,
+static GtkWidget * colorsel_triangle_create_preview (ColorselTriangle *triangle);
+static void        colorsel_triangle_update_preview (ColorselTriangle *triangle);
+static void        colorsel_triangle_size_allocate  (GtkWidget        *widget,
                                                      GtkAllocation    *allocation,
                                                      ColorselTriangle *triangle);
-static gboolean   colorsel_triangle_event           (GtkWidget        *widget,
+static gboolean    colorsel_triangle_event          (GtkWidget        *widget,
                                                      GdkEvent         *event,
                                                      ColorselTriangle *triangle);
 
@@ -114,8 +112,8 @@
 };
 
 
-static GType                   colorsel_triangle_type = 0;
-static GimpColorSelectorClass *parent_class           = NULL;
+G_DEFINE_DYNAMIC_TYPE (ColorselTriangle, colorsel_triangle,
+                       GIMP_TYPE_COLOR_SELECTOR)
 
 
 G_MODULE_EXPORT const GimpModuleInfo *
@@ -127,46 +125,16 @@
 G_MODULE_EXPORT gboolean
 gimp_module_register (GTypeModule *module)
 {
-  colorsel_triangle_get_type (module);
+  colorsel_triangle_register_type (module);
 
   return TRUE;
 }
 
-static GType
-colorsel_triangle_get_type (GTypeModule *module)
-{
-  if (! colorsel_triangle_type)
-    {
-      const GTypeInfo select_info =
-      {
-        sizeof (ColorselTriangleClass),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) colorsel_triangle_class_init,
-        NULL,           /* class_finalize */
-        NULL,           /* class_data     */
-        sizeof (ColorselTriangle),
-        0,              /* n_preallocs    */
-        (GInstanceInitFunc) colorsel_triangle_init,
-      };
-
-      colorsel_triangle_type =
-        g_type_module_register_type (module,
-                                     GIMP_TYPE_COLOR_SELECTOR,
-                                     "ColorselTriangle",
-                                     &select_info, 0);
-    }
-
-  return colorsel_triangle_type;
-}
-
 static void
 colorsel_triangle_class_init (ColorselTriangleClass *klass)
 {
   GimpColorSelectorClass *selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
 
-  parent_class = g_type_class_peek_parent (klass);
-
   selector_class->name      = _("Triangle");
   selector_class->help_id   = "gimp-colorselector-triangle";
   selector_class->stock_id  = GIMP_STOCK_COLOR_TRIANGLE;
@@ -174,6 +142,11 @@
 }
 
 static void
+colorsel_triangle_class_finalize (ColorselTriangleClass *klass)
+{
+}
+
+static void
 colorsel_triangle_init (ColorselTriangle *triangle)
 {
   GtkWidget *frame;

Modified: branches/weskaggs/modules/colorsel_water.c
==============================================================================
--- branches/weskaggs/modules/colorsel_water.c	(original)
+++ branches/weskaggs/modules/colorsel_water.c	Thu Jan 10 03:08:46 2008
@@ -32,7 +32,7 @@
 #include "libgimp/libgimp-intl.h"
 
 
-#define COLORSEL_TYPE_WATER            (colorsel_water_type)
+#define COLORSEL_TYPE_WATER            (colorsel_water_get_type ())
 #define COLORSEL_WATER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), COLORSEL_TYPE_WATER, ColorselWater))
 #define COLORSEL_WATER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), COLORSEL_TYPE_WATER, ColorselWaterClass))
 #define COLORSEL_IS_WATER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COLORSEL_TYPE_WATER))
@@ -59,23 +59,21 @@
 };
 
 
-static GType      colorsel_water_get_type   (GTypeModule        *module);
-static void       colorsel_water_class_init (ColorselWaterClass *klass);
-static void       colorsel_water_init       (ColorselWater      *water);
-
-static void       select_area_expose        (GtkWidget          *widget,
-                                             GdkEventExpose     *event);
-static gboolean   button_press_event        (GtkWidget          *widget,
-                                             GdkEventButton     *event,
-                                             ColorselWater      *water);
-static gboolean   motion_notify_event       (GtkWidget          *widget,
-                                             GdkEventMotion     *event,
-                                             ColorselWater      *water);
-static gboolean   proximity_out_event       (GtkWidget          *widget,
-                                             GdkEventProximity  *event,
-                                             ColorselWater      *water);
-static void       pressure_adjust_update    (GtkAdjustment      *adj,
-                                             ColorselWater      *water);
+GType             colorsel_water_get_type (void);
+
+static void       select_area_expose      (GtkWidget          *widget,
+                                           GdkEventExpose     *event);
+static gboolean   button_press_event      (GtkWidget          *widget,
+                                           GdkEventButton     *event,
+                                           ColorselWater      *water);
+static gboolean   motion_notify_event     (GtkWidget          *widget,
+                                           GdkEventMotion     *event,
+                                           ColorselWater      *water);
+static gboolean   proximity_out_event     (GtkWidget          *widget,
+                                           GdkEventProximity  *event,
+                                           ColorselWater      *water);
+static void       pressure_adjust_update  (GtkAdjustment      *adj,
+                                           ColorselWater      *water);
 
 
 static const GimpModuleInfo colorsel_water_info =
@@ -94,8 +92,8 @@
 };
 
 
-static GType                   colorsel_water_type = 0;
-static GimpColorSelectorClass *parent_class           = NULL;
+G_DEFINE_DYNAMIC_TYPE (ColorselWater, colorsel_water,
+                       GIMP_TYPE_COLOR_SELECTOR)
 
 
 G_MODULE_EXPORT const GimpModuleInfo *
@@ -107,49 +105,24 @@
 G_MODULE_EXPORT gboolean
 gimp_module_register (GTypeModule *module)
 {
-  colorsel_water_get_type (module);
+  colorsel_water_register_type (module);
 
   return TRUE;
 }
 
-static GType
-colorsel_water_get_type (GTypeModule *module)
-{
-  if (! colorsel_water_type)
-    {
-      const GTypeInfo select_info =
-      {
-        sizeof (ColorselWaterClass),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) colorsel_water_class_init,
-        NULL,           /* class_finalize */
-        NULL,           /* class_data     */
-        sizeof (ColorselWater),
-        0,              /* n_preallocs    */
-        (GInstanceInitFunc) colorsel_water_init,
-      };
-
-      colorsel_water_type =
-        g_type_module_register_type (module,
-                                     GIMP_TYPE_COLOR_SELECTOR,
-                                     "ColorselWater",
-                                     &select_info, 0);
-    }
-
-  return colorsel_water_type;
-}
-
 static void
 colorsel_water_class_init (ColorselWaterClass *klass)
 {
   GimpColorSelectorClass *selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
 
-  parent_class = g_type_class_peek_parent (klass);
+  selector_class->name     = _("Watercolor");
+  selector_class->help_id  = "gimp-colorselector-watercolor";
+  selector_class->stock_id = GIMP_STOCK_TOOL_PAINTBRUSH;
+}
 
-  selector_class->name      = _("Watercolor");
-  selector_class->help_id   = "gimp-colorselector-watercolor";
-  selector_class->stock_id  = GIMP_STOCK_TOOL_PAINTBRUSH;
+static void
+colorsel_water_class_finalize (ColorselWaterClass *klass)
+{
 }
 
 static void

Modified: branches/weskaggs/modules/controller_dx_dinput.c
==============================================================================
--- branches/weskaggs/modules/controller_dx_dinput.c	(original)
+++ branches/weskaggs/modules/controller_dx_dinput.c	Thu Jan 10 03:08:46 2008
@@ -34,7 +34,7 @@
 #include <string.h>
 #include <math.h>
 
-#define _WIN32_WINNT 0x0501 
+#define _WIN32_WINNT 0x0501
 #include <windows.h>
 #define DIRECTINPUT_VERSION 0x0800
 #include <dinput.h>
@@ -64,7 +64,7 @@
 #define NUM_EVENTS_PER_SLIDER 2 /* Slider decrease and increase */
 #define NUM_EVENTS_PER_POV 3    /* POV view vector X and Y view and return */
 
-#define CONTROLLER_TYPE_DX_DINPUT            (controller_type)
+#define CONTROLLER_TYPE_DX_DINPUT            (controller_dx_input_get_type ())
 #define CONTROLLER_DX_DINPUT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTROLLER_TYPE_DX_DINPUT, ControllerDXDInput))
 #define CONTROLLER_DX_DINPUT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CONTROLLER_TYPE_DX_DINPUT, ControllerDXDInputClass))
 #define CONTROLLER_IS_DX_DINPUT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTROLLER_TYPE_DX_DINPUT))
@@ -79,7 +79,7 @@
   GSource             source;
   ControllerDXDInput *controller;
 };
-  
+
 struct _ControllerDXDInput
 {
   GimpController        parent_instance;
@@ -103,7 +103,7 @@
 
   gint                  num_povs;
   gint                  num_pov_events;
-  
+
   gint                  num_events;
   gchar               **event_names;
   gchar               **event_blurbs;
@@ -125,19 +125,18 @@
 };
 
 
-GType         dx_dinput_get_type     (GTypeModule    *module);
-static void   dx_dinput_class_init   (ControllerDXDInputClass *klass);
-static void   dx_dinput_init         (ControllerDXDInput      *controller);
-static void   dx_dinput_dispose      (GObject        *object);
-static void   dx_dinput_finalize     (GObject        *object);
-static void   dx_dinput_set_property (GObject        *object,
-                                      guint           property_id,
-                                      const GValue   *value,
-                                      GParamSpec     *pspec);
-static void   dx_dinput_get_property (GObject        *object,
-                                      guint           property_id,
-                                      GValue         *value,
-                                      GParamSpec     *pspec);
+GType         controller_dx_dinput_get_type     (void);
+
+static void   dx_dinput_dispose                 (GObject        *object);
+static void   dx_dinput_finalize                (GObject        *object);
+static void   dx_dinput_set_property            (GObject        *object,
+                                                 guint           property_id,
+                                                 const GValue   *value,
+                                                 GParamSpec     *pspec);
+static void   dx_dinput_get_property            (GObject        *object,
+                                                 guint           property_id,
+                                                 GValue         *value,
+                                                 GParamSpec     *pspec);
 
 static gint          dx_dinput_get_n_events     (GimpController *controller);
 static const gchar * dx_dinput_get_event_name   (GimpController *controller,
@@ -162,8 +161,8 @@
 };
 
 
-static GType                controller_type = 0;
-static GimpControllerClass *parent_class    = NULL;
+G_DEFINE_DYNAMIC_TYPE (ControllerDXInput, controller_dx_input,
+                       GIMP_TYPE_CONTROLLER)
 
 
 G_MODULE_EXPORT const GimpModuleInfo *
@@ -176,47 +175,17 @@
 gimp_module_register (GTypeModule *module)
 {
   gimp_input_device_store_get_type (module);
-  dx_dinput_get_type (module);
+  controller_dx_dinput_register_type (module);
 
   return TRUE;
 }
 
-
-GType
-dx_dinput_get_type (GTypeModule *module)
-{
-  if (! controller_type)
-    {
-      const GTypeInfo controller_info =
-      {
-        sizeof (ControllerDXDInputClass),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) dx_dinput_class_init,
-        NULL,           /* class_finalize */
-        NULL,           /* class_data     */
-        sizeof (ControllerDXDInput),
-        0,              /* n_preallocs    */
-        (GInstanceInitFunc) dx_dinput_init
-      };
-
-      controller_type = g_type_module_register_type (module,
-                                                     GIMP_TYPE_CONTROLLER,
-                                                     "ControllerDXDInput",
-                                                     &controller_info, 0);
-    }
-
-  return controller_type;
-}
-
 static void
-dx_dinput_class_init (ControllerDXDInputClass *klass)
+controller_dx_dinput_class_init (ControllerDXDInputClass *klass)
 {
   GimpControllerClass *controller_class = GIMP_CONTROLLER_CLASS (klass);
   GObjectClass        *object_class     = G_OBJECT_CLASS (klass);
 
-  parent_class = g_type_class_peek_parent (klass);
-
   object_class->dispose            = dx_dinput_dispose;
   object_class->finalize           = dx_dinput_finalize;
   object_class->get_property       = dx_dinput_get_property;
@@ -244,7 +213,12 @@
 }
 
 static void
-dx_dinput_init (ControllerDXDInput *controller)
+controller_dx_dinput_class_finalize (ControllerDXDInputClass *klass)
+{
+}
+
+static void
+controller_dx_dinput_init (ControllerDXDInput *controller)
 {
   controller->store = gimp_input_device_store_new ();
 
@@ -266,7 +240,7 @@
 
   dx_dinput_set_device (controller, NULL);
 
-  G_OBJECT_CLASS (parent_class)->dispose (object);
+  G_OBJECT_CLASS (controller_dx_input_parent_class)->dispose (object);
 }
 
 static void
@@ -306,7 +280,7 @@
       controller->store = NULL;
     }
 
-  G_OBJECT_CLASS (parent_class)->finalize (object);
+  G_OBJECT_CLASS (controller_dx_input_parent_class)->finalize (object);
 }
 
 static void
@@ -354,7 +328,7 @@
 dx_dinput_get_n_events (GimpController *controller)
 {
   ControllerDXDInput *cdxdi = (ControllerDXDInput *) controller;
-  
+
   return cdxdi->num_events;
 }
 
@@ -367,7 +341,7 @@
 
   if (event_id < 0 || event_id >= cdxdi->num_events)
     return NULL;
-  
+
   return cdxdi->event_names[event_id];
 }
 
@@ -379,7 +353,7 @@
 
   if (event_id < 0 || event_id >= cdxdi->num_events)
     return NULL;
-  
+
   return cdxdi->event_blurbs[event_id];
 }
 
@@ -565,7 +539,7 @@
     controller->num_axes =
     controller->num_sliders =
     controller->num_povs = 0;
-  
+
   if (FAILED ((hresult = IDirectInputDevice8_EnumObjects (controller->didevice8,
                                                           count_objects,
                                                           controller,
@@ -679,7 +653,7 @@
   guchar                          *data;
   gint                             i;
   GimpControllerEvent              cevent = { 0, };
-  
+
   data = g_malloc (format->dwDataSize);
 
   if (FAILED ((hresult = IDirectInputDevice8_GetDeviceState (input->didevice8,
@@ -749,7 +723,7 @@
         *curr = *prev;
       rgodf++;
     }
-  
+
   for (i = 0; i < input->num_sliders; i++)
     {
       LONG *prev = (LONG *)(input->prevdata+rgodf->dwOfs);
@@ -780,7 +754,7 @@
         *curr = *prev;
       rgodf++;
     }
-  
+
   for (i = 0; i < input->num_povs; i++)
     {
       LONG prev = *((LONG *)(input->prevdata+rgodf->dwOfs));
@@ -834,7 +808,7 @@
         }
       rgodf++;
     }
-  
+
   g_assert (rgodf == format->rgodf + format->dwNumObjs);
 
   memmove (input->prevdata, data, format->dwDataSize);
@@ -875,7 +849,7 @@
     {
       const DIOBJECTDATAFORMAT *oformat = (DIOBJECTDATAFORMAT *) (((char *) format->rgodf) + i*format->dwObjSize);
       unsigned char *guid;
-      
+
       g_print ("Object %d:\n", i);
       if (oformat->pguid == NULL)
         g_print ("  pguid: NULL\n");
@@ -968,7 +942,7 @@
                    g_win32_error_message (hresult));
       goto fail0;
     }
-                                                          
+
   controller->format->dwFlags = dword.dwData + 1;
 
   controller->format->dwNumObjs =
@@ -993,7 +967,7 @@
     }
 
   controller->format->dwDataSize = 4*((controller->format->dwDataSize + 3)/4);
-  
+
   for (i = 0; i < controller->num_axes; i++)
     {
       controller->format->rgodf[k].pguid = NULL;
@@ -1003,7 +977,7 @@
       controller->format->dwDataSize += 4;
       k++;
     }
-  
+
   for (i = 0; i < controller->num_sliders; i++)
     {
       controller->format->rgodf[k].pguid = NULL;
@@ -1056,7 +1030,7 @@
                    g_win32_error_message (hresult));
       goto fail2;
     }
-    
+
   if (FAILED ((hresult = IDirectInputDevice8_GetDeviceState (controller->didevice8,
                                                              controller->format->dwDataSize,
                                                              controller->prevdata))))

Modified: branches/weskaggs/modules/controller_linux_input.c
==============================================================================
--- branches/weskaggs/modules/controller_linux_input.c	(original)
+++ branches/weskaggs/modules/controller_linux_input.c	Thu Jan 10 03:08:46 2008
@@ -118,7 +118,7 @@
 };
 
 
-#define CONTROLLER_TYPE_LINUX_INPUT            (controller_type)
+#define CONTROLLER_TYPE_LINUX_INPUT            (controller_linux_input_get_type ())
 #define CONTROLLER_LINUX_INPUT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTROLLER_TYPE_LINUX_INPUT, ControllerLinuxInput))
 #define CONTROLLER_LINUX_INPUT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CONTROLLER_TYPE_LINUX_INPUT, ControllerLinuxInputClass))
 #define CONTROLLER_IS_LINUX_INPUT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTROLLER_TYPE_LINUX_INPUT))
@@ -144,19 +144,18 @@
 };
 
 
-GType         linux_input_get_type     (GTypeModule    *module);
-static void   linux_input_class_init   (ControllerLinuxInputClass *klass);
-static void   linux_input_init         (ControllerLinuxInput      *controller);
-static void   linux_input_dispose      (GObject        *object);
-static void   linux_input_finalize     (GObject        *object);
-static void   linux_input_set_property (GObject        *object,
-                                        guint           property_id,
-                                        const GValue   *value,
-                                        GParamSpec     *pspec);
-static void   linux_input_get_property (GObject        *object,
-                                        guint           property_id,
-                                        GValue         *value,
-                                        GParamSpec     *pspec);
+GType         controller_linux_input_get_type     (void);
+
+static void   linux_input_dispose                 (GObject        *object);
+static void   linux_input_finalize                (GObject        *object);
+static void   linux_input_set_property            (GObject        *object,
+                                                   guint           property_id,
+                                                   const GValue   *value,
+                                                   GParamSpec     *pspec);
+static void   linux_input_get_property            (GObject        *object,
+                                                   guint           property_id,
+                                                   GValue         *value,
+                                                   GParamSpec     *pspec);
 
 static gint          linux_input_get_n_events     (GimpController *controller);
 static const gchar * linux_input_get_event_name   (GimpController *controller,
@@ -184,8 +183,8 @@
 };
 
 
-static GType                controller_type = 0;
-static GimpControllerClass *parent_class    = NULL;
+G_DEFINE_DYNAMIC_TYPE (ControllerLinuxInput, controller_linux_input,
+                       GIMP_TYPE_CONTROLLER)
 
 
 G_MODULE_EXPORT const GimpModuleInfo *
@@ -198,47 +197,17 @@
 gimp_module_register (GTypeModule *module)
 {
   gimp_input_device_store_get_type (module);
-  linux_input_get_type (module);
+  controller_linux_input_register_type (module);
 
   return TRUE;
 }
 
-
-GType
-linux_input_get_type (GTypeModule *module)
-{
-  if (! controller_type)
-    {
-      const GTypeInfo controller_info =
-      {
-        sizeof (ControllerLinuxInputClass),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) linux_input_class_init,
-        NULL,           /* class_finalize */
-        NULL,           /* class_data     */
-        sizeof (ControllerLinuxInput),
-        0,              /* n_preallocs    */
-        (GInstanceInitFunc) linux_input_init
-      };
-
-      controller_type = g_type_module_register_type (module,
-                                                     GIMP_TYPE_CONTROLLER,
-                                                     "ControllerLinuxInput",
-                                                     &controller_info, 0);
-    }
-
-  return controller_type;
-}
-
 static void
-linux_input_class_init (ControllerLinuxInputClass *klass)
+controller_linux_input_class_init (ControllerLinuxInputClass *klass)
 {
   GimpControllerClass *controller_class = GIMP_CONTROLLER_CLASS (klass);
   GObjectClass        *object_class     = G_OBJECT_CLASS (klass);
 
-  parent_class = g_type_class_peek_parent (klass);
-
   object_class->dispose            = linux_input_dispose;
   object_class->finalize           = linux_input_finalize;
   object_class->get_property       = linux_input_get_property;
@@ -268,7 +237,12 @@
 }
 
 static void
-linux_input_init (ControllerLinuxInput *controller)
+controller_linux_input_class_finalize (ControllerLinuxInputClass *klass)
+{
+}
+
+static void
+controller_linux_input_init (ControllerLinuxInput *controller)
 {
   controller->store = gimp_input_device_store_new ();
 
@@ -290,7 +264,7 @@
 
   linux_input_set_device (controller, NULL);
 
-  G_OBJECT_CLASS (parent_class)->dispose (object);
+  G_OBJECT_CLASS (controller_linux_input_parent_class)->dispose (object);
 }
 
 static void
@@ -304,7 +278,7 @@
       controller->store = NULL;
     }
 
-  G_OBJECT_CLASS (parent_class)->finalize (object);
+  G_OBJECT_CLASS (controller_linux_input_parent_class)->finalize (object);
 }
 
 static void

Modified: branches/weskaggs/modules/controller_midi.c
==============================================================================
--- branches/weskaggs/modules/controller_midi.c	(original)
+++ branches/weskaggs/modules/controller_midi.c	Thu Jan 10 03:08:46 2008
@@ -63,7 +63,7 @@
 };
 
 
-#define CONTROLLER_TYPE_MIDI            (controller_type)
+#define CONTROLLER_TYPE_MIDI            (controller_midi_get_type ())
 #define CONTROLLER_MIDI(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTROLLER_TYPE_MIDI, ControllerMidi))
 #define CONTROLLER_MIDI_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CONTROLLER_TYPE_MIDI, ControllerMidiClass))
 #define CONTROLLER_IS_MIDI(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTROLLER_TYPE_MIDI))
@@ -104,45 +104,42 @@
 };
 
 
-GType                midi_get_type        (GTypeModule    *module);
+GType                controller_midi_get_type (void);
 
-static void          midi_class_init      (ControllerMidiClass *klass);
-static void          midi_init            (ControllerMidi      *midi);
-
-static void          midi_dispose         (GObject        *object);
-static void          midi_set_property    (GObject        *object,
-                                           guint           property_id,
-                                           const GValue   *value,
-                                           GParamSpec     *pspec);
-static void          midi_get_property    (GObject        *object,
-                                           guint           property_id,
-                                           GValue         *value,
-                                           GParamSpec     *pspec);
-
-static gint          midi_get_n_events    (GimpController *controller);
-static const gchar * midi_get_event_name  (GimpController *controller,
-                                           gint            event_id);
-static const gchar * midi_get_event_blurb (GimpController *controller,
-                                           gint            event_id);
-
-static gboolean      midi_set_device      (ControllerMidi *controller,
-                                           const gchar    *device);
-static void          midi_event           (ControllerMidi *midi,
-                                           gint            channel,
-                                           gint            event_id,
-                                           gdouble         value);
-
-static gboolean      midi_read_event      (GIOChannel     *io,
-                                           GIOCondition    cond,
-                                           gpointer        data);
+static void          midi_dispose             (GObject        *object);
+static void          midi_set_property        (GObject        *object,
+                                               guint           property_id,
+                                               const GValue   *value,
+                                               GParamSpec     *pspec);
+static void          midi_get_property        (GObject        *object,
+                                               guint           property_id,
+                                               GValue         *value,
+                                               GParamSpec     *pspec);
+
+static gint          midi_get_n_events        (GimpController *controller);
+static const gchar * midi_get_event_name      (GimpController *controller,
+                                               gint            event_id);
+static const gchar * midi_get_event_blurb     (GimpController *controller,
+                                               gint            event_id);
+
+static gboolean      midi_set_device          (ControllerMidi *controller,
+                                               const gchar    *device);
+static void          midi_event               (ControllerMidi *midi,
+                                               gint            channel,
+                                               gint            event_id,
+                                               gdouble         value);
+
+static gboolean      midi_read_event          (GIOChannel     *io,
+                                               GIOCondition    cond,
+                                               gpointer        data);
 
 #ifdef HAVE_ALSA
-static gboolean      midi_alsa_prepare    (GSource        *source,
-                                           gint           *timeout);
-static gboolean      midi_alsa_check      (GSource        *source);
-static gboolean      midi_alsa_dispatch   (GSource        *source,
-                                           GSourceFunc     callback,
-                                           gpointer        user_data);
+static gboolean      midi_alsa_prepare        (GSource        *source,
+                                               gint           *timeout);
+static gboolean      midi_alsa_check          (GSource        *source);
+static gboolean      midi_alsa_dispatch       (GSource        *source,
+                                               GSourceFunc     callback,
+                                               gpointer        user_data);
 
 static GSourceFuncs alsa_source_funcs =
 {
@@ -172,10 +169,10 @@
 };
 
 
-static GType                controller_type = 0;
-static GimpControllerClass *parent_class    = NULL;
+G_DEFINE_DYNAMIC_TYPE (ControllerMidi, controller_midi,
+                       GIMP_TYPE_CONTROLLER)
 
-static MidiEvent            midi_events[128 + 128 + 128];
+static MidiEvent midi_events[128 + 128 + 128];
 
 
 G_MODULE_EXPORT const GimpModuleInfo *
@@ -187,48 +184,18 @@
 G_MODULE_EXPORT gboolean
 gimp_module_register (GTypeModule *module)
 {
-  midi_get_type (module);
+  controller_midi_register_type (module);
 
   return TRUE;
 }
 
-
-GType
-midi_get_type (GTypeModule *module)
-{
-  if (! controller_type)
-    {
-      const GTypeInfo controller_info =
-      {
-        sizeof (ControllerMidiClass),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) midi_class_init,
-        NULL,           /* class_finalize */
-        NULL,           /* class_data     */
-        sizeof (ControllerMidi),
-        0,              /* n_preallocs    */
-        (GInstanceInitFunc) midi_init
-      };
-
-      controller_type = g_type_module_register_type (module,
-                                                     GIMP_TYPE_CONTROLLER,
-                                                     "ControllerMidi",
-                                                     &controller_info, 0);
-    }
-
-  return controller_type;
-}
-
 static void
-midi_class_init (ControllerMidiClass *klass)
+controller_midi_class_init (ControllerMidiClass *klass)
 {
   GimpControllerClass *controller_class = GIMP_CONTROLLER_CLASS (klass);
   GObjectClass        *object_class     = G_OBJECT_CLASS (klass);
   gchar               *blurb;
 
-  parent_class = g_type_class_peek_parent (klass);
-
   object_class->dispose            = midi_dispose;
   object_class->get_property       = midi_get_property;
   object_class->set_property       = midi_set_property;
@@ -266,7 +233,12 @@
 }
 
 static void
-midi_init (ControllerMidi *midi)
+controller_midi_class_finalize (ControllerMidiClass *klass)
+{
+}
+
+static void
+controller_midi_init (ControllerMidi *midi)
 {
   midi->device       = NULL;
   midi->midi_channel = -1;
@@ -293,7 +265,7 @@
 
   midi_set_device (midi, NULL);
 
-  G_OBJECT_CLASS (parent_class)->dispose (object);
+  G_OBJECT_CLASS (controller_midi_parent_class)->dispose (object);
 }
 
 static void

Modified: branches/weskaggs/plug-ins/Makefile.am
==============================================================================
--- branches/weskaggs/plug-ins/Makefile.am	(original)
+++ branches/weskaggs/plug-ins/Makefile.am	Thu Jan 10 03:08:46 2008
@@ -8,6 +8,10 @@
 helpbrowser = helpbrowser
 endif
 
+if BUILD_JPEG
+jpeg = jpeg
+endif
+
 if BUILD_PRINT
 print = print
 endif
@@ -60,7 +64,7 @@
 	$(helpbrowser)		\
 	ifscompose		\
 	imagemap		\
-	jpeg                    \
+	$(jpeg)                 \
 	maze			\
 	metadata		\
 	pagecurl		\

Modified: branches/weskaggs/plug-ins/common/convmatrix.c
==============================================================================
--- branches/weskaggs/plug-ins/common/convmatrix.c	(original)
+++ branches/weskaggs/plug-ins/common/convmatrix.c	Thu Jan 10 03:08:46 2008
@@ -15,44 +15,6 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The GNU General Public License is also available from
- * http://www.fsf.org/copyleft/gpl.html
- *
- *
- * CHANGELOG:
- * v0.14        21.09.2006                   (gg <gg at catking the net>)
- *      Replace numerical consts by named const, much variable renaming for maintainability
- *      Generalisation of code w.r.t. matrix dimension with aim to support 7x7
- *      Some minor bug fixes.
- *
- * v0.13        15.12.2000
- *      Made the PDB interface actually work.   (Simon Budig <simon gimp org>)
- *
- * v0.12        15.9.1997
- *      Got rid of the unportable snprintf. Also made some _tiny_ GUI fixes.
- *
- * v0.11        20.7.1997
- *      Negative values in the matrix are now abs'ed when used to weight
- *      alpha. Embossing effects should work properly now. Also fixed a
- *      totally idiotic bug with embossing.
- *
- * v0.1         2.7.1997
- *      Initial release. Works... kinda.
- *
- *
- * TODO:
- *
- * - remove channels selector (that's what the channels dialog is for)
- * - remove idiotic slowdowns
- * - clean up code
- * - optimize properly
- * - save & load matrices
- * - spiffy frontend for designing matrices
- *
- * What else?
- *
- *
  */
 
 #include "config.h"
@@ -68,6 +30,7 @@
 
 #define PLUG_IN_PROC   "plug-in-convmatrix"
 #define PLUG_IN_BINARY "convmatrix"
+
 #define RESPONSE_RESET 1
 
 
@@ -569,10 +532,10 @@
   guchar       *dest_row[DEST_ROWS];
   guchar       *src_row[MATRIX_SIZE];
   guchar       *tmp_row;
-  gfloat        sum;
   gint          x_offset;
-  gboolean      chanmask[CHANNELS-1];
-  gint          bpp,channel,alpha_channel;
+  gboolean      chanmask[CHANNELS - 1];
+  gint          bpp;
+  gint          alpha_channel;
 
   /* Get the input area. This is the bounding box of the selection in
    *  the image (or the entire image if there is no selection). Only
@@ -605,7 +568,7 @@
 
   if (gimp_drawable_is_rgb (drawable->drawable_id))
     {
-      for (i = 0; i < CHANNELS; i++)
+      for (i = 0; i < CHANNELS - 1; i++)
         chanmask[i] = config.channels[i + 1];
     }
   else /* Grayscale */
@@ -642,34 +605,51 @@
 
   for (row = src_y1; row < src_y2; row++)
     {
+      gint channel;
+
       x_offset = 0;
 
       for (col = src_x1; col < src_x2; col++)
         for (channel = 0; channel < bpp; channel++)
           {
+            guchar d;
+
             if (chanmask[channel])
-              sum = convolve_pixel(src_row, x_offset, channel, drawable);
+              {
+                gint result;
+
+                result = ROUND (convolve_pixel (src_row,
+                                                x_offset, channel, drawable));
+                d = CLAMP (result, 0, 255);
+              }
             else
-              sum = src_row[HALF_WINDOW][x_offset + HALF_WINDOW * bpp];  /* copy unmodified px */
+              {
+                /* copy unmodified pixel */
+                d = src_row[HALF_WINDOW][x_offset + HALF_WINDOW * bpp];
+              }
 
-            dest_row[HALF_WINDOW][x_offset] = (guchar) CLAMP (sum, 0, 255);
+            dest_row[HALF_WINDOW][x_offset] = d;
             x_offset++;
           }
 
       if (row >= src_y1 + HALF_WINDOW)
-        gimp_pixel_rgn_set_row (&destPR, dest_row[0], src_x1, row - HALF_WINDOW, src_w);
+        gimp_pixel_rgn_set_row (&destPR,
+                                dest_row[0], src_x1, row - HALF_WINDOW, src_w);
 
       if (row < src_y2 - 1)
         {
           tmp_row = dest_row[0];
+
           for (i = 0; i < DEST_ROWS - 1; i++)
             dest_row[i] = dest_row[i + 1];
 
           dest_row[DEST_ROWS - 1] = tmp_row;
 
           tmp_row = src_row[0];
+
           for (i = 0; i < MATRIX_SIZE - 1; i++)
             src_row[i] = src_row[i + 1];
+
           src_row[MATRIX_SIZE-1] = tmp_row;
 
           my_get_row (&srcPR, src_row[MATRIX_SIZE - 1],
@@ -696,10 +676,13 @@
     {
       gimp_drawable_flush (drawable);
       gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
-      gimp_drawable_update (drawable->drawable_id, src_x1, src_y1, src_x2 - src_x1, src_y2 - src_y1);
+      gimp_drawable_update (drawable->drawable_id,
+                            src_x1, src_y1, src_x2 - src_x1, src_y2 - src_y1);
     }
+
   for (i = 0; i < MATRIX_SIZE; i++)
     g_free (src_row[i]);
+
   for (i = 0; i < DEST_ROWS; i++)
     g_free (dest_row[i]);
 }

Modified: branches/weskaggs/plug-ins/common/tile.c
==============================================================================
--- branches/weskaggs/plug-ins/common/tile.c	(original)
+++ branches/weskaggs/plug-ins/common/tile.c	Thu Jan 10 03:08:46 2008
@@ -334,7 +334,7 @@
 
               progress += src_rgn.w * src_rgn.h;
 
-              if (c % 8 == 0)
+              if (c % 16 == 0)
                 gimp_progress_update ((gdouble) progress /
                                       (gdouble) max_progress);
             }

Modified: branches/weskaggs/plug-ins/psd/psd-image-res-load.c
==============================================================================
--- branches/weskaggs/plug-ins/psd/psd-image-res-load.c	(original)
+++ branches/weskaggs/plug-ins/psd/psd-image-res-load.c	Thu Jan 10 03:08:46 2008
@@ -19,7 +19,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-
 /* ----- Known Image Resource Block Types -----
   All image resources not otherwise handled, including unknown types
   are added as image parasites.
@@ -83,12 +82,12 @@
   PSD_PATH_INFO_LAST    = 2998,    Loaded     * 0x0bb6 - Last path info block *
   PSD_CLIPPING_PATH     = 2999,               * 0x0bb7 - Name of clipping path *
   PSD_PRINT_FLAGS_2     = 10000               * 0x2710 - Print flags *
-
 */
 
 #include "config.h"
 
 #include <string.h>
+#include <errno.h>
 
 #include <glib/gstdio.h>
 #include <libgimp/gimp.h>
@@ -111,230 +110,256 @@
 
 #define EXIF_HEADER_SIZE 8
 
-
 /*  Local function prototypes  */
 static gint     load_resource_unknown  (const PSDimageres     *res_a,
                                         const gint32           image_id,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_ps_only  (const PSDimageres     *res_a,
                                         const gint32           image_id,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_1005     (const PSDimageres     *res_a,
                                         const gint32           image_id,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_1006     (const PSDimageres     *res_a,
                                         const gint32           image_id,
                                         PSDimage              *img_a,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_1007     (const PSDimageres     *res_a,
                                         const gint32           image_id,
                                         PSDimage              *img_a,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_1008     (const PSDimageres     *res_a,
                                         const gint32           image_id,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_1022     (const PSDimageres     *res_a,
                                         const gint32           image_id,
                                         PSDimage              *img_a,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_1024     (const PSDimageres     *res_a,
                                         const gint32           image_id,
                                         PSDimage              *img_a,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_1028     (const PSDimageres     *res_a,
                                         const gint32           image_id,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_1032     (const PSDimageres     *res_a,
                                         const gint32           image_id,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_1033     (const PSDimageres     *res_a,
                                         const gint32           image_id,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_1039     (const PSDimageres     *res_a,
                                         const gint32           image_id,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_1045     (const PSDimageres     *res_a,
                                         const gint32           image_id,
                                         PSDimage              *img_a,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_1046     (const PSDimageres     *res_a,
                                         const gint32           image_id,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_1053     (const PSDimageres     *res_a,
                                         const gint32           image_id,
                                         PSDimage              *img_a,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_1058     (const PSDimageres     *res_a,
                                         const gint32           image_id,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_1060     (const PSDimageres     *res_a,
                                         const gint32           image_id,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 static gint     load_resource_2000     (const PSDimageres     *res_a,
                                         const gint32           image_id,
-                                        FILE                  *f);
+                                        FILE                  *f,
+                                        GError               **error);
 
 /* Public Functions */
 gint
-get_image_resource_header (PSDimageres *res_a,
-                           FILE        *f)
+get_image_resource_header (PSDimageres  *res_a,
+                           FILE         *f,
+                           GError      **error)
 {
-  gint32               read_len,
-                       write_len;
-  gchar                *name;
+  gint32        read_len;
+  gint32        write_len;
+  gchar        *name;
 
   if (fread (&res_a->type, 4, 1, f) < 1
       || fread (&res_a->id, 2, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block header"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   res_a->id = GUINT16_FROM_BE (res_a->id);
-  name = fread_pascal_string (&read_len, &write_len, 2, f);
+  name = fread_pascal_string (&read_len, &write_len, 2, f, error);
+  if (*error)
+    return -1;
   if (name != NULL)
     g_strlcpy (res_a->name, name, write_len + 1);
   else
-    res_a->name[0] = 0;
+    res_a->name[0] = 0x0;
   g_free (name);
   if (fread (&res_a->data_len, 4, 1, f) < 1)
     {
-      g_message (_("Error image resource block length"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   res_a->data_len = GUINT32_FROM_BE (res_a->data_len);
   res_a->data_start = ftell (f);
 
   IFDBG(2) g_debug ("Type: %.4s, id: %d, start: %d, len: %d",
-                        res_a->type, res_a->id, res_a->data_start, res_a->data_len);
+                    res_a->type, res_a->id, res_a->data_start, res_a->data_len);
 
   return 0;
 }
 
 gint
-load_image_resource (PSDimageres  *res_a,
-                     const gint32  image_id,
-                     PSDimage     *img_a,
-                     FILE         *f)
+load_image_resource (PSDimageres   *res_a,
+                     const gint32   image_id,
+                     PSDimage      *img_a,
+                     FILE          *f,
+                     GError       **error)
 {
   gint  pad;
 
   /* Set file position to start of image resource data block */
   if (fseek (f, res_a->data_start, SEEK_SET) < 0)
     {
-      g_message (_("Error setting file position"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
    /* Process image resource blocks */
   if (memcmp (res_a->type, "8BIM", 4) != 0 &&
       memcmp (res_a->type, "MeSa", 4) !=0)
-      g_message (_("Unknown image resource type signature %.4s"), res_a->type);
-
-  switch (res_a->id)
     {
-      case PSD_PS2_IMAGE_INFO:
-      case PSD_PS2_COLOR_TAB:
-      case PSD_OBSOLETE_01:
-      case PSD_OBSOLETE_02:
-      case PSD_OBSOLETE_03:
-        /* Drop obsolete image resource blocks */
-        IFDBG(2) g_debug ("Obsolete image resource block: %d",
-                           res_a->id);
-        break;
+      IFDBG(1) g_debug ("Unknown image resource type signature %.4s",
+                        res_a->type);
+    }
+  else
+    {
+      switch (res_a->id)
+        {
+          case PSD_PS2_IMAGE_INFO:
+          case PSD_PS2_COLOR_TAB:
+          case PSD_OBSOLETE_01:
+          case PSD_OBSOLETE_02:
+          case PSD_OBSOLETE_03:
+            /* Drop obsolete image resource blocks */
+            IFDBG(2) g_debug ("Obsolete image resource block: %d",
+                               res_a->id);
+            break;
 
-      case PSD_THUMB_RES:
-      case PSD_THUMB_RES2:
-        /* Drop thumbnails from standard file load */
-        IFDBG(2) g_debug ("Thumbnail resource block: %d",
-                           res_a->id);
-        break;
+          case PSD_THUMB_RES:
+          case PSD_THUMB_RES2:
+            /* Drop thumbnails from standard file load */
+            IFDBG(2) g_debug ("Thumbnail resource block: %d",
+                               res_a->id);
+            break;
 
-      case PSD_MAC_PRINT_INFO:
-      case PSD_JPEG_QUAL:
-        /* Save photoshop resources with no meaning for GIMP
-          as image parasites */
-        load_resource_ps_only (res_a, image_id, f);
-        break;
+          case PSD_MAC_PRINT_INFO:
+          case PSD_JPEG_QUAL:
+            /* Save photoshop resources with no meaning for GIMP
+              as image parasites */
+            load_resource_ps_only (res_a, image_id, f, error);
+            break;
 
-      case PSD_RESN_INFO:
-        load_resource_1005 (res_a, image_id, f);
-        break;
+          case PSD_RESN_INFO:
+            load_resource_1005 (res_a, image_id, f, error);
+            break;
 
-      case PSD_ALPHA_NAMES:
-        load_resource_1006 (res_a, image_id, img_a, f);
-        break;
+          case PSD_ALPHA_NAMES:
+            load_resource_1006 (res_a, image_id, img_a, f, error);
+            break;
 
-      case PSD_DISPLAY_INFO:
-        load_resource_1007 (res_a, image_id, img_a, f);
-        break;
+          case PSD_DISPLAY_INFO:
+            load_resource_1007 (res_a, image_id, img_a, f, error);
+            break;
 
-      case PSD_CAPTION:
-        load_resource_1008 (res_a, image_id, f);
-        break;
+          case PSD_CAPTION:
+            load_resource_1008 (res_a, image_id, f, error);
+            break;
 
-      case PSD_QUICK_MASK:
-        load_resource_1022 (res_a, image_id, img_a, f);
-        break;
+          case PSD_QUICK_MASK:
+            load_resource_1022 (res_a, image_id, img_a, f, error);
+            break;
 
-      case PSD_LAYER_STATE:
-        load_resource_1024 (res_a, image_id, img_a, f);
-        break;
+          case PSD_LAYER_STATE:
+            load_resource_1024 (res_a, image_id, img_a, f, error);
+            break;
 
-      case PSD_IPTC_NAA_DATA:
-        load_resource_1028 (res_a, image_id, f);
-        break;
+          case PSD_IPTC_NAA_DATA:
+            load_resource_1028 (res_a, image_id, f, error);
+            break;
 
-      case PSD_GRID_GUIDE:
-        load_resource_1032 (res_a, image_id, f);
-        break;
+          case PSD_GRID_GUIDE:
+            load_resource_1032 (res_a, image_id, f, error);
+            break;
 
-      case PSD_ICC_PROFILE:
-        load_resource_1039 (res_a, image_id, f);
-        break;
+          case PSD_ICC_PROFILE:
+            load_resource_1039 (res_a, image_id, f, error);
+            break;
 
-      case PSD_ALPHA_NAMES_UNI:
-        load_resource_1045 (res_a, image_id, img_a,  f);
-        break;
+          case PSD_ALPHA_NAMES_UNI:
+            load_resource_1045 (res_a, image_id, img_a, f, error);
+            break;
 
-      case PSD_IDX_COL_TAB_CNT:
-        load_resource_1046 (res_a, image_id, f);
-        break;
+          case PSD_IDX_COL_TAB_CNT:
+            load_resource_1046 (res_a, image_id, f, error);
+            break;
 
-      case PSD_ALPHA_ID:
-        load_resource_1053 (res_a, image_id, img_a, f);
-        break;
+          case PSD_ALPHA_ID:
+            load_resource_1053 (res_a, image_id, img_a, f, error);
+            break;
 
-      case PSD_EXIF_DATA:
-        load_resource_1058 (res_a, image_id, f);
-        break;
+          case PSD_EXIF_DATA:
+            load_resource_1058 (res_a, image_id, f, error);
+            break;
 
-      case PSD_XMP_DATA:
-        load_resource_1060 (res_a, image_id, f);
-        break;
+          case PSD_XMP_DATA:
+            load_resource_1060 (res_a, image_id, f, error);
+            break;
 
-      default:
-        if (res_a->id >= 2000 &&
-            res_a->id <  2999)
-          load_resource_2000 (res_a, image_id, f);
-        else
-          load_resource_unknown (res_a, image_id, f);
+          default:
+            if (res_a->id >= 2000 &&
+                res_a->id <  2999)
+              load_resource_2000 (res_a, image_id, f, error);
+            else
+              load_resource_unknown (res_a, image_id, f, error);
+        }
     }
 
   /* Image blocks are null padded to even length */
@@ -346,7 +371,7 @@
   /* Set file position to end of image resource block */
   if (fseek (f, res_a->data_start + res_a->data_len + pad, SEEK_SET) < 0)
     {
-      g_message (_("Error setting file position"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
@@ -354,9 +379,10 @@
 }
 
 gint
-load_thumbnail_resource (PSDimageres  *res_a,
-                         const gint32  image_id,
-                         FILE         *f)
+load_thumbnail_resource (PSDimageres   *res_a,
+                         const gint32   image_id,
+                         FILE          *f,
+                         GError       **error)
 {
   gint  rtn = 0;
   gint  pad;
@@ -364,7 +390,7 @@
   /* Set file position to start of image resource data block */
   if (fseek (f, res_a->data_start, SEEK_SET) < 0)
     {
-      g_message (_("Error setting file position"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
@@ -373,7 +399,7 @@
      || res_a->id == PSD_THUMB_RES2)
    {
         /* Load thumbnails from standard file load */
-        load_resource_1033 (res_a, image_id, f);
+        load_resource_1033 (res_a, image_id, f, error);
         rtn = 1;
    }
 
@@ -386,7 +412,7 @@
   /* Set file position to end of image resource block */
   if (fseek (f, res_a->data_start + res_a->data_len + pad, SEEK_SET) < 0)
     {
-      g_message (_("Error setting file position"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
@@ -396,9 +422,10 @@
 /* Private Functions */
 
 static gint
-load_resource_unknown (const PSDimageres *res_a,
-                       const gint32       image_id,
-                       FILE              *f)
+load_resource_unknown (const PSDimageres  *res_a,
+                       const gint32        image_id,
+                       FILE               *f,
+                       GError            **error)
 {
   /* Unknown image resources attached as parasites to re-save later */
   GimpParasite  *parasite;
@@ -410,7 +437,7 @@
   data = g_malloc (res_a->data_len);
   if (fread (data, res_a->data_len, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block %d"), res_a->id);
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
@@ -428,9 +455,10 @@
 }
 
 static gint
-load_resource_ps_only (const PSDimageres *res_a,
-                       const gint32       image_id,
-                       FILE              *f)
+load_resource_ps_only (const PSDimageres  *res_a,
+                       const gint32        image_id,
+                       FILE               *f,
+                       GError            **error)
 {
   /* Save photoshop resources with no meaning for GIMP as image parasites
      to re-save later */
@@ -443,7 +471,7 @@
   data = g_malloc (res_a->data_len);
   if (fread (data, res_a->data_len, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block %d"), res_a->id);
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
@@ -461,9 +489,10 @@
 }
 
 static gint
-load_resource_1005 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    FILE              *f)
+load_resource_1005 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load image resolution and unit of measure */
 
@@ -481,7 +510,7 @@
       || fread (&res_info.vResUnit, 2, 1, f) < 1
       || fread (&res_info.heightUnit, 2, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block %d"), res_a->id);
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   res_info.hRes = GINT32_FROM_BE (res_info.hRes);
@@ -499,7 +528,7 @@
                       res_info.vResUnit,
                       res_info.heightUnit);
 
-  /* Resolution always record as pixels / inch in a fixed point implied
+  /* Resolution always recorded as pixels / inch in a fixed point implied
      decimal int32 with 16 bits before point and 16 after (i.e. cast as
      double and divide resolution by 2^16 */
   gimp_image_set_resolution (image_id,
@@ -524,24 +553,25 @@
 }
 
 static gint
-load_resource_1006 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    PSDimage          *img_a,
-                    FILE              *f)
+load_resource_1006 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    PSDimage           *img_a,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load alpha channel names stored as a series of pascal strings
      unpadded between strings */
 
   gchar        *str;
-  gint32        block_rem,
-                read_len,
-                write_len;
+  gint32        block_rem;
+  gint32        read_len;
+  gint32        write_len;
 
   IFDBG(2) g_debug ("Process image resource block 1006: Alpha Channel Names");
 
   if (img_a->alpha_names)
     {
-      IFDBG(2) g_debug ("Alpha names loaded from unicode resource block");
+      IFDBG(3) g_debug ("Alpha names loaded from unicode resource block");
       return 0;
     }
 
@@ -550,12 +580,13 @@
   block_rem = res_a->data_len;
   while (block_rem > 1)
     {
-      str = fread_pascal_string (&read_len, &write_len, 1, f);
-      IFDBG(2) g_debug ("String: %s, %d, %d", str, read_len, write_len);
+      str = fread_pascal_string (&read_len, &write_len, 1, f, error);
+      if (*error)
+        return -1;
+      IFDBG(3) g_debug ("String: %s, %d, %d", str, read_len, write_len);
       if (write_len >= 0)
         {
-          g_ptr_array_add (img_a->alpha_names, (gpointer) g_strdup (str));
-          g_free (str);
+          g_ptr_array_add (img_a->alpha_names, (gpointer) str);
         }
       block_rem -= read_len;
     }
@@ -564,10 +595,11 @@
 }
 
 static gint
-load_resource_1007 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    PSDimage          *img_a,
-                    FILE              *f)
+load_resource_1007 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    PSDimage           *img_a,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load alpha channel display info */
 
@@ -594,7 +626,7 @@
           || fread (&dsp_info.kind, 1, 1, f) < 1
           || fread (&dsp_info.padding, 1, 1, f) < 1)
         {
-          g_message (_("Error reading image resource block %d"), res_a->id);
+          psd_set_error (feof (f), errno, error);
           return -1;
         }
       dsp_info.colorSpace = GINT16_FROM_BE (dsp_info.colorSpace);
@@ -642,9 +674,14 @@
           case PSD_CS_DIC:
           case PSD_CS_ANPA:
           default:
-            IFDBG(2) g_debug ("Color space %d not supported by GIMP", dsp_info.colorSpace);
+            if (CONVERSION_WARNINGS)
+              g_message ("Unsupported color space: %d",
+                         dsp_info.colorSpace);
             gimp_rgb_set (&gimp_rgb, 1.0, 0.0, 0.0);
         }
+
+      gimp_rgb_set_alpha (&gimp_rgb, 1.0);
+
       IFDBG(2) g_debug ("PS cSpace: %d, col: %d %d %d %d, opacity: %d, kind: %d",
              dsp_info.colorSpace, ps_color.cmyk.cyan, ps_color.cmyk.magenta,
              ps_color.cmyk.yellow, ps_color.cmyk.black, dsp_info.opacity,
@@ -666,20 +703,23 @@
 }
 
 static gint
-load_resource_1008 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    FILE              *f)
+load_resource_1008 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load image caption */
   GimpParasite  *parasite;
   gchar         *caption;
-  gint32         read_len,
-                 write_len;
+  gint32         read_len;
+  gint32         write_len;
 
   IFDBG(2) g_debug ("Process image resource block: 1008: Caption");
-  caption = fread_pascal_string (&read_len, &write_len, 1, f);
+  caption = fread_pascal_string (&read_len, &write_len, 1, f, error);
+  if (*error)
+    return -1;
 
-  IFDBG(2) g_debug ("Caption: %s", caption);
+  IFDBG(3) g_debug ("Caption: %s", caption);
   parasite = gimp_parasite_new (GIMP_PARASITE_COMMENT, GIMP_PARASITE_PERSISTENT,
                                 write_len, caption);
   gimp_image_parasite_attach (image_id, parasite);
@@ -690,10 +730,11 @@
 }
 
 static gint
-load_resource_1022 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    PSDimage          *img_a,
-                    FILE              *f)
+load_resource_1022 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    PSDimage           *img_a,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load quick mask info */
   gboolean              quick_mask_empty;       /* Quick mask initially empty */
@@ -703,7 +744,7 @@
   if (fread (&img_a->quick_mask_id, 2, 1, f) < 1
       || fread (&quick_mask_empty, 1, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block %d"), res_a->id);
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   img_a->quick_mask_id = GUINT16_FROM_BE (img_a->quick_mask_id);
@@ -716,17 +757,18 @@
 }
 
 static gint
-load_resource_1024 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    PSDimage          *img_a,
-                    FILE              *f)
+load_resource_1024 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    PSDimage           *img_a,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load image layer state - current active layer counting from bottom up */
   IFDBG(2) g_debug ("Process image resource block: 1024: Layer State");
 
   if (fread (&img_a->layer_state, 2, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block %d"), res_a->id);
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   img_a->layer_state = GUINT16_FROM_BE (img_a->layer_state);
@@ -735,9 +777,10 @@
 }
 
 static gint
-load_resource_1028 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    FILE              *f)
+load_resource_1028 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load IPTC data block */
 
@@ -757,7 +800,7 @@
   res_data = g_malloc (res_a->data_len);
   if (fread (res_data, res_a->data_len, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block %d"), res_a->id);
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
@@ -787,7 +830,7 @@
   IFDBG (2) g_debug ("Processing IPTC data as psd parasite");
   name = g_strdup_printf ("psd-image-resource-%.4s-%.4x",
                            res_a->type, res_a->id);
-  IFDBG(2) g_debug ("Parasite name: %s", name);
+  IFDBG(3) g_debug ("Parasite name: %s", name);
 
   parasite = gimp_parasite_new (name, 0, res_a->data_len, res_data);
   gimp_image_parasite_attach (image_id, parasite);
@@ -801,9 +844,10 @@
 }
 
 static gint
-load_resource_1032 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    FILE              *f)
+load_resource_1032 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load grid and guides */
 
@@ -820,7 +864,7 @@
       || fread (&hdr.fGridCycleH, 4, 1, f) < 1
       || fread (&hdr.fGuideCount, 4, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block %d"), res_a->id);
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   hdr.fVersion = GUINT32_FROM_BE (hdr.fVersion);
@@ -828,7 +872,7 @@
   hdr.fGridCycleH = GUINT32_FROM_BE (hdr.fGridCycleH);
   hdr.fGuideCount = GUINT32_FROM_BE (hdr.fGuideCount);
 
-  IFDBG(2) g_debug ("Grids & Guides: %d, %d, %d, %d",
+  IFDBG(3) g_debug ("Grids & Guides: %d, %d, %d, %d",
                      hdr.fVersion,
                      hdr.fGridCycleV,
                      hdr.fGridCycleH,
@@ -839,13 +883,13 @@
       if (fread (&guide.fLocation, 4, 1, f) < 1
           || fread (&guide.fDirection, 1, 1, f) < 1)
         {
-          g_message (_("Error reading image resource block %d"), res_a->id);
+          psd_set_error (feof (f), errno, error);
           return -1;
         }
       guide.fLocation = GUINT32_FROM_BE (guide.fLocation);
       guide.fLocation /= 32;
 
-      IFDBG(2) g_debug ("Guide: %d px, %d",
+      IFDBG(3) g_debug ("Guide: %d px, %d",
                          guide.fLocation,
                          guide.fDirection);
 
@@ -859,9 +903,10 @@
 }
 
 static gint
-load_resource_1033 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    FILE              *f)
+load_resource_1033 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load thumbnail image */
 
@@ -872,9 +917,9 @@
   GimpDrawable         *drawable;
   GimpPixelRgn          pixel_rgn;
   gint32                layer_id;
-  guchar               *buf,
-                       *rgb_buf,
-                      **rowbuf;
+  guchar               *buf;
+  guchar               *rgb_buf;
+  guchar              **rowbuf;
   gint                  i;
 
   IFDBG(2) g_debug ("Process image resource block %d: Thumbnail Image", res_a->id);
@@ -889,7 +934,7 @@
       || fread (&thumb_info.bitspixel, 2, 1, f) < 1
       || fread (&thumb_info.planes, 2, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block %d"), res_a->id);
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   thumb_info.format = GINT32_FROM_BE (thumb_info.format);
@@ -910,7 +955,7 @@
 
   if (thumb_info.format != 1)
     {
-      g_message (_("Unknown thumbnail format %d"), thumb_info.format);
+      IFDBG(1) g_debug ("Unknown thumbnail format %d", thumb_info.format);
       return -1;
     }
 
@@ -1008,9 +1053,10 @@
 }
 
 static gint
-load_resource_1039 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    FILE              *f)
+load_resource_1039 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load ICC profile */
   GimpParasite  *parasite;
@@ -1021,7 +1067,7 @@
   icc_profile = g_malloc (res_a->data_len);
   if (fread (icc_profile, res_a->data_len, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block %d"), res_a->id);
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
@@ -1036,24 +1082,31 @@
 }
 
 static gint
-load_resource_1045 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    PSDimage          *img_a,
-                    FILE              *f)
+load_resource_1045 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    PSDimage           *img_a,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load alpha channel names stored as a series of unicode strings
      in a GPtrArray */
 
   gchar        *str;
-  gint32        block_rem,
-                read_len,
-                write_len;
+  gint32        block_rem;
+  gint32        read_len;
+  gint32        write_len;
 
   IFDBG(2) g_debug ("Process image resource block 1045: Unicode Alpha Channel Names");
 
   if (img_a->alpha_names)
     {
-      IFDBG(2) g_debug ("Deleting localised alpha channel names");
+      gint      i;
+      IFDBG(3) g_debug ("Deleting localised alpha channel names");
+      for (i = 0; i < img_a->alpha_names->len; ++i)
+        {
+          str = g_ptr_array_index (img_a->alpha_names, i);
+          g_free (str);
+        }
       g_ptr_array_free (img_a->alpha_names, TRUE);
     }
 
@@ -1062,12 +1115,14 @@
   block_rem = res_a->data_len;
   while (block_rem > 1)
     {
-      str = fread_unicode_string (&read_len, &write_len, 1, f);
-      IFDBG(2) g_debug ("String: %s, %d, %d", str, read_len, write_len);
+      str = fread_unicode_string (&read_len, &write_len, 1, f, error);
+      if (*error)
+        return -1;
+
+      IFDBG(3) g_debug ("String: %s, %d, %d", str, read_len, write_len);
       if (write_len >= 0)
         {
-          g_ptr_array_add (img_a->alpha_names, (gpointer) g_strdup (str));
-          g_free (str);
+          g_ptr_array_add (img_a->alpha_names, (gpointer) str);
         }
       block_rem -= read_len;
     }
@@ -1076,9 +1131,10 @@
 }
 
 static gint
-load_resource_1046 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    FILE              *f)
+load_resource_1046 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load indexed color table count */
   guchar       *cmap;
@@ -1089,12 +1145,12 @@
 
   if (fread (&index_count, 2, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block %d"), res_a->id);
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   index_count = GINT16_FROM_BE (index_count);
 
-  IFDBG(2) g_debug ("Indexed color table count: %d", index_count);
+  IFDBG(3) g_debug ("Indexed color table count: %d", index_count);
   /* FIXME - check that we have indexed image */
   if (index_count && index_count < 256)
     {
@@ -1107,14 +1163,15 @@
 }
 
 static gint
-load_resource_1053 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    PSDimage          *img_a,
-                    FILE              *f)
+load_resource_1053 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    PSDimage           *img_a,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load image alpha channel ids (tattoos) */
-  gint16        tot_rec,
-                cidx;
+  gint16        tot_rec;
+  gint16        cidx;
 
   IFDBG(2) g_debug ("Process image resource block: 1053: Channel ID");
 
@@ -1128,7 +1185,7 @@
     {
       if (fread (&img_a->alpha_id[cidx], 4, 1, f) < 1)
         {
-          g_message (_("Error reading image resource block %d"), res_a->id);
+          psd_set_error (feof (f), errno, error);
           return -1;
         }
       img_a->alpha_id[cidx] = GUINT32_FROM_BE (img_a->alpha_id[cidx]);
@@ -1140,20 +1197,22 @@
 }
 
 static gint
-load_resource_1058 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    FILE              *f)
+load_resource_1058 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load EXIF data block */
 
 #ifdef HAVE_EXIF
   ExifData     *exif_data;
   ExifEntry    *exif_entry;
-  guchar       *exif_buf,
-               *tmp_data;
+  guchar       *exif_buf;
+  guchar       *tmp_data;
   guint         exif_buf_len;
-  gint16        jpeg_len,
-                jpeg_fill = 0;
+  gint16        jpeg_len;
+  gint16        jpeg_fill = 0;
+  GimpParam    *return_vals;
   gint          nreturn_vals;
 #else
   gchar        *name;
@@ -1167,7 +1226,7 @@
   res_data = g_malloc (res_a->data_len);
   if (fread (res_data, res_a->data_len, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block %d"), res_a->id);
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
@@ -1198,19 +1257,20 @@
   if ((exif_entry = exif_content_get_entry (exif_data->ifd[EXIF_IFD_0],
                                             EXIF_TAG_XML_PACKET)))
     {
-      IFDBG(2) g_debug ("Processing Exif XMP data block");
+      IFDBG(3) g_debug ("Processing Exif XMP data block");
       /*Create NULL terminated EXIF data block */
       tmp_data = g_malloc (exif_entry->size + 1);
       memcpy (tmp_data, exif_entry->data, exif_entry->size);
       tmp_data[exif_entry->size] = 0;
       /* Merge with existing XMP data block */
-      gimp_run_procedure (DECODE_XMP_PROC,
-                          &nreturn_vals,
-                          GIMP_PDB_IMAGE,  image_id,
-                          GIMP_PDB_STRING, tmp_data,
-                          GIMP_PDB_END);
+      return_vals = gimp_run_procedure (DECODE_XMP_PROC,
+                                        &nreturn_vals,
+                                        GIMP_PDB_IMAGE,  image_id,
+                                        GIMP_PDB_STRING, tmp_data,
+                                        GIMP_PDB_END);
       g_free (tmp_data);
-      IFDBG(2) g_debug ("Deleting XMP block from Exif data");
+      gimp_destroy_params (return_vals, nreturn_vals);
+      IFDBG(3) g_debug ("Deleting XMP block from Exif data");
       /* Delete XMP data from Exif block */
       exif_content_remove_entry (exif_data->ifd[EXIF_IFD_0],
                                  exif_entry);
@@ -1220,7 +1280,7 @@
   if ((exif_entry = exif_content_get_entry (exif_data->ifd[EXIF_IFD_0],
                                             EXIF_TAG_IMAGE_RESOURCES)))
     {
-      IFDBG(2) g_debug ("Deleting PS Image Resource block from Exif data");
+      IFDBG(3) g_debug ("Deleting PS Image Resource block from Exif data");
       /* Delete PS Image Resource data from Exif block */
       exif_content_remove_entry (exif_data->ifd[EXIF_IFD_0],
                                  exif_entry);
@@ -1247,7 +1307,7 @@
   IFDBG (2) g_debug ("Processing exif data as psd parasite");
   name = g_strdup_printf ("psd-image-resource-%.4s-%.4x",
                            res_a->type, res_a->id);
-  IFDBG(2) g_debug ("Parasite name: %s", name);
+  IFDBG(3) g_debug ("Parasite name: %s", name);
 
   parasite = gimp_parasite_new (name, 0, res_a->data_len, res_data);
   gimp_image_parasite_attach (image_id, parasite);
@@ -1261,11 +1321,13 @@
 }
 
 static gint
-load_resource_1060 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    FILE              *f)
+load_resource_1060 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load XMP Metadata block */
+  GimpParam    *return_vals;
   gint          nreturn_vals;
   gchar        *res_data;
 
@@ -1274,42 +1336,42 @@
   res_data = g_malloc (res_a->data_len + 1);
   if (fread (res_data, res_a->data_len, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block %d"), res_a->id);
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   /* Null terminate metadata block for decode procedure */
   res_data[res_a->data_len] = 0;
 
-  gimp_run_procedure (DECODE_XMP_PROC,
-                      &nreturn_vals,
-                      GIMP_PDB_IMAGE,  image_id,
-                      GIMP_PDB_STRING, res_data,
-                      GIMP_PDB_END);
-
+  return_vals = gimp_run_procedure (DECODE_XMP_PROC,
+                                    &nreturn_vals,
+                                    GIMP_PDB_IMAGE,  image_id,
+                                    GIMP_PDB_STRING, res_data,
+                                    GIMP_PDB_END);
   g_free (res_data);
+  gimp_destroy_params (return_vals, nreturn_vals);
   return 0;
 }
 
 static gint
-load_resource_2000 (const PSDimageres *res_a,
-                    const gint32       image_id,
-                    FILE              *f)
+load_resource_2000 (const PSDimageres  *res_a,
+                    const gint32        image_id,
+                    FILE               *f,
+                    GError            **error)
 {
-  gchar        *name;
   gdouble      *controlpoints;
-  gint32        x[3],
-                y[3],
-                vector_id = -1;
-  gint16        type,
-                init_fill,
-                num_rec,
-                path_rec,
-                cntr;
-  gint          image_width,
-                image_height,
-                i;
-  gboolean      closed,
-                fill;
+  gint32        x[3];
+  gint32        y[3];
+  gint32        vector_id = -1;
+  gint16        type;
+  gint16        init_fill;
+  gint16        num_rec;
+  gint16        path_rec;
+  gint16        cntr;
+  gint          image_width;
+  gint          image_height;
+  gint          i;
+  gboolean      closed;
+  gboolean      fill;
 
   /* Load path data from image resources 2000-2998 */
 
@@ -1320,13 +1382,13 @@
 
   if (fread (&type, 2, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block %d"), res_a->id);
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   type = GINT16_FROM_BE (type);
   if (type != PSD_PATH_FILL_RULE)
     {
-      g_message (_("Unexpected path record type: %d"), type);
+      IFDBG(1) g_debug ("Unexpected path record type: %d", type);
       return -1;
     }
   else
@@ -1334,7 +1396,7 @@
 
   if (fseek (f, 24, SEEK_CUR) < 0)
     {
-      g_message (_("Error setting file position"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
@@ -1346,27 +1408,25 @@
   image_height = gimp_image_height (image_id);
 
   /* Create path */
-  name = gimp_any_to_utf8 (res_a->name, -1, _("Invalid UTF-8 string in PSD file"));
-  vector_id = gimp_vectors_new (image_id, name);
-  g_free (name);
+  vector_id = gimp_vectors_new (image_id, res_a->name);
   gimp_image_add_vectors (image_id, vector_id, -1);
 
   while (path_rec > 0)
     {
       if (fread (&type, 2, 1, f) < 1)
         {
-          g_message (_("Error reading image resource block %d"), res_a->id);
+          psd_set_error (feof (f), errno, error);
           return -1;
         }
       type = GINT16_FROM_BE (type);
-      IFDBG(2) g_debug ("Path record type %d", type);
+      IFDBG(3) g_debug ("Path record type %d", type);
 
       if (type == PSD_PATH_FILL_RULE)
         {
           fill = FALSE;
           if (fseek (f, 24, SEEK_CUR) < 0)
             {
-              g_message (_("Error setting file position"));
+              psd_set_error (feof (f), errno, error);
               return -1;
             }
         }
@@ -1375,7 +1435,7 @@
         {
           if (fread (&init_fill, 2, 1, f) < 1)
             {
-              g_message (_("Error reading image resource block %d"), res_a->id);
+              psd_set_error (feof (f), errno, error);
               return -1;
             }
           if (init_fill != 0)
@@ -1383,7 +1443,7 @@
 
           if (fseek (f, 22, SEEK_CUR) < 0)
             {
-              g_message (_("Error setting file position"));
+              psd_set_error (feof (f), errno, error);
               return -1;
             }
         }
@@ -1393,16 +1453,16 @@
         {
           if (fread (&num_rec, 2, 1, f) < 1)
             {
-              g_message (_("Error reading image resource block %d"), res_a->id);
+              psd_set_error (feof (f), errno, error);
               return -1;
             }
           num_rec = GINT16_FROM_BE (num_rec);
           if (num_rec > path_rec)
             {
-              g_message (_("Too many path point records"));
+              psd_set_error (feof (f), errno, error);
               return - 1;
             }
-          IFDBG(2) g_debug ("Num path records %d", num_rec);
+          IFDBG(3) g_debug ("Num path records %d", num_rec);
 
           if (type == PSD_PATH_CL_LEN)
             closed = TRUE;
@@ -1412,7 +1472,7 @@
           controlpoints = g_malloc (sizeof (gdouble) * num_rec * 6);
           if (fseek (f, 22, SEEK_CUR) < 0)
             {
-              g_message (_("Error setting file position"));
+              psd_set_error (feof (f), errno, error);
               return -1;
             }
 
@@ -1420,12 +1480,11 @@
             {
               if (fread (&type, 2, 1, f) < 1)
                 {
-                  g_message (_("Error reading image resource block %d"),
-                             res_a->id);
+                  psd_set_error (feof (f), errno, error);
                   return -1;
                 }
               type = GINT16_FROM_BE (type);
-              IFDBG(2) g_debug ("Path record type %d", type);
+              IFDBG(3) g_debug ("Path record type %d", type);
 
               if (type == PSD_PATH_CL_LNK
                   || type == PSD_PATH_CL_UNLNK
@@ -1439,8 +1498,7 @@
                     || fread (&y[2], 4, 1, f) < 1
                     || fread (&x[2], 4, 1, f) < 1)
                     {
-                      g_message (_("Error reading image resource block %d"),
-                                 res_a->id);
+                      psd_set_error (feof (f), errno, error);
                       return -1;
                     }
                   for (i = 0; i < 3; ++i)
@@ -1452,15 +1510,15 @@
                       controlpoints[cntr] = y[i] / 16777216.0 * image_height;
                       cntr++;
                     }
-                  IFDBG(2) g_debug ("Path points (%d,%d), (%d,%d), (%d,%d)",
+                  IFDBG(3) g_debug ("Path points (%d,%d), (%d,%d), (%d,%d)",
                                     x[0], y[0], x[1], y[1], x[2], y[2]);
                 }
               else
                 {
-                  g_message (_("Unexpected path type record %d"), type);
+                  IFDBG(1) g_debug ("Unexpected path type record %d", type);
                   if (fseek (f, 24, SEEK_CUR) < 0)
                     {
-                      g_message (_("Error setting file position"));
+                      psd_set_error (feof (f), errno, error);
                       return -1;
                     }
                 }
@@ -1478,7 +1536,7 @@
         {
           if (fseek (f, 24, SEEK_CUR) < 0)
             {
-              g_message (_("Error setting file position"));
+              psd_set_error (feof (f), errno, error);
               return -1;
             }
         }

Modified: branches/weskaggs/plug-ins/psd/psd-image-res-load.h
==============================================================================
--- branches/weskaggs/plug-ins/psd/psd-image-res-load.h	(original)
+++ branches/weskaggs/plug-ins/psd/psd-image-res-load.h	Thu Jan 10 03:08:46 2008
@@ -24,16 +24,18 @@
 
 
 gint  get_image_resource_header (PSDimageres  *res_a,
-                                 FILE         *f);
-
-gint  load_image_resource       (PSDimageres  *res_a,
-                                 const gint32  image_id,
-                                 PSDimage     *img_a,
-                                 FILE         *f);
-
-gint  load_thumbnail_resource   (PSDimageres  *res_a,
-                                 const gint32  image_id,
-                                 FILE         *f);
+                                 FILE         *f,
+                                 GError      **error);
 
+gint  load_image_resource       (PSDimageres   *res_a,
+                                 const gint32   image_id,
+                                 PSDimage      *img_a,
+                                 FILE          *f,
+                                 GError       **error);
+
+gint  load_thumbnail_resource   (PSDimageres   *res_a,
+                                 const gint32   image_id,
+                                 FILE          *f,
+                                 GError       **error);
 
 #endif /* __PSD_IMAGE_RES_LOAD_H__ */

Modified: branches/weskaggs/plug-ins/psd/psd-layer-res-load.c
==============================================================================
--- branches/weskaggs/plug-ins/psd/psd-layer-res-load.c	(original)
+++ branches/weskaggs/plug-ins/psd/psd-layer-res-load.c	Thu Jan 10 03:08:46 2008
@@ -92,6 +92,7 @@
 #include "config.h"
 
 #include <string.h>
+#include <errno.h>
 
 #include <glib/gstdio.h>
 #include <libgimp/gimp.h>
@@ -102,51 +103,59 @@
 
 #include "libgimp/stdplugins-intl.h"
 
-
 /*  Local function prototypes  */
 static gint     load_resource_unknown (const PSDlayerres     *res_a,
                                        PSDlayer              *lyr_a,
-                                       FILE                  *f);
+                                       FILE                  *f,
+                                       GError               **error);
 
 static gint     load_resource_ladj    (const PSDlayerres     *res_a,
                                        PSDlayer              *lyr_a,
-                                       FILE                  *f);
+                                       FILE                  *f,
+                                       GError               **error);
 
 static gint     load_resource_lfil    (const PSDlayerres     *res_a,
                                        PSDlayer              *lyr_a,
-                                       FILE                  *f);
+                                       FILE                  *f,
+                                       GError               **error);
 
 static gint     load_resource_lfx     (const PSDlayerres     *res_a,
                                        PSDlayer              *lyr_a,
-                                       FILE                  *f);
+                                       FILE                  *f,
+                                       GError               **error);
 
 static gint     load_resource_ltyp    (const PSDlayerres     *res_a,
                                        PSDlayer              *lyr_a,
-                                       FILE                  *f);
+                                       FILE                  *f,
+                                       GError               **error);
 
 static gint     load_resource_luni    (const PSDlayerres     *res_a,
                                        PSDlayer              *lyr_a,
-                                       FILE                  *f);
+                                       FILE                  *f,
+                                       GError               **error);
 
 static gint     load_resource_lyid    (const PSDlayerres     *res_a,
                                        PSDlayer              *lyr_a,
-                                       FILE                  *f);
+                                       FILE                  *f,
+                                       GError               **error);
 
 static gint     load_resource_lsct    (const PSDlayerres     *res_a,
                                        PSDlayer              *lyr_a,
-                                       FILE                  *f);
+                                       FILE                  *f,
+                                       GError               **error);
 
 
 /* Public Functions */
 gint
-get_layer_resource_header (PSDlayerres *res_a,
-                           FILE        *f)
+get_layer_resource_header (PSDlayerres  *res_a,
+                           FILE         *f,
+                           GError      **error)
 {
   if (fread (res_a->sig, 4, 1, f) < 1
       || fread (res_a->key, 4, 1, f) < 1
       || fread (&res_a->data_len, 4, 1, f) < 1)
     {
-      g_message (_("Error reading layer resource block header"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   res_a->data_len = GUINT32_FROM_BE (res_a->data_len);
@@ -159,64 +168,69 @@
 }
 
 gint
-load_layer_resource (PSDlayerres *res_a,
-                     PSDlayer    *lyr_a,
-                     FILE        *f)
+load_layer_resource (PSDlayerres  *res_a,
+                     PSDlayer     *lyr_a,
+                     FILE         *f,
+                     GError      **error)
 {
   gint  pad;
 
   /* Set file position to start of layer resource data block */
   if (fseek (f, res_a->data_start, SEEK_SET) < 0)
     {
-      g_message (_("Error setting file position"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
    /* Process layer resource blocks */
   if (memcmp (res_a->sig, "8BIM", 4) != 0)
-      g_message (_("Unknown layer resource signature %.4s"), res_a->sig);
-
-  if (memcmp (res_a->key, PSD_LADJ_LEVEL, 4) == 0
-      || memcmp (res_a->key, PSD_LADJ_CURVE, 4) == 0
-      || memcmp (res_a->key, PSD_LADJ_BRIGHTNESS, 4) == 0
-      || memcmp (res_a->key, PSD_LADJ_BALANCE, 4) == 0
-      || memcmp (res_a->key, PSD_LADJ_BLACK_WHITE, 4) == 0
-      || memcmp (res_a->key, PSD_LADJ_HUE, 4) == 0
-      || memcmp (res_a->key, PSD_LADJ_HUE2, 4) == 0
-      || memcmp (res_a->key, PSD_LADJ_SELECTIVE, 4) == 0
-      || memcmp (res_a->key, PSD_LADJ_MIXER, 4) == 0
-      || memcmp (res_a->key, PSD_LADJ_GRAD_MAP, 4) == 0
-      || memcmp (res_a->key, PSD_LADJ_PHOTO_FILT, 4) == 0
-      || memcmp (res_a->key, PSD_LADJ_EXPOSURE, 4) == 0
-      || memcmp (res_a->key, PSD_LADJ_THRESHOLD, 4) == 0
-      || memcmp (res_a->key, PSD_LADJ_INVERT, 4) == 0
-      || memcmp (res_a->key, PSD_LADJ_POSTERIZE, 4) == 0)
-        load_resource_ladj (res_a, lyr_a, f);
-
-  else if (memcmp (res_a->key, PSD_LFIL_SOLID, 4) == 0
-      || memcmp (res_a->key, PSD_LFIL_PATTERN, 4) == 0
-      || memcmp (res_a->key, PSD_LFIL_GRADIENT, 4) == 0)
-        load_resource_lfil (res_a, lyr_a, f);
-
-  else if (memcmp (res_a->key, PSD_LFX_FX, 4) == 0
-      || memcmp (res_a->key, PSD_LFX_FX2, 4) == 0)
-        load_resource_lfx (res_a, lyr_a, f);
-
-  else if (memcmp (res_a->key, PSD_LTYP_TYPE, 4) == 0
-      || memcmp (res_a->key, PSD_LTYP_TYPE2, 4) == 0)
-        load_resource_ltyp (res_a, lyr_a, f);
-
-  else if (memcmp (res_a->key, PSD_LPRP_UNICODE, 4) == 0)
-        load_resource_luni (res_a, lyr_a, f);
+    {
+      IFDBG(1) g_debug ("Unknown layer resource signature %.4s", res_a->sig);
+    }
+  else
+    {
+      if (memcmp (res_a->key, PSD_LADJ_LEVEL, 4) == 0
+          || memcmp (res_a->key, PSD_LADJ_CURVE, 4) == 0
+          || memcmp (res_a->key, PSD_LADJ_BRIGHTNESS, 4) == 0
+          || memcmp (res_a->key, PSD_LADJ_BALANCE, 4) == 0
+          || memcmp (res_a->key, PSD_LADJ_BLACK_WHITE, 4) == 0
+          || memcmp (res_a->key, PSD_LADJ_HUE, 4) == 0
+          || memcmp (res_a->key, PSD_LADJ_HUE2, 4) == 0
+          || memcmp (res_a->key, PSD_LADJ_SELECTIVE, 4) == 0
+          || memcmp (res_a->key, PSD_LADJ_MIXER, 4) == 0
+          || memcmp (res_a->key, PSD_LADJ_GRAD_MAP, 4) == 0
+          || memcmp (res_a->key, PSD_LADJ_PHOTO_FILT, 4) == 0
+          || memcmp (res_a->key, PSD_LADJ_EXPOSURE, 4) == 0
+          || memcmp (res_a->key, PSD_LADJ_THRESHOLD, 4) == 0
+          || memcmp (res_a->key, PSD_LADJ_INVERT, 4) == 0
+          || memcmp (res_a->key, PSD_LADJ_POSTERIZE, 4) == 0)
+            load_resource_ladj (res_a, lyr_a, f, error);
+
+      else if (memcmp (res_a->key, PSD_LFIL_SOLID, 4) == 0
+          || memcmp (res_a->key, PSD_LFIL_PATTERN, 4) == 0
+          || memcmp (res_a->key, PSD_LFIL_GRADIENT, 4) == 0)
+            load_resource_lfil (res_a, lyr_a, f, error);
+
+      else if (memcmp (res_a->key, PSD_LFX_FX, 4) == 0
+          || memcmp (res_a->key, PSD_LFX_FX2, 4) == 0)
+            load_resource_lfx (res_a, lyr_a, f, error);
+
+      else if (memcmp (res_a->key, PSD_LTYP_TYPE, 4) == 0
+          || memcmp (res_a->key, PSD_LTYP_TYPE2, 4) == 0)
+            load_resource_ltyp (res_a, lyr_a, f, error);
+
+      else if (memcmp (res_a->key, PSD_LPRP_UNICODE, 4) == 0)
+            load_resource_luni (res_a, lyr_a, f, error);
 
-  else if (memcmp (res_a->key, PSD_LPRP_ID, 4) == 0)
-        load_resource_lyid (res_a, lyr_a, f);
+      else if (memcmp (res_a->key, PSD_LPRP_ID, 4) == 0)
+            load_resource_lyid (res_a, lyr_a, f, error);
 
-  else if (memcmp (res_a->key, PSD_LOTH_SECTION, 4) == 0)
-        load_resource_lsct (res_a, lyr_a, f);
+      else if (memcmp (res_a->key, PSD_LOTH_SECTION, 4) == 0)
+            load_resource_lsct (res_a, lyr_a, f, error);
 
-  else
-    load_resource_unknown (res_a, lyr_a, f);
+      else
+        load_resource_unknown (res_a, lyr_a, f, error);
+    }
 
   /* Layer blocks are null padded to even length */
   if (res_a->data_len % 2 == 0)
@@ -227,7 +241,7 @@
   /* Set file position to end of layer resource block */
   if (fseek (f, res_a->data_start + res_a->data_len + pad, SEEK_SET) < 0)
     {
-      g_message (_("Error setting file position"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
@@ -237,9 +251,10 @@
 /* Private Functions */
 
 static gint
-load_resource_unknown (const PSDlayerres *res_a,
-                       PSDlayer          *lyr_a,
-                       FILE              *f)
+load_resource_unknown (const PSDlayerres  *res_a,
+                       PSDlayer           *lyr_a,
+                       FILE               *f,
+                       GError            **error)
 {
   IFDBG(2) g_debug ("Process unknown layer resource block: %.4s", res_a->key);
 
@@ -247,9 +262,10 @@
 }
 
 static gint
-load_resource_ladj (const PSDlayerres *res_a,
-                    PSDlayer          *lyr_a,
-                    FILE              *f)
+load_resource_ladj (const PSDlayerres  *res_a,
+                    PSDlayer           *lyr_a,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load adjustment layer */
   static gboolean   msg_flag = FALSE;
@@ -258,10 +274,10 @@
   lyr_a->drop = TRUE;
   if (! msg_flag && CONVERSION_WARNINGS)
     {
-      g_message (_("Warning:\n"
-                   "The image file contains adjustment layers. "
-                   "These are not supported by the GIMP and will "
-                   "be dropped."));
+      g_message ("Warning:\n"
+                 "The image file contains adjustment layers. "
+                 "These are not supported by the GIMP and will "
+                 "be dropped.");
       msg_flag = TRUE;
     }
 
@@ -269,9 +285,10 @@
 }
 
 static gint
-load_resource_lfil (const PSDlayerres *res_a,
-                    PSDlayer          *lyr_a,
-                    FILE              *f)
+load_resource_lfil (const PSDlayerres  *res_a,
+                    PSDlayer           *lyr_a,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load fill layer */
   static gboolean   msg_flag = FALSE;
@@ -279,10 +296,10 @@
   IFDBG(2) g_debug ("Process layer resource block %.4s: Fill layer", res_a->key);
   if (! msg_flag && CONVERSION_WARNINGS)
     {
-      g_message (_("Warning:\n"
-                   "The image file contains fill layers. "
-                   "These are not supported by the GIMP and will "
-                   "be rasterized."));
+      g_message ("Warning:\n"
+                 "The image file contains fill layers. "
+                 "These are not supported by the GIMP and will "
+                 "be rasterized.");
       msg_flag = TRUE;
     }
 
@@ -290,9 +307,10 @@
 }
 
 static gint
-load_resource_lfx (const PSDlayerres *res_a,
-                   PSDlayer          *lyr_a,
-                   FILE              *f)
+load_resource_lfx (const PSDlayerres  *res_a,
+                   PSDlayer           *lyr_a,
+                   FILE               *f,
+                   GError            **error)
 {
   /* Load layer effects */
   static gboolean   msg_flag = FALSE;
@@ -300,10 +318,10 @@
   IFDBG(2) g_debug ("Process layer resource block %.4s: Layer effects", res_a->key);
   if (! msg_flag && CONVERSION_WARNINGS)
     {
-      g_message (_("Warning:\n"
-                   "The image file contains layer effects. "
-                   "These are not supported by the GIMP and will "
-                   "be dropped."));
+      g_message ("Warning:\n"
+                 "The image file contains layer effects. "
+                 "These are not supported by the GIMP and will "
+                 "be dropped.");
       msg_flag = TRUE;
     }
 
@@ -311,36 +329,37 @@
 }
 
 static gint
-load_resource_ltyp (const PSDlayerres *res_a,
-                    PSDlayer          *lyr_a,
-                    FILE              *f)
+load_resource_ltyp (const PSDlayerres  *res_a,
+                    PSDlayer           *lyr_a,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load type tool layer */
-  gint16            version,
-                    text_desc_vers;
+  gint16            version;
+  gint16            text_desc_vers;
   gint32            desc_version;
-  guint64           t_xx,
-                    t_xy,
-                    t_yx,
-                    t_yy,
-                    t_tx,
-                    t_ty;
-  gdouble           transform_xx,
-                    transform_xy,
-                    transform_yx,
-                    transform_yy,
-                    transform_tx,
-                    transform_ty;
+  guint64           t_xx;
+  guint64           t_xy;
+  guint64           t_yx;
+  guint64           t_yy;
+  guint64           t_tx;
+  guint64           t_ty;
+  gdouble           transform_xx;
+  gdouble           transform_xy;
+  gdouble           transform_yx;
+  gdouble           transform_yy;
+  gdouble           transform_tx;
+  gdouble           transform_ty;
 
   static gboolean   msg_flag = FALSE;
 
   IFDBG(2) g_debug ("Process layer resource block %.4s: Type tool layer", res_a->key);
   if (! msg_flag && CONVERSION_WARNINGS)
     {
-      g_message (_("Warning:\n"
-                   "The image file contains type tool layers. "
-                   "These are not supported by the GIMP and will "
-                   "be dropped."));
+      g_message ("Warning:\n"
+                 "The image file contains type tool layers. "
+                 "These are not supported by the GIMP and will "
+                 "be dropped.");
       msg_flag = TRUE;
     }
 
@@ -357,7 +376,7 @@
           || fread (&text_desc_vers, 2, 1, f) < 1
           || fread (&desc_version, 4, 1, f) < 1)
         {
-          g_message (_("Error reading text descriptor info"));
+          psd_set_error (feof (f), errno, error);
           return -1;
         }
 
@@ -395,47 +414,52 @@
 }
 
 static gint
-load_resource_luni (const PSDlayerres *res_a,
-                    PSDlayer          *lyr_a,
-                    FILE              *f)
+load_resource_luni (const PSDlayerres  *res_a,
+                    PSDlayer           *lyr_a,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load layer name in unicode (length padded to multiple of 4 bytes) */
-  gint32                read_len,
-                        write_len;
+  gint32        read_len;
+  gint32        write_len;
 
   IFDBG(2) g_debug ("Process layer resource block luni: Unicode Name");
   if (lyr_a->name)
     g_free (lyr_a->name);
 
-  lyr_a->name = fread_unicode_string (&read_len, &write_len, 4, f);
-  IFDBG(2) g_debug ("Unicode name: %s", lyr_a->name);
+  lyr_a->name = fread_unicode_string (&read_len, &write_len, 4, f, error);
+  if (*error)
+    return -1;
+  IFDBG(3) g_debug ("Unicode name: %s", lyr_a->name);
 
   return 0;
 }
 
 static gint
-load_resource_lyid (const PSDlayerres *res_a,
-                    PSDlayer          *lyr_a,
-                    FILE              *f)
+load_resource_lyid (const PSDlayerres  *res_a,
+                    PSDlayer           *lyr_a,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load layer id (tattoo) */
 
   IFDBG(2) g_debug ("Process layer resource block lyid: Layer ID");
   if (fread (&lyr_a->id, 4, 1, f) < 1)
     {
-      g_message (_("Error reading layer ID"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   lyr_a->id = GUINT32_FROM_BE (lyr_a->id);
-  IFDBG(2) g_debug ("Layer id: %i", lyr_a->id);
+  IFDBG(3) g_debug ("Layer id: %i", lyr_a->id);
 
   return 0;
 }
 
 static gint
-load_resource_lsct (const PSDlayerres *res_a,
-                    PSDlayer          *lyr_a,
-                    FILE              *f)
+load_resource_lsct (const PSDlayerres  *res_a,
+                    PSDlayer           *lyr_a,
+                    FILE               *f,
+                    GError            **error)
 {
   /* Load adjustment layer */
   static gboolean   msg_flag = FALSE;
@@ -444,11 +468,11 @@
   IFDBG(2) g_debug ("Process layer resource block %.4s: Section divider", res_a->key);
   if (fread (&type, 4, 1, f) < 1)
     {
-      g_message (_("Error reading Section divider record"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   type = GUINT32_FROM_BE (type);
-  IFDBG(2) g_debug ("Section divider type: %i", type);
+  IFDBG(3) g_debug ("Section divider type: %i", type);
 
   if (type == 1 ||      /* Layer group start - open folder */
       type == 2)        /* Layer group start - closed folder */
@@ -456,10 +480,10 @@
       lyr_a->drop = TRUE;
       if (! msg_flag && CONVERSION_WARNINGS)
         {
-          g_message (_("Warning:\n"
-                       "The image file contains layer groups. "
-                       "These are not supported by the GIMP and will "
-                       "be dropped."));
+          g_message ("Warning:\n"
+                     "The image file contains layer groups. "
+                     "These are not supported by the GIMP and will "
+                     "be dropped.");
           msg_flag = TRUE;
         }
     }

Modified: branches/weskaggs/plug-ins/psd/psd-layer-res-load.h
==============================================================================
--- branches/weskaggs/plug-ins/psd/psd-layer-res-load.h	(original)
+++ branches/weskaggs/plug-ins/psd/psd-layer-res-load.h	Thu Jan 10 03:08:46 2008
@@ -23,12 +23,14 @@
 #define __PSD_LAYER_RES_LOAD_H__
 
 
-gint  get_layer_resource_header (PSDlayerres *res_a,
-                                 FILE        *f);
+gint  get_layer_resource_header (PSDlayerres  *res_a,
+                                 FILE         *f,
+                                 GError      **error);
 
-gint  load_layer_resource       (PSDlayerres *res_a,
-                                 PSDlayer    *lyr_a,
-                                 FILE        *f);
+gint  load_layer_resource       (PSDlayerres  *res_a,
+                                 PSDlayer     *lyr_a,
+                                 FILE         *f,
+                                 GError      **error);
 
 
 #endif /* __PSD_LAYER_RES_LOAD_H__ */

Modified: branches/weskaggs/plug-ins/psd/psd-load.c
==============================================================================
--- branches/weskaggs/plug-ins/psd/psd-load.c	(original)
+++ branches/weskaggs/plug-ins/psd/psd-load.c	Thu Jan 10 03:08:46 2008
@@ -35,22 +35,26 @@
 
 #include "libgimp/stdplugins-intl.h"
 
-
 /*  Local function prototypes  */
 static gint             read_header_block          (PSDimage     *img_a,
-                                                    FILE         *f);
+                                                    FILE         *f,
+                                                    GError      **error);
 
 static gint             read_color_mode_block      (PSDimage     *img_a,
-                                                    FILE         *f);
+                                                    FILE         *f,
+                                                    GError      **error);
 
 static gint             read_image_resource_block  (PSDimage     *img_a,
-                                                    FILE         *f);
+                                                    FILE         *f,
+                                                    GError      **error);
 
 static PSDlayer **      read_layer_block           (PSDimage     *img_a,
-                                                    FILE         *f);
+                                                    FILE         *f,
+                                                    GError      **error);
 
 static gint             read_merged_image_block    (PSDimage     *img_a,
-                                                    FILE         *f);
+                                                    FILE         *f,
+                                                    GError      **error);
 
 static gint32           create_gimp_image          (PSDimage     *img_a,
                                                     const gchar  *filename);
@@ -60,18 +64,23 @@
 
 static gint             add_image_resources        (const gint32  image_id,
                                                     PSDimage     *img_a,
-                                                    FILE         *f);
+                                                    FILE         *f,
+                                                    GError      **error);
 
 static gint             add_layers                 (const gint32  image_id,
                                                     PSDimage     *img_a,
                                                     PSDlayer    **lyr_a,
-                                                    FILE         *f);
+                                                    FILE         *f,
+                                                    GError      **error);
 
 static gint             add_merged_image           (const gint32  image_id,
                                                     PSDimage     *img_a,
-                                                    FILE         *f);
+                                                    FILE         *f,
+                                                    GError      **error);
 
 /*  Local utility function prototypes  */
+static gchar          * get_psd_color_mode_name    (PSDColorMode  mode);
+
 static void             psd_to_gimp_color_map      (guchar       *map256);
 
 static GimpImageType    get_gimp_image_type        (const GimpImageBaseType image_base_type,
@@ -81,11 +90,13 @@
                                                     const guint16   bps,
                                                     const guint16   compression,
                                                     const guint16  *rle_pack_len,
-                                                    FILE           *f);
+                                                    FILE           *f,
+                                                    GError        **error);
 
 static void             convert_16_bit             (const gchar *src,
                                                     gchar       *dst,
                                                     guint32      len);
+
 static void             convert_1_bit              (const gchar *src,
                                                     gchar       *dst,
                                                     guint32      rows,
@@ -101,14 +112,13 @@
   PSDimage              img_a;
   PSDlayer            **lyr_a;
   gint32                image_id = -1;
-
+  GError               *error = NULL;
 
   /* ----- Open PSD file ----- */
   if (g_stat (filename, &st) == -1)
     return -1;
 
   IFDBG(1) g_debug ("Open file %s", gimp_filename_to_utf8 (filename));
-
   f = g_fopen (filename, "rb");
   if (f == NULL)
     {
@@ -120,121 +130,103 @@
   gimp_progress_init_printf (_("Opening '%s'"),
                              gimp_filename_to_utf8 (filename));
 
-  IFDBG(2) g_debug ("Read header block");
   /* ----- Read the PSD file Header block ----- */
-  if (read_header_block (&img_a, f) < 0)
-    {
-      fclose(f);
-      return -1;
-    }
+  IFDBG(2) g_debug ("Read header block");
+  if (read_header_block (&img_a, f, &error) < 0)
+    goto load_error;
   gimp_progress_update (0.1);
 
-  IFDBG(2) g_debug ("Read colour mode block");
   /* ----- Read the PSD file Colour Mode block ----- */
-  if (read_color_mode_block (&img_a, f) < 0)
-    {
-      fclose(f);
-      return -1;
-    }
+  IFDBG(2) g_debug ("Read colour mode block");
+  if (read_color_mode_block (&img_a, f, &error) < 0)
+    goto load_error;
   gimp_progress_update (0.2);
 
-  IFDBG(2) g_debug ("Read image resource block");
   /* ----- Read the PSD file Image Resource block ----- */
-  if (read_image_resource_block (&img_a, f) < 0)
-    {
-      fclose(f);
-      return -1;
-    }
+  IFDBG(2) g_debug ("Read image resource block");
+  if (read_image_resource_block (&img_a, f, &error) < 0)
+    goto load_error;
   gimp_progress_update (0.3);
 
-  IFDBG(2) g_debug ("Read layer & mask block");
   /* ----- Read the PSD file Layer & Mask block ----- */
-  lyr_a = read_layer_block (&img_a, f);
-  if (img_a.num_layers != 0)
-    if (lyr_a == NULL)
-      {
-        fclose(f);
-        return -1;
-      }
+  IFDBG(2) g_debug ("Read layer & mask block");
+  lyr_a = read_layer_block (&img_a, f, &error);
+  if (img_a.num_layers != 0 && lyr_a == NULL)
+    goto load_error;
   gimp_progress_update (0.4);
 
-  IFDBG(2) g_debug ("Read merged image and extra alpha channel block");
   /* ----- Read the PSD file Merged Image Data block ----- */
-  if (read_merged_image_block (&img_a, f) < 0)
-    {
-      fclose(f);
-      return -1;
-    }
+  IFDBG(2) g_debug ("Read merged image and extra alpha channel block");
+  if (read_merged_image_block (&img_a, f, &error) < 0)
+    goto load_error;
   gimp_progress_update (0.5);
 
-  IFDBG(2) g_debug ("Create GIMP image");
   /* ----- Create GIMP image ----- */
+  IFDBG(2) g_debug ("Create GIMP image");
   image_id = create_gimp_image (&img_a, filename);
-  if (image_id == -1)
-    {
-      fclose(f);
-      return -1;
-    }
+  if (image_id < 0)
+    goto load_error;
   gimp_progress_update (0.6);
 
-  IFDBG(2) g_debug ("Add color map");
   /* ----- Add colour map ----- */
+  IFDBG(2) g_debug ("Add color map");
   if (add_color_map (image_id, &img_a) < 0)
-    {
-      gimp_image_delete (image_id);
-      fclose(f);
-      return -1;
-    }
+    goto load_error;
   gimp_progress_update (0.7);
 
-  IFDBG(2) g_debug ("Add image resources");
   /* ----- Add image resources ----- */
-  if (add_image_resources (image_id, &img_a, f) < 0)
-    {
-      gimp_image_delete (image_id);
-      fclose(f);
-      return -1;
-    }
+  IFDBG(2) g_debug ("Add image resources");
+  if (add_image_resources (image_id, &img_a, f, &error) < 0)
+    goto load_error;
   gimp_progress_update (0.8);
 
-  IFDBG(2) g_debug ("Add layers");
   /* ----- Add layers -----*/
-  if (add_layers (image_id, &img_a, lyr_a, f) < 0)
-    {
-      gimp_image_delete (image_id);
-      fclose(f);
-      return -1;
-    }
+  IFDBG(2) g_debug ("Add layers");
+  if (add_layers (image_id, &img_a, lyr_a, f, &error) < 0)
+    goto load_error;
   gimp_progress_update (0.9);
 
-  IFDBG(2) g_debug ("Add merged image data and extra alpha channels");
   /* ----- Add merged image data and extra alpha channels ----- */
-  if (add_merged_image (image_id, &img_a, f) < 0)
-    {
-      gimp_image_delete (image_id);
-      fclose(f);
-      return -1;
-    }
-
+  IFDBG(2) g_debug ("Add merged image data and extra alpha channels");
+  if (add_merged_image (image_id, &img_a, f, &error) < 0)
+    goto load_error;
+  gimp_progress_update (1.0);
 
   IFDBG(2) g_debug ("Close file & return, image id: %d", image_id);
   IFDBG(1) g_debug ("\n----------------------------------------"
                     "----------------------------------------\n");
 
-  gimp_progress_update (1.0);
-
   gimp_image_clean_all (image_id);
   gimp_image_undo_enable (image_id);
   fclose (f);
   return image_id;
+
+  /* ----- Process load errors ----- */
+ load_error:
+  if (error)
+    {
+      g_message (_("Error loading PSD file:\n\n%s"), error->message);
+      g_error_free (error);
+    }
+
+  /* Delete partially loaded image */
+  if (image_id > 0)
+    gimp_image_delete (image_id);
+
+  /* Close file if Open */
+  if (! (f == NULL))
+    fclose (f);
+
+  return -1;
 }
 
 
 /* Local functions */
 
 static gint
-read_header_block (PSDimage *img_a,
-                   FILE     *f)
+read_header_block (PSDimage  *img_a,
+                   FILE      *f,
+                   GError   **error)
 {
   guint16  version;
   gchar    sig[4];
@@ -249,7 +241,7 @@
       || fread (&img_a->bps, 2, 1, f) < 1
       || fread (&img_a->color_mode, 2, 1, f) < 1)
     {
-      g_message (_("Error reading file header"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   version = GUINT16_FROM_BE (version);
@@ -267,37 +259,43 @@
 
   if (memcmp (sig, "8BPS", 4) != 0)
     {
-      g_message (_("Incorrect file signature"));
+      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                  _("Not a valid photoshop document file"));
       return -1;
     }
 
   if (version != 1)
     {
-      g_message (_("Unsupported PSD file format version %d"), version);
+      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                  _("Unsupported file format version: %d"), version);
       return -1;
     }
 
   if (img_a->channels > MAX_CHANNELS)
     {
-      g_message (_("Too many channels in file (%d)"), img_a->channels);
+      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                  _("Too many channels in file: %d"), img_a->channels);
       return -1;
     }
 
-  if (img_a->rows == 0 || img_a->columns == 0)
-    {
-      g_message (_("Unsupported PSD file version (< 2.5)")); /* FIXME - image size */
-                                                             /* in resource block 1000 */
-      return -1;                                             /* don't have PS2 file spec */
-    }
-
     /* Photoshop CS (version 8) supports 300000 x 300000, but this
        is currently larger than GIMP_MAX_IMAGE_SIZE */
 
-    if ((img_a->rows > GIMP_MAX_IMAGE_SIZE) ||
-        (img_a->columns > GIMP_MAX_IMAGE_SIZE))
-      {
-        g_message (_("Image size too large for GIMP."));
-      }
+  if (img_a->rows < 1 || img_a->rows > GIMP_MAX_IMAGE_SIZE)
+    {
+      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                  _("Unsupported or invalid image height: %d"),
+                  img_a->rows);
+      return -1;
+    }
+
+  if (img_a->columns < 1 || img_a->columns > GIMP_MAX_IMAGE_SIZE)
+    {
+      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                  _("Unsupported or invalid image width: %d"),
+                  img_a->columns);
+      return -1;
+    }
 
   if (img_a->color_mode != PSD_BITMAP
       && img_a->color_mode != PSD_GRAYSCALE
@@ -305,8 +303,9 @@
       && img_a->color_mode != PSD_RGB
       && img_a->color_mode != PSD_DUOTONE)
     {
-      g_message (_("PSD color mode %d is not supported"),
-                   img_a->color_mode);
+      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                  _("Unsupported color mode: %s"),
+                  get_psd_color_mode_name (img_a->color_mode));
       return -1;
     }
 
@@ -316,10 +315,10 @@
       case 16:
         IFDBG(3) g_debug ("16 Bit Data");
         if (CONVERSION_WARNINGS)
-          g_message (_("Warning:\n"
-                        "The image you are loading has 16 bits per channel. GIMP "
-                        "can only handle 8 bit, so it will be converted for you. "
-                        "Information will be lost because of this conversion."));
+          g_message ("Warning:\n"
+                     "The image you are loading has 16 bits per channel. GIMP "
+                     "can only handle 8 bit, so it will be converted for you. "
+                     "Information will be lost because of this conversion.");
         break;
 
       case 8:
@@ -331,7 +330,8 @@
         break;
 
       default:
-        g_message (_("Unknown bit depth: %d."), img_a->bps);
+        g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                    _("Unsupported bit depth: %d"), img_a->bps);
         return -1;
         break;
     }
@@ -340,8 +340,9 @@
 }
 
 static gint
-read_color_mode_block (PSDimage *img_a,
-                       FILE     *f)
+read_color_mode_block (PSDimage  *img_a,
+                       FILE      *f,
+                       GError   **error)
 {
   static guchar cmap[] = {0, 0, 0, 255, 255, 255};
   guint32       block_len;
@@ -350,7 +351,7 @@
   img_a->color_map_len = 0;
   if (fread (&block_len, 4, 1, f) < 1)
     {
-      g_message (_("Error reading color block"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   block_len = GUINT32_FROM_BE (block_len);
@@ -362,7 +363,9 @@
       if (img_a->color_mode == PSD_INDEXED ||
           img_a->color_mode == PSD_DUOTONE )
         {
-          g_message (_("No color block for indexed or duotone image"));
+          IFDBG(1) g_debug ("No color block for indexed or duotone image");
+          g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                      _("The file is corrupt!"));
           return -1;
         }
     }
@@ -370,7 +373,9 @@
     {
       if (block_len != 768)
         {
-          g_message (_("Invalid color block size for indexed image"));
+          IFDBG(1) g_debug ("Invalid color block size for indexed image");
+          g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                      _("The file is corrupt!"));
           return -1;
         }
       else
@@ -379,7 +384,7 @@
           img_a->color_map = g_malloc (img_a->color_map_len);
           if (fread (img_a->color_map, block_len, 1, f) < 1)
             {
-              g_message (_("Error reading color block"));
+              psd_set_error (feof (f), errno, error);
               return -1;
             }
           else
@@ -391,13 +396,13 @@
     }
   else if (img_a->color_mode == PSD_DUOTONE)
     {
-       img_a->color_map_len = block_len;
-       img_a->color_map = g_malloc (img_a->color_map_len);
-       if (fread (img_a->color_map, block_len, 1, f) < 1)
-         {
-           g_message (_("Error reading color block"));
-           return -1;
-         }
+      img_a->color_map_len = block_len;
+      img_a->color_map = g_malloc (img_a->color_map_len);
+      if (fread (img_a->color_map, block_len, 1, f) < 1)
+        {
+          psd_set_error (feof (f), errno, error);
+          return -1;
+        }
     }
 
   /* Create color map for bitmap image */
@@ -414,15 +419,16 @@
 }
 
 static gint
-read_image_resource_block (PSDimage *img_a,
-                           FILE     *f)
+read_image_resource_block (PSDimage  *img_a,
+                           FILE      *f,
+                           GError   **error)
 {
   guint32 block_len;
   guint32 block_end;
 
   if (fread (&block_len, 4, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   img_a->image_res_len = GUINT32_FROM_BE (block_len);
@@ -434,7 +440,7 @@
 
   if (fseek (f, block_end, SEEK_SET) < 0)
     {
-      g_message (_("Error setting file position"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
@@ -442,21 +448,22 @@
 }
 
 static PSDlayer **
-read_layer_block (PSDimage *img_a,
-                  FILE     *f)
+read_layer_block (PSDimage  *img_a,
+                  FILE      *f,
+                  GError   **error)
 {
   PSDlayer **lyr_a;
-  guint32    block_len,
-             block_end,
-             block_rem;
-  gint32     read_len,
-             write_len;
-  gint       lidx,                  /* Layer index */
-             cidx;                  /* Channel index */
+  guint32    block_len;
+  guint32    block_end;
+  guint32    block_rem;
+  gint32     read_len;
+  gint32     write_len;
+  gint       lidx;                  /* Layer index */
+  gint       cidx;                  /* Channel index */
 
   if (fread (&block_len, 4, 1, f) < 1)
     {
-      g_message (_("Error reading layer and mask block"));
+      psd_set_error (feof (f), errno, error);
       img_a->num_layers = -1;
       return NULL;
     }
@@ -481,7 +488,7 @@
       if (fread (&block_len, 4, 1, f) < 1
           || fread (&img_a->num_layers, 2, 1, f) < 1)
         {
-          g_message (_("Error reading number of layers"));
+          psd_set_error (feof (f), errno, error);
           img_a->num_layers = -1;
           return NULL;
         }
@@ -516,7 +523,7 @@
                   || fread (&lyr_a[lidx]->right, 4, 1, f) < 1
                   || fread (&lyr_a[lidx]->num_channels, 2, 1, f) < 1)
                 {
-                  g_message (_("Error reading layer record (i)"));
+                  psd_set_error (feof (f), errno, error);
                   return NULL;
                 }
               lyr_a[lidx]->top = GUINT32_FROM_BE (lyr_a[lidx]->top);
@@ -527,18 +534,26 @@
 
               if (lyr_a[lidx]->num_channels > MAX_CHANNELS)
                 {
-                  g_message (_("Too many channels in layer (%d)"),
+                  g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                              _("Too many channels in layer: %d"),
                               lyr_a[lidx]->num_channels);
                   return NULL;
                 }
-              if ((lyr_a[lidx]->right - lyr_a[lidx]->left > GIMP_MAX_IMAGE_SIZE) ||
-                  (lyr_a[lidx]->bottom - lyr_a[lidx]->top > GIMP_MAX_IMAGE_SIZE))
+              if (lyr_a[lidx]->bottom - lyr_a[lidx]->top > GIMP_MAX_IMAGE_SIZE)
                 {
-                  g_message (_("Layer size too large for GIMP."));
+                  g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                              _("Unsupported or invalid layer height: %d"),
+                              lyr_a[lidx]->bottom - lyr_a[lidx]->top);
+                  return NULL;
+                }
+              if (lyr_a[lidx]->right - lyr_a[lidx]->left > GIMP_MAX_IMAGE_SIZE)
+                {
+                  g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                              _("Unsupported or invalid layer width: %d"),
+                              lyr_a[lidx]->right - lyr_a[lidx]->left);
                   return NULL;
                 }
 
-              IFDBG(2) g_debug (" ");
               IFDBG(2) g_debug ("Layer %d, Coords %d %d %d %d, channels %d, ",
                                  lidx, lyr_a[lidx]->left, lyr_a[lidx]->top,
                                  lyr_a[lidx]->right, lyr_a[lidx]->bottom,
@@ -550,7 +565,7 @@
                   if (fread (&lyr_a[lidx]->chn_info[cidx].channel_id, 2, 1, f) < 1
                       || fread (&lyr_a[lidx]->chn_info[cidx].data_len, 4, 1, f) < 1)
                     {
-                      g_message (_("Error reading layer - channel record"));
+                      psd_set_error (feof (f), errno, error);
                       return NULL;
                     }
                   lyr_a[lidx]->chn_info[cidx].channel_id =
@@ -558,7 +573,7 @@
                   lyr_a[lidx]->chn_info[cidx].data_len =
                     GUINT32_FROM_BE (lyr_a[lidx]->chn_info[cidx].data_len);
                   img_a->layer_data_len += lyr_a[lidx]->chn_info[cidx].data_len;
-                  IFDBG(2) g_debug ("Channel ID %d, data len %d",
+                  IFDBG(3) g_debug ("Channel ID %d, data len %d",
                                      lyr_a[lidx]->chn_info[cidx].channel_id,
                                      lyr_a[lidx]->chn_info[cidx].data_len);
                 }
@@ -571,13 +586,15 @@
                   || fread (&lyr_a[lidx]->filler, 1, 1, f) < 1
                   || fread (&lyr_a[lidx]->extra_len, 4, 1, f) < 1)
                 {
-                  g_message (_("Error reading layer record (ii)"));
+                  psd_set_error (feof (f), errno, error);
                   return NULL;
                 }
               if (memcmp (lyr_a[lidx]->mode_key, "8BIM", 4) != 0)
                 {
-                  g_message (_("Incorrect layer mode signature %.4s"),
-                              lyr_a[lidx]->mode_key);
+                  IFDBG(1) g_debug ("Incorrect layer mode signature %.4s",
+                                    lyr_a[lidx]->mode_key);
+                  g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                              _("The file is corrupt!"));
                   return NULL;
                 }
 
@@ -606,7 +623,7 @@
               /* Layer mask data */
               if (fread (&block_len, 4, 1, f) < 1)
                 {
-                  g_message (_("Error reading layer mask data length"));
+                  psd_set_error (feof (f), errno, error);
                   return NULL;
                 }
               block_len = GUINT32_FROM_BE (block_len);
@@ -642,7 +659,7 @@
                         || fread (&lyr_a[lidx]->layer_mask.extra_def_color, 1, 1, f) < 1
                         || fread (&lyr_a[lidx]->layer_mask.extra_flags, 1, 1, f) < 1)
                       {
-                        g_message (_("Error reading layer mask record"));
+                        psd_set_error (feof (f), errno, error);
                         return NULL;
                       }
                     lyr_a[lidx]->layer_mask.top =
@@ -674,7 +691,7 @@
                         || fread (&lyr_a[lidx]->layer_mask.bottom, 4, 1, f) < 1
                         || fread (&lyr_a[lidx]->layer_mask.right, 4, 1, f) < 1)
                       {
-                        g_message (_("Error reading layer mask extra record"));
+                        psd_set_error (feof (f), errno, error);
                         return NULL;
                       }
                     lyr_a[lidx]->layer_mask_extra.top =
@@ -702,10 +719,10 @@
                     break;
 
                   default:
-                    g_message ("Unknown layer mask size ... skipping");
+                    IFDBG(1) g_debug ("Unknown layer mask record size ... skipping");
                     if (fseek (f, block_len, SEEK_CUR) < 0)
                       {
-                        g_message (_("Error setting file position"));
+                        psd_set_error (feof (f), errno, error);
                         return NULL;
                       }
                 }
@@ -717,14 +734,14 @@
                                 lyr_a[lidx]->layer_mask.bottom,
                                 lyr_a[lidx]->layer_mask.mask_flags.relative_pos);
 
-              IFDBG(2) g_debug ("Default mask color, %d, %d",
+              IFDBG(3) g_debug ("Default mask color, %d, %d",
                                 lyr_a[lidx]->layer_mask.def_color,
                                 lyr_a[lidx]->layer_mask.extra_def_color);
 
               /* Layer blending ranges */           /* FIXME  */
               if (fread (&block_len, 4, 1, f) < 1)
                 {
-                  g_message (_("Error reading layer blending ranges length"));
+                  psd_set_error (feof (f), errno, error);
                   return NULL;
                 }
               block_len = GUINT32_FROM_BE (block_len);
@@ -734,12 +751,15 @@
                 {
                   if (fseek (f, block_len, SEEK_CUR) < 0)
                     {
-                      g_message (_("Error setting file position"));
+                      psd_set_error (feof (f), errno, error);
                       return NULL;
                     }
                 }
 
-              lyr_a[lidx]->name = fread_pascal_string (&read_len, &write_len, 4, f);
+              lyr_a[lidx]->name = fread_pascal_string (&read_len, &write_len,
+                                                       4, f, error);
+              if (*error)
+                return NULL;
               block_rem -= read_len;
               IFDBG(3) g_debug ("Remaining length %d", block_rem);
 
@@ -747,17 +767,19 @@
 
               while (block_rem > 7)
                 {
-                  if (get_layer_resource_header (&res_a, f) < 0)
+                  if (get_layer_resource_header (&res_a, f, error) < 0)
                     return NULL;
                   block_rem -= 12;
 
                   if (res_a.data_len > block_rem)
                     {
-                      g_message ("Unexpected end of layer resource data");
+                      IFDBG(1) g_debug ("Unexpected end of layer resource data");
+                      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                                  _("The file is corrupt!"));
                       return NULL;
                     }
 
-                  if (load_layer_resource (&res_a, lyr_a[lidx], f) < 0)
+                  if (load_layer_resource (&res_a, lyr_a[lidx], f, error) < 0)
                     return NULL;
                   block_rem -= res_a.data_len;
                 }
@@ -765,7 +787,7 @@
                 {
                   if (fseek (f, block_rem, SEEK_CUR) < 0)
                     {
-                      g_message (_("Error setting file position"));
+                      psd_set_error (feof (f), errno, error);
                       return NULL;
                     }
                 }
@@ -774,7 +796,7 @@
           img_a->layer_data_start = ftell(f);
           if (fseek (f, img_a->layer_data_len, SEEK_CUR) < 0)
             {
-              g_message (_("Error setting file position"));
+              psd_set_error (feof (f), errno, error);
               return NULL;
             }
 
@@ -789,7 +811,7 @@
       /* Skip to end of block */
       if (fseek (f, block_end, SEEK_SET) < 0)
         {
-          g_message (_("Error setting file position"));
+          psd_set_error (feof (f), errno, error);
           return NULL;
         }
     }
@@ -798,11 +820,17 @@
 }
 
 static gint
-read_merged_image_block (PSDimage *img_a,
-                         FILE     *f)
+read_merged_image_block (PSDimage  *img_a,
+                         FILE      *f,
+                         GError   **error)
 {
   img_a->merged_image_start = ftell(f);
-  fseek (f, 0, SEEK_END);
+  if (fseek (f, 0, SEEK_END) < 0)
+    {
+      psd_set_error (feof (f), errno, error);
+      return -1;
+    }
+
   img_a->merged_image_len = ftell(f) - img_a->merged_image_start;
 
   IFDBG(1) g_debug ("Merged image data block: Start: %d, len: %d",
@@ -834,22 +862,19 @@
         break;
 
       default:
-        g_message (_("PSD color mode %d not supported"), img_a->color_mode);
+        /* Color mode already validated - should not be here */
+        g_warning ("Invalid color mode");
         return -1;
         break;
     }
 
   /* Create gimp image */
   IFDBG(2) g_debug ("Create image");
-  if ((image_id = gimp_image_new (img_a->columns, img_a->rows,
-                                  img_a->base_type)) == -1)
-    {
-      g_message (_("Could not create a new image"));
-      return -1;
-    }
+  image_id = gimp_image_new (img_a->columns, img_a->rows, img_a->base_type);
 
-  gimp_image_undo_disable (image_id);
   gimp_image_set_filename (image_id, filename);
+  gimp_image_undo_disable (image_id);
+
   return image_id;
 }
 
@@ -881,13 +906,14 @@
 static gint
 add_image_resources (const gint32  image_id,
                      PSDimage     *img_a,
-                     FILE         *f)
+                     FILE         *f,
+                     GError      **error)
 {
   PSDimageres  res_a;
 
   if (fseek (f, img_a->image_res_start, SEEK_SET) < 0)
     {
-      g_message (_("Error setting file position"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
@@ -903,17 +929,17 @@
 
   while (ftell (f) < img_a->image_res_start + img_a->image_res_len)
     {
-      if (get_image_resource_header (&res_a, f) < 0)
+      if (get_image_resource_header (&res_a, f, error) < 0)
         return -1;
 
       if (res_a.data_start + res_a.data_len >
           img_a->image_res_start + img_a->image_res_len)
         {
-          g_message ("Unexpected end of image resource data");
+          IFDBG(1) g_debug ("Unexpected end of image resource data");
           return 0;
         }
 
-      if (load_image_resource (&res_a, image_id, img_a,  f) < 0)
+      if (load_image_resource (&res_a, image_id, img_a, f, error) < 0)
         return -1;
     }
 
@@ -924,36 +950,37 @@
 add_layers (const gint32  image_id,
             PSDimage     *img_a,
             PSDlayer    **lyr_a,
-            FILE         *f)
+            FILE         *f,
+            GError      **error)
 {
   PSDchannel          **lyr_chn;
   guchar               *pixels;
-  guint16               comp_mode,
-                        alpha_chn,
-                        user_mask_chn,
-                        layer_channels,
-                        channel_idx[MAX_CHANNELS],
-                       *rle_pack_len;
-  gint32                l_x,                   /* Layer x */
-                        l_y,                   /* Layer y */
-                        l_w,                   /* Layer width */
-                        l_h,                   /* Layer height */
-                        lm_x,                  /* Layer mask x */
-                        lm_y,                  /* Layer mask y */
-                        lm_w,                  /* Layer mask width */
-                        lm_h,                  /* Layer mask height */
-                        layer_size,
-                        layer_id = -1,
-                        mask_id = -1;
-  gint                  lidx,                  /* Layer index */
-                        cidx,                  /* Channel index */
-                        rowi,                  /* Row index */
-                        coli,                  /* Column index */
-                        i;
-  gboolean              alpha,
-                        user_mask,
-                        empty,
-                        empty_mask;
+  guint16               comp_mode;
+  guint16               alpha_chn;
+  guint16               user_mask_chn;
+  guint16               layer_channels;
+  guint16               channel_idx[MAX_CHANNELS];
+  guint16              *rle_pack_len;
+  gint32                l_x;                   /* Layer x */
+  gint32                l_y;                   /* Layer y */
+  gint32                l_w;                   /* Layer width */
+  gint32                l_h;                   /* Layer height */
+  gint32                lm_x;                  /* Layer mask x */
+  gint32                lm_y;                  /* Layer mask y */
+  gint32                lm_w;                  /* Layer mask width */
+  gint32                lm_h;                  /* Layer mask height */
+  gint32                layer_size;
+  gint32                layer_id = -1;
+  gint32                mask_id = -1;
+  gint                  lidx;                  /* Layer index */
+  gint                  cidx;                  /* Channel index */
+  gint                  rowi;                  /* Row index */
+  gint                  coli;                  /* Column index */
+  gint                  i;
+  gboolean              alpha;
+  gboolean              user_mask;
+  gboolean              empty;
+  gboolean              empty_mask;
   GimpDrawable         *drawable;
   GimpPixelRgn          pixel_rgn;
   GimpImageType         image_type;
@@ -971,7 +998,7 @@
   /* Layered image - Photoshop 3 style */
   if (fseek (f, img_a->layer_data_start, SEEK_SET) < 0)
     {
-      g_message (_("Error setting file position"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
@@ -985,8 +1012,13 @@
 
           /* Step past layer data */
           for (cidx = 0; cidx < lyr_a[lidx]->num_channels; ++cidx)
-              fseek (f, lyr_a[lidx]->chn_info[cidx].data_len, SEEK_CUR);
-
+            {
+              if (fseek (f, lyr_a[lidx]->chn_info[cidx].data_len, SEEK_CUR) < 0)
+                {
+                  psd_set_error (feof (f), errno, error);
+                  return -1;
+                }
+            }
           g_free (lyr_a[lidx]->chn_info);
           g_free (lyr_a[lidx]->name);
         }
@@ -1007,7 +1039,7 @@
           else
               empty_mask = FALSE;
 
-          IFDBG(2) g_debug ("Empty mask %d, size %d %d", empty_mask,
+          IFDBG(3) g_debug ("Empty mask %d, size %d %d", empty_mask,
                             lyr_a[lidx]->layer_mask.bottom - lyr_a[lidx]->layer_mask.top,
                             lyr_a[lidx]->layer_mask.right - lyr_a[lidx]->layer_mask.left);
 
@@ -1049,36 +1081,33 @@
                                            lyr_a[lidx]->layer_mask.left);
                 }
 
-              IFDBG(2) g_debug ("Channel id %d, %dx%d",
+              IFDBG(3) g_debug ("Channel id %d, %dx%d",
                                 lyr_chn[cidx]->id,
                                 lyr_chn[cidx]->columns,
                                 lyr_chn[cidx]->rows);
 
               if (fread (&comp_mode, 2, 1, f) < 1)
                 {
-                  g_message (_("Error reading layer compression mode"));
+                  psd_set_error (feof (f), errno, error);
                   return -1;
                 }
               comp_mode = GUINT16_FROM_BE (comp_mode);
-              IFDBG(2) g_debug ("Compression mode: %d", comp_mode);
+              IFDBG(3) g_debug ("Compression mode: %d", comp_mode);
 
               if (lyr_a[lidx]->chn_info[cidx].data_len - 2 > 0)
                 {
                   switch (comp_mode)
                     {
                       case PSD_COMP_RAW:        /* Planar raw data */
-                        IFDBG(2) g_debug ("Raw data length: %d",
+                        IFDBG(3) g_debug ("Raw data length: %d",
                                           lyr_a[lidx]->chn_info[cidx].data_len - 2);
-                        if (read_channel_data (lyr_chn[cidx],
-                            img_a->bps, PSD_COMP_RAW, NULL, f) < 1)
-                          {
-                            g_message (_("Error reading raw channel"));
-                            return -1;
-                          }
+                        if (read_channel_data (lyr_chn[cidx], img_a->bps,
+                            PSD_COMP_RAW, NULL, f, error) < 1)
+                          return -1;
                         break;
 
                       case PSD_COMP_RLE:        /* Packbits */
-                        IFDBG(2) g_debug ("RLE channel length %d, RLE length data: %d, "
+                        IFDBG(3) g_debug ("RLE channel length %d, RLE length data: %d, "
                                           "RLE data block: %d",
                                           lyr_a[lidx]->chn_info[cidx].data_len - 2,
                                           lyr_chn[cidx]->rows * 2,
@@ -1089,28 +1118,24 @@
                           {
                             if (fread (&rle_pack_len[rowi], 2, 1, f) < 1)
                               {
-                                g_message (_("Error reading packbits length"));
+                                psd_set_error (feof (f), errno, error);
                                 return -1;
                               }
                                 rle_pack_len[rowi] = GUINT16_FROM_BE (rle_pack_len[rowi]);
-                                IFDBG(3) g_debug ("Row %d, Packed length %d",
-                                                  rowi, rle_pack_len[rowi]);
                           }
 
                         IFDBG(3) g_debug ("RLE decode - data");
                         if (read_channel_data (lyr_chn[cidx], img_a->bps,
-                            PSD_COMP_RLE, rle_pack_len, f) < 1)
-                          {
-                            g_message (_("Error reading packbits channel"));
-                            return -1;
-                          }
+                            PSD_COMP_RLE, rle_pack_len, f, error) < 1)
+                          return -1;
 
                         g_free (rle_pack_len);
                         break;
 
                       case PSD_COMP_ZIP:                 /* ? */
                       case PSD_COMP_ZIP_PRED:
-                        g_message (_("Compression mode not supported %d"), comp_mode);
+                        g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                                    _("Unsupported compression mode: %d"), comp_mode);
                         return -1;
                         break;
                     }
@@ -1130,7 +1155,7 @@
           l_w = img_a->columns;
           l_h = img_a->rows;
 
-          IFDBG(2) g_debug ("Re-hash channel indices");
+          IFDBG(3) g_debug ("Re-hash channel indices");
           for (cidx = 0; cidx < lyr_a[lidx]->num_channels; ++cidx)
             {
               if (lyr_chn[cidx]->id == PSD_CHANNEL_MASK)
@@ -1181,32 +1206,24 @@
               l_w = lyr_a[lidx]->right - lyr_a[lidx]->left;
               l_h = lyr_a[lidx]->bottom - lyr_a[lidx]->top;
 
-              IFDBG(2) g_debug ("Draw layer");
+              IFDBG(3) g_debug ("Draw layer");
               image_type = get_gimp_image_type (img_a->base_type, alpha);
-              IFDBG(2) g_debug ("Layer type %d", image_type);
+              IFDBG(3) g_debug ("Layer type %d", image_type);
               layer_size = l_w * l_h;
               pixels = g_malloc (layer_size * layer_channels);
-              IFDBG(2) g_debug ("Allocate Pixels %d x %d", layer_size, layer_channels);
               for (cidx = 0; cidx < layer_channels; ++cidx)
                 {
-                  IFDBG(2) g_debug ("Start channel %d", channel_idx[cidx]);
+                  IFDBG(3) g_debug ("Start channel %d", channel_idx[cidx]);
                   for (i = 0; i < layer_size; ++i)
-                    {
-                      pixels[(i * layer_channels) + cidx] = lyr_chn[channel_idx[cidx]]->data[i];
-                      IFDBG(3) g_debug ("Pixels, %d, %d", (i * layer_channels) + cidx,
-                                         pixels[(i * layer_channels) + cidx]);
-                    }
-                  IFDBG(2) g_debug ("Done channel %d, id %d", cidx,
-                                     lyr_chn[channel_idx[cidx]]->id);
+                    pixels[(i * layer_channels) + cidx] = lyr_chn[channel_idx[cidx]]->data[i];
                   g_free (lyr_chn[channel_idx[cidx]]->data);
-                  IFDBG(2) g_debug ("Free channel %d", channel_idx[cidx]);
                 }
 
               layer_mode = psd_to_gimp_blend_mode (lyr_a[lidx]->blend_mode);
               layer_id = gimp_layer_new (image_id, lyr_a[lidx]->name, l_w, l_h,
                                          image_type, lyr_a[lidx]->opacity * 100 / 255,
                                          layer_mode);
-              IFDBG(2) g_debug ("New layer %d", layer_id);
+              IFDBG(3) g_debug ("Layer tattoo: %d", layer_id);
               g_free (lyr_a[lidx]->name);
               gimp_image_add_layer (image_id, layer_id, -1);
               gimp_layer_set_offsets (layer_id, l_x, l_y);
@@ -1229,7 +1246,7 @@
             {
               if (empty_mask)
                 {
-                  IFDBG(2) g_debug ("Create empty mask");
+                  IFDBG(3) g_debug ("Create empty mask");
                   if (lyr_a[lidx]->layer_mask.def_color == 255)
                     mask_id = gimp_layer_create_mask (layer_id, GIMP_ADD_WHITE_MASK);
                   else
@@ -1255,23 +1272,23 @@
                       lm_w = lyr_a[lidx]->layer_mask.right - lyr_a[lidx]->layer_mask.left;
                       lm_h = lyr_a[lidx]->layer_mask.bottom - lyr_a[lidx]->layer_mask.top;
                     }
-                  IFDBG(2) g_debug ("Mask channel index %d", user_mask_chn);
-                  IFDBG(2) g_debug ("Relative pos %d",
+                  IFDBG(3) g_debug ("Mask channel index %d", user_mask_chn);
+                  IFDBG(3) g_debug ("Relative pos %d",
                                     lyr_a[lidx]->layer_mask.mask_flags.relative_pos);
                   layer_size = lm_w * lm_h;
                   pixels = g_malloc (layer_size);
-                  IFDBG(2) g_debug ("Allocate Pixels %d", layer_size);
+                  IFDBG(3) g_debug ("Allocate Pixels %d", layer_size);
                   /* Crop mask at layer boundry */
-                  IFDBG(2) g_debug ("Original Mask %d %d %d %d", lm_x, lm_y, lm_w, lm_h);
+                  IFDBG(3) g_debug ("Original Mask %d %d %d %d", lm_x, lm_y, lm_w, lm_h);
                   if (lm_x < 0
                       || lm_y < 0
                       || lm_w + lm_x > l_w
                       || lm_h + lm_y > l_h)
                     {
                       if (CONVERSION_WARNINGS)
-                        g_message (_("Warning\n"
-                                     "Layer mask partly lies outside layer boundry. The mask will be "
-                                     "cropped which may result in data loss."));
+                        g_message ("Warning\n"
+                                   "Layer mask partly lies outside layer boundry. The mask will be "
+                                   "cropped which may result in data loss.");
                       i = 0;
                       for (rowi = 0; rowi < lm_h; ++rowi)
                         {
@@ -1281,7 +1298,6 @@
                                 {
                                   if (coli + lm_x >= 0 && coli + lm_x < l_w)
                                     {
-                                      IFDBG(3) g_debug ("Row %d, col %d", rowi, coli);
                                       pixels[i] =
                                         lyr_chn[user_mask_chn]->data[(rowi * lm_w) + coli];
                                       i++;
@@ -1308,8 +1324,8 @@
                     memcpy (pixels, lyr_chn[user_mask_chn]->data, layer_size);
                   g_free (lyr_chn[user_mask_chn]->data);
                   /* Draw layer mask data */
-                  IFDBG(2) g_debug ("Layer %d %d %d %d", l_x, l_y, l_w, l_h);
-                  IFDBG(2) g_debug ("Mask %d %d %d %d", lm_x, lm_y, lm_w, lm_h);
+                  IFDBG(3) g_debug ("Layer %d %d %d %d", l_x, l_y, l_w, l_h);
+                  IFDBG(3) g_debug ("Mask %d %d %d %d", lm_x, lm_y, lm_w, lm_h);
 
                   if (lyr_a[lidx]->layer_mask.def_color == 255)
                     mask_id = gimp_layer_create_mask (layer_id, GIMP_ADD_WHITE_MASK);
@@ -1344,31 +1360,32 @@
 static gint
 add_merged_image (const gint32  image_id,
                   PSDimage     *img_a,
-                  FILE         *f)
+                  FILE         *f,
+                  GError      **error)
 {
   PSDchannel            chn_a[MAX_CHANNELS];
   gchar                *alpha_name;
   guchar               *pixels;
-  guint16               comp_mode,
-                        base_channels,
-                        extra_channels,
-                        total_channels,
-                       *rle_pack_len[MAX_CHANNELS];
-  guint32               block_len,
-                        block_start,
-                        block_end,
-                        alpha_id;
-  gint32                layer_size,
-                        layer_id = -1,
-                        channel_id = -1,
-                        active_layer;
+  guint16               comp_mode;
+  guint16               base_channels;
+  guint16               extra_channels;
+  guint16               total_channels;
+  guint16              *rle_pack_len[MAX_CHANNELS];
+  guint32               block_len;
+  guint32               block_start;
+  guint32               block_end;
+  guint32               alpha_id;
+  gint32                layer_size;
+  gint32                layer_id = -1;
+  gint32                channel_id = -1;
+  gint32                active_layer;
   gint16                alpha_opacity;
-  gint                 *lyr_lst,
-                        cidx,                  /* Channel index */
-                        rowi,                  /* Row index */
-                        lyr_count,
-                        offset,
-                        i;
+  gint                 *lyr_lst;
+  gint                  cidx;                  /* Channel index */
+  gint                  rowi;                  /* Row index */
+  gint                  lyr_count;
+  gint                  offset;
+  gint                  i;
   gboolean              alpha_visible;
   GimpDrawable         *drawable;
   GimpPixelRgn          pixel_rgn;
@@ -1412,7 +1429,7 @@
 
       if (fread (&comp_mode, 2, 1, f) < 1)
         {
-          g_message (_("Error reading layer compression mode"));
+          psd_set_error (feof (f), errno, error);
           return -1;
         }
       comp_mode = GUINT16_FROM_BE (comp_mode);
@@ -1420,23 +1437,21 @@
       switch (comp_mode)
         {
           case PSD_COMP_RAW:        /* Planar raw data */
-            IFDBG(2) g_debug ("Raw data length: %d", block_len);
+            IFDBG(3) g_debug ("Raw data length: %d", block_len);
             for (cidx = 0; cidx < total_channels; ++cidx)
               {
                 chn_a[cidx].columns = img_a->columns;
                 chn_a[cidx].rows = img_a->rows;
-                if (read_channel_data (&chn_a[cidx], img_a->bps, PSD_COMP_RAW, NULL, f) < 1)
-                  {
-                    g_message (_("Error reading raw channel"));
-                    return -1;
-                  }
+                if (read_channel_data (&chn_a[cidx], img_a->bps,
+                    PSD_COMP_RAW, NULL, f, error) < 1)
+                  return -1;
               }
             break;
 
           case PSD_COMP_RLE:        /* Packbits */
             /* Image data is stored as packed scanlines in planar order
                with all compressed length counters stored first */
-            IFDBG(2) g_debug ("RLE length data: %d, RLE data block: %d",
+            IFDBG(3) g_debug ("RLE length data: %d, RLE data block: %d",
                                total_channels * img_a->rows * 2,
                                block_len - (total_channels * img_a->rows * 2));
             for (cidx = 0; cidx < total_channels; ++cidx)
@@ -1448,29 +1463,27 @@
                   {
                     if (fread (&rle_pack_len[cidx][rowi], 2, 1, f) < 1)
                       {
-                        g_message (_("Error reading packbits length"));
+                        psd_set_error (feof (f), errno, error);
                         return -1;
                       }
                     rle_pack_len[cidx][rowi] = GUINT16_FROM_BE (rle_pack_len[cidx][rowi]);
                   }
               }
 
-            IFDBG(2) g_debug ("RLE decode - data");
+            IFDBG(3) g_debug ("RLE decode - data");
             for (cidx = 0; cidx < total_channels; ++cidx)
               {
                 if (read_channel_data (&chn_a[cidx], img_a->bps,
-                    PSD_COMP_RLE, rle_pack_len[cidx], f) < 1)
-                    {
-                      g_message (_("Error reading packbits channel"));
-                      return -1;
-                    }
+                    PSD_COMP_RLE, rle_pack_len[cidx], f, error) < 1)
+                  return -1;
                 g_free (rle_pack_len[cidx]);
               }
             break;
 
           case PSD_COMP_ZIP:                 /* ? */
           case PSD_COMP_ZIP_PRED:
-            g_message (_("Compression mode not supported %d"), comp_mode);
+            g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                        _("Unsupported compression mode: %d"), comp_mode);
             return -1;
             break;
         }
@@ -1488,8 +1501,6 @@
           for (i = 0; i < layer_size; ++i)
             {
               pixels[(i * base_channels) + cidx] = chn_a[cidx].data[i];
-              IFDBG(3) g_debug ("Pixels, %d, %d",
-                (i * base_channels) + cidx, pixels[(i * base_channels) + cidx]);
             }
           g_free (chn_a[cidx].data);
         }
@@ -1511,13 +1522,16 @@
       g_free (pixels);
     }
   else
-    /* Free merged image data for layered image */
-    if (extra_channels)
-      for (cidx = 0; cidx < base_channels; ++cidx)
-        g_free (chn_a[cidx].data);
+    {
+      /* Free merged image data for layered image */
+      if (extra_channels)
+        for (cidx = 0; cidx < base_channels; ++cidx)
+          g_free (chn_a[cidx].data);
+    }
 
   /* ----- Draw extra alpha channels ----- */
-  if (extra_channels                    /* Extra alpha channels */
+  if ((extra_channels                   /* Extra alpha channels */
+      || img_a->transparency)           /* Transparency alpha channel */
       && image_id > -1)
     {
       IFDBG(2) g_debug ("Add extra channels");
@@ -1525,11 +1539,18 @@
 
       /* Get channel resource data */
       if (img_a->transparency)
-        offset = 1;
+        {
+          offset = 1;
+          /* Free "Transparency" channel name */
+          alpha_name = g_ptr_array_index (img_a->alpha_names, 0);
+          if (alpha_name)
+            g_free (alpha_name);
+        }
       else
         offset = 0;
 
       /* Draw channels */
+      IFDBG(2) g_debug ("Number of channels: %d", extra_channels);
       for (i = 0; i < extra_channels; ++i)
         {
           /* Alpha channel name */
@@ -1539,6 +1560,10 @@
           if (img_a->quick_mask_id)
             if (i == img_a->quick_mask_id - base_channels + offset)
               {
+                /* Free "Quick Mask" channel name */
+                alpha_name = g_ptr_array_index (img_a->alpha_names, i + offset);
+                if (alpha_name)
+                  g_free (alpha_name);
                 alpha_name = g_strdup (GIMP_IMAGE_QUICK_MASK_NAME);
                 alpha_visible = TRUE;
               }
@@ -1562,7 +1587,7 @@
             }
           else
             {
-              gimp_rgb_set (&alpha_rgb, 1.0, 0.0, 0.0);
+              gimp_rgba_set (&alpha_rgb, 1.0, 0.0, 0.0, 1.0);
               alpha_opacity = 50;
             }
 
@@ -1573,6 +1598,7 @@
                                          chn_a[cidx].columns, chn_a[cidx].rows,
                                          alpha_opacity, &alpha_rgb);
           gimp_image_add_channel (image_id, channel_id, 0);
+          g_free (alpha_name);
           drawable = gimp_drawable_get (channel_id);
           if (alpha_id)
             gimp_drawable_set_tattoo (drawable->drawable_id, alpha_id);
@@ -1619,6 +1645,33 @@
 
 
 /* Local utility functions */
+static gchar *
+get_psd_color_mode_name (PSDColorMode mode)
+{
+  static gchar *psd_color_mode_names[] =
+  {
+    "BITMAP",
+    "GRAYSCALE",
+    "INDEXED",
+    "RGB",
+    "CMYK",
+    "UNKNOWN (5)",
+    "UNKNOWN (6)",
+    "MULTICHANNEL",
+    "DUOTONE",
+    "LAB"
+  };
+
+  static gchar *err_name = NULL;
+  if (mode >= PSD_BITMAP && mode <= PSD_LAB)
+    {
+      return psd_color_mode_names[mode];
+    }
+  g_free (err_name);
+
+  err_name = g_strdup_printf ("UNKNOWN (%d)", mode);
+  return err_name;
+}
 
 static void
 psd_to_gimp_color_map (guchar *map256)
@@ -1668,11 +1721,12 @@
 }
 
 static gint
-read_channel_data (PSDchannel    *channel,
-                   const guint16  bps,
-                   const guint16  compression,
-                   const guint16 *rle_pack_len,
-                   FILE          *f)
+read_channel_data (PSDchannel     *channel,
+                   const guint16   bps,
+                   const guint16   compression,
+                   const guint16  *rle_pack_len,
+                   FILE           *f,
+                   GError        **error)
 {
   gchar    *raw_data;
   gchar    *src;
@@ -1686,13 +1740,16 @@
     readline_len = (channel->columns * bps >> 3);
 
   IFDBG(3) g_debug ("raw data size %d x %d = %d", readline_len,
-   channel->rows, readline_len * channel->rows);
+                    channel->rows, readline_len * channel->rows);
   raw_data = g_malloc (readline_len * channel->rows);
   switch (compression)
     {
       case PSD_COMP_RAW:
         if (fread (raw_data, readline_len, channel->rows, f) < 1)
+          {
+            psd_set_error (feof (f), errno, error);
             return -1;
+          }
         break;
 
       case PSD_COMP_RLE:
@@ -1703,14 +1760,13 @@
 /*      FIXME check for over-run
             if (ftell (f) + rle_pack_len[i] > block_end)
               {
-                g_message (_("Unexpected end of file"));
+                psd_set_error (TRUE, errno, error);
                 return -1;
               }
 */
-            IFDBG(3) g_debug ("pack len %d", rle_pack_len[i]);
             if (fread (src, rle_pack_len[i], 1, f) < 1)
               {
-                g_message (_("Error reading packbits data"));
+                psd_set_error (feof (f), errno, error);
                 return -1;
               }
             /* FIXME check for errors returned from decode packbits */
@@ -1753,7 +1809,7 @@
 {
 /* Convert 16 bit to 8 bit dropping low byte
 */
-  int i;
+  gint      i;
 
   IFDBG(3)  g_debug ("Start 16 bit conversion");
 

Modified: branches/weskaggs/plug-ins/psd/psd-thumb-load.c
==============================================================================
--- branches/weskaggs/plug-ins/psd/psd-thumb-load.c	(original)
+++ branches/weskaggs/plug-ins/psd/psd-thumb-load.c	Thu Jan 10 03:08:46 2008
@@ -19,7 +19,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-
 #include "config.h"
 
 #include <string.h>
@@ -29,28 +28,32 @@
 #include <libgimp/gimp.h>
 
 #include "psd.h"
+#include "psd-util.h"
 #include "psd-image-res-load.h"
 #include "psd-thumb-load.h"
 
 #include "libgimp/stdplugins-intl.h"
 
-
 /*  Local function prototypes  */
-static gint     read_header_block         (PSDimage     *img_a,
-                                           FILE         *f);
-
-static gint     read_color_mode_block     (PSDimage     *img_a,
-                                           FILE         *f);
-
-static gint     read_image_resource_block (PSDimage     *img_a,
-                                           FILE         *f);
-
-static gint32   create_gimp_image         (PSDimage     *img_a,
-                                           const gchar  *filename);
-
-static gint     add_image_resources       (const gint32  image_id,
-                                           PSDimage     *img_a,
-                                           FILE         *f);
+static gint             read_header_block          (PSDimage     *img_a,
+                                                    FILE         *f,
+                                                    GError      **error);
+
+static gint             read_color_mode_block      (PSDimage     *img_a,
+                                                    FILE         *f,
+                                                    GError      **error);
+
+static gint             read_image_resource_block  (PSDimage     *img_a,
+                                                    FILE         *f,
+                                                    GError      **error);
+
+static gint32           create_gimp_image          (PSDimage     *img_a,
+                                                    const gchar  *filename);
+
+static gint             add_image_resources        (const gint32  image_id,
+                                                    PSDimage     *img_a,
+                                                    FILE         *f,
+                                                    GError      **error);
 
 /* Main file load function */
 gint32
@@ -58,11 +61,11 @@
                       gint        *width,
                       gint        *height)
 {
-  FILE        *f;
-  struct stat  st;
-  PSDimage     img_a;
-  gint32       image_id = -1;
-
+  FILE                 *f;
+  struct stat           st;
+  PSDimage              img_a;
+  gint32                image_id = -1;
+  GError               *error = NULL;
 
   /* ----- Open PSD file ----- */
   if (g_stat (filename, &st) == -1)
@@ -77,54 +80,37 @@
       return -1;
     }
 
-  gimp_progress_init_printf (_("Loading thumbnail for '%s'"),
+  gimp_progress_init_printf (_("Opening thumbnail for '%s'"),
                              gimp_filename_to_utf8 (filename));
 
-  IFDBG(2) g_debug ("Read header block");
   /* ----- Read the PSD file Header block ----- */
-  if (read_header_block (&img_a, f) < 0)
-    {
-      fclose(f);
-      return -1;
-    }
+  IFDBG(2) g_debug ("Read header block");
+  if (read_header_block (&img_a, f, &error) < 0)
+    goto load_error;
   gimp_progress_update (0.2);
 
-  IFDBG(2) g_debug ("Read colour mode block");
   /* ----- Read the PSD file Colour Mode block ----- */
-  if (read_color_mode_block (&img_a, f) < 0)
-    {
-      fclose(f);
-      return -1;
-    }
+  IFDBG(2) g_debug ("Read colour mode block");
+  if (read_color_mode_block (&img_a, f, &error) < 0)
+    goto load_error;
   gimp_progress_update (0.4);
 
-  IFDBG(2) g_debug ("Read image resource block");
   /* ----- Read the PSD file Image Resource block ----- */
-  if (read_image_resource_block (&img_a, f) < 0)
-    {
-      fclose(f);
-      return -1;
-    }
+  IFDBG(2) g_debug ("Read image resource block");
+  if (read_image_resource_block (&img_a, f, &error) < 0)
+    goto load_error;
   gimp_progress_update (0.6);
 
-  IFDBG(2) g_debug ("Create GIMP image");
   /* ----- Create GIMP image ----- */
+  IFDBG(2) g_debug ("Create GIMP image");
   image_id = create_gimp_image (&img_a, filename);
-  if (image_id == -1)
-    {
-      fclose(f);
-      return -1;
-    }
-  gimp_progress_update (0.8);
+  if (image_id < 0)
+    goto load_error;
 
-  IFDBG(2) g_debug ("Add image resources");
   /* ----- Add image resources ----- */
-  if (add_image_resources (image_id, &img_a, f) < 1)
-    {
-      gimp_image_delete (image_id);
-      fclose(f);
-      return -1;
-    }
+  IFDBG(2) g_debug ("Add image resources");
+  if (add_image_resources (image_id, &img_a, f, &error) < 1)
+    goto load_error;
   gimp_progress_update (1.0);
 
   gimp_image_clean_all (image_id);
@@ -134,14 +120,27 @@
   *width = img_a.columns;
   *height = img_a.rows;
   return image_id;
+
+  /* ----- Process load errors ----- */
+ load_error:
+  /* Delete partially loaded image */
+  if (image_id > 0)
+    gimp_image_delete (image_id);
+
+  /* Close file if Open */
+  if (! (f == NULL))
+    fclose (f);
+
+  return -1;
 }
 
 
 /* Local functions */
 
 static gint
-read_header_block (PSDimage *img_a,
-                   FILE     *f)
+read_header_block (PSDimage  *img_a,
+                   FILE      *f,
+                   GError   **error)
 {
   guint16  version;
   gchar    sig[4];
@@ -156,7 +155,7 @@
       || fread (&img_a->bps, 2, 1, f) < 1
       || fread (&img_a->color_mode, 2, 1, f) < 1)
     {
-      g_message (_("Error reading file header"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   version = GUINT16_FROM_BE (version);
@@ -173,36 +172,27 @@
                     img_a->bps, img_a->color_mode);
 
   if (memcmp (sig, "8BPS", 4) != 0)
-    {
-      g_message (_("Incorrect file signature"));
-      return -1;
-    }
+    return -1;
 
   if (version != 1)
-    {
-      g_message (_("Unsupported PSD file format version %d"), version);
-      return -1;
-    }
+    return -1;
 
   if (img_a->channels > MAX_CHANNELS)
-    {
-      g_message (_("Too many channels in file (%d)"), img_a->channels);
-      return -1;
-    }
+    return -1;
 
-  if (img_a->rows == 0 || img_a->columns == 0)
-    {
-      g_message (_("Unsupported PSD file version (< 2.5)")); /* FIXME - image size */
-                                                             /* in resource block 1000 */
-      return -1;                                             /* don't have PS2 file spec */
-    }
+  if (img_a->rows < 1 || img_a->rows > GIMP_MAX_IMAGE_SIZE)
+    return -1;
+
+  if (img_a->columns < 1 || img_a->columns > GIMP_MAX_IMAGE_SIZE)
+    return -1;
 
   return 0;
 }
 
 static gint
-read_color_mode_block (PSDimage *img_a,
-                       FILE     *f)
+read_color_mode_block (PSDimage  *img_a,
+                       FILE      *f,
+                       GError   **error)
 {
   guint32 block_len;
   guint32 block_start;
@@ -210,19 +200,17 @@
 
   if (fread (&block_len, 4, 1, f) < 1)
     {
-      g_message (_("Error reading color block"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   block_len = GUINT32_FROM_BE (block_len);
 
-  IFDBG(1) g_debug ("Color map block size = %d", block_len);
-
   block_start = ftell (f);
   block_end = block_start + block_len;
 
   if (fseek (f, block_end, SEEK_SET) < 0)
     {
-      g_message (_("Error setting file position"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
@@ -230,15 +218,16 @@
 }
 
 static gint
-read_image_resource_block (PSDimage *img_a,
-                           FILE     *f)
+read_image_resource_block (PSDimage  *img_a,
+                           FILE      *f,
+                           GError   **error)
 {
   guint32 block_len;
   guint32 block_end;
 
   if (fread (&block_len, 4, 1, f) < 1)
     {
-      g_message (_("Error reading image resource block"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
   img_a->image_res_len = GUINT32_FROM_BE (block_len);
@@ -250,7 +239,7 @@
 
   if (fseek (f, block_end, SEEK_SET) < 0)
     {
-      g_message (_("Error setting file position"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
@@ -267,44 +256,39 @@
 
   /* Create gimp image */
   IFDBG(2) g_debug ("Create image");
-  if ((image_id = gimp_image_new (img_a->columns, img_a->rows,
-                                  img_a->base_type)) == -1)
-    {
-      g_message (_("Could not create a new image"));
-      return -1;
-    }
+  image_id = gimp_image_new (img_a->columns, img_a->rows, img_a->base_type);
 
-  gimp_image_undo_disable (image_id);
   gimp_image_set_filename (image_id, filename);
+  gimp_image_undo_disable (image_id);
+
   return image_id;
 }
 
 static gint
-add_image_resources (const gint32  image_id,
-                     PSDimage     *img_a,
-                     FILE         *f)
+add_image_resources (const gint32   image_id,
+                     PSDimage      *img_a,
+                     FILE          *f,
+                     GError       **error)
 {
   PSDimageres   res_a;
   gint          status;
 
   if (fseek (f, img_a->image_res_start, SEEK_SET) < 0)
     {
-      g_message (_("Error setting file position"));
+      psd_set_error (feof (f), errno, error);
       return -1;
     }
 
   while (ftell (f) < img_a->image_res_start + img_a->image_res_len)
     {
-      if (get_image_resource_header (&res_a, f) < 0)
+      if (get_image_resource_header (&res_a, f, error) < 0)
         return -1;
 
       if (res_a.data_start + res_a.data_len >
           img_a->image_res_start + img_a->image_res_len)
-        {
-          g_message ("Unexpected end of image resource data");
-          return 0;
-        }
-      status = load_thumbnail_resource (&res_a, image_id, f);
+        return 0;
+
+      status = load_thumbnail_resource (&res_a, image_id, f, error);
       /* Error */
       if (status < 0)
         return -1;

Modified: branches/weskaggs/plug-ins/psd/psd-util.c
==============================================================================
--- branches/weskaggs/plug-ins/psd/psd-util.c	(original)
+++ branches/weskaggs/plug-ins/psd/psd-util.c	Thu Jan 10 03:08:46 2008
@@ -19,10 +19,10 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-
 #include "config.h"
 
 #include <string.h>
+#include <errno.h>
 
 #include <glib/gstdio.h>
 #include <libgimp/gimp.h>
@@ -36,19 +36,43 @@
 #define MIN_RUN     3
 
 /*  Local function prototypes  */
+static gchar *          gimp_layer_mode_effects_name    (const GimpLayerModeEffects      mode);
 
 
 /* Utility function */
+void
+psd_set_error (const gboolean   file_eof,
+               const gint       err_no,
+               GError         **error)
+{
+  /*
+   *  Set error
+   */
+  if (file_eof)
+    *error = g_error_new (G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                          _("Unexpected end of file"));
+  else
+    *error = g_error_new (G_FILE_ERROR,
+                          g_file_error_from_errno (err_no),
+                          "%s", g_strerror (err_no));
+
+  return;
+}
+
 gchar *
-fread_pascal_string (gint32        *bytes_read,
-                     gint32        *bytes_written,
-                     const guint16  pad_len,
-                     FILE          *f)
+fread_pascal_string (gint32         *bytes_read,
+                     gint32         *bytes_written,
+                     const guint16   mod_len,
+                     FILE           *f,
+                     GError        **error)
 {
-  /* Reads a pascal string padded to a multiple of pad_len and converts to utf-8 */
+  /*
+   * Reads a pascal string from the file padded to a multiple of mod_len
+   * and returns a utf-8 string.
+   */
 
-  gchar        *str,
-               *utf8_str;
+  gchar        *str;
+  gchar        *utf8_str;
   guchar        len;
   gint32        padded_len;
 
@@ -57,7 +81,7 @@
 
   if (fread (&len, 1, 1, f) < 1)
     {
-      g_message (_("Error reading pascal string length"));
+      psd_set_error (feof (f), errno, error);
       return NULL;
     }
   (*bytes_read)++;
@@ -65,12 +89,12 @@
 
   if (len == 0)
     {
-      if (fseek (f, pad_len - 1, SEEK_CUR) < 0)
+      if (fseek (f, mod_len - 1, SEEK_CUR) < 0)
         {
-          g_message (_("Error setting file position"));
+          psd_set_error (feof (f), errno, error);
           return NULL;
         }
-      *bytes_read += (pad_len - 1);
+      *bytes_read += (mod_len - 1);
       *bytes_written = 0;
       return NULL;
     }
@@ -78,19 +102,19 @@
   str = g_malloc (len);
   if (fread (str, len, 1, f) < 1)
     {
-      g_message (_("Error reading pascal string"));
+      psd_set_error (feof (f), errno, error);
       return NULL;
     }
   *bytes_read += len;
 
-  if (pad_len > 0)
+  if (mod_len > 0)
     {
       padded_len = len + 1;
-      while (padded_len % pad_len != 0)
+      while (padded_len % mod_len != 0)
         {
           if (fseek (f, 1, SEEK_CUR) < 0)
             {
-              g_message (_("Error setting file position"));
+              psd_set_error (feof (f), errno, error);
               return NULL;
             }
           (*bytes_read)++;
@@ -98,27 +122,30 @@
         }
     }
 
-  utf8_str = gimp_any_to_utf8 (str, len, _("Invalid UTF-8 string in PSD file"));
+  utf8_str = gimp_any_to_utf8 (str, len, NULL);
   *bytes_written = strlen (utf8_str);
   g_free (str);
 
-  IFDBG(2) g_debug ("Pascal string: %s, bytes_read: %d, bytes_written: %d",
+  IFDBG(3) g_debug ("Pascal string: %s, bytes_read: %d, bytes_written: %d",
                     utf8_str, *bytes_read, *bytes_written);
 
   return utf8_str;
 }
 
 gint32
-fwrite_pascal_string (const gchar   *src,
-                      const guint16  pad_len,
-                      FILE          *f)
+fwrite_pascal_string (const gchar    *src,
+                      const guint16   mod_len,
+                      FILE           *f,
+                      GError        **error)
 {
-  /* Converts utf-8 string to current locale and writes as pascal string with
-     padding to pad width */
+  /*
+   *  Converts utf-8 string to current locale and writes as pascal
+   *  string with padding to a multiple of mod_len.
+   */
 
-  gchar        *str,
-               *pascal_str,
-                null_str = 0x0;
+  gchar        *str;
+  gchar        *pascal_str;
+  gchar         null_str = 0x0;
   guchar        pascal_len;
   gint32        bytes_written = 0;
   gsize         len;
@@ -129,7 +156,7 @@
       if (fwrite (&null_str, 1, 1, f) < 1
           || fwrite (&null_str, 1, 1, f) < 1)
         {
-          g_message (_("Error writing pascal string"));
+          psd_set_error (feof (f), errno, error);
           return -1;
         }
       bytes_written += 2;
@@ -146,7 +173,7 @@
       if (fwrite (&pascal_len, 1, 1, f) < 1
           || fwrite (pascal_str, pascal_len, 1, f) < 1)
         {
-          g_message (_("Error writing pascal string"));
+          psd_set_error (feof (f), errno, error);
           return -1;
         }
       bytes_written++;
@@ -156,13 +183,13 @@
     }
 
   /* Pad with nulls */
-  if (pad_len > 0)
+  if (mod_len > 0)
     {
-      while (bytes_written % pad_len != 0)
+      while (bytes_written % mod_len != 0)
         {
           if (fwrite (&null_str, 1, 1, f) < 1)
             {
-              g_message (_("Error writing pascal string"));
+              psd_set_error (feof (f), errno, error);
               return -1;
             }
           bytes_written++;
@@ -173,18 +200,22 @@
 }
 
 gchar *
-fread_unicode_string (gint32        *bytes_read,
-                      gint32        *bytes_written,
-                      const guint16  pad_len,
-                      FILE          *f)
+fread_unicode_string (gint32         *bytes_read,
+                      gint32         *bytes_written,
+                      const guint16   mod_len,
+                      FILE           *f,
+                      GError        **error)
 {
-  /* Reads a utf-16 string padded to a multiple of pad_len and converts to utf-8 */
+  /*
+   * Reads a utf-16 string from the file padded to a multiple of mod_len
+   * and returns a utf-8 string.
+   */
 
   gchar        *utf8_str;
   gunichar2    *utf16_str;
-  gint32        len,
-                i,
-                padded_len;
+  gint32        len;
+  gint32        i;
+  gint32        padded_len;
   glong         utf8_str_len;
 
   *bytes_read = 0;
@@ -192,7 +223,7 @@
 
   if (fread (&len, 4, 1, f) < 1)
     {
-      g_message (_("Error reading unicode string length"));
+      psd_set_error (feof (f), errno, error);
       return NULL;
     }
   *bytes_read += 4;
@@ -201,12 +232,12 @@
 
   if (len == 0)
     {
-      if (fseek (f, pad_len - 1, SEEK_CUR) < 0)
+      if (fseek (f, mod_len - 1, SEEK_CUR) < 0)
         {
-          g_message (_("Error setting file position"));
+          psd_set_error (feof (f), errno, error);
           return NULL;
         }
-      *bytes_read += (pad_len - 1);
+      *bytes_read += (mod_len - 1);
       *bytes_written = 0;
       return NULL;
     }
@@ -216,21 +247,21 @@
     {
       if (fread (&utf16_str[i], 2, 1, f) < 1)
         {
-          g_message (_("Error reading unicode string"));
+          psd_set_error (feof (f), errno, error);
           return NULL;
         }
       *bytes_read += 2;
       utf16_str[i] = GINT16_FROM_BE (utf16_str[i]);
     }
 
-  if (pad_len > 0)
+  if (mod_len > 0)
     {
       padded_len = len + 1;
-      while (padded_len % pad_len != 0)
+      while (padded_len % mod_len != 0)
         {
           if (fseek (f, 1, SEEK_CUR) < 0)
             {
-              g_message (_("Error setting file position"));
+              psd_set_error (feof (f), errno, error);
               return NULL;
             }
           (*bytes_read)++;
@@ -249,17 +280,20 @@
 }
 
 gint32
-fwrite_unicode_string (const gchar   *src,
-                       const guint16  pad_len,
-                       FILE          *f)
+fwrite_unicode_string (const gchar    *src,
+                       const guint16   mod_len,
+                       FILE           *f,
+                       GError        **error)
 {
-  /* Converts utf-8 string to utf-16 and writes 4 byte length then string
-     padding to pad width */
+  /*
+   *  Converts utf-8 string to utf-16 and writes 4 byte length
+   *  then string padding to multiple of mod_len.
+   */
 
   gunichar2    *utf16_str;
   gchar         null_str = 0x0;
-  gint32        utf16_len = 0,
-                bytes_written = 0;
+  gint32        utf16_len = 0;
+  gint32        bytes_written = 0;
   gint          i;
   glong         len;
 
@@ -268,7 +302,7 @@
        /* Write null string as four byte 0 int32 */
       if (fwrite (&utf16_len, 4, 1, f) < 1)
         {
-          g_message (_("Error writing unicode string"));
+          psd_set_error (feof (f), errno, error);
           return -1;
         }
       bytes_written += 4;
@@ -285,7 +319,7 @@
       if (fwrite (&utf16_len, 4, 1, f) < 1
           || fwrite (utf16_str, 2, utf16_len + 1, f) < utf16_len + 1)
         {
-          g_message (_("Error writing unicode string"));
+          psd_set_error (feof (f), errno, error);
           return -1;
         }
       bytes_written += (4 + 2 * utf16_len + 2);
@@ -294,13 +328,13 @@
     }
 
   /* Pad with nulls */
-  if (pad_len > 0)
+  if (mod_len > 0)
     {
-      while (bytes_written % pad_len != 0)
+      while (bytes_written % mod_len != 0)
         {
           if (fwrite (&null_str, 1, 1, f) < 1)
             {
-              g_message (_("Error writing unicode string"));
+              psd_set_error (feof (f), errno, error);
               return -1;
             }
           bytes_written++;
@@ -319,15 +353,12 @@
 /*
  *  Decode a PackBits chunk.
  */
-  int    n;
-  gchar  dat;
-  gint32 unpack_left = unpacked_len,
-         pack_left = packed_len,
-         error_code = 0,
-         return_val = 0;
-
-  IFDBG(3) g_debug ("Decode packbits");
-  IFDBG(3) g_debug ("Packed len %d, unpacked %d",packed_len, unpacked_len);
+  gint      n;
+  gchar     dat;
+  gint32    unpack_left = unpacked_len;
+  gint32    pack_left = packed_len;
+  gint32    error_code = 0;
+  gint32    return_val = 0;
 
   while (unpack_left > 0 && pack_left > 0)
     {
@@ -405,7 +436,6 @@
         }
     }
 
-  IFDBG(3) g_debug ("Pack left %d, unpack left %d", pack_left, unpack_left);
   if (unpack_left)
     {
       IFDBG(2) g_debug ("Packbits decode - unpack left %d", unpack_left);
@@ -582,8 +612,12 @@
   if (g_ascii_strncasecmp (psd_mode, "sat ", 4) == 0)           /* Saturation (ps3) */
     {
       if (CONVERSION_WARNINGS)
-        g_message (_("Gimp uses a different equation to photoshop for the "
-                     "saturation blend mode. Results will differ."));
+        {
+          static gchar  *mode_name = "SATURATION";
+          g_message ("Gimp uses a different equation to photoshop for "
+                     "blend mode: %s. Results will differ.",
+                     mode_name);
+        }
       return GIMP_SATURATION_MODE;
     }
   if (g_ascii_strncasecmp (psd_mode, "colr", 4) == 0)           /* Color (ps3) */
@@ -591,8 +625,12 @@
   if (g_ascii_strncasecmp (psd_mode, "lum ", 4) == 0)           /* Luminosity (ps3) */
     {
       if (CONVERSION_WARNINGS)
-        g_message (_("Gimp uses a different equation to photoshop for the "
-                     "value (luminosity) blend mode. Results will differ."));
+        {
+          static gchar  *mode_name = "LUMINOSITY (VALUE)";
+          g_message ("Gimp uses a different equation to photoshop for "
+                     "blend mode: %s. Results will differ.",
+                     mode_name);
+        }
       return GIMP_VALUE_MODE;
     }
   if (g_ascii_strncasecmp (psd_mode, "mul ", 4) == 0)           /* Multiply (ps3) */
@@ -604,8 +642,12 @@
   if (g_ascii_strncasecmp (psd_mode, "over", 4) == 0)           /* Overlay (ps3) */
     {
       if (CONVERSION_WARNINGS)
-        g_message (_("Gimp uses a different equation to photoshop for the "
-                     "overlay blend mode. Results will differ."));
+        {
+          static gchar  *mode_name = "OVERLAY";
+          g_message ("Gimp uses a different equation to photoshop for "
+                     "blend mode: %s. Results will differ.",
+                     mode_name);
+        }
       return GIMP_OVERLAY_MODE;
     }
   if (g_ascii_strncasecmp (psd_mode, "hLit", 4) == 0)           /* Hard light (ps3) */
@@ -613,8 +655,12 @@
   if (g_ascii_strncasecmp (psd_mode, "sLit", 4) == 0)           /* Soft light (ps3) */
     {
       if (CONVERSION_WARNINGS)
-        g_message (_("Gimp uses a different equation to photoshop for the "
-                     "soft light blend mode. Results will differ."));
+        {
+          static gchar  *mode_name = "SOFT LIGHT";
+          g_message ("Gimp uses a different equation to photoshop for "
+                     "blend mode: %s. Results will differ.",
+                     mode_name);
+        }
     return GIMP_SOFTLIGHT_MODE;
     }
   if (g_ascii_strncasecmp (psd_mode, "diff", 4) == 0)           /* Difference (ps3) */
@@ -622,8 +668,11 @@
   if (g_ascii_strncasecmp (psd_mode, "smud", 4) == 0)           /* Exclusion (ps6) */
     {
       if (CONVERSION_WARNINGS)
-        g_message (_("Exclusion blend mode not supported by GIMP. "
-                     "Blend mode reverts to normal."));
+        {
+          static gchar  *mode_name = "EXCLUSION";
+          g_message ("Unsupported blend mode: %s. Mode reverts to normal",
+                     mode_name);
+        }
       return GIMP_NORMAL_MODE;
     }
   if (g_ascii_strncasecmp (psd_mode, "div ", 4) == 0)           /* Color dodge (ps6) */
@@ -633,8 +682,11 @@
   if (g_ascii_strncasecmp (psd_mode, "lbrn", 4) == 0)           /* Linear burn (ps7)*/
     {
       if (CONVERSION_WARNINGS)
-        g_message (_("Linear burn blend mode not supported by GIMP. "
-                     "Blend mode reverts to normal."));
+        {
+          static gchar  *mode_name = "LINEAR BURN";
+          g_message ("Unsupported blend mode: %s. Mode reverts to normal",
+                     mode_name);
+        }
       return GIMP_NORMAL_MODE;
     }
   if (g_ascii_strncasecmp (psd_mode, "lddg", 4) == 0)           /* Linear dodge (ps7)*/
@@ -642,34 +694,51 @@
   if (g_ascii_strncasecmp (psd_mode, "lLit", 4) == 0)           /* Linear light (ps7)*/
     {
       if (CONVERSION_WARNINGS)
-        g_message (_("Linear light blend mode not supported by GIMP. "
-                     "Blend mode reverts to normal."));
+        {
+          static gchar  *mode_name = "LINEAR LIGHT";
+          g_message ("Unsupported blend mode: %s. Mode reverts to normal",
+                     mode_name);
+        }
       return GIMP_NORMAL_MODE;
     }
   if (g_ascii_strncasecmp (psd_mode, "pLit", 4) == 0)           /* Pin light (ps7)*/
     {
       if (CONVERSION_WARNINGS)
-        g_message (_("Pin light blend mode not supported by GIMP. "
-                     "Blend mode reverts to normal."));
+        {
+          static gchar  *mode_name = "PIN LIGHT";
+          g_message ("Unsupported blend mode: %s. Mode reverts to normal",
+                     mode_name);
+        }
       return GIMP_NORMAL_MODE;
     }
   if (g_ascii_strncasecmp (psd_mode, "vLit", 4) == 0)           /* Vivid light (ps7)*/
     {
       if (CONVERSION_WARNINGS)
-        g_message (_("Vivid light blend mode not supported by GIMP. "
-                     "Blend mode reverts to normal."));
+        {
+          static gchar  *mode_name = "VIVID LIGHT";
+          g_message ("Unsupported blend mode: %s. Mode reverts to normal",
+                     mode_name);
+        }
       return GIMP_NORMAL_MODE;
     }
   if (g_ascii_strncasecmp (psd_mode, "hMix", 4) == 0)           /* Hard Mix (CS)*/
     {
       if (CONVERSION_WARNINGS)
-        g_message (_("Hard mix blend mode not supported by GIMP. "
-                     "Blend mode reverts to normal."));
+        {
+          static gchar  *mode_name = "HARD MIX";
+          g_message ("Unsupported blend mode: %s. Mode reverts to normal",
+                     mode_name);
+        }
       return GIMP_NORMAL_MODE;
     }
 
   if (CONVERSION_WARNINGS)
-    g_message (_("Unknown blend mode %.4s. Blend mode reverts to normal."), psd_mode);
+    {
+      gchar  *mode_name = g_strndup (psd_mode, 4);
+      g_message ("Unsupported blend mode: %s. Mode reverts to normal",
+                 mode_name);
+      g_free (mode_name);
+    }
   return GIMP_NORMAL_MODE;
 }
 
@@ -688,8 +757,8 @@
         break;
       case GIMP_BEHIND_MODE:
         if (CONVERSION_WARNINGS)
-          g_message (_("Behind blend mode not supported in PSD file. "
-                       "Blend mode reverts to normal."));
+          g_message ("Unsupported blend mode: %s. Mode reverts to normal",
+                     gimp_layer_mode_effects_name (gimp_layer_mode));
         psd_mode = g_strndup ("norm", 4);
         break;
       case GIMP_MULTIPLY_MODE:
@@ -700,8 +769,9 @@
         break;
       case GIMP_OVERLAY_MODE:
         if (CONVERSION_WARNINGS)
-          g_message (_("Gimp uses a different equation to photoshop for the "
-                       "overlay blend mode. Results will differ."));
+          g_message ("Gimp uses a different equation to photoshop for "
+                     "blend mode: %s. Results will differ.",
+                     gimp_layer_mode_effects_name (gimp_layer_mode));
         psd_mode = g_strndup ("over", 4);                       /* Overlay (ps3) */
         break;
       case GIMP_DIFFERENCE_MODE:
@@ -712,8 +782,8 @@
         break;
       case GIMP_SUBTRACT_MODE:
         if (CONVERSION_WARNINGS)
-          g_message (_("Photoshop does not support the subtract "
-                       "blend mode. Layer mode reverts to normal."));
+          g_message ("Unsupported blend mode: %s. Mode reverts to normal",
+                     gimp_layer_mode_effects_name (gimp_layer_mode));
         psd_mode = g_strndup ("norm", 4);
         break;
       case GIMP_DARKEN_ONLY_MODE:
@@ -727,8 +797,9 @@
         break;
       case GIMP_SATURATION_MODE:
         if (CONVERSION_WARNINGS)
-          g_message (_("Gimp uses a different equation to photoshop for the "
-                       "saturation blend mode. Results will differ."));
+          g_message ("Gimp uses a different equation to photoshop for "
+                     "blend mode: %s. Results will differ.",
+                     gimp_layer_mode_effects_name (gimp_layer_mode));
         psd_mode = g_strndup ("sat ", 4);                       /* Saturation (ps3) */
         break;
       case GIMP_COLOR_MODE:
@@ -736,14 +807,15 @@
         break;
       case GIMP_VALUE_MODE:
         if (CONVERSION_WARNINGS)
-          g_message (_("Gimp uses a different equation to photoshop for the "
-                       "value (luminosity) blend mode. Results will differ."));
+          g_message ("Gimp uses a different equation to photoshop for "
+                     "blend mode: %s. Results will differ.",
+                     gimp_layer_mode_effects_name (gimp_layer_mode));
         psd_mode = g_strndup ("lum ", 4);                       /* Luminosity (ps3) */
         break;
       case GIMP_DIVIDE_MODE:
         if (CONVERSION_WARNINGS)
-          g_message (_("Photoshop does not support the divide "
-                       "blend mode. Layer mode reverts to normal."));
+          g_message ("Unsupported blend mode: %s. Mode reverts to normal",
+                     gimp_layer_mode_effects_name (gimp_layer_mode));
         psd_mode = g_strndup ("norm", 4);
         break;
       case GIMP_DODGE_MODE:
@@ -757,35 +829,73 @@
         break;
       case GIMP_SOFTLIGHT_MODE:
         if (CONVERSION_WARNINGS)
-          g_message (_("Gimp uses a different equation to photoshop for the "
-                       "soft light blend mode. Results will differ."));
-        psd_mode = g_strndup ("sLit", 4);                       /* Soft Light (ps3) */
+          g_message ("Unsupported blend mode: %s. Mode reverts to normal",
+                     gimp_layer_mode_effects_name (gimp_layer_mode));
+         psd_mode = g_strndup ("sLit", 4);                       /* Soft Light (ps3) */
         break;
       case GIMP_GRAIN_EXTRACT_MODE:
         if (CONVERSION_WARNINGS)
-          g_message (_("Photoshop does not support the grain extract "
-                       "blend mode. Layer mode reverts to normal."));
+          g_message ("Unsupported blend mode: %s. Mode reverts to normal",
+                     gimp_layer_mode_effects_name (gimp_layer_mode));
         psd_mode = g_strndup ("norm", 4);
         break;
       case GIMP_GRAIN_MERGE_MODE:
         if (CONVERSION_WARNINGS)
-          g_message (_("Photoshop does not support the grain merge "
-                       "blend mode. Layer mode reverts to normal."));
+          g_message ("Unsupported blend mode: %s. Mode reverts to normal",
+                     gimp_layer_mode_effects_name (gimp_layer_mode));
         psd_mode = g_strndup ("norm", 4);
         break;
       case GIMP_COLOR_ERASE_MODE:
         if (CONVERSION_WARNINGS)
-          g_message (_("Photoshop does not support the color erase "
-                       "blend mode. Layer mode reverts to normal."));
+          g_message ("Unsupported blend mode: %s. Mode reverts to normal",
+                     gimp_layer_mode_effects_name (gimp_layer_mode));
         psd_mode = g_strndup ("norm", 4);
         break;
 
       default:
         if (CONVERSION_WARNINGS)
-          g_message (_("Blend mode %d not supported. Blend mode reverts to normal.")
-                     , gimp_layer_mode);
+          g_message ("Unsupported blend mode: %s. Mode reverts to normal",
+                     gimp_layer_mode_effects_name (gimp_layer_mode));
         psd_mode = g_strndup ("norm", 4);
     }
 
   return psd_mode;
 }
+
+static gchar *
+gimp_layer_mode_effects_name (const GimpLayerModeEffects mode)
+{
+  static gchar *layer_mode_effects_names[] =
+  {
+    "NORMAL",
+    "DISSOLVE",
+    "BEHIND",
+    "MULTIPLY",
+    "SCREEN",
+    "OVERLAY",
+    "DIFFERENCE",
+    "ADD",
+    "SUBTRACT",
+    "DARKEN",
+    "LIGHTEN",
+    "HUE",
+    "SATURATION",
+    "COLOR",
+    "VALUE",
+    "DIVIDE",
+    "DODGE",
+    "BURN",
+    "HARD LIGHT",
+    "SOFT LIGHT",
+    "GRAIN EXTRACT",
+    "GRAIN MERGE",
+    "COLOR ERASE"
+  };
+  static gchar *err_name = NULL;
+  if (mode >= 0 && mode <= GIMP_COLOR_ERASE_MODE)
+    return layer_mode_effects_names[mode];
+  g_free (err_name);
+
+  err_name = g_strdup_printf ("UNKNOWN (%d)", mode);
+  return err_name;
+}

Modified: branches/weskaggs/plug-ins/psd/psd-util.h
==============================================================================
--- branches/weskaggs/plug-ins/psd/psd-util.h	(original)
+++ branches/weskaggs/plug-ins/psd/psd-util.h	Thu Jan 10 03:08:46 2008
@@ -22,36 +22,62 @@
 #ifndef __PSD_UTIL_H__
 #define __PSD_UTIL_H__
 
+/*
+ *  Set file read error
+ */
+void                    psd_set_error          (const gboolean  file_eof,
+                                                const gint      err_no,
+                                                GError        **error);
+
+/*
+ * Reads a pascal string from the file padded to a multiple of mod_len
+ * and returns a utf-8 string.
+ */
+gchar                 * fread_pascal_string    (gint32         *bytes_read,
+                                                gint32         *bytes_written,
+                                                const guint16   mod_len,
+                                                FILE           *f,
+                                                GError        **error);
+
+/*
+ *  Converts utf-8 string to current locale and writes as pascal
+ *  string with padding to a multiple of mod_len.
+ */
+gint32                  fwrite_pascal_string   (const gchar    *src,
+                                                const guint16   mod_len,
+                                                FILE           *f,
+                                                GError        **error);
+
+/*
+ * Reads a utf-16 string from the file padded to a multiple of mod_len
+ * and returns a utf-8 string.
+ */
+gchar                 * fread_unicode_string   (gint32         *bytes_read,
+                                                gint32         *bytes_written,
+                                                const guint16   mod_len,
+                                                FILE           *f,
+                                                GError        **error);
+
+/*
+ *  Converts utf-8 string to utf-16 and writes 4 byte length
+ *  then string padding to multiple of mod_len.
+ */
+gint32                  fwrite_unicode_string  (const gchar    *src,
+                                                const guint16   mod_len,
+                                                FILE           *f,
+                                                GError        **error);
+
+gint                    decode_packbits        (const gchar    *src,
+                                                gchar          *dst,
+                                                guint16         packed_len,
+                                                guint32         unpacked_len);
+
+gchar                 * encode_packbits        (const gchar    *src,
+                                                const guint32   unpacked_len,
+                                                guint16        *packed_len);
 
-gchar                * fread_pascal_string    (gint32        *bytes_read,
-                                               gint32        *bytes_written,
-                                               const guint16  pad_len,
-                                               FILE          *f);
-
-gint32                 fwrite_pascal_string   (const gchar   *src,
-                                               const guint16  pad_len,
-                                               FILE          *f);
-
-gchar                * fread_unicode_string   (gint32        *bytes_read,
-                                               gint32        *bytes_written,
-                                               const guint16  pad_len,
-                                               FILE          *f);
-
-gint32                 fwrite_unicode_string  (const gchar   *src,
-                                               const guint16  pad_len,
-                                               FILE          *f);
-
-gint                   decode_packbits        (const gchar   *src,
-                                               gchar         *dst,
-                                               guint16        packed_len,
-                                               guint32        unpacked_len);
-
-gchar                * encode_packbits        (const gchar   *src,
-                                               const guint32  unpacked_len,
-                                               guint16       *packed_len);
+GimpLayerModeEffects    psd_to_gimp_blend_mode (const gchar    *psd_mode);
 
-GimpLayerModeEffects   psd_to_gimp_blend_mode (const gchar   *psd_mode);
-
-gchar *                gimp_to_psd_blend_mode (const GimpLayerModeEffects gimp_layer_mode);
+gchar *                 gimp_to_psd_blend_mode (const GimpLayerModeEffects gimp_layer_mode);
 
 #endif /* __PSD_UTIL_H__ */

Modified: branches/weskaggs/plug-ins/psd/psd.c
==============================================================================
--- branches/weskaggs/plug-ins/psd/psd.c	(original)
+++ branches/weskaggs/plug-ins/psd/psd.c	Thu Jan 10 03:08:46 2008
@@ -157,7 +157,7 @@
                           save_args, NULL);
 
   gimp_register_save_handler (SAVE_PROC, "psd", "");
-  gimp_register_file_handler_mime (SAVE_PROC, "image/psd");
+  gimp_register_file_handler_mime (SAVE_PROC, "image/x-psd");
 #endif /* PSD_SAVE */
 }
 
@@ -200,8 +200,6 @@
         }
       else
         {
-          g_message (_("Could not open '%s' for reading"),
-                     gimp_filename_to_utf8 (param[1].data.d_string));
           status = GIMP_PDB_EXECUTION_ERROR;
         }
     }

Modified: branches/weskaggs/plug-ins/psd/psd.h
==============================================================================
--- branches/weskaggs/plug-ins/psd/psd.h	(original)
+++ branches/weskaggs/plug-ins/psd/psd.h	Thu Jan 10 03:08:46 2008
@@ -19,7 +19,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-
 #ifndef __PSD_H__
 #define __PSD_H__
 
@@ -133,7 +132,6 @@
 #define PSD_LFX_INNER_GLW       "iglw"          /* Effects layer - inner glow (PS5) */
 #define PSD_LFX_BEVEL           "bevl"          /* Effects layer - bevel (PS5) */
 
-
 /* PSD spec enums */
 
 /* Image colour modes */

Modified: branches/weskaggs/plug-ins/pygimp/pygimp-image.c
==============================================================================
--- branches/weskaggs/plug-ins/pygimp/pygimp-image.c	(original)
+++ branches/weskaggs/plug-ins/pygimp/pygimp-image.c	Thu Jan 10 03:08:46 2008
@@ -66,6 +66,94 @@
 }
 
 static PyObject *
+img_new_layer(PyGimpImage *self, PyObject *args, PyObject *kwargs)
+{
+    char *layer_name;
+    int layer_id;
+    int width, height;
+    int layer_type;
+    int offs_x = 0, offs_y = 0;
+    gboolean alpha = TRUE;
+    int pos = -1;
+    double opacity = 100.0;
+    GimpLayerModeEffects mode = GIMP_NORMAL_MODE;
+    GimpFillType fill_mode = -1;
+
+    static char *kwlist[] = { "name", "width", "height", "offset_x", "offset_y",
+                              "alpha", "pos", "opacity", "mode", "fill_mode",
+                              NULL };
+
+    layer_name = "New Layer";
+
+    width = gimp_image_width(self->ID);
+    height = gimp_image_width(self->ID);
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+                                     "|siiiiiidii:new_layer", kwlist,
+                                     &layer_name, &width, &height,
+                                     &offs_x, &offs_y, &alpha, &pos,
+                                     &opacity, &mode, &fill_mode))
+        return NULL;
+
+
+    switch (gimp_image_base_type(self->ID))  {
+        case GIMP_RGB:
+            layer_type = alpha ? GIMP_RGBA_IMAGE: GIMP_RGB_IMAGE;
+            break;
+        case GIMP_GRAY:
+            layer_type = alpha ? GIMP_GRAYA_IMAGE: GIMP_GRAY_IMAGE;
+            break;
+        case GIMP_INDEXED:
+            layer_type = alpha ? GIMP_INDEXEDA_IMAGE: GIMP_INDEXED_IMAGE;
+            break;
+        default:
+            PyErr_SetString(pygimp_error, "Unknown image base type");
+            return NULL; 
+    }
+
+    if (fill_mode == -1)
+        fill_mode = alpha ? GIMP_TRANSPARENT_FILL: GIMP_BACKGROUND_FILL;
+
+
+    layer_id = gimp_layer_new(self->ID, layer_name, width, height,
+                              layer_type, opacity, mode);
+
+    if (!layer_id) {
+        PyErr_Format(pygimp_error,
+                     "could not create new layer in image (ID %d)",
+                     self->ID);
+        return NULL;
+    }
+
+    if (!gimp_drawable_fill(layer_id, fill_mode)) {
+        gimp_drawable_delete(layer_id);
+        PyErr_Format(pygimp_error,
+                     "could not fill new layer with fill mode %d",
+                     fill_mode);
+        return NULL;
+    }
+
+    if (!gimp_image_add_layer(self->ID, layer_id, pos)) {
+        gimp_drawable_delete(layer_id);
+        PyErr_Format(pygimp_error,
+                     "could not add layer (ID %d) to image (ID %d)",
+                     layer_id, self->ID);
+        return NULL;
+    }
+
+    if (!gimp_layer_set_offsets(layer_id, offs_x, offs_y)) {
+        gimp_image_remove_layer(self->ID, layer_id);
+        PyErr_Format(pygimp_error,
+                     "could not set offset %d, %d on layer (ID %d)",
+                      offs_x, offs_y, layer_id);
+        return NULL;
+    }
+
+    return pygimp_layer_new(layer_id);
+}
+
+
+static PyObject *
 img_clean_all(PyGimpImage *self)
 {
     if (!gimp_image_clean_all(self->ID)) {
@@ -740,6 +828,7 @@
 static PyMethodDef img_methods[] = {
     {"add_channel",	(PyCFunction)img_add_channel,	METH_VARARGS},
     {"add_layer",	(PyCFunction)img_add_layer,	METH_VARARGS},
+    {"new_layer",       (PyCFunction)img_new_layer, METH_VARARGS | METH_KEYWORDS},
     {"clean_all",	(PyCFunction)img_clean_all,	METH_NOARGS},
     {"disable_undo",	(PyCFunction)img_disable_undo,	METH_NOARGS},
     {"enable_undo",	(PyCFunction)img_enable_undo,	METH_NOARGS},

Modified: branches/weskaggs/plug-ins/pygimp/pygimp-vectors.c
==============================================================================
--- branches/weskaggs/plug-ins/pygimp/pygimp-vectors.c	(original)
+++ branches/weskaggs/plug-ins/pygimp/pygimp-vectors.c	Thu Jan 10 03:08:46 2008
@@ -152,7 +152,7 @@
 
     static char *kwlist[] = { "flip_type", "axis", NULL };
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id:rotate", kwlist,
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id:flip", kwlist,
                                      &flip_type, &axis))
         return NULL;
 
@@ -169,7 +169,7 @@
 
     static char *kwlist[] = { "x1", "y1", "x2", "y2", NULL };
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dddd:rotate", kwlist,
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dddd:flip_free", kwlist,
                                      &x1, &y1, &x2, &y2))
         return NULL;
 
@@ -446,7 +446,7 @@
     static char *kwlist[] = { "x0", "y0", "x1", "y1", "x2", "y2", NULL };
 
     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
-                                     "dddddd:conicto", kwlist,
+                                     "dddddd:cubicto", kwlist,
                                      &x0, &y0, &x1, &y1, &x2, &y2))
         return NULL;
 
@@ -594,16 +594,24 @@
 static PyObject *
 vectors_remove_stroke(PyGimpVectors *self, PyObject *args, PyObject *kwargs)
 {
-    int stroke;
+    int stroke_id ;
+    /* PyGimpVectorsStroke *stroke; */
+    PyObject *stroke = NULL;
 
     static char *kwlist[] = { "stroke", NULL };
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:remove_stroke", kwlist,
-                                     &stroke))
-        return NULL;
+    PyArg_ParseTupleAndKeywords(args, kwargs, "O:remove_stroke", kwlist, &stroke);
 
+    if (PyInt_Check(stroke))
+        stroke_id = PyInt_AsLong(stroke);
+    else if (PyObject_IsInstance(stroke, (PyObject *) &PyGimpVectorsStroke_Type))
+        stroke_id = ((PyGimpVectorsStroke *) stroke)->stroke;
+    else  {
+        PyErr_SetString(PyExc_TypeError, "stroke must be a gimp.VectorsBezierStroke object or an Integer");
+        return NULL;
+    }
 
-    gimp_vectors_remove_stroke(self->ID, stroke);
+    gimp_vectors_remove_stroke(self->ID, stroke_id);
 
     Py_INCREF(Py_None);
     return Py_None;

Modified: branches/weskaggs/plug-ins/script-fu/ftx/ftx.c
==============================================================================
--- branches/weskaggs/plug-ins/script-fu/ftx/ftx.c	(original)
+++ branches/weskaggs/plug-ins/script-fu/ftx/ftx.c	Thu Jan 10 03:08:46 2008
@@ -90,12 +90,12 @@
   filename = sc->vptr->string_value(first_arg);
   filename = g_filename_from_utf8 (filename, -1, NULL, NULL, NULL);
 
-  if (g_file_test(filename, G_FILE_TEST_IS_REGULAR))
+  if (g_file_test(filename, G_FILE_TEST_IS_SYMLINK))
+    retcode =  FILE_TYPE_LINK;
+  else if (g_file_test(filename, G_FILE_TEST_IS_REGULAR))
     retcode = FILE_TYPE_FILE;
   else if (g_file_test(filename, G_FILE_TEST_IS_DIR))
     retcode = FILE_TYPE_DIR;
-  else if (g_file_test(filename, G_FILE_TEST_IS_SYMLINK))
-    retcode =  FILE_TYPE_LINK;
   else
     retcode = FILE_TYPE_UNKNOWN;
 

Modified: branches/weskaggs/tools/pdbgen/pdb/channel.pdb
==============================================================================
--- branches/weskaggs/tools/pdbgen/pdb/channel.pdb	(original)
+++ branches/weskaggs/tools/pdbgen/pdb/channel.pdb	Thu Jan 10 03:08:46 2008
@@ -90,7 +90,7 @@
 	code => <<'CODE'
 {
   channel_copy = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (channel),
-                               G_TYPE_FROM_INSTANCE (channel), FALSE));
+                               G_TYPE_FROM_INSTANCE (channel)));
 
   if (! channel_copy)
     success = FALSE;

Modified: branches/weskaggs/tools/pdbgen/pdb/color.pdb
==============================================================================
--- branches/weskaggs/tools/pdbgen/pdb/color.pdb	(original)
+++ branches/weskaggs/tools/pdbgen/pdb/color.pdb	Thu Jan 10 03:08:46 2008
@@ -47,6 +47,26 @@
 
   if (success)
     {
+  if (gimp->config->use_gegl)
+    {
+      GeglNode *node = g_object_new (GEGL_TYPE_NODE,
+                                     "operation",  "brightness-contrast",
+                                     NULL);
+
+      gegl_node_set (node,
+                     "brightness", brightness / 127.0,
+                     "contrast",   (contrast < 0 ?
+                                    (contrast + 127.0) / 127.0 :
+                                    contrast * 4.0 / 127.0 + 1),
+                     NULL);
+
+      gimp_drawable_apply_operation (drawable, node, TRUE,
+                                     progress, _("Brightness-Contrast"));
+
+      g_object_unref (node);
+    }
+  else
+    {
       gint x, y, width, height;
 
       /* The application should occur only within selection bounds */
@@ -74,6 +94,7 @@
           gimp_drawable_update (drawable, x, y, width, height);
         }
     }
+    }
 }
 CODE
     );
@@ -116,8 +137,7 @@
     );
 
     %invoke = (
-	headers => [ qw("base/levels.h"
-                        "core/gimpdrawable-levels.h") ],
+	headers => [ qw("core/gimpdrawable-levels.h") ],
 	code => <<'CODE'
 {
   if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
@@ -159,9 +179,7 @@
     );
 
     %invoke = (
-        headers => [ qw("base/levels.h"
-                        "base/gimphistogram.h"
-                        "core/gimpdrawable-histogram.h"
+        headers => [ qw("core/gimpdrawable-histogram.h"
                         "core/gimpdrawable-levels.h") ],
         code => <<'CODE'
 {
@@ -185,9 +203,7 @@
     );
 
     %invoke = (
-        headers => [ qw("base/levels.h"
-                        "base/gimphistogram.h"
-                        "core/gimpdrawable-histogram.h"
+        headers => [ qw("core/gimpdrawable-histogram.h"
                         "core/gimpdrawable-levels.h") ],
         code => <<'CODE'
 {
@@ -229,6 +245,23 @@
 
   if (success)
     {
+  if (gimp->config->use_gegl)
+    {
+      GeglNode *node = g_object_new (GEGL_TYPE_NODE,
+                                     "operation", "gimp-posterize",
+                                     NULL);
+
+      gegl_node_set (node,
+                     "levels", levels,
+                     NULL);
+
+      gimp_drawable_apply_operation (drawable, node, TRUE,
+                                     progress, _("Levels"));
+
+      g_object_unref (node);
+    }
+  else
+    {
       gint x, y, width, height;
 
       /* The application should occur only within selection bounds */
@@ -254,6 +287,7 @@
           gimp_drawable_update (drawable, x, y, width, height);
         }
     }
+    }
 }
 CODE
     );
@@ -693,6 +727,25 @@
 
   if (success)
     {
+  if (gimp->config->use_gegl)
+    {
+      GeglNode *node = g_object_new (GEGL_TYPE_NODE,
+                                     "operation", "gimp-colorize",
+                                     NULL);
+
+      gegl_node_set (node,
+                     "hue",        hue,
+                     "saturation", saturation,
+                     "lightness",  lightness,
+                     NULL);
+
+      gimp_drawable_apply_operation (drawable, node, TRUE,
+                                     progress, _("Colorize"));
+
+      g_object_unref (node);
+    }
+  else
+    {
       gint x, y, width, height;
 
       /* The application should occur only within selection bounds */
@@ -721,6 +774,7 @@
           gimp_drawable_update (drawable, x, y, width, height);
         }
     }
+    }
 }
 CODE
     );
@@ -774,7 +828,7 @@
     );
 
     %invoke = (
-	headers => [ qw("core/gimp.h" "core/gimpdrawable-histogram.h") ],
+	headers => [ qw("core/gimpdrawable-histogram.h") ],
 	code => <<'CODE'
 {
   if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
@@ -912,6 +966,24 @@
 
   if (success)
     {
+  if (gimp->config->use_gegl)
+    {
+      GeglNode *node = g_object_new (GEGL_TYPE_NODE,
+                                     "operation", "gimp-threshold",
+                                     NULL);
+
+      gegl_node_set (node,
+                     "low",  low_threshold  / 255.0,
+                     "high", high_threshold / 255.0,
+                     NULL);
+
+      gimp_drawable_apply_operation (drawable, node, TRUE,
+                                     progress, _("Threshold"));
+
+      g_object_unref (node);
+    }
+  else
+    {
       gint x, y, width, height;
 
       /* The application should occur only within selection bounds */
@@ -936,24 +1008,37 @@
           gimp_drawable_update (drawable, x, y, width, height);
         }
     }
+    }
 }
 CODE
     );
 }
 
 
- headers = qw("base/gimphistogram.h"
+ headers = qw(<gegl.h>
+              "base/gimphistogram.h"
               "base/gimplut.h"
               "base/lut-funcs.h"
-	      "base/pixel-region.h"
+              "base/pixel-region.h"
               "base/pixel-processor.h"
+              "config/gimpcoreconfig.h"
+              "core/gimp.h"
               "core/gimpdrawable.h"
+              "core/gimpdrawable-operation.h"
               "core/gimpimage.h"
               "gimp-intl.h");
 
- procs = qw(brightness_contrast levels levels_auto levels_stretch posterize
-            desaturate desaturate_full equalize invert curves_spline
-            curves_explicit color_balance colorize histogram hue_saturation
+ procs = qw(brightness_contrast
+            levels levels_auto levels_stretch
+            posterize
+            desaturate desaturate_full
+            equalize
+            invert
+            curves_spline curves_explicit
+            color_balance
+            colorize
+            histogram
+            hue_saturation
             threshold);
 
 %exports = (app => [ procs], lib => [ procs]);

Modified: branches/weskaggs/tools/pdbgen/pdb/layer.pdb
==============================================================================
--- branches/weskaggs/tools/pdbgen/pdb/layer.pdb	(original)
+++ branches/weskaggs/tools/pdbgen/pdb/layer.pdb	Thu Jan 10 03:08:46 2008
@@ -94,10 +94,16 @@
 	code => <<'CODE'
 {
   layer_copy = GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (layer),
-                                                G_TYPE_FROM_INSTANCE (layer),
-                                                add_alpha));
-  if (! layer_copy)
-    success = FALSE;
+                                                G_TYPE_FROM_INSTANCE (layer)));
+  if (layer_copy)
+    {
+      if (add_alpha)
+        gimp_layer_add_alpha (layer_copy);
+    }
+  else
+    {
+      success = FALSE;
+    }
 }
 CODE
     );
@@ -588,9 +594,9 @@
     new_type = GIMP_TYPE_LAYER;
 
   if (dest_image == gimp_item_get_image (GIMP_ITEM (drawable)))
-    new_item = gimp_item_duplicate (GIMP_ITEM (drawable), new_type, TRUE);
+    new_item = gimp_item_duplicate (GIMP_ITEM (drawable), new_type);
   else
-    new_item = gimp_item_convert (GIMP_ITEM (drawable), dest_image, new_type, TRUE);
+    new_item = gimp_item_convert (GIMP_ITEM (drawable), dest_image, new_type);
 
   if (new_item)
     layer_copy = GIMP_LAYER (new_item);



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