1
/* The GIMP -- an image manipulation program
1
/* GIMP - The GNU Image Manipulation Program
2
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
4
* This program is free software; you can redistribute it and/or modify
28
28
#include "base/base.h"
30
30
#include "core/gimp.h"
31
#include "core/gimpparamspecs.h"
34
#include "pdb/procedural_db.h"
35
#include "pdb/gimppdb.h"
36
#include "pdb/gimpprocedure.h"
36
38
#include "gimp-intl.h"
39
#define BATCH_DEFAULT_EVAL_PROC "plug_in_script_fu_eval"
42
static gboolean batch_exit_after_callback (Gimp *gimp,
44
static void batch_run_cmd (Gimp *gimp,
45
const gchar *proc_name,
41
#define BATCH_DEFAULT_EVAL_PROC "plug-in-script-fu-eval"
44
static gboolean batch_exit_after_callback (Gimp *gimp,
46
static void batch_run_cmd (Gimp *gimp,
47
const gchar *proc_name,
48
GimpProcedure *procedure,
65
67
if (! batch_interpreter)
67
batch_interpreter = BATCH_DEFAULT_EVAL_PROC;
69
g_printerr ("No batch interpreter specified, using the default '%s'.\n",
69
batch_interpreter = g_getenv ("GIMP_BATCH_INTERPRETER");
71
if (! batch_interpreter)
73
batch_interpreter = BATCH_DEFAULT_EVAL_PROC;
75
g_printerr (_("No batch interpreter specified, using the default "
76
"'%s'.\n"), batch_interpreter);
73
80
/* script-fu text console, hardcoded for backward compatibility */
75
if (strcmp (batch_interpreter, "plug_in_script_fu_eval") == 0 &&
82
if (strcmp (batch_interpreter, "plug-in-script-fu-eval") == 0 &&
76
83
strcmp (batch_commands[0], "-") == 0)
78
const gchar *proc_name = "plug_in_script_fu_text_console";
79
ProcRecord *proc = procedural_db_lookup (gimp, proc_name);
85
const gchar *proc_name = "plug-in-script-fu-text-console";
86
GimpProcedure *procedure = gimp_pdb_lookup_procedure (gimp->pdb,
82
batch_run_cmd (gimp, proc_name, proc, GIMP_RUN_INTERACTIVE, NULL);
90
batch_run_cmd (gimp, proc_name, procedure,
91
GIMP_RUN_NONINTERACTIVE, NULL);
84
g_message (_("The batch interpreter '%s' is not available, "
85
"batch mode disabled."), proc_name);
93
g_message (_("The batch interpreter '%s' is not available. "
94
"Batch mode disabled."), proc_name);
89
ProcRecord *eval_proc = procedural_db_lookup (gimp, batch_interpreter);
98
GimpProcedure *eval_proc = gimp_pdb_lookup_procedure (gimp->pdb,
101
g_message (_("The batch interpreter '%s' is not available, "
102
"batch mode disabled."), batch_interpreter);
111
g_message (_("The batch interpreter '%s' is not available. "
112
"Batch mode disabled."), batch_interpreter);
125
batch_run_cmd (Gimp *gimp,
126
const gchar *proc_name,
128
GimpRunMode run_mode,
135
batch_run_cmd (Gimp *gimp,
136
const gchar *proc_name,
137
GimpProcedure *procedure,
138
GimpRunMode run_mode,
135
args = g_new0 (Argument, proc->num_args);
136
for (i = 0; i < proc->num_args; i++)
137
args[i].arg_type = proc->args[i].arg_type;
139
args[0].value.pdb_int = run_mode;
141
if (proc->num_args > 1)
142
args[1].value.pdb_pointer = (gpointer) cmd;
144
vals = procedural_db_execute (gimp,
145
gimp_get_user_context (gimp), NULL,
148
switch (vals[0].value.pdb_int)
142
GValueArray *return_vals;
145
args = gimp_procedure_get_arguments (procedure);
147
if (procedure->num_args > i && GIMP_IS_PARAM_SPEC_INT32 (procedure->args[i]))
148
g_value_set_int (&args->values[i++], run_mode);
150
if (procedure->num_args > i && GIMP_IS_PARAM_SPEC_STRING (procedure->args[i]))
151
g_value_set_static_string (&args->values[i++], cmd);
154
gimp_pdb_execute_procedure_by_name_args (gimp->pdb,
155
gimp_get_user_context (gimp),
159
switch (g_value_get_enum (&return_vals->values[0]))
150
161
case GIMP_PDB_EXECUTION_ERROR:
151
162
g_printerr ("batch command: experienced an execution error.\n");