~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/batch.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
28
28
#include "base/base.h"
29
29
 
30
30
#include "core/gimp.h"
 
31
#include "core/gimpparamspecs.h"
31
32
 
32
33
#include "batch.h"
33
34
 
34
 
#include "pdb/procedural_db.h"
 
35
#include "pdb/gimppdb.h"
 
36
#include "pdb/gimpprocedure.h"
35
37
 
36
38
#include "gimp-intl.h"
37
39
 
38
40
 
39
 
#define BATCH_DEFAULT_EVAL_PROC   "plug_in_script_fu_eval"
40
 
 
41
 
 
42
 
static gboolean  batch_exit_after_callback (Gimp        *gimp,
43
 
                                            gboolean     kill_it);
44
 
static void      batch_run_cmd             (Gimp        *gimp,
45
 
                                            const gchar *proc_name,
46
 
                                            ProcRecord  *proc,
47
 
                                            GimpRunMode  run_mode,
48
 
                                            const gchar *cmd);
 
41
#define BATCH_DEFAULT_EVAL_PROC   "plug-in-script-fu-eval"
 
42
 
 
43
 
 
44
static gboolean  batch_exit_after_callback (Gimp          *gimp,
 
45
                                            gboolean       kill_it);
 
46
static void      batch_run_cmd             (Gimp          *gimp,
 
47
                                            const gchar   *proc_name,
 
48
                                            GimpProcedure *procedure,
 
49
                                            GimpRunMode    run_mode,
 
50
                                            const gchar   *cmd);
49
51
 
50
52
 
51
53
void
64
66
 
65
67
  if (! batch_interpreter)
66
68
    {
67
 
      batch_interpreter = BATCH_DEFAULT_EVAL_PROC;
68
 
 
69
 
      g_printerr ("No batch interpreter specified, using the default '%s'.\n",
70
 
                  batch_interpreter);
 
69
      batch_interpreter = g_getenv ("GIMP_BATCH_INTERPRETER");
 
70
 
 
71
      if (! batch_interpreter)
 
72
        {
 
73
          batch_interpreter = BATCH_DEFAULT_EVAL_PROC;
 
74
 
 
75
          g_printerr (_("No batch interpreter specified, using the default "
 
76
                        "'%s'.\n"), batch_interpreter);
 
77
        }
71
78
    }
72
79
 
73
80
  /*  script-fu text console, hardcoded for backward compatibility  */
74
81
 
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)
77
84
    {
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,
 
87
                                                            proc_name);
80
88
 
81
 
      if (proc)
82
 
        batch_run_cmd (gimp, proc_name, proc, GIMP_RUN_INTERACTIVE, NULL);
 
89
      if (procedure)
 
90
        batch_run_cmd (gimp, proc_name, procedure,
 
91
                       GIMP_RUN_NONINTERACTIVE, NULL);
83
92
      else
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);
86
95
    }
87
96
  else
88
97
    {
89
 
      ProcRecord *eval_proc = procedural_db_lookup (gimp, batch_interpreter);
 
98
      GimpProcedure *eval_proc = gimp_pdb_lookup_procedure (gimp->pdb,
 
99
                                                            batch_interpreter);
90
100
 
91
101
      if (eval_proc)
92
102
        {
98
108
        }
99
109
      else
100
110
        {
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);
103
113
        }
104
114
    }
105
115
 
122
132
}
123
133
 
124
134
static void
125
 
batch_run_cmd (Gimp        *gimp,
126
 
               const gchar *proc_name,
127
 
               ProcRecord  *proc,
128
 
               GimpRunMode  run_mode,
129
 
               const gchar *cmd)
 
135
batch_run_cmd (Gimp          *gimp,
 
136
               const gchar   *proc_name,
 
137
               GimpProcedure *procedure,
 
138
               GimpRunMode    run_mode,
 
139
               const gchar   *cmd)
130
140
{
131
 
  Argument *args;
132
 
  Argument *vals;
133
 
  gint      i;
134
 
 
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;
138
 
 
139
 
  args[0].value.pdb_int = run_mode;
140
 
 
141
 
  if (proc->num_args > 1)
142
 
    args[1].value.pdb_pointer = (gpointer) cmd;
143
 
 
144
 
  vals = procedural_db_execute (gimp,
145
 
                                gimp_get_user_context (gimp), NULL,
146
 
                                proc_name, args);
147
 
 
148
 
  switch (vals[0].value.pdb_int)
 
141
  GValueArray *args;
 
142
  GValueArray *return_vals;
 
143
  gint         i = 0;
 
144
 
 
145
  args = gimp_procedure_get_arguments (procedure);
 
146
 
 
147
  if (procedure->num_args > i && GIMP_IS_PARAM_SPEC_INT32 (procedure->args[i]))
 
148
    g_value_set_int (&args->values[i++], run_mode);
 
149
 
 
150
  if (procedure->num_args > i && GIMP_IS_PARAM_SPEC_STRING (procedure->args[i]))
 
151
    g_value_set_static_string (&args->values[i++], cmd);
 
152
 
 
153
  return_vals =
 
154
    gimp_pdb_execute_procedure_by_name_args (gimp->pdb,
 
155
                                             gimp_get_user_context (gimp),
 
156
                                             NULL,
 
157
                                             proc_name, args);
 
158
 
 
159
  switch (g_value_get_enum (&return_vals->values[0]))
149
160
    {
150
161
    case GIMP_PDB_EXECUTION_ERROR:
151
162
      g_printerr ("batch command: experienced an execution error.\n");
160
171
      break;
161
172
    }
162
173
 
163
 
  procedural_db_destroy_args (vals, proc->num_values);
164
 
  g_free (args);
 
174
  g_value_array_free (return_vals);
 
175
  g_value_array_free (args);
165
176
 
166
177
  return;
167
178
}