[gimp] pdb: add "sample-merged" as property to the PDB context



commit bb6083a1eb7ee4ac59bec0ff1f4828b9ba660da3
Author: Michael Natterer <mitch gimp org>
Date:   Thu Jan 27 19:37:13 2011 +0100

    pdb: add "sample-merged" as property to the PDB context
    
    - add API to get/set the new state
    - remove sample-merged parameters from the new gimp_image_select_foo() API
    - update procedure documentation

 app/pdb/context-cmds.c            |   91 +++++++++++++++++++++++++++++++++++++
 app/pdb/gimppdbcontext.c          |   14 ++++++
 app/pdb/gimppdbcontext.h          |    1 +
 app/pdb/image-select-cmds.c       |   45 ++++++------------
 app/pdb/internal-procs.c          |    2 +-
 libgimp/gimpcontext_pdb.c         |   68 +++++++++++++++++++++++++++
 libgimp/gimpcontext_pdb.h         |    2 +
 libgimp/gimpimageselect_pdb.c     |   30 +++++-------
 libgimp/gimpimageselect_pdb.h     |    2 -
 tools/pdbgen/pdb/context.pdb      |   58 +++++++++++++++++++++++
 tools/pdbgen/pdb/image_select.pdb |   47 ++++++++++---------
 11 files changed, 286 insertions(+), 74 deletions(-)
---
diff --git a/app/pdb/context-cmds.c b/app/pdb/context-cmds.c
index 0ba4dac..2e7e71e 100644
--- a/app/pdb/context-cmds.c
+++ b/app/pdb/context-cmds.c
@@ -770,6 +770,51 @@ context_set_feather_radius_invoker (GimpProcedure      *procedure,
 }
 
 static GValueArray *
+context_get_sample_merged_invoker (GimpProcedure      *procedure,
+                                   Gimp               *gimp,
+                                   GimpContext        *context,
+                                   GimpProgress       *progress,
+                                   const GValueArray  *args,
+                                   GError            **error)
+{
+  GValueArray *return_vals;
+  gboolean sample_merged = FALSE;
+
+  g_object_get (context,
+                "sample-merged", &sample_merged,
+                NULL);
+
+  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
+  g_value_set_boolean (&return_vals->values[1], sample_merged);
+
+  return return_vals;
+}
+
+static GValueArray *
+context_set_sample_merged_invoker (GimpProcedure      *procedure,
+                                   Gimp               *gimp,
+                                   GimpContext        *context,
+                                   GimpProgress       *progress,
+                                   const GValueArray  *args,
+                                   GError            **error)
+{
+  gboolean success = TRUE;
+  gboolean sample_merged;
+
+  sample_merged = g_value_get_boolean (&args->values[0]);
+
+  if (success)
+    {
+      g_object_set (context,
+                    "sample-merged", sample_merged,
+                    NULL);
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GValueArray *
 context_get_interpolation_invoker (GimpProcedure      *procedure,
                                    Gimp               *gimp,
                                    GimpContext        *context,
@@ -1679,6 +1724,52 @@ register_context_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-context-get-sample-merged
+   */
+  procedure = gimp_procedure_new (context_get_sample_merged_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-get-sample-merged");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-get-sample-merged",
+                                     "Get the sample merged setting.",
+                                     "This procedure returns the sample merged setting.",
+                                     "Michael Natterer <mitch gimp org>",
+                                     "Michael Natterer",
+                                     "2011",
+                                     NULL);
+  gimp_procedure_add_return_value (procedure,
+                                   g_param_spec_boolean ("sample-merged",
+                                                         "sample merged",
+                                                         "The sample merged setting",
+                                                         FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-context-set-sample-merged
+   */
+  procedure = gimp_procedure_new (context_set_sample_merged_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-set-sample-merged");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-set-sample-merged",
+                                     "Set the sample merged setting.",
+                                     "This procedure modifies the sample merged setting. If an operation depends on the colors of the pixels present in a drawable, like when doing a seed fill, this setting controls whether the pixel data from the specified drawable is used ('sample-merged' is FALSE), or the pixel data from the composite image ('sample-merged' is TRUE. This is equivalent to sampling for colors after merging all visible layers). This setting affects the following procedures: 'gimp-image-select-color', 'gimp-image-select-fuzzy'.",
+                                     "Michael Natterer <mitch gimp org>",
+                                     "Michael Natterer",
+                                     "2011",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_boolean ("sample-merged",
+                                                     "sample merged",
+                                                     "The sample merged setting",
+                                                     FALSE,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-context-get-interpolation
    */
   procedure = gimp_procedure_new (context_get_interpolation_invoker);
diff --git a/app/pdb/gimppdbcontext.c b/app/pdb/gimppdbcontext.c
index 9119162..b6cc39d 100644
--- a/app/pdb/gimppdbcontext.c
+++ b/app/pdb/gimppdbcontext.c
@@ -41,6 +41,7 @@ enum
   PROP_FEATHER,
   PROP_FEATHER_RADIUS_X,
   PROP_FEATHER_RADIUS_Y,
+  PROP_SAMPLE_MERGED,
   PROP_INTERPOLATION,
   PROP_TRANSFORM_DIRECTION,
   PROP_TRANSFORM_RESIZE,
@@ -94,6 +95,11 @@ gimp_pdb_context_class_init (GimpPDBContextClass *klass)
                                    0.0, 1000.0, 10.0,
                                    GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAMPLE_MERGED,
+                                    "sample-merged", NULL,
+                                    FALSE,
+                                    GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_INTERPOLATION,
                                  "interpolation", NULL,
                                  GIMP_TYPE_INTERPOLATION_TYPE,
@@ -169,6 +175,10 @@ gimp_pdb_context_set_property (GObject      *object,
       options->feather_radius_y = g_value_get_double (value);
       break;
 
+    case PROP_SAMPLE_MERGED:
+      options->sample_merged = g_value_get_boolean (value);
+      break;
+
     case PROP_INTERPOLATION:
       options->interpolation = g_value_get_enum (value);
       break;
@@ -217,6 +227,10 @@ gimp_pdb_context_get_property (GObject    *object,
       g_value_set_double (value, options->feather_radius_y);
       break;
 
+    case PROP_SAMPLE_MERGED:
+      g_value_set_boolean (value, options->sample_merged);
+      break;
+
     case PROP_INTERPOLATION:
       g_value_set_enum (value, options->interpolation);
       break;
diff --git a/app/pdb/gimppdbcontext.h b/app/pdb/gimppdbcontext.h
index 40ba0b7..c75c2ff 100644
--- a/app/pdb/gimppdbcontext.h
+++ b/app/pdb/gimppdbcontext.h
@@ -43,6 +43,7 @@ struct _GimpPDBContext
   gboolean                feather;
   gdouble                 feather_radius_x;
   gdouble                 feather_radius_y;
+  gboolean                sample_merged;
 
   GimpInterpolationType   interpolation;
   GimpTransformDirection  transform_direction;
diff --git a/app/pdb/image-select-cmds.c b/app/pdb/image-select-cmds.c
index 0c1cfa5..b45429d 100644
--- a/app/pdb/image-select-cmds.c
+++ b/app/pdb/image-select-cmds.c
@@ -55,7 +55,6 @@ image_select_color_invoker (GimpProcedure      *procedure,
   GimpDrawable *drawable;
   GimpRGB color;
   gint32 threshold;
-  gboolean sample_merged;
   gboolean select_transparent;
   gint32 select_criterion;
 
@@ -64,19 +63,18 @@ image_select_color_invoker (GimpProcedure      *procedure,
   drawable = gimp_value_get_drawable (&args->values[2], gimp);
   gimp_value_get_rgb (&args->values[3], &color);
   threshold = g_value_get_int (&args->values[4]);
-  sample_merged = g_value_get_boolean (&args->values[5]);
-  select_transparent = g_value_get_boolean (&args->values[6]);
-  select_criterion = g_value_get_enum (&args->values[7]);
+  select_transparent = g_value_get_boolean (&args->values[5]);
+  select_criterion = g_value_get_enum (&args->values[6]);
 
   if (success)
     {
-      if (sample_merged ||
+      GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
+
+      if (pdb_context->sample_merged ||
           gimp_pdb_item_is_attached (GIMP_ITEM (drawable), image, FALSE, error))
         {
-          GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
-
           gimp_channel_select_by_color (gimp_image_get_mask (image), drawable,
-                                        sample_merged,
+                                        pdb_context->sample_merged,
                                         &color,
                                         threshold,
                                         select_transparent,
@@ -191,7 +189,6 @@ image_select_fuzzy_invoker (GimpProcedure      *procedure,
   gdouble x;
   gdouble y;
   gint32 threshold;
-  gboolean sample_merged;
   gboolean select_transparent;
   gint32 select_criterion;
 
@@ -201,20 +198,20 @@ image_select_fuzzy_invoker (GimpProcedure      *procedure,
   x = g_value_get_double (&args->values[3]);
   y = g_value_get_double (&args->values[4]);
   threshold = g_value_get_int (&args->values[5]);
-  sample_merged = g_value_get_boolean (&args->values[6]);
-  select_transparent = g_value_get_boolean (&args->values[7]);
-  select_criterion = g_value_get_enum (&args->values[8]);
+  select_transparent = g_value_get_boolean (&args->values[6]);
+  select_criterion = g_value_get_enum (&args->values[7]);
 
   if (success)
     {
-      if (sample_merged ||
+      GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
+
+      if (pdb_context->sample_merged ||
           gimp_pdb_item_is_attached (GIMP_ITEM (drawable), image, FALSE, error))
         {
-          GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
 
           gimp_channel_select_fuzzy (gimp_image_get_mask (image),
                                      drawable,
-                                     sample_merged,
+                                     pdb_context->sample_merged,
                                      x, y,
                                      threshold,
                                      select_transparent,
@@ -373,7 +370,7 @@ register_image_select_procs (GimpPDB *pdb)
   gimp_procedure_set_static_strings (procedure,
                                      "gimp-image-select-color",
                                      "Create a selection by selecting all pixels (in the specified drawable) with the same (or similar) color to that specified.",
-                                     "This tool creates a selection over the specified image. A by-color selection is determined by the supplied color under the constraints of the specified threshold. Essentially, all pixels (in the drawable) that have color sufficiently close to the specified color (as determined by the threshold value) are included in the selection. To select transparent regions, the color specified must also have minimum alpha. If the 'sample-merged' parameter is TRUE, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored.",
+                                     "This tool creates a selection over the specified image. A by-color selection is determined by the supplied color under the constraints of the specified threshold. Essentially, all pixels (in the drawable) that have color sufficiently close to the specified color (as determined by the threshold value) are included in the selection. To select transparent regions, the color specified must also have minimum alpha. This prodecure is affected by the following context setters: 'gimp-context-set-antialias', 'gimp-context-set-feather', 'gimp-context-set-feather-radius', 'gimp-context-set-sample-merged'. In the case of a merged sampling, the supplied drawable is ignored.",
                                      "David Gowers",
                                      "David Gowers",
                                      "2010",
@@ -411,12 +408,6 @@ register_image_select_procs (GimpPDB *pdb)
                                                       0, 255, 0,
                                                       GIMP_PARAM_READWRITE));
   gimp_procedure_add_argument (procedure,
-                               g_param_spec_boolean ("sample-merged",
-                                                     "sample merged",
-                                                     "Use the composite image, not the drawable",
-                                                     FALSE,
-                                                     GIMP_PARAM_READWRITE));
-  gimp_procedure_add_argument (procedure,
                                g_param_spec_boolean ("select-transparent",
                                                      "select transparent",
                                                      "Whether to consider transparent pixels for selection. If TRUE, transparency is considered as a unique selectable color.",
@@ -536,8 +527,8 @@ register_image_select_procs (GimpPDB *pdb)
   gimp_procedure_set_static_strings (procedure,
                                      "gimp-image-select-fuzzy",
                                      "Create a fuzzy selection starting at the specified coordinates on the specified drawable.",
-                                     "This tool creates a fuzzy selection over the specified image. A fuzzy selection is determined by a seed fill under the constraints of the specified threshold. Essentially, the color at the specified coordinates (in the drawable) is measured and the selection expands outwards from that point to any adjacent pixels which are not significantly different (as determined by the threshold value). This process continues until no more expansion is possible. If antialiasing is turned on, the final selection mask will contain intermediate values based on close misses to the threshold bar at pixels along the seed fill boundary. If the 'sample-merged' parameter is TRUE, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored. If the sample is merged, the specified coordinates a
 re relative to the image origin; otherwise,"
-  "they are relative to the drawable's origin.",
+                                     "This tool creates a fuzzy selection over the specified image. A fuzzy selection is determined by a seed fill under the constraints of the specified threshold. Essentially, the color at the specified coordinates (in the drawable) is measured and the selection expands outwards from that point to any adjacent pixels which are not significantly different (as determined by the threshold value). This process continues until no more expansion is possible. If antialiasing is turned on, the final selection mask will contain intermediate values based on close misses to the threshold bar at pixels along the seed fill boundary. This prodecure is affected by the following context setters: 'gimp-context-set-antialias', 'gimp-context-set-feather', 'gimp-context-set-feather-radius', 'gimp-context-set-sample-merged'. In the case of a merged sampling, the supplied drawable is ignored. If the sample is merged, the specified coordinates are relative to the 
 image origin; otherwise, they are relative to"
+  "the drawable's origin.",
                                      "David Gowers",
                                      "David Gowers",
                                      "2010",
@@ -580,12 +571,6 @@ register_image_select_procs (GimpPDB *pdb)
                                                       0, 255, 0,
                                                       GIMP_PARAM_READWRITE));
   gimp_procedure_add_argument (procedure,
-                               g_param_spec_boolean ("sample-merged",
-                                                     "sample merged",
-                                                     "Use the composite image, not the drawable",
-                                                     FALSE,
-                                                     GIMP_PARAM_READWRITE));
-  gimp_procedure_add_argument (procedure,
                                g_param_spec_boolean ("select-transparent",
                                                      "select transparent",
                                                      "Whether to consider transparent pixels for selection. If TRUE, transparency is considered as a unique selectable color.",
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 2050726..466694e 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 640 procedures registered total */
+/* 642 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)
diff --git a/libgimp/gimpcontext_pdb.c b/libgimp/gimpcontext_pdb.c
index 68e4de0..78ff5fb 100644
--- a/libgimp/gimpcontext_pdb.c
+++ b/libgimp/gimpcontext_pdb.c
@@ -1076,6 +1076,74 @@ gimp_context_set_feather_radius (gdouble feather_radius_x,
 }
 
 /**
+ * gimp_context_get_sample_merged:
+ *
+ * Get the sample merged setting.
+ *
+ * This procedure returns the sample merged setting.
+ *
+ * Returns: The sample merged setting.
+ *
+ * Since: GIMP 2.8
+ **/
+gboolean
+gimp_context_get_sample_merged (void)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gboolean sample_merged = FALSE;
+
+  return_vals = gimp_run_procedure ("gimp-context-get-sample-merged",
+                                    &nreturn_vals,
+                                    GIMP_PDB_END);
+
+  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+    sample_merged = return_vals[1].data.d_int32;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return sample_merged;
+}
+
+/**
+ * gimp_context_set_sample_merged:
+ * @sample_merged: The sample merged setting.
+ *
+ * Set the sample merged setting.
+ *
+ * This procedure modifies the sample merged setting. If an operation
+ * depends on the colors of the pixels present in a drawable, like when
+ * doing a seed fill, this setting controls whether the pixel data from
+ * the specified drawable is used ('sample-merged' is FALSE), or the
+ * pixel data from the composite image ('sample-merged' is TRUE. This
+ * is equivalent to sampling for colors after merging all visible
+ * layers). This setting affects the following procedures:
+ * gimp_image_select_color(), gimp_image_select_fuzzy().
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: GIMP 2.8
+ **/
+gboolean
+gimp_context_set_sample_merged (gboolean sample_merged)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gboolean success = TRUE;
+
+  return_vals = gimp_run_procedure ("gimp-context-set-sample-merged",
+                                    &nreturn_vals,
+                                    GIMP_PDB_INT32, sample_merged,
+                                    GIMP_PDB_END);
+
+  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return success;
+}
+
+/**
  * gimp_context_get_interpolation:
  *
  * Get the interpolation type.
diff --git a/libgimp/gimpcontext_pdb.h b/libgimp/gimpcontext_pdb.h
index 2822982..73b79d9 100644
--- a/libgimp/gimpcontext_pdb.h
+++ b/libgimp/gimpcontext_pdb.h
@@ -62,6 +62,8 @@ gboolean               gimp_context_get_feather_radius      (gdouble
                                                              gdouble                  *feather_radius_y);
 gboolean               gimp_context_set_feather_radius      (gdouble                   feather_radius_x,
                                                              gdouble                   feather_radius_y);
+gboolean               gimp_context_get_sample_merged       (void);
+gboolean               gimp_context_set_sample_merged       (gboolean                  sample_merged);
 GimpInterpolationType  gimp_context_get_interpolation       (void);
 gboolean               gimp_context_set_interpolation       (GimpInterpolationType     interpolation);
 GimpTransformDirection gimp_context_get_transform_direction (void);
diff --git a/libgimp/gimpimageselect_pdb.c b/libgimp/gimpimageselect_pdb.c
index edf5520..e2e36a0 100644
--- a/libgimp/gimpimageselect_pdb.c
+++ b/libgimp/gimpimageselect_pdb.c
@@ -41,7 +41,6 @@
  * @drawable_ID: The affected drawable.
  * @color: The color to select.
  * @threshold: Threshold in intensity levels.
- * @sample_merged: Use the composite image, not the drawable.
  * @select_transparent: Whether to consider transparent pixels for selection. If TRUE, transparency is considered as a unique selectable color.
  * @select_criterion: The criterion used to determine color similarity. SELECT_CRITERION_COMPOSITE is the standard choice.
  *
@@ -54,11 +53,11 @@
  * drawable) that have color sufficiently close to the specified color
  * (as determined by the threshold value) are included in the
  * selection. To select transparent regions, the color specified must
- * also have minimum alpha. If the 'sample-merged' parameter is TRUE,
- * the data of the composite image will be used instead of that for the
- * specified drawable. This is equivalent to sampling for colors after
- * merging all visible layers. In the case of a merged sampling, the
- * supplied drawable is ignored.
+ * also have minimum alpha. This prodecure is affected by the following
+ * context setters: gimp_context_set_antialias(),
+ * gimp_context_set_feather(), gimp_context_set_feather_radius(),
+ * gimp_context_set_sample_merged(). In the case of a merged sampling,
+ * the supplied drawable is ignored.
  *
  * Returns: TRUE on success.
  *
@@ -70,7 +69,6 @@ gimp_image_select_color (gint32               image_ID,
                          gint32               drawable_ID,
                          const GimpRGB       *color,
                          gint                 threshold,
-                         gboolean             sample_merged,
                          gboolean             select_transparent,
                          GimpSelectCriterion  select_criterion)
 {
@@ -85,7 +83,6 @@ gimp_image_select_color (gint32               image_ID,
                                     GIMP_PDB_DRAWABLE, drawable_ID,
                                     GIMP_PDB_COLOR, color,
                                     GIMP_PDB_INT32, threshold,
-                                    GIMP_PDB_INT32, sample_merged,
                                     GIMP_PDB_INT32, select_transparent,
                                     GIMP_PDB_INT32, select_criterion,
                                     GIMP_PDB_END);
@@ -206,7 +203,6 @@ gimp_image_select_polygon (gint32          image_ID,
  * @x: x coordinate of initial seed fill point: (image coordinates).
  * @y: y coordinate of initial seed fill point: (image coordinates).
  * @threshold: Threshold in intensity levels.
- * @sample_merged: Use the composite image, not the drawable.
  * @select_transparent: Whether to consider transparent pixels for selection. If TRUE, transparency is considered as a unique selectable color.
  * @select_criterion: The criterion used to determine color similarity. SELECT_CRITERION_COMPOSITE is the standard choice.
  *
@@ -222,13 +218,13 @@ gimp_image_select_polygon (gint32          image_ID,
  * process continues until no more expansion is possible. If
  * antialiasing is turned on, the final selection mask will contain
  * intermediate values based on close misses to the threshold bar at
- * pixels along the seed fill boundary. If the 'sample-merged'
- * parameter is TRUE, the data of the composite image will be used
- * instead of that for the specified drawable. This is equivalent to
- * sampling for colors after merging all visible layers. In the case of
- * a merged sampling, the supplied drawable is ignored. If the sample
- * is merged, the specified coordinates are relative to the image
- * origin; otherwise, they are relative to the drawable's origin.
+ * pixels along the seed fill boundary. This prodecure is affected by
+ * the following context setters: gimp_context_set_antialias(),
+ * gimp_context_set_feather(), gimp_context_set_feather_radius(),
+ * gimp_context_set_sample_merged(). In the case of a merged sampling,
+ * the supplied drawable is ignored. If the sample is merged, the
+ * specified coordinates are relative to the image origin; otherwise,
+ * they are relative to the drawable's origin.
  *
  * Returns: TRUE on success.
  *
@@ -241,7 +237,6 @@ gimp_image_select_fuzzy (gint32              image_ID,
                          gdouble             x,
                          gdouble             y,
                          gint                threshold,
-                         gboolean            sample_merged,
                          gboolean            select_transparent,
                          GimpSelectCriterion select_criterion)
 {
@@ -257,7 +252,6 @@ gimp_image_select_fuzzy (gint32              image_ID,
                                     GIMP_PDB_FLOAT, x,
                                     GIMP_PDB_FLOAT, y,
                                     GIMP_PDB_INT32, threshold,
-                                    GIMP_PDB_INT32, sample_merged,
                                     GIMP_PDB_INT32, select_transparent,
                                     GIMP_PDB_INT32, select_criterion,
                                     GIMP_PDB_END);
diff --git a/libgimp/gimpimageselect_pdb.h b/libgimp/gimpimageselect_pdb.h
index 7d68f7a..27ecc9b 100644
--- a/libgimp/gimpimageselect_pdb.h
+++ b/libgimp/gimpimageselect_pdb.h
@@ -33,7 +33,6 @@ gboolean gimp_image_select_color           (gint32               image_ID,
                                             gint32               drawable_ID,
                                             const GimpRGB       *color,
                                             gint                 threshold,
-                                            gboolean             sample_merged,
                                             gboolean             select_transparent,
                                             GimpSelectCriterion  select_criterion);
 gboolean gimp_image_select_ellipse         (gint32               image_ID,
@@ -52,7 +51,6 @@ gboolean gimp_image_select_fuzzy           (gint32               image_ID,
                                             gdouble              x,
                                             gdouble              y,
                                             gint                 threshold,
-                                            gboolean             sample_merged,
                                             gboolean             select_transparent,
                                             GimpSelectCriterion  select_criterion);
 gboolean gimp_image_select_rectangle       (gint32               image_ID,
diff --git a/tools/pdbgen/pdb/context.pdb b/tools/pdbgen/pdb/context.pdb
index f569b26..2bc00d9 100644
--- a/tools/pdbgen/pdb/context.pdb
+++ b/tools/pdbgen/pdb/context.pdb
@@ -872,6 +872,63 @@ CODE
     );
 }
 
+sub context_get_sample_merged {
+    $blurb = 'Get the sample merged setting.';
+
+    $help = <<'HELP';
+This procedure returns the sample merged setting.
+HELP
+
+    &mitch_pdb_misc('2011', '2.8');
+
+    @outargs = (
+        { name => 'sample_merged', type => 'boolean',
+          desc => 'The sample merged setting' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  g_object_get (context,
+                "sample-merged", &sample_merged,
+                NULL);
+}
+CODE
+    );
+}
+
+sub context_set_sample_merged {
+    $blurb = 'Set the sample merged setting.';
+
+    $help = <<'HELP';
+This procedure modifies the sample merged setting. If an operation
+depends on the colors of the pixels present in a drawable, like when
+doing a seed fill, this setting controls whether the pixel data from
+the specified drawable is used ('sample-merged' is FALSE), or the
+pixel data from the composite image ('sample-merged' is TRUE. This is
+equivalent to sampling for colors after merging all visible
+layers). This setting affects the following procedures:
+gimp_image_select_color(), gimp_image_select_fuzzy().
+HELP
+
+    &mitch_pdb_misc('2011', '2.8');
+
+    @inargs = (
+        { name => 'sample_merged', type => 'boolean',
+          desc => 'The sample merged setting' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  g_object_set (context,
+                "sample-merged", sample_merged,
+                NULL);
+}
+CODE
+    );
+}
+
 sub context_get_interpolation {
     $blurb = 'Get the interpolation type.';
 
@@ -1114,6 +1171,7 @@ CODE
             context_get_antialias context_set_antialias
             context_get_feather context_set_feather
             context_get_feather_radius context_set_feather_radius
+            context_get_sample_merged context_set_sample_merged
             context_get_interpolation context_set_interpolation
             context_get_transform_direction context_set_transform_direction
             context_get_transform_resize context_set_transform_resize
diff --git a/tools/pdbgen/pdb/image_select.pdb b/tools/pdbgen/pdb/image_select.pdb
index 96949a0..242c5a5 100644
--- a/tools/pdbgen/pdb/image_select.pdb
+++ b/tools/pdbgen/pdb/image_select.pdb
@@ -29,11 +29,13 @@ the specified threshold. Essentially, all pixels (in the drawable)
 that have color sufficiently close to the specified color (as
 determined by the threshold value) are included in the selection. To
 select transparent regions, the color specified must also have minimum
-alpha. If the 'sample-merged' parameter is TRUE, the data of the
-composite image will be used instead of that for the specified
-drawable.  This is equivalent to sampling for colors after merging all
-visible layers. In the case of a merged sampling, the supplied
-drawable is ignored.
+alpha.
+
+This prodecure is affected by the following context setters:
+gimp_context_set_antialias(), gimp_context_set_feather(),
+gimp_context_set_feather_radius(), gimp_context_set_sample_merged().
+
+In the case of a merged sampling, the supplied drawable is ignored.
 HELP
 
     &david_pdb_misc('2010', '2.8');
@@ -49,8 +51,6 @@ HELP
 	  desc => 'The color to select' },
 	{ name => 'threshold', type => '0 <= int32 <= 255',
 	  desc => 'Threshold in intensity levels' },
-	{ name => 'sample_merged', type => 'boolean',
-	  desc => 'Use the composite image, not the drawable' },
         { name => 'select_transparent', type => 'boolean',
           desc => "Whether to consider transparent pixels for selection.
                    If TRUE, transparency is considered as a unique selectable
@@ -64,13 +64,13 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (sample_merged ||
+  GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
+
+  if (pdb_context->sample_merged ||
       gimp_pdb_item_is_attached (GIMP_ITEM (drawable), image, FALSE, error))
     {
-      GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
-
       gimp_channel_select_by_color (gimp_image_get_mask (image), drawable,
-                                    sample_merged,
+                                    pdb_context->sample_merged,
                                     &color,
                                     threshold,
                                     select_transparent,
@@ -209,13 +209,15 @@ significantly different (as determined by the threshold value). This
 process continues until no more expansion is possible. If antialiasing
 is turned on, the final selection mask will contain intermediate
 values based on close misses to the threshold bar at pixels along the
-seed fill boundary. If the 'sample-merged' parameter is TRUE, the data
-of the composite image will be used instead of that for the specified
-drawable.  This is equivalent to sampling for colors after merging all
-visible layers. In the case of a merged sampling, the supplied
-drawable is ignored. If the sample is merged, the specified
-coordinates are relative to the image origin; otherwise, they are
-relative to the drawable's origin.
+seed fill boundary.
+
+This prodecure is affected by the following context setters:
+gimp_context_set_antialias(), gimp_context_set_feather(),
+gimp_context_set_feather_radius(), gimp_context_set_sample_merged().
+
+In the case of a merged sampling, the supplied drawable is ignored.
+If the sample is merged, the specified coordinates are relative to the
+image origin; otherwise, they are relative to the drawable's origin.
 HELP
 
     &david_pdb_misc('2010', '2.8');
@@ -235,8 +237,6 @@ HELP
 	  	   coordinates)' },
 	{ name => 'threshold', type => '0 <= int32 <= 255',
 	  desc => 'Threshold in intensity levels' },
-	{ name => 'sample_merged', type => 'boolean',
-	  desc => 'Use the composite image, not the drawable' },
 	{ name => 'select_transparent', type => 'boolean',
           desc => "Whether to consider transparent pixels for selection.
                    If TRUE, transparency is considered as a unique selectable
@@ -250,14 +250,15 @@ HELP
     %invoke = (
 	code => <<'CODE'
 {
-  if (sample_merged ||
+  GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
+
+  if (pdb_context->sample_merged ||
       gimp_pdb_item_is_attached (GIMP_ITEM (drawable), image, FALSE, error))
     {
-      GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
 
       gimp_channel_select_fuzzy (gimp_image_get_mask (image),
                                  drawable,
-                                 sample_merged,
+                                 pdb_context->sample_merged,
                                  x, y,
                                  threshold,
                                  select_transparent,



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