2000-06-02 05:18:04 +08:00
/* The GIMP -- an image manipulation program
2003-07-03 08:47:26 +08:00
* Copyright ( C ) 1995 - 2003 Spencer Kimball and Peter Mattis
2000-06-02 05:18:04 +08:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program 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 General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
/* NOTE: This file is autogenerated by pdbgen.pl. */
2000-12-29 23:22:01 +08:00
# include "config.h"
2001-10-29 02:45:45 +08:00
# include <string.h>
2000-12-29 23:22:01 +08:00
2001-08-17 22:27:31 +08:00
# include <glib-object.h>
2000-12-29 23:22:01 +08:00
2001-08-17 22:27:31 +08:00
# include "pdb-types.h"
2000-06-02 05:18:04 +08:00
# include "procedural_db.h"
2001-07-05 03:31:35 +08:00
# include "core/gimp.h"
2003-09-05 01:04:36 +08:00
# include "core/gimpcontainer-filter.h"
2001-05-09 10:32:03 +08:00
# include "core/gimpcontext.h"
# include "core/gimpdatafactory.h"
# include "core/gimpgradient.h"
# include "core/gimplist.h"
2000-06-02 05:18:04 +08:00
2002-02-21 19:16:00 +08:00
static ProcRecord gradients_refresh_proc ;
2000-06-02 05:18:04 +08:00
static ProcRecord gradients_get_list_proc ;
static ProcRecord gradients_sample_uniform_proc ;
static ProcRecord gradients_sample_custom_proc ;
2001-10-26 05:59:52 +08:00
static ProcRecord gradients_get_gradient_data_proc ;
2000-06-02 05:18:04 +08:00
void
2001-07-05 03:31:35 +08:00
register_gradients_procs ( Gimp * gimp )
2000-06-02 05:18:04 +08:00
{
2002-02-21 19:16:00 +08:00
procedural_db_register ( gimp , & gradients_refresh_proc ) ;
2001-07-05 03:31:35 +08:00
procedural_db_register ( gimp , & gradients_get_list_proc ) ;
procedural_db_register ( gimp , & gradients_sample_uniform_proc ) ;
procedural_db_register ( gimp , & gradients_sample_custom_proc ) ;
2001-10-26 05:59:52 +08:00
procedural_db_register ( gimp , & gradients_get_gradient_data_proc ) ;
2000-06-02 05:18:04 +08:00
}
2002-02-21 19:16:00 +08:00
static Argument *
2004-08-11 02:47:21 +08:00
gradients_refresh_invoker ( Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
Argument * args )
2002-02-21 19:16:00 +08:00
{
2005-04-13 06:58:12 +08:00
gimp_data_factory_data_refresh ( gimp - > gradient_factory ) ;
2002-02-21 19:16:00 +08:00
return procedural_db_return_args ( & gradients_refresh_proc , TRUE ) ;
}
static ProcRecord gradients_refresh_proc =
{
2005-08-03 06:52:23 +08:00
" gimp-gradients-refresh " ,
" gimp-gradients-refresh " ,
2003-12-08 19:58:45 +08:00
" Refresh current gradients. This function always succeeds. " ,
2002-02-21 19:16:00 +08:00
" This procedure retrieves all gradients currently in the user's gradient path and updates the gradient dialogs accordingly. " ,
2006-03-15 05:35:50 +08:00
" Michael Natterer <mitch@gimp.org> " ,
2002-02-21 19:16:00 +08:00
" Michael Natterer " ,
" 2002 " ,
2004-10-06 21:13:08 +08:00
NULL ,
2002-02-21 19:16:00 +08:00
GIMP_INTERNAL ,
0 ,
NULL ,
0 ,
NULL ,
{ { gradients_refresh_invoker } }
} ;
2000-06-02 05:18:04 +08:00
static Argument *
2004-08-11 02:47:21 +08:00
gradients_get_list_invoker ( Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
Argument * args )
2000-06-02 05:18:04 +08:00
{
2003-09-05 01:04:36 +08:00
gboolean success = TRUE ;
2000-06-02 05:18:04 +08:00
Argument * return_args ;
2003-09-05 01:04:36 +08:00
gchar * filter ;
2003-09-04 20:02:31 +08:00
gint32 num_gradients ;
2003-09-05 01:28:13 +08:00
gchar * * gradient_list = NULL ;
2001-02-11 03:35:29 +08:00
2003-09-05 01:04:36 +08:00
filter = ( gchar * ) args [ 0 ] . value . pdb_pointer ;
if ( filter & & ! g_utf8_validate ( filter , - 1 , NULL ) )
success = FALSE ;
if ( success )
gradient_list = gimp_container_get_filtered_name_array ( gimp - > gradient_factory - > container , filter , & num_gradients ) ;
2000-06-02 05:18:04 +08:00
2003-09-05 01:04:36 +08:00
return_args = procedural_db_return_args ( & gradients_get_list_proc , success ) ;
2000-06-02 05:18:04 +08:00
2003-09-05 01:04:36 +08:00
if ( success )
{
return_args [ 1 ] . value . pdb_int = num_gradients ;
return_args [ 2 ] . value . pdb_pointer = gradient_list ;
}
2000-06-02 05:18:04 +08:00
return return_args ;
}
2003-09-05 01:04:36 +08:00
static ProcArg gradients_get_list_inargs [ ] =
{
{
GIMP_PDB_STRING ,
" filter " ,
" An optional regular expression used to filter the list "
}
} ;
2000-06-02 05:18:04 +08:00
static ProcArg gradients_get_list_outargs [ ] =
{
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
2005-08-06 02:19:09 +08:00
" num-gradients " ,
2000-06-02 05:18:04 +08:00
" The number of loaded gradients "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_STRINGARRAY ,
2005-08-06 02:19:09 +08:00
" gradient-list " ,
2000-06-02 05:18:04 +08:00
" The list of gradient names "
}
} ;
static ProcRecord gradients_get_list_proc =
{
2005-08-03 06:52:23 +08:00
" gimp-gradients-get-list " ,
" gimp-gradients-get-list " ,
2000-06-02 05:18:04 +08:00
" Retrieve the list of loaded gradients. " ,
2005-08-03 06:52:23 +08:00
" This procedure returns a list of the gradients that are currently loaded. You can later use the 'gimp-context-set-gradient' function to set the active gradient. " ,
2000-06-02 05:18:04 +08:00
" Federico Mena Quintero " ,
" Federico Mena Quintero " ,
" 1997 " ,
2004-10-06 21:13:08 +08:00
NULL ,
2001-05-21 21:58:46 +08:00
GIMP_INTERNAL ,
2003-09-05 01:04:36 +08:00
1 ,
gradients_get_list_inargs ,
2000-06-02 05:18:04 +08:00
2 ,
gradients_get_list_outargs ,
{ { gradients_get_list_invoker } }
} ;
static Argument *
2004-08-11 02:47:21 +08:00
gradients_sample_uniform_invoker ( Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
Argument * args )
2000-06-02 05:18:04 +08:00
{
gboolean success = TRUE ;
Argument * return_args ;
gint32 i ;
2003-08-18 20:17:21 +08:00
gboolean reverse ;
2000-06-02 05:18:04 +08:00
gint32 array_length = 0 ;
gdouble * color_samples = NULL ;
i = args [ 0 ] . value . pdb_int ;
if ( i < 2 )
success = FALSE ;
2003-08-18 20:17:21 +08:00
reverse = args [ 1 ] . value . pdb_int ? TRUE : FALSE ;
2000-06-02 05:18:04 +08:00
if ( success )
{
2006-03-15 05:35:50 +08:00
GimpGradient * gradient ;
2005-02-27 07:55:50 +08:00
GimpGradientSegment * seg = NULL ;
2006-03-15 05:35:50 +08:00
gdouble pos , delta ;
GimpRGB color ;
gdouble * pv ;
2005-02-27 07:55:50 +08:00
2004-09-23 23:05:48 +08:00
pos = 0.0 ;
2000-06-02 05:18:04 +08:00
delta = 1.0 / ( i - 1 ) ;
2004-03-27 00:38:44 +08:00
2000-06-02 05:18:04 +08:00
array_length = i * 4 ;
2004-03-27 00:38:44 +08:00
2000-06-02 05:18:04 +08:00
pv = color_samples = g_new ( gdouble , array_length ) ;
2004-03-27 00:38:44 +08:00
2004-04-15 07:37:34 +08:00
gradient = gimp_context_get_gradient ( context ) ;
2004-03-27 00:38:44 +08:00
2000-06-02 05:18:04 +08:00
while ( i - - )
2004-03-27 00:49:18 +08:00
{
2005-02-27 07:55:50 +08:00
seg = gimp_gradient_get_color_at ( gradient , seg , pos , reverse , & color ) ;
2004-03-27 00:38:44 +08:00
2004-03-27 00:49:18 +08:00
* pv + + = color . r ;
* pv + + = color . g ;
* pv + + = color . b ;
* pv + + = color . a ;
2004-03-27 00:38:44 +08:00
2004-03-27 00:49:18 +08:00
pos + = delta ;
}
2000-06-02 05:18:04 +08:00
}
return_args = procedural_db_return_args ( & gradients_sample_uniform_proc , success ) ;
if ( success )
{
return_args [ 1 ] . value . pdb_int = array_length ;
return_args [ 2 ] . value . pdb_pointer = color_samples ;
}
return return_args ;
}
static ProcArg gradients_sample_uniform_inargs [ ] =
{
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
2005-08-06 02:19:09 +08:00
" num-samples " ,
2000-06-02 05:18:04 +08:00
" The number of samples to take "
2003-08-18 20:17:21 +08:00
} ,
{
GIMP_PDB_INT32 ,
" reverse " ,
" Use the reverse gradient (TRUE or FALSE) "
2000-06-02 05:18:04 +08:00
}
} ;
static ProcArg gradients_sample_uniform_outargs [ ] =
{
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
2005-08-06 02:19:09 +08:00
" array-length " ,
2000-06-02 05:18:04 +08:00
" Length of the color_samples array (4 * num_samples) "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_FLOATARRAY ,
2005-08-06 02:19:09 +08:00
" color-samples " ,
2000-06-02 05:18:04 +08:00
" Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An } "
}
} ;
static ProcRecord gradients_sample_uniform_proc =
{
2005-08-03 06:52:23 +08:00
" gimp-gradients-sample-uniform " ,
" gimp-gradients-sample-uniform " ,
" This procedure is deprecated! Use 'gimp-gradient-get-uniform-samples' instead. " ,
" This procedure is deprecated! Use 'gimp-gradient-get-uniform-samples' instead. " ,
2004-10-06 07:28:17 +08:00
" " ,
" " ,
" " ,
2005-08-03 06:52:23 +08:00
" gimp-gradient-get-uniform-samples " ,
2001-05-21 21:58:46 +08:00
GIMP_INTERNAL ,
2003-08-18 20:17:21 +08:00
2 ,
2000-06-02 05:18:04 +08:00
gradients_sample_uniform_inargs ,
2 ,
gradients_sample_uniform_outargs ,
{ { gradients_sample_uniform_invoker } }
} ;
static Argument *
2004-08-11 02:47:21 +08:00
gradients_sample_custom_invoker ( Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
Argument * args )
2000-06-02 05:18:04 +08:00
{
gboolean success = TRUE ;
Argument * return_args ;
gint32 i ;
gdouble * pos ;
2003-08-18 20:17:21 +08:00
gboolean reverse ;
2000-06-02 05:18:04 +08:00
gint32 array_length = 0 ;
gdouble * color_samples = NULL ;
i = args [ 0 ] . value . pdb_int ;
if ( i < = 0 )
success = FALSE ;
pos = ( gdouble * ) args [ 1 ] . value . pdb_pointer ;
2003-08-18 20:17:21 +08:00
reverse = args [ 2 ] . value . pdb_int ? TRUE : FALSE ;
2000-06-02 05:18:04 +08:00
if ( success )
{
2006-03-15 05:35:50 +08:00
GimpGradient * gradient ;
2005-02-27 07:55:50 +08:00
GimpGradientSegment * seg = NULL ;
2006-03-15 05:35:50 +08:00
GimpRGB color ;
gdouble * pv ;
2005-02-27 07:55:50 +08:00
2000-06-02 05:18:04 +08:00
array_length = i * 4 ;
2004-03-27 00:38:44 +08:00
2000-06-02 05:18:04 +08:00
pv = color_samples = g_new ( gdouble , array_length ) ;
2004-03-27 00:38:44 +08:00
2004-04-15 07:37:34 +08:00
gradient = gimp_context_get_gradient ( context ) ;
2004-03-27 00:38:44 +08:00
2000-06-02 05:18:04 +08:00
while ( i - - )
2004-03-27 00:49:18 +08:00
{
2005-02-27 07:55:50 +08:00
seg = gimp_gradient_get_color_at ( gradient , seg , * pos , reverse , & color ) ;
2004-03-27 00:38:44 +08:00
2004-03-27 00:49:18 +08:00
* pv + + = color . r ;
* pv + + = color . g ;
* pv + + = color . b ;
* pv + + = color . a ;
2004-03-27 00:38:44 +08:00
2004-03-27 00:49:18 +08:00
pos + + ;
}
2000-06-02 05:18:04 +08:00
}
return_args = procedural_db_return_args ( & gradients_sample_custom_proc , success ) ;
if ( success )
{
return_args [ 1 ] . value . pdb_int = array_length ;
return_args [ 2 ] . value . pdb_pointer = color_samples ;
}
return return_args ;
}
static ProcArg gradients_sample_custom_inargs [ ] =
{
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
2005-08-06 02:19:09 +08:00
" num-samples " ,
2000-06-02 05:18:04 +08:00
" The number of samples to take "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_FLOATARRAY ,
2000-06-02 05:18:04 +08:00
" positions " ,
" The list of positions to sample along the gradient "
2003-08-18 20:17:21 +08:00
} ,
{
GIMP_PDB_INT32 ,
" reverse " ,
" Use the reverse gradient (TRUE or FALSE) "
2000-06-02 05:18:04 +08:00
}
} ;
static ProcArg gradients_sample_custom_outargs [ ] =
{
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
2005-08-06 02:19:09 +08:00
" array-length " ,
2000-06-02 05:18:04 +08:00
" Length of the color_samples array (4 * num_samples) "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_FLOATARRAY ,
2005-08-06 02:19:09 +08:00
" color-samples " ,
2000-06-02 05:18:04 +08:00
" Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An } "
}
} ;
static ProcRecord gradients_sample_custom_proc =
{
2005-08-03 06:52:23 +08:00
" gimp-gradients-sample-custom " ,
" gimp-gradients-sample-custom " ,
" This procedure is deprecated! Use 'gimp-gradient-get-custom-samples' instead. " ,
" This procedure is deprecated! Use 'gimp-gradient-get-custom-samples' instead. " ,
2004-10-06 07:28:17 +08:00
" " ,
" " ,
" " ,
2005-08-03 06:52:23 +08:00
" gimp-gradient-get-custom-samples " ,
2001-05-21 21:58:46 +08:00
GIMP_INTERNAL ,
2003-08-18 20:17:21 +08:00
3 ,
2000-06-02 05:18:04 +08:00
gradients_sample_custom_inargs ,
2 ,
gradients_sample_custom_outargs ,
{ { gradients_sample_custom_invoker } }
} ;
2001-10-26 05:59:52 +08:00
static Argument *
2004-08-11 02:47:21 +08:00
gradients_get_gradient_data_invoker ( Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
Argument * args )
2001-10-26 05:59:52 +08:00
{
gboolean success = TRUE ;
Argument * return_args ;
gchar * name ;
gint32 sample_size ;
2003-08-18 20:17:21 +08:00
gboolean reverse ;
2001-10-26 05:59:52 +08:00
gdouble * values = NULL ;
GimpGradient * gradient = NULL ;
name = ( gchar * ) args [ 0 ] . value . pdb_pointer ;
2004-09-23 23:05:48 +08:00
if ( name & & ! g_utf8_validate ( name , - 1 , NULL ) )
2001-10-26 05:59:52 +08:00
success = FALSE ;
sample_size = args [ 1 ] . value . pdb_int ;
if ( sample_size < = 0 | | sample_size > 10000 )
sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE ;
2003-08-18 20:17:21 +08:00
reverse = args [ 2 ] . value . pdb_int ? TRUE : FALSE ;
2001-10-26 05:59:52 +08:00
if ( success )
{
2004-09-23 23:05:48 +08:00
if ( name & & strlen ( name ) )
2004-10-06 07:28:17 +08:00
{
gradient = ( GimpGradient * )
gimp_container_get_child_by_name ( gimp - > gradient_factory - > container ,
name ) ;
}
else
{
gradient = gimp_context_get_gradient ( context ) ;
}
2004-03-27 00:38:44 +08:00
2003-07-22 22:24:11 +08:00
if ( gradient )
2004-03-27 00:49:18 +08:00
{
2005-02-27 07:55:50 +08:00
GimpGradientSegment * seg = NULL ;
gdouble * pv ;
gdouble pos , delta ;
GimpRGB color ;
gint i ;
2004-03-27 00:49:18 +08:00
i = sample_size ;
pos = 0.0 ;
delta = 1.0 / ( i - 1 ) ;
pv = values = g_new ( gdouble , i * 4 ) ;
while ( i - - )
{
2005-02-27 07:55:50 +08:00
seg = gimp_gradient_get_color_at ( gradient , seg , pos , reverse , & color ) ;
2004-03-27 00:49:18 +08:00
* pv + + = color . r ;
* pv + + = color . g ;
* pv + + = color . b ;
* pv + + = color . a ;
pos + = delta ;
}
}
2003-12-08 19:58:45 +08:00
else
2004-03-27 00:49:18 +08:00
success = FALSE ;
2001-10-26 05:59:52 +08:00
}
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 ,
2005-08-06 02:19:09 +08:00
" sample-size " ,
2001-10-26 05:59:52 +08:00
" Size of the sample to return when the gradient is changed (0 < sample_size <= 10000) "
2003-08-18 20:17:21 +08:00
} ,
{
GIMP_PDB_INT32 ,
" reverse " ,
" Use the reverse gradient (TRUE or FALSE) "
2001-10-26 05:59:52 +08:00
}
} ;
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 ,
2005-08-06 02:19:09 +08:00
" grad-data " ,
2001-10-26 05:59:52 +08:00
" The gradient sample data "
}
} ;
static ProcRecord gradients_get_gradient_data_proc =
{
2005-08-03 06:52:23 +08:00
" gimp-gradients-get-gradient-data " ,
" gimp-gradients-get-gradient-data " ,
" This procedure is deprecated! Use 'gimp-gradient-get-uniform-samples' instead. " ,
" This procedure is deprecated! Use 'gimp-gradient-get-uniform-samples' instead. " ,
2004-10-06 07:28:17 +08:00
" " ,
" " ,
" " ,
2005-08-03 06:52:23 +08:00
" gimp-gradient-get-uniform-samples " ,
2001-10-26 05:59:52 +08:00
GIMP_INTERNAL ,
2003-08-18 20:17:21 +08:00
3 ,
2001-10-26 05:59:52 +08:00
gradients_get_gradient_data_inargs ,
3 ,
gradients_get_gradient_data_outargs ,
{ { gradients_get_gradient_data_invoker } }
} ;