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



commit d3a291d2dfea3691a9875b7dcba1a30871efcff8
Author: Michael Natterer <mitch gimp org>
Date:   Fri Feb 4 18:32:32 2011 +0100

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

 app/pdb/context-cmds.c       |   91 ++++++++++++++++++++++++++++++++++++++++++
 app/pdb/gimppdbcontext.c     |   14 ++++++
 app/pdb/gimppdbcontext.h     |    1 +
 app/pdb/internal-procs.c     |    2 +-
 libgimp/gimp.def             |    2 +
 libgimp/gimpcontext_pdb.c    |   67 +++++++++++++++++++++++++++++++
 libgimp/gimpcontext_pdb.h    |    2 +
 tools/pdbgen/pdb/context.pdb |   57 ++++++++++++++++++++++++++
 8 files changed, 235 insertions(+), 1 deletions(-)
---
diff --git a/app/pdb/context-cmds.c b/app/pdb/context-cmds.c
index f711a0a..99af5d7 100644
--- a/app/pdb/context-cmds.c
+++ b/app/pdb/context-cmds.c
@@ -954,6 +954,51 @@ context_set_sample_threshold_int_invoker (GimpProcedure      *procedure,
 }
 
 static GValueArray *
+context_get_sample_transparent_invoker (GimpProcedure      *procedure,
+                                        Gimp               *gimp,
+                                        GimpContext        *context,
+                                        GimpProgress       *progress,
+                                        const GValueArray  *args,
+                                        GError            **error)
+{
+  GValueArray *return_vals;
+  gboolean sample_transparent = FALSE;
+
+  g_object_get (context,
+                "sample-transparent", &sample_transparent,
+                NULL);
+
+  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
+  g_value_set_boolean (&return_vals->values[1], sample_transparent);
+
+  return return_vals;
+}
+
+static GValueArray *
+context_set_sample_transparent_invoker (GimpProcedure      *procedure,
+                                        Gimp               *gimp,
+                                        GimpContext        *context,
+                                        GimpProgress       *progress,
+                                        const GValueArray  *args,
+                                        GError            **error)
+{
+  gboolean success = TRUE;
+  gboolean sample_transparent;
+
+  sample_transparent = g_value_get_boolean (&args->values[0]);
+
+  if (success)
+    {
+      g_object_set (context,
+                    "sample-transparent", sample_transparent,
+                    NULL);
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GValueArray *
 context_get_interpolation_invoker (GimpProcedure      *procedure,
                                    Gimp               *gimp,
                                    GimpContext        *context,
@@ -2049,6 +2094,52 @@ register_context_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-context-get-sample-transparent
+   */
+  procedure = gimp_procedure_new (context_get_sample_transparent_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-get-sample-transparent");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-get-sample-transparent",
+                                     "Get the sample transparent setting.",
+                                     "This procedure returns the sample transparent setting.",
+                                     "Michael Natterer <mitch gimp org>",
+                                     "Michael Natterer",
+                                     "2011",
+                                     NULL);
+  gimp_procedure_add_return_value (procedure,
+                                   g_param_spec_boolean ("sample-transparent",
+                                                         "sample transparent",
+                                                         "The sample transparent setting",
+                                                         FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-context-set-sample-transparent
+   */
+  procedure = gimp_procedure_new (context_set_sample_transparent_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-set-sample-transparent");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-set-sample-transparent",
+                                     "Set the sample transparent setting.",
+                                     "This procedure modifies the sample transparent 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 transparency is considered to be a unique selectable color. When this setting is TRUE, transparent areas can be selected or filled. 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-transparent",
+                                                     "sample transparent",
+                                                     "The sample transparent 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 4777420..0055d82 100644
--- a/app/pdb/gimppdbcontext.c
+++ b/app/pdb/gimppdbcontext.c
@@ -44,6 +44,7 @@ enum
   PROP_SAMPLE_MERGED,
   PROP_SAMPLE_CRITERION,
   PROP_SAMPLE_THRESHOLD,
+  PROP_SAMPLE_TRANSPARENT,
   PROP_INTERPOLATION,
   PROP_TRANSFORM_DIRECTION,
   PROP_TRANSFORM_RESIZE,
@@ -113,6 +114,11 @@ gimp_pdb_context_class_init (GimpPDBContextClass *klass)
                                    0.0, 1.0, 0.0,
                                    GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAMPLE_TRANSPARENT,
+                                    "sample-transparent", NULL,
+                                    FALSE,
+                                    GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_INTERPOLATION,
                                  "interpolation", NULL,
                                  GIMP_TYPE_INTERPOLATION_TYPE,
@@ -215,6 +221,10 @@ gimp_pdb_context_set_property (GObject      *object,
       options->sample_threshold = g_value_get_double (value);
       break;
 
+    case PROP_SAMPLE_TRANSPARENT:
+      options->sample_transparent = g_value_get_boolean (value);
+      break;
+
     case PROP_INTERPOLATION:
       options->interpolation = g_value_get_enum (value);
       break;
@@ -275,6 +285,10 @@ gimp_pdb_context_get_property (GObject    *object,
       g_value_set_double (value, options->sample_threshold);
       break;
 
+    case PROP_SAMPLE_TRANSPARENT:
+      g_value_set_boolean (value, options->sample_transparent);
+      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 3c7c40f..e364dc8 100644
--- a/app/pdb/gimppdbcontext.h
+++ b/app/pdb/gimppdbcontext.h
@@ -46,6 +46,7 @@ struct _GimpPDBContext
   gboolean                sample_merged;
   GimpSelectCriterion     sample_criterion;
   gdouble                 sample_threshold;
+  gboolean                sample_transparent;
 
   GimpInterpolationType   interpolation;
   GimpTransformDirection  transform_direction;
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 2cfe635..d1f1ade 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 648 procedures registered total */
+/* 650 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index a892a3a..6115cb2 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -86,6 +86,7 @@ EXPORTS
 	gimp_context_get_sample_merged
 	gimp_context_get_sample_threshold
 	gimp_context_get_sample_threshold_int
+	gimp_context_get_sample_transparent
 	gimp_context_get_transform_direction
 	gimp_context_get_transform_recursion
 	gimp_context_get_transform_resize
@@ -111,6 +112,7 @@ EXPORTS
 	gimp_context_set_sample_merged
 	gimp_context_set_sample_threshold
 	gimp_context_set_sample_threshold_int
+	gimp_context_set_sample_transparent
 	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 46e0b1f..945ccae 100644
--- a/libgimp/gimpcontext_pdb.c
+++ b/libgimp/gimpcontext_pdb.c
@@ -1340,6 +1340,73 @@ gimp_context_set_sample_threshold_int (gint sample_threshold)
 }
 
 /**
+ * gimp_context_get_sample_transparent:
+ *
+ * Get the sample transparent setting.
+ *
+ * This procedure returns the sample transparent setting.
+ *
+ * Returns: The sample transparent setting.
+ *
+ * Since: GIMP 2.8
+ **/
+gboolean
+gimp_context_get_sample_transparent (void)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gboolean sample_transparent = FALSE;
+
+  return_vals = gimp_run_procedure ("gimp-context-get-sample-transparent",
+                                    &nreturn_vals,
+                                    GIMP_PDB_END);
+
+  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+    sample_transparent = return_vals[1].data.d_int32;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return sample_transparent;
+}
+
+/**
+ * gimp_context_set_sample_transparent:
+ * @sample_transparent: The sample transparent setting.
+ *
+ * Set the sample transparent setting.
+ *
+ * This procedure modifies the sample transparent 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
+ * transparency is considered to be a unique selectable color. When
+ * this setting is TRUE, transparent areas can be selected or filled.
+ * 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_transparent (gboolean sample_transparent)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gboolean success = TRUE;
+
+  return_vals = gimp_run_procedure ("gimp-context-set-sample-transparent",
+                                    &nreturn_vals,
+                                    GIMP_PDB_INT32, sample_transparent,
+                                    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 83ac50d..060c048 100644
--- a/libgimp/gimpcontext_pdb.h
+++ b/libgimp/gimpcontext_pdb.h
@@ -70,6 +70,8 @@ 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);
+gboolean               gimp_context_get_sample_transparent   (void);
+gboolean               gimp_context_set_sample_transparent   (gboolean                  sample_transparent);
 GimpInterpolationType  gimp_context_get_interpolation        (void);
 gboolean               gimp_context_set_interpolation        (GimpInterpolationType     interpolation);
 GimpTransformDirection gimp_context_get_transform_direction  (void);
diff --git a/tools/pdbgen/pdb/context.pdb b/tools/pdbgen/pdb/context.pdb
index ca02873..d75b027 100644
--- a/tools/pdbgen/pdb/context.pdb
+++ b/tools/pdbgen/pdb/context.pdb
@@ -1098,6 +1098,62 @@ CODE
     );
 }
 
+sub context_get_sample_transparent {
+    $blurb = 'Get the sample transparent setting.';
+
+    $help = <<'HELP';
+This procedure returns the sample transparent setting.
+HELP
+
+    &mitch_pdb_misc('2011', '2.8');
+
+    @outargs = (
+        { name => 'sample_transparent', type => 'boolean',
+          desc => 'The sample transparent setting' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  g_object_get (context,
+                "sample-transparent", &sample_transparent,
+                NULL);
+}
+CODE
+    );
+}
+
+sub context_set_sample_transparent {
+    $blurb = 'Set the sample transparent setting.';
+
+    $help = <<'HELP';
+This procedure modifies the sample transparent 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
+transparency is considered to be a unique selectable color. When this
+setting is TRUE, transparent areas can be selected or filled.  This
+setting affects the following procedures: gimp_image_select_color(),
+gimp_image_select_fuzzy().
+HELP
+
+    &mitch_pdb_misc('2011', '2.8');
+
+    @inargs = (
+        { name => 'sample_transparent', type => 'boolean',
+          desc => 'The sample transparent setting' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  g_object_set (context,
+                "sample-transparent", sample_transparent,
+                NULL);
+}
+CODE
+    );
+}
+
 sub context_get_interpolation {
     $blurb = 'Get the interpolation type.';
 
@@ -1344,6 +1400,7 @@ CODE
             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_sample_transparent context_set_sample_transparent
             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]