[gimp] pdb: Add "diagonal-neighbors" as GimpPDBContext property
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] pdb: Add "diagonal-neighbors" as GimpPDBContext property
- Date: Sat, 16 Jan 2016 23:47:33 +0000 (UTC)
commit 7b3e5ba1e94f078521ca362ae8133f47e2470d8e
Author: Ell <ell_se yahoo com>
Date: Mon Jan 11 10:41:23 2016 +0000
pdb: Add "diagonal-neighbors" 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 | 66 ++++++++++++++++++++++++++++++
libgimp/gimpcontext_pdb.h | 2 +
tools/pdbgen/pdb/context.pdb | 62 ++++++++++++++++++++++++++++
8 files changed, 239 insertions(+), 1 deletions(-)
---
diff --git a/app/pdb/context-cmds.c b/app/pdb/context-cmds.c
index 59a558b..1c67391 100644
--- a/app/pdb/context-cmds.c
+++ b/app/pdb/context-cmds.c
@@ -2043,6 +2043,51 @@ context_set_sample_transparent_invoker (GimpProcedure *procedure,
}
static GimpValueArray *
+context_get_diagonal_neighbors_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
+{
+ GimpValueArray *return_vals;
+ gboolean diagonal_neighbors = FALSE;
+
+ g_object_get (context,
+ "diagonal-neighbors", &diagonal_neighbors,
+ NULL);
+
+ return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
+ g_value_set_boolean (gimp_value_array_index (return_vals, 1), diagonal_neighbors);
+
+ return return_vals;
+}
+
+static GimpValueArray *
+context_set_diagonal_neighbors_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
+{
+ gboolean success = TRUE;
+ gboolean diagonal_neighbors;
+
+ diagonal_neighbors = g_value_get_boolean (gimp_value_array_index (args, 0));
+
+ if (success)
+ {
+ g_object_set (context,
+ "diagonal-neighbors", diagonal_neighbors,
+ NULL);
+ }
+
+ return gimp_procedure_get_return_values (procedure, success,
+ error ? *error : NULL);
+}
+
+static GimpValueArray *
context_get_interpolation_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
@@ -4525,6 +4570,52 @@ register_context_procs (GimpPDB *pdb)
g_object_unref (procedure);
/*
+ * gimp-context-get-diagonal-neighbors
+ */
+ procedure = gimp_procedure_new (context_get_diagonal_neighbors_invoker);
+ gimp_object_set_static_name (GIMP_OBJECT (procedure),
+ "gimp-context-get-diagonal-neighbors");
+ gimp_procedure_set_static_strings (procedure,
+ "gimp-context-get-diagonal-neighbors",
+ "Get the diagonal neighbors setting.",
+ "This procedure returns the diagonal neighbors setting.",
+ "Ell",
+ "Ell",
+ "2016",
+ NULL);
+ gimp_procedure_add_return_value (procedure,
+ g_param_spec_boolean ("diagonal-neighbors",
+ "diagonal neighbors",
+ "The diagonal neighbors setting",
+ FALSE,
+ GIMP_PARAM_READWRITE));
+ gimp_pdb_register_procedure (pdb, procedure);
+ g_object_unref (procedure);
+
+ /*
+ * gimp-context-set-diagonal-neighbors
+ */
+ procedure = gimp_procedure_new (context_set_diagonal_neighbors_invoker);
+ gimp_object_set_static_name (GIMP_OBJECT (procedure),
+ "gimp-context-set-diagonal-neighbors");
+ gimp_procedure_set_static_strings (procedure,
+ "gimp-context-set-diagonal-neighbors",
+ "Set the diagonal neighbors setting.",
+ "This procedure modifies the diagonal neighbors setting. If the
affected region of an operation is based on a seed point, like when doing a seed fill, then, when this
setting is TRUE, all eight neighbors of each pixel are considered when calculating the affected region; in
contrast, when this setting is FALSE, only the four orthogonal neighors of each pixel are considered.",
+ "Ell",
+ "Ell",
+ "2016",
+ NULL);
+ gimp_procedure_add_argument (procedure,
+ g_param_spec_boolean ("diagonal-neighbors",
+ "diagonal neighbors",
+ "The diagonal neighbors 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 9cb030e..20e553c 100644
--- a/app/pdb/gimppdbcontext.c
+++ b/app/pdb/gimppdbcontext.c
@@ -52,6 +52,7 @@ enum
PROP_SAMPLE_CRITERION,
PROP_SAMPLE_THRESHOLD,
PROP_SAMPLE_TRANSPARENT,
+ PROP_DIAGONAL_NEIGHBORS,
PROP_INTERPOLATION,
PROP_TRANSFORM_DIRECTION,
PROP_TRANSFORM_RESIZE
@@ -135,6 +136,11 @@ gimp_pdb_context_class_init (GimpPDBContextClass *klass)
FALSE,
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_DIAGONAL_NEIGHBORS,
+ "diagonal-neighbors", NULL,
+ FALSE,
+ GIMP_PARAM_STATIC_STRINGS);
+
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_INTERPOLATION,
"interpolation", NULL,
GIMP_TYPE_INTERPOLATION_TYPE,
@@ -288,6 +294,10 @@ gimp_pdb_context_set_property (GObject *object,
options->sample_transparent = g_value_get_boolean (value);
break;
+ case PROP_DIAGONAL_NEIGHBORS:
+ options->diagonal_neighbors = g_value_get_boolean (value);
+ break;
+
case PROP_INTERPOLATION:
options->interpolation = g_value_get_enum (value);
break;
@@ -348,6 +358,10 @@ gimp_pdb_context_get_property (GObject *object,
g_value_set_boolean (value, options->sample_transparent);
break;
+ case PROP_DIAGONAL_NEIGHBORS:
+ g_value_set_boolean (value, options->diagonal_neighbors);
+ 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 1607f8d..a39349f 100644
--- a/app/pdb/gimppdbcontext.h
+++ b/app/pdb/gimppdbcontext.h
@@ -47,6 +47,7 @@ struct _GimpPDBContext
GimpSelectCriterion sample_criterion;
gdouble sample_threshold;
gboolean sample_transparent;
+ gboolean diagonal_neighbors;
GimpInterpolationType interpolation;
GimpTransformDirection transform_direction;
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index b5ae8cf..ab75227 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
#include "internal-procs.h"
-/* 797 procedures registered total */
+/* 799 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index 0b9a7f6..df9a921 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -110,6 +110,7 @@ EXPORTS
gimp_context_get_sample_threshold
gimp_context_get_sample_threshold_int
gimp_context_get_sample_transparent
+ gimp_context_get_diagonal_neighbors
gimp_context_get_stroke_method
gimp_context_get_transform_direction
gimp_context_get_transform_recursion
@@ -164,6 +165,7 @@ EXPORTS
gimp_context_set_sample_threshold
gimp_context_set_sample_threshold_int
gimp_context_set_sample_transparent
+ gimp_context_set_diagonal_neighbors
gimp_context_set_stroke_method
gimp_context_set_transform_direction
gimp_context_set_transform_recursion
diff --git a/libgimp/gimpcontext_pdb.c b/libgimp/gimpcontext_pdb.c
index c70d7e8..d9898b0 100644
--- a/libgimp/gimpcontext_pdb.c
+++ b/libgimp/gimpcontext_pdb.c
@@ -2580,6 +2580,72 @@ gimp_context_set_sample_transparent (gboolean sample_transparent)
}
/**
+ * gimp_context_get_diagonal_neighbors:
+ *
+ * Get the diagonal neighbors setting.
+ *
+ * This procedure returns the diagonal neighbors setting.
+ *
+ * Returns: The diagonal neighbors setting.
+ *
+ * Since: 2.10
+ **/
+gboolean
+gimp_context_get_diagonal_neighbors (void)
+{
+ GimpParam *return_vals;
+ gint nreturn_vals;
+ gboolean diagonal_neighbors = FALSE;
+
+ return_vals = gimp_run_procedure ("gimp-context-get-diagonal-neighbors",
+ &nreturn_vals,
+ GIMP_PDB_END);
+
+ if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+ diagonal_neighbors = return_vals[1].data.d_int32;
+
+ gimp_destroy_params (return_vals, nreturn_vals);
+
+ return diagonal_neighbors;
+}
+
+/**
+ * gimp_context_set_diagonal_neighbors:
+ * @diagonal_neighbors: The diagonal neighbors setting.
+ *
+ * Set the diagonal neighbors setting.
+ *
+ * This procedure modifies the diagonal neighbors setting. If the
+ * affected region of an operation is based on a seed point, like when
+ * doing a seed fill, then, when this setting is TRUE, all eight
+ * neighbors of each pixel are considered when calculating the affected
+ * region; in contrast, when this setting is FALSE, only the four
+ * orthogonal neighors of each pixel are considered.
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: 2.10
+ **/
+gboolean
+gimp_context_set_diagonal_neighbors (gboolean diagonal_neighbors)
+{
+ GimpParam *return_vals;
+ gint nreturn_vals;
+ gboolean success = TRUE;
+
+ return_vals = gimp_run_procedure ("gimp-context-set-diagonal-neighbors",
+ &nreturn_vals,
+ GIMP_PDB_INT32, diagonal_neighbors,
+ 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 2bd21b5..675abf2 100644
--- a/libgimp/gimpcontext_pdb.h
+++ b/libgimp/gimpcontext_pdb.h
@@ -114,6 +114,8 @@ 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);
+gboolean gimp_context_get_diagonal_neighbors (void);
+gboolean gimp_context_set_diagonal_neighbors (gboolean
diagonal_neighbors);
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 35f75d3..5bd6d17 100644
--- a/tools/pdbgen/pdb/context.pdb
+++ b/tools/pdbgen/pdb/context.pdb
@@ -2271,6 +2271,67 @@ CODE
);
}
+sub context_get_diagonal_neighbors {
+ $blurb = 'Get the diagonal neighbors setting.';
+
+ $help = <<'HELP';
+This procedure returns the diagonal neighbors setting.
+HELP
+
+ $author = 'Ell';
+ $copyright = 'Ell';
+ $date = '2016';
+ $since = '2.10';
+
+ @outargs = (
+ { name => 'diagonal_neighbors', type => 'boolean',
+ desc => 'The diagonal neighbors setting' }
+ );
+
+ %invoke = (
+ code => <<'CODE'
+{
+ g_object_get (context,
+ "diagonal-neighbors", &diagonal_neighbors,
+ NULL);
+}
+CODE
+ );
+}
+
+sub context_set_diagonal_neighbors {
+ $blurb = 'Set the diagonal neighbors setting.';
+
+ $help = <<'HELP';
+This procedure modifies the diagonal neighbors setting. If the affected
+region of an operation is based on a seed point, like when doing a seed
+fill, then, when this setting is TRUE, all eight neighbors of each pixel
+are considered when calculating the affected region; in contrast, when
+this setting is FALSE, only the four orthogonal neighors of each pixel
+are considered.
+HELP
+
+ $author = 'Ell';
+ $copyright = 'Ell';
+ $date = '2016';
+ $since = '2.10';
+
+ @inargs = (
+ { name => 'diagonal_neighbors', type => 'boolean',
+ desc => 'The diagonal neighbors setting' }
+ );
+
+ %invoke = (
+ code => <<'CODE'
+{
+ g_object_set (context,
+ "diagonal-neighbors", diagonal_neighbors,
+ NULL);
+}
+CODE
+ );
+}
+
sub context_get_interpolation {
$blurb = 'Get the interpolation type.';
@@ -3021,6 +3082,7 @@ CODE
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_diagonal_neighbors context_set_diagonal_neighbors
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]