2016-01-02 00:33:45 +01:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* 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 3 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
|
2018-07-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2016-01-02 00:33:45 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gegl.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
|
|
|
#include "actions-types.h"
|
|
|
|
|
2016-01-04 15:07:30 +01:00
|
|
|
#include "core/gimp.h"
|
2016-01-02 00:33:45 +01:00
|
|
|
#include "core/gimpimage.h"
|
2021-04-02 01:04:07 +02:00
|
|
|
#include "core/gimpdrawable.h"
|
2016-01-02 00:33:45 +01:00
|
|
|
#include "core/gimpparamspecs.h"
|
2016-01-04 15:07:30 +01:00
|
|
|
#include "core/gimpprogress.h"
|
2016-01-02 00:33:45 +01:00
|
|
|
|
|
|
|
#include "pdb/gimpprocedure.h"
|
|
|
|
|
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
|
|
|
#include "procedure-commands.h"
|
|
|
|
|
|
|
|
|
app, libgimp, libgimpbase: plug-in and PDB protocol refactoring part two
- Change the wire protocol's GPProcInstall to transmit the entire
information needed for constructing all GParamSpecs we use, don't
use GimpPDBArgType in GPProcInstall but an enum private to the wire
protocol plus the GParamSpec's GType name. Bump the wire protocol
version.
- Add gimpgpparamspecs.[ch] in both app/plug-in/ and libgimp/ which
take care of converting between GPParamDef and GParamSpec. They
share code as far as possible.
- Change pluginrc writing and parsing to re-use GPParamDef and the
utility functions from gimpgpparamspecs.
- Remove gimp_pdb_compat_param_spec() from app/pdb/gimp-pdb-compat.[ch],
the entire core uses proper GParamSpecs from the wire protocol now,
the whole file will follow down the drain once we use a GValue
representation on the wire too.
- In gimp_plug_in_handle_proc_install(), change the "run-mode"
parameter to a GParamSpecEnum(GIMP_TYPE_RUN_MODE) (if it is not
already an enum). and change all places in app/ to treat it as an
enum value.
- plug-ins: fix cml-explorer to register correctly, a typo in
"run-mode" was never noticed until now.
- Add gimpgpcompat.[ch] in libgimp to deal with all the transforms
between old-style wire communication and using GParamSpec and
GValue, it contains some functions that are subject to change or
even removal in the next steps.
- Change the libgimp GimpProcedure and GimpPlugIn in many ways to be
able to actually install procedures the new way.
- plug-ins: change goat-exercise to completely use the new GimpPlugIn
and GimpProcedure API, look here to see how plug-ins will look in
the future, of course subject to change until this is finished.
- Next: changing GPParam to transmit all information about a GValue.
2019-07-27 16:37:55 +02:00
|
|
|
static inline gboolean
|
|
|
|
GIMP_IS_PARAM_SPEC_RUN_MODE (GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
return (G_IS_PARAM_SPEC_ENUM (pspec) &&
|
|
|
|
pspec->value_type == GIMP_TYPE_RUN_MODE);
|
|
|
|
}
|
|
|
|
|
2016-04-26 16:10:08 +02:00
|
|
|
GimpValueArray *
|
|
|
|
procedure_commands_get_run_mode_arg (GimpProcedure *procedure)
|
|
|
|
{
|
|
|
|
GimpValueArray *args;
|
|
|
|
gint n_args = 0;
|
|
|
|
|
|
|
|
args = gimp_procedure_get_arguments (procedure);
|
|
|
|
|
|
|
|
/* initialize the first argument */
|
|
|
|
if (gimp_value_array_length (args) > n_args &&
|
app, libgimp, libgimpbase: plug-in and PDB protocol refactoring part two
- Change the wire protocol's GPProcInstall to transmit the entire
information needed for constructing all GParamSpecs we use, don't
use GimpPDBArgType in GPProcInstall but an enum private to the wire
protocol plus the GParamSpec's GType name. Bump the wire protocol
version.
- Add gimpgpparamspecs.[ch] in both app/plug-in/ and libgimp/ which
take care of converting between GPParamDef and GParamSpec. They
share code as far as possible.
- Change pluginrc writing and parsing to re-use GPParamDef and the
utility functions from gimpgpparamspecs.
- Remove gimp_pdb_compat_param_spec() from app/pdb/gimp-pdb-compat.[ch],
the entire core uses proper GParamSpecs from the wire protocol now,
the whole file will follow down the drain once we use a GValue
representation on the wire too.
- In gimp_plug_in_handle_proc_install(), change the "run-mode"
parameter to a GParamSpecEnum(GIMP_TYPE_RUN_MODE) (if it is not
already an enum). and change all places in app/ to treat it as an
enum value.
- plug-ins: fix cml-explorer to register correctly, a typo in
"run-mode" was never noticed until now.
- Add gimpgpcompat.[ch] in libgimp to deal with all the transforms
between old-style wire communication and using GParamSpec and
GValue, it contains some functions that are subject to change or
even removal in the next steps.
- Change the libgimp GimpProcedure and GimpPlugIn in many ways to be
able to actually install procedures the new way.
- plug-ins: change goat-exercise to completely use the new GimpPlugIn
and GimpProcedure API, look here to see how plug-ins will look in
the future, of course subject to change until this is finished.
- Next: changing GPParam to transmit all information about a GValue.
2019-07-27 16:37:55 +02:00
|
|
|
GIMP_IS_PARAM_SPEC_RUN_MODE (procedure->args[n_args]))
|
2016-04-26 16:10:08 +02:00
|
|
|
{
|
app, libgimp, libgimpbase: plug-in and PDB protocol refactoring part two
- Change the wire protocol's GPProcInstall to transmit the entire
information needed for constructing all GParamSpecs we use, don't
use GimpPDBArgType in GPProcInstall but an enum private to the wire
protocol plus the GParamSpec's GType name. Bump the wire protocol
version.
- Add gimpgpparamspecs.[ch] in both app/plug-in/ and libgimp/ which
take care of converting between GPParamDef and GParamSpec. They
share code as far as possible.
- Change pluginrc writing and parsing to re-use GPParamDef and the
utility functions from gimpgpparamspecs.
- Remove gimp_pdb_compat_param_spec() from app/pdb/gimp-pdb-compat.[ch],
the entire core uses proper GParamSpecs from the wire protocol now,
the whole file will follow down the drain once we use a GValue
representation on the wire too.
- In gimp_plug_in_handle_proc_install(), change the "run-mode"
parameter to a GParamSpecEnum(GIMP_TYPE_RUN_MODE) (if it is not
already an enum). and change all places in app/ to treat it as an
enum value.
- plug-ins: fix cml-explorer to register correctly, a typo in
"run-mode" was never noticed until now.
- Add gimpgpcompat.[ch] in libgimp to deal with all the transforms
between old-style wire communication and using GParamSpec and
GValue, it contains some functions that are subject to change or
even removal in the next steps.
- Change the libgimp GimpProcedure and GimpPlugIn in many ways to be
able to actually install procedures the new way.
- plug-ins: change goat-exercise to completely use the new GimpPlugIn
and GimpProcedure API, look here to see how plug-ins will look in
the future, of course subject to change until this is finished.
- Next: changing GPParam to transmit all information about a GValue.
2019-07-27 16:37:55 +02:00
|
|
|
g_value_set_enum (gimp_value_array_index (args, n_args),
|
|
|
|
GIMP_RUN_INTERACTIVE);
|
2016-04-26 16:10:08 +02:00
|
|
|
n_args++;
|
|
|
|
}
|
|
|
|
|
2019-08-01 18:20:31 +02:00
|
|
|
if (n_args > 0)
|
|
|
|
gimp_value_array_truncate (args, n_args);
|
2016-04-26 16:10:08 +02:00
|
|
|
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
|
2016-01-02 00:33:45 +01:00
|
|
|
GimpValueArray *
|
|
|
|
procedure_commands_get_data_args (GimpProcedure *procedure,
|
|
|
|
GimpObject *object)
|
|
|
|
{
|
|
|
|
GimpValueArray *args;
|
|
|
|
gint n_args = 0;
|
|
|
|
|
|
|
|
args = gimp_procedure_get_arguments (procedure);
|
|
|
|
|
|
|
|
/* initialize the first argument */
|
2019-08-01 18:20:31 +02:00
|
|
|
if (gimp_value_array_length (args) > n_args &&
|
|
|
|
GIMP_IS_PARAM_SPEC_RUN_MODE (procedure->args[n_args]))
|
|
|
|
{
|
|
|
|
g_value_set_enum (gimp_value_array_index (args, n_args),
|
|
|
|
GIMP_RUN_INTERACTIVE);
|
|
|
|
n_args++;
|
|
|
|
}
|
2016-01-02 00:33:45 +01:00
|
|
|
|
|
|
|
if (gimp_value_array_length (args) > n_args &&
|
2020-01-05 17:31:45 +01:00
|
|
|
G_IS_PARAM_SPEC_STRING (procedure->args[n_args]))
|
2016-01-02 00:33:45 +01:00
|
|
|
{
|
|
|
|
if (object)
|
|
|
|
{
|
|
|
|
g_value_set_string (gimp_value_array_index (args, n_args),
|
|
|
|
gimp_object_get_name (object));
|
|
|
|
n_args++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("Uh-oh, no active data object for the plug-in!");
|
|
|
|
gimp_value_array_unref (args);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-01 18:20:31 +02:00
|
|
|
if (n_args > 0)
|
|
|
|
gimp_value_array_truncate (args, n_args);
|
2016-01-02 00:33:45 +01:00
|
|
|
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpValueArray *
|
|
|
|
procedure_commands_get_image_args (GimpProcedure *procedure,
|
|
|
|
GimpImage *image)
|
|
|
|
{
|
|
|
|
GimpValueArray *args;
|
|
|
|
gint n_args = 0;
|
|
|
|
|
|
|
|
args = gimp_procedure_get_arguments (procedure);
|
|
|
|
|
|
|
|
/* initialize the first argument */
|
2019-08-01 18:20:31 +02:00
|
|
|
if (gimp_value_array_length (args) > n_args &&
|
|
|
|
GIMP_IS_PARAM_SPEC_RUN_MODE (procedure->args[n_args]))
|
|
|
|
{
|
|
|
|
g_value_set_enum (gimp_value_array_index (args, n_args),
|
|
|
|
GIMP_RUN_INTERACTIVE);
|
|
|
|
n_args++;
|
|
|
|
}
|
2016-01-02 00:33:45 +01:00
|
|
|
|
|
|
|
if (gimp_value_array_length (args) > n_args &&
|
2019-08-29 11:25:35 +02:00
|
|
|
GIMP_IS_PARAM_SPEC_IMAGE (procedure->args[n_args]))
|
2016-01-02 00:33:45 +01:00
|
|
|
{
|
|
|
|
if (image)
|
|
|
|
{
|
2019-08-29 11:25:35 +02:00
|
|
|
g_value_set_object (gimp_value_array_index (args, n_args), image);
|
2016-01-02 00:33:45 +01:00
|
|
|
n_args++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("Uh-oh, no active image for the plug-in!");
|
|
|
|
gimp_value_array_unref (args);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-01 18:20:31 +02:00
|
|
|
if (n_args)
|
|
|
|
gimp_value_array_truncate (args, n_args);
|
2016-01-02 00:33:45 +01:00
|
|
|
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpValueArray *
|
2022-10-12 22:37:14 +02:00
|
|
|
procedure_commands_get_items_args (GimpProcedure *procedure,
|
|
|
|
GimpImage *image,
|
|
|
|
GList *items_list)
|
2016-01-02 00:33:45 +01:00
|
|
|
{
|
|
|
|
GimpValueArray *args;
|
|
|
|
gint n_args = 0;
|
|
|
|
|
|
|
|
args = gimp_procedure_get_arguments (procedure);
|
|
|
|
|
|
|
|
/* initialize the first argument */
|
2019-08-01 18:20:31 +02:00
|
|
|
if (gimp_value_array_length (args) > n_args &&
|
|
|
|
GIMP_IS_PARAM_SPEC_RUN_MODE (procedure->args[n_args]))
|
|
|
|
{
|
|
|
|
g_value_set_enum (gimp_value_array_index (args, n_args),
|
|
|
|
GIMP_RUN_INTERACTIVE);
|
|
|
|
n_args++;
|
|
|
|
}
|
2016-01-02 00:33:45 +01:00
|
|
|
|
|
|
|
if (gimp_value_array_length (args) > n_args &&
|
2019-08-29 11:25:35 +02:00
|
|
|
GIMP_IS_PARAM_SPEC_IMAGE (procedure->args[n_args]))
|
2016-01-02 00:33:45 +01:00
|
|
|
{
|
|
|
|
if (image)
|
|
|
|
{
|
2019-08-29 11:25:35 +02:00
|
|
|
g_value_set_object (gimp_value_array_index (args, n_args), image);
|
2016-01-02 00:33:45 +01:00
|
|
|
n_args++;
|
|
|
|
|
|
|
|
if (gimp_value_array_length (args) > n_args &&
|
2019-08-29 11:25:35 +02:00
|
|
|
GIMP_IS_PARAM_SPEC_ITEM (procedure->args[n_args]))
|
2016-01-02 00:33:45 +01:00
|
|
|
{
|
2022-10-12 22:37:14 +02:00
|
|
|
if (items_list)
|
2016-01-02 00:33:45 +01:00
|
|
|
{
|
2022-10-12 22:37:14 +02:00
|
|
|
g_printerr ("%s: plug-in procedures expecting a single item are deprecated!\n",
|
|
|
|
G_STRFUNC);
|
2019-08-29 11:25:35 +02:00
|
|
|
g_value_set_object (gimp_value_array_index (args, n_args),
|
2022-10-12 22:37:14 +02:00
|
|
|
items_list->data);
|
2016-01-02 00:33:45 +01:00
|
|
|
n_args++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-10-12 22:37:14 +02:00
|
|
|
g_warning ("Uh-oh, no selected items for the plug-in!");
|
2016-01-02 00:33:45 +01:00
|
|
|
gimp_value_array_unref (args);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2024-10-22 22:46:21 +02:00
|
|
|
else if (GIMP_IS_PARAM_SPEC_CORE_OBJECT_ARRAY (procedure->args[n_args]))
|
2022-10-12 22:37:14 +02:00
|
|
|
{
|
|
|
|
GimpItem **items = NULL;
|
|
|
|
gint n_items;
|
2024-10-22 22:46:21 +02:00
|
|
|
GList *iter;
|
|
|
|
gint i;
|
2022-10-12 22:37:14 +02:00
|
|
|
|
|
|
|
|
2024-10-22 22:46:21 +02:00
|
|
|
n_items = g_list_length (items_list);
|
|
|
|
items = g_new0 (GimpItem *, n_items + 1);
|
|
|
|
for (iter = items_list, i = 0; iter; iter = iter->next, i++)
|
|
|
|
items[i] = iter->data;
|
2022-10-12 22:37:14 +02:00
|
|
|
|
2024-10-22 22:46:21 +02:00
|
|
|
g_value_set_boxed (gimp_value_array_index (args, n_args++), (GObject **) items);
|
2022-10-12 22:37:14 +02:00
|
|
|
|
|
|
|
g_free (items);
|
|
|
|
}
|
2016-01-02 00:33:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-01 18:20:31 +02:00
|
|
|
if (n_args)
|
|
|
|
gimp_value_array_truncate (args, n_args);
|
2016-01-02 00:33:45 +01:00
|
|
|
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpValueArray *
|
|
|
|
procedure_commands_get_display_args (GimpProcedure *procedure,
|
2017-05-29 23:53:36 +02:00
|
|
|
GimpDisplay *display,
|
|
|
|
GimpObject *settings)
|
2016-01-02 00:33:45 +01:00
|
|
|
{
|
|
|
|
GimpValueArray *args;
|
|
|
|
gint n_args = 0;
|
|
|
|
|
|
|
|
args = gimp_procedure_get_arguments (procedure);
|
|
|
|
|
|
|
|
/* initialize the first argument */
|
2019-08-01 18:20:31 +02:00
|
|
|
if (gimp_value_array_length (args) > n_args &&
|
|
|
|
GIMP_IS_PARAM_SPEC_RUN_MODE (procedure->args[n_args]))
|
|
|
|
{
|
|
|
|
g_value_set_enum (gimp_value_array_index (args, n_args),
|
|
|
|
GIMP_RUN_INTERACTIVE);
|
|
|
|
n_args++;
|
|
|
|
}
|
2016-01-02 00:33:45 +01:00
|
|
|
|
|
|
|
if (gimp_value_array_length (args) > n_args &&
|
2019-08-29 11:25:35 +02:00
|
|
|
GIMP_IS_PARAM_SPEC_DISPLAY (procedure->args[n_args]))
|
2016-01-02 00:33:45 +01:00
|
|
|
{
|
|
|
|
if (display)
|
|
|
|
{
|
2019-08-29 11:25:35 +02:00
|
|
|
g_value_set_object (gimp_value_array_index (args, n_args), display);
|
2016-01-02 00:33:45 +01:00
|
|
|
n_args++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("Uh-oh, no active display for the plug-in!");
|
|
|
|
gimp_value_array_unref (args);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gimp_value_array_length (args) > n_args &&
|
2019-08-29 11:25:35 +02:00
|
|
|
GIMP_IS_PARAM_SPEC_IMAGE (procedure->args[n_args]))
|
2016-01-02 00:33:45 +01:00
|
|
|
{
|
|
|
|
GimpImage *image = display ? gimp_display_get_image (display) : NULL;
|
|
|
|
|
|
|
|
if (image)
|
|
|
|
{
|
2021-04-02 01:04:07 +02:00
|
|
|
GList *drawables_list = gimp_image_get_selected_drawables (image);
|
|
|
|
|
2019-08-29 11:25:35 +02:00
|
|
|
g_value_set_object (gimp_value_array_index (args, n_args), image);
|
2016-01-02 00:33:45 +01:00
|
|
|
n_args++;
|
|
|
|
|
|
|
|
if (gimp_value_array_length (args) > n_args &&
|
2019-08-29 11:25:35 +02:00
|
|
|
GIMP_IS_PARAM_SPEC_DRAWABLE (procedure->args[n_args]))
|
2016-01-02 00:33:45 +01:00
|
|
|
{
|
2021-04-02 01:04:07 +02:00
|
|
|
if (drawables_list)
|
2016-01-02 00:33:45 +01:00
|
|
|
{
|
2021-04-20 17:43:53 +02:00
|
|
|
g_printerr ("%s: plug-in procedures expecting a single drawable are deprecated!\n",
|
|
|
|
G_STRFUNC);
|
2019-08-29 11:25:35 +02:00
|
|
|
g_value_set_object (gimp_value_array_index (args, n_args),
|
2021-04-02 01:04:07 +02:00
|
|
|
drawables_list->data);
|
2016-01-02 00:33:45 +01:00
|
|
|
n_args++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-10-12 22:37:14 +02:00
|
|
|
g_warning ("Uh-oh, no selected drawables for the plug-in!");
|
2021-04-02 01:04:07 +02:00
|
|
|
|
2016-01-02 00:33:45 +01:00
|
|
|
gimp_value_array_unref (args);
|
2021-04-02 01:04:07 +02:00
|
|
|
g_list_free (drawables_list);
|
|
|
|
|
2016-01-02 00:33:45 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2024-10-22 22:46:21 +02:00
|
|
|
else if (GIMP_IS_PARAM_SPEC_CORE_OBJECT_ARRAY (procedure->args[n_args]))
|
2021-04-02 01:04:07 +02:00
|
|
|
{
|
|
|
|
GimpDrawable **drawables = NULL;
|
|
|
|
gint n_drawables;
|
2024-10-22 22:46:21 +02:00
|
|
|
GList *iter;
|
|
|
|
gint i;
|
2021-04-02 01:04:07 +02:00
|
|
|
|
|
|
|
|
2024-10-22 22:46:21 +02:00
|
|
|
n_drawables = g_list_length (drawables_list);
|
2021-04-02 01:04:07 +02:00
|
|
|
|
2024-10-22 22:46:21 +02:00
|
|
|
drawables = g_new0 (GimpDrawable *, n_drawables + 1);
|
|
|
|
for (iter = drawables_list, i = 0; iter; iter = iter->next, i++)
|
|
|
|
drawables[i] = iter->data;
|
2021-04-02 01:04:07 +02:00
|
|
|
|
2024-10-22 22:46:21 +02:00
|
|
|
g_value_set_boxed (gimp_value_array_index (args, n_args++), (GObject **) drawables);
|
2021-04-02 01:04:07 +02:00
|
|
|
|
|
|
|
g_free (drawables);
|
|
|
|
}
|
|
|
|
g_list_free (drawables_list);
|
2016-01-02 00:33:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-29 23:53:36 +02:00
|
|
|
if (gimp_value_array_length (args) > n_args &&
|
|
|
|
g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (procedure->args[n_args]),
|
|
|
|
GIMP_TYPE_OBJECT))
|
|
|
|
{
|
|
|
|
g_value_set_object (gimp_value_array_index (args, n_args), settings);
|
|
|
|
n_args++;
|
|
|
|
}
|
|
|
|
|
2019-08-01 18:20:31 +02:00
|
|
|
if (n_args)
|
|
|
|
gimp_value_array_truncate (args, n_args);
|
2016-01-02 00:33:45 +01:00
|
|
|
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:07:30 +01:00
|
|
|
gboolean
|
|
|
|
procedure_commands_run_procedure (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpProgress *progress,
|
2017-05-30 00:12:22 +02:00
|
|
|
GimpValueArray *args)
|
|
|
|
{
|
|
|
|
GimpValueArray *return_vals;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
|
|
|
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
|
|
|
|
g_return_val_if_fail (args != NULL, FALSE);
|
|
|
|
|
2019-08-01 18:20:31 +02:00
|
|
|
if (gimp_value_array_length (args) > 0 &&
|
|
|
|
GIMP_IS_PARAM_SPEC_RUN_MODE (procedure->args[0]))
|
|
|
|
g_value_set_enum (gimp_value_array_index (args, 0),
|
|
|
|
GIMP_RUN_NONINTERACTIVE);
|
2017-05-30 00:12:22 +02:00
|
|
|
|
|
|
|
return_vals = gimp_procedure_execute (procedure, gimp,
|
|
|
|
gimp_get_user_context (gimp),
|
|
|
|
progress, args,
|
|
|
|
&error);
|
|
|
|
gimp_value_array_unref (return_vals);
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
gimp_message_literal (gimp,
|
|
|
|
G_OBJECT (progress), GIMP_MESSAGE_ERROR,
|
|
|
|
error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
procedure_commands_run_procedure_async (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpProgress *progress,
|
|
|
|
GimpRunMode run_mode,
|
|
|
|
GimpValueArray *args,
|
|
|
|
GimpDisplay *display)
|
2016-01-04 15:07:30 +01:00
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
|
|
|
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
|
|
|
|
g_return_val_if_fail (display == NULL || GIMP_IS_DISPLAY (display), FALSE);
|
|
|
|
g_return_val_if_fail (args != NULL, FALSE);
|
|
|
|
|
2019-08-01 18:20:31 +02:00
|
|
|
if (gimp_value_array_length (args) > 0 &&
|
|
|
|
GIMP_IS_PARAM_SPEC_RUN_MODE (procedure->args[0]))
|
|
|
|
g_value_set_enum (gimp_value_array_index (args, 0),
|
|
|
|
run_mode);
|
2016-01-04 15:07:30 +01:00
|
|
|
|
|
|
|
gimp_procedure_execute_async (procedure, gimp,
|
|
|
|
gimp_get_user_context (gimp),
|
|
|
|
progress, args,
|
2019-09-04 14:27:18 +02:00
|
|
|
display, &error);
|
2016-01-04 15:07:30 +01:00
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
gimp_message_literal (gimp,
|
|
|
|
G_OBJECT (progress), GIMP_MESSAGE_ERROR,
|
|
|
|
error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|