From 3f4995d3d71f294271a71b707133e098243a7331 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Mon, 16 Apr 2018 11:42:46 +0200 Subject: [PATCH] pdb: add procedures to set the built-in gradients gimp-context-set-gradient-fg-bg-rgb gimp-context-set-gradient-fg-bg-hsv-cw gimp-context-set-gradient-fg-bg-hsv-ccw gimp-context-set-gradient-fg-transparent --- app/pdb/context-cmds.c | 125 ++++++++++++++++++++++++++++++++++++++ app/pdb/internal-procs.c | 2 +- libgimp/gimp.def | 4 ++ libgimp/gimpcontext_pdb.c | 124 +++++++++++++++++++++++++++++++++++++ libgimp/gimpcontext_pdb.h | 4 ++ pdb/groups/context.pdb | 85 ++++++++++++++++++++++++++ 6 files changed, 343 insertions(+), 1 deletion(-) diff --git a/app/pdb/context-cmds.c b/app/pdb/context-cmds.c index dbf9cad303..6c065974bb 100644 --- a/app/pdb/context-cmds.c +++ b/app/pdb/context-cmds.c @@ -32,6 +32,7 @@ #include "pdb-types.h" +#include "core/gimp-gradients.h" #include "core/gimp.h" #include "core/gimpcontainer.h" #include "core/gimpdashpattern.h" @@ -1562,6 +1563,62 @@ context_set_gradient_invoker (GimpProcedure *procedure, error ? *error : NULL); } +static GimpValueArray * +context_set_gradient_fg_bg_rgb_invoker (GimpProcedure *procedure, + Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + const GimpValueArray *args, + GError **error) +{ + gimp_context_set_gradient (context, + gimp_gradients_get_fg_bg_rgb (gimp)); + + return gimp_procedure_get_return_values (procedure, TRUE, NULL); +} + +static GimpValueArray * +context_set_gradient_fg_bg_hsv_cw_invoker (GimpProcedure *procedure, + Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + const GimpValueArray *args, + GError **error) +{ + gimp_context_set_gradient (context, + gimp_gradients_get_fg_bg_hsv_cw (gimp)); + + return gimp_procedure_get_return_values (procedure, TRUE, NULL); +} + +static GimpValueArray * +context_set_gradient_fg_bg_hsv_ccw_invoker (GimpProcedure *procedure, + Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + const GimpValueArray *args, + GError **error) +{ + gimp_context_set_gradient (context, + gimp_gradients_get_fg_bg_hsv_ccw (gimp)); + + return gimp_procedure_get_return_values (procedure, TRUE, NULL); +} + +static GimpValueArray * +context_set_gradient_fg_transparent_invoker (GimpProcedure *procedure, + Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + const GimpValueArray *args, + GError **error) +{ + gimp_context_set_gradient (context, + gimp_gradients_get_fg_transparent (gimp)); + + return gimp_procedure_get_return_values (procedure, TRUE, NULL); +} + static GimpValueArray * context_get_gradient_blend_color_space_invoker (GimpProcedure *procedure, Gimp *gimp, @@ -4319,6 +4376,74 @@ register_context_procs (GimpPDB *pdb) gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); + /* + * gimp-context-set-gradient-fg-bg-rgb + */ + procedure = gimp_procedure_new (context_set_gradient_fg_bg_rgb_invoker); + gimp_object_set_static_name (GIMP_OBJECT (procedure), + "gimp-context-set-gradient-fg-bg-rgb"); + gimp_procedure_set_static_strings (procedure, + "gimp-context-set-gradient-fg-bg-rgb", + "Sets the built-in FG-BG RGB gradient as the active gradient.", + "This procedure sets the built-in FG-BG RGB gradient as the active gradient. The gradient will be used for subsequent gradient operations.", + "Michael Natterer ", + "Michael Natterer", + "2018", + NULL); + gimp_pdb_register_procedure (pdb, procedure); + g_object_unref (procedure); + + /* + * gimp-context-set-gradient-fg-bg-hsv-cw + */ + procedure = gimp_procedure_new (context_set_gradient_fg_bg_hsv_cw_invoker); + gimp_object_set_static_name (GIMP_OBJECT (procedure), + "gimp-context-set-gradient-fg-bg-hsv-cw"); + gimp_procedure_set_static_strings (procedure, + "gimp-context-set-gradient-fg-bg-hsv-cw", + "Sets the built-in FG-BG HSV (cw) gradient as the active gradient.", + "This procedure sets the built-in FG-BG HSV (cw) gradient as the active gradient. The gradient will be used for subsequent gradient operations.", + "Michael Natterer ", + "Michael Natterer", + "2018", + NULL); + gimp_pdb_register_procedure (pdb, procedure); + g_object_unref (procedure); + + /* + * gimp-context-set-gradient-fg-bg-hsv-ccw + */ + procedure = gimp_procedure_new (context_set_gradient_fg_bg_hsv_ccw_invoker); + gimp_object_set_static_name (GIMP_OBJECT (procedure), + "gimp-context-set-gradient-fg-bg-hsv-ccw"); + gimp_procedure_set_static_strings (procedure, + "gimp-context-set-gradient-fg-bg-hsv-ccw", + "Sets the built-in FG-BG HSV (ccw) gradient as the active gradient.", + "This procedure sets the built-in FG-BG HSV (ccw) gradient as the active gradient. The gradient will be used for subsequent gradient operations.", + "Michael Natterer ", + "Michael Natterer", + "2018", + NULL); + gimp_pdb_register_procedure (pdb, procedure); + g_object_unref (procedure); + + /* + * gimp-context-set-gradient-fg-transparent + */ + procedure = gimp_procedure_new (context_set_gradient_fg_transparent_invoker); + gimp_object_set_static_name (GIMP_OBJECT (procedure), + "gimp-context-set-gradient-fg-transparent"); + gimp_procedure_set_static_strings (procedure, + "gimp-context-set-gradient-fg-transparent", + "Sets the built-in FG-Transparent gradient as the active gradient.", + "This procedure sets the built-in FG-Transparent gradient as the active gradient. The gradient will be used for subsequent gradient operations.", + "Michael Natterer ", + "Michael Natterer", + "2018", + NULL); + gimp_pdb_register_procedure (pdb, procedure); + g_object_unref (procedure); + /* * gimp-context-get-gradient-blend-color-space */ diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c index 28657e365e..d2cc538624 100644 --- a/app/pdb/internal-procs.c +++ b/app/pdb/internal-procs.c @@ -28,7 +28,7 @@ #include "internal-procs.h" -/* 828 procedures registered total */ +/* 832 procedures registered total */ void internal_procs_init (GimpPDB *pdb) diff --git a/libgimp/gimp.def b/libgimp/gimp.def index 3e198af503..f3dbc7d585 100644 --- a/libgimp/gimp.def +++ b/libgimp/gimp.def @@ -145,6 +145,10 @@ EXPORTS gimp_context_set_foreground gimp_context_set_gradient gimp_context_set_gradient_blend_color_space + gimp_context_set_gradient_fg_bg_rgb + gimp_context_set_gradient_fg_bg_hsv_cw + gimp_context_set_gradient_fg_bg_hsv_ccw + gimp_context_set_gradient_fg_transparent gimp_context_set_gradient_repeat_mode gimp_context_set_gradient_reverse gimp_context_set_ink_angle diff --git a/libgimp/gimpcontext_pdb.c b/libgimp/gimpcontext_pdb.c index 1102f7f607..4cedbe0bd0 100644 --- a/libgimp/gimpcontext_pdb.c +++ b/libgimp/gimpcontext_pdb.c @@ -1906,6 +1906,130 @@ gimp_context_set_gradient (const gchar *name) return success; } +/** + * gimp_context_set_gradient_fg_bg_rgb: + * + * Sets the built-in FG-BG RGB gradient as the active gradient. + * + * This procedure sets the built-in FG-BG RGB gradient as the active + * gradient. The gradient will be used for subsequent gradient + * operations. + * + * Returns: TRUE on success. + * + * Since: 2.10 + **/ +gboolean +gimp_context_set_gradient_fg_bg_rgb (void) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp-context-set-gradient-fg-bg-rgb", + &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_set_gradient_fg_bg_hsv_cw: + * + * Sets the built-in FG-BG HSV (cw) gradient as the active gradient. + * + * This procedure sets the built-in FG-BG HSV (cw) gradient as the + * active gradient. The gradient will be used for subsequent gradient + * operations. + * + * Returns: TRUE on success. + * + * Since: 2.10 + **/ +gboolean +gimp_context_set_gradient_fg_bg_hsv_cw (void) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp-context-set-gradient-fg-bg-hsv-cw", + &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_set_gradient_fg_bg_hsv_ccw: + * + * Sets the built-in FG-BG HSV (ccw) gradient as the active gradient. + * + * This procedure sets the built-in FG-BG HSV (ccw) gradient as the + * active gradient. The gradient will be used for subsequent gradient + * operations. + * + * Returns: TRUE on success. + * + * Since: 2.10 + **/ +gboolean +gimp_context_set_gradient_fg_bg_hsv_ccw (void) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp-context-set-gradient-fg-bg-hsv-ccw", + &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_set_gradient_fg_transparent: + * + * Sets the built-in FG-Transparent gradient as the active gradient. + * + * This procedure sets the built-in FG-Transparent gradient as the + * active gradient. The gradient will be used for subsequent gradient + * operations. + * + * Returns: TRUE on success. + * + * Since: 2.10 + **/ +gboolean +gimp_context_set_gradient_fg_transparent (void) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp-context-set-gradient-fg-transparent", + &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_gradient_blend_color_space: * diff --git a/libgimp/gimpcontext_pdb.h b/libgimp/gimpcontext_pdb.h index 4869b53117..079604837e 100644 --- a/libgimp/gimpcontext_pdb.h +++ b/libgimp/gimpcontext_pdb.h @@ -92,6 +92,10 @@ gchar* gimp_context_get_pattern (void); gboolean gimp_context_set_pattern (const gchar *name); gchar* gimp_context_get_gradient (void); gboolean gimp_context_set_gradient (const gchar *name); +gboolean gimp_context_set_gradient_fg_bg_rgb (void); +gboolean gimp_context_set_gradient_fg_bg_hsv_cw (void); +gboolean gimp_context_set_gradient_fg_bg_hsv_ccw (void); +gboolean gimp_context_set_gradient_fg_transparent (void); GimpGradientBlendColorSpace gimp_context_get_gradient_blend_color_space (void); gboolean gimp_context_set_gradient_blend_color_space (GimpGradientBlendColorSpace blend_color_space); GimpRepeatMode gimp_context_get_gradient_repeat_mode (void); diff --git a/pdb/groups/context.pdb b/pdb/groups/context.pdb index 0e834bbb59..0b883db477 100644 --- a/pdb/groups/context.pdb +++ b/pdb/groups/context.pdb @@ -1692,6 +1692,86 @@ CODE ); } +sub context_set_gradient_fg_bg_rgb { + $blurb = 'Sets the built-in FG-BG RGB gradient as the active gradient.'; + + $help = <<'HELP'; +This procedure sets the built-in FG-BG RGB gradient as the active +gradient. The gradient will be used for subsequent gradient operations. +HELP + + &mitch_pdb_misc('2018', '2.10'); + + %invoke = ( + code => <<'CODE' +{ + gimp_context_set_gradient (context, + gimp_gradients_get_fg_bg_rgb (gimp)); +} +CODE + ); +} + +sub context_set_gradient_fg_bg_hsv_cw { + $blurb = 'Sets the built-in FG-BG HSV (cw) gradient as the active gradient.'; + + $help = <<'HELP'; +This procedure sets the built-in FG-BG HSV (cw) gradient as the active +gradient. The gradient will be used for subsequent gradient operations. +HELP + + &mitch_pdb_misc('2018', '2.10'); + + %invoke = ( + code => <<'CODE' +{ + gimp_context_set_gradient (context, + gimp_gradients_get_fg_bg_hsv_cw (gimp)); +} +CODE + ); +} + +sub context_set_gradient_fg_bg_hsv_ccw { + $blurb = 'Sets the built-in FG-BG HSV (ccw) gradient as the active gradient.'; + + $help = <<'HELP'; +This procedure sets the built-in FG-BG HSV (ccw) gradient as the active +gradient. The gradient will be used for subsequent gradient operations. +HELP + + &mitch_pdb_misc('2018', '2.10'); + + %invoke = ( + code => <<'CODE' +{ + gimp_context_set_gradient (context, + gimp_gradients_get_fg_bg_hsv_ccw (gimp)); +} +CODE + ); +} + +sub context_set_gradient_fg_transparent { + $blurb = 'Sets the built-in FG-Transparent gradient as the active gradient.'; + + $help = <<'HELP'; +This procedure sets the built-in FG-Transparent gradient as the active +gradient. The gradient will be used for subsequent gradient operations. +HELP + + &mitch_pdb_misc('2018', '2.10'); + + %invoke = ( + code => <<'CODE' +{ + gimp_context_set_gradient (context, + gimp_gradients_get_fg_transparent (gimp)); +} +CODE + ); +} + sub context_set_gradient_blend_color_space { $blurb = 'Set the gradient blend color space.'; $help = 'Set the gradient blend color space for paint tools and the gradient tool.'; @@ -3261,6 +3341,7 @@ CODE } @headers = qw("core/gimp.h" + "core/gimp-gradients.h" "core/gimpcontainer.h" "core/gimpdashpattern.h" "core/gimpdatafactory.h" @@ -3306,6 +3387,10 @@ CODE context_get_mypaint_brush context_set_mypaint_brush context_get_pattern context_set_pattern context_get_gradient context_set_gradient + context_set_gradient_fg_bg_rgb + context_set_gradient_fg_bg_hsv_cw + context_set_gradient_fg_bg_hsv_ccw + context_set_gradient_fg_transparent context_get_gradient_blend_color_space context_set_gradient_blend_color_space context_get_gradient_repeat_mode context_set_gradient_repeat_mode context_get_gradient_reverse context_set_gradient_reverse