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

« back to all changes in this revision

Viewing changes to app/pdb/patterns_cmds.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-2003 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
16
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
17
 */
18
18
 
19
 
/* NOTE: This file is autogenerated by pdbgen.pl. */
 
19
/* NOTE: This file is auto-generated by pdbgen.pl. */
20
20
 
21
21
#include "config.h"
22
22
 
25
25
#include <glib-object.h>
26
26
 
27
27
#include "pdb-types.h"
28
 
#include "procedural_db.h"
 
28
#include "gimppdb.h"
 
29
#include "gimpprocedure.h"
 
30
#include "core/gimpparamspecs.h"
29
31
 
30
32
#include "base/temp-buf.h"
31
33
#include "core/gimp.h"
35
37
#include "core/gimplist.h"
36
38
#include "core/gimppattern.h"
37
39
 
38
 
static ProcRecord patterns_refresh_proc;
39
 
static ProcRecord patterns_get_list_proc;
40
 
static ProcRecord patterns_get_pattern_proc;
41
 
static ProcRecord patterns_get_pattern_data_proc;
42
 
 
43
 
void
44
 
register_patterns_procs (Gimp *gimp)
45
 
{
46
 
  procedural_db_register (gimp, &patterns_refresh_proc);
47
 
  procedural_db_register (gimp, &patterns_get_list_proc);
48
 
  procedural_db_register (gimp, &patterns_get_pattern_proc);
49
 
  procedural_db_register (gimp, &patterns_get_pattern_data_proc);
50
 
}
51
 
 
52
 
static Argument *
53
 
patterns_refresh_invoker (Gimp         *gimp,
54
 
                          GimpContext  *context,
55
 
                          GimpProgress *progress,
56
 
                          Argument     *args)
57
 
{
58
 
  gimp_data_factory_data_save (gimp->pattern_factory);
59
 
  gimp_data_factory_data_init (gimp->pattern_factory, FALSE);
60
 
  return procedural_db_return_args (&patterns_refresh_proc, TRUE);
61
 
}
62
 
 
63
 
static ProcRecord patterns_refresh_proc =
64
 
{
65
 
  "gimp_patterns_refresh",
66
 
  "Refresh current patterns. This function always succeeds.",
67
 
  "This procedure retrieves all patterns currently in the user's pattern path and updates all pattern dialogs accordingly.",
68
 
  "Michael Natterer",
69
 
  "Michael Natterer",
70
 
  "2002",
71
 
  NULL,
72
 
  GIMP_INTERNAL,
73
 
  0,
74
 
  NULL,
75
 
  0,
76
 
  NULL,
77
 
  { { patterns_refresh_invoker } }
78
 
};
79
 
 
80
 
static Argument *
81
 
patterns_get_list_invoker (Gimp         *gimp,
82
 
                           GimpContext  *context,
83
 
                           GimpProgress *progress,
84
 
                           Argument     *args)
 
40
#include "internal_procs.h"
 
41
 
 
42
 
 
43
static GValueArray *
 
44
patterns_refresh_invoker (GimpProcedure     *procedure,
 
45
                          Gimp              *gimp,
 
46
                          GimpContext       *context,
 
47
                          GimpProgress      *progress,
 
48
                          const GValueArray *args)
 
49
{
 
50
  gimp_data_factory_data_refresh (gimp->pattern_factory);
 
51
  return gimp_procedure_get_return_values (procedure, TRUE);
 
52
}
 
53
 
 
54
static GValueArray *
 
55
patterns_get_list_invoker (GimpProcedure     *procedure,
 
56
                           Gimp              *gimp,
 
57
                           GimpContext       *context,
 
58
                           GimpProgress      *progress,
 
59
                           const GValueArray *args)
85
60
{
86
61
  gboolean success = TRUE;
87
 
  Argument *return_args;
88
 
  gchar *filter;
89
 
  gint32 num_patterns;
 
62
  GValueArray *return_vals;
 
63
  const gchar *filter;
 
64
  gint32 num_patterns = 0;
90
65
  gchar **pattern_list = NULL;
91
66
 
92
 
  filter = (gchar *) args[0].value.pdb_pointer;
93
 
  if (filter && !g_utf8_validate (filter, -1, NULL))
 
67
  filter = g_value_get_string (&args->values[0]);
 
68
 
 
69
  if (success)
 
70
    {
 
71
      pattern_list = gimp_container_get_filtered_name_array (gimp->pattern_factory->container,
 
72
                                                             filter, &num_patterns);
 
73
    }
 
74
 
 
75
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
76
 
 
77
  if (success)
 
78
    {
 
79
      g_value_set_int (&return_vals->values[1], num_patterns);
 
80
      gimp_value_take_stringarray (&return_vals->values[2], pattern_list, num_patterns);
 
81
    }
 
82
 
 
83
  return return_vals;
 
84
}
 
85
 
 
86
static GValueArray *
 
87
patterns_get_pattern_invoker (GimpProcedure     *procedure,
 
88
                              Gimp              *gimp,
 
89
                              GimpContext       *context,
 
90
                              GimpProgress      *progress,
 
91
                              const GValueArray *args)
 
92
{
 
93
  gboolean success = TRUE;
 
94
  GValueArray *return_vals;
 
95
  gchar *name = NULL;
 
96
  gint32 width = 0;
 
97
  gint32 height = 0;
 
98
 
 
99
  GimpPattern *pattern = gimp_context_get_pattern (context);
 
100
 
 
101
  if (pattern)
 
102
    {
 
103
      name   = g_strdup (gimp_object_get_name (GIMP_OBJECT (pattern)));
 
104
      width  = pattern->mask->width;
 
105
      height = pattern->mask->height;
 
106
    }
 
107
  else
94
108
    success = FALSE;
95
109
 
96
 
  if (success)
97
 
    pattern_list = gimp_container_get_filtered_name_array (gimp->pattern_factory->container, filter, &num_patterns);
98
 
 
99
 
  return_args = procedural_db_return_args (&patterns_get_list_proc, success);
100
 
 
101
 
  if (success)
102
 
    {
103
 
      return_args[1].value.pdb_int = num_patterns;
104
 
      return_args[2].value.pdb_pointer = pattern_list;
105
 
    }
106
 
 
107
 
  return return_args;
108
 
}
109
 
 
110
 
static ProcArg patterns_get_list_inargs[] =
111
 
{
112
 
  {
113
 
    GIMP_PDB_STRING,
114
 
    "filter",
115
 
    "An optional regular expression used to filter the list"
116
 
  }
117
 
};
118
 
 
119
 
static ProcArg patterns_get_list_outargs[] =
120
 
{
121
 
  {
122
 
    GIMP_PDB_INT32,
123
 
    "num_patterns",
124
 
    "The number of patterns in the pattern list"
125
 
  },
126
 
  {
127
 
    GIMP_PDB_STRINGARRAY,
128
 
    "pattern_list",
129
 
    "The list of pattern names"
130
 
  }
131
 
};
132
 
 
133
 
static ProcRecord patterns_get_list_proc =
134
 
{
135
 
  "gimp_patterns_get_list",
136
 
  "Retrieve a complete listing of the available patterns.",
137
 
  "This procedure returns a complete listing of available GIMP patterns. Each name returned can be used as input to the 'gimp_context_set_pattern'.",
138
 
  "Spencer Kimball & Peter Mattis",
139
 
  "Spencer Kimball & Peter Mattis",
140
 
  "1995-1996",
141
 
  NULL,
142
 
  GIMP_INTERNAL,
143
 
  1,
144
 
  patterns_get_list_inargs,
145
 
  2,
146
 
  patterns_get_list_outargs,
147
 
  { { patterns_get_list_invoker } }
148
 
};
149
 
 
150
 
static Argument *
151
 
patterns_get_pattern_invoker (Gimp         *gimp,
152
 
                              GimpContext  *context,
153
 
                              GimpProgress *progress,
154
 
                              Argument     *args)
155
 
{
156
 
  gboolean success = TRUE;
157
 
  Argument *return_args;
158
 
  GimpPattern *pattern;
159
 
 
160
 
  success = (pattern = gimp_context_get_pattern (context)) != NULL;
161
 
 
162
 
  return_args = procedural_db_return_args (&patterns_get_pattern_proc, success);
163
 
 
164
 
  if (success)
165
 
    {
166
 
      return_args[1].value.pdb_pointer = g_strdup (GIMP_OBJECT (pattern)->name);
167
 
      return_args[2].value.pdb_int = pattern->mask->width;
168
 
      return_args[3].value.pdb_int = pattern->mask->height;
169
 
    }
170
 
 
171
 
  return return_args;
172
 
}
173
 
 
174
 
static ProcArg patterns_get_pattern_outargs[] =
175
 
{
176
 
  {
177
 
    GIMP_PDB_STRING,
178
 
    "name",
179
 
    "The pattern name"
180
 
  },
181
 
  {
182
 
    GIMP_PDB_INT32,
183
 
    "width",
184
 
    "The pattern width"
185
 
  },
186
 
  {
187
 
    GIMP_PDB_INT32,
188
 
    "height",
189
 
    "The pattern height"
190
 
  }
191
 
};
192
 
 
193
 
static ProcRecord patterns_get_pattern_proc =
194
 
{
195
 
  "gimp_patterns_get_pattern",
196
 
  "This procedure is deprecated! Use 'gimp_context_get_pattern' instead.",
197
 
  "This procedure is deprecated! Use 'gimp_context_get_pattern' instead.",
198
 
  "",
199
 
  "",
200
 
  "",
201
 
  "gimp_context_get_pattern",
202
 
  GIMP_INTERNAL,
203
 
  0,
204
 
  NULL,
205
 
  3,
206
 
  patterns_get_pattern_outargs,
207
 
  { { patterns_get_pattern_invoker } }
208
 
};
209
 
 
210
 
static Argument *
211
 
patterns_get_pattern_data_invoker (Gimp         *gimp,
212
 
                                   GimpContext  *context,
213
 
                                   GimpProgress *progress,
214
 
                                   Argument     *args)
215
 
{
216
 
  gboolean success = TRUE;
217
 
  Argument *return_args;
218
 
  gchar *name;
 
110
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
111
 
 
112
  if (success)
 
113
    {
 
114
      g_value_take_string (&return_vals->values[1], name);
 
115
      g_value_set_int (&return_vals->values[2], width);
 
116
      g_value_set_int (&return_vals->values[3], height);
 
117
    }
 
118
 
 
119
  return return_vals;
 
120
}
 
121
 
 
122
static GValueArray *
 
123
patterns_get_pattern_data_invoker (GimpProcedure     *procedure,
 
124
                                   Gimp              *gimp,
 
125
                                   GimpContext       *context,
 
126
                                   GimpProgress      *progress,
 
127
                                   const GValueArray *args)
 
128
{
 
129
  gboolean success = TRUE;
 
130
  GValueArray *return_vals;
 
131
  const gchar *name;
 
132
  gchar *actual_name = NULL;
 
133
  gint32 width = 0;
 
134
  gint32 height = 0;
 
135
  gint32 mask_bpp = 0;
219
136
  gint32 length = 0;
220
137
  guint8 *mask_data = NULL;
221
 
  GimpPattern *pattern = NULL;
222
138
 
223
 
  name = (gchar *) args[0].value.pdb_pointer;
224
 
  if (name && !g_utf8_validate (name, -1, NULL))
225
 
    success = FALSE;
 
139
  name = g_value_get_string (&args->values[0]);
226
140
 
227
141
  if (success)
228
142
    {
 
143
      GimpPattern *pattern;
 
144
 
229
145
      if (name && strlen (name))
230
146
        {
231
147
          pattern = (GimpPattern *)
239
155
 
240
156
      if (pattern)
241
157
        {
242
 
          length = pattern->mask->height * pattern->mask->width *
243
 
                   pattern->mask->bytes;
244
 
          mask_data = g_memdup (temp_buf_data (pattern->mask), length);
 
158
          actual_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (pattern)));
 
159
          width       = pattern->mask->width;
 
160
          height      = pattern->mask->height;
 
161
          mask_bpp    = pattern->mask->bytes;
 
162
          length      = pattern->mask->height * pattern->mask->width *
 
163
                        pattern->mask->bytes;
 
164
          mask_data   = g_memdup (temp_buf_data (pattern->mask), length);
245
165
        }
246
166
      else
247
167
        success = FALSE;
248
168
    }
249
169
 
250
 
  return_args = procedural_db_return_args (&patterns_get_pattern_data_proc, success);
 
170
  return_vals = gimp_procedure_get_return_values (procedure, success);
251
171
 
252
172
  if (success)
253
173
    {
254
 
      return_args[1].value.pdb_pointer = g_strdup (GIMP_OBJECT (pattern)->name);
255
 
      return_args[2].value.pdb_int = pattern->mask->width;
256
 
      return_args[3].value.pdb_int = pattern->mask->height;
257
 
      return_args[4].value.pdb_int = pattern->mask->bytes;
258
 
      return_args[5].value.pdb_int = length;
259
 
      return_args[6].value.pdb_pointer = mask_data;
 
174
      g_value_take_string (&return_vals->values[1], actual_name);
 
175
      g_value_set_int (&return_vals->values[2], width);
 
176
      g_value_set_int (&return_vals->values[3], height);
 
177
      g_value_set_int (&return_vals->values[4], mask_bpp);
 
178
      g_value_set_int (&return_vals->values[5], length);
 
179
      gimp_value_take_int8array (&return_vals->values[6], mask_data, length);
260
180
    }
261
181
 
262
 
  return return_args;
263
 
}
264
 
 
265
 
static ProcArg patterns_get_pattern_data_inargs[] =
266
 
{
267
 
  {
268
 
    GIMP_PDB_STRING,
269
 
    "name",
270
 
    "The pattern name (\"\" means currently active pattern)"
271
 
  }
272
 
};
273
 
 
274
 
static ProcArg patterns_get_pattern_data_outargs[] =
275
 
{
276
 
  {
277
 
    GIMP_PDB_STRING,
278
 
    "name",
279
 
    "The pattern name"
280
 
  },
281
 
  {
282
 
    GIMP_PDB_INT32,
283
 
    "width",
284
 
    "The pattern width"
285
 
  },
286
 
  {
287
 
    GIMP_PDB_INT32,
288
 
    "height",
289
 
    "The pattern height"
290
 
  },
291
 
  {
292
 
    GIMP_PDB_INT32,
293
 
    "mask_bpp",
294
 
    "Pattern bytes per pixel"
295
 
  },
296
 
  {
297
 
    GIMP_PDB_INT32,
298
 
    "length",
299
 
    "Length of pattern mask data"
300
 
  },
301
 
  {
302
 
    GIMP_PDB_INT8ARRAY,
303
 
    "mask_data",
304
 
    "The pattern mask data"
305
 
  }
306
 
};
307
 
 
308
 
static ProcRecord patterns_get_pattern_data_proc =
309
 
{
310
 
  "gimp_patterns_get_pattern_data",
311
 
  "This procedure is deprecated! Use 'gimp_pattern_get_pixels' instead.",
312
 
  "This procedure is deprecated! Use 'gimp_pattern_get_pixels' instead.",
313
 
  "",
314
 
  "",
315
 
  "",
316
 
  "gimp_pattern_get_pixels",
317
 
  GIMP_INTERNAL,
318
 
  1,
319
 
  patterns_get_pattern_data_inargs,
320
 
  6,
321
 
  patterns_get_pattern_data_outargs,
322
 
  { { patterns_get_pattern_data_invoker } }
323
 
};
 
182
  return return_vals;
 
183
}
 
184
 
 
185
void
 
186
register_patterns_procs (GimpPDB *pdb)
 
187
{
 
188
  GimpProcedure *procedure;
 
189
 
 
190
  /*
 
191
   * gimp-patterns-refresh
 
192
   */
 
193
  procedure = gimp_procedure_new (patterns_refresh_invoker);
 
194
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-patterns-refresh");
 
195
  gimp_procedure_set_static_strings (procedure,
 
196
                                     "gimp-patterns-refresh",
 
197
                                     "Refresh current patterns. This function always succeeds.",
 
198
                                     "This procedure retrieves all patterns currently in the user's pattern path and updates all pattern dialogs accordingly.",
 
199
                                     "Michael Natterer <mitch@gimp.org>",
 
200
                                     "Michael Natterer",
 
201
                                     "2002",
 
202
                                     NULL);
 
203
  gimp_pdb_register_procedure (pdb, procedure);
 
204
  g_object_unref (procedure);
 
205
 
 
206
  /*
 
207
   * gimp-patterns-get-list
 
208
   */
 
209
  procedure = gimp_procedure_new (patterns_get_list_invoker);
 
210
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-patterns-get-list");
 
211
  gimp_procedure_set_static_strings (procedure,
 
212
                                     "gimp-patterns-get-list",
 
213
                                     "Retrieve a complete listing of the available patterns.",
 
214
                                     "This procedure returns a complete listing of available GIMP patterns. Each name returned can be used as input to the 'gimp-context-set-pattern'.",
 
215
                                     "Spencer Kimball & Peter Mattis",
 
216
                                     "Spencer Kimball & Peter Mattis",
 
217
                                     "1995-1996",
 
218
                                     NULL);
 
219
  gimp_procedure_add_argument (procedure,
 
220
                               gimp_param_spec_string ("filter",
 
221
                                                       "filter",
 
222
                                                       "An optional regular expression used to filter the list",
 
223
                                                       FALSE, TRUE,
 
224
                                                       NULL,
 
225
                                                       GIMP_PARAM_READWRITE));
 
226
  gimp_procedure_add_return_value (procedure,
 
227
                                   gimp_param_spec_int32 ("num-patterns",
 
228
                                                          "num patterns",
 
229
                                                          "The number of patterns in the pattern list",
 
230
                                                          0, G_MAXINT32, 0,
 
231
                                                          GIMP_PARAM_READWRITE));
 
232
  gimp_procedure_add_return_value (procedure,
 
233
                                   gimp_param_spec_string_array ("pattern-list",
 
234
                                                                 "pattern list",
 
235
                                                                 "The list of pattern names",
 
236
                                                                 GIMP_PARAM_READWRITE));
 
237
  gimp_pdb_register_procedure (pdb, procedure);
 
238
  g_object_unref (procedure);
 
239
 
 
240
  /*
 
241
   * gimp-patterns-get-pattern
 
242
   */
 
243
  procedure = gimp_procedure_new (patterns_get_pattern_invoker);
 
244
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-patterns-get-pattern");
 
245
  gimp_procedure_set_static_strings (procedure,
 
246
                                     "gimp-patterns-get-pattern",
 
247
                                     "This procedure is deprecated! Use 'gimp-context-get-pattern' instead.",
 
248
                                     "This procedure is deprecated! Use 'gimp-context-get-pattern' instead.",
 
249
                                     "",
 
250
                                     "",
 
251
                                     "",
 
252
                                     "gimp-context-get-pattern");
 
253
  gimp_procedure_add_return_value (procedure,
 
254
                                   gimp_param_spec_string ("name",
 
255
                                                           "name",
 
256
                                                           "The pattern name",
 
257
                                                           FALSE, FALSE,
 
258
                                                           NULL,
 
259
                                                           GIMP_PARAM_READWRITE));
 
260
  gimp_procedure_add_return_value (procedure,
 
261
                                   gimp_param_spec_int32 ("width",
 
262
                                                          "width",
 
263
                                                          "The pattern width",
 
264
                                                          G_MININT32, G_MAXINT32, 0,
 
265
                                                          GIMP_PARAM_READWRITE));
 
266
  gimp_procedure_add_return_value (procedure,
 
267
                                   gimp_param_spec_int32 ("height",
 
268
                                                          "height",
 
269
                                                          "The pattern height",
 
270
                                                          G_MININT32, G_MAXINT32, 0,
 
271
                                                          GIMP_PARAM_READWRITE));
 
272
  gimp_pdb_register_procedure (pdb, procedure);
 
273
  g_object_unref (procedure);
 
274
 
 
275
  /*
 
276
   * gimp-patterns-get-pattern-data
 
277
   */
 
278
  procedure = gimp_procedure_new (patterns_get_pattern_data_invoker);
 
279
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-patterns-get-pattern-data");
 
280
  gimp_procedure_set_static_strings (procedure,
 
281
                                     "gimp-patterns-get-pattern-data",
 
282
                                     "This procedure is deprecated! Use 'gimp-pattern-get-pixels' instead.",
 
283
                                     "This procedure is deprecated! Use 'gimp-pattern-get-pixels' instead.",
 
284
                                     "",
 
285
                                     "",
 
286
                                     "",
 
287
                                     "gimp-pattern-get-pixels");
 
288
  gimp_procedure_add_argument (procedure,
 
289
                               gimp_param_spec_string ("name",
 
290
                                                       "name",
 
291
                                                       "The pattern name (\"\" means currently active pattern)",
 
292
                                                       FALSE, TRUE,
 
293
                                                       NULL,
 
294
                                                       GIMP_PARAM_READWRITE));
 
295
  gimp_procedure_add_return_value (procedure,
 
296
                                   gimp_param_spec_string ("actual-name",
 
297
                                                           "actual name",
 
298
                                                           "The pattern name",
 
299
                                                           FALSE, FALSE,
 
300
                                                           NULL,
 
301
                                                           GIMP_PARAM_READWRITE));
 
302
  gimp_procedure_add_return_value (procedure,
 
303
                                   gimp_param_spec_int32 ("width",
 
304
                                                          "width",
 
305
                                                          "The pattern width",
 
306
                                                          G_MININT32, G_MAXINT32, 0,
 
307
                                                          GIMP_PARAM_READWRITE));
 
308
  gimp_procedure_add_return_value (procedure,
 
309
                                   gimp_param_spec_int32 ("height",
 
310
                                                          "height",
 
311
                                                          "The pattern height",
 
312
                                                          G_MININT32, G_MAXINT32, 0,
 
313
                                                          GIMP_PARAM_READWRITE));
 
314
  gimp_procedure_add_return_value (procedure,
 
315
                                   gimp_param_spec_int32 ("mask-bpp",
 
316
                                                          "mask bpp",
 
317
                                                          "Pattern bytes per pixel",
 
318
                                                          G_MININT32, G_MAXINT32, 0,
 
319
                                                          GIMP_PARAM_READWRITE));
 
320
  gimp_procedure_add_return_value (procedure,
 
321
                                   gimp_param_spec_int32 ("length",
 
322
                                                          "length",
 
323
                                                          "Length of pattern mask data",
 
324
                                                          0, G_MAXINT32, 0,
 
325
                                                          GIMP_PARAM_READWRITE));
 
326
  gimp_procedure_add_return_value (procedure,
 
327
                                   gimp_param_spec_int8_array ("mask-data",
 
328
                                                               "mask data",
 
329
                                                               "The pattern mask data",
 
330
                                                               GIMP_PARAM_READWRITE));
 
331
  gimp_pdb_register_procedure (pdb, procedure);
 
332
  g_object_unref (procedure);
 
333
}