mirror of https://github.com/GNOME/gimp.git
pdb: Add "diagonal-neighbors" as GimpPDBContext property
and add PDB API to get/set it.
This commit is contained in:
parent
e0b1aa1c26
commit
7b3e5ba1e9
|
@ -2042,6 +2042,51 @@ context_set_sample_transparent_invoker (GimpProcedure *procedure,
|
|||
error ? *error : NULL);
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -4524,6 +4569,52 @@ register_context_procs (GimpPDB *pdb)
|
|||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
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
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -47,6 +47,7 @@ struct _GimpPDBContext
|
|||
GimpSelectCriterion sample_criterion;
|
||||
gdouble sample_threshold;
|
||||
gboolean sample_transparent;
|
||||
gboolean diagonal_neighbors;
|
||||
|
||||
GimpInterpolationType interpolation;
|
||||
GimpTransformDirection transform_direction;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 797 procedures registered total */
|
||||
/* 799 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -2579,6 +2579,72 @@ gimp_context_set_sample_transparent (gboolean sample_transparent)
|
|||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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:
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue