Commit 01dffdc2 authored by Michael Natterer's avatar Michael Natterer 😴

Bug 680531 - Function gimp-context-get-brush-size takes size argument...

The context getters need PDB @outargs, not @inargs. This "API change"
is OK in stable because the API was totally unusable before this fix.
parent 220b2867
......@@ -438,27 +438,28 @@ context_get_brush_size_invoker (GimpProcedure *procedure,
GError **error)
{
gboolean success = TRUE;
gdouble size;
GimpValueArray *return_vals;
gdouble size = 0.0;
size = g_value_get_double (gimp_value_array_index (args, 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 (success)
{
/* 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-size", &size,
NULL);
else
success = FALSE;
if (options)
g_object_get (options,
"brush-size", &size,
NULL);
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_double (gimp_value_array_index (return_vals, 1), size);
return return_vals;
}
static GimpValueArray *
......@@ -538,27 +539,28 @@ context_get_brush_aspect_ratio_invoker (GimpProcedure *procedure,
GError **error)
{
gboolean success = TRUE;
gdouble aspect;
GimpValueArray *return_vals;
gdouble aspect = 0.0;
aspect = g_value_get_double (gimp_value_array_index (args, 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 (success)
{
/* 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-aspect-ratio", &aspect,
NULL);
else
success = FALSE;
if (options)
g_object_get (options,
"brush-aspect-ratio", &aspect,
NULL);
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_double (gimp_value_array_index (return_vals, 1), aspect);
return return_vals;
}
static GimpValueArray *
......@@ -602,27 +604,28 @@ context_get_brush_angle_invoker (GimpProcedure *procedure,
GError **error)
{
gboolean success = TRUE;
gdouble angle;
GimpValueArray *return_vals;
gdouble angle = 0.0;
angle = g_value_get_double (gimp_value_array_index (args, 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 (success)
{
/* 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-angle", &angle,
NULL);
else
success = FALSE;
if (options)
g_object_get (options,
"brush-angle", &angle,
NULL);
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_double (gimp_value_array_index (return_vals, 1), angle);
return return_vals;
}
static GimpValueArray *
......@@ -2408,12 +2411,12 @@ register_context_procs (GimpPDB *pdb)
"Ed Swartz",
"2012",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_double ("size",
"size",
"brush size in pixels",
0, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_double ("size",
"size",
"brush size in pixels",
0, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
......@@ -2471,12 +2474,12 @@ register_context_procs (GimpPDB *pdb)
"Ed Swartz",
"2012",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_double ("aspect",
"aspect",
"aspect ratio",
-20, 20, -20,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_double ("aspect",
"aspect",
"aspect ratio",
-20, 20, -20,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
......@@ -2517,12 +2520,12 @@ register_context_procs (GimpPDB *pdb)
"Ed Swartz",
"2012",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_double ("angle",
"angle",
"angle in degrees",
-180, 180, -180,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_double ("angle",
"angle",
"angle in degrees",
-180, 180, -180,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
......
......@@ -636,33 +636,32 @@ gimp_context_set_brush (const gchar *name)
/**
* gimp_context_get_brush_size:
* @size: brush size in pixels.
*
* Get brush size in pixels.
*
* Get the brush size in pixels for brush based paint tools.
*
* Returns: TRUE on success.
* Returns: brush size in pixels.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_get_brush_size (gdouble size)
gdouble
gimp_context_get_brush_size (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
gdouble size = 0.0;
return_vals = gimp_run_procedure ("gimp-context-get-brush-size",
&nreturn_vals,
GIMP_PDB_FLOAT, size,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
size = return_vals[1].data.d_float;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
return size;
}
/**
......@@ -728,33 +727,32 @@ gimp_context_set_brush_default_size (void)
/**
* gimp_context_get_brush_aspect_ratio:
* @aspect: aspect ratio.
*
* Get brush aspect ratio.
*
* Set the aspect ratio for brush based paint tools.
*
* Returns: TRUE on success.
* Returns: aspect ratio.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_get_brush_aspect_ratio (gdouble aspect)
gdouble
gimp_context_get_brush_aspect_ratio (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
gdouble aspect = 0.0;
return_vals = gimp_run_procedure ("gimp-context-get-brush-aspect-ratio",
&nreturn_vals,
GIMP_PDB_FLOAT, aspect,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
aspect = return_vals[1].data.d_float;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
return aspect;
}
/**
......@@ -790,33 +788,32 @@ gimp_context_set_brush_aspect_ratio (gdouble aspect)
/**
* gimp_context_get_brush_angle:
* @angle: angle in degrees.
*
* Get brush angle in degrees.
*
* Set the angle in degrees for brush based paint tools.
*
* Returns: TRUE on success.
* Returns: angle in degrees.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_get_brush_angle (gdouble angle)
gdouble
gimp_context_get_brush_angle (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
gdouble angle = 0.0;
return_vals = gimp_run_procedure ("gimp-context-get-brush-angle",
&nreturn_vals,
GIMP_PDB_FLOAT, angle,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
angle = return_vals[1].data.d_float;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
return angle;
}
/**
......
......@@ -51,12 +51,12 @@ 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);
gboolean gimp_context_get_brush_size (gdouble size);
gdouble gimp_context_get_brush_size (void);
gboolean gimp_context_set_brush_size (gdouble size);
gboolean gimp_context_set_brush_default_size (void);
gboolean gimp_context_get_brush_aspect_ratio (gdouble aspect);
gdouble gimp_context_get_brush_aspect_ratio (void);
gboolean gimp_context_set_brush_aspect_ratio (gdouble aspect);
gboolean gimp_context_get_brush_angle (gdouble angle);
gdouble gimp_context_get_brush_angle (void);
gboolean gimp_context_set_brush_angle (gdouble angle);
gchar* gimp_context_get_dynamics (void);
gboolean gimp_context_set_dynamics (const gchar *name);
......
......@@ -493,7 +493,7 @@ sub context_get_brush_size {
&ejs_pdb_misc('2012', '2.8');
@inargs = (
@outargs = (
{ name => "size", type => "0 < float",
desc => "brush size in pixels" }
);
......@@ -622,7 +622,7 @@ sub context_get_brush_aspect_ratio {
&ejs_pdb_misc('2012', '2.8');
@inargs = (
@outargs = (
{ name => "aspect", type => "-20 <= float <= 20",
desc => "aspect ratio" }
);
......@@ -682,7 +682,7 @@ sub context_get_brush_angle {
&ejs_pdb_misc('2012', '2.8');
@inargs = (
@outargs = (
{ name => "angle", type => "-180 <= float <= 180",
desc => "angle in degrees" }
);
......
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