[gimp] pdb: add "sample-threshold" as GimpPDBContext property



commit 2e16d932ecd2647d6d2f816e1594d7eaef807e63
Author: Michael Natterer <mitch gimp org>
Date:   Fri Feb 4 15:36:56 2011 +0100

    pdb: add "sample-threshold" as GimpPDBContext property
    
    and add PDB API to get/set it.

 app/pdb/context-cmds.c       |  188 +++++++++++++++++++++++++++++++++++++++++-
 app/pdb/gimppdbcontext.c     |   29 +++++++
 app/pdb/gimppdbcontext.h     |    1 +
 app/pdb/internal-procs.c     |    2 +-
 libgimp/gimp.def             |    4 +
 libgimp/gimpcontext_pdb.c    |  132 +++++++++++++++++++++++++++++-
 libgimp/gimpcontext_pdb.h    |   96 +++++++++++----------
 tools/pdbgen/pdb/context.pdb |  118 ++++++++++++++++++++++++++-
 8 files changed, 520 insertions(+), 50 deletions(-)
---
diff --git a/app/pdb/context-cmds.c b/app/pdb/context-cmds.c
index 110db77..f711a0a 100644
--- a/app/pdb/context-cmds.c
+++ b/app/pdb/context-cmds.c
@@ -860,6 +860,100 @@ context_set_sample_criterion_invoker (GimpProcedure      *procedure,
 }
 
 static GValueArray *
+context_get_sample_threshold_invoker (GimpProcedure      *procedure,
+                                      Gimp               *gimp,
+                                      GimpContext        *context,
+                                      GimpProgress       *progress,
+                                      const GValueArray  *args,
+                                      GError            **error)
+{
+  GValueArray *return_vals;
+  gdouble sample_threshold = 0.0;
+
+  g_object_get (context,
+                "sample-threshold", &sample_threshold,
+                NULL);
+
+  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
+  g_value_set_double (&return_vals->values[1], sample_threshold);
+
+  return return_vals;
+}
+
+static GValueArray *
+context_set_sample_threshold_invoker (GimpProcedure      *procedure,
+                                      Gimp               *gimp,
+                                      GimpContext        *context,
+                                      GimpProgress       *progress,
+                                      const GValueArray  *args,
+                                      GError            **error)
+{
+  gboolean success = TRUE;
+  gdouble sample_threshold;
+
+  sample_threshold = g_value_get_double (&args->values[0]);
+
+  if (success)
+    {
+      g_object_set (context,
+                    "sample-threshold", sample_threshold,
+                    NULL);
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GValueArray *
+context_get_sample_threshold_int_invoker (GimpProcedure      *procedure,
+                                          Gimp               *gimp,
+                                          GimpContext        *context,
+                                          GimpProgress       *progress,
+                                          const GValueArray  *args,
+                                          GError            **error)
+{
+  GValueArray *return_vals;
+  gint32 sample_threshold = 0;
+
+  gdouble threshold;
+
+  g_object_get (context,
+                "sample-threshold", &threshold,
+                NULL);
+
+  sample_threshold = (gint) (threshold * 255.99);
+
+  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
+  g_value_set_int (&return_vals->values[1], sample_threshold);
+
+  return return_vals;
+}
+
+static GValueArray *
+context_set_sample_threshold_int_invoker (GimpProcedure      *procedure,
+                                          Gimp               *gimp,
+                                          GimpContext        *context,
+                                          GimpProgress       *progress,
+                                          const GValueArray  *args,
+                                          GError            **error)
+{
+  gboolean success = TRUE;
+  gint32 sample_threshold;
+
+  sample_threshold = g_value_get_int (&args->values[0]);
+
+  if (success)
+    {
+      g_object_set (context,
+                    "sample-threshold", (gdouble) sample_threshold / 255.0,
+                    NULL);
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GValueArray *
 context_get_interpolation_invoker (GimpProcedure      *procedure,
                                    Gimp               *gimp,
                                    GimpContext        *context,
@@ -1846,7 +1940,7 @@ register_context_procs (GimpPDB *pdb)
                                "gimp-context-set-sample-criterion");
   gimp_procedure_set_static_strings (procedure,
                                      "gimp-context-set-sample-criterion",
-                                     "Set the sample merged setting.",
+                                     "Set the sample criterion setting.",
                                      "This procedure modifies the sample criterion setting. If an operation depends on the colors of the pixels present in a drawable, like when doing a seed fill, this setting controls how color similarity is determined. SELECT_CRITERION_COMPOSITE is the default value. This setting affects the following procedures: 'gimp-image-select-color', 'gimp-image-select-fuzzy'.",
                                      "Michael Natterer <mitch gimp org>",
                                      "Michael Natterer",
@@ -1863,6 +1957,98 @@ register_context_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-context-get-sample-threshold
+   */
+  procedure = gimp_procedure_new (context_get_sample_threshold_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-get-sample-threshold");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-get-sample-threshold",
+                                     "Get the sample threshold setting.",
+                                     "This procedure returns the sample threshold setting.",
+                                     "Michael Natterer <mitch gimp org>",
+                                     "Michael Natterer",
+                                     "2011",
+                                     NULL);
+  gimp_procedure_add_return_value (procedure,
+                                   g_param_spec_double ("sample-threshold",
+                                                        "sample threshold",
+                                                        "The sample threshold setting",
+                                                        0.0, 1.0, 0.0,
+                                                        GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-context-set-sample-threshold
+   */
+  procedure = gimp_procedure_new (context_set_sample_threshold_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-set-sample-threshold");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-set-sample-threshold",
+                                     "Set the sample threshold setting.",
+                                     "This procedure modifies the sample threshold setting. If an operation depends on the colors of the pixels present in a drawable, like when doing a seed fill, this setting controls what is \"sufficiently close\" to be considered a similar color. If the sample threshold has not been set explicitly, the default threshold set in gimprc will be used. 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_double ("sample-threshold",
+                                                    "sample threshold",
+                                                    "The sample threshold setting",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-context-get-sample-threshold-int
+   */
+  procedure = gimp_procedure_new (context_get_sample_threshold_int_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-get-sample-threshold-int");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-get-sample-threshold-int",
+                                     "Get the sample threshold setting as an integer value.",
+                                     "This procedure returns the sample threshold setting as an integer value. See 'gimp-context-get-sample-threshold'.",
+                                     "Michael Natterer <mitch gimp org>",
+                                     "Michael Natterer",
+                                     "2011",
+                                     NULL);
+  gimp_procedure_add_return_value (procedure,
+                                   gimp_param_spec_int32 ("sample-threshold",
+                                                          "sample threshold",
+                                                          "The sample threshold setting",
+                                                          0, 255, 0,
+                                                          GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-context-set-sample-threshold-int
+   */
+  procedure = gimp_procedure_new (context_set_sample_threshold_int_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-set-sample-threshold-int");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-set-sample-threshold-int",
+                                     "Set the sample threshold setting as an integer value.",
+                                     "This procedure modifies the sample threshold setting as an integer value. See 'gimp-context-set-sample-threshold'.",
+                                     "Michael Natterer <mitch gimp org>",
+                                     "Michael Natterer",
+                                     "2011",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("sample-threshold",
+                                                      "sample threshold",
+                                                      "The sample threshold setting",
+                                                      0, 255, 0,
+                                                      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 49eaa38..4777420 100644
--- a/app/pdb/gimppdbcontext.c
+++ b/app/pdb/gimppdbcontext.c
@@ -43,6 +43,7 @@ enum
   PROP_FEATHER_RADIUS_Y,
   PROP_SAMPLE_MERGED,
   PROP_SAMPLE_CRITERION,
+  PROP_SAMPLE_THRESHOLD,
   PROP_INTERPOLATION,
   PROP_TRANSFORM_DIRECTION,
   PROP_TRANSFORM_RESIZE,
@@ -107,6 +108,11 @@ gimp_pdb_context_class_init (GimpPDBContextClass *klass)
                                  GIMP_SELECT_CRITERION_COMPOSITE,
                                  GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_SAMPLE_THRESHOLD,
+                                   "sample-threshold", NULL,
+                                   0.0, 1.0, 0.0,
+                                   GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_INTERPOLATION,
                                  "interpolation", NULL,
                                  GIMP_TYPE_INTERPOLATION_TYPE,
@@ -140,8 +146,11 @@ static void
 gimp_pdb_context_constructed (GObject *object)
 {
   GimpInterpolationType  interpolation;
+  gint                   threshold;
   GParamSpec            *pspec;
 
+  /* get default interpolation from gimprc */
+
   interpolation = GIMP_CONTEXT (object)->gimp->config->interpolation_type;
 
   pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
@@ -152,6 +161,18 @@ gimp_pdb_context_constructed (GObject *object)
 
   g_object_set (object, "interpolation", interpolation, NULL);
 
+  /* get default threshold from gimprc */
+
+  threshold = GIMP_CONTEXT (object)->gimp->config->default_threshold;
+
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
+                                        "sample-threshold");
+
+  if (pspec)
+    G_PARAM_SPEC_DOUBLE (pspec)->default_value = threshold / 255.0;
+
+  g_object_set (object, "sample-threshold", threshold / 255.0, NULL);
+
   if (G_OBJECT_CLASS (parent_class)->constructed)
     G_OBJECT_CLASS (parent_class)->constructed (object);
 }
@@ -190,6 +211,10 @@ gimp_pdb_context_set_property (GObject      *object,
       options->sample_criterion = g_value_get_enum (value);
       break;
 
+    case PROP_SAMPLE_THRESHOLD:
+      options->sample_threshold = g_value_get_double (value);
+      break;
+
     case PROP_INTERPOLATION:
       options->interpolation = g_value_get_enum (value);
       break;
@@ -246,6 +271,10 @@ gimp_pdb_context_get_property (GObject    *object,
       g_value_set_enum (value, options->sample_criterion);
       break;
 
+    case PROP_SAMPLE_THRESHOLD:
+      g_value_set_double (value, options->sample_threshold);
+      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 1f93b5d..3c7c40f 100644
--- a/app/pdb/gimppdbcontext.h
+++ b/app/pdb/gimppdbcontext.h
@@ -45,6 +45,7 @@ struct _GimpPDBContext
   gdouble                 feather_radius_y;
   gboolean                sample_merged;
   GimpSelectCriterion     sample_criterion;
+  gdouble                 sample_threshold;
 
   GimpInterpolationType   interpolation;
   GimpTransformDirection  transform_direction;
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index a84e502..2cfe635 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 644 procedures registered total */
+/* 648 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index d3c1890..a892a3a 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -84,6 +84,8 @@ EXPORTS
 	gimp_context_get_pattern
 	gimp_context_get_sample_criterion
 	gimp_context_get_sample_merged
+	gimp_context_get_sample_threshold
+	gimp_context_get_sample_threshold_int
 	gimp_context_get_transform_direction
 	gimp_context_get_transform_recursion
 	gimp_context_get_transform_resize
@@ -107,6 +109,8 @@ EXPORTS
 	gimp_context_set_pattern
 	gimp_context_set_sample_criterion
 	gimp_context_set_sample_merged
+	gimp_context_set_sample_threshold
+	gimp_context_set_sample_threshold_int
 	gimp_context_set_transform_direction
 	gimp_context_set_transform_recursion
 	gimp_context_set_transform_resize
diff --git a/libgimp/gimpcontext_pdb.c b/libgimp/gimpcontext_pdb.c
index 002a75b..46e0b1f 100644
--- a/libgimp/gimpcontext_pdb.c
+++ b/libgimp/gimpcontext_pdb.c
@@ -1177,7 +1177,7 @@ gimp_context_get_sample_criterion (void)
  * gimp_context_set_sample_criterion:
  * @sample_criterion: The sample criterion setting.
  *
- * Set the sample merged setting.
+ * Set the sample criterion setting.
  *
  * This procedure modifies the sample criterion setting. If an
  * operation depends on the colors of the pixels present in a drawable,
@@ -1210,6 +1210,136 @@ gimp_context_set_sample_criterion (GimpSelectCriterion sample_criterion)
 }
 
 /**
+ * gimp_context_get_sample_threshold:
+ *
+ * Get the sample threshold setting.
+ *
+ * This procedure returns the sample threshold setting.
+ *
+ * Returns: The sample threshold setting.
+ *
+ * Since: GIMP 2.8
+ **/
+gdouble
+gimp_context_get_sample_threshold (void)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gdouble sample_threshold = 0.0;
+
+  return_vals = gimp_run_procedure ("gimp-context-get-sample-threshold",
+                                    &nreturn_vals,
+                                    GIMP_PDB_END);
+
+  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+    sample_threshold = return_vals[1].data.d_float;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return sample_threshold;
+}
+
+/**
+ * gimp_context_set_sample_threshold:
+ * @sample_threshold: The sample threshold setting.
+ *
+ * Set the sample threshold setting.
+ *
+ * This procedure modifies the sample threshold setting. If an
+ * operation depends on the colors of the pixels present in a drawable,
+ * like when doing a seed fill, this setting controls what is
+ * \"sufficiently close\" to be considered a similar color. If the
+ * sample threshold has not been set explicitly, the default threshold
+ * set in gimprc will be used. 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_threshold (gdouble sample_threshold)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gboolean success = TRUE;
+
+  return_vals = gimp_run_procedure ("gimp-context-set-sample-threshold",
+                                    &nreturn_vals,
+                                    GIMP_PDB_FLOAT, sample_threshold,
+                                    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_sample_threshold_int:
+ *
+ * Get the sample threshold setting as an integer value.
+ *
+ * This procedure returns the sample threshold setting as an integer
+ * value. See gimp_context_get_sample_threshold().
+ *
+ * Returns: The sample threshold setting.
+ *
+ * Since: GIMP 2.8
+ **/
+gint
+gimp_context_get_sample_threshold_int (void)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gint sample_threshold = 0;
+
+  return_vals = gimp_run_procedure ("gimp-context-get-sample-threshold-int",
+                                    &nreturn_vals,
+                                    GIMP_PDB_END);
+
+  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+    sample_threshold = return_vals[1].data.d_int32;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return sample_threshold;
+}
+
+/**
+ * gimp_context_set_sample_threshold_int:
+ * @sample_threshold: The sample threshold setting.
+ *
+ * Set the sample threshold setting as an integer value.
+ *
+ * This procedure modifies the sample threshold setting as an integer
+ * value. See gimp_context_set_sample_threshold().
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: GIMP 2.8
+ **/
+gboolean
+gimp_context_set_sample_threshold_int (gint sample_threshold)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gboolean success = TRUE;
+
+  return_vals = gimp_run_procedure ("gimp-context-set-sample-threshold-int",
+                                    &nreturn_vals,
+                                    GIMP_PDB_INT32, sample_threshold,
+                                    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 73ac2d5..83ac50d 100644
--- a/libgimp/gimpcontext_pdb.h
+++ b/libgimp/gimpcontext_pdb.h
@@ -28,52 +28,56 @@ G_BEGIN_DECLS
 /* For information look into the C source or the html documentation */
 
 
-gboolean               gimp_context_push                    (void);
-gboolean               gimp_context_pop                     (void);
-gboolean               gimp_context_list_paint_methods      (gint                     *num_paint_methods,
-                                                             gchar                  ***paint_methods);
-gchar*                 gimp_context_get_paint_method        (void);
-gboolean               gimp_context_set_paint_method        (const gchar              *name);
-gboolean               gimp_context_get_foreground          (GimpRGB                  *foreground);
-gboolean               gimp_context_set_foreground          (const GimpRGB            *foreground);
-gboolean               gimp_context_get_background          (GimpRGB                  *background);
-gboolean               gimp_context_set_background          (const GimpRGB            *background);
-gboolean               gimp_context_set_default_colors      (void);
-gboolean               gimp_context_swap_colors             (void);
-gdouble                gimp_context_get_opacity             (void);
-gboolean               gimp_context_set_opacity             (gdouble                   opacity);
-GimpLayerModeEffects   gimp_context_get_paint_mode          (void);
-gboolean               gimp_context_set_paint_mode          (GimpLayerModeEffects      paint_mode);
-gchar*                 gimp_context_get_brush               (void);
-gboolean               gimp_context_set_brush               (const gchar              *name);
-gchar*                 gimp_context_get_pattern             (void);
-gboolean               gimp_context_set_pattern             (const gchar              *name);
-gchar*                 gimp_context_get_gradient            (void);
-gboolean               gimp_context_set_gradient            (const gchar              *name);
-gchar*                 gimp_context_get_palette             (void);
-gboolean               gimp_context_set_palette             (const gchar              *name);
-gchar*                 gimp_context_get_font                (void);
-gboolean               gimp_context_set_font                (const gchar              *name);
-gboolean               gimp_context_get_antialias           (void);
-gboolean               gimp_context_set_antialias           (gboolean                  antialias);
-gboolean               gimp_context_get_feather             (void);
-gboolean               gimp_context_set_feather             (gboolean                  feather);
-gboolean               gimp_context_get_feather_radius      (gdouble                  *feather_radius_x,
-                                                             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);
-GimpSelectCriterion    gimp_context_get_sample_criterion    (void);
-gboolean               gimp_context_set_sample_criterion    (GimpSelectCriterion       sample_criterion);
-GimpInterpolationType  gimp_context_get_interpolation       (void);
-gboolean               gimp_context_set_interpolation       (GimpInterpolationType     interpolation);
-GimpTransformDirection gimp_context_get_transform_direction (void);
-gboolean               gimp_context_set_transform_direction (GimpTransformDirection    transform_direction);
-GimpTransformResize    gimp_context_get_transform_resize    (void);
-gboolean               gimp_context_set_transform_resize    (GimpTransformResize       transform_resize);
-gint                   gimp_context_get_transform_recursion (void);
-gboolean               gimp_context_set_transform_recursion (gint                      transform_recursion);
+gboolean               gimp_context_push                     (void);
+gboolean               gimp_context_pop                      (void);
+gboolean               gimp_context_list_paint_methods       (gint                     *num_paint_methods,
+                                                              gchar                  ***paint_methods);
+gchar*                 gimp_context_get_paint_method         (void);
+gboolean               gimp_context_set_paint_method         (const gchar              *name);
+gboolean               gimp_context_get_foreground           (GimpRGB                  *foreground);
+gboolean               gimp_context_set_foreground           (const GimpRGB            *foreground);
+gboolean               gimp_context_get_background           (GimpRGB                  *background);
+gboolean               gimp_context_set_background           (const GimpRGB            *background);
+gboolean               gimp_context_set_default_colors       (void);
+gboolean               gimp_context_swap_colors              (void);
+gdouble                gimp_context_get_opacity              (void);
+gboolean               gimp_context_set_opacity              (gdouble                   opacity);
+GimpLayerModeEffects   gimp_context_get_paint_mode           (void);
+gboolean               gimp_context_set_paint_mode           (GimpLayerModeEffects      paint_mode);
+gchar*                 gimp_context_get_brush                (void);
+gboolean               gimp_context_set_brush                (const gchar              *name);
+gchar*                 gimp_context_get_pattern              (void);
+gboolean               gimp_context_set_pattern              (const gchar              *name);
+gchar*                 gimp_context_get_gradient             (void);
+gboolean               gimp_context_set_gradient             (const gchar              *name);
+gchar*                 gimp_context_get_palette              (void);
+gboolean               gimp_context_set_palette              (const gchar              *name);
+gchar*                 gimp_context_get_font                 (void);
+gboolean               gimp_context_set_font                 (const gchar              *name);
+gboolean               gimp_context_get_antialias            (void);
+gboolean               gimp_context_set_antialias            (gboolean                  antialias);
+gboolean               gimp_context_get_feather              (void);
+gboolean               gimp_context_set_feather              (gboolean                  feather);
+gboolean               gimp_context_get_feather_radius       (gdouble                  *feather_radius_x,
+                                                              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);
+GimpSelectCriterion    gimp_context_get_sample_criterion     (void);
+gboolean               gimp_context_set_sample_criterion     (GimpSelectCriterion       sample_criterion);
+gdouble                gimp_context_get_sample_threshold     (void);
+gboolean               gimp_context_set_sample_threshold     (gdouble                   sample_threshold);
+gint                   gimp_context_get_sample_threshold_int (void);
+gboolean               gimp_context_set_sample_threshold_int (gint                      sample_threshold);
+GimpInterpolationType  gimp_context_get_interpolation        (void);
+gboolean               gimp_context_set_interpolation        (GimpInterpolationType     interpolation);
+GimpTransformDirection gimp_context_get_transform_direction  (void);
+gboolean               gimp_context_set_transform_direction  (GimpTransformDirection    transform_direction);
+GimpTransformResize    gimp_context_get_transform_resize     (void);
+gboolean               gimp_context_set_transform_resize     (GimpTransformResize       transform_resize);
+gint                   gimp_context_get_transform_recursion  (void);
+gboolean               gimp_context_set_transform_recursion  (gint                      transform_recursion);
 
 
 G_END_DECLS
diff --git a/tools/pdbgen/pdb/context.pdb b/tools/pdbgen/pdb/context.pdb
index a1a9f08..ca02873 100644
--- a/tools/pdbgen/pdb/context.pdb
+++ b/tools/pdbgen/pdb/context.pdb
@@ -955,7 +955,7 @@ CODE
 }
 
 sub context_set_sample_criterion {
-    $blurb = 'Set the sample merged setting.';
+    $blurb = 'Set the sample criterion setting.';
 
     $help = <<'HELP';
 This procedure modifies the sample criterion setting. If an operation
@@ -984,6 +984,120 @@ CODE
     );
 }
 
+sub context_get_sample_threshold {
+    $blurb = 'Get the sample threshold setting.';
+
+    $help = <<'HELP';
+This procedure returns the sample threshold setting.
+HELP
+
+    &mitch_pdb_misc('2011', '2.8');
+
+    @outargs = (
+        { name => 'sample_threshold', type => '0.0 <= float <= 1.0',
+          desc => 'The sample threshold setting' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  g_object_get (context,
+                "sample-threshold", &sample_threshold,
+                NULL);
+}
+CODE
+    );
+}
+
+sub context_set_sample_threshold {
+    $blurb = 'Set the sample threshold setting.';
+
+    $help = <<'HELP';
+
+This procedure modifies the sample threshold setting. If an operation
+depends on the colors of the pixels present in a drawable, like when
+doing a seed fill, this setting controls what is "sufficiently close"
+to be considered a similar color. If the sample threshold has not been
+set explicitly, the default threshold set in gimprc will be used.
+This setting affects the following procedures: gimp_image_select_color(),
+gimp_image_select_fuzzy().
+HELP
+
+    &mitch_pdb_misc('2011', '2.8');
+
+    @inargs = (
+        { name => 'sample_threshold', type => '0.0 <= float <= 1.0',
+          desc => 'The sample threshold setting' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  g_object_set (context,
+                "sample-threshold", sample_threshold,
+                NULL);
+}
+CODE
+    );
+}
+
+sub context_get_sample_threshold_int {
+    $blurb = 'Get the sample threshold setting as an integer value.';
+
+    $help = <<'HELP';
+This procedure returns the sample threshold setting as an integer value.
+See gimp_context_get_sample_threshold().
+HELP
+
+    &mitch_pdb_misc('2011', '2.8');
+
+    @outargs = (
+        { name => 'sample_threshold', type => '0 <= int32 <= 255',
+          desc => 'The sample threshold setting' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  gdouble threshold;
+
+  g_object_get (context,
+                "sample-threshold", &threshold,
+                NULL);
+
+  sample_threshold = (gint) (threshold * 255.99);
+}
+CODE
+    );
+}
+
+sub context_set_sample_threshold_int {
+    $blurb = 'Set the sample threshold setting as an integer value.';
+
+    $help = <<'HELP';
+
+This procedure modifies the sample threshold setting as an integer value.
+See gimp_context_set_sample_threshold().
+HELP
+
+    &mitch_pdb_misc('2011', '2.8');
+
+    @inargs = (
+        { name => 'sample_threshold', type => '0 <= int32 <= 255',
+          desc => 'The sample threshold setting' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  g_object_set (context,
+                "sample-threshold", (gdouble) sample_threshold / 255.0,
+                NULL);
+}
+CODE
+    );
+}
+
 sub context_get_interpolation {
     $blurb = 'Get the interpolation type.';
 
@@ -1228,6 +1342,8 @@ CODE
             context_get_feather_radius context_set_feather_radius
             context_get_sample_merged context_set_sample_merged
             context_get_sample_criterion context_set_sample_criterion
+            context_get_sample_threshold context_set_sample_threshold
+            context_get_sample_threshold_int context_set_sample_threshold_int
             context_get_interpolation context_set_interpolation
             context_get_transform_direction context_set_transform_direction
             context_get_transform_resize context_set_transform_resize



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