2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-07-18 00:24:07 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-07-18 00:24:07 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-07-18 00:24:07 +00:00
|
|
|
* (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/>.
|
2001-07-18 00:24:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
2004-10-06 09:56:15 +00:00
|
|
|
#include <stdlib.h>
|
2001-07-18 00:24:07 +00:00
|
|
|
|
2016-01-01 19:37:10 +01:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2008-02-18 21:13:25 +00:00
|
|
|
#include <gegl.h>
|
2001-07-18 00:24:07 +00:00
|
|
|
|
2012-05-04 00:50:23 +02:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
2015-09-30 01:57:33 +02:00
|
|
|
#include "core-types.h"
|
2001-07-18 00:24:07 +00:00
|
|
|
|
2015-09-30 01:57:33 +02:00
|
|
|
#include "gimp.h"
|
|
|
|
#include "gimp-batch.h"
|
|
|
|
#include "gimpparamspecs.h"
|
2001-07-18 00:24:07 +00:00
|
|
|
|
2006-04-26 09:13:47 +00:00
|
|
|
#include "pdb/gimppdb.h"
|
2006-03-31 09:15:08 +00:00
|
|
|
#include "pdb/gimpprocedure.h"
|
2001-07-18 00:24:07 +00:00
|
|
|
|
2022-04-16 23:13:50 +02:00
|
|
|
#include "plug-in/gimppluginmanager.h"
|
|
|
|
#include "plug-in/gimppluginprocedure.h"
|
2004-10-06 09:56:15 +00:00
|
|
|
|
2022-04-16 23:13:50 +02:00
|
|
|
#include "gimp-intl.h"
|
2004-10-06 09:56:15 +00:00
|
|
|
|
2001-07-18 00:24:07 +00:00
|
|
|
|
2015-09-30 01:57:33 +02:00
|
|
|
static void gimp_batch_exit_after_callback (Gimp *gimp) G_GNUC_NORETURN;
|
2008-12-23 12:08:18 +00:00
|
|
|
|
app: when called with --quit, GIMP exit code will report batch failure.
If you call GIMP with batch commands and ask it to quit immediately, you
are likely interested by failure information. For this reason, let's now
report exit code other than success, but only in such case. In
particular, even if the batch commands fail, but GIMP is not set to exit
immediately, we continue reporting SUCCESS run at the very end (when
exiting interactively).
Note that I hardcode a few exit values, as standardly found on Linux
(but not using headers which may not be found on all platforms; in
particular, Windows apparently doesn't use any standard code other than
0 for success, from what my searches return).
Additionally, when several commands are requested, GIMP will now stop at
the first failing and will return its error code, and print a message on
stderr to easily report the failed command for easier debugging.
2022-04-16 02:25:03 +02:00
|
|
|
static gint gimp_batch_run_cmd (Gimp *gimp,
|
2015-09-30 01:57:33 +02:00
|
|
|
const gchar *proc_name,
|
|
|
|
GimpProcedure *procedure,
|
|
|
|
GimpRunMode run_mode,
|
|
|
|
const gchar *cmd);
|
2001-07-18 00:24:07 +00:00
|
|
|
|
|
|
|
|
app: when called with --quit, GIMP exit code will report batch failure.
If you call GIMP with batch commands and ask it to quit immediately, you
are likely interested by failure information. For this reason, let's now
report exit code other than success, but only in such case. In
particular, even if the batch commands fail, but GIMP is not set to exit
immediately, we continue reporting SUCCESS run at the very end (when
exiting interactively).
Note that I hardcode a few exit values, as standardly found on Linux
(but not using headers which may not be found on all platforms; in
particular, Windows apparently doesn't use any standard code other than
0 for success, from what my searches return).
Additionally, when several commands are requested, GIMP will now stop at
the first failing and will return its error code, and print a message on
stderr to easily report the failed command for easier debugging.
2022-04-16 02:25:03 +02:00
|
|
|
gint
|
2015-09-30 01:57:33 +02:00
|
|
|
gimp_batch_run (Gimp *gimp,
|
|
|
|
const gchar *batch_interpreter,
|
|
|
|
const gchar **batch_commands)
|
2001-07-18 00:24:07 +00:00
|
|
|
{
|
2022-04-17 14:23:21 +02:00
|
|
|
GimpProcedure *eval_proc;
|
|
|
|
GSList *batch_procedures;
|
|
|
|
GSList *iter;
|
|
|
|
gulong exit_id;
|
|
|
|
gint retval = EXIT_SUCCESS;
|
2001-07-18 00:24:07 +00:00
|
|
|
|
2004-12-12 18:41:52 +00:00
|
|
|
if (! batch_commands || ! batch_commands[0])
|
app: when called with --quit, GIMP exit code will report batch failure.
If you call GIMP with batch commands and ask it to quit immediately, you
are likely interested by failure information. For this reason, let's now
report exit code other than success, but only in such case. In
particular, even if the batch commands fail, but GIMP is not set to exit
immediately, we continue reporting SUCCESS run at the very end (when
exiting interactively).
Note that I hardcode a few exit values, as standardly found on Linux
(but not using headers which may not be found on all platforms; in
particular, Windows apparently doesn't use any standard code other than
0 for success, from what my searches return).
Additionally, when several commands are requested, GIMP will now stop at
the first failing and will return its error code, and print a message on
stderr to easily report the failed command for easier debugging.
2022-04-16 02:25:03 +02:00
|
|
|
return retval;
|
2004-10-06 09:56:15 +00:00
|
|
|
|
2022-04-16 23:13:50 +02:00
|
|
|
batch_procedures = gimp_plug_in_manager_get_batch_procedures (gimp->plug_in_manager);
|
|
|
|
if (g_slist_length (batch_procedures) == 0)
|
|
|
|
{
|
|
|
|
g_message (_("No batch interpreters are available. "
|
|
|
|
"Batch mode disabled."));
|
|
|
|
retval = 69; /* EX_UNAVAILABLE - service unavailable (sysexits.h) */
|
|
|
|
return retval;
|
|
|
|
}
|
2003-11-30 14:44:13 +00:00
|
|
|
|
2004-10-06 09:56:15 +00:00
|
|
|
if (! batch_interpreter)
|
2001-07-18 00:24:07 +00:00
|
|
|
{
|
2006-05-30 09:41:36 +00:00
|
|
|
batch_interpreter = g_getenv ("GIMP_BATCH_INTERPRETER");
|
2004-10-06 09:56:15 +00:00
|
|
|
|
2006-05-30 09:41:36 +00:00
|
|
|
if (! batch_interpreter)
|
|
|
|
{
|
2022-04-16 23:13:50 +02:00
|
|
|
if (g_slist_length (batch_procedures) == 1)
|
|
|
|
{
|
|
|
|
batch_interpreter = gimp_object_get_name (batch_procedures->data);;
|
|
|
|
|
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_printerr (_("No batch interpreter specified, using "
|
|
|
|
"'%s'.\n"), batch_interpreter);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
retval = 64; /* EX_USAGE - command line usage error */
|
2022-04-16 23:36:50 +02:00
|
|
|
g_print ("%s\n\n%s\n",
|
2022-04-16 23:13:50 +02:00
|
|
|
_("No batch interpreter specified."),
|
|
|
|
_("Available interpreters are:"));
|
|
|
|
|
|
|
|
for (iter = batch_procedures; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
GimpPlugInProcedure *proc = iter->data;
|
|
|
|
gchar *locale_name;
|
|
|
|
|
|
|
|
locale_name = g_locale_from_utf8 (proc->batch_interpreter_name,
|
|
|
|
-1, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
g_print ("- %s (%s)\n",
|
|
|
|
gimp_object_get_name (iter->data),
|
|
|
|
locale_name ? locale_name : proc->batch_interpreter_name);
|
|
|
|
|
|
|
|
g_free (locale_name);
|
|
|
|
}
|
|
|
|
|
2022-04-16 23:36:50 +02:00
|
|
|
g_print ("\n%s\n",
|
|
|
|
_("Specify one of these interpreters as --batch-interpreter option."));
|
|
|
|
|
2022-04-16 23:13:50 +02:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (iter = batch_procedures; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
if (g_strcmp0 (gimp_object_get_name (iter->data),
|
|
|
|
batch_interpreter) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iter == NULL)
|
|
|
|
{
|
|
|
|
retval = 69; /* EX_UNAVAILABLE - service unavailable (sysexits.h) */
|
|
|
|
g_print (_("The procedure '%s' is not a valid batch interpreter."),
|
|
|
|
batch_interpreter);
|
2022-04-16 23:36:50 +02:00
|
|
|
g_print ("\n%s\n\n%s\n",
|
2022-04-16 23:13:50 +02:00
|
|
|
_("Batch mode disabled."),
|
|
|
|
_("Available interpreters are:"));
|
|
|
|
|
|
|
|
for (iter = batch_procedures; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
GimpPlugInProcedure *proc = iter->data;
|
|
|
|
gchar *locale_name;
|
|
|
|
|
|
|
|
locale_name = g_locale_from_utf8 (proc->batch_interpreter_name,
|
|
|
|
-1, NULL, NULL, NULL);
|
2006-05-30 09:41:36 +00:00
|
|
|
|
2022-04-16 23:13:50 +02:00
|
|
|
g_print ("- %s (%s)\n",
|
|
|
|
gimp_object_get_name (iter->data),
|
|
|
|
locale_name ? locale_name : proc->batch_interpreter_name);
|
|
|
|
|
|
|
|
g_free (locale_name);
|
2006-05-30 09:41:36 +00:00
|
|
|
}
|
2022-04-16 23:36:50 +02:00
|
|
|
|
|
|
|
g_print ("\n%s\n",
|
|
|
|
_("Specify one of these interpreters as --batch-interpreter option."));
|
|
|
|
|
2022-04-16 23:13:50 +02:00
|
|
|
return retval;
|
2001-07-18 00:24:07 +00:00
|
|
|
}
|
|
|
|
|
2022-04-16 23:13:50 +02:00
|
|
|
exit_id = g_signal_connect_after (gimp, "exit",
|
|
|
|
G_CALLBACK (gimp_batch_exit_after_callback),
|
|
|
|
NULL);
|
|
|
|
|
2022-04-17 14:23:21 +02:00
|
|
|
eval_proc = gimp_pdb_lookup_procedure (gimp->pdb, batch_interpreter);
|
|
|
|
if (eval_proc)
|
2004-10-06 09:56:15 +00:00
|
|
|
{
|
2022-04-17 14:23:21 +02:00
|
|
|
gint i;
|
2004-12-12 18:41:52 +00:00
|
|
|
|
2022-04-17 14:23:21 +02:00
|
|
|
retval = EXIT_SUCCESS;
|
|
|
|
for (i = 0; batch_commands[i]; i++)
|
2004-12-12 18:41:52 +00:00
|
|
|
{
|
2022-04-17 14:23:21 +02:00
|
|
|
retval = gimp_batch_run_cmd (gimp, batch_interpreter, eval_proc,
|
|
|
|
GIMP_RUN_NONINTERACTIVE, batch_commands[i]);
|
2004-12-12 18:41:52 +00:00
|
|
|
|
2022-04-17 14:23:21 +02:00
|
|
|
/* In case of several commands, stop and return last
|
|
|
|
* failed command.
|
|
|
|
*/
|
|
|
|
if (retval != EXIT_SUCCESS)
|
app: when called with --quit, GIMP exit code will report batch failure.
If you call GIMP with batch commands and ask it to quit immediately, you
are likely interested by failure information. For this reason, let's now
report exit code other than success, but only in such case. In
particular, even if the batch commands fail, but GIMP is not set to exit
immediately, we continue reporting SUCCESS run at the very end (when
exiting interactively).
Note that I hardcode a few exit values, as standardly found on Linux
(but not using headers which may not be found on all platforms; in
particular, Windows apparently doesn't use any standard code other than
0 for success, from what my searches return).
Additionally, when several commands are requested, GIMP will now stop at
the first failing and will return its error code, and print a message on
stderr to easily report the failed command for easier debugging.
2022-04-16 02:25:03 +02:00
|
|
|
{
|
2022-04-17 14:23:21 +02:00
|
|
|
g_printerr ("Stopping at failing batch command [%d]: %s\n",
|
|
|
|
i, batch_commands[i]);
|
|
|
|
break;
|
app: when called with --quit, GIMP exit code will report batch failure.
If you call GIMP with batch commands and ask it to quit immediately, you
are likely interested by failure information. For this reason, let's now
report exit code other than success, but only in such case. In
particular, even if the batch commands fail, but GIMP is not set to exit
immediately, we continue reporting SUCCESS run at the very end (when
exiting interactively).
Note that I hardcode a few exit values, as standardly found on Linux
(but not using headers which may not be found on all platforms; in
particular, Windows apparently doesn't use any standard code other than
0 for success, from what my searches return).
Additionally, when several commands are requested, GIMP will now stop at
the first failing and will return its error code, and print a message on
stderr to easily report the failed command for easier debugging.
2022-04-16 02:25:03 +02:00
|
|
|
}
|
2004-12-12 18:41:52 +00:00
|
|
|
}
|
2022-04-17 14:23:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
retval = 69; /* EX_UNAVAILABLE - service unavailable (sysexits.h) */
|
|
|
|
g_message (_("The batch interpreter '%s' is not available. "
|
|
|
|
"Batch mode disabled."), batch_interpreter);
|
2001-07-18 00:24:07 +00:00
|
|
|
}
|
2003-11-30 14:44:13 +00:00
|
|
|
|
|
|
|
g_signal_handler_disconnect (gimp, exit_id);
|
app: when called with --quit, GIMP exit code will report batch failure.
If you call GIMP with batch commands and ask it to quit immediately, you
are likely interested by failure information. For this reason, let's now
report exit code other than success, but only in such case. In
particular, even if the batch commands fail, but GIMP is not set to exit
immediately, we continue reporting SUCCESS run at the very end (when
exiting interactively).
Note that I hardcode a few exit values, as standardly found on Linux
(but not using headers which may not be found on all platforms; in
particular, Windows apparently doesn't use any standard code other than
0 for success, from what my searches return).
Additionally, when several commands are requested, GIMP will now stop at
the first failing and will return its error code, and print a message on
stderr to easily report the failed command for easier debugging.
2022-04-16 02:25:03 +02:00
|
|
|
|
|
|
|
return retval;
|
2001-07-18 00:24:07 +00:00
|
|
|
}
|
|
|
|
|
2004-10-06 09:56:15 +00:00
|
|
|
|
2008-02-18 21:13:25 +00:00
|
|
|
/*
|
|
|
|
* The purpose of this handler is to exit GIMP cleanly when the batch
|
|
|
|
* procedure calls the gimp-exit procedure. Without this callback, the
|
|
|
|
* message "batch command experienced an execution error" would appear
|
|
|
|
* and gimp would hang forever.
|
|
|
|
*/
|
2008-12-23 12:08:18 +00:00
|
|
|
static void
|
2015-09-30 01:57:33 +02:00
|
|
|
gimp_batch_exit_after_callback (Gimp *gimp)
|
2003-11-30 14:44:13 +00:00
|
|
|
{
|
|
|
|
if (gimp->be_verbose)
|
2008-02-19 13:38:24 +00:00
|
|
|
g_print ("EXIT: %s\n", G_STRFUNC);
|
2008-02-18 21:13:25 +00:00
|
|
|
|
|
|
|
gegl_exit ();
|
|
|
|
|
2003-11-30 14:44:13 +00:00
|
|
|
exit (EXIT_SUCCESS);
|
|
|
|
}
|
2001-07-18 00:24:07 +00: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
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
app: when called with --quit, GIMP exit code will report batch failure.
If you call GIMP with batch commands and ask it to quit immediately, you
are likely interested by failure information. For this reason, let's now
report exit code other than success, but only in such case. In
particular, even if the batch commands fail, but GIMP is not set to exit
immediately, we continue reporting SUCCESS run at the very end (when
exiting interactively).
Note that I hardcode a few exit values, as standardly found on Linux
(but not using headers which may not be found on all platforms; in
particular, Windows apparently doesn't use any standard code other than
0 for success, from what my searches return).
Additionally, when several commands are requested, GIMP will now stop at
the first failing and will return its error code, and print a message on
stderr to easily report the failed command for easier debugging.
2022-04-16 02:25:03 +02:00
|
|
|
static gint
|
2015-09-30 01:57:33 +02:00
|
|
|
gimp_batch_run_cmd (Gimp *gimp,
|
|
|
|
const gchar *proc_name,
|
|
|
|
GimpProcedure *procedure,
|
|
|
|
GimpRunMode run_mode,
|
|
|
|
const gchar *cmd)
|
2001-07-18 00:24:07 +00:00
|
|
|
{
|
2012-05-04 00:50:23 +02:00
|
|
|
GimpValueArray *args;
|
|
|
|
GimpValueArray *return_vals;
|
app: when called with --quit, GIMP exit code will report batch failure.
If you call GIMP with batch commands and ask it to quit immediately, you
are likely interested by failure information. For this reason, let's now
report exit code other than success, but only in such case. In
particular, even if the batch commands fail, but GIMP is not set to exit
immediately, we continue reporting SUCCESS run at the very end (when
exiting interactively).
Note that I hardcode a few exit values, as standardly found on Linux
(but not using headers which may not be found on all platforms; in
particular, Windows apparently doesn't use any standard code other than
0 for success, from what my searches return).
Additionally, when several commands are requested, GIMP will now stop at
the first failing and will return its error code, and print a message on
stderr to easily report the failed command for easier debugging.
2022-04-16 02:25:03 +02:00
|
|
|
GError *error = NULL;
|
|
|
|
gint i = 0;
|
|
|
|
gint retval = EXIT_SUCCESS;
|
2001-07-18 00:24:07 +00:00
|
|
|
|
2006-03-31 17:42:13 +00:00
|
|
|
args = gimp_procedure_get_arguments (procedure);
|
2001-07-18 00:24:07 +00:00
|
|
|
|
2012-05-04 00:50:23 +02:00
|
|
|
if (procedure->num_args > i &&
|
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[i]))
|
|
|
|
{
|
|
|
|
g_value_set_enum (gimp_value_array_index (args, i++), run_mode);
|
|
|
|
}
|
2004-12-12 18:41:52 +00:00
|
|
|
|
2012-05-04 00:50:23 +02:00
|
|
|
if (procedure->num_args > i &&
|
2020-01-05 17:31:45 +01:00
|
|
|
G_IS_PARAM_SPEC_STRING (procedure->args[i]))
|
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_static_string (gimp_value_array_index (args, i++), cmd);
|
|
|
|
}
|
2001-07-18 00:24:07 +00:00
|
|
|
|
2006-06-09 06:47:03 +00:00
|
|
|
return_vals =
|
|
|
|
gimp_pdb_execute_procedure_by_name_args (gimp->pdb,
|
|
|
|
gimp_get_user_context (gimp),
|
2007-12-02 18:05:54 +00:00
|
|
|
NULL, &error,
|
2006-06-09 06:47:03 +00:00
|
|
|
proc_name, args);
|
2001-07-18 00:24:07 +00:00
|
|
|
|
2012-05-04 00:50:23 +02:00
|
|
|
switch (g_value_get_enum (gimp_value_array_index (return_vals, 0)))
|
2001-07-18 00:24:07 +00:00
|
|
|
{
|
|
|
|
case GIMP_PDB_EXECUTION_ERROR:
|
app: when called with --quit, GIMP exit code will report batch failure.
If you call GIMP with batch commands and ask it to quit immediately, you
are likely interested by failure information. For this reason, let's now
report exit code other than success, but only in such case. In
particular, even if the batch commands fail, but GIMP is not set to exit
immediately, we continue reporting SUCCESS run at the very end (when
exiting interactively).
Note that I hardcode a few exit values, as standardly found on Linux
(but not using headers which may not be found on all platforms; in
particular, Windows apparently doesn't use any standard code other than
0 for success, from what my searches return).
Additionally, when several commands are requested, GIMP will now stop at
the first failing and will return its error code, and print a message on
stderr to easily report the failed command for easier debugging.
2022-04-16 02:25:03 +02:00
|
|
|
/* Using Linux's standard exit code as found in /usr/include/sysexits.h
|
|
|
|
* Since other platforms may not have the header, I simply
|
|
|
|
* hardcode the few cases.
|
|
|
|
*/
|
|
|
|
retval = 70; /* EX_SOFTWARE - internal software error */
|
2007-12-02 18:05:54 +00:00
|
|
|
if (error)
|
|
|
|
{
|
2009-03-22 20:49:55 +00:00
|
|
|
g_printerr ("batch command experienced an execution error:\n"
|
|
|
|
"%s\n", error->message);
|
2007-12-02 18:05:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_printerr ("batch command experienced an execution error\n");
|
|
|
|
}
|
2001-07-18 00:24:07 +00:00
|
|
|
break;
|
2004-10-06 09:56:15 +00:00
|
|
|
|
2001-07-18 00:24:07 +00:00
|
|
|
case GIMP_PDB_CALLING_ERROR:
|
app: when called with --quit, GIMP exit code will report batch failure.
If you call GIMP with batch commands and ask it to quit immediately, you
are likely interested by failure information. For this reason, let's now
report exit code other than success, but only in such case. In
particular, even if the batch commands fail, but GIMP is not set to exit
immediately, we continue reporting SUCCESS run at the very end (when
exiting interactively).
Note that I hardcode a few exit values, as standardly found on Linux
(but not using headers which may not be found on all platforms; in
particular, Windows apparently doesn't use any standard code other than
0 for success, from what my searches return).
Additionally, when several commands are requested, GIMP will now stop at
the first failing and will return its error code, and print a message on
stderr to easily report the failed command for easier debugging.
2022-04-16 02:25:03 +02:00
|
|
|
retval = 64; /* EX_USAGE - command line usage error */
|
2007-12-02 18:05:54 +00:00
|
|
|
if (error)
|
|
|
|
{
|
2009-03-22 20:49:55 +00:00
|
|
|
g_printerr ("batch command experienced a calling error:\n"
|
|
|
|
"%s\n", error->message);
|
2007-12-02 18:05:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_printerr ("batch command experienced a calling error\n");
|
|
|
|
}
|
2001-07-18 00:24:07 +00:00
|
|
|
break;
|
2004-10-06 09:56:15 +00:00
|
|
|
|
2001-07-18 00:24:07 +00:00
|
|
|
case GIMP_PDB_SUCCESS:
|
app: when called with --quit, GIMP exit code will report batch failure.
If you call GIMP with batch commands and ask it to quit immediately, you
are likely interested by failure information. For this reason, let's now
report exit code other than success, but only in such case. In
particular, even if the batch commands fail, but GIMP is not set to exit
immediately, we continue reporting SUCCESS run at the very end (when
exiting interactively).
Note that I hardcode a few exit values, as standardly found on Linux
(but not using headers which may not be found on all platforms; in
particular, Windows apparently doesn't use any standard code other than
0 for success, from what my searches return).
Additionally, when several commands are requested, GIMP will now stop at
the first failing and will return its error code, and print a message on
stderr to easily report the failed command for easier debugging.
2022-04-16 02:25:03 +02:00
|
|
|
retval = EXIT_SUCCESS;
|
2007-12-02 18:05:54 +00:00
|
|
|
g_printerr ("batch command executed successfully\n");
|
2001-07-18 00:24:07 +00:00
|
|
|
break;
|
app: when called with --quit, GIMP exit code will report batch failure.
If you call GIMP with batch commands and ask it to quit immediately, you
are likely interested by failure information. For this reason, let's now
report exit code other than success, but only in such case. In
particular, even if the batch commands fail, but GIMP is not set to exit
immediately, we continue reporting SUCCESS run at the very end (when
exiting interactively).
Note that I hardcode a few exit values, as standardly found on Linux
(but not using headers which may not be found on all platforms; in
particular, Windows apparently doesn't use any standard code other than
0 for success, from what my searches return).
Additionally, when several commands are requested, GIMP will now stop at
the first failing and will return its error code, and print a message on
stderr to easily report the failed command for easier debugging.
2022-04-16 02:25:03 +02:00
|
|
|
|
|
|
|
case GIMP_PDB_CANCEL:
|
|
|
|
/* Not in sysexits.h, but usually used for 'Script terminated by
|
|
|
|
* Control-C'. See: https://tldp.org/LDP/abs/html/exitcodes.html
|
|
|
|
*/
|
|
|
|
retval = 130;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_PASS_THROUGH:
|
|
|
|
retval = EXIT_FAILURE; /* Catchall. */
|
|
|
|
break;
|
2001-07-18 00:24:07 +00:00
|
|
|
}
|
2003-09-03 09:30:09 +00:00
|
|
|
|
2012-05-04 00:50:23 +02:00
|
|
|
gimp_value_array_unref (return_vals);
|
|
|
|
gimp_value_array_unref (args);
|
2001-07-18 00:24:07 +00:00
|
|
|
|
2007-12-02 18:05:54 +00:00
|
|
|
if (error)
|
|
|
|
g_error_free (error);
|
|
|
|
|
app: when called with --quit, GIMP exit code will report batch failure.
If you call GIMP with batch commands and ask it to quit immediately, you
are likely interested by failure information. For this reason, let's now
report exit code other than success, but only in such case. In
particular, even if the batch commands fail, but GIMP is not set to exit
immediately, we continue reporting SUCCESS run at the very end (when
exiting interactively).
Note that I hardcode a few exit values, as standardly found on Linux
(but not using headers which may not be found on all platforms; in
particular, Windows apparently doesn't use any standard code other than
0 for success, from what my searches return).
Additionally, when several commands are requested, GIMP will now stop at
the first failing and will return its error code, and print a message on
stderr to easily report the failed command for easier debugging.
2022-04-16 02:25:03 +02:00
|
|
|
return retval;
|
2001-07-18 00:24:07 +00:00
|
|
|
}
|