mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
libgimp: allow to run gimp_procedure_run_config() with no config object.
This is the equivalent to run the procedure with its defaults.
This commit is contained in:
parent
01cdf777a6
commit
baae7287be
2 changed files with 17 additions and 5 deletions
|
@ -1935,7 +1935,7 @@ gimp_procedure_run_valist (GimpProcedure *procedure,
|
||||||
/**
|
/**
|
||||||
* gimp_procedure_run_config: (rename-to gimp_procedure_run)
|
* gimp_procedure_run_config: (rename-to gimp_procedure_run)
|
||||||
* @procedure: the [class@gimp.Procedure] to run.
|
* @procedure: the [class@gimp.Procedure] to run.
|
||||||
* @config: the @procedure's arguments.
|
* @config: (nullable): the @procedure's arguments.
|
||||||
*
|
*
|
||||||
* Runs @procedure, calling the run_func given in [ctor@Procedure.new].
|
* Runs @procedure, calling the run_func given in [ctor@Procedure.new].
|
||||||
*
|
*
|
||||||
|
@ -1943,6 +1943,8 @@ gimp_procedure_run_valist (GimpProcedure *procedure,
|
||||||
* [method@Gimp.Procedure.create_config] then set any argument you wish
|
* [method@Gimp.Procedure.create_config] then set any argument you wish
|
||||||
* to change from defaults with [method@GObject.Object.set].
|
* to change from defaults with [method@GObject.Object.set].
|
||||||
*
|
*
|
||||||
|
* If @config is %NULL, the default arguments of @procedure will be used.
|
||||||
|
*
|
||||||
* Returns: (transfer full): The @procedure's return values.
|
* Returns: (transfer full): The @procedure's return values.
|
||||||
*
|
*
|
||||||
* Since: 3.0
|
* Since: 3.0
|
||||||
|
@ -1953,10 +1955,17 @@ gimp_procedure_run_config (GimpProcedure *procedure,
|
||||||
{
|
{
|
||||||
GimpValueArray *return_vals;
|
GimpValueArray *return_vals;
|
||||||
GimpValueArray *args;
|
GimpValueArray *args;
|
||||||
|
gboolean free_config = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
||||||
g_return_val_if_fail (GIMP_IS_PROCEDURE_CONFIG (config), NULL);
|
g_return_val_if_fail (config == NULL || GIMP_IS_PROCEDURE_CONFIG (config), NULL);
|
||||||
g_return_val_if_fail (gimp_procedure_config_get_procedure (config) == procedure, NULL);
|
g_return_val_if_fail (config == NULL || gimp_procedure_config_get_procedure (config) == procedure, NULL);
|
||||||
|
|
||||||
|
if (config == NULL)
|
||||||
|
{
|
||||||
|
config = gimp_procedure_create_config (procedure);
|
||||||
|
free_config = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
args = gimp_procedure_new_arguments (procedure);
|
args = gimp_procedure_new_arguments (procedure);
|
||||||
_gimp_procedure_config_get_values (config, args);
|
_gimp_procedure_config_get_values (config, args);
|
||||||
|
@ -1965,6 +1974,9 @@ gimp_procedure_run_config (GimpProcedure *procedure,
|
||||||
|
|
||||||
gimp_value_array_unref (args);
|
gimp_value_array_unref (args);
|
||||||
|
|
||||||
|
if (free_config)
|
||||||
|
g_object_unref (config);
|
||||||
|
|
||||||
return return_vals;
|
return return_vals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,6 @@ TEST_NAME=$3
|
||||||
|
|
||||||
cmd="import os; import sys; sys.path.insert(0, '$SRC_DIR'); from pygimp.utils import gimp_c_assert;"
|
cmd="import os; import sys; sys.path.insert(0, '$SRC_DIR'); from pygimp.utils import gimp_c_assert;"
|
||||||
cmd="$cmd proc = Gimp.get_pdb().lookup_procedure('$TEST_NAME'); gimp_c_assert('$TEST_FILE', 'Test PDB procedure does not exist: {}'.format('$TEST_NAME'), proc is not None);"
|
cmd="$cmd proc = Gimp.get_pdb().lookup_procedure('$TEST_NAME'); gimp_c_assert('$TEST_FILE', 'Test PDB procedure does not exist: {}'.format('$TEST_NAME'), proc is not None);"
|
||||||
cmd="$cmd result = proc.run(proc.create_config());"
|
cmd="$cmd result = proc.run(None);"
|
||||||
cmd="$cmd print('SUCCESS') if result.index(0) == Gimp.PDBStatusType.SUCCESS else gimp_c_assert('$TEST_FILE', result.index(1), False);"
|
cmd="$cmd print('SUCCESS') if result.index(0) == Gimp.PDBStatusType.SUCCESS else gimp_c_assert('$TEST_FILE', result.index(1), False);"
|
||||||
echo "$cmd" | "$GIMP_EXE" -nis --batch-interpreter "python-fu-eval" -b - --quit
|
echo "$cmd" | "$GIMP_EXE" -nis --batch-interpreter "python-fu-eval" -b - --quit
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue