buffer-cmds.c 20.1 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
2 3
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7 8 9 10 11 12 13 14
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 17
 */

18
/* NOTE: This file is auto-generated by pdbgen.pl. */
19 20 21 22 23

#include "config.h"

#include <string.h>

24
#include <gegl.h>
25 26 27 28 29

#include "pdb-types.h"

#include "core/gimp.h"
#include "core/gimpbuffer.h"
30
#include "core/gimpcontainer-filter.h"
31
#include "core/gimpcontainer.h"
32
#include "core/gimpparamspecs.h"
33

34 35 36
#include "gimppdb.h"
#include "gimppdb-utils.h"
#include "gimpprocedure.h"
37
#include "internal-procs.h"
38

39

40
static GValueArray *
41 42 43 44 45 46
buffers_get_list_invoker (GimpProcedure      *procedure,
                          Gimp               *gimp,
                          GimpContext        *context,
                          GimpProgress       *progress,
                          const GValueArray  *args,
                          GError            **error)
47 48
{
  gboolean success = TRUE;
49
  GValueArray *return_vals;
50
  const gchar *filter;
51
  gint32 num_buffers = 0;
52 53
  gchar **buffer_list = NULL;

54
  filter = g_value_get_string (&args->values[0]);
55 56

  if (success)
57 58 59 60
    {
      buffer_list = gimp_container_get_filtered_name_array (gimp->named_buffers,
                                                            filter, &num_buffers);
    }
61

62 63
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
64 65 66

  if (success)
    {
67 68
      g_value_set_int (&return_vals->values[1], num_buffers);
      gimp_value_take_stringarray (&return_vals->values[2], buffer_list, num_buffers);
69 70
    }

71
  return return_vals;
72 73
}

74
static GValueArray *
75 76 77 78 79 80
buffer_rename_invoker (GimpProcedure      *procedure,
                       Gimp               *gimp,
                       GimpContext        *context,
                       GimpProgress       *progress,
                       const GValueArray  *args,
                       GError            **error)
81 82
{
  gboolean success = TRUE;
83
  GValueArray *return_vals;
84 85
  const gchar *buffer_name;
  const gchar *new_name;
86 87
  gchar *real_name = NULL;

88 89
  buffer_name = g_value_get_string (&args->values[0]);
  new_name = g_value_get_string (&args->values[1]);
90 91 92

  if (success)
    {
93
      GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error);
94

95
      if (buffer)
96 97 98 99
        {
          gimp_object_set_name (GIMP_OBJECT (buffer), new_name);
          real_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (buffer)));
        }
100 101
      else
        success = FALSE;
102 103
    }

104 105
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
106 107

  if (success)
108
    g_value_take_string (&return_vals->values[1], real_name);
109

110
  return return_vals;
111 112
}

113
static GValueArray *
114 115 116 117 118 119
buffer_delete_invoker (GimpProcedure      *procedure,
                       Gimp               *gimp,
                       GimpContext        *context,
                       GimpProgress       *progress,
                       const GValueArray  *args,
                       GError            **error)
120 121
{
  gboolean success = TRUE;
122
  const gchar *buffer_name;
123

124
  buffer_name = g_value_get_string (&args->values[0]);
125 126 127

  if (success)
    {
128
      GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error);
129

130
      if (buffer)
131
        success = gimp_container_remove (gimp->named_buffers, GIMP_OBJECT (buffer));
132 133
      else
        success = FALSE;
134 135
    }

136 137
  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
138 139
}

140
static GValueArray *
141 142 143 144 145 146
buffer_get_width_invoker (GimpProcedure      *procedure,
                          Gimp               *gimp,
                          GimpContext        *context,
                          GimpProgress       *progress,
                          const GValueArray  *args,
                          GError            **error)
147 148
{
  gboolean success = TRUE;
149
  GValueArray *return_vals;
150
  const gchar *buffer_name;
151
  gint32 width = 0;
152

153
  buffer_name = g_value_get_string (&args->values[0]);
154 155 156

  if (success)
    {
157
      GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error);
158

159 160 161 162
      if (buffer)
        width = gimp_buffer_get_width (buffer);
      else
        success = FALSE;
163 164
    }

165 166
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
167 168

  if (success)
169
    g_value_set_int (&return_vals->values[1], width);
170

171
  return return_vals;
172 173
}

174
static GValueArray *
175 176 177 178 179 180
buffer_get_height_invoker (GimpProcedure      *procedure,
                           Gimp               *gimp,
                           GimpContext        *context,
                           GimpProgress       *progress,
                           const GValueArray  *args,
                           GError            **error)
181 182
{
  gboolean success = TRUE;
183
  GValueArray *return_vals;
184
  const gchar *buffer_name;
185
  gint32 height = 0;
186

187
  buffer_name = g_value_get_string (&args->values[0]);
188 189 190

  if (success)
    {
191
      GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error);
192

193 194 195 196
      if (buffer)
        height = gimp_buffer_get_height (buffer);
      else
        success = FALSE;
197 198
    }

199 200
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
201 202

  if (success)
203
    g_value_set_int (&return_vals->values[1], height);
204

205
  return return_vals;
206 207
}

208
static GValueArray *
209 210 211 212 213 214
buffer_get_bytes_invoker (GimpProcedure      *procedure,
                          Gimp               *gimp,
                          GimpContext        *context,
                          GimpProgress       *progress,
                          const GValueArray  *args,
                          GError            **error)
215 216
{
  gboolean success = TRUE;
217
  GValueArray *return_vals;
218
  const gchar *buffer_name;
219
  gint32 bytes = 0;
220

221
  buffer_name = g_value_get_string (&args->values[0]);
222 223 224

  if (success)
    {
225
      GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error);
226

227 228 229 230
      if (buffer)
        bytes = gimp_buffer_get_bytes (buffer);
      else
        success = FALSE;
231 232
    }

233 234
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
235 236

  if (success)
237
    g_value_set_int (&return_vals->values[1], bytes);
238

239
  return return_vals;
240 241
}

242
static GValueArray *
243 244 245 246 247 248
buffer_get_image_type_invoker (GimpProcedure      *procedure,
                               Gimp               *gimp,
                               GimpContext        *context,
                               GimpProgress       *progress,
                               const GValueArray  *args,
                               GError            **error)
249 250
{
  gboolean success = TRUE;
251
  GValueArray *return_vals;
252
  const gchar *buffer_name;
253
  gint32 image_type = 0;
254

255
  buffer_name = g_value_get_string (&args->values[0]);
256 257 258

  if (success)
    {
259
      GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error);
260

261 262 263 264
      if (buffer)
        image_type = gimp_buffer_get_image_type (buffer);
      else
        success = FALSE;
265 266
    }

267 268
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
269 270

  if (success)
271
    g_value_set_enum (&return_vals->values[1], image_type);
272

273
  return return_vals;
274 275
}

276
void
277
register_buffer_procs (GimpPDB *pdb)
278
{
279 280 281 282 283
  GimpProcedure *procedure;

  /*
   * gimp-buffers-get-list
   */
284
  procedure = gimp_procedure_new (buffers_get_list_invoker);
285 286
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-buffers-get-list");
287 288 289 290 291 292 293 294 295 296 297 298
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-buffers-get-list",
                                     "Retrieve a complete listing of the available buffers.",
                                     "This procedure returns a complete listing of available named buffers.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2005",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("filter",
                                                       "filter",
                                                       "An optional regular expression used to filter the list",
299
                                                       FALSE, TRUE, FALSE,
300 301 302 303 304 305 306 307 308 309 310 311 312
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("num-buffers",
                                                          "num buffers",
                                                          "The number of buffers",
                                                          0, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string_array ("buffer-list",
                                                                 "buffer list",
                                                                 "The list of buffer names",
                                                                 GIMP_PARAM_READWRITE));
313
  gimp_pdb_register_procedure (pdb, procedure);
314
  g_object_unref (procedure);
315 316 317 318

  /*
   * gimp-buffer-rename
   */
319
  procedure = gimp_procedure_new (buffer_rename_invoker);
320 321
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-buffer-rename");
322 323 324 325 326 327 328 329 330 331 332 333
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-buffer-rename",
                                     "Renames a named buffer.",
                                     "This procedure renames a named buffer.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2005",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("buffer-name",
                                                       "buffer name",
                                                       "The buffer name",
334
                                                       FALSE, FALSE, TRUE,
335 336 337 338 339 340
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("new-name",
                                                       "new name",
                                                       "The buffer's new name",
341
                                                       FALSE, FALSE, TRUE,
342 343 344 345 346 347
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("real-name",
                                                           "real name",
                                                           "The real name given to the buffer",
348
                                                           FALSE, FALSE, FALSE,
349 350
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
351
  gimp_pdb_register_procedure (pdb, procedure);
352
  g_object_unref (procedure);
353 354 355 356

  /*
   * gimp-buffer-delete
   */
357
  procedure = gimp_procedure_new (buffer_delete_invoker);
358 359
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-buffer-delete");
360 361 362 363 364 365 366 367 368 369 370 371
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-buffer-delete",
                                     "Deletes a named buffer.",
                                     "This procedure deletes a named buffer.",
                                     "David Gowers <neota@softhome.net>",
                                     "David Gowers <neota@softhome.net>",
                                     "2005",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("buffer-name",
                                                       "buffer name",
                                                       "The buffer name",
372
                                                       FALSE, FALSE, TRUE,
373 374
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
375
  gimp_pdb_register_procedure (pdb, procedure);
376
  g_object_unref (procedure);
377 378 379 380

  /*
   * gimp-buffer-get-width
   */
381
  procedure = gimp_procedure_new (buffer_get_width_invoker);
382 383
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-buffer-get-width");
384 385 386 387 388 389 390 391 392 393 394 395
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-buffer-get-width",
                                     "Retrieves the specified buffer's width.",
                                     "This procedure retrieves the specified named buffer's width.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2005",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("buffer-name",
                                                       "buffer name",
                                                       "The buffer name",
396
                                                       FALSE, FALSE, TRUE,
397 398 399 400 401 402 403 404
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("width",
                                                          "width",
                                                          "The buffer width",
                                                          G_MININT32, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
405
  gimp_pdb_register_procedure (pdb, procedure);
406
  g_object_unref (procedure);
407 408 409 410

  /*
   * gimp-buffer-get-height
   */
411
  procedure = gimp_procedure_new (buffer_get_height_invoker);
412 413
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-buffer-get-height");
414 415 416 417 418 419 420 421 422 423 424 425
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-buffer-get-height",
                                     "Retrieves the specified buffer's height.",
                                     "This procedure retrieves the specified named buffer's height.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2005",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("buffer-name",
                                                       "buffer name",
                                                       "The buffer name",
426
                                                       FALSE, FALSE, TRUE,
427 428 429 430 431 432 433 434
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("height",
                                                          "height",
                                                          "The buffer height",
                                                          G_MININT32, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
435
  gimp_pdb_register_procedure (pdb, procedure);
436
  g_object_unref (procedure);
437 438 439 440

  /*
   * gimp-buffer-get-bytes
   */
441
  procedure = gimp_procedure_new (buffer_get_bytes_invoker);
442 443
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-buffer-get-bytes");
444 445 446 447 448 449 450 451 452 453 454 455
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-buffer-get-bytes",
                                     "Retrieves the specified buffer's bytes.",
                                     "This procedure retrieves the specified named buffer's bytes.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2005",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("buffer-name",
                                                       "buffer name",
                                                       "The buffer name",
456
                                                       FALSE, FALSE, TRUE,
457 458 459 460 461 462 463 464
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("bytes",
                                                          "bytes",
                                                          "The buffer bpp",
                                                          G_MININT32, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
465
  gimp_pdb_register_procedure (pdb, procedure);
466
  g_object_unref (procedure);
467 468 469 470

  /*
   * gimp-buffer-get-image-type
   */
471
  procedure = gimp_procedure_new (buffer_get_image_type_invoker);
472 473
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-buffer-get-image-type");
474 475 476 477 478 479 480 481 482 483 484 485
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-buffer-get-image-type",
                                     "Retrieves the specified buffer's image type.",
                                     "This procedure retrieves the specified named buffer's image type.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2005",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("buffer-name",
                                                       "buffer name",
                                                       "The buffer name",
486
                                                       FALSE, FALSE, TRUE,
487 488 489 490 491
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   g_param_spec_enum ("image-type",
                                                      "image type",
492
                                                      "The buffer image type",
493 494 495
                                                      GIMP_TYPE_IMAGE_BASE_TYPE,
                                                      GIMP_RGB,
                                                      GIMP_PARAM_READWRITE));
496
  gimp_pdb_register_procedure (pdb, procedure);
497
  g_object_unref (procedure);
498
}