gimp r24652 - in branches/weskaggs: . app/base app/core app/gegl app/gegl/gegl app/gegl/gegl/buffer app/gegl/gegl/graph app/tools po po-plug-ins



Author: weskaggs
Date: Fri Jan 18 18:33:02 2008
New Revision: 24652
URL: http://svn.gnome.org/viewvc/gimp?rev=24652&view=rev

Log:
Bill Skaggs  <weskaggs primate ucdavis edu>

	Merged 24626:24650 from trunk.


Added:
   branches/weskaggs/app/core/gimptagged.c
      - copied unchanged from r24647, /trunk/app/core/gimptagged.c
   branches/weskaggs/app/core/gimptagged.h
      - copied unchanged from r24647, /trunk/app/core/gimptagged.h
   branches/weskaggs/app/gegl/gimpcolorizeconfig.c
      - copied unchanged from r24647, /trunk/app/gegl/gimpcolorizeconfig.c
   branches/weskaggs/app/gegl/gimpcolorizeconfig.h
      - copied unchanged from r24647, /trunk/app/gegl/gimpcolorizeconfig.h
   branches/weskaggs/app/gegl/gimplevelsconfig.c
      - copied unchanged from r24647, /trunk/app/gegl/gimplevelsconfig.c
   branches/weskaggs/app/gegl/gimplevelsconfig.h
      - copied unchanged from r24647, /trunk/app/gegl/gimplevelsconfig.h
Removed:
   branches/weskaggs/app/gegl/gegl/buffer/
   branches/weskaggs/app/gegl/gegl/graph/
Modified:
   branches/weskaggs/ChangeLog
   branches/weskaggs/app/base/boundary.c
   branches/weskaggs/app/base/lut-funcs.c
   branches/weskaggs/app/core/Makefile.am
   branches/weskaggs/app/core/core-types.h
   branches/weskaggs/app/core/gimpdata.c
   branches/weskaggs/app/core/gimpdata.h
   branches/weskaggs/app/core/gimpviewable.h
   branches/weskaggs/app/gegl/Makefile.am
   branches/weskaggs/app/gegl/gegl-types.h
   branches/weskaggs/app/gegl/gegl/gegl-operation-filter.h
   branches/weskaggs/app/gegl/gegl/gegl-operation.h
   branches/weskaggs/app/gegl/gimpoperationcolorize.c
   branches/weskaggs/app/gegl/gimpoperationcolorize.h
   branches/weskaggs/app/gegl/gimpoperationhuesaturation.c
   branches/weskaggs/app/gegl/gimpoperationlevels.c
   branches/weskaggs/app/gegl/gimpoperationlevels.h
   branches/weskaggs/app/gegl/gimpoperationtilesink.c
   branches/weskaggs/app/gegl/gimpoperationtilesource.c
   branches/weskaggs/app/tools/gimpcolorizetool.c
   branches/weskaggs/app/tools/gimpcolorizetool.h
   branches/weskaggs/app/tools/gimpeditselectiontool.c
   branches/weskaggs/app/tools/gimpimagemaptool.c
   branches/weskaggs/app/tools/gimplevelstool.c
   branches/weskaggs/app/tools/gimplevelstool.h
   branches/weskaggs/po-plug-ins/ChangeLog
   branches/weskaggs/po-plug-ins/ru.po
   branches/weskaggs/po/ChangeLog
   branches/weskaggs/po/ru.po

Modified: branches/weskaggs/app/base/boundary.c
==============================================================================
--- branches/weskaggs/app/base/boundary.c	(original)
+++ branches/weskaggs/app/base/boundary.c	Fri Jan 18 18:33:02 2008
@@ -59,53 +59,48 @@
 
 /*  local function prototypes  */
 
-static Boundary * boundary_new       (PixelRegion     *PR);
-static BoundSeg * boundary_free      (Boundary        *boundary,
-                                      gboolean         free_segs);
-
-static void       boundary_add_seg   (Boundary        *bounrady,
-                                      gint             x1,
-                                      gint             y1,
-                                      gint             x2,
-                                      gint             y2,
-                                      gboolean         open);
-
-static void       find_empty_segs    (PixelRegion     *maskPR,
-                                      gint             scanline,
-                                      gint             empty_segs[],
-                                      gint             max_empty,
-                                      gint            *num_empty,
-                                      BoundaryType     type,
-                                      gint             x1,
-                                      gint             y1,
-                                      gint             x2,
-                                      gint             y2,
-                                      guchar           threshold);
-static void       process_horiz_seg  (Boundary        *boundary,
-                                      gint             x1,
-                                      gint             y1,
-                                      gint             x2,
-                                      gint             y2,
-                                      gboolean         open);
-static void       make_horiz_segs    (Boundary        *boundary,
-                                      gint             start,
-                                      gint             end,
-                                      gint             scanline,
-                                      gint             empty[],
-                                      gint             num_empty,
-                                      gint             top);
-static Boundary * generate_boundary  (PixelRegion     *PR,
-                                      BoundaryType     type,
-                                      gint             x1,
-                                      gint             y1,
-                                      gint             x2,
-                                      gint             y2,
-                                      guchar           threshold);
-
-static gint       cmp_xy              (gint ax,
-                                       gint ay,
-                                       gint bx,
-                                       gint by);
+static Boundary * boundary_new        (PixelRegion     *PR);
+static BoundSeg * boundary_free       (Boundary        *boundary,
+                                       gboolean         free_segs);
+
+static void       boundary_add_seg    (Boundary        *bounrady,
+                                       gint             x1,
+                                       gint             y1,
+                                       gint             x2,
+                                       gint             y2,
+                                       gboolean         open);
+
+static void       find_empty_segs     (PixelRegion     *maskPR,
+                                       gint             scanline,
+                                       gint             empty_segs[],
+                                       gint             max_empty,
+                                       gint            *num_empty,
+                                       BoundaryType     type,
+                                       gint             x1,
+                                       gint             y1,
+                                       gint             x2,
+                                       gint             y2,
+                                       guchar           threshold);
+static void       process_horiz_seg   (Boundary        *boundary,
+                                       gint             x1,
+                                       gint             y1,
+                                       gint             x2,
+                                       gint             y2,
+                                       gboolean         open);
+static void       make_horiz_segs     (Boundary        *boundary,
+                                       gint             start,
+                                       gint             end,
+                                       gint             scanline,
+                                       gint             empty[],
+                                       gint             num_empty,
+                                       gint             top);
+static Boundary * generate_boundary   (PixelRegion     *PR,
+                                       BoundaryType     type,
+                                       gint             x1,
+                                       gint             y1,
+                                       gint             x2,
+                                       gint             y2,
+                                       guchar           threshold);
 
 static gint       cmp_segptr_xy1_addr (const BoundSeg **seg_ptr_a,
                                        const BoundSeg **seg_ptr_b);
@@ -128,10 +123,10 @@
                                                 const BoundSeg  *search_seg,
                                                 GCompareFunc     cmp_func);
 
-static void       simplify_subdivide (const BoundSeg  *segs,
-                                      gint             start_idx,
-                                      gint             end_idx,
-                                      GArray         **ret_points);
+static void       simplify_subdivide  (const BoundSeg  *segs,
+                                       gint             start_idx,
+                                       gint             end_idx,
+                                       GArray         **ret_points);
 
 
 /*  public functions  */
@@ -345,8 +340,8 @@
           /* temporarily use the delimiter to close the polygon */
           tmp_seg = sorted_segs[seg];
           sorted_segs[seg] = sorted_segs[start];
-          simplify_subdivide (sorted_segs, start, start + n_points,
-                              &tmp_points);
+          simplify_subdivide (sorted_segs,
+                              start, start + n_points, &tmp_points);
           sorted_segs[seg] = tmp_seg;
 
           for (j = 0; j < tmp_points->len; j++)
@@ -723,20 +718,32 @@
 
 /*  sorting utility functions  */
 
-static gint
-cmp_xy(gint ax, gint ay, gint bx, gint by)
+static inline gint
+cmp_xy (const gint ax,
+        const gint ay,
+        const gint bx,
+        const gint by)
 {
-  if (ay < by) {
-    return -1;
-  } else if (ay > by) {
-    return 1;
-  } else if (ax < bx) {
-    return -1;
-  } else if (ax > bx) {
-    return 1;
-  } else {
-    return 0;
-  }
+  if (ay < by)
+    {
+      return -1;
+    }
+  else if (ay > by)
+    {
+      return 1;
+    }
+  else if (ax < bx)
+    {
+      return -1;
+    }
+  else if (ax > bx)
+    {
+      return 1;
+    }
+  else
+    {
+      return 0;
+    }
 }
 
 
@@ -797,7 +804,7 @@
 {
   const BoundSeg *seg_a = *seg_ptr_a, *seg_b = *seg_ptr_b;
 
-  return cmp_xy(seg_a->x1, seg_a->y1, seg_b->x1, seg_b->y1);
+  return cmp_xy (seg_a->x1, seg_a->y1, seg_b->x1, seg_b->y1);
 }
 
 /*

Modified: branches/weskaggs/app/base/lut-funcs.c
==============================================================================
--- branches/weskaggs/app/base/lut-funcs.c	(original)
+++ branches/weskaggs/app/base/lut-funcs.c	Fri Jan 18 18:33:02 2008
@@ -293,13 +293,17 @@
 
 static gfloat
 equalize_lut_func (hist_lut_struct *hlut,
-                   gint             n_channels,
+                   gint             nchannels,
                    gint             channel,
                    gfloat           value)
 {
   gint i = 0;
   gint j;
 
+  /* don't equalize the alpha channel */
+  if ((nchannels == 2 || nchannels == 4) && channel == nchannels - 1)
+    return value;
+
   j = (gint) (value * 255.0 + 0.5);
 
   while (hlut->part[channel][i + 1] <= j)

Modified: branches/weskaggs/app/core/Makefile.am
==============================================================================
--- branches/weskaggs/app/core/Makefile.am	(original)
+++ branches/weskaggs/app/core/Makefile.am	Fri Jan 18 18:33:02 2008
@@ -290,6 +290,8 @@
 	gimpstrokeoptions.h		\
 	gimpsubprogress.c		\
 	gimpsubprogress.h		\
+	gimptagged.c			\
+	gimptagged.h			\
 	gimptemplate.c			\
 	gimptemplate.h			\
 	gimptoolinfo.c			\

Modified: branches/weskaggs/app/core/core-types.h
==============================================================================
--- branches/weskaggs/app/core/core-types.h	(original)
+++ branches/weskaggs/app/core/core-types.h	Fri Jan 18 18:33:02 2008
@@ -150,6 +150,7 @@
 
 typedef struct _GimpPickable        GimpPickable; /* dummy typedef */
 typedef struct _GimpProgress        GimpProgress; /* dummy typedef */
+typedef struct _GimpTagged          GimpTagged;   /* dummy typedef */
 
 
 /*  non-object types  */
@@ -163,6 +164,13 @@
 typedef struct _GimpScanConvert     GimpScanConvert;
 
 
+/*  tags  */
+
+typedef GQuark                      GimpTag;
+#define gimp_tag_new(name)          g_quark_from_string (name)
+#define gimp_tag_get_name(tag)      g_quark_to_string (name)
+
+
 /*  functions  */
 
 typedef void     (* GimpInitStatusFunc)    (const gchar      *text1,

Modified: branches/weskaggs/app/core/gimpdata.c
==============================================================================
--- branches/weskaggs/app/core/gimpdata.c	(original)
+++ branches/weskaggs/app/core/gimpdata.c	Fri Jan 18 18:33:02 2008
@@ -42,6 +42,7 @@
 #include "gimp-utils.h"
 #include "gimpdata.h"
 #include "gimpmarshal.h"
+#include "gimptagged.h"
 
 #include "gimp-intl.h"
 
@@ -62,14 +63,15 @@
 };
 
 
-static void      gimp_data_class_init   (GimpDataClass *klass);
-static void      gimp_data_init         (GimpData      *data,
-                                         GimpDataClass *data_class);
+static void      gimp_data_class_init        (GimpDataClass       *klass);
+static void      gimp_data_tagged_iface_init (GimpTaggedInterface *iface);
 
-static GObject * gimp_data_constructor  (GType                  type,
-                                         guint                  n_params,
-                                         GObjectConstructParam *params);
+static GObject * gimp_data_constructor     (GType                  type,
+                                            guint                  n_params,
+                                            GObjectConstructParam *params);
 
+static void      gimp_data_init         (GimpData      *data,
+                                         GimpDataClass *data_class);
 static void      gimp_data_finalize     (GObject       *object);
 static void      gimp_data_set_property (GObject       *object,
                                          guint          property_id,
@@ -85,6 +87,12 @@
 
 static void      gimp_data_real_dirty   (GimpData      *data);
 
+static gboolean  gimp_data_add_tag      (GimpTagged    *tagged,
+                                         GimpTag        tag);
+static gboolean  gimp_data_remove_tag   (GimpTagged    *tagged,
+                                         GimpTag        tag);
+static GList *   gimp_data_get_tags     (GimpTagged    *tagged);
+
 
 static guint data_signals[LAST_SIGNAL] = { 0 };
 
@@ -111,9 +119,18 @@
         (GInstanceInitFunc) gimp_data_init,
       };
 
+      const GInterfaceInfo tagged_info =
+      {
+        (GInterfaceInitFunc) gimp_data_tagged_iface_init,
+        NULL,           /* interface_finalize */
+        NULL            /* interface_data     */
+      };
+
       data_type = g_type_register_static (GIMP_TYPE_VIEWABLE,
                                           "GimpData",
                                           &data_info, 0);
+
+      g_type_add_interface_static (data_type, GIMP_TYPE_TAGGED, &tagged_info);
   }
 
   return data_type;
@@ -171,6 +188,14 @@
 }
 
 static void
+gimp_data_tagged_iface_init (GimpTaggedInterface *iface)
+{
+  iface->add_tag    = gimp_data_add_tag;
+  iface->remove_tag = gimp_data_remove_tag;
+  iface->get_tags   = gimp_data_get_tags;
+}
+
+static void
 gimp_data_init (GimpData      *data,
                 GimpDataClass *data_class)
 {
@@ -182,6 +207,7 @@
   data->internal     = FALSE;
   data->freeze_count = 0;
   data->mtime        = 0;
+  data->tags         = NULL;
 
   /*  look at the passed class pointer, not at GIMP_DATA_GET_CLASS(data)
    *  here, because the latter is always GimpDataClass itself
@@ -204,6 +230,12 @@
       data->filename = NULL;
     }
 
+  if (data->tags)
+    {
+      g_list_free (data->tags);
+      data->tags = NULL;
+    }
+
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -314,6 +346,53 @@
   gimp_object_name_changed (GIMP_OBJECT (data));
 }
 
+static gboolean
+gimp_data_add_tag (GimpTagged *tagged,
+                   GimpTag     tag)
+{
+  GimpData *data = GIMP_DATA (tagged);
+  GList    *list;
+
+  for (list = data->tags; list; list = list->next)
+    {
+      GimpTag this = GPOINTER_TO_UINT (list->data);
+
+      if (this == tag)
+        return FALSE;
+    }
+
+  data->tags = g_list_prepend (data->tags, GUINT_TO_POINTER (tag));
+
+  return TRUE;
+}
+
+static gboolean
+gimp_data_remove_tag (GimpTagged *tagged,
+                      GimpTag     tag)
+{
+  GimpData *data = GIMP_DATA (tagged);
+  GList    *list;
+
+  for (list = data->tags; list; list = list->next)
+    {
+      GimpTag this = GPOINTER_TO_UINT (list->data);
+
+      if (this == tag)
+        {
+          data->tags = g_list_delete_link (data->tags, list);
+          return TRUE;
+        }
+    }
+
+  return FALSE;
+}
+
+static GList *
+gimp_data_get_tags (GimpTagged *tagged)
+{
+  return GIMP_DATA (tagged)->tags;
+}
+
 /**
  * gimp_data_save:
  * @data:  object whose contents are to be saved.

Modified: branches/weskaggs/app/core/gimpdata.h
==============================================================================
--- branches/weskaggs/app/core/gimpdata.h	(original)
+++ branches/weskaggs/app/core/gimpdata.h	Fri Jan 18 18:33:02 2008
@@ -58,6 +58,8 @@
   guint         internal  : 1;
   gint          freeze_count;
   time_t        mtime;
+
+  GList        *tags;
 };
 
 struct _GimpDataClass

Modified: branches/weskaggs/app/core/gimpviewable.h
==============================================================================
--- branches/weskaggs/app/core/gimpviewable.h	(original)
+++ branches/weskaggs/app/core/gimpviewable.h	Fri Jan 18 18:33:02 2008
@@ -170,9 +170,9 @@
 void          gimp_viewable_set_stock_id     (GimpViewable  *viewable,
                                               const gchar   *stock_id);
 
-void       gimp_viewable_preview_freeze      (GimpViewable  *viewable);
-void       gimp_viewable_preview_thaw        (GimpViewable  *viewable);
-gboolean   gimp_viewable_preview_is_frozen   (GimpViewable  *viewable);
+void        gimp_viewable_preview_freeze     (GimpViewable  *viewable);
+void        gimp_viewable_preview_thaw       (GimpViewable  *viewable);
+gboolean    gimp_viewable_preview_is_frozen  (GimpViewable  *viewable);
 
 
 #endif  /* __GIMP_VIEWABLE_H__ */

Modified: branches/weskaggs/app/gegl/Makefile.am
==============================================================================
--- branches/weskaggs/app/gegl/Makefile.am	(original)
+++ branches/weskaggs/app/gegl/Makefile.am	Fri Jan 18 18:33:02 2008
@@ -7,6 +7,12 @@
 	gimp-gegl.h			\
 	gimp-gegl-utils.c		\
 	gimp-gegl-utils.h		\
+	\
+	gimpcolorizeconfig.c		\
+	gimpcolorizeconfig.h		\
+	gimplevelsconfig.c		\
+	gimplevelsconfig.h		\
+	\
 	gimpoperationcolorbalance.c	\
 	gimpoperationcolorbalance.h	\
 	gimpoperationcolorize.c		\

Modified: branches/weskaggs/app/gegl/gegl-types.h
==============================================================================
--- branches/weskaggs/app/gegl/gegl-types.h	(original)
+++ branches/weskaggs/app/gegl/gegl-types.h	Fri Jan 18 18:33:02 2008
@@ -26,6 +26,8 @@
 #include "gegl/gegl-types.h"
 
 
+/*  operations  */
+
 typedef struct _GimpOperationColorBalance  GimpOperationColorBalance;
 typedef struct _GimpOperationColorize      GimpOperationColorize;
 typedef struct _GimpOperationDesaturate    GimpOperationDesaturate;
@@ -37,4 +39,10 @@
 typedef struct _GimpOperationTileSource    GimpOperationTileSource;
 
 
+/*  operation config objects  */
+
+typedef struct _GimpColorizeConfig         GimpColorizeConfig;
+typedef struct _GimpLevelsConfig           GimpLevelsConfig;
+
+
 #endif /* __GEGL_TYPES_H__ */

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	Fri Jan 18 18:33:02 2008
@@ -19,8 +19,6 @@
 #ifndef __GEGL_OPERATION_FILTER_H__
 #define __GEGL_OPERATION_FILTER_H__
 
-#include <glib-object.h>
-#include "gegl-types.h"
 #include "gegl-operation.h"
 
 G_BEGIN_DECLS
@@ -44,7 +42,8 @@
   GeglOperationClass parent_class;
 
   gboolean (* process) (GeglOperation       *self,
-                        GeglNodeContext     *context,
+                        GeglBuffer          *input,
+                        GeglBuffer          *output,
                         const GeglRectangle *result);
 };
 

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	Fri Jan 18 18:33:02 2008
@@ -23,7 +23,7 @@
 #include <glib-object.h>
 #include <babl/babl.h>
 #include "gegl-types.h"
-#include "buffer/gegl-buffer-types.h"
+#include "gegl-buffer.h"
 
 G_BEGIN_DECLS
 
@@ -34,10 +34,6 @@
 #define GEGL_IS_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GEGL_TYPE_OPERATION))
 #define GEGL_OPERATION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GEGL_TYPE_OPERATION, GeglOperationClass))
 
-#define MAX_PADS        16
-#define MAX_INPUT_PADS  MAX_PADS
-#define MAX_OUTPUT_PADS MAX_PADS
-
 typedef struct _GeglOperationClass GeglOperationClass;
 
 struct _GeglOperation

Modified: branches/weskaggs/app/gegl/gimpoperationcolorize.c
==============================================================================
--- branches/weskaggs/app/gegl/gimpoperationcolorize.c	(original)
+++ branches/weskaggs/app/gegl/gimpoperationcolorize.c	Fri Jan 18 18:33:02 2008
@@ -27,18 +27,18 @@
 
 #include "gegl-types.h"
 
+#include "gimpcolorizeconfig.h"
 #include "gimpoperationcolorize.h"
 
 
 enum
 {
   PROP_0,
-  PROP_HUE,
-  PROP_SATURATION,
-  PROP_LIGHTNESS
+  PROP_CONFIG
 };
 
 
+static void     gimp_operation_colorize_finalize     (GObject       *object);
 static void     gimp_operation_colorize_get_property (GObject       *object,
                                                       guint          property_id,
                                                       GValue        *value,
@@ -67,6 +67,7 @@
   GeglOperationClass            *operation_class = GEGL_OPERATION_CLASS (klass);
   GeglOperationPointFilterClass *point_class     = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
 
+  object_class->finalize     = gimp_operation_colorize_finalize;
   object_class->set_property = gimp_operation_colorize_set_property;
   object_class->get_property = gimp_operation_colorize_get_property;
 
@@ -74,27 +75,11 @@
 
   gegl_operation_class_set_name (operation_class, "gimp-colorize");
 
-  g_object_class_install_property (object_class, PROP_HUE,
-                                   g_param_spec_double ("hue",
-                                                        "Hue",
-                                                        "Hue",
-                                                        0.0, 1.0, 0.5,
-                                                        G_PARAM_READWRITE |
-                                                        G_PARAM_CONSTRUCT));
-
-  g_object_class_install_property (object_class, PROP_SATURATION,
-                                   g_param_spec_double ("saturation",
-                                                        "Saturation",
-                                                        "Saturation",
-                                                        0.0, 1.0, 0.5,
-                                                        G_PARAM_READWRITE |
-                                                        G_PARAM_CONSTRUCT));
-
-  g_object_class_install_property (object_class, PROP_LIGHTNESS,
-                                   g_param_spec_double ("lightness",
-                                                        "Lightness",
-                                                        "Lightness",
-                                                        -1.0, 1.0, 0.0,
+  g_object_class_install_property (object_class, PROP_CONFIG,
+                                   g_param_spec_object ("config",
+                                                        "Config",
+                                                        "The config object",
+                                                        GIMP_TYPE_COLORIZE_CONFIG,
                                                         G_PARAM_READWRITE |
                                                         G_PARAM_CONSTRUCT));
 }
@@ -105,6 +90,20 @@
 }
 
 static void
+gimp_operation_colorize_finalize (GObject *object)
+{
+  GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (object);
+
+  if (self->config)
+    {
+      g_object_unref (self->config);
+      self->config = NULL;
+    }
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
 gimp_operation_colorize_get_property (GObject    *object,
                                       guint       property_id,
                                       GValue     *value,
@@ -114,16 +113,8 @@
 
   switch (property_id)
     {
-    case PROP_HUE:
-      g_value_set_double (value, self->hue);
-      break;
-
-    case PROP_SATURATION:
-      g_value_set_double (value, self->saturation);
-      break;
-
-    case PROP_LIGHTNESS:
-      g_value_set_double (value, self->lightness);
+    case PROP_CONFIG:
+      g_value_set_object (value, self->config);
       break;
 
     default:
@@ -142,16 +133,10 @@
 
   switch (property_id)
     {
-    case PROP_HUE:
-      self->hue = g_value_get_double (value);
-      break;
-
-    case PROP_SATURATION:
-      self->saturation = g_value_get_double (value);
-      break;
-
-    case PROP_LIGHTNESS:
-      self->lightness = g_value_get_double (value);
+    case PROP_CONFIG:
+      if (self->config)
+        g_object_unref (self->config);
+      self->config = g_value_dup_object (value);
       break;
 
    default:
@@ -166,32 +151,34 @@
                                  void          *out_buf,
                                  glong          samples)
 {
-  GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (operation);
-  gfloat                *src  = in_buf;
-  gfloat                *dest = out_buf;
+  GimpOperationColorize *self   = GIMP_OPERATION_COLORIZE (operation);
+  GimpColorizeConfig    *config = self->config;
+  gfloat                *src    = in_buf;
+  gfloat                *dest   = out_buf;
+  GimpHSL                hsl;
   glong                  sample;
 
+  hsl.h = config->hue;
+  hsl.s = config->saturation;
+
   for (sample = 0; sample < samples; sample++)
     {
-      GimpHSL hsl;
       GimpRGB rgb;
       gfloat  lum = GIMP_RGB_LUMINANCE (src[RED_PIX],
                                         src[GREEN_PIX],
                                         src[BLUE_PIX]);
 
-      if (self->lightness > 0)
+      if (config->lightness > 0)
         {
-          lum = lum * (1.0 - self->lightness);
+          lum = lum * (1.0 - config->lightness);
 
-          lum += 1.0 - (1.0 - self->lightness);
+          lum += 1.0 - (1.0 - config->lightness);
         }
-      else if (self->lightness < 0)
+      else if (config->lightness < 0)
         {
-          lum = lum * (self->lightness + 1.0);
+          lum = lum * (config->lightness + 1.0);
         }
 
-      hsl.h = self->hue;
-      hsl.s = self->saturation;
       hsl.l = lum;
 
       gimp_hsl_to_rgb (&hsl, &rgb);

Modified: branches/weskaggs/app/gegl/gimpoperationcolorize.h
==============================================================================
--- branches/weskaggs/app/gegl/gimpoperationcolorize.h	(original)
+++ branches/weskaggs/app/gegl/gimpoperationcolorize.h	Fri Jan 18 18:33:02 2008
@@ -38,9 +38,7 @@
 {
   GeglOperationPointFilter  parent_instance;
 
-  gdouble                   hue;
-  gdouble                   saturation;
-  gdouble                   lightness;
+  GimpColorizeConfig       *config;
 };
 
 struct _GimpOperationColorizeClass

Modified: branches/weskaggs/app/gegl/gimpoperationhuesaturation.c
==============================================================================
--- branches/weskaggs/app/gegl/gimpoperationhuesaturation.c	(original)
+++ branches/weskaggs/app/gegl/gimpoperationhuesaturation.c	Fri Jan 18 18:33:02 2008
@@ -266,9 +266,10 @@
                                        void          *out_buf,
                                        glong          samples)
 {
-  GimpOperationHueSaturation *self = GIMP_OPERATION_HUE_SATURATION (operation);
-  gfloat                     *src  = in_buf;
-  gfloat                     *dest = out_buf;
+  GimpOperationHueSaturation *self    = GIMP_OPERATION_HUE_SATURATION (operation);
+  gfloat                     *src     = in_buf;
+  gfloat                     *dest    = out_buf;
+  gfloat                      overlap = self->overlap / 2.0;
   glong                       sample;
 
   for (sample = 0; sample < samples; sample++)
@@ -282,7 +283,6 @@
       gboolean use_secondary_hue   = FALSE;
       gfloat   primary_intensity   = 0.0;
       gfloat   secondary_intensity = 0.0;
-      gfloat   overlap             = self->overlap / 2.0;
 
       rgb.r = src[RED_PIX];
       rgb.g = src[GREEN_PIX];

Modified: branches/weskaggs/app/gegl/gimpoperationlevels.c
==============================================================================
--- branches/weskaggs/app/gegl/gimpoperationlevels.c	(original)
+++ branches/weskaggs/app/gegl/gimpoperationlevels.c	Fri Jan 18 18:33:02 2008
@@ -28,21 +28,18 @@
 
 #include "gegl-types.h"
 
+#include "gimplevelsconfig.h"
 #include "gimpoperationlevels.h"
 
 
 enum
 {
   PROP_0,
-  PROP_CHANNEL,
-  PROP_GAMMA,
-  PROP_LOW_INPUT,
-  PROP_HIGH_INPUT,
-  PROP_LOW_OUTPUT,
-  PROP_HIGH_OUTPUT
+  PROP_CONFIG
 };
 
 
+static void     gimp_operation_levels_finalize     (GObject       *object);
 static void     gimp_operation_levels_get_property (GObject       *object,
                                                     guint          property_id,
                                                     GValue        *value,
@@ -71,6 +68,7 @@
   GeglOperationClass            *operation_class = GEGL_OPERATION_CLASS (klass);
   GeglOperationPointFilterClass *point_class     = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
 
+  object_class->finalize     = gimp_operation_levels_finalize;
   object_class->set_property = gimp_operation_levels_set_property;
   object_class->get_property = gimp_operation_levels_get_property;
 
@@ -78,52 +76,11 @@
 
   gegl_operation_class_set_name (operation_class, "gimp-levels");
 
-  g_object_class_install_property (object_class, PROP_CHANNEL,
-                                   g_param_spec_enum ("channel",
-                                                      "Channel",
-                                                      "The affected channel",
-                                                      GIMP_TYPE_HISTOGRAM_CHANNEL,
-                                                      GIMP_HISTOGRAM_VALUE,
-                                                      G_PARAM_READWRITE |
-                                                      G_PARAM_CONSTRUCT));
-
-  g_object_class_install_property (object_class, PROP_GAMMA,
-                                   g_param_spec_double ("gamma",
-                                                        "Gamma",
-                                                        "Gamma",
-                                                        0.1, 10.0, 1.0,
-                                                        G_PARAM_READWRITE |
-                                                        G_PARAM_CONSTRUCT));
-
-  g_object_class_install_property (object_class, PROP_LOW_INPUT,
-                                   g_param_spec_double ("low-input",
-                                                        "Low Input",
-                                                        "Low Input",
-                                                        0.0, 1.0, 0.0,
-                                                        G_PARAM_READWRITE |
-                                                        G_PARAM_CONSTRUCT));
-
-  g_object_class_install_property (object_class, PROP_HIGH_INPUT,
-                                   g_param_spec_double ("high-input",
-                                                        "High Input",
-                                                        "High Input",
-                                                        0.0, 1.0, 1.0,
-                                                        G_PARAM_READWRITE |
-                                                        G_PARAM_CONSTRUCT));
-
-  g_object_class_install_property (object_class, PROP_LOW_OUTPUT,
-                                   g_param_spec_double ("low-output",
-                                                        "Low Output",
-                                                        "Low Output",
-                                                        0.0, 1.0, 0.0,
-                                                        G_PARAM_READWRITE |
-                                                        G_PARAM_CONSTRUCT));
-
-  g_object_class_install_property (object_class, PROP_HIGH_OUTPUT,
-                                   g_param_spec_double ("high-output",
-                                                        "High Output",
-                                                        "High Output",
-                                                        0.0, 1.0, 1.0,
+  g_object_class_install_property (object_class, PROP_CONFIG,
+                                   g_param_spec_object ("config",
+                                                        "Config",
+                                                        "The config object",
+                                                        GIMP_TYPE_LEVELS_CONFIG,
                                                         G_PARAM_READWRITE |
                                                         G_PARAM_CONSTRUCT));
 }
@@ -131,20 +88,20 @@
 static void
 gimp_operation_levels_init (GimpOperationLevels *self)
 {
-  GimpHistogramChannel channel;
+}
 
-  self->channel = GIMP_HISTOGRAM_VALUE;
+static void
+gimp_operation_levels_finalize (GObject *object)
+{
+  GimpOperationLevels *self = GIMP_OPERATION_LEVELS (object);
 
-  for (channel = GIMP_HISTOGRAM_VALUE;
-       channel <= GIMP_HISTOGRAM_ALPHA;
-       channel++)
+  if (self->config)
     {
-      self->gamma[channel]       = 1.0;
-      self->low_input[channel]   = 0.0;
-      self->high_input[channel]  = 1.0;
-      self->low_output[channel]  = 0.0;
-      self->high_output[channel] = 1.0;
+      g_object_unref (self->config);
+      self->config = NULL;
     }
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
 static void
@@ -157,28 +114,8 @@
 
   switch (property_id)
     {
-    case PROP_CHANNEL:
-      g_value_set_enum (value, self->channel);
-      break;
-
-    case PROP_GAMMA:
-      g_value_set_double (value, self->gamma[self->channel]);
-      break;
-
-    case PROP_LOW_INPUT:
-      g_value_set_double (value, self->low_input[self->channel]);
-      break;
-
-    case PROP_HIGH_INPUT:
-      g_value_set_double (value, self->high_input[self->channel]);
-      break;
-
-    case PROP_LOW_OUTPUT:
-      g_value_set_double (value, self->low_output[self->channel]);
-      break;
-
-    case PROP_HIGH_OUTPUT:
-      g_value_set_double (value, self->high_output[self->channel]);
+    case PROP_CONFIG:
+      g_value_set_object (value, self->config);
       break;
 
     default:
@@ -197,28 +134,10 @@
 
   switch (property_id)
     {
-    case PROP_CHANNEL:
-      self->channel = g_value_get_enum (value);
-      break;
-
-    case PROP_GAMMA:
-      self->gamma[self->channel] = g_value_get_double (value);
-      break;
-
-    case PROP_LOW_INPUT:
-      self->low_input[self->channel] = g_value_get_double (value);
-      break;
-
-    case PROP_HIGH_INPUT:
-      self->high_input[self->channel] = g_value_get_double (value);
-      break;
-
-    case PROP_LOW_OUTPUT:
-      self->low_output[self->channel] = g_value_get_double (value);
-      break;
-
-    case PROP_HIGH_OUTPUT:
-      self->high_output[self->channel] = g_value_get_double (value);
+    case PROP_CONFIG:
+      if (self->config)
+        g_object_unref (self->config);
+      self->config = g_value_dup_object (value);
       break;
 
    default:
@@ -264,11 +183,15 @@
                                void          *out_buf,
                                glong          samples)
 {
-  GimpOperationLevels *self = GIMP_OPERATION_LEVELS (operation);
-  gfloat              *src  = in_buf;
-  gfloat              *dest = out_buf;
+  GimpOperationLevels *self   = GIMP_OPERATION_LEVELS (operation);
+  GimpLevelsConfig    *config = self->config;
+  gfloat              *src    = in_buf;
+  gfloat              *dest   = out_buf;
   glong                sample;
 
+  if (! config)
+    return FALSE;
+
   for (sample = 0; sample < samples; sample++)
     {
       gint channel;
@@ -278,20 +201,20 @@
           gdouble value;
 
           value = gimp_operation_levels_map (src[channel],
-                                             self->gamma[channel + 1],
-                                             self->low_input[channel + 1],
-                                             self->high_input[channel + 1],
-                                             self->low_output[channel + 1],
-                                             self->high_output[channel + 1]);
+                                             config->gamma[channel + 1],
+                                             config->low_input[channel + 1],
+                                             config->high_input[channel + 1],
+                                             config->low_output[channel + 1],
+                                             config->high_output[channel + 1]);
 
           /* don't apply the overall curve to the alpha channel */
           if (channel != ALPHA_PIX)
             value = gimp_operation_levels_map (value,
-                                               self->gamma[0],
-                                               self->low_input[0],
-                                               self->high_input[0],
-                                               self->low_output[0],
-                                               self->high_output[0]);
+                                               config->gamma[0],
+                                               config->low_input[0],
+                                               config->high_input[0],
+                                               config->low_output[0],
+                                               config->high_output[0]);
 
           dest[channel] = value;
         }

Modified: branches/weskaggs/app/gegl/gimpoperationlevels.h
==============================================================================
--- branches/weskaggs/app/gegl/gimpoperationlevels.h	(original)
+++ branches/weskaggs/app/gegl/gimpoperationlevels.h	Fri Jan 18 18:33:02 2008
@@ -40,15 +40,7 @@
 {
   GeglOperationPointFilter  parent_instance;
 
-  GimpHistogramChannel      channel;
-
-  gdouble                   gamma[5];
-
-  gdouble                   low_input[5];
-  gdouble                   high_input[5];
-
-  gdouble                   low_output[5];
-  gdouble                   high_output[5];
+  GimpLevelsConfig         *config;
 };
 
 struct _GimpOperationLevelsClass

Modified: branches/weskaggs/app/gegl/gimpoperationtilesink.c
==============================================================================
--- branches/weskaggs/app/gegl/gimpoperationtilesink.c	(original)
+++ branches/weskaggs/app/gegl/gimpoperationtilesink.c	Fri Jan 18 18:33:02 2008
@@ -24,7 +24,7 @@
 #include <string.h>
 
 #include <gegl.h>
-#include "gegl/buffer/gegl-buffer.h"
+#include <gegl-buffer.h>
 
 #include "gegl-types.h"
 
@@ -99,16 +99,15 @@
 
   gegl_operation_class_set_name (operation_class, "gimp-tilemanager-sink");;
 
-  g_object_class_install_property (object_class,
-                                   PROP_TILE_MANAGER,
+  g_object_class_install_property (object_class, PROP_TILE_MANAGER,
                                    g_param_spec_boxed ("tile-manager",
                                                        "Tile Manager",
                                                        "The tile manager to use as a destination",
                                                        GIMP_TYPE_TILE_MANAGER,
                                                        G_PARAM_READWRITE |
                                                        G_PARAM_CONSTRUCT));
-  g_object_class_install_property (object_class,
-                                   PROP_LINEAR,
+
+  g_object_class_install_property (object_class, PROP_LINEAR,
                                    g_param_spec_boolean ("linear",
                                                          "Linear data",
                                                          "Should the data written to the tile-manager be linear or gamma-corrected?",

Modified: branches/weskaggs/app/gegl/gimpoperationtilesource.c
==============================================================================
--- branches/weskaggs/app/gegl/gimpoperationtilesource.c	(original)
+++ branches/weskaggs/app/gegl/gimpoperationtilesource.c	Fri Jan 18 18:33:02 2008
@@ -24,7 +24,7 @@
 #include <string.h>
 
 #include <gegl.h>
-#include "gegl/buffer/gegl-buffer.h"
+#include <gegl-buffer.h>
 
 #include "gegl-types.h"
 
@@ -91,16 +91,15 @@
 
   gegl_operation_class_set_name (operation_class, "gimp-tilemanager-source");;
 
-  g_object_class_install_property (object_class,
-                                   PROP_TILE_MANAGER,
+  g_object_class_install_property (object_class, PROP_TILE_MANAGER,
                                    g_param_spec_boxed ("tile-manager",
                                                        "Tile Manager",
                                                        "The tile manager to use as source",
                                                        GIMP_TYPE_TILE_MANAGER,
                                                        G_PARAM_READWRITE |
                                                        G_PARAM_CONSTRUCT));
-  g_object_class_install_property (object_class,
-                                   PROP_LINEAR,
+
+  g_object_class_install_property (object_class, PROP_LINEAR,
                                    g_param_spec_boolean ("linear",
                                                          "Linear data",
                                                          "Should the data read from the tile-manager assumed to be linear or gamma-corrected?",

Modified: branches/weskaggs/app/tools/gimpcolorizetool.c
==============================================================================
--- branches/weskaggs/app/tools/gimpcolorizetool.c	(original)
+++ branches/weskaggs/app/tools/gimpcolorizetool.c	Fri Jan 18 18:33:02 2008
@@ -27,6 +27,8 @@
 
 #include "base/colorize.h"
 
+#include "gegl/gimpcolorizeconfig.h"
+
 #include "core/gimpdrawable.h"
 #include "core/gimpimage.h"
 #include "core/gimpimagemap.h"
@@ -126,6 +128,12 @@
 
   g_slice_free (Colorize, col_tool->colorize);
 
+  if (col_tool->config)
+    {
+      g_object_unref (col_tool->config);
+      col_tool->config = NULL;
+    }
+
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -147,7 +155,11 @@
       return FALSE;
     }
 
-  colorize_init (col_tool->colorize);
+  g_object_set (col_tool->config,
+                "hue",        0.5,
+                "saturation", 0.5,
+                "lightness",  0.0,
+                NULL);
 
   GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
 
@@ -161,23 +173,34 @@
 static GeglNode *
 gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool)
 {
-  return g_object_new (GEGL_TYPE_NODE,
+  GimpColorizeTool *tool = GIMP_COLORIZE_TOOL (im_tool);
+  GeglNode         *node;
+
+  node = g_object_new (GEGL_TYPE_NODE,
                        "operation", "gimp-colorize",
                        NULL);
+
+  tool->config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG, NULL);
+
+  gegl_node_set (node,
+                 "config", tool->config,
+                 NULL);
+
+  return node;
 }
 
 static void
 gimp_colorize_tool_map (GimpImageMapTool *image_map_tool)
 {
-  GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
+  GimpColorizeTool   *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
+  GimpColorizeConfig *config   = col_tool->config;
+  Colorize           *colorize = col_tool->colorize;
+
+  colorize->hue        = config->hue        * 360.0;
+  colorize->saturation = config->saturation * 100.0;
+  colorize->lightness  = config->lightness  * 100.0;
 
-  gegl_node_set (image_map_tool->operation,
-                 "hue",        col_tool->colorize->hue        / 360.0,
-                 "saturation", col_tool->colorize->saturation / 100.0,
-                 "lightness",  col_tool->colorize->lightness  / 100.0,
-                 NULL);
-
-  colorize_calculate (col_tool->colorize);
+  colorize_calculate (colorize);
 }
 
 
@@ -235,7 +258,7 @@
   slider = GIMP_SCALE_ENTRY_SCALE (data);
   gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_CONTINUOUS);
 
-  g_signal_connect (col_tool->saturation_data, "value-changed",
+  g_signal_connect (data, "value-changed",
                     G_CALLBACK (colorize_saturation_changed),
                     col_tool);
 
@@ -259,7 +282,11 @@
 {
   GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
 
-  colorize_init (col_tool->colorize);
+  g_object_set (col_tool->config,
+                "hue",        0.5,
+                "saturation", 0.5,
+                "lightness",  0.0,
+                NULL);
 
   colorize_update_sliders (col_tool);
 }
@@ -267,21 +294,25 @@
 static void
 colorize_update_sliders (GimpColorizeTool *col_tool)
 {
-  gtk_adjustment_set_value (GTK_ADJUSTMENT (col_tool->hue_data),
-                            col_tool->colorize->hue);
-  gtk_adjustment_set_value (GTK_ADJUSTMENT (col_tool->saturation_data),
-                            col_tool->colorize->saturation);
-  gtk_adjustment_set_value (GTK_ADJUSTMENT (col_tool->lightness_data),
-                            col_tool->colorize->lightness);
+  gtk_adjustment_set_value (col_tool->hue_data,
+                            col_tool->config->hue        * 360.0);
+  gtk_adjustment_set_value (col_tool->saturation_data,
+                            col_tool->config->saturation * 100.0);
+  gtk_adjustment_set_value (col_tool->lightness_data,
+                            col_tool->config->lightness  * 100.0);
 }
 
 static void
 colorize_hue_changed (GtkAdjustment    *adjustment,
                       GimpColorizeTool *col_tool)
 {
-  if (col_tool->colorize->hue != adjustment->value)
+  gdouble value = adjustment->value / 360.0;
+
+  if (col_tool->config->hue != value)
     {
-      col_tool->colorize->hue = adjustment->value;
+      g_object_set (col_tool->config,
+                    "hue", value,
+                    NULL);
 
       gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
     }
@@ -291,9 +322,13 @@
 colorize_saturation_changed (GtkAdjustment    *adjustment,
                              GimpColorizeTool *col_tool)
 {
-  if (col_tool->colorize->saturation != adjustment->value)
+  gdouble value = adjustment->value / 100.0;
+
+  if (col_tool->config->saturation != value)
     {
-      col_tool->colorize->saturation = adjustment->value;
+      g_object_set (col_tool->config,
+                    "saturation", value,
+                    NULL);
 
       gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
     }
@@ -303,9 +338,13 @@
 colorize_lightness_changed (GtkAdjustment    *adjustment,
                             GimpColorizeTool *col_tool)
 {
-  if (col_tool->colorize->lightness != adjustment->value)
+  gdouble value = adjustment->value / 100.0;
+
+  if (col_tool->config->lightness != value)
     {
-      col_tool->colorize->lightness = adjustment->value;
+      g_object_set (col_tool->config,
+                    "lightness", value,
+                    NULL);
 
       gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
     }

Modified: branches/weskaggs/app/tools/gimpcolorizetool.h
==============================================================================
--- branches/weskaggs/app/tools/gimpcolorizetool.h	(original)
+++ branches/weskaggs/app/tools/gimpcolorizetool.h	Fri Jan 18 18:33:02 2008
@@ -36,14 +36,15 @@
 
 struct _GimpColorizeTool
 {
-  GimpImageMapTool  parent_instance;
+  GimpImageMapTool    parent_instance;
 
-  Colorize         *colorize;
+  GimpColorizeConfig *config;
+  Colorize           *colorize;
 
   /*  dialog  */
-  GtkAdjustment    *hue_data;
-  GtkAdjustment    *saturation_data;
-  GtkAdjustment    *lightness_data;
+  GtkAdjustment      *hue_data;
+  GtkAdjustment      *saturation_data;
+  GtkAdjustment      *lightness_data;
 };
 
 struct _GimpColorizeToolClass

Modified: branches/weskaggs/app/tools/gimpeditselectiontool.c
==============================================================================
--- branches/weskaggs/app/tools/gimpeditselectiontool.c	(original)
+++ branches/weskaggs/app/tools/gimpeditselectiontool.c	Fri Jan 18 18:33:02 2008
@@ -64,23 +64,26 @@
 #define ARROW_VELOCITY          25
 
 
-static void    gimp_edit_selection_tool_button_release      (GimpTool              *tool,
-                                                             GimpCoords            *coords,
-                                                             guint32                time,
-                                                             GdkModifierType        state,
-                                                             GimpButtonReleaseType  release_type,
-                                                             GimpDisplay           *display);
-static void    gimp_edit_selection_tool_motion              (GimpTool              *tool,
-                                                             GimpCoords            *coords,
-                                                             guint32                time,
-                                                             GdkModifierType        state,
-                                                             GimpDisplay           *display);
-static void    gimp_edit_selection_tool_active_modifier_key (GimpTool              *tool,
-                                                             GdkModifierType        key,
-                                                             gboolean               press,
-                                                             GdkModifierType        state,
-                                                             GimpDisplay           *display);
-static void    gimp_edit_selection_tool_draw                (GimpDrawTool          *tool);
+static void       gimp_edit_selection_tool_button_release      (GimpTool                    *tool,
+                                                                GimpCoords                  *coords,
+                                                                guint32                      time,
+                                                                GdkModifierType              state,
+                                                                GimpButtonReleaseType        release_type,
+                                                                GimpDisplay                 *display);
+static void       gimp_edit_selection_tool_motion              (GimpTool                    *tool,
+                                                                GimpCoords                  *coords,
+                                                                guint32                      time,
+                                                                GdkModifierType              state,
+                                                                GimpDisplay                 *display);
+static void       gimp_edit_selection_tool_active_modifier_key (GimpTool                    *tool,
+                                                                GdkModifierType              key,
+                                                                gboolean                     press,
+                                                                GdkModifierType              state,
+                                                                GimpDisplay                 *display);
+static void       gimp_edit_selection_tool_draw                (GimpDrawTool                *tool);
+
+static GimpItem * gimp_edit_selection_tool_get_active_item     (const GimpEditSelectionTool *edit_select,
+                                                                const GimpImage             *image);
 
 
 G_DEFINE_TYPE (GimpEditSelectionTool, gimp_edit_selection_tool,
@@ -180,10 +183,8 @@
 
   edit_select->edit_mode = edit_mode;
 
-  if (edit_select->edit_mode == GIMP_TRANSLATE_MODE_VECTORS)
-    active_item = GIMP_ITEM (gimp_image_get_active_vectors (display->image));
-  else
-    active_item = GIMP_ITEM (gimp_image_get_active_drawable (display->image));
+  active_item = gimp_edit_selection_tool_get_active_item (edit_select,
+                                                          display->image);
 
   switch (edit_select->edit_mode)
     {
@@ -435,10 +436,8 @@
 
   tool_manager_pop_tool (display->image->gimp);
 
-  if (edit_select->edit_mode == GIMP_TRANSLATE_MODE_VECTORS)
-    active_item = GIMP_ITEM (gimp_image_get_active_vectors (display->image));
-  else
-    active_item = GIMP_ITEM (gimp_image_get_active_drawable (display->image));
+  active_item = gimp_edit_selection_tool_get_active_item (edit_select,
+                                                          display->image);
 
   gimp_edit_selection_tool_calc_coords (edit_select,
                                         coords->x,
@@ -549,10 +548,8 @@
 
   gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
 
-  if (edit_select->edit_mode == GIMP_TRANSLATE_MODE_VECTORS)
-    active_item = GIMP_ITEM (gimp_image_get_active_vectors (display->image));
-  else
-    active_item = GIMP_ITEM (gimp_image_get_active_drawable (display->image));
+  active_item = gimp_edit_selection_tool_get_active_item (edit_select,
+                                                          display->image);
 
   gimp_item_offsets (active_item, &off_x, &off_y);
 
@@ -716,10 +713,8 @@
   GimpDisplay           *display       = GIMP_TOOL (draw_tool)->display;
   GimpItem              *active_item;
 
-  if (edit_select->edit_mode == GIMP_TRANSLATE_MODE_VECTORS)
-    active_item = GIMP_ITEM (gimp_image_get_active_vectors (display->image));
-  else
-    active_item = GIMP_ITEM (gimp_image_get_active_drawable (display->image));
+  active_item = gimp_edit_selection_tool_get_active_item (edit_select,
+                                                          display->image);
 
   switch (edit_select->edit_mode)
     {
@@ -905,6 +900,20 @@
   GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
 }
 
+static GimpItem *
+gimp_edit_selection_tool_get_active_item (const GimpEditSelectionTool *edit_select,
+                                          const GimpImage             *image)
+{
+  GimpItem *active_item;
+
+  if (edit_select->edit_mode == GIMP_TRANSLATE_MODE_VECTORS)
+    active_item = GIMP_ITEM (gimp_image_get_active_vectors (image));
+  else
+    active_item = GIMP_ITEM (gimp_image_get_active_drawable (image));
+
+  return active_item;
+}
+
 static gint
 process_event_queue_keys (GdkEventKey *kevent,
                           ... /* GdkKeyType, GdkModifierType, value ... 0 */)

Modified: branches/weskaggs/app/tools/gimpimagemaptool.c
==============================================================================
--- branches/weskaggs/app/tools/gimpimagemaptool.c	(original)
+++ branches/weskaggs/app/tools/gimpimagemaptool.c	Fri Jan 18 18:33:02 2008
@@ -61,57 +61,60 @@
 
 /*  local function prototypes  */
 
-static void     gimp_image_map_tool_finalize   (GObject          *object);
-
-static gboolean gimp_image_map_tool_initialize (GimpTool         *tool,
-                                                GimpDisplay      *display,
-                                                GError          **error);
-static void     gimp_image_map_tool_control    (GimpTool         *tool,
-                                                GimpToolAction    action,
-                                                GimpDisplay      *display);
-static gboolean gimp_image_map_tool_key_press  (GimpTool         *tool,
-                                                GdkEventKey      *kevent,
-                                                GimpDisplay      *display);
-
-static gboolean gimp_image_map_tool_pick_color (GimpColorTool    *color_tool,
-                                                gint              x,
-                                                gint              y,
-                                                GimpImageType    *sample_type,
-                                                GimpRGB          *color,
-                                                gint             *color_index);
-static void     gimp_image_map_tool_map        (GimpImageMapTool *im_tool);
-static void     gimp_image_map_tool_dialog     (GimpImageMapTool *im_tool);
-static void     gimp_image_map_tool_reset      (GimpImageMapTool *im_tool);
-
-static void     gimp_image_map_tool_create_map (GimpImageMapTool *im_tool);
-
-static void     gimp_image_map_tool_flush      (GimpImageMap     *image_map,
-                                                GimpImageMapTool *im_tool);
-
-static void     gimp_image_map_tool_response   (GtkWidget        *widget,
-                                                gint              response_id,
-                                                GimpImageMapTool *im_tool);
-
-static void     gimp_image_map_tool_load_clicked     (GtkWidget        *widget,
-                                                      GimpImageMapTool *tool);
-static void     gimp_image_map_tool_load_ext_clicked (GtkWidget        *widget,
-                                                      GdkModifierType   state,
-                                                      GimpImageMapTool *tool);
-static void     gimp_image_map_tool_save_clicked     (GtkWidget        *widget,
-                                                      GimpImageMapTool *tool);
-static void     gimp_image_map_tool_save_ext_clicked (GtkWidget        *widget,
-                                                      GdkModifierType   state,
-                                                      GimpImageMapTool *tool);
-
-static void     gimp_image_map_tool_settings_dialog  (GimpImageMapTool *im_tool,
-                                                      const gchar      *title,
-                                                      gboolean          save);
-static void     gimp_image_map_tool_notify_preview   (GObject          *config,
-                                                      GParamSpec       *pspec,
-                                                      GimpImageMapTool *im_tool);
-static void     gimp_image_map_tool_gegl_notify      (GObject          *config,
-                                                      const GParamSpec *pspec,
-                                                      GimpImageMapTool *im_tool);
+static GObject * gimp_image_map_tool_constructor (GType             type,
+                                                  guint             n_params,
+                                                  GObjectConstructParam *params);
+static void      gimp_image_map_tool_finalize    (GObject          *object);
+
+static gboolean  gimp_image_map_tool_initialize  (GimpTool         *tool,
+                                                  GimpDisplay      *display,
+                                                  GError          **error);
+static void      gimp_image_map_tool_control     (GimpTool         *tool,
+                                                  GimpToolAction    action,
+                                                  GimpDisplay      *display);
+static gboolean  gimp_image_map_tool_key_press   (GimpTool         *tool,
+                                                  GdkEventKey      *kevent,
+                                                  GimpDisplay      *display);
+
+static gboolean  gimp_image_map_tool_pick_color  (GimpColorTool    *color_tool,
+                                                  gint              x,
+                                                  gint              y,
+                                                  GimpImageType    *sample_type,
+                                                  GimpRGB          *color,
+                                                  gint             *color_index);
+static void      gimp_image_map_tool_map         (GimpImageMapTool *im_tool);
+static void      gimp_image_map_tool_dialog      (GimpImageMapTool *im_tool);
+static void      gimp_image_map_tool_reset       (GimpImageMapTool *im_tool);
+
+static void      gimp_image_map_tool_create_map  (GimpImageMapTool *im_tool);
+
+static void      gimp_image_map_tool_flush       (GimpImageMap     *image_map,
+                                                  GimpImageMapTool *im_tool);
+
+static void      gimp_image_map_tool_response    (GtkWidget        *widget,
+                                                  gint              response_id,
+                                                  GimpImageMapTool *im_tool);
+
+static void      gimp_image_map_tool_load_clicked     (GtkWidget        *widget,
+                                                       GimpImageMapTool *tool);
+static void      gimp_image_map_tool_load_ext_clicked (GtkWidget        *widget,
+                                                       GdkModifierType   state,
+                                                       GimpImageMapTool *tool);
+static void      gimp_image_map_tool_save_clicked     (GtkWidget        *widget,
+                                                       GimpImageMapTool *tool);
+static void      gimp_image_map_tool_save_ext_clicked (GtkWidget        *widget,
+                                                       GdkModifierType   state,
+                                                       GimpImageMapTool *tool);
+
+static void      gimp_image_map_tool_settings_dialog  (GimpImageMapTool *im_tool,
+                                                       const gchar      *title,
+                                                       gboolean          save);
+static void      gimp_image_map_tool_notify_preview   (GObject          *config,
+                                                       GParamSpec       *pspec,
+                                                       GimpImageMapTool *im_tool);
+static void      gimp_image_map_tool_gegl_notify      (GObject          *config,
+                                                       const GParamSpec *pspec,
+                                                       GimpImageMapTool *im_tool);
 
 
 G_DEFINE_TYPE (GimpImageMapTool, gimp_image_map_tool, GIMP_TYPE_COLOR_TOOL)
@@ -126,27 +129,28 @@
   GimpToolClass      *tool_class       = GIMP_TOOL_CLASS (klass);
   GimpColorToolClass *color_tool_class = GIMP_COLOR_TOOL_CLASS (klass);
 
-  object_class->finalize   = gimp_image_map_tool_finalize;
+  object_class->constructor = gimp_image_map_tool_constructor;
+  object_class->finalize    = gimp_image_map_tool_finalize;
 
-  tool_class->initialize   = gimp_image_map_tool_initialize;
-  tool_class->control      = gimp_image_map_tool_control;
-  tool_class->key_press    = gimp_image_map_tool_key_press;
-
-  color_tool_class->pick   = gimp_image_map_tool_pick_color;
-
-  klass->shell_desc        = NULL;
-  klass->settings_name     = NULL;
-  klass->load_dialog_title = NULL;
-  klass->load_button_tip   = NULL;
-  klass->save_dialog_title = NULL;
-  klass->save_button_tip   = NULL;
-
-  klass->get_operation     = NULL;
-  klass->map               = NULL;
-  klass->dialog            = NULL;
-  klass->reset             = NULL;
-  klass->settings_load     = NULL;
-  klass->settings_save     = NULL;
+  tool_class->initialize    = gimp_image_map_tool_initialize;
+  tool_class->control       = gimp_image_map_tool_control;
+  tool_class->key_press     = gimp_image_map_tool_key_press;
+
+  color_tool_class->pick    = gimp_image_map_tool_pick_color;
+
+  klass->shell_desc         = NULL;
+  klass->settings_name      = NULL;
+  klass->load_dialog_title  = NULL;
+  klass->load_button_tip    = NULL;
+  klass->save_dialog_title  = NULL;
+  klass->save_button_tip    = NULL;
+
+  klass->get_operation      = NULL;
+  klass->map                = NULL;
+  klass->dialog             = NULL;
+  klass->reset              = NULL;
+  klass->settings_load      = NULL;
+  klass->settings_save      = NULL;
 }
 
 static void
@@ -173,6 +177,26 @@
   image_map_tool->settings_dialog = NULL;
 }
 
+static GObject *
+gimp_image_map_tool_constructor (GType                  type,
+                                 guint                  n_params,
+                                 GObjectConstructParam *params)
+{
+  GObject               *object;
+  GimpImageMapTool      *image_map_tool;
+  GimpImageMapToolClass *klass;
+
+  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
+
+  image_map_tool = GIMP_IMAGE_MAP_TOOL (object);
+  klass          = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);
+
+  if (klass->get_operation)
+    image_map_tool->operation = klass->get_operation (image_map_tool);
+
+  return object;
+}
+
 static void
 gimp_image_map_tool_finalize (GObject *object)
 {
@@ -323,7 +347,7 @@
 
       gtk_widget_show (vbox);
 
-      if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool)->get_operation)
+      if (image_map_tool->operation)
         g_signal_connect_object (tool_info->gimp->config, "notify::use-gegl",
                                  G_CALLBACK (gimp_image_map_tool_gegl_notify),
                                  image_map_tool, 0);
@@ -476,9 +500,6 @@
       g_object_unref (tool->image_map);
     }
 
-  if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->get_operation)
-    tool->operation = GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->get_operation (tool);
-
   g_assert (tool->operation || tool->apply_func);
 
   use_gegl = (config->use_gegl || ! tool->apply_func);

Modified: branches/weskaggs/app/tools/gimplevelstool.c
==============================================================================
--- branches/weskaggs/app/tools/gimplevelstool.c	(original)
+++ branches/weskaggs/app/tools/gimplevelstool.c	Fri Jan 18 18:33:02 2008
@@ -37,6 +37,8 @@
 #include "base/gimplut.h"
 #include "base/levels.h"
 
+#include "gegl/gimplevelsconfig.h"
+
 #include "core/gimpdrawable.h"
 #include "core/gimpdrawable-histogram.h"
 #include "core/gimpimage.h"
@@ -197,6 +199,12 @@
   gimp_lut_free (tool->lut);
   g_slice_free (Levels, tool->levels);
 
+  if (tool->config)
+    {
+      g_object_unref (tool->config);
+      tool->config = NULL;
+    }
+
   if (tool->hist)
     {
       gimp_histogram_free (tool->hist);
@@ -227,9 +235,9 @@
   if (! l_tool->hist)
     l_tool->hist = gimp_histogram_new ();
 
-  levels_init (l_tool->levels);
+  gimp_levels_config_reset (l_tool->config);
 
-  l_tool->channel = GIMP_HISTOGRAM_VALUE;
+  l_tool->channel = l_tool->config->channel;
   l_tool->color   = gimp_drawable_is_rgb (drawable);
   l_tool->alpha   = gimp_drawable_has_alpha (drawable);
 
@@ -245,10 +253,6 @@
   gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (l_tool->channel_menu),
                                  l_tool->channel);
 
-  /* FIXME: hack */
-  if (! l_tool->color)
-    l_tool->channel = (l_tool->channel == GIMP_HISTOGRAM_ALPHA) ? 1 : 0;
-
   levels_update_adjustments (l_tool);
 
   gimp_drawable_calculate_histogram (drawable, l_tool->hist);
@@ -261,47 +265,54 @@
 static GeglNode *
 gimp_levels_tool_get_operation (GimpImageMapTool *im_tool)
 {
-  return g_object_new (GEGL_TYPE_NODE,
+  GimpLevelsTool *tool = GIMP_LEVELS_TOOL (im_tool);
+  GeglNode       *node;
+
+  node = g_object_new (GEGL_TYPE_NODE,
                        "operation", "gimp-levels",
                        NULL);
+
+  tool->config = g_object_new (GIMP_TYPE_LEVELS_CONFIG, NULL);
+
+  gegl_node_set (node,
+                 "config", tool->config,
+                 NULL);
+
+  return node;
 }
 
 static void
 gimp_levels_tool_map (GimpImageMapTool *image_map_tool)
 {
-  GimpLevelsTool       *tool = GIMP_LEVELS_TOOL (image_map_tool);
+  GimpLevelsTool       *tool   = GIMP_LEVELS_TOOL (image_map_tool);
+  GimpLevelsConfig     *config = tool->config;
+  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);
+      levels->gamma[channel]       = config->gamma[channel];
+      levels->low_input[channel]   = config->low_input[channel]   * 255.999;
+      levels->high_input[channel]  = config->high_input[channel]  * 255.999;
+      levels->low_output[channel]  = config->low_output[channel]  * 255.999;
+      levels->high_output[channel] = config->high_output[channel] * 255.999;
+    }
 
-      gegl_node_set (image_map_tool->operation,
-                     "gamma",       tool->levels->gamma[channel],
-                     "low-input",   tool->levels->low_input[channel]   / 255.0,
-                     "high-input",  tool->levels->high_input[channel]  / 255.0,
-                     "low-output",  tool->levels->low_output[channel]  / 255.0,
-                     "high-output", tool->levels->high_output[channel] / 255.0,
-                     NULL);
-
-      /* FIXME: hack */
-      if (! tool->color && channel == 1)
-        break;
+  /* FIXME: hack */
+  if (! tool->color)
+    {
+      levels->gamma[1]       = levels->gamma[GIMP_HISTOGRAM_ALPHA];
+      levels->low_input[1]   = levels->low_input[GIMP_HISTOGRAM_ALPHA];
+      levels->high_input[1]  = levels->high_input[GIMP_HISTOGRAM_ALPHA];
+      levels->low_output[1]  = levels->low_output[GIMP_HISTOGRAM_ALPHA];
+      levels->high_output[1] = levels->high_output[GIMP_HISTOGRAM_ALPHA];
     }
 
   gimp_lut_setup (tool->lut,
                   (GimpLutFunc) levels_lut_func,
-                  tool->levels,
+                  levels,
                   gimp_drawable_bytes (image_map_tool->drawable));
 }
 
@@ -704,7 +715,7 @@
 {
   GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
 
-  levels_init (tool->levels);
+  gimp_levels_config_reset (tool->config);
   levels_update_adjustments (tool);
 }
 
@@ -754,12 +765,22 @@
 
   for (i = 0; i < 5; i++)
     {
-      tool->levels->low_input[i]   = low_input[i];
-      tool->levels->high_input[i]  = high_input[i];
-      tool->levels->low_output[i]  = low_output[i];
-      tool->levels->high_output[i] = high_output[i];
-      tool->levels->gamma[i]       = gamma[i];
-    }
+      g_object_set (tool->config,
+                    "channel", i,
+                    NULL);
+
+      g_object_set (tool->config,
+                    "low-input",   low_input[i]   / 255.0,
+                    "high-input",  high_input[i]  / 255.0,
+                    "low-output",  low_output[i]  / 255.0,
+                    "high-output", high_output[i] / 255.0,
+                    "gamma",       gamma[i],
+                    NULL);
+    }
+
+  g_object_set (tool->config,
+                "channel", tool->channel,
+                NULL);
 
   levels_update_adjustments (tool);
 
@@ -786,12 +807,12 @@
       gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
 
       fprintf (file, "%d %d %d %d %s\n",
-               tool->levels->low_input[i],
-               tool->levels->high_input[i],
-               tool->levels->low_output[i],
-               tool->levels->high_output[i],
+               (gint) (tool->config->low_input[i]   * 255.999),
+               (gint) (tool->config->high_input[i]  * 255.999),
+               (gint) (tool->config->low_output[i]  * 255.999),
+               (gint) (tool->config->high_output[i] * 255.999),
                g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
-                                tool->levels->gamma[i]));
+                                tool->config->gamma[i]));
     }
 
   return TRUE;
@@ -806,11 +827,11 @@
   tool->gamma_linear->upper = 255;
 
   gtk_adjustment_set_value (tool->low_input,
-                            tool->levels->low_input[tool->channel]);
+                            tool->config->low_input[tool->channel] * 255.0);
   gtk_adjustment_set_value (tool->gamma,
-                            tool->levels->gamma[tool->channel]);
+                            tool->config->gamma[tool->channel]);
   gtk_adjustment_set_value (tool->high_input,
-                            tool->levels->high_input[tool->channel]);
+                            tool->config->high_input[tool->channel] * 255.0);
 
   tool->low_input->upper    = tool->high_input->value;
   tool->high_input->lower   = tool->low_input->value;
@@ -821,9 +842,9 @@
   gtk_adjustment_changed (tool->gamma_linear);
 
   gtk_adjustment_set_value (tool->low_output,
-                            tool->levels->low_output[tool->channel]);
+                            tool->config->low_output[tool->channel] * 255.0);
   gtk_adjustment_set_value (tool->high_output,
-                            tool->levels->high_output[tool->channel]);
+                            tool->config->high_output[tool->channel] * 255.0);
 
   levels_update_input_bar (tool);
 }
@@ -831,25 +852,10 @@
 static void
 levels_update_input_bar (GimpLevelsTool *tool)
 {
-  GimpHistogramChannel channel;
-
-  if (tool->color)
-    {
-      channel = tool->channel;
-    }
-  else
-    {
-      /* FIXME: hack */
-      if (tool->channel == 1)
-        channel = GIMP_HISTOGRAM_ALPHA;
-      else
-        channel = GIMP_HISTOGRAM_VALUE;
-    }
-
   /*  Recalculate the transfer arrays  */
   levels_calculate_transfers (tool->levels);
 
-  switch (channel)
+  switch (tool->channel)
     {
     case GIMP_HISTOGRAM_VALUE:
     case GIMP_HISTOGRAM_ALPHA:
@@ -880,15 +886,16 @@
   if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value))
     {
       tool->channel = value;
+
+      g_object_set (tool->config,
+                    "channel", tool->channel,
+                    NULL);
+
       gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->hist_view),
                                        tool->channel);
       gimp_color_bar_set_channel (GIMP_COLOR_BAR (tool->output_bar),
                                   tool->channel);
 
-      /* FIXME: hack */
-      if (! tool->color)
-        tool->channel = (tool->channel == GIMP_HISTOGRAM_ALPHA) ? 1 : 0;
-
       levels_update_adjustments (tool);
     }
 }
@@ -897,7 +904,7 @@
 levels_channel_reset_callback (GtkWidget      *widget,
                                GimpLevelsTool *tool)
 {
-  levels_channel_reset (tool->levels, tool->channel);
+  gimp_levels_config_reset_channel (tool->config, tool->channel);
   levels_update_adjustments (tool);
 
   gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
@@ -934,7 +941,7 @@
 levels_stretch_callback (GtkWidget      *widget,
                          GimpLevelsTool *tool)
 {
-  levels_stretch (tool->levels, tool->hist, tool->color);
+  gimp_levels_config_stretch (tool->config, tool->hist, tool->color);
   levels_update_adjustments (tool);
 
   gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
@@ -947,7 +954,7 @@
 
   delta = (tool->high_input->value - tool->low_input->value) / 2.0;
   mid   = tool->low_input->value + delta;
-  tmp   = log10 (1.0 / tool->levels->gamma[tool->channel]);
+  tmp   = log10 (1.0 / tool->config->gamma[tool->channel]);
   value = mid + delta * tmp;
 
   gtk_adjustment_set_value (tool->gamma_linear, value);
@@ -985,9 +992,11 @@
   gtk_adjustment_changed (tool->high_input);
   gtk_adjustment_changed (tool->gamma_linear);
 
-  if (tool->levels->low_input[tool->channel] != value)
+  if (tool->config->low_input[tool->channel] != value / 255.0)
     {
-      tool->levels->low_input[tool->channel] = value;
+      g_object_set (tool->config,
+                    "low-input", value / 255.0,
+                    NULL);
       levels_update_input_bar (tool);
 
       gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
@@ -1000,9 +1009,11 @@
 levels_gamma_changed (GtkAdjustment  *adjustment,
                       GimpLevelsTool *tool)
 {
-  if (tool->levels->gamma[tool->channel] != adjustment->value)
+  if (tool->config->gamma[tool->channel] != adjustment->value)
     {
-      tool->levels->gamma[tool->channel] = adjustment->value;
+      g_object_set (tool->config,
+                    "gamma", adjustment->value,
+                    NULL);
       levels_update_input_bar (tool);
 
       gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
@@ -1022,9 +1033,11 @@
   gtk_adjustment_changed (tool->low_input);
   gtk_adjustment_changed (tool->gamma_linear);
 
-  if (tool->levels->high_input[tool->channel] != value)
+  if (tool->config->high_input[tool->channel] != value / 255.0)
     {
-      tool->levels->high_input[tool->channel] = value;
+      g_object_set (tool->config,
+                    "high-input", value / 255.0,
+                    NULL);
       levels_update_input_bar (tool);
 
       gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
@@ -1039,9 +1052,11 @@
 {
   gint value = ROUND (adjustment->value);
 
-  if (tool->levels->low_output[tool->channel] != value)
+  if (tool->config->low_output[tool->channel] != value / 255.0)
     {
-      tool->levels->low_output[tool->channel] = value;
+      g_object_set (tool->config,
+                    "low-output", value / 255.0,
+                    NULL);
 
       gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
     }
@@ -1053,9 +1068,11 @@
 {
   gint value = ROUND (adjustment->value);
 
-  if (tool->levels->high_output[tool->channel] != value)
+  if (tool->config->high_output[tool->channel] != value / 255.0)
     {
-      tool->levels->high_output[tool->channel] = value;
+      g_object_set (tool->config,
+                    "high-output", value / 255.0,
+                    NULL);
 
       gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
     }
@@ -1087,21 +1104,21 @@
 }
 
 static void
-levels_input_adjust_by_color (Levels               *levels,
+levels_input_adjust_by_color (GimpLevelsConfig     *config,
                               guint                 value,
                               GimpHistogramChannel  channel,
-                              guchar               *color)
+                              const GimpRGB        *color)
 {
   switch (value & 0xF)
     {
     case PICK_LOW_INPUT:
-      levels_adjust_by_colors (levels, channel, color, NULL, NULL);
+      gimp_levels_config_adjust_by_colors (config, channel, color, NULL, NULL);
       break;
     case PICK_GAMMA:
-      levels_adjust_by_colors (levels, channel, NULL, color, NULL);
+      gimp_levels_config_adjust_by_colors (config, channel, NULL, color, NULL);
       break;
     case PICK_HIGH_INPUT:
-      levels_adjust_by_colors (levels, channel, NULL, NULL, color);
+      gimp_levels_config_adjust_by_colors (config, channel, NULL, NULL, color);
       break;
     default:
       break;
@@ -1116,15 +1133,8 @@
                                gint                color_index)
 {
   GimpLevelsTool *tool = GIMP_LEVELS_TOOL (color_tool);
-  guchar          col[5];
   guint           value;
 
-  gimp_rgba_get_uchar (color,
-                       col + RED_PIX,
-                       col + GREEN_PIX,
-                       col + BLUE_PIX,
-                       col + ALPHA_PIX);
-
   value = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tool->active_picker),
                                                "pick-value"));
 
@@ -1136,13 +1146,13 @@
       switch (value & 0xF)
         {
         case PICK_LOW_INPUT:
-          tool->levels->low_input[GIMP_HISTOGRAM_VALUE] = 0;
+          tool->config->low_input[GIMP_HISTOGRAM_VALUE] = 0.0;
           break;
         case PICK_GAMMA:
-          tool->levels->gamma[GIMP_HISTOGRAM_VALUE] = 1.0;
+          tool->config->gamma[GIMP_HISTOGRAM_VALUE] = 1.0;
           break;
         case PICK_HIGH_INPUT:
-          tool->levels->high_input[GIMP_HISTOGRAM_VALUE] = 255;
+          tool->config->high_input[GIMP_HISTOGRAM_VALUE] = 1.0;
           break;
         default:
           break;
@@ -1153,14 +1163,14 @@
            channel <= GIMP_HISTOGRAM_BLUE;
            channel++)
         {
-          levels_input_adjust_by_color (tool->levels,
-                                        value, channel, col);
+          levels_input_adjust_by_color (tool->config,
+                                        value, channel, color);
         }
     }
   else
     {
-      levels_input_adjust_by_color (tool->levels,
-                                    value, tool->channel, col);
+      levels_input_adjust_by_color (tool->config,
+                                    value, tool->channel, color);
     }
 
   levels_update_adjustments (tool);

Modified: branches/weskaggs/app/tools/gimplevelstool.h
==============================================================================
--- branches/weskaggs/app/tools/gimplevelstool.h	(original)
+++ branches/weskaggs/app/tools/gimplevelstool.h	Fri Jan 18 18:33:02 2008
@@ -38,6 +38,7 @@
 {
   GimpImageMapTool      parent_instance;
 
+  GimpLevelsConfig     *config;
   GimpLut              *lut;
   Levels               *levels;
 



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