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

« back to all changes in this revision

Viewing changes to app/pdb/palettes_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
 
27
27
#include "libgimpcolor/gimpcolor.h"
28
28
 
29
29
#include "pdb-types.h"
30
 
#include "procedural_db.h"
 
30
#include "gimppdb.h"
 
31
#include "gimpprocedure.h"
 
32
#include "core/gimpparamspecs.h"
31
33
 
32
34
#include "core/gimp.h"
33
35
#include "core/gimpcontainer-filter.h"
36
38
#include "core/gimplist.h"
37
39
#include "core/gimppalette.h"
38
40
 
39
 
static ProcRecord palettes_refresh_proc;
40
 
static ProcRecord palettes_get_list_proc;
41
 
static ProcRecord palettes_get_palette_proc;
42
 
static ProcRecord palettes_get_palette_entry_proc;
43
 
 
44
 
void
45
 
register_palettes_procs (Gimp *gimp)
46
 
{
47
 
  procedural_db_register (gimp, &palettes_refresh_proc);
48
 
  procedural_db_register (gimp, &palettes_get_list_proc);
49
 
  procedural_db_register (gimp, &palettes_get_palette_proc);
50
 
  procedural_db_register (gimp, &palettes_get_palette_entry_proc);
51
 
}
52
 
 
53
 
static Argument *
54
 
palettes_refresh_invoker (Gimp         *gimp,
55
 
                          GimpContext  *context,
56
 
                          GimpProgress *progress,
57
 
                          Argument     *args)
58
 
{
59
 
  gimp_data_factory_data_save (gimp->palette_factory);
60
 
  gimp_data_factory_data_init (gimp->palette_factory, FALSE);
61
 
  return procedural_db_return_args (&palettes_refresh_proc, TRUE);
62
 
}
63
 
 
64
 
static ProcRecord palettes_refresh_proc =
65
 
{
66
 
  "gimp_palettes_refresh",
67
 
  "Refreshes current palettes. This function always succeeds.",
68
 
  "This procedure retrieves all palettes currently in the user's palette path and updates the palette dialogs accordingly.",
69
 
  "Adrian Likins <adrian@gimp.org>",
70
 
  "Adrian Likins",
71
 
  "1998",
72
 
  NULL,
73
 
  GIMP_INTERNAL,
74
 
  0,
75
 
  NULL,
76
 
  0,
77
 
  NULL,
78
 
  { { palettes_refresh_invoker } }
79
 
};
80
 
 
81
 
static Argument *
82
 
palettes_get_list_invoker (Gimp         *gimp,
83
 
                           GimpContext  *context,
84
 
                           GimpProgress *progress,
85
 
                           Argument     *args)
 
41
#include "internal_procs.h"
 
42
 
 
43
 
 
44
static GValueArray *
 
45
palettes_refresh_invoker (GimpProcedure     *procedure,
 
46
                          Gimp              *gimp,
 
47
                          GimpContext       *context,
 
48
                          GimpProgress      *progress,
 
49
                          const GValueArray *args)
 
50
{
 
51
  gimp_data_factory_data_refresh (gimp->palette_factory);
 
52
  return gimp_procedure_get_return_values (procedure, TRUE);
 
53
}
 
54
 
 
55
static GValueArray *
 
56
palettes_get_list_invoker (GimpProcedure     *procedure,
 
57
                           Gimp              *gimp,
 
58
                           GimpContext       *context,
 
59
                           GimpProgress      *progress,
 
60
                           const GValueArray *args)
86
61
{
87
62
  gboolean success = TRUE;
88
 
  Argument *return_args;
89
 
  gchar *filter;
90
 
  gint32 num_palettes;
 
63
  GValueArray *return_vals;
 
64
  const gchar *filter;
 
65
  gint32 num_palettes = 0;
91
66
  gchar **palette_list = NULL;
92
67
 
93
 
  filter = (gchar *) args[0].value.pdb_pointer;
94
 
  if (filter && !g_utf8_validate (filter, -1, NULL))
 
68
  filter = g_value_get_string (&args->values[0]);
 
69
 
 
70
  if (success)
 
71
    {
 
72
      palette_list = gimp_container_get_filtered_name_array (gimp->palette_factory->container,
 
73
                                                             filter, &num_palettes);
 
74
    }
 
75
 
 
76
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
77
 
 
78
  if (success)
 
79
    {
 
80
      g_value_set_int (&return_vals->values[1], num_palettes);
 
81
      gimp_value_take_stringarray (&return_vals->values[2], palette_list, num_palettes);
 
82
    }
 
83
 
 
84
  return return_vals;
 
85
}
 
86
 
 
87
static GValueArray *
 
88
palettes_get_palette_invoker (GimpProcedure     *procedure,
 
89
                              Gimp              *gimp,
 
90
                              GimpContext       *context,
 
91
                              GimpProgress      *progress,
 
92
                              const GValueArray *args)
 
93
{
 
94
  gboolean success = TRUE;
 
95
  GValueArray *return_vals;
 
96
  gchar *name = NULL;
 
97
  gint32 num_colors = 0;
 
98
 
 
99
  GimpPalette *palette = gimp_context_get_palette (context);
 
100
 
 
101
  if (palette)
 
102
    {
 
103
      name       = g_strdup (gimp_object_get_name (GIMP_OBJECT (palette)));
 
104
      num_colors = palette->n_colors;
 
105
    }
 
106
  else
95
107
    success = FALSE;
96
108
 
97
 
  if (success)
98
 
    palette_list = gimp_container_get_filtered_name_array (gimp->palette_factory->container, filter, &num_palettes);
99
 
 
100
 
  return_args = procedural_db_return_args (&palettes_get_list_proc, success);
101
 
 
102
 
  if (success)
103
 
    {
104
 
      return_args[1].value.pdb_int = num_palettes;
105
 
      return_args[2].value.pdb_pointer = palette_list;
106
 
    }
107
 
 
108
 
  return return_args;
109
 
}
110
 
 
111
 
static ProcArg palettes_get_list_inargs[] =
112
 
{
113
 
  {
114
 
    GIMP_PDB_STRING,
115
 
    "filter",
116
 
    "An optional regular expression used to filter the list"
117
 
  }
118
 
};
119
 
 
120
 
static ProcArg palettes_get_list_outargs[] =
121
 
{
122
 
  {
123
 
    GIMP_PDB_INT32,
124
 
    "num_palettes",
125
 
    "The number of palettes in the list"
126
 
  },
127
 
  {
128
 
    GIMP_PDB_STRINGARRAY,
129
 
    "palette_list",
130
 
    "The list of palette names"
131
 
  }
132
 
};
133
 
 
134
 
static ProcRecord palettes_get_list_proc =
135
 
{
136
 
  "gimp_palettes_get_list",
137
 
  "Retrieves a list of all of the available palettes",
138
 
  "This procedure returns a complete listing of available palettes. Each name returned can be used as input to the command 'gimp_context_set_palette'.",
139
 
  "Nathan Summers <rock@gimp.org>",
140
 
  "Nathan Summers",
141
 
  "2001",
142
 
  NULL,
143
 
  GIMP_INTERNAL,
144
 
  1,
145
 
  palettes_get_list_inargs,
146
 
  2,
147
 
  palettes_get_list_outargs,
148
 
  { { palettes_get_list_invoker } }
149
 
};
150
 
 
151
 
static Argument *
152
 
palettes_get_palette_invoker (Gimp         *gimp,
153
 
                              GimpContext  *context,
154
 
                              GimpProgress *progress,
155
 
                              Argument     *args)
156
 
{
157
 
  gboolean success = TRUE;
158
 
  Argument *return_args;
159
 
  GimpPalette *palette;
160
 
 
161
 
  success = (palette = gimp_context_get_palette (context)) != NULL;
162
 
 
163
 
  return_args = procedural_db_return_args (&palettes_get_palette_proc, success);
164
 
 
165
 
  if (success)
166
 
    {
167
 
      return_args[1].value.pdb_pointer = g_strdup (GIMP_OBJECT (palette)->name);
168
 
      return_args[2].value.pdb_int = palette->n_colors;
169
 
    }
170
 
 
171
 
  return return_args;
172
 
}
173
 
 
174
 
static ProcArg palettes_get_palette_outargs[] =
175
 
{
176
 
  {
177
 
    GIMP_PDB_STRING,
178
 
    "name",
179
 
    "The palette name"
180
 
  },
181
 
  {
182
 
    GIMP_PDB_INT32,
183
 
    "num_colors",
184
 
    "The palette num_colors"
185
 
  }
186
 
};
187
 
 
188
 
static ProcRecord palettes_get_palette_proc =
189
 
{
190
 
  "gimp_palettes_get_palette",
191
 
  "This procedure is deprecated! Use 'gimp_context_get_palette' instead.",
192
 
  "This procedure is deprecated! Use 'gimp_context_get_palette' instead.",
193
 
  "",
194
 
  "",
195
 
  "",
196
 
  "gimp_context_get_palette",
197
 
  GIMP_INTERNAL,
198
 
  0,
199
 
  NULL,
200
 
  2,
201
 
  palettes_get_palette_outargs,
202
 
  { { palettes_get_palette_invoker } }
203
 
};
204
 
 
205
 
static Argument *
206
 
palettes_get_palette_entry_invoker (Gimp         *gimp,
207
 
                                    GimpContext  *context,
208
 
                                    GimpProgress *progress,
209
 
                                    Argument     *args)
210
 
{
211
 
  gboolean success = TRUE;
212
 
  Argument *return_args;
213
 
  gchar *name;
 
109
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
110
 
 
111
  if (success)
 
112
    {
 
113
      g_value_take_string (&return_vals->values[1], name);
 
114
      g_value_set_int (&return_vals->values[2], num_colors);
 
115
    }
 
116
 
 
117
  return return_vals;
 
118
}
 
119
 
 
120
static GValueArray *
 
121
palettes_get_palette_entry_invoker (GimpProcedure     *procedure,
 
122
                                    Gimp              *gimp,
 
123
                                    GimpContext       *context,
 
124
                                    GimpProgress      *progress,
 
125
                                    const GValueArray *args)
 
126
{
 
127
  gboolean success = TRUE;
 
128
  GValueArray *return_vals;
 
129
  const gchar *name;
214
130
  gint32 entry_num;
215
 
  GimpRGB color;
216
 
  GimpPalette *palette = NULL;
217
 
 
218
 
  name = (gchar *) args[0].value.pdb_pointer;
219
 
  if (name && !g_utf8_validate (name, -1, NULL))
220
 
    success = FALSE;
221
 
 
222
 
  entry_num = args[1].value.pdb_int;
 
131
  gchar *actual_name = NULL;
 
132
  gint32 num_colors = 0;
 
133
  GimpRGB color = { 0.0, 0.0, 0.0, 1.0 };
 
134
 
 
135
  name = g_value_get_string (&args->values[0]);
 
136
  entry_num = g_value_get_int (&args->values[1]);
223
137
 
224
138
  if (success)
225
139
    {
 
140
      GimpPalette *palette;
 
141
 
226
142
      if (name && strlen (name))
227
 
      {
228
 
        palette = (GimpPalette *)
229
 
          gimp_container_get_child_by_name (gimp->palette_factory->container,
230
 
                                            name);
231
 
      }
232
 
    else
233
 
      {
234
 
        palette = gimp_context_get_palette (context);
235
 
      }
 
143
        {
 
144
          palette = (GimpPalette *)
 
145
            gimp_container_get_child_by_name (gimp->palette_factory->container,
 
146
                                              name);
 
147
        }
 
148
      else
 
149
        {
 
150
          palette = gimp_context_get_palette (context);
 
151
        }
236
152
 
237
153
      if (palette)
238
154
        {
239
 
          if (entry_num < 0 || entry_num >= palette->n_colors) 
 
155
          if (entry_num >= 0 && entry_num < palette->n_colors)
240
156
            {
241
 
              success = FALSE;
 
157
              GimpPaletteEntry *entry = g_list_nth_data (palette->colors, entry_num);
 
158
 
 
159
              actual_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (palette)));
 
160
              num_colors  = palette->n_colors;
 
161
              color       = entry->color;
242
162
            }
243
163
          else
244
 
            {
245
 
              GimpPaletteEntry *entry;
246
 
 
247
 
              entry = (GimpPaletteEntry *)
248
 
                g_list_nth_data (palette->colors, entry_num);
249
 
 
250
 
              color = entry->color;
251
 
            }
 
164
            success = FALSE;
252
165
        }
253
166
      else
254
167
        success = FALSE;
255
168
    }
256
169
 
257
 
  return_args = procedural_db_return_args (&palettes_get_palette_entry_proc, success);
 
170
  return_vals = gimp_procedure_get_return_values (procedure, success);
258
171
 
259
172
  if (success)
260
173
    {
261
 
      return_args[1].value.pdb_pointer = g_strdup (GIMP_OBJECT (palette)->name);
262
 
      return_args[2].value.pdb_int = palette->n_colors;
263
 
      return_args[3].value.pdb_color = color;
 
174
      g_value_take_string (&return_vals->values[1], actual_name);
 
175
      g_value_set_int (&return_vals->values[2], num_colors);
 
176
      gimp_value_set_rgb (&return_vals->values[3], &color);
264
177
    }
265
178
 
266
 
  return return_args;
267
 
}
268
 
 
269
 
static ProcArg palettes_get_palette_entry_inargs[] =
270
 
{
271
 
  {
272
 
    GIMP_PDB_STRING,
273
 
    "name",
274
 
    "The palette name (\"\" means currently active palette)"
275
 
  },
276
 
  {
277
 
    GIMP_PDB_INT32,
278
 
    "entry_num",
279
 
    "The entry to retrieve"
280
 
  }
281
 
};
282
 
 
283
 
static ProcArg palettes_get_palette_entry_outargs[] =
284
 
{
285
 
  {
286
 
    GIMP_PDB_STRING,
287
 
    "name",
288
 
    "The palette name"
289
 
  },
290
 
  {
291
 
    GIMP_PDB_INT32,
292
 
    "num_colors",
293
 
    "The palette num_colors"
294
 
  },
295
 
  {
296
 
    GIMP_PDB_COLOR,
297
 
    "color",
298
 
    "The color requested"
299
 
  }
300
 
};
301
 
 
302
 
static ProcRecord palettes_get_palette_entry_proc =
303
 
{
304
 
  "gimp_palettes_get_palette_entry",
305
 
  "This procedure is deprecated! Use 'gimp_palette_entry_get_color' instead.",
306
 
  "This procedure is deprecated! Use 'gimp_palette_entry_get_color' instead.",
307
 
  "",
308
 
  "",
309
 
  "",
310
 
  "gimp_palette_entry_get_color",
311
 
  GIMP_INTERNAL,
312
 
  2,
313
 
  palettes_get_palette_entry_inargs,
314
 
  3,
315
 
  palettes_get_palette_entry_outargs,
316
 
  { { palettes_get_palette_entry_invoker } }
317
 
};
 
179
  return return_vals;
 
180
}
 
181
 
 
182
void
 
183
register_palettes_procs (GimpPDB *pdb)
 
184
{
 
185
  GimpProcedure *procedure;
 
186
 
 
187
  /*
 
188
   * gimp-palettes-refresh
 
189
   */
 
190
  procedure = gimp_procedure_new (palettes_refresh_invoker);
 
191
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-palettes-refresh");
 
192
  gimp_procedure_set_static_strings (procedure,
 
193
                                     "gimp-palettes-refresh",
 
194
                                     "Refreshes current palettes. This function always succeeds.",
 
195
                                     "This procedure retrieves all palettes currently in the user's palette path and updates the palette dialogs accordingly.",
 
196
                                     "Adrian Likins <adrian@gimp.org>",
 
197
                                     "Adrian Likins",
 
198
                                     "1998",
 
199
                                     NULL);
 
200
  gimp_pdb_register_procedure (pdb, procedure);
 
201
  g_object_unref (procedure);
 
202
 
 
203
  /*
 
204
   * gimp-palettes-get-list
 
205
   */
 
206
  procedure = gimp_procedure_new (palettes_get_list_invoker);
 
207
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-palettes-get-list");
 
208
  gimp_procedure_set_static_strings (procedure,
 
209
                                     "gimp-palettes-get-list",
 
210
                                     "Retrieves a list of all of the available palettes",
 
211
                                     "This procedure returns a complete listing of available palettes. Each name returned can be used as input to the command 'gimp-context-set-palette'.",
 
212
                                     "Nathan Summers <rock@gimp.org>",
 
213
                                     "Nathan Summers",
 
214
                                     "2001",
 
215
                                     NULL);
 
216
  gimp_procedure_add_argument (procedure,
 
217
                               gimp_param_spec_string ("filter",
 
218
                                                       "filter",
 
219
                                                       "An optional regular expression used to filter the list",
 
220
                                                       FALSE, TRUE,
 
221
                                                       NULL,
 
222
                                                       GIMP_PARAM_READWRITE));
 
223
  gimp_procedure_add_return_value (procedure,
 
224
                                   gimp_param_spec_int32 ("num-palettes",
 
225
                                                          "num palettes",
 
226
                                                          "The number of palettes in the list",
 
227
                                                          0, G_MAXINT32, 0,
 
228
                                                          GIMP_PARAM_READWRITE));
 
229
  gimp_procedure_add_return_value (procedure,
 
230
                                   gimp_param_spec_string_array ("palette-list",
 
231
                                                                 "palette list",
 
232
                                                                 "The list of palette names",
 
233
                                                                 GIMP_PARAM_READWRITE));
 
234
  gimp_pdb_register_procedure (pdb, procedure);
 
235
  g_object_unref (procedure);
 
236
 
 
237
  /*
 
238
   * gimp-palettes-get-palette
 
239
   */
 
240
  procedure = gimp_procedure_new (palettes_get_palette_invoker);
 
241
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-palettes-get-palette");
 
242
  gimp_procedure_set_static_strings (procedure,
 
243
                                     "gimp-palettes-get-palette",
 
244
                                     "This procedure is deprecated! Use 'gimp-context-get-palette' instead.",
 
245
                                     "This procedure is deprecated! Use 'gimp-context-get-palette' instead.",
 
246
                                     "",
 
247
                                     "",
 
248
                                     "",
 
249
                                     "gimp-context-get-palette");
 
250
  gimp_procedure_add_return_value (procedure,
 
251
                                   gimp_param_spec_string ("name",
 
252
                                                           "name",
 
253
                                                           "The palette name",
 
254
                                                           FALSE, TRUE,
 
255
                                                           NULL,
 
256
                                                           GIMP_PARAM_READWRITE));
 
257
  gimp_procedure_add_return_value (procedure,
 
258
                                   gimp_param_spec_int32 ("num-colors",
 
259
                                                          "num colors",
 
260
                                                          "The palette num_colors",
 
261
                                                          G_MININT32, G_MAXINT32, 0,
 
262
                                                          GIMP_PARAM_READWRITE));
 
263
  gimp_pdb_register_procedure (pdb, procedure);
 
264
  g_object_unref (procedure);
 
265
 
 
266
  /*
 
267
   * gimp-palettes-get-palette-entry
 
268
   */
 
269
  procedure = gimp_procedure_new (palettes_get_palette_entry_invoker);
 
270
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-palettes-get-palette-entry");
 
271
  gimp_procedure_set_static_strings (procedure,
 
272
                                     "gimp-palettes-get-palette-entry",
 
273
                                     "This procedure is deprecated! Use 'gimp-palette-entry-get-color' instead.",
 
274
                                     "This procedure is deprecated! Use 'gimp-palette-entry-get-color' instead.",
 
275
                                     "",
 
276
                                     "",
 
277
                                     "",
 
278
                                     "gimp-palette-entry-get-color");
 
279
  gimp_procedure_add_argument (procedure,
 
280
                               gimp_param_spec_string ("name",
 
281
                                                       "name",
 
282
                                                       "The palette name (\"\" means currently active palette)",
 
283
                                                       FALSE, TRUE,
 
284
                                                       NULL,
 
285
                                                       GIMP_PARAM_READWRITE));
 
286
  gimp_procedure_add_argument (procedure,
 
287
                               gimp_param_spec_int32 ("entry-num",
 
288
                                                      "entry num",
 
289
                                                      "The entry to retrieve",
 
290
                                                      G_MININT32, G_MAXINT32, 0,
 
291
                                                      GIMP_PARAM_READWRITE));
 
292
  gimp_procedure_add_return_value (procedure,
 
293
                                   gimp_param_spec_string ("actual-name",
 
294
                                                           "actual name",
 
295
                                                           "The palette name",
 
296
                                                           FALSE, FALSE,
 
297
                                                           NULL,
 
298
                                                           GIMP_PARAM_READWRITE));
 
299
  gimp_procedure_add_return_value (procedure,
 
300
                                   gimp_param_spec_int32 ("num-colors",
 
301
                                                          "num colors",
 
302
                                                          "The palette num_colors",
 
303
                                                          G_MININT32, G_MAXINT32, 0,
 
304
                                                          GIMP_PARAM_READWRITE));
 
305
  gimp_procedure_add_return_value (procedure,
 
306
                                   gimp_param_spec_rgb ("color",
 
307
                                                        "color",
 
308
                                                        "The color requested",
 
309
                                                        FALSE,
 
310
                                                        NULL,
 
311
                                                        GIMP_PARAM_READWRITE));
 
312
  gimp_pdb_register_procedure (pdb, procedure);
 
313
  g_object_unref (procedure);
 
314
}