libgimp: PDB procedure arguments are not order-based anymore (API-wise).

As far as plug-in API is concerned, at least the calling API, order of arguments
when calling PDB procedures doesn't matter anymore.

Order still matters for creating procedures with standard arguments (for
instance, "run-mode" is first, then image, or file, drawables or whatnot,
depending on the subtype of procedure), but not for calling with libgimp.

Concretely in this commit:

- gimp_pdb_run_procedure_argv() was removed as it's intrinsically order-based.
- gimp_pdb_run_procedure() and gimp_pdb_run_procedure_valist() stay but their
  semantic changes. Instead of an ordered list of (type, value) couple, it's now
  an unordered list of (name, type, value) triplets. This way, you can also
  ignore as many args as you want if you intend to keep them default. For
  instance, say you have a procedure with 20 args and you only want to change
  the last one and keep the 19 first with default values: while you used to have
  to write down all 20 args annoyingly, now you can just list the only arg you
  care about.

There are 2 important consequences here:

1. Calling PDB procedures becomes much more semantic, which means scripts with
   PDB calls are simpler (smaller list of arguments) and easier to read (when
   you had 5 int arguments in a row, you couldn't know what they refer to,
   except by always checking the PDB source; now you'll have associated names,
   such as "width", "height" and so on) hence maintain.
2. We will have the ability to add arguments and even order the new arguments in
   middle of existing arguments without breaking compatibility. The only thing
   which will matter will be that default values of new arguments will have to
   behave like when the arg didn't exist. This way, existing scripts will not be
   broken. This will avoid us having to always create variants of PDB procedure
   (like original "file-bla-save", then variant "file-bla-save-2" and so on)
   each time we add arguments.

Note: gimp_pdb_run_procedure_array() was not removed yet because it's currently
used by the PDB. To be followed.
This commit is contained in:
Jehan 2023-10-16 16:44:06 +02:00
parent 61e2faed1b
commit 70438028aa
20 changed files with 204 additions and 202 deletions

View File

@ -435,6 +435,7 @@ file_gbr_image_to_brush (GimpImage *image,
gint height; gint height;
g_return_val_if_fail (n_drawables > 0, NULL); g_return_val_if_fail (n_drawables > 0, NULL);
g_return_val_if_fail (drawables != NULL, NULL);
if (n_drawables > 1) if (n_drawables > 1)
{ {

View File

@ -256,6 +256,7 @@ file_pat_image_to_pattern (GimpImage *image,
gint height; gint height;
g_return_val_if_fail (n_drawables > 0, NULL); g_return_val_if_fail (n_drawables > 0, NULL);
g_return_val_if_fail (drawables != NULL, NULL);
if (n_drawables > 1) if (n_drawables > 1)
{ {

View File

@ -704,7 +704,6 @@ EXPORTS
gimp_pdb_procedure_exists gimp_pdb_procedure_exists
gimp_pdb_query_procedures gimp_pdb_query_procedures
gimp_pdb_run_procedure gimp_pdb_run_procedure
gimp_pdb_run_procedure_argv
gimp_pdb_run_procedure_array gimp_pdb_run_procedure_array
gimp_pdb_run_procedure_config gimp_pdb_run_procedure_config
gimp_pdb_run_procedure_valist gimp_pdb_run_procedure_valist

View File

@ -20,6 +20,8 @@
#include "config.h" #include "config.h"
#include <gobject/gvaluecollector.h>
#include "gimp.h" #include "gimp.h"
#include "libgimpbase/gimpprotocol.h" #include "libgimpbase/gimpprotocol.h"
@ -192,11 +194,15 @@ gimp_pdb_lookup_procedure (GimpPDB *pdb,
* gimp_pdb_run_procedure: (skip) * gimp_pdb_run_procedure: (skip)
* @pdb: the #GimpPDB object. * @pdb: the #GimpPDB object.
* @procedure_name: the procedure registered name. * @procedure_name: the procedure registered name.
* @first_type: the #GType of the first argument, or #G_TYPE_NONE. * @first_arg_name: the name of an argument of @procedure_name.
* @...: the call arguments. * @...: the call arguments.
* *
* Runs the procedure named @procedure_name with arguments given as * Runs the procedure named @procedure_name with arguments given as
* list of (#GType, value) pairs, terminated by #G_TYPE_NONE. * list of `(const gchar *, GType, value)` triplet, terminated by %NULL.
*
* The order of arguments does not matter and if any argument is missing, its
* default value will be used. The %GType must correspond to the argument type
* as registered for @procedure_name.
* *
* Returns: (transfer full): the return values for the procedure call. * Returns: (transfer full): the return values for the procedure call.
* *
@ -205,7 +211,7 @@ gimp_pdb_lookup_procedure (GimpPDB *pdb,
GimpValueArray * GimpValueArray *
gimp_pdb_run_procedure (GimpPDB *pdb, gimp_pdb_run_procedure (GimpPDB *pdb,
const gchar *procedure_name, const gchar *procedure_name,
GType first_type, const gchar *first_arg_name,
...) ...)
{ {
GimpValueArray *return_values; GimpValueArray *return_values;
@ -214,10 +220,10 @@ gimp_pdb_run_procedure (GimpPDB *pdb,
g_return_val_if_fail (GIMP_IS_PDB (pdb), NULL); g_return_val_if_fail (GIMP_IS_PDB (pdb), NULL);
g_return_val_if_fail (gimp_is_canonical_identifier (procedure_name), NULL); g_return_val_if_fail (gimp_is_canonical_identifier (procedure_name), NULL);
va_start (args, first_type); va_start (args, first_arg_name);
return_values = gimp_pdb_run_procedure_valist (pdb, procedure_name, return_values = gimp_pdb_run_procedure_valist (pdb, procedure_name,
first_type, args); first_arg_name, args);
va_end (args); va_end (args);
@ -228,11 +234,11 @@ gimp_pdb_run_procedure (GimpPDB *pdb,
* gimp_pdb_run_procedure_valist: (skip) * gimp_pdb_run_procedure_valist: (skip)
* @pdb: the #GimpPDB object. * @pdb: the #GimpPDB object.
* @procedure_name: the procedure registered name. * @procedure_name: the procedure registered name.
* @first_type: the #GType of the first argument, or #G_TYPE_NONE. * @first_arg_name: the name of an argument of @procedure_name.
* @args: the call arguments. * @args: the call arguments.
* *
* Runs the procedure named @procedure_name with @args given in the * Runs the procedure named @procedure_name with arguments name, type and value
* order as passed to [method@PDB.run_procedure]. * given in the order as passed to [method@PDB.run_procedure].
* *
* Returns: (transfer full): the return values for the procedure call. * Returns: (transfer full): the return values for the procedure call.
* *
@ -241,71 +247,70 @@ gimp_pdb_run_procedure (GimpPDB *pdb,
GimpValueArray * GimpValueArray *
gimp_pdb_run_procedure_valist (GimpPDB *pdb, gimp_pdb_run_procedure_valist (GimpPDB *pdb,
const gchar *procedure_name, const gchar *procedure_name,
GType first_type, const gchar *first_arg_name,
va_list args) va_list args)
{ {
GimpValueArray *arguments;
GimpValueArray *return_values; GimpValueArray *return_values;
gchar *error_msg = NULL; GimpProcedure *procedure;
GimpProcedureConfig *config;
const gchar *arg_name;
g_return_val_if_fail (GIMP_IS_PDB (pdb), NULL); g_return_val_if_fail (GIMP_IS_PDB (pdb), NULL);
g_return_val_if_fail (gimp_is_canonical_identifier (procedure_name), NULL); g_return_val_if_fail (gimp_is_canonical_identifier (procedure_name), NULL);
arguments = gimp_value_array_new_from_types_valist (&error_msg, procedure = gimp_pdb_lookup_procedure (pdb, procedure_name);
first_type, config = gimp_procedure_create_config (procedure);
args);
if (! arguments) arg_name = first_arg_name;
while (arg_name != NULL)
{ {
GError *error = g_error_new_literal (GIMP_PDB_ERROR, GParamSpec *pspec;
GIMP_PDB_ERROR_INTERNAL_ERROR, gchar *error = NULL;
error_msg); GValue value = G_VALUE_INIT;
g_printerr ("%s: %s", G_STRFUNC, error_msg); GType type;
g_free (error_msg);
return gimp_procedure_new_return_values (NULL, type = va_arg (args, GType);
GIMP_PDB_CALLING_ERROR,
error); if (type == G_TYPE_NONE)
{
g_warning ("%s: invalid argument '%s' with type G_TYPE_NONE.", G_STRFUNC, arg_name);
g_clear_object (&config);
return NULL;
} }
return_values = gimp_pdb_run_procedure_array (pdb, procedure_name, g_value_init (&value, type);
arguments);
gimp_value_array_unref (arguments);
return return_values; G_VALUE_COLLECT (&value, args, G_VALUE_NOCOPY_CONTENTS, &error);
}
/** if (error)
* gimp_pdb_run_procedure_argv: (rename-to gimp_pdb_run_procedure) {
* @pdb: the #GimpPDB object. g_warning ("%s: %s", G_STRFUNC, error);
* @procedure_name: the registered name to call. g_free (error);
* @arguments: (array length=n_arguments) (nullable): the call arguments or %NULL. g_clear_object (&config);
* @n_arguments: the number of arguments. return NULL;
* }
* Runs the procedure named @procedure_name with @arguments.
*
* Returns: (transfer full): the return values for the procedure call.
*
* Since: 3.0
*/
GimpValueArray *
gimp_pdb_run_procedure_argv (GimpPDB *pdb,
const gchar *procedure_name,
const GValue *arguments,
gint n_arguments)
{
GimpValueArray *args;
GimpValueArray *return_values;
g_return_val_if_fail (GIMP_IS_PDB (pdb), NULL); pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (config), arg_name);
g_return_val_if_fail (gimp_is_canonical_identifier (procedure_name), NULL); if (pspec == NULL)
/* Not require arguments != NULL. g_warning ("%s: %s has no property named '%s'",
* gimp_value_array_new_from_values(NULL, 0) will return empty GValueArray. G_STRFUNC,
*/ g_type_name (G_TYPE_FROM_INSTANCE (config)),
arg_name);
else if (! g_type_is_a (type, pspec->value_type))
g_warning ("%s: value of type %s is incompatible with argument '%s' of type %s",
G_STRFUNC, g_type_name (type),
arg_name, g_type_name (pspec->value_type));
else
g_object_set_property (G_OBJECT (config), arg_name, &value);
args = gimp_value_array_new_from_values (arguments, n_arguments); g_value_unset (&value);
return_values = gimp_pdb_run_procedure_array (pdb, procedure_name, args);
gimp_value_array_unref (args); arg_name = va_arg (args, const gchar *);
}
return_values = gimp_pdb_run_procedure_config (pdb, procedure_name, config);
g_clear_object (&config);
return return_values; return return_values;
} }

View File

@ -75,16 +75,12 @@ GimpProcedure * gimp_pdb_lookup_procedure (GimpPDB *pdb,
GimpValueArray * gimp_pdb_run_procedure (GimpPDB *pdb, GimpValueArray * gimp_pdb_run_procedure (GimpPDB *pdb,
const gchar *procedure_name, const gchar *procedure_name,
GType first_type, const gchar *first_arg_name,
...); ...) G_GNUC_NULL_TERMINATED;
GimpValueArray * gimp_pdb_run_procedure_valist (GimpPDB *pdb, GimpValueArray * gimp_pdb_run_procedure_valist (GimpPDB *pdb,
const gchar *procedure_name, const gchar *procedure_name,
GType first_type, const gchar *first_arg_name,
va_list args); va_list args);
GimpValueArray * gimp_pdb_run_procedure_argv (GimpPDB *pdb,
const gchar *procedure_name,
const GValue *arguments,
gint n_arguments);
GimpValueArray * gimp_pdb_run_procedure_array (GimpPDB *pdb, GimpValueArray * gimp_pdb_run_procedure_array (GimpPDB *pdb,
const gchar *procedure_name, const gchar *procedure_name,
const GimpValueArray *arguments); const GimpValueArray *arguments);

View File

@ -330,9 +330,9 @@ gimp_save_procedure_dialog_edit_metadata_thread (gpointer data)
GimpSaveProcedureDialog *dialog = data; GimpSaveProcedureDialog *dialog = data;
gimp_pdb_run_procedure (gimp_get_pdb (), "plug-in-metadata-editor", gimp_pdb_run_procedure (gimp_get_pdb (), "plug-in-metadata-editor",
GIMP_TYPE_RUN_MODE, GIMP_RUN_INTERACTIVE, "run-mode", GIMP_TYPE_RUN_MODE, GIMP_RUN_INTERACTIVE,
GIMP_TYPE_IMAGE, dialog->priv->image, "image", GIMP_TYPE_IMAGE, dialog->priv->image,
G_TYPE_NONE); NULL);
g_mutex_lock (&dialog->priv->metadata_thread_mutex); g_mutex_lock (&dialog->priv->metadata_thread_mutex);
g_thread_unref (dialog->priv->metadata_thread); g_thread_unref (dialog->priv->metadata_thread);

View File

@ -231,7 +231,6 @@ gbr_save (GimpProcedure *procedure,
if (status == GIMP_PDB_SUCCESS) if (status == GIMP_PDB_SUCCESS)
{ {
GimpValueArray *args;
GimpValueArray *save_retvals; GimpValueArray *save_retvals;
GimpObjectArray *drawables_array; GimpObjectArray *drawables_array;
gint spacing; gint spacing;
@ -241,21 +240,19 @@ gbr_save (GimpProcedure *procedure,
"spacing", &spacing, "spacing", &spacing,
NULL); NULL);
drawables_array = gimp_object_array_new (GIMP_TYPE_ITEM, (GObject **) drawables, drawables_array = gimp_object_array_new (GIMP_TYPE_DRAWABLE, (GObject **) drawables,
n_drawables, FALSE); n_drawables, FALSE);
args = gimp_value_array_new_from_types (NULL, save_retvals =
GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE, gimp_pdb_run_procedure (gimp_get_pdb (),
GIMP_TYPE_IMAGE, image,
G_TYPE_INT, n_drawables,
GIMP_TYPE_OBJECT_ARRAY, drawables_array,
G_TYPE_FILE, file,
G_TYPE_INT, spacing,
G_TYPE_STRING, description,
G_TYPE_NONE);
save_retvals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"file-gbr-save-internal", "file-gbr-save-internal",
args); "image", GIMP_TYPE_IMAGE, image,
gimp_value_array_unref (args); "num-drawables", G_TYPE_INT, n_drawables,
"drawables", GIMP_TYPE_OBJECT_ARRAY, drawables_array,
"file", G_TYPE_FILE, file,
"spacing", G_TYPE_INT, spacing,
"name", G_TYPE_STRING, description,
NULL);
gimp_object_array_free (drawables_array); gimp_object_array_free (drawables_array);
g_free (description); g_free (description);

View File

@ -383,28 +383,24 @@ gih_save (GimpProcedure *procedure,
if (status == GIMP_PDB_SUCCESS) if (status == GIMP_PDB_SUCCESS)
{ {
GimpValueArray *save_retvals; GimpValueArray *save_retvals;
GimpObjectArray *drawables_array;
gchar *paramstring; gchar *paramstring;
GimpValueArray *args;
paramstring = gimp_pixpipe_params_build (&gihparams); paramstring = gimp_pixpipe_params_build (&gihparams);
args = gimp_value_array_new_from_types (NULL, drawables_array = gimp_object_array_new (GIMP_TYPE_DRAWABLE, (GObject **) drawables,
GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE, n_drawables, FALSE);
GIMP_TYPE_IMAGE, image, save_retvals = gimp_pdb_run_procedure (gimp_get_pdb (),
G_TYPE_INT, n_drawables,
GIMP_TYPE_OBJECT_ARRAY, NULL,
G_TYPE_FILE, file,
G_TYPE_INT, spacing,
G_TYPE_STRING, description,
G_TYPE_STRING, paramstring,
G_TYPE_NONE);
gimp_value_set_object_array (gimp_value_array_index (args, 3),
GIMP_TYPE_ITEM, (GObject **) drawables, n_drawables);
save_retvals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"file-gih-save-internal", "file-gih-save-internal",
args); "image", GIMP_TYPE_IMAGE, image,
gimp_value_array_unref (args); "num-drawables", G_TYPE_INT, n_drawables,
"drawables", GIMP_TYPE_OBJECT_ARRAY, drawables_array,
"file", G_TYPE_FILE, file,
"spacing", G_TYPE_INT, spacing,
"name", G_TYPE_STRING, description,
"params", G_TYPE_STRING, paramstring,
NULL);
gimp_object_array_free (drawables_array);
if (GIMP_VALUES_GET_ENUM (save_retvals, 0) == GIMP_PDB_SUCCESS) if (GIMP_VALUES_GET_ENUM (save_retvals, 0) == GIMP_PDB_SUCCESS)
{ {

View File

@ -210,27 +210,22 @@ pat_save (GimpProcedure *procedure,
if (status == GIMP_PDB_SUCCESS) if (status == GIMP_PDB_SUCCESS)
{ {
GimpValueArray *save_retvals; GimpValueArray *save_retvals;
GimpValueArray *args; GimpObjectArray *drawables_array;
drawables_array = gimp_object_array_new (GIMP_TYPE_DRAWABLE, (GObject **) drawables, n_drawables, FALSE);
g_object_get (config, g_object_get (config,
"description", &description, "description", &description,
NULL); NULL);
args = gimp_value_array_new_from_types (NULL, save_retvals = gimp_pdb_run_procedure (gimp_get_pdb (),
GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE,
GIMP_TYPE_IMAGE, image,
G_TYPE_INT, n_drawables,
GIMP_TYPE_OBJECT_ARRAY, NULL,
G_TYPE_FILE, file,
G_TYPE_STRING, description,
G_TYPE_NONE);
gimp_value_set_object_array (gimp_value_array_index (args, 3),
GIMP_TYPE_ITEM, (GObject **) drawables, n_drawables);
save_retvals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"file-pat-save-internal", "file-pat-save-internal",
args); "image", GIMP_TYPE_IMAGE, image,
gimp_value_array_unref (args); "num-drawables", G_TYPE_INT, n_drawables,
"drawables", GIMP_TYPE_OBJECT_ARRAY, drawables_array,
"file", G_TYPE_FILE, file,
"name", G_TYPE_STRING, description,
NULL);
if (GIMP_VALUES_GET_ENUM (save_retvals, 0) != GIMP_PDB_SUCCESS) if (GIMP_VALUES_GET_ENUM (save_retvals, 0) != GIMP_PDB_SUCCESS)
{ {
@ -243,6 +238,7 @@ pat_save (GimpProcedure *procedure,
} }
gimp_value_array_unref (save_retvals); gimp_value_array_unref (save_retvals);
gimp_object_array_free (drawables_array);
} }
if (export == GIMP_EXPORT_EXPORT) if (export == GIMP_EXPORT_EXPORT)

View File

@ -613,9 +613,9 @@ load_esm_image (GInputStream *input,
return_vals = return_vals =
gimp_pdb_run_procedure (gimp_get_pdb (), gimp_pdb_run_procedure (gimp_get_pdb (),
"file-jpeg-load", "file-jpeg-load",
GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE, "run-mode", GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE,
G_TYPE_FILE, temp_file, "file", G_TYPE_FILE, temp_file,
G_TYPE_NONE); NULL);
if (return_vals) if (return_vals)
{ {

View File

@ -373,8 +373,8 @@ browser_search (GimpBrowser *gimp_browser,
return_vals = gimp_pdb_run_procedure (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure (gimp_get_pdb (),
"gimp-plug-ins-query", "gimp-plug-ins-query",
G_TYPE_STRING, search_text, "search-string", G_TYPE_STRING, search_text,
G_TYPE_NONE); NULL);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS) if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
{ {

View File

@ -442,9 +442,9 @@ icns_attach_image (GimpImage *image,
return_vals = return_vals =
gimp_pdb_run_procedure (gimp_get_pdb (), gimp_pdb_run_procedure (gimp_get_pdb (),
procedure_name, procedure_name,
GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE, "run-mode", GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE,
G_TYPE_FILE, temp_file, "file", G_TYPE_FILE, temp_file,
G_TYPE_NONE); NULL);
} }
if (temp_image && return_vals) if (temp_image && return_vals)

View File

@ -469,20 +469,20 @@ icns_export_image (GFile *file,
return_vals = return_vals =
gimp_pdb_run_procedure (gimp_get_pdb (), gimp_pdb_run_procedure (gimp_get_pdb (),
"file-png-save", "file-png-save",
GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE, "run-mode", GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE,
GIMP_TYPE_IMAGE, image, "image", GIMP_TYPE_IMAGE, image,
G_TYPE_INT, 1, "num-drawables", G_TYPE_INT, 1,
GIMP_TYPE_OBJECT_ARRAY, args, "drawables", GIMP_TYPE_OBJECT_ARRAY, args,
G_TYPE_FILE, temp_file, "file", G_TYPE_FILE, temp_file,
G_TYPE_BOOLEAN, FALSE, "interlaced", G_TYPE_BOOLEAN, FALSE,
G_TYPE_INT, 9, "compression", G_TYPE_INT, 9,
G_TYPE_BOOLEAN, FALSE, "bkgd", G_TYPE_BOOLEAN, FALSE,
G_TYPE_BOOLEAN, FALSE, "offs", G_TYPE_BOOLEAN, FALSE,
G_TYPE_BOOLEAN, FALSE, "phys", G_TYPE_BOOLEAN, FALSE,
G_TYPE_BOOLEAN, FALSE, "time", G_TYPE_BOOLEAN, FALSE,
G_TYPE_BOOLEAN, FALSE, "save-transparent", G_TYPE_BOOLEAN, FALSE,
G_TYPE_BOOLEAN, FALSE, "optimize-palette", G_TYPE_BOOLEAN, FALSE,
G_TYPE_NONE); NULL);
gimp_object_array_free (args); gimp_object_array_free (args);
g_clear_pointer (&drawables, g_free); g_clear_pointer (&drawables, g_free);

View File

@ -507,11 +507,11 @@ ico_dialog_update_icon_preview (GtkWidget *dialog,
return_vals = return_vals =
gimp_pdb_run_procedure (gimp_get_pdb (), gimp_pdb_run_procedure (gimp_get_pdb (),
"plug-in-threshold-alpha", "plug-in-threshold-alpha",
GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE, "run-mode", GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE,
GIMP_TYPE_IMAGE, tmp_image, "image", GIMP_TYPE_IMAGE, tmp_image,
GIMP_TYPE_DRAWABLE, tmp_layer, "drawable", GIMP_TYPE_DRAWABLE, tmp_layer,
G_TYPE_INT, ICO_ALPHA_THRESHOLD, "threshold", G_TYPE_INT, ICO_ALPHA_THRESHOLD,
G_TYPE_NONE); NULL);
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);

View File

@ -828,11 +828,11 @@ ico_image_get_reduced_buf (GimpDrawable *layer,
return_vals = return_vals =
gimp_pdb_run_procedure (gimp_get_pdb (), gimp_pdb_run_procedure (gimp_get_pdb (),
"plug-in-threshold-alpha", "plug-in-threshold-alpha",
GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE, "run-mode", GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE,
GIMP_TYPE_IMAGE, tmp_image, "image", GIMP_TYPE_IMAGE, tmp_image,
GIMP_TYPE_DRAWABLE, tmp_layer, "drawable", GIMP_TYPE_DRAWABLE, tmp_layer,
G_TYPE_INT, ICO_ALPHA_THRESHOLD, "threshold", G_TYPE_INT, ICO_ALPHA_THRESHOLD,
G_TYPE_NONE); NULL);
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);
} }

View File

@ -499,12 +499,12 @@ load_image (GFile *file,
return_vals = return_vals =
gimp_pdb_run_procedure (gimp_get_pdb (), gimp_pdb_run_procedure (gimp_get_pdb (),
"file-psd-load-metadata", "file-psd-load-metadata",
GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE, "run-mode", GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE,
G_TYPE_FILE, temp_file, "file", G_TYPE_FILE, temp_file,
G_TYPE_INT, photoshop_len, "size", G_TYPE_INT, photoshop_len,
GIMP_TYPE_IMAGE, image, "image", GIMP_TYPE_IMAGE, image,
G_TYPE_BOOLEAN, FALSE, "metadata-type", G_TYPE_BOOLEAN, FALSE,
G_TYPE_NONE); NULL);
g_file_delete (temp_file, NULL, NULL); g_file_delete (temp_file, NULL, NULL);
g_object_unref (temp_file); g_object_unref (temp_file);

View File

@ -1769,12 +1769,12 @@ load_image (GFile *file,
return_vals = return_vals =
gimp_pdb_run_procedure (gimp_get_pdb (), gimp_pdb_run_procedure (gimp_get_pdb (),
"file-psd-load-metadata", "file-psd-load-metadata",
GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE, "run-mode", GIMP_TYPE_RUN_MODE, GIMP_RUN_NONINTERACTIVE,
G_TYPE_FILE, temp_file, "file", G_TYPE_FILE, temp_file,
G_TYPE_INT, photoshop_len, "size", G_TYPE_INT, photoshop_len,
GIMP_TYPE_IMAGE, *image, "image", GIMP_TYPE_IMAGE, *image,
G_TYPE_BOOLEAN, FALSE, "metadata-type", G_TYPE_BOOLEAN, FALSE,
G_TYPE_NONE); NULL);
g_file_delete (temp_file, NULL, NULL); g_file_delete (temp_file, NULL, NULL);
g_object_unref (temp_file); g_object_unref (temp_file);
@ -1811,13 +1811,13 @@ load_image (GFile *file,
return_vals = return_vals =
gimp_pdb_run_procedure (gimp_get_pdb (), gimp_pdb_run_procedure (gimp_get_pdb (),
"file-psd-load-metadata", "file-psd-load-metadata",
GIMP_TYPE_RUN_MODE, run_mode, "run-mode", GIMP_TYPE_RUN_MODE, run_mode,
G_TYPE_FILE, temp_file, "file", G_TYPE_FILE, temp_file,
G_TYPE_INT, photoshop_len, "size", G_TYPE_INT, photoshop_len,
GIMP_TYPE_IMAGE, *image, "image", GIMP_TYPE_IMAGE, *image,
G_TYPE_BOOLEAN, TRUE, "metadata-type", G_TYPE_BOOLEAN, TRUE,
G_TYPE_BOOLEAN, is_cmyk, "cmyk", G_TYPE_BOOLEAN, is_cmyk,
G_TYPE_NONE); NULL);
g_file_delete (temp_file, NULL, NULL); g_file_delete (temp_file, NULL, NULL);
g_object_unref (temp_file); g_object_unref (temp_file);

View File

@ -331,8 +331,8 @@ help_load_idle (gpointer data)
return_vals = gimp_pdb_run_procedure (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure (gimp_get_pdb (),
idle_help->procedure, idle_help->procedure,
G_TYPE_STRING, uri, "domain-names", G_TYPE_STRING, uri,
G_TYPE_NONE); NULL);
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);
g_free (uri); g_free (uri);

View File

@ -403,7 +403,7 @@ page_setup (GimpImage *image)
return_vals = gimp_pdb_run_procedure (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure (gimp_get_pdb (),
name, name,
GIMP_TYPE_IMAGE, image, "image", GIMP_TYPE_IMAGE, image,
G_TYPE_NONE); G_TYPE_NONE);
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);

View File

@ -639,7 +639,7 @@ script_fu_marshal_procedure_call (scheme *sc,
gboolean deprecated) gboolean deprecated)
{ {
GimpProcedure *procedure; GimpProcedure *procedure;
GimpValueArray *args; GimpProcedureConfig *config;
GimpValueArray *values = NULL; GimpValueArray *values = NULL;
gchar *proc_name; gchar *proc_name;
GParamSpec **arg_specs; GParamSpec **arg_specs;
@ -650,7 +650,6 @@ script_fu_marshal_procedure_call (scheme *sc,
gint i; gint i;
pointer return_val = sc->NIL; pointer return_val = sc->NIL;
g_debug ("In %s()", G_STRFUNC); g_debug ("In %s()", G_STRFUNC);
if (a == sc->NIL) if (a == sc->NIL)
@ -688,6 +687,7 @@ script_fu_marshal_procedure_call (scheme *sc,
return script_error (sc, error_str, 0); return script_error (sc, error_str, 0);
} }
config = gimp_procedure_create_config (procedure);
arg_specs = gimp_procedure_get_arguments (procedure, &n_arg_specs); arg_specs = gimp_procedure_get_arguments (procedure, &n_arg_specs);
actual_arg_count = sc->vptr->list_length (sc, a) - 1; actual_arg_count = sc->vptr->list_length (sc, a) - 1;
@ -720,8 +720,6 @@ script_fu_marshal_procedure_call (scheme *sc,
} }
/* Marshall the supplied arguments */ /* Marshall the supplied arguments */
args = gimp_value_array_new (n_arg_specs);
for (i = 0; i < n_arg_specs; i++) for (i = 0; i < n_arg_specs; i++)
{ {
GParamSpec *arg_spec = arg_specs[i]; GParamSpec *arg_spec = arg_specs[i];
@ -846,8 +844,7 @@ script_fu_marshal_procedure_call (scheme *sc,
{ {
g_printerr (" "); g_printerr (" ");
for (j = 0; j < count; ++j) for (j = 0; j < count; ++j)
g_printerr (" \"%s\"", g_printerr (" \"%s\"", array[j]);
args[i].data.d_strv[j]);
g_printerr ("\n"); g_printerr ("\n");
} }
} }
@ -988,7 +985,12 @@ script_fu_marshal_procedure_call (scheme *sc,
*/ */
gint32 *array; gint32 *array;
n_elements = GIMP_VALUES_GET_INT (args, i - 1); if (i == 0)
return script_error (sc, "The first argument cannot be an array", a);
else if (! g_type_is_a (arg_specs[i - 1]->value_type, G_TYPE_INT))
return script_error (sc, "Array arguments must be preceded by an int argument (number of items)", a);
g_object_get (config, arg_specs[i - 1]->name, &n_elements, NULL);
if (n_elements > sc->vptr->vector_length (vector)) if (n_elements > sc->vptr->vector_length (vector))
return script_length_error_in_vector (sc, i, proc_name, n_elements, vector); return script_length_error_in_vector (sc, i, proc_name, n_elements, vector);
@ -1054,7 +1056,12 @@ script_fu_marshal_procedure_call (scheme *sc,
{ {
gdouble *array; gdouble *array;
n_elements = GIMP_VALUES_GET_INT (args, i - 1); if (i == 0)
return script_error (sc, "The first argument cannot be an array", a);
else if (! g_type_is_a (arg_specs[i - 1]->value_type, G_TYPE_INT))
return script_error (sc, "Array arguments must be preceded by an int argument (number of items)", a);
g_object_get (config, arg_specs[i - 1]->name, &n_elements, NULL);
if (n_elements > sc->vptr->vector_length (vector)) if (n_elements > sc->vptr->vector_length (vector))
return script_length_error_in_vector (sc, i, proc_name, n_elements, vector); return script_length_error_in_vector (sc, i, proc_name, n_elements, vector);
@ -1138,7 +1145,12 @@ script_fu_marshal_procedure_call (scheme *sc,
{ {
GimpRGB *array; GimpRGB *array;
n_elements = GIMP_VALUES_GET_INT (args, i - 1); if (i == 0)
return script_error (sc, "The first argument cannot be an array", a);
else if (! g_type_is_a (arg_specs[i - 1]->value_type, G_TYPE_INT))
return script_error (sc, "Array arguments must be preceded by an int argument (number of items)", a);
g_object_get (config, arg_specs[i - 1]->name, &n_elements, NULL);
if (n_elements > sc->vptr->vector_length (vector)) if (n_elements > sc->vptr->vector_length (vector))
return script_length_error_in_vector (sc, i, proc_name, n_elements, vector); return script_length_error_in_vector (sc, i, proc_name, n_elements, vector);
@ -1283,7 +1295,7 @@ script_fu_marshal_procedure_call (scheme *sc,
return implementation_error (sc, error_str, 0); return implementation_error (sc, error_str, 0);
} }
debug_gvalue (&value); debug_gvalue (&value);
gimp_value_array_append (args, &value); g_object_set_property (G_OBJECT (config), arg_specs[i]->name, &value);
g_value_unset (&value); g_value_unset (&value);
} }
@ -1292,9 +1304,9 @@ script_fu_marshal_procedure_call (scheme *sc,
return script_error (sc, "A script cannot refresh scripts", 0); return script_error (sc, "A script cannot refresh scripts", 0);
g_debug ("calling %s", proc_name); g_debug ("calling %s", proc_name);
values = gimp_pdb_run_procedure_array (gimp_get_pdb (), values = gimp_pdb_run_procedure_config (gimp_get_pdb (), proc_name, config);
proc_name, args);
g_debug ("done."); g_debug ("done.");
g_clear_object (&config);
/* Check the return status */ /* Check the return status */
if (! values) if (! values)
@ -1326,7 +1338,6 @@ script_fu_marshal_procedure_call (scheme *sc,
gimp_value_array_unref (values); gimp_value_array_unref (values);
/* free arguments and values */ /* free arguments and values */
gimp_value_array_unref (args);
/* The callback is NULL except for script-fu-server. See explanation there. */ /* The callback is NULL except for script-fu-server. See explanation there. */
if (post_command_callback != NULL) if (post_command_callback != NULL)