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

« back to all changes in this revision

Viewing changes to app/pdb/pattern_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"
34
36
#include "core/gimplist.h"
35
37
#include "core/gimppattern.h"
36
38
 
37
 
static ProcRecord pattern_get_info_proc;
38
 
static ProcRecord pattern_get_pixels_proc;
39
 
 
40
 
void
41
 
register_pattern_procs (Gimp *gimp)
42
 
{
43
 
  procedural_db_register (gimp, &pattern_get_info_proc);
44
 
  procedural_db_register (gimp, &pattern_get_pixels_proc);
45
 
}
46
 
 
47
 
static Argument *
48
 
pattern_get_info_invoker (Gimp         *gimp,
49
 
                          GimpContext  *context,
50
 
                          GimpProgress *progress,
51
 
                          Argument     *args)
 
39
#include "internal_procs.h"
 
40
 
 
41
 
 
42
static GValueArray *
 
43
pattern_get_info_invoker (GimpProcedure     *procedure,
 
44
                          Gimp              *gimp,
 
45
                          GimpContext       *context,
 
46
                          GimpProgress      *progress,
 
47
                          const GValueArray *args)
52
48
{
53
49
  gboolean success = TRUE;
54
 
  Argument *return_args;
55
 
  gchar *name;
56
 
  GimpPattern *pattern = NULL;
 
50
  GValueArray *return_vals;
 
51
  const gchar *name;
 
52
  gint32 width = 0;
 
53
  gint32 height = 0;
 
54
  gint32 bpp = 0;
57
55
 
58
 
  name = (gchar *) args[0].value.pdb_pointer;
59
 
  if (name == NULL || !g_utf8_validate (name, -1, NULL))
60
 
    success = FALSE;
 
56
  name = g_value_get_string (&args->values[0]);
61
57
 
62
58
  if (success)
63
59
    {
64
 
      pattern = (GimpPattern *)
 
60
      GimpPattern *pattern = (GimpPattern *)
65
61
        gimp_container_get_child_by_name (gimp->pattern_factory->container, name);
66
62
 
67
 
      success = (pattern != NULL);
 
63
      if (pattern)
 
64
        {
 
65
          width  = pattern->mask->width;
 
66
          height = pattern->mask->height;
 
67
          bpp    = pattern->mask->bytes;
 
68
        }
 
69
      else
 
70
        success = FALSE;
68
71
    }
69
72
 
70
 
  return_args = procedural_db_return_args (&pattern_get_info_proc, success);
 
73
  return_vals = gimp_procedure_get_return_values (procedure, success);
71
74
 
72
75
  if (success)
73
76
    {
74
 
      return_args[1].value.pdb_int = pattern->mask->width;
75
 
      return_args[2].value.pdb_int = pattern->mask->height;
76
 
      return_args[3].value.pdb_int = pattern->mask->bytes;
 
77
      g_value_set_int (&return_vals->values[1], width);
 
78
      g_value_set_int (&return_vals->values[2], height);
 
79
      g_value_set_int (&return_vals->values[3], bpp);
77
80
    }
78
81
 
79
 
  return return_args;
 
82
  return return_vals;
80
83
}
81
84
 
82
 
static ProcArg pattern_get_info_inargs[] =
83
 
{
84
 
  {
85
 
    GIMP_PDB_STRING,
86
 
    "name",
87
 
    "The pattern name."
88
 
  }
89
 
};
90
 
 
91
 
static ProcArg pattern_get_info_outargs[] =
92
 
{
93
 
  {
94
 
    GIMP_PDB_INT32,
95
 
    "width",
96
 
    "The pattern width"
97
 
  },
98
 
  {
99
 
    GIMP_PDB_INT32,
100
 
    "height",
101
 
    "The pattern height"
102
 
  },
103
 
  {
104
 
    GIMP_PDB_INT32,
105
 
    "bpp",
106
 
    "The pattern bpp"
107
 
  }
108
 
};
109
 
 
110
 
static ProcRecord pattern_get_info_proc =
111
 
{
112
 
  "gimp_pattern_get_info",
113
 
  "Retrieve information about the specified pattern.",
114
 
  "This procedure retrieves information about the specified pattern. This includes the pattern extents (width and height).",
115
 
  "Michael Natterer <mitch@gimp.org>",
116
 
  "Michael Natterer",
117
 
  "2004",
118
 
  NULL,
119
 
  GIMP_INTERNAL,
120
 
  1,
121
 
  pattern_get_info_inargs,
122
 
  3,
123
 
  pattern_get_info_outargs,
124
 
  { { pattern_get_info_invoker } }
125
 
};
126
 
 
127
 
static Argument *
128
 
pattern_get_pixels_invoker (Gimp         *gimp,
129
 
                            GimpContext  *context,
130
 
                            GimpProgress *progress,
131
 
                            Argument     *args)
 
85
static GValueArray *
 
86
pattern_get_pixels_invoker (GimpProcedure     *procedure,
 
87
                            Gimp              *gimp,
 
88
                            GimpContext       *context,
 
89
                            GimpProgress      *progress,
 
90
                            const GValueArray *args)
132
91
{
133
92
  gboolean success = TRUE;
134
 
  Argument *return_args;
135
 
  gchar *name;
 
93
  GValueArray *return_vals;
 
94
  const gchar *name;
 
95
  gint32 width = 0;
 
96
  gint32 height = 0;
 
97
  gint32 bpp = 0;
136
98
  gint32 num_color_bytes = 0;
137
99
  guint8 *color_bytes = NULL;
138
 
  GimpPattern *pattern = NULL;
139
100
 
140
 
  name = (gchar *) args[0].value.pdb_pointer;
141
 
  if (name == NULL || !g_utf8_validate (name, -1, NULL))
142
 
    success = FALSE;
 
101
  name = g_value_get_string (&args->values[0]);
143
102
 
144
103
  if (success)
145
104
    {
146
 
      pattern = (GimpPattern *)
 
105
      GimpPattern *pattern = (GimpPattern *)
147
106
        gimp_container_get_child_by_name (gimp->pattern_factory->container, name);
148
107
 
149
108
      if (pattern)
150
109
        {
 
110
          width           = pattern->mask->width;
 
111
          height          = pattern->mask->height;
 
112
          bpp             = pattern->mask->bytes;
151
113
          num_color_bytes = pattern->mask->height * pattern->mask->width *
152
114
                            pattern->mask->bytes;
153
115
          color_bytes     = g_memdup (temp_buf_data (pattern->mask),
157
119
        success = FALSE;
158
120
    }
159
121
 
160
 
  return_args = procedural_db_return_args (&pattern_get_pixels_proc, success);
 
122
  return_vals = gimp_procedure_get_return_values (procedure, success);
161
123
 
162
124
  if (success)
163
125
    {
164
 
      return_args[1].value.pdb_int = pattern->mask->width;
165
 
      return_args[2].value.pdb_int = pattern->mask->height;
166
 
      return_args[3].value.pdb_int = pattern->mask->bytes;
167
 
      return_args[4].value.pdb_int = num_color_bytes;
168
 
      return_args[5].value.pdb_pointer = color_bytes;
 
126
      g_value_set_int (&return_vals->values[1], width);
 
127
      g_value_set_int (&return_vals->values[2], height);
 
128
      g_value_set_int (&return_vals->values[3], bpp);
 
129
      g_value_set_int (&return_vals->values[4], num_color_bytes);
 
130
      gimp_value_take_int8array (&return_vals->values[5], color_bytes, num_color_bytes);
169
131
    }
170
132
 
171
 
  return return_args;
172
 
}
173
 
 
174
 
static ProcArg pattern_get_pixels_inargs[] =
175
 
{
176
 
  {
177
 
    GIMP_PDB_STRING,
178
 
    "name",
179
 
    "The pattern name."
180
 
  }
181
 
};
182
 
 
183
 
static ProcArg pattern_get_pixels_outargs[] =
184
 
{
185
 
  {
186
 
    GIMP_PDB_INT32,
187
 
    "width",
188
 
    "The pattern width"
189
 
  },
190
 
  {
191
 
    GIMP_PDB_INT32,
192
 
    "height",
193
 
    "The pattern height"
194
 
  },
195
 
  {
196
 
    GIMP_PDB_INT32,
197
 
    "bpp",
198
 
    "The pattern bpp"
199
 
  },
200
 
  {
201
 
    GIMP_PDB_INT32,
202
 
    "num_color_bytes",
203
 
    "Number of pattern bytes"
204
 
  },
205
 
  {
206
 
    GIMP_PDB_INT8ARRAY,
207
 
    "color_bytes",
208
 
    "The pattern data."
209
 
  }
210
 
};
211
 
 
212
 
static ProcRecord pattern_get_pixels_proc =
213
 
{
214
 
  "gimp_pattern_get_pixels",
215
 
  "Retrieve information about the specified pattern (including pixels).",
216
 
  "This procedure retrieves information about the specified. This includes the pattern extents (width and height), its bpp and its pixel data.",
217
 
  "Michael Natterer <mitch@gimp.org>",
218
 
  "Michael Natterer",
219
 
  "2004",
220
 
  NULL,
221
 
  GIMP_INTERNAL,
222
 
  1,
223
 
  pattern_get_pixels_inargs,
224
 
  5,
225
 
  pattern_get_pixels_outargs,
226
 
  { { pattern_get_pixels_invoker } }
227
 
};
 
133
  return return_vals;
 
134
}
 
135
 
 
136
void
 
137
register_pattern_procs (GimpPDB *pdb)
 
138
{
 
139
  GimpProcedure *procedure;
 
140
 
 
141
  /*
 
142
   * gimp-pattern-get-info
 
143
   */
 
144
  procedure = gimp_procedure_new (pattern_get_info_invoker);
 
145
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-pattern-get-info");
 
146
  gimp_procedure_set_static_strings (procedure,
 
147
                                     "gimp-pattern-get-info",
 
148
                                     "Retrieve information about the specified pattern.",
 
149
                                     "This procedure retrieves information about the specified pattern. This includes the pattern extents (width and height).",
 
150
                                     "Michael Natterer <mitch@gimp.org>",
 
151
                                     "Michael Natterer",
 
152
                                     "2004",
 
153
                                     NULL);
 
154
  gimp_procedure_add_argument (procedure,
 
155
                               gimp_param_spec_string ("name",
 
156
                                                       "name",
 
157
                                                       "The pattern name.",
 
158
                                                       FALSE, FALSE,
 
159
                                                       NULL,
 
160
                                                       GIMP_PARAM_READWRITE));
 
161
  gimp_procedure_add_return_value (procedure,
 
162
                                   gimp_param_spec_int32 ("width",
 
163
                                                          "width",
 
164
                                                          "The pattern width",
 
165
                                                          G_MININT32, G_MAXINT32, 0,
 
166
                                                          GIMP_PARAM_READWRITE));
 
167
  gimp_procedure_add_return_value (procedure,
 
168
                                   gimp_param_spec_int32 ("height",
 
169
                                                          "height",
 
170
                                                          "The pattern height",
 
171
                                                          G_MININT32, G_MAXINT32, 0,
 
172
                                                          GIMP_PARAM_READWRITE));
 
173
  gimp_procedure_add_return_value (procedure,
 
174
                                   gimp_param_spec_int32 ("bpp",
 
175
                                                          "bpp",
 
176
                                                          "The pattern bpp",
 
177
                                                          G_MININT32, G_MAXINT32, 0,
 
178
                                                          GIMP_PARAM_READWRITE));
 
179
  gimp_pdb_register_procedure (pdb, procedure);
 
180
  g_object_unref (procedure);
 
181
 
 
182
  /*
 
183
   * gimp-pattern-get-pixels
 
184
   */
 
185
  procedure = gimp_procedure_new (pattern_get_pixels_invoker);
 
186
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-pattern-get-pixels");
 
187
  gimp_procedure_set_static_strings (procedure,
 
188
                                     "gimp-pattern-get-pixels",
 
189
                                     "Retrieve information about the specified pattern (including pixels).",
 
190
                                     "This procedure retrieves information about the specified. This includes the pattern extents (width and height), its bpp and its pixel data.",
 
191
                                     "Michael Natterer <mitch@gimp.org>",
 
192
                                     "Michael Natterer",
 
193
                                     "2004",
 
194
                                     NULL);
 
195
  gimp_procedure_add_argument (procedure,
 
196
                               gimp_param_spec_string ("name",
 
197
                                                       "name",
 
198
                                                       "The pattern name.",
 
199
                                                       FALSE, FALSE,
 
200
                                                       NULL,
 
201
                                                       GIMP_PARAM_READWRITE));
 
202
  gimp_procedure_add_return_value (procedure,
 
203
                                   gimp_param_spec_int32 ("width",
 
204
                                                          "width",
 
205
                                                          "The pattern width",
 
206
                                                          G_MININT32, G_MAXINT32, 0,
 
207
                                                          GIMP_PARAM_READWRITE));
 
208
  gimp_procedure_add_return_value (procedure,
 
209
                                   gimp_param_spec_int32 ("height",
 
210
                                                          "height",
 
211
                                                          "The pattern height",
 
212
                                                          G_MININT32, G_MAXINT32, 0,
 
213
                                                          GIMP_PARAM_READWRITE));
 
214
  gimp_procedure_add_return_value (procedure,
 
215
                                   gimp_param_spec_int32 ("bpp",
 
216
                                                          "bpp",
 
217
                                                          "The pattern bpp",
 
218
                                                          G_MININT32, G_MAXINT32, 0,
 
219
                                                          GIMP_PARAM_READWRITE));
 
220
  gimp_procedure_add_return_value (procedure,
 
221
                                   gimp_param_spec_int32 ("num-color-bytes",
 
222
                                                          "num color bytes",
 
223
                                                          "Number of pattern bytes",
 
224
                                                          0, G_MAXINT32, 0,
 
225
                                                          GIMP_PARAM_READWRITE));
 
226
  gimp_procedure_add_return_value (procedure,
 
227
                                   gimp_param_spec_int8_array ("color-bytes",
 
228
                                                               "color bytes",
 
229
                                                               "The pattern data.",
 
230
                                                               GIMP_PARAM_READWRITE));
 
231
  gimp_pdb_register_procedure (pdb, procedure);
 
232
  g_object_unref (procedure);
 
233
}