Index: app/pdb/procedural_db.c =================================================================== RCS file: /cvs/gnome/gimp/app/pdb/procedural_db.c,v retrieving revision 1.58 diff -u -p -r1.58 procedural_db.c --- app/pdb/procedural_db.c 27 Mar 2006 22:57:25 -0000 1.58 +++ app/pdb/procedural_db.c 28 Mar 2006 15:48:09 -0000 @@ -25,13 +25,19 @@ #include #include "libgimpbase/gimpbase.h" +#include "libgimpcolor/gimpcolor.h" #include "pdb-types.h" #include "core/gimp.h" #include "core/gimpcontext.h" +#include "core/gimpchannel.h" +#include "core/gimplayer.h" +#include "core/gimpparamspecs.h" #include "core/gimpprogress.h" +#include "vectors/gimpvectors.h" + #include "plug-in/plug-in-run.h" #include "internal_procs.h" @@ -586,6 +592,232 @@ procedural_db_destroy_args (Argument *ar g_free (args); } +void +procedural_db_init_proc (ProcRecord *procedure, + gint n_arguments, + gint n_return_values) +{ + g_return_if_fail (procedure != NULL); + g_return_if_fail (procedure->args == NULL); + g_return_if_fail (procedure->values == NULL); + g_return_if_fail (n_arguments >= 0); + g_return_if_fail (n_return_values >= 0); + + procedure->num_args = n_arguments; + procedure->args = g_new0 (ProcArg, n_arguments); + + procedure->num_values = n_return_values; + procedure->values = g_new0 (ProcArg, n_return_values); +} + +void +procedural_db_add_argument (ProcRecord *procedure, + GimpPDBArgType arg_type, + GParamSpec *pspec) +{ + gint i; + + g_return_if_fail (procedure != NULL); + g_return_if_fail (G_IS_PARAM_SPEC (pspec)); + + for (i = 0; i < procedure->num_args; i++) + if (procedure->args[i].pspec == NULL) + { + procedure->args[i].arg_type = arg_type; + procedure->args[i].pspec = pspec; + + g_param_spec_ref (pspec); + g_param_spec_sink (pspec); + + return; + } + + g_warning ("%s: can't register more than %d arguments for procedure %s", + G_STRFUNC, procedure->num_args, procedure->name); +} + +void +procedural_db_add_return_value (ProcRecord *procedure, + GimpPDBArgType arg_type, + GParamSpec *pspec) +{ + gint i; + + g_return_if_fail (procedure != NULL); + g_return_if_fail (G_IS_PARAM_SPEC (pspec)); + + for (i = 0; i < procedure->num_values; i++) + if (procedure->values[i].pspec == NULL) + { + procedure->values[i].arg_type = arg_type; + procedure->values[i].pspec = pspec; + + g_param_spec_ref (pspec); + g_param_spec_sink (pspec); + + return; + } + + g_warning ("%s: can't register more than %d return values for procedure %s", + G_STRFUNC, procedure->num_values, procedure->name); +} + +static GParamSpec * +procedural_db_compat_pspec (Gimp *gimp, + GimpPDBArgType arg_type, + const gchar *name, + const gchar *desc) +{ + GParamSpec *pspec = NULL; + + switch (arg_type) + { + case GIMP_PDB_INT32: + pspec = g_param_spec_int (name, name, desc, + G_MININT32, G_MAXINT32, 0, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_INT16: + pspec = g_param_spec_int (name, name, desc, + G_MININT16, G_MAXINT16, 0, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_INT8: + pspec = g_param_spec_uint (name, name, desc, + 0, G_MAXUINT8, 0, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_FLOAT: + pspec = g_param_spec_double (name, name, desc, + -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_STRING: + pspec = g_param_spec_string (name, name, desc, + NULL, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_INT32ARRAY: + case GIMP_PDB_INT16ARRAY: + case GIMP_PDB_INT8ARRAY: + case GIMP_PDB_FLOATARRAY: + case GIMP_PDB_STRINGARRAY: + pspec = g_param_spec_pointer (name, name, desc, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_COLOR: + pspec = gimp_param_spec_rgb (name, name, desc, + NULL, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_REGION: + break; + + case GIMP_PDB_DISPLAY: + pspec = gimp_param_spec_display_id (name, name, desc, + gimp, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_IMAGE: + pspec = gimp_param_spec_image_id (name, name, desc, + gimp, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_LAYER: + pspec = gimp_param_spec_item_id (name, name, desc, + gimp, GIMP_TYPE_LAYER, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_CHANNEL: + pspec = gimp_param_spec_item_id (name, name, desc, + gimp, GIMP_TYPE_CHANNEL, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_DRAWABLE: + pspec = gimp_param_spec_item_id (name, name, desc, + gimp, GIMP_TYPE_DRAWABLE, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_SELECTION: + pspec = gimp_param_spec_item_id (name, name, desc, + gimp, GIMP_TYPE_CHANNEL, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_BOUNDARY: + break; + + case GIMP_PDB_VECTORS: + pspec = gimp_param_spec_item_id (name, name, desc, + gimp, GIMP_TYPE_VECTORS, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_PARASITE: + pspec = gimp_param_spec_parasite (name, name, desc, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_STATUS: + pspec = g_param_spec_int (name, name, desc, + G_MININT32, G_MAXINT32, 0, + G_PARAM_READWRITE); + break; + + case GIMP_PDB_END: + break; + } + + if (! pspec) + g_warning ("%s: returning NULL for %s (%s)", + G_STRFUNC, name, procedural_db_type_name (arg_type)); + + return pspec; +} + +void +procedural_db_add_compat_arg (ProcRecord *procedure, + Gimp *gimp, + GimpPDBArgType arg_type, + const gchar *name, + const gchar *desc) +{ + g_return_if_fail (procedure != NULL); + g_return_if_fail (GIMP_IS_GIMP (gimp)); + g_return_if_fail (name != NULL); + + procedural_db_add_argument (procedure, arg_type, + procedural_db_compat_pspec (gimp, arg_type, + name, desc)); +} + +void +procedural_db_add_compat_value (ProcRecord *procedure, + Gimp *gimp, + GimpPDBArgType arg_type, + const gchar *name, + const gchar *desc) +{ + g_return_if_fail (procedure != NULL); + g_return_if_fail (GIMP_IS_GIMP (gimp)); + g_return_if_fail (name != NULL); + + procedural_db_add_return_value (procedure, arg_type, + procedural_db_compat_pspec (gimp, arg_type, + name, desc)); +} /* private functions */ Index: app/pdb/procedural_db.h =================================================================== RCS file: /cvs/gnome/gimp/app/pdb/procedural_db.h,v retrieving revision 1.20 diff -u -p -r1.20 procedural_db.h --- app/pdb/procedural_db.h 27 Mar 2006 21:04:36 -0000 1.20 +++ app/pdb/procedural_db.h 28 Mar 2006 15:48:09 -0000 @@ -75,8 +75,7 @@ struct _TempExec struct _ProcArg { GimpPDBArgType arg_type; /* Argument type (int, char, char *, etc) */ - gchar *name; /* Argument name */ - gchar *description; /* Argument description */ + GParamSpec *pspec; }; @@ -100,11 +99,11 @@ struct _ProcRecord /* Input arguments */ gint32 num_args; /* Number of procedure arguments */ - ProcArg *args; /* Array of procedure arguments */ + ProcArg *args; /* Array of procedure arguments */ /* Output values */ - gint32 num_values; /* Number of return values */ - ProcArg *values; /* Array of return values */ + gint32 num_values; /* Number of return values */ + ProcArg *values; /* Array of return values */ /* Method of procedure execution */ union _ExecMethod @@ -119,35 +118,57 @@ struct _ProcRecord /* Functions */ -void procedural_db_init (Gimp *gimp); -void procedural_db_free (Gimp *gimp); +void procedural_db_init (Gimp *gimp); +void procedural_db_free (Gimp *gimp); -void procedural_db_init_procs (Gimp *gimp); +void procedural_db_init_procs (Gimp *gimp); -void procedural_db_register (Gimp *gimp, - ProcRecord *procedure); -void procedural_db_unregister (Gimp *gimp, - const gchar *name); -ProcRecord * procedural_db_lookup (Gimp *gimp, - const gchar *name); - -Argument * procedural_db_execute (Gimp *gimp, - GimpContext *context, - GimpProgress *progress, - const gchar *name, - Argument *args); -Argument * procedural_db_run_proc (Gimp *gimp, - GimpContext *context, - GimpProgress *progress, - const gchar *name, - gint *nreturn_vals, - ...); - -Argument * procedural_db_arguments (ProcRecord *procedure); -Argument * procedural_db_return_values (ProcRecord *procedure, - gboolean success); -void procedural_db_destroy_args (Argument *args, - gint nargs); +void procedural_db_register (Gimp *gimp, + ProcRecord *procedure); +void procedural_db_unregister (Gimp *gimp, + const gchar *name); +ProcRecord * procedural_db_lookup (Gimp *gimp, + const gchar *name); + +Argument * procedural_db_execute (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + const gchar *name, + Argument *args); +Argument * procedural_db_run_proc (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + const gchar *name, + gint *nreturn_vals, + ...); + +Argument * procedural_db_arguments (ProcRecord *procedure); +Argument * procedural_db_return_values (ProcRecord *procedure, + gboolean success); +void procedural_db_destroy_args (Argument *args, + gint nargs); + +void procedural_db_init_proc (ProcRecord *procedure, + gint n_arguments, + gint n_return_values); + +void procedural_db_add_argument (ProcRecord *procedure, + GimpPDBArgType arg_type, + GParamSpec *pspec); +void procedural_db_add_return_value (ProcRecord *procedure, + GimpPDBArgType arg_type, + GParamSpec *pspec); + +void procedural_db_add_compat_arg (ProcRecord *procedure, + Gimp *gimp, + GimpPDBArgType arg_type, + const gchar *name, + const gchar *desc); +void procedural_db_add_compat_value (ProcRecord *procedure, + Gimp *gimp, + GimpPDBArgType arg_type, + const gchar *name, + const gchar *desc); #endif /* __PROCEDURAL_DB_H__ */ Index: app/pdb/procedural-db-query.c =================================================================== RCS file: /cvs/gnome/gimp/app/pdb/procedural-db-query.c,v retrieving revision 1.3 diff -u -p -r1.3 procedural-db-query.c --- app/pdb/procedural-db-query.c 10 Mar 2006 10:08:34 -0000 1.3 +++ app/pdb/procedural-db-query.c 28 Mar 2006 15:48:09 -0000 @@ -407,9 +407,9 @@ procedural_db_print_entry (gpointer key, arg_value = g_enum_get_value (arg_class, procedure->args[i].arg_type); - output_string (file, procedure->args[i].name); + output_string (file, g_param_spec_get_name (procedure->args[i].pspec)); output_string (file, arg_value->value_name); - output_string (file, procedure->args[i].description); + output_string (file, g_param_spec_get_blurb (procedure->args[i].pspec)); fprintf (file, " ) "); } @@ -423,9 +423,9 @@ procedural_db_print_entry (gpointer key, arg_value = g_enum_get_value (arg_class, procedure->values[i].arg_type); - output_string (file, procedure->values[i].name); + output_string (file, g_param_spec_get_name (procedure->values[i].pspec)); output_string (file, arg_value->value_name); - output_string (file, procedure->values[i].description); + output_string (file, g_param_spec_get_blurb (procedure->values[i].pspec)); fprintf (file, " ) "); } Index: app/plug-in/plug-in-message.c =================================================================== RCS file: /cvs/gnome/gimp/app/plug-in/plug-in-message.c,v retrieving revision 1.232 diff -u -p -r1.232 plug-in-message.c --- app/plug-in/plug-in-message.c 13 Dec 2005 14:11:55 -0000 1.232 +++ app/plug-in/plug-in-message.c 28 Mar 2006 15:48:09 -0000 @@ -740,7 +740,7 @@ plug_in_handle_proc_install (PlugIn proc = &proc_def->db_info; - proc->name = g_strdup (canonical); + proc->name = canonical; proc->original_name = g_strdup (proc_install->name); proc->blurb = g_strdup (proc_install->blurb); proc->help = g_strdup (proc_install->help); @@ -749,24 +749,33 @@ plug_in_handle_proc_install (PlugIn proc->date = g_strdup (proc_install->date); proc->proc_type = proc_install->type; - proc->num_args = proc_install->nparams; - proc->num_values = proc_install->nreturn_vals; - - proc->args = g_new0 (ProcArg, proc->num_args); - proc->values = g_new0 (ProcArg, proc->num_values); + procedural_db_init_proc (proc, + proc_install->nparams, proc_install->nreturn_vals); for (i = 0; i < proc->num_args; i++) { - proc->args[i].arg_type = proc_install->params[i].type; - proc->args[i].name = gimp_canonicalize_identifier (proc_install->params[i].name); - proc->args[i].description = g_strdup (proc_install->params[i].description); + canonical = gimp_canonicalize_identifier (proc_install->params[i].name); + + procedural_db_add_compat_arg (proc, + plug_in->gimp, + proc_install->params[i].type, + canonical, + proc_install->params[i].description); + + g_free (canonical); } for (i = 0; i < proc->num_values; i++) { - proc->values[i].arg_type = proc_install->return_vals[i].type; - proc->values[i].name = gimp_canonicalize_identifier (proc_install->return_vals[i].name); - proc->values[i].description = g_strdup (proc_install->return_vals[i].description); + canonical = gimp_canonicalize_identifier (proc_install->return_vals[i].name); + + procedural_db_add_compat_value (proc, + plug_in->gimp, + proc_install->return_vals[i].type, + canonical, + proc_install->return_vals[i].description); + + g_free (canonical); } switch (proc_install->type) @@ -786,8 +795,6 @@ plug_in_handle_proc_install (PlugIn plug_ins_temp_proc_def_add (plug_in->gimp, proc_def); break; } - - g_free (canonical); } static void Index: app/plug-in/plug-in-proc-def.c =================================================================== RCS file: /cvs/gnome/gimp/app/plug-in/plug-in-proc-def.c,v retrieving revision 1.22 diff -u -p -r1.22 plug-in-proc-def.c --- app/plug-in/plug-in-proc-def.c 12 Aug 2005 00:51:43 -0000 1.22 +++ app/plug-in/plug-in-proc-def.c 28 Mar 2006 15:48:09 -0000 @@ -64,16 +64,10 @@ plug_in_proc_def_free (PlugInProcDef *pr g_free (proc_def->db_info.date); for (i = 0; i < proc_def->db_info.num_args; i++) - { - g_free (proc_def->db_info.args[i].name); - g_free (proc_def->db_info.args[i].description); - } + g_param_spec_unref (proc_def->db_info.args[i].pspec); for (i = 0; i < proc_def->db_info.num_values; i++) - { - g_free (proc_def->db_info.values[i].name); - g_free (proc_def->db_info.values[i].description); - } + g_param_spec_unref (proc_def->db_info.values[i].pspec); g_free (proc_def->db_info.args); g_free (proc_def->db_info.values); Index: app/plug-in/plug-in-rc.c =================================================================== RCS file: /cvs/gnome/gimp/app/plug-in/plug-in-rc.c,v retrieving revision 1.33 diff -u -p -r1.33 plug-in-rc.c --- app/plug-in/plug-in-rc.c 2 Aug 2005 22:52:16 -0000 1.33 +++ app/plug-in/plug-in-rc.c 28 Mar 2006 15:48:10 -0000 @@ -47,6 +47,7 @@ static GTokenType plug_in_def_deserialize (Gimp *gimp, GScanner *scanner); static GTokenType plug_in_proc_def_deserialize (GScanner *scanner, + Gimp *gimp, PlugInProcDef *proc_def); static GTokenType plug_in_menu_path_deserialize (GScanner *scanner, PlugInProcDef *proc_def); @@ -55,7 +56,9 @@ static GTokenType plug_in_icon_deseriali static GTokenType plug_in_file_proc_deserialize (GScanner *scanner, PlugInProcDef *proc_def); static GTokenType plug_in_proc_arg_deserialize (GScanner *scanner, - ProcArg *arg); + Gimp *gimp, + ProcRecord *proc, + gboolean return_value); static GTokenType plug_in_locale_def_deserialize (GScanner *scanner, PlugInDef *plug_in_def); static GTokenType plug_in_help_def_deserialize (GScanner *scanner, @@ -253,7 +256,7 @@ plug_in_def_deserialize (Gimp *gimp, { case PROC_DEF: proc_def = plug_in_proc_def_new (); - token = plug_in_proc_def_deserialize (scanner, proc_def); + token = plug_in_proc_def_deserialize (scanner, gimp, proc_def); if (token == G_TOKEN_LEFT_PAREN) plug_in_def_add_proc_def (plug_in_def, proc_def); @@ -305,9 +308,12 @@ plug_in_def_deserialize (Gimp *gimp, static GTokenType plug_in_proc_def_deserialize (GScanner *scanner, + Gimp *gimp, PlugInProcDef *proc_def) { GTokenType token; + gint n_args; + gint n_return_vals; gint n_menu_paths; gint i; @@ -356,29 +362,25 @@ plug_in_proc_def_deserialize (GScanner proc_def->image_types_val = plug_ins_image_types_parse (proc_def->image_types); - if (! gimp_scanner_parse_int (scanner, (gint *) &proc_def->db_info.num_args)) + if (! gimp_scanner_parse_int (scanner, (gint *) &n_args)) return G_TOKEN_INT; - if (! gimp_scanner_parse_int (scanner, (gint *) &proc_def->db_info.num_values)) + if (! gimp_scanner_parse_int (scanner, (gint *) &n_return_vals)) return G_TOKEN_INT; - if (proc_def->db_info.num_args > 0) - proc_def->db_info.args = g_new0 (ProcArg, proc_def->db_info.num_args); + procedural_db_init_proc (&proc_def->db_info, n_args, n_return_vals); - for (i = 0; i < proc_def->db_info.num_args; i++) + for (i = 0; i < n_args; i++) { - token = plug_in_proc_arg_deserialize (scanner, - &proc_def->db_info.args[i]); + token = plug_in_proc_arg_deserialize (scanner, gimp, + &proc_def->db_info, FALSE); if (token != G_TOKEN_LEFT_PAREN) return token; } - if (proc_def->db_info.num_values > 0) - proc_def->db_info.values = g_new0 (ProcArg, proc_def->db_info.num_values); - - for (i = 0; i < proc_def->db_info.num_values; i++) + for (i = 0; i < n_return_vals; i++) { - token = plug_in_proc_arg_deserialize (scanner, - &proc_def->db_info.values[i]); + token = plug_in_proc_arg_deserialize (scanner, gimp, + &proc_def->db_info, TRUE); if (token != G_TOKEN_LEFT_PAREN) return token; } @@ -596,27 +598,64 @@ plug_in_file_proc_deserialize (GScanner } static GTokenType -plug_in_proc_arg_deserialize (GScanner *scanner, - ProcArg *arg) +plug_in_proc_arg_deserialize (GScanner *scanner, + Gimp *gimp, + ProcRecord *proc, + gboolean return_value) { + GTokenType token; + gint arg_type; + gchar *name = NULL; + gchar *desc = NULL; + if (! gimp_scanner_parse_token (scanner, G_TOKEN_LEFT_PAREN)) - return G_TOKEN_LEFT_PAREN; + { + token = G_TOKEN_LEFT_PAREN; + goto error; + } if (! gimp_scanner_parse_token (scanner, G_TOKEN_SYMBOL) || GPOINTER_TO_INT (scanner->value.v_symbol) != PROC_ARG) - return G_TOKEN_SYMBOL; + { + token = G_TOKEN_SYMBOL; + goto error; + } - if (! gimp_scanner_parse_int (scanner, (gint *) &arg->arg_type)) - return G_TOKEN_INT; - if (! gimp_scanner_parse_string (scanner, &arg->name)) - return G_TOKEN_STRING; - if (! gimp_scanner_parse_string (scanner, &arg->description)) - return G_TOKEN_STRING; + if (! gimp_scanner_parse_int (scanner, (gint *) &arg_type)) + { + token = G_TOKEN_INT; + goto error; + } + if (! gimp_scanner_parse_string (scanner, &name)) + { + token = G_TOKEN_STRING; + goto error; + } + if (! gimp_scanner_parse_string (scanner, &desc)) + { + token = G_TOKEN_STRING; + goto error; + } if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN)) - return G_TOKEN_RIGHT_PAREN; + { + token = G_TOKEN_RIGHT_PAREN; + goto error; + } - return G_TOKEN_LEFT_PAREN; + token = G_TOKEN_LEFT_PAREN; + + if (return_value) + procedural_db_add_compat_value (proc, gimp, arg_type, name, desc); + else + procedural_db_add_compat_arg (proc, gimp, arg_type, name, desc); + + error: + + g_free (name); + g_free (desc); + + return token; } static GTokenType @@ -845,9 +884,9 @@ plug_in_rc_write (GSList *plug_in_ proc_def->db_info.args[i].arg_type); gimp_config_writer_string (writer, - proc_def->db_info.args[i].name); + g_param_spec_get_name (proc_def->db_info.args[i].pspec)); gimp_config_writer_string (writer, - proc_def->db_info.args[i].description); + g_param_spec_get_blurb (proc_def->db_info.args[i].pspec)); gimp_config_writer_close (writer); } @@ -859,9 +898,9 @@ plug_in_rc_write (GSList *plug_in_ proc_def->db_info.values[i].arg_type); gimp_config_writer_string (writer, - proc_def->db_info.values[i].name); + g_param_spec_get_name (proc_def->db_info.values[i].pspec)); gimp_config_writer_string (writer, - proc_def->db_info.values[i].description); + g_param_spec_get_blurb (proc_def->db_info.values[i].pspec)); gimp_config_writer_close (writer); } Index: app/xcf/xcf.c =================================================================== RCS file: /cvs/gnome/gimp/app/xcf/xcf.c,v retrieving revision 1.136 diff -u -p -r1.136 xcf.c --- app/xcf/xcf.c 27 Mar 2006 21:04:37 -0000 1.136 +++ app/xcf/xcf.c 28 Mar 2006 15:48:10 -0000 @@ -62,26 +62,6 @@ static Argument * xcf_save_invoker (Proc Argument *args); -static ProcArg xcf_load_args[] = -{ - { GIMP_PDB_INT32, - "dummy-param", - "dummy parameter" }, - { GIMP_PDB_STRING, - "filename", - "The name of the file to load, in the on-disk character set and encoding" }, - { GIMP_PDB_STRING, - "raw-filename", - "The basename of the file, in UTF-8" } -}; - -static ProcArg xcf_load_return_vals[] = -{ - { GIMP_PDB_IMAGE, - "image", - "Output image" } -}; - static PlugInProcDef xcf_plug_in_load_proc = { "gimp-xcf-load", @@ -106,10 +86,7 @@ static PlugInProcDef xcf_plug_in_load_pr "1995-1996", NULL, GIMP_INTERNAL, - 3, - xcf_load_args, - 1, - xcf_load_return_vals, + 0, NULL, 0, NULL, { { xcf_load_invoker } }, }, TRUE, @@ -122,25 +99,6 @@ static PlugInProcDef xcf_plug_in_load_pr NULL /* fill me in at runtime */ }; -static ProcArg xcf_save_args[] = -{ - { GIMP_PDB_INT32, - "dummy-param", - "dummy parameter" }, - { GIMP_PDB_IMAGE, - "image", - "Input image" }, - { GIMP_PDB_DRAWABLE, - "drawable", - "Active drawable of input image" }, - { GIMP_PDB_STRING, - "filename", - "The name of the file to save the image in, in the on-disk character set and encoding" }, - { GIMP_PDB_STRING, - "raw_filename", - "The basename of the file, in UTF-8" } -}; - static PlugInProcDef xcf_plug_in_save_proc = { "gimp-xcf-save", @@ -165,10 +123,7 @@ static PlugInProcDef xcf_plug_in_save_pr "1995-1996", NULL, GIMP_INTERNAL, - 5, - xcf_save_args, - 0, - NULL, + 0, NULL, 0, NULL, { { xcf_save_invoker } }, }, TRUE, @@ -203,11 +158,51 @@ xcf_init (Gimp *gimp) * though they are internal. The only thing it requires is using a * PlugInProcDef struct. -josh */ + procedural_db_init_proc (&xcf_plug_in_save_proc.db_info, 5, 0); + procedural_db_add_compat_arg (&xcf_plug_in_save_proc.db_info, gimp, + GIMP_PDB_INT32, + "dummy-param", + "dummy parameter"); + procedural_db_add_compat_arg (&xcf_plug_in_save_proc.db_info, gimp, + GIMP_PDB_IMAGE, + "image", + "Input image"); + procedural_db_add_compat_arg (&xcf_plug_in_save_proc.db_info, gimp, + GIMP_PDB_DRAWABLE, + "drawable", + "Active drawable of input image"); + procedural_db_add_compat_arg (&xcf_plug_in_save_proc.db_info, gimp, + GIMP_PDB_STRING, + "filename", + "The name of the file to save the image in, " + "in the on-disk character set and encoding"); + procedural_db_add_compat_arg (&xcf_plug_in_save_proc.db_info, gimp, + GIMP_PDB_STRING, + "raw_filename", + "The basename of the file, in UTF-8"); procedural_db_register (gimp, &xcf_plug_in_save_proc.db_info); xcf_plug_in_save_proc.image_types_val = plug_ins_image_types_parse (xcf_plug_in_save_proc.image_types); plug_ins_add_internal (gimp, &xcf_plug_in_save_proc); + procedural_db_init_proc (&xcf_plug_in_load_proc.db_info, 3, 1); + procedural_db_add_compat_arg (&xcf_plug_in_load_proc.db_info, gimp, + GIMP_PDB_INT32, + "dummy-param", + "dummy parameter"); + procedural_db_add_compat_arg (&xcf_plug_in_load_proc.db_info, gimp, + GIMP_PDB_STRING, + "filename", + "The name of the file to load, " + "in the on-disk character set and encoding"); + procedural_db_add_compat_arg (&xcf_plug_in_load_proc.db_info, gimp, + GIMP_PDB_STRING, + "raw-filename", + "The basename of the file, in UTF-8"); + procedural_db_add_compat_value (&xcf_plug_in_load_proc.db_info, gimp, + GIMP_PDB_IMAGE, + "image", + "Output image"); procedural_db_register (gimp, &xcf_plug_in_load_proc.db_info); xcf_plug_in_load_proc.image_types_val = plug_ins_image_types_parse (xcf_plug_in_load_proc.image_types); Index: tools/pdbgen/app.pl =================================================================== RCS file: /cvs/gnome/gimp/tools/pdbgen/app.pl,v retrieving revision 1.79 diff -u -p -r1.79 app.pl --- tools/pdbgen/app.pl 27 Mar 2006 21:04:38 -0000 1.79 +++ tools/pdbgen/app.pl 28 Mar 2006 15:48:10 -0000 @@ -150,39 +150,6 @@ sub make_desc { $desc; } -sub make_arg_recs { - my $proc = shift; - - my $result = ""; - my $once; - - foreach (@_) { - my @args = @{$proc->{$_}} if exists $proc->{$_}; - - if (scalar @args) { - $result .= "\nstatic ProcArg $proc->{name}_${_}\[] =\n{\n"; - - foreach $arg (@{$proc->{$_}}) { - my ($type, $name) = &arg_parse($arg->{type}); - my $desc = &make_desc($arg); - - $result .= <{name}, - "$arg->{canonical_name}", - @{[ "ewrap($desc, 4) ]} - }, -CODE - } - - $result =~ s/,\n$/\n/s; - $result .= "};\n"; - } - } - - $result; -} - sub marshal_inargs { my ($proc, $argc) = @_; @@ -405,6 +372,265 @@ CODE $result; } +sub generate_pspec { + my $arg = shift; + + my($pdbtype, @typeinfo) = &arg_parse($arg->{type}); + + my $name = $arg->{canonical_name}; + my $nick = $arg->{canonical_name}; + my $blurb = &make_desc($arg); + my $min; + my $max; + my $default; + my $flags = 'GIMP_PARAM_READWRITE'; + my $pspec = ""; + + $nick =~ s/-/ /g; + + if (exists $arg->{no_success}) { + $flags .= ' | GIMP_PARAM_NO_VALIDATE'; + } + + if ($pdbtype eq 'image') { + $pspec = <{default} ? $arg->{default} : defined $typeinfo[0] ? $typeinfo[0] : 0.0; + $pspec = <{default} ? $arg->{default} : defined $typeinfo[0] ? $typeinfo[0] : 0; + $pspec = <{default} ? $arg->{default} : defined $typeinfo[0] ? $typeinfo[0] : 0; + $pspec = <{default} ? $arg->{default} : defined $typeinfo[0] ? $typeinfo[0] : 0; + $pspec = <{default} ? $arg->{default} : FALSE; + $pspec = <{no_validate} ? 'TRUE' : 'FALSE'; + $null_ok = exists $arg->{null_ok} ? 'TRUE' : 'FALSE'; + $default = exists $arg->{default} ? $arg->{default} : NULL; + $pspec = <{default} ? $arg->{default} : $enums{$typeinfo[0]}->{symbols}[0]; + $pspec = <{allow_percent} ? TRUE : FALSE; + $default = exists $arg->{default} ? $arg->{default} : $typeinfo[0]; + $pspec = <{default} ? $arg->{default} : NULL; + $pspec = <{name} ($arg->{type})"; + exit -1; + } + + $pspec = "GIMP_PDB_$arg_types{$pdbtype}->{name},\n" . $pspec; + $pspec =~ s/\s$//; + + $pspec; +} + sub generate { my @procs = @{(shift)}; my %out; @@ -423,8 +649,38 @@ sub generate { $out->{procs} .= "static ProcRecord ${name}_proc;\n"; + $out->{register} .= <{register} .= <{register} .= <{register} .= <{invoke}->{headers}) { @@ -479,8 +735,6 @@ CODE $out->{code} .= $code; - $out->{code} .= &make_arg_recs($proc, qw(inargs outargs)); - $out->{code} .= <{deprecated} ? "\"$proc->{deprecated}\"" : 'NULL']}, GIMP_INTERNAL, - @{[scalar @inargs]}, - @{[scalar @inargs ? "${name}_inargs" : 'NULL']}, - @{[scalar @outargs]}, - @{[scalar @outargs ? "${name}_outargs" : 'NULL']}, + 0, NULL, 0, NULL, { { ${name}_invoker } } }; CODE @@ -589,6 +840,8 @@ GPL $headers .= '#include "pdb-types.h"'; $headers .= "\n"; $headers .= '#include "procedural_db.h"'; + $headers .= "\n"; + $headers .= '#include "core/gimpparamspecs.h"'; $headers .= "\n\n"; } } Index: tools/pdbgen/pdb/procedural_db.pdb =================================================================== RCS file: /cvs/gnome/gimp/tools/pdbgen/pdb/procedural_db.pdb,v retrieving revision 1.53 diff -u -p -r1.53 procedural_db.pdb --- tools/pdbgen/pdb/procedural_db.pdb 24 Mar 2006 22:49:20 -0000 1.53 +++ tools/pdbgen/pdb/procedural_db.pdb 28 Mar 2006 15:48:10 -0000 @@ -77,8 +77,8 @@ HELP ProcArg *$type = \&proc->${real_type}\[${type}_num]; ${type}_type = ${type}->arg_type; - ${type}_name = g_strdup (${type}->name); - ${type}_desc = g_strdup (${type}->description); + ${type}_name = g_strdup (g_param_spec_get_name (${type}->pspec)); + ${type}_desc = g_strdup (g_param_spec_get_blurb (${type}->pspec)); } else success = FALSE;