Commit b952f80b authored by Michael Natterer's avatar Michael Natterer 😴

Bug 658477 - add PDB support for more paint and ink options

Apply heavily modified patch from Es Swartz which adds PDB API for
brush size, angle and aspect ratio, as well as a full interface for
ink. Changed to patch to add all procedures to the "context" group
instead of creating new PDB groups, properly use the new
GimpPDBContext APIs for paint options, and did some general cleanup.
(Warning, completely untested).
parent c2f68b59
......@@ -86,7 +86,7 @@ typedef enum
GType gimp_ink_blob_type_get_type (void) G_GNUC_CONST;
typedef enum /*< pdb-skip >*/
typedef enum
{
GIMP_INK_BLOB_TYPE_CIRCLE, /*< desc="Circle" >*/
GIMP_INK_BLOB_TYPE_SQUARE, /*< desc="Square" >*/
......
This diff is collapsed.
......@@ -31,6 +31,7 @@
#include "core/gimplist.h"
#include "core/gimppaintinfo.h"
#include "paint/gimpbrushcore.h"
#include "paint/gimppaintoptions.h"
#include "gimppdbcontext.h"
......@@ -394,3 +395,24 @@ gimp_pdb_context_get_paint_options (GimpPDBContext *context,
return (GimpPaintOptions *)
gimp_container_get_child_by_name (context->paint_options_list, name);
}
GList *
gimp_pdb_context_get_brush_options (GimpPDBContext *context)
{
GList *brush_options = NULL;
GList *list;
g_return_val_if_fail (GIMP_IS_PDB_CONTEXT (context), NULL);
for (list = GIMP_LIST (context->paint_options_list)->list;
list;
list = g_list_next (list))
{
GimpPaintOptions *options = list->data;
if (g_type_is_a (options->paint_info->paint_type, GIMP_TYPE_BRUSH_CORE))
brush_options = g_list_prepend (brush_options, options);
}
return g_list_reverse (brush_options);
}
......@@ -70,6 +70,7 @@ GimpContext * gimp_pdb_context_new (Gimp *gimp,
GimpPaintOptions * gimp_pdb_context_get_paint_options (GimpPDBContext *context,
const gchar *name);
GList * gimp_pdb_context_get_brush_options (GimpPDBContext *context);
#endif /* __GIMP_PDB_CONTEXT_H__ */
......@@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 640 procedures registered total */
/* 663 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
......
......@@ -72,12 +72,23 @@ EXPORTS
gimp_context_get_antialias
gimp_context_get_background
gimp_context_get_brush
gimp_context_get_brush_angle
gimp_context_get_brush_aspect_ratio
gimp_context_get_brush_size
gimp_context_get_dynamics
gimp_context_get_feather
gimp_context_get_feather_radius
gimp_context_get_font
gimp_context_get_foreground
gimp_context_get_gradient
gimp_context_get_ink_angle
gimp_context_get_ink_blob_angle
gimp_context_get_ink_blob_aspect_ratio
gimp_context_get_ink_blob_type
gimp_context_get_ink_size
gimp_context_get_ink_size_sensitivity
gimp_context_get_ink_speed_sensitivity
gimp_context_get_ink_tilt_sensitivity
gimp_context_get_interpolation
gimp_context_get_opacity
gimp_context_get_paint_method
......@@ -98,6 +109,10 @@ EXPORTS
gimp_context_set_antialias
gimp_context_set_background
gimp_context_set_brush
gimp_context_set_brush_angle
gimp_context_set_brush_aspect_ratio
gimp_context_set_brush_default_size
gimp_context_set_brush_size
gimp_context_set_default_colors
gimp_context_set_defaults
gimp_context_set_dynamics
......@@ -106,6 +121,14 @@ EXPORTS
gimp_context_set_font
gimp_context_set_foreground
gimp_context_set_gradient
gimp_context_set_ink_angle
gimp_context_set_ink_blob_angle
gimp_context_set_ink_blob_aspect_ratio
gimp_context_set_ink_blob_type
gimp_context_set_ink_size
gimp_context_set_ink_size_sensitivity
gimp_context_set_ink_speed_sensitivity
gimp_context_set_ink_tilt_sensitivity
gimp_context_set_interpolation
gimp_context_set_opacity
gimp_context_set_paint_method
......
......@@ -634,6 +634,222 @@ gimp_context_set_brush (const gchar *name)
return success;
}
/**
* 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.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_get_brush_size (gdouble size)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
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;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_context_set_brush_size:
* @size: brush size in pixels.
*
* Set brush size in pixels.
*
* Set the brush size in pixels for brush based paint tools.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_set_brush_size (gdouble size)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-brush-size",
&nreturn_vals,
GIMP_PDB_FLOAT, size,
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_size:
*
* Set brush size to its default.
*
* Set the brush size to the default (max of width and height) for
* paintbrush, airbrush, or pencil tools.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_set_brush_default_size (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-brush-default-size",
&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_brush_aspect_ratio:
* @aspect: aspect ratio.
*
* Get brush aspect ratio.
*
* Set the aspect ratio for brush based paint tools.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_get_brush_aspect_ratio (gdouble aspect)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
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;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_context_set_brush_aspect_ratio:
* @aspect: aspect ratio.
*
* Set brush aspect ratio.
*
* Set the aspect ratio for brush based paint tools.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_set_brush_aspect_ratio (gdouble aspect)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-brush-aspect-ratio",
&nreturn_vals,
GIMP_PDB_FLOAT, aspect,
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_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.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_get_brush_angle (gdouble angle)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
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;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_context_set_brush_angle:
* @angle: angle in degrees.
*
* Set brush angle in degrees.
*
* Set the angle in degrees for brush based paint tools.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_set_brush_angle (gdouble angle)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-brush-angle",
&nreturn_vals,
GIMP_PDB_FLOAT, angle,
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:
*
......@@ -1790,3 +2006,491 @@ gimp_context_set_transform_recursion (gint transform_recursion)
return success;
}
/**
* gimp_context_get_ink_size:
*
* Get ink blob size in pixels.
*
* Get the ink blob size in pixels for ink tool.
*
* Returns: ink blob size in pixels.
*
* Since: GIMP 2.8
**/
gdouble
gimp_context_get_ink_size (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gdouble size = 0.0;
return_vals = gimp_run_procedure ("gimp-context-get-ink-size",
&nreturn_vals,
GIMP_PDB_END);
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 size;
}
/**
* gimp_context_set_ink_size:
* @size: ink blob size in pixels.
*
* Set ink blob size in pixels.
*
* Set the ink blob size in pixels for ink tool.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_set_ink_size (gdouble size)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-ink-size",
&nreturn_vals,
GIMP_PDB_FLOAT, size,
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_ink_angle:
*
* Get ink angle in degrees.
*
* Get the ink angle in degrees for ink tool.
*
* Returns: ink angle in degrees.
*
* Since: GIMP 2.8
**/
gdouble
gimp_context_get_ink_angle (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gdouble angle = 0.0;
return_vals = gimp_run_procedure ("gimp-context-get-ink-angle",
&nreturn_vals,
GIMP_PDB_END);
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 angle;
}
/**
* gimp_context_set_ink_angle:
* @angle: ink angle in degrees.
*
* Set ink angle in degrees.
*
* Set the ink angle in degrees for ink tool.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_set_ink_angle (gdouble angle)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-ink-angle",
&nreturn_vals,
GIMP_PDB_FLOAT, angle,
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_ink_size_sensitivity:
*
* Get ink size sensitivity.
*
* Get the ink size sensitivity for ink tool.
*
* Returns: ink size sensitivity.
*
* Since: GIMP 2.8
**/
gdouble
gimp_context_get_ink_size_sensitivity (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gdouble size = 0.0;
return_vals = gimp_run_procedure ("gimp-context-get-ink-size-sensitivity",
&nreturn_vals,
GIMP_PDB_END);
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 size;
}
/**
* gimp_context_set_ink_size_sensitivity:
* @size: ink size sensitivity.
*
* Set ink size sensitivity.
*
* Set the ink size sensitivity for ink tool.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_set_ink_size_sensitivity (gdouble size)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-ink-size-sensitivity",
&nreturn_vals,
GIMP_PDB_FLOAT, size,
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_ink_tilt_sensitivity:
*
* Get ink tilt sensitivity.
*
* Get the ink tilt sensitivity for ink tool.
*
* Returns: ink tilt sensitivity.
*
* Since: GIMP 2.8
**/
gdouble
gimp_context_get_ink_tilt_sensitivity (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gdouble tilt = 0.0;
return_vals = gimp_run_procedure ("gimp-context-get-ink-tilt-sensitivity",
&nreturn_vals,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
tilt = return_vals[1].data.d_float;
gimp_destroy_params (return_vals, nreturn_vals);
return tilt;
}
/**
* gimp_context_set_ink_tilt_sensitivity:
* @tilt: ink tilt sensitivity.
*
* Set ink tilt sensitivity.
*
* Set the ink tilt sensitivity for ink tool.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_set_ink_tilt_sensitivity (gdouble tilt)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-ink-tilt-sensitivity",
&nreturn_vals,
GIMP_PDB_FLOAT, tilt,
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_ink_speed_sensitivity:
*
* Get ink speed sensitivity.
*
* Get the ink speed sensitivity for ink tool.
*
* Returns: ink speed sensitivity.
*
* Since: GIMP 2.8
**/
gdouble
gimp_context_get_ink_speed_sensitivity (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gdouble speed = 0.0;
return_vals = gimp_run_procedure ("gimp-context-get-ink-speed-sensitivity",
&nreturn_vals,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
speed = return_vals[1].data.d_float;
gimp_destroy_params (return_vals, nreturn_vals);
return speed;
}
/**
* gimp_context_set_ink_speed_sensitivity:
* @speed: ink speed sensitivity.
*
* Set ink speed sensitivity.
*
* Set the ink speed sensitivity for ink tool.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_set_ink_speed_sensitivity (gdouble speed)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-ink-speed-sensitivity",
&nreturn_vals,
GIMP_PDB_FLOAT, speed,
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_ink_blob_type:
*
* Get ink blob type.
*
* Get the ink blob type for ink tool.
*
* Returns: Ink blob type.
*
* Since: GIMP 2.8
**/
GimpInkBlobType
gimp_context_get_ink_blob_type (void)
{
GimpParam *return_vals;
gint nreturn_vals;
GimpInkBlobType type = 0;
return_vals = gimp_run_procedure ("gimp-context-get-ink-blob-type",
&nreturn_vals,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
type = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return type;
}
/**
* gimp_context_set_ink_blob_type:
* @type: Ink blob type.
*
* Set ink blob type.
*
* Set the ink blob type for ink tool.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_set_ink_blob_type (GimpInkBlobType type)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-ink-blob-type",
&nreturn_vals,
GIMP_PDB_INT32, type,
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_ink_blob_aspect_ratio:
*
* Get ink blob aspect ratio.
*
* Get the ink blob aspect ratio for ink tool.
*
* Returns: ink blob aspect ratio.
*
* Since: GIMP 2.8
**/
gdouble
gimp_context_get_ink_blob_aspect_ratio (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gdouble aspect = 0.0;
return_vals = gimp_run_procedure ("gimp-context-get-ink-blob-aspect-ratio",
&nreturn_vals,
GIMP_PDB_END);
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 aspect;
}
/**
* gimp_context_set_ink_blob_aspect_ratio:
* @aspect: ink blob aspect ratio.
*
* Set ink blob aspect ratio.
*
* Set the ink blob aspect ratio for ink tool.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_set_ink_blob_aspect_ratio (gdouble aspect)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals