/* PIKA - Photo and Image Kooker Application
 * a rebranding of The GNU Image Manipulation Program (created with heckimp)
 * A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
 *
 * Original copyright, applying to most contents (license remains unchanged): 
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (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
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

/* NOTE: This file is auto-generated by pdbgen.pl. */

#include "config.h"

#include "stamp-pdbgen.h"

#include <gegl.h>

#include <gdk-pixbuf/gdk-pixbuf.h>

#include "libpikabase/pikabase.h"

#include "libpikabase/pikabase.h"

#include "pdb-types.h"

#include "core/pikaimage.h"
#include "core/pikaitem.h"
#include "core/pikalayermask.h"
#include "core/pikalist.h"
#include "core/pikaparamspecs.h"
#include "core/pikaselection.h"
#include "text/pikatextlayer.h"
#include "vectors/pikavectors.h"

#include "pikapdb.h"
#include "pikapdb-utils.h"
#include "pikapdbcontext.h"
#include "pikaprocedure.h"
#include "internal-procs.h"

#include "pika-intl.h"


static PikaValueArray *
item_id_is_valid_invoker (PikaProcedure         *procedure,
                          Pika                  *pika,
                          PikaContext           *context,
                          PikaProgress          *progress,
                          const PikaValueArray  *args,
                          GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  gint item_id;
  gboolean valid = FALSE;

  item_id = g_value_get_int (pika_value_array_index (args, 0));

  if (success)
    {
      PikaItem *item = pika_item_get_by_id (pika, item_id);

      valid = (PIKA_IS_ITEM (item) &&
               ! pika_item_is_removed (PIKA_ITEM (item)));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), valid);

  return return_vals;
}

static PikaValueArray *
item_id_is_drawable_invoker (PikaProcedure         *procedure,
                             Pika                  *pika,
                             PikaContext           *context,
                             PikaProgress          *progress,
                             const PikaValueArray  *args,
                             GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  gint item_id;
  gboolean drawable = FALSE;

  item_id = g_value_get_int (pika_value_array_index (args, 0));

  if (success)
    {
      PikaItem *item = pika_item_get_by_id (pika, item_id);

      drawable = (PIKA_IS_DRAWABLE (item) &&
                  ! pika_item_is_removed (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), drawable);

  return return_vals;
}

static PikaValueArray *
item_id_is_layer_invoker (PikaProcedure         *procedure,
                          Pika                  *pika,
                          PikaContext           *context,
                          PikaProgress          *progress,
                          const PikaValueArray  *args,
                          GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  gint item_id;
  gboolean layer = FALSE;

  item_id = g_value_get_int (pika_value_array_index (args, 0));

  if (success)
    {
      PikaItem *item = pika_item_get_by_id (pika, item_id);

      layer = (PIKA_IS_LAYER (item) &&
               ! pika_item_is_removed (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), layer);

  return return_vals;
}

static PikaValueArray *
item_id_is_text_layer_invoker (PikaProcedure         *procedure,
                               Pika                  *pika,
                               PikaContext           *context,
                               PikaProgress          *progress,
                               const PikaValueArray  *args,
                               GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  gint item_id;
  gboolean text_layer = FALSE;

  item_id = g_value_get_int (pika_value_array_index (args, 0));

  if (success)
    {
      PikaItem *item = pika_item_get_by_id (pika, item_id);

      text_layer = (PIKA_IS_LAYER (item) &&
                    ! pika_item_is_removed (item) &&
                    pika_item_is_text_layer (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), text_layer);

  return return_vals;
}

static PikaValueArray *
item_id_is_channel_invoker (PikaProcedure         *procedure,
                            Pika                  *pika,
                            PikaContext           *context,
                            PikaProgress          *progress,
                            const PikaValueArray  *args,
                            GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  gint item_id;
  gboolean channel = FALSE;

  item_id = g_value_get_int (pika_value_array_index (args, 0));

  if (success)
    {
      PikaItem *item = pika_item_get_by_id (pika, item_id);

      channel = (PIKA_IS_CHANNEL (item) &&
                 ! pika_item_is_removed (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), channel);

  return return_vals;
}

static PikaValueArray *
item_id_is_layer_mask_invoker (PikaProcedure         *procedure,
                               Pika                  *pika,
                               PikaContext           *context,
                               PikaProgress          *progress,
                               const PikaValueArray  *args,
                               GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  gint item_id;
  gboolean layer_mask = FALSE;

  item_id = g_value_get_int (pika_value_array_index (args, 0));

  if (success)
    {
      PikaItem *item = pika_item_get_by_id (pika, item_id);

      layer_mask = (PIKA_IS_LAYER_MASK (item) &&
                    ! pika_item_is_removed (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), layer_mask);

  return return_vals;
}

static PikaValueArray *
item_id_is_selection_invoker (PikaProcedure         *procedure,
                              Pika                  *pika,
                              PikaContext           *context,
                              PikaProgress          *progress,
                              const PikaValueArray  *args,
                              GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  gint item_id;
  gboolean selection = FALSE;

  item_id = g_value_get_int (pika_value_array_index (args, 0));

  if (success)
    {
      PikaItem *item = pika_item_get_by_id (pika, item_id);

      selection = (PIKA_IS_SELECTION (item) &&
                   ! pika_item_is_removed (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), selection);

  return return_vals;
}

static PikaValueArray *
item_id_is_vectors_invoker (PikaProcedure         *procedure,
                            Pika                  *pika,
                            PikaContext           *context,
                            PikaProgress          *progress,
                            const PikaValueArray  *args,
                            GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  gint item_id;
  gboolean vectors = FALSE;

  item_id = g_value_get_int (pika_value_array_index (args, 0));

  if (success)
    {
      PikaItem *item = pika_item_get_by_id (pika, item_id);

      vectors = (PIKA_IS_VECTORS (item) &&
                 ! pika_item_is_removed (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), vectors);

  return return_vals;
}

static PikaValueArray *
item_get_image_invoker (PikaProcedure         *procedure,
                        Pika                  *pika,
                        PikaContext           *context,
                        PikaProgress          *progress,
                        const PikaValueArray  *args,
                        GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaItem *item;
  PikaImage *image = NULL;

  item = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      image = pika_item_get_image (PIKA_ITEM (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_object (pika_value_array_index (return_vals, 1), image);

  return return_vals;
}

static PikaValueArray *
item_delete_invoker (PikaProcedure         *procedure,
                     Pika                  *pika,
                     PikaContext           *context,
                     PikaProgress          *progress,
                     const PikaValueArray  *args,
                     GError               **error)
{
  gboolean success = TRUE;
  PikaItem *item;

  item = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      if (g_object_is_floating (item))
        {
          g_object_ref_sink (item);
          g_object_unref (item);
        }
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
item_is_group_invoker (PikaProcedure         *procedure,
                       Pika                  *pika,
                       PikaContext           *context,
                       PikaProgress          *progress,
                       const PikaValueArray  *args,
                       GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaItem *item;
  gboolean group = FALSE;

  item = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      group = (pika_viewable_get_children (PIKA_VIEWABLE (item)) != NULL);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), group);

  return return_vals;
}

static PikaValueArray *
item_get_parent_invoker (PikaProcedure         *procedure,
                         Pika                  *pika,
                         PikaContext           *context,
                         PikaProgress          *progress,
                         const PikaValueArray  *args,
                         GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaItem *item;
  PikaItem *parent = NULL;

  item = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      parent = pika_item_get_parent (item);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_object (pika_value_array_index (return_vals, 1), parent);

  return return_vals;
}

static PikaValueArray *
item_get_children_invoker (PikaProcedure         *procedure,
                           Pika                  *pika,
                           PikaContext           *context,
                           PikaProgress          *progress,
                           const PikaValueArray  *args,
                           GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaItem *item;
  gint num_children = 0;
  PikaItem **children = NULL;

  item = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      PikaContainer *container = pika_viewable_get_children (PIKA_VIEWABLE (item));

      if (container)
        {
          num_children = pika_container_get_n_children (container);

          if (num_children)
            {
              GList *list;
              gint   i;

              children = g_new (PikaItem *, num_children);

              for (list = PIKA_LIST (container)->queue->head, i = 0;
                   list;
                   list = g_list_next (list), i++)
                {
                  children[i] = g_object_ref (list->data);
                }
            }
        }
      else
        success = FALSE;

    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_set_int (pika_value_array_index (return_vals, 1), num_children);
      pika_value_take_object_array (pika_value_array_index (return_vals, 2), PIKA_TYPE_ITEM, (GObject **) children, num_children);
    }

  return return_vals;
}

static PikaValueArray *
item_get_expanded_invoker (PikaProcedure         *procedure,
                           Pika                  *pika,
                           PikaContext           *context,
                           PikaProgress          *progress,
                           const PikaValueArray  *args,
                           GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaItem *item;
  gboolean expanded = FALSE;

  item = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      expanded = pika_viewable_get_expanded (PIKA_VIEWABLE (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), expanded);

  return return_vals;
}

static PikaValueArray *
item_set_expanded_invoker (PikaProcedure         *procedure,
                           Pika                  *pika,
                           PikaContext           *context,
                           PikaProgress          *progress,
                           const PikaValueArray  *args,
                           GError               **error)
{
  gboolean success = TRUE;
  PikaItem *item;
  gboolean expanded;

  item = g_value_get_object (pika_value_array_index (args, 0));
  expanded = g_value_get_boolean (pika_value_array_index (args, 1));

  if (success)
    {
      pika_viewable_set_expanded (PIKA_VIEWABLE (item), expanded);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
item_get_name_invoker (PikaProcedure         *procedure,
                       Pika                  *pika,
                       PikaContext           *context,
                       PikaProgress          *progress,
                       const PikaValueArray  *args,
                       GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaItem *item;
  gchar *name = NULL;

  item = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      name = g_strdup (pika_object_get_name (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_take_string (pika_value_array_index (return_vals, 1), name);

  return return_vals;
}

static PikaValueArray *
item_set_name_invoker (PikaProcedure         *procedure,
                       Pika                  *pika,
                       PikaContext           *context,
                       PikaProgress          *progress,
                       const PikaValueArray  *args,
                       GError               **error)
{
  gboolean success = TRUE;
  PikaItem *item;
  const gchar *name;

  item = g_value_get_object (pika_value_array_index (args, 0));
  name = g_value_get_string (pika_value_array_index (args, 1));

  if (success)
    {
      success = pika_item_rename (PIKA_ITEM (item), name, error);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
item_get_visible_invoker (PikaProcedure         *procedure,
                          Pika                  *pika,
                          PikaContext           *context,
                          PikaProgress          *progress,
                          const PikaValueArray  *args,
                          GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaItem *item;
  gboolean visible = FALSE;

  item = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      visible = pika_item_get_visible (PIKA_ITEM (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), visible);

  return return_vals;
}

static PikaValueArray *
item_set_visible_invoker (PikaProcedure         *procedure,
                          Pika                  *pika,
                          PikaContext           *context,
                          PikaProgress          *progress,
                          const PikaValueArray  *args,
                          GError               **error)
{
  gboolean success = TRUE;
  PikaItem *item;
  gboolean visible;

  item = g_value_get_object (pika_value_array_index (args, 0));
  visible = g_value_get_boolean (pika_value_array_index (args, 1));

  if (success)
    {
      pika_item_set_visible (PIKA_ITEM (item), visible, TRUE);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
item_get_lock_content_invoker (PikaProcedure         *procedure,
                               Pika                  *pika,
                               PikaContext           *context,
                               PikaProgress          *progress,
                               const PikaValueArray  *args,
                               GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaItem *item;
  gboolean lock_content = FALSE;

  item = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      lock_content = pika_item_get_lock_content (PIKA_ITEM (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), lock_content);

  return return_vals;
}

static PikaValueArray *
item_set_lock_content_invoker (PikaProcedure         *procedure,
                               Pika                  *pika,
                               PikaContext           *context,
                               PikaProgress          *progress,
                               const PikaValueArray  *args,
                               GError               **error)
{
  gboolean success = TRUE;
  PikaItem *item;
  gboolean lock_content;

  item = g_value_get_object (pika_value_array_index (args, 0));
  lock_content = g_value_get_boolean (pika_value_array_index (args, 1));

  if (success)
    {
      if (pika_item_can_lock_content (PIKA_ITEM (item)))
        pika_item_set_lock_content (PIKA_ITEM (item), lock_content, TRUE);
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
item_get_lock_position_invoker (PikaProcedure         *procedure,
                                Pika                  *pika,
                                PikaContext           *context,
                                PikaProgress          *progress,
                                const PikaValueArray  *args,
                                GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaItem *item;
  gboolean lock_position = FALSE;

  item = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      lock_position = pika_item_get_lock_position (PIKA_ITEM (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), lock_position);

  return return_vals;
}

static PikaValueArray *
item_set_lock_position_invoker (PikaProcedure         *procedure,
                                Pika                  *pika,
                                PikaContext           *context,
                                PikaProgress          *progress,
                                const PikaValueArray  *args,
                                GError               **error)
{
  gboolean success = TRUE;
  PikaItem *item;
  gboolean lock_position;

  item = g_value_get_object (pika_value_array_index (args, 0));
  lock_position = g_value_get_boolean (pika_value_array_index (args, 1));

  if (success)
    {
      if (pika_item_can_lock_position (PIKA_ITEM (item)))
        pika_item_set_lock_position (PIKA_ITEM (item), lock_position, TRUE);
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
item_get_lock_visibility_invoker (PikaProcedure         *procedure,
                                  Pika                  *pika,
                                  PikaContext           *context,
                                  PikaProgress          *progress,
                                  const PikaValueArray  *args,
                                  GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaItem *item;
  gboolean lock_visibility = FALSE;

  item = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      lock_visibility = pika_item_get_lock_visibility (PIKA_ITEM (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (pika_value_array_index (return_vals, 1), lock_visibility);

  return return_vals;
}

static PikaValueArray *
item_set_lock_visibility_invoker (PikaProcedure         *procedure,
                                  Pika                  *pika,
                                  PikaContext           *context,
                                  PikaProgress          *progress,
                                  const PikaValueArray  *args,
                                  GError               **error)
{
  gboolean success = TRUE;
  PikaItem *item;
  gboolean lock_visibility;

  item = g_value_get_object (pika_value_array_index (args, 0));
  lock_visibility = g_value_get_boolean (pika_value_array_index (args, 1));

  if (success)
    {
      if (pika_item_can_lock_visibility (PIKA_ITEM (item)))
        pika_item_set_lock_visibility (PIKA_ITEM (item), lock_visibility, TRUE);
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
item_get_color_tag_invoker (PikaProcedure         *procedure,
                            Pika                  *pika,
                            PikaContext           *context,
                            PikaProgress          *progress,
                            const PikaValueArray  *args,
                            GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaItem *item;
  gint color_tag = 0;

  item = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      color_tag = pika_item_get_color_tag (PIKA_ITEM (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_enum (pika_value_array_index (return_vals, 1), color_tag);

  return return_vals;
}

static PikaValueArray *
item_set_color_tag_invoker (PikaProcedure         *procedure,
                            Pika                  *pika,
                            PikaContext           *context,
                            PikaProgress          *progress,
                            const PikaValueArray  *args,
                            GError               **error)
{
  gboolean success = TRUE;
  PikaItem *item;
  gint color_tag;

  item = g_value_get_object (pika_value_array_index (args, 0));
  color_tag = g_value_get_enum (pika_value_array_index (args, 1));

  if (success)
    {
      pika_item_set_color_tag (PIKA_ITEM (item), color_tag, TRUE);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
item_get_tattoo_invoker (PikaProcedure         *procedure,
                         Pika                  *pika,
                         PikaContext           *context,
                         PikaProgress          *progress,
                         const PikaValueArray  *args,
                         GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaItem *item;
  guint tattoo = 0;

  item = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      tattoo = pika_item_get_tattoo (PIKA_ITEM (item));
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_uint (pika_value_array_index (return_vals, 1), tattoo);

  return return_vals;
}

static PikaValueArray *
item_set_tattoo_invoker (PikaProcedure         *procedure,
                         Pika                  *pika,
                         PikaContext           *context,
                         PikaProgress          *progress,
                         const PikaValueArray  *args,
                         GError               **error)
{
  gboolean success = TRUE;
  PikaItem *item;
  guint tattoo;

  item = g_value_get_object (pika_value_array_index (args, 0));
  tattoo = g_value_get_uint (pika_value_array_index (args, 1));

  if (success)
    {
      pika_item_set_tattoo (PIKA_ITEM (item), tattoo);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
item_attach_parasite_invoker (PikaProcedure         *procedure,
                              Pika                  *pika,
                              PikaContext           *context,
                              PikaProgress          *progress,
                              const PikaValueArray  *args,
                              GError               **error)
{
  gboolean success = TRUE;
  PikaItem *item;
  const PikaParasite *parasite;

  item = g_value_get_object (pika_value_array_index (args, 0));
  parasite = g_value_get_boxed (pika_value_array_index (args, 1));

  if (success)
    {
      if (pika_item_parasite_validate (item, parasite, error))
        pika_item_parasite_attach (item, parasite, TRUE);
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
item_detach_parasite_invoker (PikaProcedure         *procedure,
                              Pika                  *pika,
                              PikaContext           *context,
                              PikaProgress          *progress,
                              const PikaValueArray  *args,
                              GError               **error)
{
  gboolean success = TRUE;
  PikaItem *item;
  const gchar *name;

  item = g_value_get_object (pika_value_array_index (args, 0));
  name = g_value_get_string (pika_value_array_index (args, 1));

  if (success)
    {
      pika_item_parasite_detach (item, name, TRUE);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
item_get_parasite_invoker (PikaProcedure         *procedure,
                           Pika                  *pika,
                           PikaContext           *context,
                           PikaProgress          *progress,
                           const PikaValueArray  *args,
                           GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaItem *item;
  const gchar *name;
  PikaParasite *parasite = NULL;

  item = g_value_get_object (pika_value_array_index (args, 0));
  name = g_value_get_string (pika_value_array_index (args, 1));

  if (success)
    {
      parasite = pika_parasite_copy (pika_item_parasite_find (item, name));

      if (! parasite)
        success = FALSE;
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_take_boxed (pika_value_array_index (return_vals, 1), parasite);

  return return_vals;
}

static PikaValueArray *
item_get_parasite_list_invoker (PikaProcedure         *procedure,
                                Pika                  *pika,
                                PikaContext           *context,
                                PikaProgress          *progress,
                                const PikaValueArray  *args,
                                GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaItem *item;
  gchar **parasites = NULL;

  item = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      parasites = pika_item_parasite_list (item);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_take_boxed (pika_value_array_index (return_vals, 1), parasites);

  return return_vals;
}

void
register_item_procs (PikaPDB *pdb)
{
  PikaProcedure *procedure;

  /*
   * pika-item-id-is-valid
   */
  procedure = pika_procedure_new (item_id_is_valid_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-id-is-valid");
  pika_procedure_set_static_help (procedure,
                                  "Returns TRUE if the item ID is valid.",
                                  "This procedure checks if the given item ID is valid and refers to an existing item.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Sven Neumann <sven@gimp.org>",
                                         "Sven Neumann",
                                         "2007");
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("item-id",
                                                 "item id",
                                                 "The item ID to check",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("valid",
                                                         "valid",
                                                         "Whether the item ID is valid",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-id-is-drawable
   */
  procedure = pika_procedure_new (item_id_is_drawable_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-id-is-drawable");
  pika_procedure_set_static_help (procedure,
                                  "Returns whether the item ID is a drawable.",
                                  "This procedure returns TRUE if the specified item ID is a drawable.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Spencer Kimball & Peter Mattis",
                                         "Spencer Kimball & Peter Mattis",
                                         "1995-1996");
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("item-id",
                                                 "item id",
                                                 "The item ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("drawable",
                                                         "drawable",
                                                         "TRUE if the item ID is a drawable, FALSE otherwise",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-id-is-layer
   */
  procedure = pika_procedure_new (item_id_is_layer_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-id-is-layer");
  pika_procedure_set_static_help (procedure,
                                  "Returns whether the item ID is a layer.",
                                  "This procedure returns TRUE if the specified item ID is a layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Spencer Kimball & Peter Mattis",
                                         "Spencer Kimball & Peter Mattis",
                                         "1995-1996");
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("item-id",
                                                 "item id",
                                                 "The item ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("layer",
                                                         "layer",
                                                         "TRUE if the item is a layer, FALSE otherwise",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-id-is-text-layer
   */
  procedure = pika_procedure_new (item_id_is_text_layer_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-id-is-text-layer");
  pika_procedure_set_static_help (procedure,
                                  "Returns whether the item ID is a text layer.",
                                  "This procedure returns TRUE if the specified item ID is a text layer.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Michael Natterer <mitch@gimp.org>",
                                         "Michael Natterer",
                                         "2010");
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("item-id",
                                                 "item id",
                                                 "The item ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("text-layer",
                                                         "text layer",
                                                         "TRUE if the item is a text layer, FALSE otherwise.",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-id-is-channel
   */
  procedure = pika_procedure_new (item_id_is_channel_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-id-is-channel");
  pika_procedure_set_static_help (procedure,
                                  "Returns whether the item ID is a channel.",
                                  "This procedure returns TRUE if the specified item ID is a channel.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Spencer Kimball & Peter Mattis",
                                         "Spencer Kimball & Peter Mattis",
                                         "1995-1996");
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("item-id",
                                                 "item id",
                                                 "The item ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("channel",
                                                         "channel",
                                                         "TRUE if the item ID is a channel, FALSE otherwise",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-id-is-layer-mask
   */
  procedure = pika_procedure_new (item_id_is_layer_mask_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-id-is-layer-mask");
  pika_procedure_set_static_help (procedure,
                                  "Returns whether the item ID is a layer mask.",
                                  "This procedure returns TRUE if the specified item ID is a layer mask.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Spencer Kimball & Peter Mattis",
                                         "Spencer Kimball & Peter Mattis",
                                         "1995-1996");
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("item-id",
                                                 "item id",
                                                 "The item",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("layer-mask",
                                                         "layer mask",
                                                         "TRUE if the item ID is a layer mask, FALSE otherwise",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-id-is-selection
   */
  procedure = pika_procedure_new (item_id_is_selection_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-id-is-selection");
  pika_procedure_set_static_help (procedure,
                                  "Returns whether the item ID is a selection.",
                                  "This procedure returns TRUE if the specified item ID is a selection.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Spencer Kimball & Peter Mattis",
                                         "Spencer Kimball & Peter Mattis",
                                         "1995-1996");
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("item-id",
                                                 "item id",
                                                 "The item ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("selection",
                                                         "selection",
                                                         "TRUE if the item ID is a selection, FALSE otherwise",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-id-is-vectors
   */
  procedure = pika_procedure_new (item_id_is_vectors_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-id-is-vectors");
  pika_procedure_set_static_help (procedure,
                                  "Returns whether the item ID is a vectors.",
                                  "This procedure returns TRUE if the specified item ID is a vectors.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Spencer Kimball & Peter Mattis",
                                         "Spencer Kimball & Peter Mattis",
                                         "1995-1996");
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("item-id",
                                                 "item id",
                                                 "The item ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("vectors",
                                                         "vectors",
                                                         "TRUE if the item ID is a vectors, FALSE otherwise",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-get-image
   */
  procedure = pika_procedure_new (item_get_image_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-get-image");
  pika_procedure_set_static_help (procedure,
                                  "Returns the item's image.",
                                  "This procedure returns the item's image.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Spencer Kimball & Peter Mattis",
                                         "Spencer Kimball & Peter Mattis",
                                         "1995-1996");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_image ("image",
                                                          "image",
                                                          "The item's image",
                                                          FALSE,
                                                          PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-delete
   */
  procedure = pika_procedure_new (item_delete_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-delete");
  pika_procedure_set_static_help (procedure,
                                  "Delete a item.",
                                  "This procedure deletes the specified item. This must not be done if the image containing this item was already deleted or if the item was already removed from the image. The only case in which this procedure is useful is if you want to get rid of a item which has not yet been added to an image.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Spencer Kimball & Peter Mattis",
                                         "Spencer Kimball & Peter Mattis",
                                         "1995-1996");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item to delete",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-is-group
   */
  procedure = pika_procedure_new (item_is_group_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-is-group");
  pika_procedure_set_static_help (procedure,
                                  "Returns whether the item is a group item.",
                                  "This procedure returns TRUE if the specified item is a group item which can have children.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Michael Natterer <mitch@gimp.org>",
                                         "Michael Natterer",
                                         "2010");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("group",
                                                         "group",
                                                         "TRUE if the item is a group, FALSE otherwise",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-get-parent
   */
  procedure = pika_procedure_new (item_get_parent_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-get-parent");
  pika_procedure_set_static_help (procedure,
                                  "Returns the item's parent item.",
                                  "This procedure returns the item's parent item, if any.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Michael Natterer <mitch@gimp.org>",
                                         "Michael Natterer",
                                         "2010");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_item ("parent",
                                                         "parent",
                                                         "The item's parent item",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-get-children
   */
  procedure = pika_procedure_new (item_get_children_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-get-children");
  pika_procedure_set_static_help (procedure,
                                  "Returns the item's list of children.",
                                  "This procedure returns the list of items which are children of the specified item. The order is topmost to bottommost.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Michael Natterer <mitch@gimp.org>",
                                         "Michael Natterer",
                                         "2010");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_int ("num-children",
                                                     "num children",
                                                     "The item's number of children",
                                                     0, G_MAXINT32, 0,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_object_array ("children",
                                                                 "children",
                                                                 "The item's list of children",
                                                                 PIKA_TYPE_ITEM,
                                                                 PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-get-expanded
   */
  procedure = pika_procedure_new (item_get_expanded_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-get-expanded");
  pika_procedure_set_static_help (procedure,
                                  "Returns whether the item is expanded.",
                                  "This procedure returns TRUE if the specified item is expanded.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Ell",
                                         "Ell",
                                         "2017");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("expanded",
                                                         "expanded",
                                                         "TRUE if the item is expanded, FALSE otherwise",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-set-expanded
   */
  procedure = pika_procedure_new (item_set_expanded_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-set-expanded");
  pika_procedure_set_static_help (procedure,
                                  "Sets the expanded state of the item.",
                                  "This procedure expands or collapses the item.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Ell",
                                         "Ell",
                                         "2017");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_boolean ("expanded",
                                                     "expanded",
                                                     "TRUE to expand the item, FALSE to collapse the item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-get-name
   */
  procedure = pika_procedure_new (item_get_name_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-get-name");
  pika_procedure_set_static_help (procedure,
                                  "Get the name of the specified item.",
                                  "This procedure returns the specified item's name.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Spencer Kimball & Peter Mattis",
                                         "Spencer Kimball & Peter Mattis",
                                         "1995-1996");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_string ("name",
                                                           "name",
                                                           "The item name",
                                                           FALSE, FALSE, FALSE,
                                                           NULL,
                                                           PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-set-name
   */
  procedure = pika_procedure_new (item_set_name_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-set-name");
  pika_procedure_set_static_help (procedure,
                                  "Set the name of the specified item.",
                                  "This procedure sets the specified item's name.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Spencer Kimball & Peter Mattis",
                                         "Spencer Kimball & Peter Mattis",
                                         "1995-1996");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_string ("name",
                                                       "name",
                                                       "The new item name",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-get-visible
   */
  procedure = pika_procedure_new (item_get_visible_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-get-visible");
  pika_procedure_set_static_help (procedure,
                                  "Get the visibility of the specified item.",
                                  "This procedure returns the specified item's visibility.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Spencer Kimball & Peter Mattis",
                                         "Spencer Kimball & Peter Mattis",
                                         "1995-1996");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("visible",
                                                         "visible",
                                                         "The item visibility",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-set-visible
   */
  procedure = pika_procedure_new (item_set_visible_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-set-visible");
  pika_procedure_set_static_help (procedure,
                                  "Set the visibility of the specified item.",
                                  "This procedure sets the specified item's visibility.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Spencer Kimball & Peter Mattis",
                                         "Spencer Kimball & Peter Mattis",
                                         "1995-1996");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_boolean ("visible",
                                                     "visible",
                                                     "The new item visibility",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-get-lock-content
   */
  procedure = pika_procedure_new (item_get_lock_content_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-get-lock-content");
  pika_procedure_set_static_help (procedure,
                                  "Get the 'lock content' state of the specified item.",
                                  "This procedure returns the specified item's lock content state.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Michael Natterer <mitch@gimp.org>",
                                         "Michael Natterer",
                                         "2009");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("lock-content",
                                                         "lock content",
                                                         "Whether the item's contents are locked",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-set-lock-content
   */
  procedure = pika_procedure_new (item_set_lock_content_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-set-lock-content");
  pika_procedure_set_static_help (procedure,
                                  "Set the 'lock content' state of the specified item.",
                                  "This procedure sets the specified item's lock content state.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Michael Natterer <mitch@gimp.org>",
                                         "Michael Natterer",
                                         "2009");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_boolean ("lock-content",
                                                     "lock content",
                                                     "The new item 'lock content' state",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-get-lock-position
   */
  procedure = pika_procedure_new (item_get_lock_position_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-get-lock-position");
  pika_procedure_set_static_help (procedure,
                                  "Get the 'lock position' state of the specified item.",
                                  "This procedure returns the specified item's lock position state.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Michael Natterer <mitch@gimp.org>",
                                         "Michael Natterer",
                                         "2012");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("lock-position",
                                                         "lock position",
                                                         "Whether the item's position is locked",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-set-lock-position
   */
  procedure = pika_procedure_new (item_set_lock_position_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-set-lock-position");
  pika_procedure_set_static_help (procedure,
                                  "Set the 'lock position' state of the specified item.",
                                  "This procedure sets the specified item's lock position state.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Michael Natterer <mitch@gimp.org>",
                                         "Michael Natterer",
                                         "2009");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_boolean ("lock-position",
                                                     "lock position",
                                                     "The new item 'lock position' state",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-get-lock-visibility
   */
  procedure = pika_procedure_new (item_get_lock_visibility_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-get-lock-visibility");
  pika_procedure_set_static_help (procedure,
                                  "Get the 'lock visibility' state of the specified item.",
                                  "This procedure returns the specified item's lock visibility state.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Jehan",
                                         "Jehan",
                                         "2021");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("lock-visibility",
                                                         "lock visibility",
                                                         "Whether the item's visibility is locked",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-set-lock-visibility
   */
  procedure = pika_procedure_new (item_set_lock_visibility_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-set-lock-visibility");
  pika_procedure_set_static_help (procedure,
                                  "Set the 'lock visibility' state of the specified item.",
                                  "This procedure sets the specified item's lock visibility state.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Jehan",
                                         "Jehan",
                                         "2021");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_boolean ("lock-visibility",
                                                     "lock visibility",
                                                     "The new item 'lock visibility' state",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-get-color-tag
   */
  procedure = pika_procedure_new (item_get_color_tag_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-get-color-tag");
  pika_procedure_set_static_help (procedure,
                                  "Get the color tag of the specified item.",
                                  "This procedure returns the specified item's color tag.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Michael Natterer <mitch@gimp.org>",
                                         "Michael Natterer",
                                         "2016");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_enum ("color-tag",
                                                      "color tag",
                                                      "The item's color tag",
                                                      PIKA_TYPE_COLOR_TAG,
                                                      PIKA_COLOR_TAG_NONE,
                                                      PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-set-color-tag
   */
  procedure = pika_procedure_new (item_set_color_tag_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-set-color-tag");
  pika_procedure_set_static_help (procedure,
                                  "Set the color tag of the specified item.",
                                  "This procedure sets the specified item's color tag.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Michael Natterer <mitch@gimp.org>",
                                         "Michael Natterer",
                                         "2016");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_enum ("color-tag",
                                                  "color tag",
                                                  "The new item color tag",
                                                  PIKA_TYPE_COLOR_TAG,
                                                  PIKA_COLOR_TAG_NONE,
                                                  PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-get-tattoo
   */
  procedure = pika_procedure_new (item_get_tattoo_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-get-tattoo");
  pika_procedure_set_static_help (procedure,
                                  "Get the tattoo of the specified item.",
                                  "This procedure returns the specified item's tattoo. A tattoo is a unique and permanent identifier attached to a item that can be used to uniquely identify a item within an image even between sessions.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Jay Cox",
                                         "Jay Cox",
                                         "1998");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_uint ("tattoo",
                                                      "tattoo",
                                                      "The item tattoo",
                                                      1, G_MAXUINT32, 1,
                                                      PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-set-tattoo
   */
  procedure = pika_procedure_new (item_set_tattoo_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-set-tattoo");
  pika_procedure_set_static_help (procedure,
                                  "Set the tattoo of the specified item.",
                                  "This procedure sets the specified item's tattoo. A tattoo is a unique and permanent identifier attached to a item that can be used to uniquely identify a item within an image even between sessions.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Jay Cox",
                                         "Jay Cox",
                                         "1998");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_uint ("tattoo",
                                                  "tattoo",
                                                  "The new item tattoo",
                                                  1, G_MAXUINT32, 1,
                                                  PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-attach-parasite
   */
  procedure = pika_procedure_new (item_attach_parasite_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-attach-parasite");
  pika_procedure_set_static_help (procedure,
                                  "Add a parasite to an item.",
                                  "This procedure attaches a parasite to an item. It has no return values.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Jay Cox",
                                         "Jay Cox",
                                         "1998");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_parasite ("parasite",
                                                         "parasite",
                                                         "The parasite to attach to the item",
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-detach-parasite
   */
  procedure = pika_procedure_new (item_detach_parasite_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-detach-parasite");
  pika_procedure_set_static_help (procedure,
                                  "Removes a parasite from an item.",
                                  "This procedure detaches a parasite from an item. It has no return values.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Jay Cox",
                                         "Jay Cox",
                                         "1998");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_string ("name",
                                                       "name",
                                                       "The name of the parasite to detach from the item.",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-get-parasite
   */
  procedure = pika_procedure_new (item_get_parasite_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-get-parasite");
  pika_procedure_set_static_help (procedure,
                                  "Look up a parasite in an item",
                                  "Finds and returns the parasite that is attached to an item.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Jay Cox",
                                         "Jay Cox",
                                         "1998");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_string ("name",
                                                       "name",
                                                       "The name of the parasite to find",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_parasite ("parasite",
                                                             "parasite",
                                                             "The found parasite",
                                                             PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-item-get-parasite-list
   */
  procedure = pika_procedure_new (item_get_parasite_list_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-item-get-parasite-list");
  pika_procedure_set_static_help (procedure,
                                  "List all parasites.",
                                  "Returns a list of all parasites currently attached the an item.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marc Lehmann",
                                         "Marc Lehmann",
                                         "1999");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_item ("item",
                                                     "item",
                                                     "The item",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boxed ("parasites",
                                                       "parasites",
                                                       "The names of currently attached parasites",
                                                       G_TYPE_STRV,
                                                       PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);
}
