diff --git a/ChangeLog b/ChangeLog index 3957b16e8e..f6a6dd253c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2001-10-26 Michael Natterer + + * tools/pdbgen/pdb/gradient_select.pdb: removed + gradients_get_gradient_data() here... + + * tools/pdbgen/pdb/gradients.pdb: ...and added it here. + + * app/pdb/gradient_select_cmds.c + * app/pdb/gradients_cmds.c + * app/pdb/internal_procs.c + * libgimp/gimpgradients_pdb.[ch] + * libgimp/gimpgradientselect_pdb.[ch]: regenerated. + + * app/core/gimpgradient.h: added GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE + here... + + * app/gui/gradient-select.h: ...removed it here. + + * libgimp/Makefile.am + * libgimp/gimp.h + * libgimp/gimpgradientselect.[ch]: removed. We don't wrap + _gradients_get_gradient_data() with gradients_get_gradient_data() + any more but call the PDB wrapper directly. + + API CHANGE: Arguments 2 and 3 are swapped now! + + * plug-ins/FractalExplorer/Dialogs.c: changed accordingly. + 2001-10-25 Michael Natterer * configure.in: generate app/file/Makefile diff --git a/app/core/gimpgradient.h b/app/core/gimpgradient.h index b65a7bf81e..e7c4f3bb06 100644 --- a/app/core/gimpgradient.h +++ b/app/core/gimpgradient.h @@ -25,6 +25,8 @@ #define GIMP_GRADIENT_FILE_EXTENSION ".ggr" +#define GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE 40 + typedef enum { diff --git a/app/gui/gradient-select.h b/app/gui/gradient-select.h index 00901ba3ae..34da20e5a5 100644 --- a/app/gui/gradient-select.h +++ b/app/gui/gradient-select.h @@ -20,9 +20,6 @@ #define __GRADIENT_SELECT_H__ -#define GRADIENT_SAMPLE_SIZE 40 - - typedef struct _GradientSelect GradientSelect; struct _GradientSelect diff --git a/app/pdb/gradient_select_cmds.c b/app/pdb/gradient_select_cmds.c index c505f0be8b..a32a17ab7e 100644 --- a/app/pdb/gradient_select_cmds.c +++ b/app/pdb/gradient_select_cmds.c @@ -40,7 +40,6 @@ static ProcRecord gradients_popup_proc; static ProcRecord gradients_close_popup_proc; static ProcRecord gradients_set_popup_proc; -static ProcRecord gradients_get_gradient_data_proc; void register_gradient_select_procs (Gimp *gimp) @@ -48,7 +47,6 @@ register_gradient_select_procs (Gimp *gimp) procedural_db_register (gimp, &gradients_popup_proc); procedural_db_register (gimp, &gradients_close_popup_proc); procedural_db_register (gimp, &gradients_set_popup_proc); - procedural_db_register (gimp, &gradients_get_gradient_data_proc); } static Argument * @@ -75,7 +73,7 @@ gradients_popup_invoker (Gimp *gimp, sample_size = args[3].value.pdb_int; if (sample_size <= 0 || sample_size > 10000) - sample_size = GRADIENT_SAMPLE_SIZE; + sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE; if (success) { @@ -264,126 +262,3 @@ static ProcRecord gradients_set_popup_proc = NULL, { { gradients_set_popup_invoker } } }; - -static Argument * -gradients_get_gradient_data_invoker (Gimp *gimp, - Argument *args) -{ - gboolean success = TRUE; - Argument *return_args; - gchar *name; - gint32 sample_size; - gdouble *values = NULL; - GimpGradient *gradient = NULL; - - name = (gchar *) args[0].value.pdb_pointer; - if (name == NULL) - success = FALSE; - - sample_size = args[1].value.pdb_int; - if (sample_size <= 0 || sample_size > 10000) - sample_size = GRADIENT_SAMPLE_SIZE; - - if (success) - { - if (strlen (name)) - { - success = FALSE; - - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - - if (gradient) - success = TRUE; - } - else - success = (gradient = gimp_context_get_gradient (gimp_get_current_context (gimp))) != NULL; - - if (success) - { - gdouble *pv; - gdouble pos, delta; - GimpRGB color; - gint i; - - i = sample_size; - pos = 0.0; - delta = 1.0 / (i - 1); - - pv = values = g_new (gdouble, i * 4); - - while (i--) - { - gimp_gradient_get_color_at (gradient, pos, &color); - - *pv++ = color.r; - *pv++ = color.g; - *pv++ = color.b; - *pv++ = color.a; - - pos += delta; - } - } - } - - return_args = procedural_db_return_args (&gradients_get_gradient_data_proc, success); - - if (success) - { - return_args[1].value.pdb_pointer = g_strdup (GIMP_OBJECT (gradient)->name); - return_args[2].value.pdb_int = sample_size * 4; - return_args[3].value.pdb_pointer = values; - } - - return return_args; -} - -static ProcArg gradients_get_gradient_data_inargs[] = -{ - { - GIMP_PDB_STRING, - "name", - "The gradient name (\"\" means current active gradient)" - }, - { - GIMP_PDB_INT32, - "sample_size", - "Size of the sample to return when the gradient is changed (0 < sample_size <= 10000)" - } -}; - -static ProcArg gradients_get_gradient_data_outargs[] = -{ - { - GIMP_PDB_STRING, - "name", - "The gradient name" - }, - { - GIMP_PDB_INT32, - "width", - "The gradient sample width (r,g,b,a)" - }, - { - GIMP_PDB_FLOATARRAY, - "grad_data", - "The gradient sample data" - } -}; - -static ProcRecord gradients_get_gradient_data_proc = -{ - "gimp_gradients_get_gradient_data", - "Retrieve information about the specified gradient (including data).", - "This procedure retrieves information about the gradient. This includes the gradient name, and the sample data for the gradient.", - "Andy Thomas", - "Andy Thomas", - "1998", - GIMP_INTERNAL, - 2, - gradients_get_gradient_data_inargs, - 3, - gradients_get_gradient_data_outargs, - { { gradients_get_gradient_data_invoker } } -}; diff --git a/app/pdb/gradients_cmds.c b/app/pdb/gradients_cmds.c index fd477e074c..23612e8829 100644 --- a/app/pdb/gradients_cmds.c +++ b/app/pdb/gradients_cmds.c @@ -40,6 +40,7 @@ static ProcRecord gradients_get_active_proc; static ProcRecord gradients_set_active_proc; static ProcRecord gradients_sample_uniform_proc; static ProcRecord gradients_sample_custom_proc; +static ProcRecord gradients_get_gradient_data_proc; void register_gradients_procs (Gimp *gimp) @@ -49,6 +50,7 @@ register_gradients_procs (Gimp *gimp) procedural_db_register (gimp, &gradients_set_active_proc); procedural_db_register (gimp, &gradients_sample_uniform_proc); procedural_db_register (gimp, &gradients_sample_custom_proc); + procedural_db_register (gimp, &gradients_get_gradient_data_proc); } static Argument * @@ -407,3 +409,126 @@ static ProcRecord gradients_sample_custom_proc = gradients_sample_custom_outargs, { { gradients_sample_custom_invoker } } }; + +static Argument * +gradients_get_gradient_data_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + gchar *name; + gint32 sample_size; + gdouble *values = NULL; + GimpGradient *gradient = NULL; + + name = (gchar *) args[0].value.pdb_pointer; + if (name == NULL) + success = FALSE; + + sample_size = args[1].value.pdb_int; + if (sample_size <= 0 || sample_size > 10000) + sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE; + + if (success) + { + if (strlen (name)) + { + success = FALSE; + + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, + name); + + if (gradient) + success = TRUE; + } + else + success = (gradient = gimp_context_get_gradient (gimp_get_current_context (gimp))) != NULL; + + if (success) + { + gdouble *pv; + gdouble pos, delta; + GimpRGB color; + gint i; + + i = sample_size; + pos = 0.0; + delta = 1.0 / (i - 1); + + pv = values = g_new (gdouble, i * 4); + + while (i--) + { + gimp_gradient_get_color_at (gradient, pos, &color); + + *pv++ = color.r; + *pv++ = color.g; + *pv++ = color.b; + *pv++ = color.a; + + pos += delta; + } + } + } + + return_args = procedural_db_return_args (&gradients_get_gradient_data_proc, success); + + if (success) + { + return_args[1].value.pdb_pointer = g_strdup (GIMP_OBJECT (gradient)->name); + return_args[2].value.pdb_int = sample_size * 4; + return_args[3].value.pdb_pointer = values; + } + + return return_args; +} + +static ProcArg gradients_get_gradient_data_inargs[] = +{ + { + GIMP_PDB_STRING, + "name", + "The gradient name (\"\" means current active gradient)" + }, + { + GIMP_PDB_INT32, + "sample_size", + "Size of the sample to return when the gradient is changed (0 < sample_size <= 10000)" + } +}; + +static ProcArg gradients_get_gradient_data_outargs[] = +{ + { + GIMP_PDB_STRING, + "name", + "The gradient name" + }, + { + GIMP_PDB_INT32, + "width", + "The gradient sample width (r,g,b,a)" + }, + { + GIMP_PDB_FLOATARRAY, + "grad_data", + "The gradient sample data" + } +}; + +static ProcRecord gradients_get_gradient_data_proc = +{ + "gimp_gradients_get_gradient_data", + "Retrieve information about the specified gradient (including data).", + "This procedure retrieves information about the gradient. This includes the gradient name, and the sample data for the gradient.", + "Federico Mena Quintero", + "Federico Mena Quintero", + "1997", + GIMP_INTERNAL, + 2, + gradients_get_gradient_data_inargs, + 3, + gradients_get_gradient_data_outargs, + { { gradients_get_gradient_data_invoker } } +}; diff --git a/app/pdb/internal_procs.c b/app/pdb/internal_procs.c index c52e4a186d..861d5c1523 100644 --- a/app/pdb/internal_procs.c +++ b/app/pdb/internal_procs.c @@ -108,7 +108,7 @@ internal_procs_init (Gimp *gimp, (* status_callback) (NULL, _("Gradients"), 0.291); register_gradients_procs (gimp); - (* status_callback) (NULL, _("Gradient UI"), 0.307); + (* status_callback) (NULL, _("Gradient UI"), 0.31); register_gradient_select_procs (gimp); (* status_callback) (NULL, _("Guide procedures"), 0.319); diff --git a/libgimp/Makefile.am b/libgimp/Makefile.am index 4dc4a0db2b..726e310dfe 100644 --- a/libgimp/Makefile.am +++ b/libgimp/Makefile.am @@ -104,8 +104,6 @@ libgimp_1_3_la_SOURCES = @STRIP_BEGIN@ \ gimpchannel.h \ gimpdrawable.c \ gimpdrawable.h \ - gimpgradientselect.c \ - gimpgradientselect.h \ gimphelp.c \ gimpimage.c \ gimpimage.h \ @@ -151,7 +149,6 @@ gimpinclude_HEADERS = @STRIP_BEGIN@ \ gimpchannel.h \ gimpdrawable.h \ gimpenums.h \ - gimpgradientselect.h \ gimpimage.h \ gimplayer.h \ gimpmodule.h \ diff --git a/libgimp/gimp.h b/libgimp/gimp.h index 7a7fb5be82..33da590f6a 100644 --- a/libgimp/gimp.h +++ b/libgimp/gimp.h @@ -33,7 +33,6 @@ #include #include -#include #include #include #include diff --git a/libgimp/gimpgradients_pdb.c b/libgimp/gimpgradients_pdb.c index 9306785072..6347f44822 100644 --- a/libgimp/gimpgradients_pdb.c +++ b/libgimp/gimpgradients_pdb.c @@ -212,3 +212,49 @@ gimp_gradients_sample_custom (gint num_samples, return color_samples; } + +/** + * gimp_gradients_get_gradient_data: + * @name: The gradient name (\"\" means current active gradient). + * @sample_size: Size of the sample to return when the gradient is changed. + * @width: The gradient sample width (r,g,b,a). + * @grad_data: The gradient sample data. + * + * Retrieve information about the specified gradient (including data). + * + * This procedure retrieves information about the gradient. This + * includes the gradient name, and the sample data for the gradient. + * + * Returns: The gradient name. + */ +gchar * +gimp_gradients_get_gradient_data (gchar *name, + gint sample_size, + gint *width, + gdouble **grad_data) +{ + GimpParam *return_vals; + gint nreturn_vals; + gchar *ret_name = NULL; + + return_vals = gimp_run_procedure ("gimp_gradients_get_gradient_data", + &nreturn_vals, + GIMP_PDB_STRING, name, + GIMP_PDB_INT32, sample_size, + GIMP_PDB_END); + + *width = 0; + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + { + ret_name = g_strdup (return_vals[1].data.d_string); + *width = return_vals[2].data.d_int32; + *grad_data = g_new (gdouble, *width); + memcpy (*grad_data, return_vals[3].data.d_floatarray, + *width * sizeof (gdouble)); + } + + gimp_destroy_params (return_vals, nreturn_vals); + + return ret_name; +} diff --git a/libgimp/gimpgradients_pdb.h b/libgimp/gimpgradients_pdb.h index 6788f4093c..c1518068af 100644 --- a/libgimp/gimpgradients_pdb.h +++ b/libgimp/gimpgradients_pdb.h @@ -31,12 +31,16 @@ extern "C" { /* For information look into the C source or the html documentation */ -gchar** gimp_gradients_get_list (gint *num_gradients); -gchar* gimp_gradients_get_active (void); -gboolean gimp_gradients_set_active (gchar *name); -gdouble* gimp_gradients_sample_uniform (gint num_samples); -gdouble* gimp_gradients_sample_custom (gint num_samples, - gdouble *positions); +gchar** gimp_gradients_get_list (gint *num_gradients); +gchar* gimp_gradients_get_active (void); +gboolean gimp_gradients_set_active (gchar *name); +gdouble* gimp_gradients_sample_uniform (gint num_samples); +gdouble* gimp_gradients_sample_custom (gint num_samples, + gdouble *positions); +gchar* gimp_gradients_get_gradient_data (gchar *name, + gint sample_size, + gint *width, + gdouble **grad_data); #ifdef __cplusplus diff --git a/libgimp/gimpgradientselect.c b/libgimp/gimpgradientselect.c deleted file mode 100644 index a44a77e5d7..0000000000 --- a/libgimp/gimpgradientselect.c +++ /dev/null @@ -1,31 +0,0 @@ -/* LIBGIMP - The GIMP Library - * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball - * - * gimpgradientselect.c - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "gimp.h" - -gchar * -gimp_gradients_get_gradient_data (gchar *name, - gint *width, - gint sample_size, - gdouble **grad_data) -{ - return _gimp_gradients_get_gradient_data (name, sample_size, width, grad_data); -} diff --git a/libgimp/gimpgradientselect.h b/libgimp/gimpgradientselect.h deleted file mode 100644 index 04703fb19d..0000000000 --- a/libgimp/gimpgradientselect.h +++ /dev/null @@ -1,42 +0,0 @@ -/* LIBGIMP - The GIMP Library - * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball - * - * gimpgradientselect.h - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GIMP_GRADIENT_SELECT_H__ -#define __GIMP_GRADIENT_SELECT_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* For information look into the C source or the html documentation */ - - -gchar * gimp_gradients_get_gradient_data (gchar *name, - gint *width, - gint sample_size, - gdouble **grad_data); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __GIMP_GRADIENT_SELECT_H__ */ diff --git a/libgimp/gimpgradientselect_pdb.c b/libgimp/gimpgradientselect_pdb.c index 5bb73e75ad..53b6ec5788 100644 --- a/libgimp/gimpgradientselect_pdb.c +++ b/libgimp/gimpgradientselect_pdb.c @@ -21,8 +21,6 @@ /* NOTE: This file is autogenerated by pdbgen.pl */ -#include - #include "gimp.h" /** @@ -123,49 +121,3 @@ gimp_gradients_set_popup (gchar *gradients_callback, return success; } - -/** - * _gimp_gradients_get_gradient_data: - * @name: The gradient name (\"\" means current active gradient). - * @sample_size: Size of the sample to return when the gradient is changed. - * @width: The gradient sample width (r,g,b,a). - * @grad_data: The gradient sample data. - * - * Retrieve information about the specified gradient (including data). - * - * This procedure retrieves information about the gradient. This - * includes the gradient name, and the sample data for the gradient. - * - * Returns: The gradient name. - */ -gchar * -_gimp_gradients_get_gradient_data (gchar *name, - gint sample_size, - gint *width, - gdouble **grad_data) -{ - GimpParam *return_vals; - gint nreturn_vals; - gchar *ret_name = NULL; - - return_vals = gimp_run_procedure ("gimp_gradients_get_gradient_data", - &nreturn_vals, - GIMP_PDB_STRING, name, - GIMP_PDB_INT32, sample_size, - GIMP_PDB_END); - - *width = 0; - - if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) - { - ret_name = g_strdup (return_vals[1].data.d_string); - *width = return_vals[2].data.d_int32; - *grad_data = g_new (gdouble, *width); - memcpy (*grad_data, return_vals[3].data.d_floatarray, - *width * sizeof (gdouble)); - } - - gimp_destroy_params (return_vals, nreturn_vals); - - return ret_name; -} diff --git a/libgimp/gimpgradientselect_pdb.h b/libgimp/gimpgradientselect_pdb.h index 81ba18f7dd..8b392da5ea 100644 --- a/libgimp/gimpgradientselect_pdb.h +++ b/libgimp/gimpgradientselect_pdb.h @@ -31,17 +31,13 @@ extern "C" { /* For information look into the C source or the html documentation */ -gboolean gimp_gradients_popup (gchar *gradients_callback, - gchar *popup_title, - gchar *initial_gradient, - gint sample_size); -gboolean gimp_gradients_close_popup (gchar *gradients_callback); -gboolean gimp_gradients_set_popup (gchar *gradients_callback, - gchar *gradient_name); -gchar* _gimp_gradients_get_gradient_data (gchar *name, - gint sample_size, - gint *width, - gdouble **grad_data); +gboolean gimp_gradients_popup (gchar *gradients_callback, + gchar *popup_title, + gchar *initial_gradient, + gint sample_size); +gboolean gimp_gradients_close_popup (gchar *gradients_callback); +gboolean gimp_gradients_set_popup (gchar *gradients_callback, + gchar *gradient_name); #ifdef __cplusplus diff --git a/tools/pdbgen/pdb/gradient_select.pdb b/tools/pdbgen/pdb/gradient_select.pdb index 9470de3855..2c357dcdfb 100644 --- a/tools/pdbgen/pdb/gradient_select.pdb +++ b/tools/pdbgen/pdb/gradient_select.pdb @@ -27,7 +27,7 @@ sub sample_size_arg {{ type => '0 < int32 <= 10000', desc => 'Size of the sample to return when the gradient is changed (%%desc%%)', - on_fail => 'sample_size = GRADIENT_SAMPLE_SIZE;', + on_fail => 'sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE;', no_success => 1 }} @@ -144,90 +144,12 @@ CODE ); } -sub gradients_get_gradient_data { - $blurb = <<'BLURB'; -Retrieve information about the specified gradient (including data). -BLURB - - $help = <<'HELP'; -This procedure retrieves information about the gradient. This includes the -gradient name, and the sample data for the gradient. -HELP - - &pdb_misc; - - @inargs = ( - { name => 'name', type => 'string', - desc => 'The gradient name ("" means current active gradient)' }, - &sample_size_arg - ); - - @outargs = ( - { name => 'name', type => 'string', - desc => 'The gradient name', - alias => 'g_strdup (GIMP_OBJECT (gradient)->name)', no_declare => 1 }, - { name => 'grad_data', type => 'floatarray', alias => 'values', - desc => 'The gradient sample data', init => 1, wrap => 1, - array => { name => 'width', - desc => 'The gradient sample width (r,g,b,a)', - alias => 'sample_size * 4', no_declare => 1 } } - ); - - %invoke = ( - vars => [ 'GimpGradient *gradient = NULL' ], - code => <<'CODE' -{ - if (strlen (name)) - { - success = FALSE; - - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - - if (gradient) - success = TRUE; - } - else - success = (gradient = gimp_context_get_gradient (gimp_get_current_context (gimp))) != NULL; - - if (success) - { - gdouble *pv; - gdouble pos, delta; - GimpRGB color; - gint i; - - i = sample_size; - pos = 0.0; - delta = 1.0 / (i - 1); - - pv = values = g_new (gdouble, i * 4); - - while (i--) - { - gimp_gradient_get_color_at (gradient, pos, &color); - - *pv++ = color.r; - *pv++ = color.g; - *pv++ = color.b; - *pv++ = color.a; - - pos += delta; - } - } -} -CODE - ); -} - @headers = qw( "core/gimp.h" "core/gimpcontext.h" "core/gimpcontainer.h" "core/gimpdatafactory.h" "core/gimpgradient.h" "gui/gui-types.h" "gui/gradient-select.h"); -@procs = qw(gradients_popup gradients_close_popup gradients_set_popup - gradients_get_gradient_data); +@procs = qw(gradients_popup gradients_close_popup gradients_set_popup); %exports = (app => [@procs], lib => [@procs]); $desc = 'Gradient UI'; diff --git a/tools/pdbgen/pdb/gradients.pdb b/tools/pdbgen/pdb/gradients.pdb index ffd21062be..e3da406141 100644 --- a/tools/pdbgen/pdb/gradients.pdb +++ b/tools/pdbgen/pdb/gradients.pdb @@ -238,12 +238,99 @@ CODE ); } +sub sample_size_arg {{ + name => 'sample_size', + type => '0 < int32 <= 10000', + desc => 'Size of the sample to return when the gradient is changed + (%%desc%%)', + on_fail => 'sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE;', + no_success => 1 +}} + +sub gradients_get_gradient_data { + $blurb = <<'BLURB'; +Retrieve information about the specified gradient (including data). +BLURB + + $help = <<'HELP'; +This procedure retrieves information about the gradient. This includes the +gradient name, and the sample data for the gradient. +HELP + + &pdb_misc; + + @inargs = ( + { name => 'name', type => 'string', + desc => 'The gradient name ("" means current active gradient)' }, + &sample_size_arg + ); + + @outargs = ( + { name => 'name', type => 'string', + desc => 'The gradient name', + alias => 'g_strdup (GIMP_OBJECT (gradient)->name)', no_declare => 1 }, + { name => 'grad_data', type => 'floatarray', alias => 'values', + desc => 'The gradient sample data', init => 1, + array => { name => 'width', + desc => 'The gradient sample width (r,g,b,a)', + alias => 'sample_size * 4', no_declare => 1 } } + ); + + %invoke = ( + vars => [ 'GimpGradient *gradient = NULL' ], + code => <<'CODE' +{ + if (strlen (name)) + { + success = FALSE; + + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, + name); + + if (gradient) + success = TRUE; + } + else + success = (gradient = gimp_context_get_gradient (gimp_get_current_context (gimp))) != NULL; + + if (success) + { + gdouble *pv; + gdouble pos, delta; + GimpRGB color; + gint i; + + i = sample_size; + pos = 0.0; + delta = 1.0 / (i - 1); + + pv = values = g_new (gdouble, i * 4); + + while (i--) + { + gimp_gradient_get_color_at (gradient, pos, &color); + + *pv++ = color.r; + *pv++ = color.g; + *pv++ = color.b; + *pv++ = color.a; + + pos += delta; + } + } +} +CODE + ); +} + @headers = qw("core/gimp.h" "core/gimpcontext.h" "core/gimpcontainer.h" "core/gimpdatafactory.h" "core/gimplist.h" "core/gimpgradient.h"); @procs = qw(gradients_get_list gradients_get_active gradients_set_active - gradients_sample_uniform gradients_sample_custom); + gradients_sample_uniform gradients_sample_custom + gradients_get_gradient_data); %exports = (app => [@procs], lib => [@procs]); $desc = 'Gradients';