2000-06-01 21:18:04 +00:00
/* The GIMP -- an image manipulation program
2003-07-03 00:47:26 +00:00
* Copyright ( C ) 1995 - 2003 Spencer Kimball and Peter Mattis
2000-06-01 21:18:04 +00: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 15:22:01 +00:00
# include "config.h"
2001-10-28 18:45:45 +00:00
# include <string.h>
2000-12-29 15:22:01 +00:00
2001-08-17 14:27:31 +00:00
# include <glib-object.h>
2000-12-29 15:22:01 +00:00
2001-08-17 14:27:31 +00:00
# include "pdb-types.h"
2000-06-01 21:18:04 +00:00
# include "procedural_db.h"
2001-07-04 19:31:35 +00:00
# include "core/gimp.h"
2003-09-04 17:04:36 +00:00
# include "core/gimpcontainer-filter.h"
2001-05-09 02:32:03 +00:00
# include "core/gimpcontext.h"
# include "core/gimpdatafactory.h"
# include "core/gimpgradient.h"
# include "core/gimplist.h"
2000-06-01 21:18:04 +00:00
2002-02-21 11:16:00 +00:00
static ProcRecord gradients_refresh_proc ;
2000-06-01 21:18:04 +00:00
static ProcRecord gradients_get_list_proc ;
static ProcRecord gradients_sample_uniform_proc ;
static ProcRecord gradients_sample_custom_proc ;
2001-10-25 21:59:52 +00:00
static ProcRecord gradients_get_gradient_data_proc ;
2000-06-01 21:18:04 +00:00
void
2001-07-04 19:31:35 +00:00
register_gradients_procs ( Gimp * gimp )
2000-06-01 21:18:04 +00:00
{
2002-02-21 11:16:00 +00:00
procedural_db_register ( gimp , & gradients_refresh_proc ) ;
2001-07-04 19:31:35 +00: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-25 21:59:52 +00:00
procedural_db_register ( gimp , & gradients_get_gradient_data_proc ) ;
2000-06-01 21:18:04 +00:00
}
2002-02-21 11:16:00 +00:00
static Argument *
2006-03-27 19:32:19 +00:00
gradients_refresh_invoker ( ProcRecord * proc_record ,
Gimp * gimp ,
2004-08-10 18:47:21 +00:00
GimpContext * context ,
GimpProgress * progress ,
Argument * args )
2002-02-21 11:16:00 +00:00
{
2005-04-12 22:58:12 +00:00
gimp_data_factory_data_refresh ( gimp - > gradient_factory ) ;
2006-03-27 19:32:19 +00:00
return procedural_db_return_args ( proc_record , TRUE ) ;
2002-02-21 11:16:00 +00:00
}
static ProcRecord gradients_refresh_proc =
{
2005-08-02 22:52:23 +00:00
" gimp-gradients-refresh " ,
" gimp-gradients-refresh " ,
2003-12-08 11:58:45 +00:00
" Refresh current gradients. This function always succeeds. " ,
2002-02-21 11:16:00 +00:00
" This procedure retrieves all gradients currently in the user's gradient path and updates the gradient dialogs accordingly. " ,
2006-03-14 21:35:50 +00:00
" Michael Natterer <mitch@gimp.org> " ,
2002-02-21 11:16:00 +00:00
" Michael Natterer " ,
" 2002 " ,
2004-10-06 13:13:08 +00:00
NULL ,
2002-02-21 11:16:00 +00:00
GIMP_INTERNAL ,
0 ,
NULL ,
0 ,
NULL ,
{ { gradients_refresh_invoker } }
} ;
2000-06-01 21:18:04 +00:00
static Argument *
2006-03-27 19:32:19 +00:00
gradients_get_list_invoker ( ProcRecord * proc_record ,
Gimp * gimp ,
2004-08-10 18:47:21 +00:00
GimpContext * context ,
GimpProgress * progress ,
Argument * args )
2000-06-01 21:18:04 +00:00
{
2003-09-04 17:04:36 +00:00
gboolean success = TRUE ;
2000-06-01 21:18:04 +00:00
Argument * return_args ;
2003-09-04 17:04:36 +00:00
gchar * filter ;
2006-03-15 15:32:39 +00:00
gint32 num_gradients = 0 ;
2003-09-04 17:28:13 +00:00
gchar * * gradient_list = NULL ;
2001-02-10 19:35:29 +00:00
2003-09-04 17:04:36 +00:00
filter = ( gchar * ) args [ 0 ] . value . pdb_pointer ;
if ( filter & & ! g_utf8_validate ( filter , - 1 , NULL ) )
success = FALSE ;
if ( success )
2006-03-22 09:58:08 +00:00
{
gradient_list = gimp_container_get_filtered_name_array ( gimp - > gradient_factory - > container ,
filter , & num_gradients ) ;
}
2000-06-01 21:18:04 +00:00
2006-03-27 19:32:19 +00:00
return_args = procedural_db_return_args ( proc_record , success ) ;
2000-06-01 21:18:04 +00:00
2003-09-04 17:04:36 +00:00
if ( success )
{
return_args [ 1 ] . value . pdb_int = num_gradients ;
return_args [ 2 ] . value . pdb_pointer = gradient_list ;
}
2000-06-01 21:18:04 +00:00
return return_args ;
}
2003-09-04 17:04:36 +00:00
static ProcArg gradients_get_list_inargs [ ] =
{
{
GIMP_PDB_STRING ,
" filter " ,
" An optional regular expression used to filter the list "
}
} ;
2000-06-01 21:18:04 +00:00
static ProcArg gradients_get_list_outargs [ ] =
{
{
2001-05-21 13:58:46 +00:00
GIMP_PDB_INT32 ,
2005-08-05 18:19:09 +00:00
" num-gradients " ,
2000-06-01 21:18:04 +00:00
" The number of loaded gradients "
} ,
{
2001-05-21 13:58:46 +00:00
GIMP_PDB_STRINGARRAY ,
2005-08-05 18:19:09 +00:00
" gradient-list " ,
2000-06-01 21:18:04 +00:00
" The list of gradient names "
}
} ;
static ProcRecord gradients_get_list_proc =
{
2005-08-02 22:52:23 +00:00
" gimp-gradients-get-list " ,
" gimp-gradients-get-list " ,
2000-06-01 21:18:04 +00:00
" Retrieve the list of loaded gradients. " ,
2005-08-02 22:52:23 +00: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-01 21:18:04 +00:00
" Federico Mena Quintero " ,
" Federico Mena Quintero " ,
" 1997 " ,
2004-10-06 13:13:08 +00:00
NULL ,
2001-05-21 13:58:46 +00:00
GIMP_INTERNAL ,
2003-09-04 17:04:36 +00:00
1 ,
gradients_get_list_inargs ,
2000-06-01 21:18:04 +00:00
2 ,
gradients_get_list_outargs ,
{ { gradients_get_list_invoker } }
} ;
static Argument *
2006-03-27 19:32:19 +00:00
gradients_sample_uniform_invoker ( ProcRecord * proc_record ,
Gimp * gimp ,
2004-08-10 18:47:21 +00:00
GimpContext * context ,
GimpProgress * progress ,
Argument * args )
2000-06-01 21:18:04 +00:00
{
gboolean success = TRUE ;
Argument * return_args ;
2006-03-15 15:00:01 +00:00
gint32 num_samples ;
2003-08-18 12:17:21 +00:00
gboolean reverse ;
2000-06-01 21:18:04 +00:00
gint32 array_length = 0 ;
gdouble * color_samples = NULL ;
2006-03-15 15:00:01 +00:00
num_samples = args [ 0 ] . value . pdb_int ;
if ( num_samples < 2 )
2000-06-01 21:18:04 +00:00
success = FALSE ;
2003-08-18 12:17:21 +00:00
reverse = args [ 1 ] . value . pdb_int ? TRUE : FALSE ;
2000-06-01 21:18:04 +00:00
if ( success )
{
2006-03-14 21:35:50 +00:00
GimpGradient * gradient ;
2005-02-26 23:55:50 +00:00
GimpGradientSegment * seg = NULL ;
2006-03-14 21:35:50 +00:00
gdouble pos , delta ;
GimpRGB color ;
gdouble * pv ;
2005-02-26 23:55:50 +00:00
2004-09-23 15:05:48 +00:00
pos = 0.0 ;
2006-03-15 15:00:01 +00:00
delta = 1.0 / ( num_samples - 1 ) ;
2004-03-26 16:38:44 +00:00
2006-03-15 15:00:01 +00:00
array_length = num_samples * 4 ;
2004-03-26 16:38:44 +00:00
2000-06-01 21:18:04 +00:00
pv = color_samples = g_new ( gdouble , array_length ) ;
2004-03-26 16:38:44 +00:00
2004-04-14 23:37:34 +00:00
gradient = gimp_context_get_gradient ( context ) ;
2004-03-26 16:38:44 +00:00
2006-03-15 15:00:01 +00:00
while ( num_samples - - )
2004-03-26 16:49:18 +00:00
{
2005-02-26 23:55:50 +00:00
seg = gimp_gradient_get_color_at ( gradient , seg , pos , reverse , & color ) ;
2004-03-26 16:38:44 +00:00
2004-03-26 16:49:18 +00:00
* pv + + = color . r ;
* pv + + = color . g ;
* pv + + = color . b ;
* pv + + = color . a ;
2004-03-26 16:38:44 +00:00
2004-03-26 16:49:18 +00:00
pos + = delta ;
}
2000-06-01 21:18:04 +00:00
}
2006-03-27 19:32:19 +00:00
return_args = procedural_db_return_args ( proc_record , success ) ;
2000-06-01 21:18:04 +00:00
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 13:58:46 +00:00
GIMP_PDB_INT32 ,
2005-08-05 18:19:09 +00:00
" num-samples " ,
2000-06-01 21:18:04 +00:00
" The number of samples to take "
2003-08-18 12:17:21 +00:00
} ,
{
GIMP_PDB_INT32 ,
" reverse " ,
" Use the reverse gradient (TRUE or FALSE) "
2000-06-01 21:18:04 +00:00
}
} ;
static ProcArg gradients_sample_uniform_outargs [ ] =
{
{
2001-05-21 13:58:46 +00:00
GIMP_PDB_INT32 ,
2005-08-05 18:19:09 +00:00
" array-length " ,
2000-06-01 21:18:04 +00:00
" Length of the color_samples array (4 * num_samples) "
} ,
{
2001-05-21 13:58:46 +00:00
GIMP_PDB_FLOATARRAY ,
2005-08-05 18:19:09 +00:00
" color-samples " ,
2000-06-01 21:18:04 +00:00
" Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An } "
}
} ;
static ProcRecord gradients_sample_uniform_proc =
{
2005-08-02 22:52:23 +00: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-05 23:28:17 +00:00
" " ,
" " ,
" " ,
2005-08-02 22:52:23 +00:00
" gimp-gradient-get-uniform-samples " ,
2001-05-21 13:58:46 +00:00
GIMP_INTERNAL ,
2003-08-18 12:17:21 +00:00
2 ,
2000-06-01 21:18:04 +00:00
gradients_sample_uniform_inargs ,
2 ,
gradients_sample_uniform_outargs ,
{ { gradients_sample_uniform_invoker } }
} ;
static Argument *
2006-03-27 19:32:19 +00:00
gradients_sample_custom_invoker ( ProcRecord * proc_record ,
Gimp * gimp ,
2004-08-10 18:47:21 +00:00
GimpContext * context ,
GimpProgress * progress ,
Argument * args )
2000-06-01 21:18:04 +00:00
{
gboolean success = TRUE ;
Argument * return_args ;
2006-03-15 15:00:01 +00:00
gint32 num_samples ;
gdouble * positions ;
2003-08-18 12:17:21 +00:00
gboolean reverse ;
2000-06-01 21:18:04 +00:00
gint32 array_length = 0 ;
gdouble * color_samples = NULL ;
2006-03-15 15:00:01 +00:00
num_samples = args [ 0 ] . value . pdb_int ;
if ( num_samples < = 0 )
2000-06-01 21:18:04 +00:00
success = FALSE ;
2006-03-15 15:00:01 +00:00
positions = ( gdouble * ) args [ 1 ] . value . pdb_pointer ;
2000-06-01 21:18:04 +00:00
2003-08-18 12:17:21 +00:00
reverse = args [ 2 ] . value . pdb_int ? TRUE : FALSE ;
2000-06-01 21:18:04 +00:00
if ( success )
{
2006-03-14 21:35:50 +00:00
GimpGradient * gradient ;
2005-02-26 23:55:50 +00:00
GimpGradientSegment * seg = NULL ;
2006-03-14 21:35:50 +00:00
GimpRGB color ;
gdouble * pv ;
2005-02-26 23:55:50 +00:00
2006-03-15 15:00:01 +00:00
array_length = num_samples * 4 ;
2004-03-26 16:38:44 +00:00
2000-06-01 21:18:04 +00:00
pv = color_samples = g_new ( gdouble , array_length ) ;
2004-03-26 16:38:44 +00:00
2004-04-14 23:37:34 +00:00
gradient = gimp_context_get_gradient ( context ) ;
2004-03-26 16:38:44 +00:00
2006-03-15 15:00:01 +00:00
while ( num_samples - - )
2004-03-26 16:49:18 +00:00
{
2006-03-15 15:00:01 +00:00
seg = gimp_gradient_get_color_at ( gradient , seg , * positions ,
reverse , & color ) ;
2004-03-26 16:38:44 +00:00
2004-03-26 16:49:18 +00:00
* pv + + = color . r ;
* pv + + = color . g ;
* pv + + = color . b ;
* pv + + = color . a ;
2004-03-26 16:38:44 +00:00
2006-03-15 15:00:01 +00:00
positions + + ;
2004-03-26 16:49:18 +00:00
}
2000-06-01 21:18:04 +00:00
}
2006-03-27 19:32:19 +00:00
return_args = procedural_db_return_args ( proc_record , success ) ;
2000-06-01 21:18:04 +00:00
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 13:58:46 +00:00
GIMP_PDB_INT32 ,
2005-08-05 18:19:09 +00:00
" num-samples " ,
2000-06-01 21:18:04 +00:00
" The number of samples to take "
} ,
{
2001-05-21 13:58:46 +00:00
GIMP_PDB_FLOATARRAY ,
2000-06-01 21:18:04 +00:00
" positions " ,
" The list of positions to sample along the gradient "
2003-08-18 12:17:21 +00:00
} ,
{
GIMP_PDB_INT32 ,
" reverse " ,
" Use the reverse gradient (TRUE or FALSE) "
2000-06-01 21:18:04 +00:00
}
} ;
static ProcArg gradients_sample_custom_outargs [ ] =
{
{
2001-05-21 13:58:46 +00:00
GIMP_PDB_INT32 ,
2005-08-05 18:19:09 +00:00
" array-length " ,
2000-06-01 21:18:04 +00:00
" Length of the color_samples array (4 * num_samples) "
} ,
{
2001-05-21 13:58:46 +00:00
GIMP_PDB_FLOATARRAY ,
2005-08-05 18:19:09 +00:00
" color-samples " ,
2000-06-01 21:18:04 +00:00
" Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An } "
}
} ;
static ProcRecord gradients_sample_custom_proc =
{
2005-08-02 22:52:23 +00: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-05 23:28:17 +00:00
" " ,
" " ,
" " ,
2005-08-02 22:52:23 +00:00
" gimp-gradient-get-custom-samples " ,
2001-05-21 13:58:46 +00:00
GIMP_INTERNAL ,
2003-08-18 12:17:21 +00:00
3 ,
2000-06-01 21:18:04 +00:00
gradients_sample_custom_inargs ,
2 ,
gradients_sample_custom_outargs ,
{ { gradients_sample_custom_invoker } }
} ;
2001-10-25 21:59:52 +00:00
static Argument *
2006-03-27 19:32:19 +00:00
gradients_get_gradient_data_invoker ( ProcRecord * proc_record ,
Gimp * gimp ,
2004-08-10 18:47:21 +00:00
GimpContext * context ,
GimpProgress * progress ,
Argument * args )
2001-10-25 21:59:52 +00:00
{
gboolean success = TRUE ;
Argument * return_args ;
gchar * name ;
gint32 sample_size ;
2003-08-18 12:17:21 +00:00
gboolean reverse ;
2006-03-15 12:49:25 +00:00
gchar * actual_name = NULL ;
gint32 width = 0 ;
2006-03-15 15:00:01 +00:00
gdouble * grad_data = NULL ;
2001-10-25 21:59:52 +00:00
name = ( gchar * ) args [ 0 ] . value . pdb_pointer ;
2004-09-23 15:05:48 +00:00
if ( name & & ! g_utf8_validate ( name , - 1 , NULL ) )
2001-10-25 21:59:52 +00:00
success = FALSE ;
sample_size = args [ 1 ] . value . pdb_int ;
2003-08-18 12:17:21 +00:00
reverse = args [ 2 ] . value . pdb_int ? TRUE : FALSE ;
2001-10-25 21:59:52 +00:00
if ( success )
{
2006-03-15 12:49:25 +00:00
GimpGradient * gradient ;
2006-03-18 10:28:39 +00:00
if ( sample_size < 1 | | sample_size > 10000 )
sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE ;
2004-09-23 15:05:48 +00:00
if ( name & & strlen ( name ) )
2004-10-05 23:28:17 +00:00
{
gradient = ( GimpGradient * )
gimp_container_get_child_by_name ( gimp - > gradient_factory - > container ,
name ) ;
}
else
{
gradient = gimp_context_get_gradient ( context ) ;
}
2004-03-26 16:38:44 +00:00
2003-07-22 14:24:11 +00:00
if ( gradient )
2004-03-26 16:49:18 +00:00
{
2005-02-26 23:55:50 +00:00
GimpGradientSegment * seg = NULL ;
gdouble * pv ;
gdouble pos , delta ;
GimpRGB color ;
2004-03-26 16:49:18 +00:00
pos = 0.0 ;
2006-03-15 12:49:25 +00:00
delta = 1.0 / ( sample_size - 1 ) ;
2006-03-24 21:57:47 +00:00
actual_name = g_strdup ( gimp_object_get_name ( GIMP_OBJECT ( gradient ) ) ) ;
2006-03-15 15:00:01 +00:00
grad_data = g_new ( gdouble , sample_size * 4 ) ;
2006-03-15 12:49:25 +00:00
width = sample_size * 4 ;
2004-03-26 16:49:18 +00:00
2006-03-15 15:00:01 +00:00
pv = grad_data ;
2004-03-26 16:49:18 +00:00
2006-03-15 12:49:25 +00:00
while ( sample_size )
2004-03-26 16:49:18 +00:00
{
2005-02-26 23:55:50 +00:00
seg = gimp_gradient_get_color_at ( gradient , seg , pos , reverse , & color ) ;
2004-03-26 16:49:18 +00:00
* pv + + = color . r ;
* pv + + = color . g ;
* pv + + = color . b ;
* pv + + = color . a ;
pos + = delta ;
}
}
2003-12-08 11:58:45 +00:00
else
2004-03-26 16:49:18 +00:00
success = FALSE ;
2001-10-25 21:59:52 +00:00
}
2006-03-27 19:32:19 +00:00
return_args = procedural_db_return_args ( proc_record , success ) ;
2001-10-25 21:59:52 +00:00
if ( success )
{
2006-03-15 12:49:25 +00:00
return_args [ 1 ] . value . pdb_pointer = actual_name ;
return_args [ 2 ] . value . pdb_int = width ;
2006-03-15 15:00:01 +00:00
return_args [ 3 ] . value . pdb_pointer = grad_data ;
2001-10-25 21:59:52 +00:00
}
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-05 18:19:09 +00:00
" sample-size " ,
2006-03-24 21:57:47 +00:00
" Size of the sample to return when the gradient is changed: (1 <= sample_size <= 10000) "
2003-08-18 12:17:21 +00:00
} ,
{
GIMP_PDB_INT32 ,
" reverse " ,
" Use the reverse gradient (TRUE or FALSE) "
2001-10-25 21:59:52 +00:00
}
} ;
static ProcArg gradients_get_gradient_data_outargs [ ] =
{
{
GIMP_PDB_STRING ,
2006-03-15 12:49:25 +00:00
" actual-name " ,
2001-10-25 21:59:52 +00:00
" The gradient name "
} ,
{
GIMP_PDB_INT32 ,
" width " ,
" The gradient sample width (r,g,b,a) "
} ,
{
GIMP_PDB_FLOATARRAY ,
2005-08-05 18:19:09 +00:00
" grad-data " ,
2001-10-25 21:59:52 +00:00
" The gradient sample data "
}
} ;
static ProcRecord gradients_get_gradient_data_proc =
{
2005-08-02 22:52:23 +00: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-05 23:28:17 +00:00
" " ,
" " ,
" " ,
2005-08-02 22:52:23 +00:00
" gimp-gradient-get-uniform-samples " ,
2001-10-25 21:59:52 +00:00
GIMP_INTERNAL ,
2003-08-18 12:17:21 +00:00
3 ,
2001-10-25 21:59:52 +00:00
gradients_get_gradient_data_inargs ,
3 ,
gradients_get_gradient_data_outargs ,
{ { gradients_get_gradient_data_invoker } }
} ;