Commit 6f4fb846 authored by Alexia Death's avatar Alexia Death

pdb: pdb definitions for spacing in tool options

parent 9f492273
......@@ -655,6 +655,103 @@ context_set_brush_angle_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GimpValueArray *
context_get_brush_spacing_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
gdouble spacing = 0.0;
/* all options should have the same value, so pick a random one */
GimpPaintOptions *options =
gimp_pdb_context_get_paint_options (GIMP_PDB_CONTEXT (context),
"gimp-paintbrush");
if (options)
g_object_get (options,
"brush-spacing", &spacing,
NULL);
else
success = FALSE;
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_double (gimp_value_array_index (return_vals, 1), spacing);
return return_vals;
}
static GimpValueArray *
context_set_brush_spacing_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
gdouble spacing;
spacing = g_value_get_double (gimp_value_array_index (args, 0));
if (success)
{
GList *options;
GList *list;
options = gimp_pdb_context_get_brush_options (GIMP_PDB_CONTEXT (context));
for (list = options; list; list = g_list_next (list))
g_object_set (list->data,
"brush-spacing", (gdouble) spacing,
NULL);
g_list_free (options);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
context_set_brush_default_spacing_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpBrush *brush = gimp_context_get_brush (context);
if (brush)
{
GList *options;
GList *list;
options = gimp_pdb_context_get_brush_options (GIMP_PDB_CONTEXT (context));
for (list = options; list; list = g_list_next (list))
gimp_paint_options_set_default_brush_spacing (list->data, brush);
g_list_free (options);
}
else
{
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
context_get_dynamics_invoker (GimpProcedure *procedure,
Gimp *gimp,
......@@ -2537,6 +2634,69 @@ register_context_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-get-brush-spacing
*/
procedure = gimp_procedure_new (context_get_brush_spacing_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-get-brush-spacing");
gimp_procedure_set_static_strings (procedure,
"gimp-context-get-brush-spacing",
"Get brush spacing as percent of size.",
"Get the brush spacing as percent of size for brush based paint tools.",
"Alexia Death",
"Alexia Death",
"2014",
NULL);
gimp_procedure_add_return_value (procedure,
g_param_spec_double ("spacing",
"spacing",
"brush spacing as percent of size",
0, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-set-brush-spacing
*/
procedure = gimp_procedure_new (context_set_brush_spacing_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-set-brush-spacing");
gimp_procedure_set_static_strings (procedure,
"gimp-context-set-brush-spacing",
"Set brush spacing as percent of size.",
"Set the brush spacing as percent of size for brush based paint tools.",
"Alexia Death",
"Alexia Death",
"2014",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_double ("spacing",
"spacing",
"brush spacing as percent of size",
0, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-set-brush-default-spacing
*/
procedure = gimp_procedure_new (context_set_brush_default_spacing_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-set-brush-default-spacing");
gimp_procedure_set_static_strings (procedure,
"gimp-context-set-brush-default-spacing",
"Set brush spacing to its default.",
"Set the brush spacing to the default for paintbrush, airbrush, or pencil tools.",
"Alexia Death",
"Alexia Death",
"2014",
NULL);
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-get-dynamics
*/
......
......@@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 734 procedures registered total */
/* 737 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
......
......@@ -848,6 +848,99 @@ gimp_context_set_brush_angle (gdouble angle)
return success;
}
/**
* gimp_context_get_brush_spacing:
*
* Get brush spacing as percent of size.
*
* Get the brush spacing as percent of size for brush based paint
* tools.
*
* Returns: brush spacing as percent of size.
*
* Since: GIMP 2.9
**/
gdouble
gimp_context_get_brush_spacing (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gdouble spacing = 0.0;
return_vals = gimp_run_procedure ("gimp-context-get-brush-spacing",
&nreturn_vals,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
spacing = return_vals[1].data.d_float;
gimp_destroy_params (return_vals, nreturn_vals);
return spacing;
}
/**
* gimp_context_set_brush_spacing:
* @spacing: brush spacing as percent of size.
*
* Set brush spacing as percent of size.
*
* Set the brush spacing as percent of size for brush based paint
* tools.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.9
**/
gboolean
gimp_context_set_brush_spacing (gdouble spacing)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-brush-spacing",
&nreturn_vals,
GIMP_PDB_FLOAT, spacing,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_context_set_brush_default_spacing:
*
* Set brush spacing to its default.
*
* Set the brush spacing to the default for paintbrush, airbrush, or
* pencil tools.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.9
**/
gboolean
gimp_context_set_brush_default_spacing (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-brush-default-spacing",
&nreturn_vals,
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_dynamics:
*
......
......@@ -58,6 +58,9 @@ gdouble gimp_context_get_brush_aspect_ratio (void);
gboolean gimp_context_set_brush_aspect_ratio (gdouble aspect);
gdouble gimp_context_get_brush_angle (void);
gboolean gimp_context_set_brush_angle (gdouble angle);
gdouble gimp_context_get_brush_spacing (void);
gboolean gimp_context_set_brush_spacing (gdouble spacing);
gboolean gimp_context_set_brush_default_spacing (void);
gchar* gimp_context_get_dynamics (void);
gboolean gimp_context_set_dynamics (const gchar *name);
gchar* gimp_context_get_pattern (void);
......
......@@ -702,6 +702,101 @@ CODE
);
}
sub context_get_brush_spacing {
$blurb = 'Get brush spacing as percent of size.';
$help = 'Get the brush spacing as percent of size for brush based paint tools.';
&adeath_pdb_misc('2014', '2.9');
@outargs = (
{ name => "spacing", type => "0 < float",
desc => "brush spacing as percent of size" }
);
%invoke = (
code => <<'CODE'
{
/* all options should have the same value, so pick a random one */
GimpPaintOptions *options =
gimp_pdb_context_get_paint_options (GIMP_PDB_CONTEXT (context),
"gimp-paintbrush");
if (options)
g_object_get (options,
"brush-spacing", &spacing,
NULL);
else
success = FALSE;
}
CODE
);
}
sub context_set_brush_spacing {
$blurb = 'Set brush spacing as percent of size.';
$help = 'Set the brush spacing as percent of size for brush based paint tools.';
&adeath_pdb_misc('2014', '2.9');
@inargs = (
{ name => "spacing", type => "0 < float",
desc => "brush spacing as percent of size" }
);
%invoke = (
code => <<'CODE'
{
GList *options;
GList *list;
options = gimp_pdb_context_get_brush_options (GIMP_PDB_CONTEXT (context));
for (list = options; list; list = g_list_next (list))
g_object_set (list->data,
"brush-spacing", (gdouble) spacing,
NULL);
g_list_free (options);
}
CODE
);
}
sub context_set_brush_default_spacing {
$blurb = 'Set brush spacing to its default.';
$help = <<'HELP';
Set the brush spacing to the default for
paintbrush, airbrush, or pencil tools.
HELP
&adeath_pdb_misc('2014', '2.9');
%invoke = (
code => <<'CODE'
{
GimpBrush *brush = gimp_context_get_brush (context);
if (brush)
{
GList *options;
GList *list;
options = gimp_pdb_context_get_brush_options (GIMP_PDB_CONTEXT (context));
for (list = options; list; list = g_list_next (list))
gimp_paint_options_set_default_brush_spacing (list->data, brush);
g_list_free (options);
}
else
{
success = FALSE;
}
}
CODE
);
}
sub context_get_dynamics {
$blurb = 'Retrieve the currently active paint dynamics.';
......@@ -2188,6 +2283,8 @@ CODE
context_set_brush_size context_set_brush_default_size
context_get_brush_aspect_ratio context_set_brush_aspect_ratio
context_get_brush_angle context_set_brush_angle
context_get_brush_spacing
context_set_brush_spacing context_set_brush_default_spacing
context_get_dynamics context_set_dynamics
context_get_pattern context_set_pattern
context_get_gradient context_set_gradient
......
......@@ -49,6 +49,10 @@ sub adrian_pdb_misc {
contrib_pdb_misc('Adrian Likins', 'adrian@gimp.org', @_);
}
sub adeath_pdb_misc {
contrib_pdb_misc('Alexia Death', '', @_);
}
sub andy_pdb_misc {
contrib_pdb_misc('Andy Thomas', '', @_);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment