app: add a new --quit CLI option to quit GIMP after a batch script.

Instead of asking for the script to call gimp_quit() which is not too
proper (because this is actually meant to exit the script, not GIMP
itself. Scripts should not have the ability to basically kill the main
GIMP process), let's add a `--quit` option which does what it says: it
quits GIMP immediately (after having processed any task on command line,
such as running batch scripts).

See discussions in issue #7376.
This commit is contained in:
Jehan 2022-04-16 00:46:32 +02:00
parent 2d3476805e
commit 028210369a
3 changed files with 18 additions and 0 deletions

View file

@ -169,6 +169,7 @@ app_run (const gchar *full_prog_name,
const gchar *session_name,
const gchar *batch_interpreter,
const gchar **batch_commands,
gboolean quit,
gboolean as_new,
gboolean no_interface,
gboolean no_data,
@ -425,6 +426,15 @@ app_run (const gchar *full_prog_name,
if (run_loop)
gimp_batch_run (gimp, batch_interpreter, batch_commands);
if (quit)
{
/* Return value, needed for the signal call; let's just ignore the
* result. */
gboolean cb_retval;
g_signal_emit_by_name (gimp, "exit", TRUE, &cb_retval);
}
if (run_loop)
g_main_loop_run (loop);

View file

@ -37,6 +37,7 @@ void app_run (const gchar *full_prog_name,
const gchar *session_name,
const gchar *batch_interpreter,
const gchar **batch_commands,
gboolean quit,
gboolean as_new,
gboolean no_interface,
gboolean no_data,

View file

@ -129,6 +129,7 @@ static const gchar *session_name = NULL;
static const gchar *batch_interpreter = NULL;
static const gchar **batch_commands = NULL;
static const gchar **filenames = NULL;
static gboolean quit = FALSE;
static gboolean as_new = FALSE;
static gboolean no_interface = FALSE;
static gboolean no_data = FALSE;
@ -239,6 +240,11 @@ static const GOptionEntry main_entries[] =
G_OPTION_ARG_STRING, &batch_interpreter,
N_("The procedure to process batch commands with"), "<proc>"
},
{
"quit", 0, 0,
G_OPTION_ARG_NONE, &quit,
N_("Quit immediately after performing requested actions"), NULL
},
{
"console-messages", 'c', 0,
G_OPTION_ARG_NONE, &console_messages,
@ -788,6 +794,7 @@ main (int argc,
session_name,
batch_interpreter,
batch_commands,
quit,
as_new,
no_interface,
no_data,