/* 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 <cairo.h>

#include <gegl.h>

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

#include "libpikabase/pikabaseenums.h"
#include "libpikacolor/pikacolor.h"

#include "libpikabase/pikabase.h"

#include "pdb-types.h"

#include "core/pikagrid.h"
#include "core/pikaimage-grid.h"
#include "core/pikaimage.h"
#include "core/pikaparamspecs.h"

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


static PikaValueArray *
image_grid_get_spacing_invoker (PikaProcedure         *procedure,
                                Pika                  *pika,
                                PikaContext           *context,
                                PikaProgress          *progress,
                                const PikaValueArray  *args,
                                GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaImage *image;
  gdouble xspacing = 0.0;
  gdouble yspacing = 0.0;

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

  if (success)
    {
      PikaGrid *grid = pika_image_get_grid (image);

      if (grid)
        g_object_get (grid,
                      "xspacing", &xspacing,
                      "yspacing", &yspacing,
                      NULL);
      else
        success = FALSE;
    }

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

  if (success)
    {
      g_value_set_double (pika_value_array_index (return_vals, 1), xspacing);
      g_value_set_double (pika_value_array_index (return_vals, 2), yspacing);
    }

  return return_vals;
}

static PikaValueArray *
image_grid_set_spacing_invoker (PikaProcedure         *procedure,
                                Pika                  *pika,
                                PikaContext           *context,
                                PikaProgress          *progress,
                                const PikaValueArray  *args,
                                GError               **error)
{
  gboolean success = TRUE;
  PikaImage *image;
  gdouble xspacing;
  gdouble yspacing;

  image = g_value_get_object (pika_value_array_index (args, 0));
  xspacing = g_value_get_double (pika_value_array_index (args, 1));
  yspacing = g_value_get_double (pika_value_array_index (args, 2));

  if (success)
    {
      PikaGrid *grid = pika_image_get_grid (image);

      if (grid)
        g_object_set (grid,
                      "xspacing", xspacing,
                      "yspacing", yspacing,
                      NULL);
      else
        success = FALSE;
    }

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

static PikaValueArray *
image_grid_get_offset_invoker (PikaProcedure         *procedure,
                               Pika                  *pika,
                               PikaContext           *context,
                               PikaProgress          *progress,
                               const PikaValueArray  *args,
                               GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaImage *image;
  gdouble xoffset = 0.0;
  gdouble yoffset = 0.0;

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

  if (success)
    {
      PikaGrid *grid = pika_image_get_grid (image);

      if (grid)
        g_object_get (grid,
                      "xoffset", &xoffset,
                      "yoffset", &yoffset,
                      NULL);
      else
        success = FALSE;
    }

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

  if (success)
    {
      g_value_set_double (pika_value_array_index (return_vals, 1), xoffset);
      g_value_set_double (pika_value_array_index (return_vals, 2), yoffset);
    }

  return return_vals;
}

static PikaValueArray *
image_grid_set_offset_invoker (PikaProcedure         *procedure,
                               Pika                  *pika,
                               PikaContext           *context,
                               PikaProgress          *progress,
                               const PikaValueArray  *args,
                               GError               **error)
{
  gboolean success = TRUE;
  PikaImage *image;
  gdouble xoffset;
  gdouble yoffset;

  image = g_value_get_object (pika_value_array_index (args, 0));
  xoffset = g_value_get_double (pika_value_array_index (args, 1));
  yoffset = g_value_get_double (pika_value_array_index (args, 2));

  if (success)
    {
      PikaGrid *grid = pika_image_get_grid (image);

      if (grid)
        g_object_set (grid,
                      "xoffset", xoffset,
                      "yoffset", yoffset,
                      NULL);
      else
        success = FALSE;
    }

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

static PikaValueArray *
image_grid_get_foreground_color_invoker (PikaProcedure         *procedure,
                                         Pika                  *pika,
                                         PikaContext           *context,
                                         PikaProgress          *progress,
                                         const PikaValueArray  *args,
                                         GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaImage *image;
  PikaRGB fgcolor = { 0.0, 0.0, 0.0, 1.0 };

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

  if (success)
    {
      PikaGrid *grid = pika_image_get_grid (image);

      if (grid)
        fgcolor = grid->fgcolor;
      else
        success = FALSE;
    }

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

  if (success)
    pika_value_set_rgb (pika_value_array_index (return_vals, 1), &fgcolor);

  return return_vals;
}

static PikaValueArray *
image_grid_set_foreground_color_invoker (PikaProcedure         *procedure,
                                         Pika                  *pika,
                                         PikaContext           *context,
                                         PikaProgress          *progress,
                                         const PikaValueArray  *args,
                                         GError               **error)
{
  gboolean success = TRUE;
  PikaImage *image;
  PikaRGB fgcolor;

  image = g_value_get_object (pika_value_array_index (args, 0));
  pika_value_get_rgb (pika_value_array_index (args, 1), &fgcolor);

  if (success)
    {
      PikaGrid *grid = pika_image_get_grid (image);

      if (grid)
        g_object_set (grid, "fgcolor", &fgcolor, NULL);
      else
        success = FALSE;
    }

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

static PikaValueArray *
image_grid_get_background_color_invoker (PikaProcedure         *procedure,
                                         Pika                  *pika,
                                         PikaContext           *context,
                                         PikaProgress          *progress,
                                         const PikaValueArray  *args,
                                         GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaImage *image;
  PikaRGB bgcolor = { 0.0, 0.0, 0.0, 1.0 };

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

  if (success)
    {
      PikaGrid *grid = pika_image_get_grid (image);

      if (grid)
        bgcolor = grid->bgcolor;
      else
        success = FALSE;
    }

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

  if (success)
    pika_value_set_rgb (pika_value_array_index (return_vals, 1), &bgcolor);

  return return_vals;
}

static PikaValueArray *
image_grid_set_background_color_invoker (PikaProcedure         *procedure,
                                         Pika                  *pika,
                                         PikaContext           *context,
                                         PikaProgress          *progress,
                                         const PikaValueArray  *args,
                                         GError               **error)
{
  gboolean success = TRUE;
  PikaImage *image;
  PikaRGB bgcolor;

  image = g_value_get_object (pika_value_array_index (args, 0));
  pika_value_get_rgb (pika_value_array_index (args, 1), &bgcolor);

  if (success)
    {
      PikaGrid *grid = pika_image_get_grid (image);

      if (grid)
        g_object_set (grid, "bgcolor", &bgcolor, NULL);
      else
        success = FALSE;
    }

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

static PikaValueArray *
image_grid_get_style_invoker (PikaProcedure         *procedure,
                              Pika                  *pika,
                              PikaContext           *context,
                              PikaProgress          *progress,
                              const PikaValueArray  *args,
                              GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaImage *image;
  gint style = 0;

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

  if (success)
    {
      PikaGrid *grid = pika_image_get_grid (image);

      if (grid)
        g_object_get (grid, "style", &style, NULL);
      else
        success = FALSE;
    }

  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), style);

  return return_vals;
}

static PikaValueArray *
image_grid_set_style_invoker (PikaProcedure         *procedure,
                              Pika                  *pika,
                              PikaContext           *context,
                              PikaProgress          *progress,
                              const PikaValueArray  *args,
                              GError               **error)
{
  gboolean success = TRUE;
  PikaImage *image;
  gint style;

  image = g_value_get_object (pika_value_array_index (args, 0));
  style = g_value_get_enum (pika_value_array_index (args, 1));

  if (success)
    {
      PikaGrid *grid = pika_image_get_grid (image);

      if (grid)
        g_object_set (grid, "style", style, NULL);
      else
        success = FALSE;
    }

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

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

  /*
   * pika-image-grid-get-spacing
   */
  procedure = pika_procedure_new (image_grid_get_spacing_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-image-grid-get-spacing");
  pika_procedure_set_static_help (procedure,
                                  "Gets the spacing of an image's grid.",
                                  "This procedure retrieves the horizontal and vertical spacing of an image's grid. It takes the image as parameter.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Sylvain Foret",
                                         "Sylvain Foret",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_double ("xspacing",
                                                        "xspacing",
                                                        "The image's grid horizontal spacing",
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_double ("yspacing",
                                                        "yspacing",
                                                        "The image's grid vertical spacing",
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                        PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-image-grid-set-spacing
   */
  procedure = pika_procedure_new (image_grid_set_spacing_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-image-grid-set-spacing");
  pika_procedure_set_static_help (procedure,
                                  "Sets the spacing of an image's grid.",
                                  "This procedure sets the horizontal and vertical spacing of an image's grid.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Sylvain Foret",
                                         "Sylvain Foret",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("xspacing",
                                                    "xspacing",
                                                    "The image's grid horizontal spacing",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("yspacing",
                                                    "yspacing",
                                                    "The image's grid vertical spacing",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-image-grid-get-offset
   */
  procedure = pika_procedure_new (image_grid_get_offset_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-image-grid-get-offset");
  pika_procedure_set_static_help (procedure,
                                  "Gets the offset of an image's grid.",
                                  "This procedure retrieves the horizontal and vertical offset of an image's grid. It takes the image as parameter.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Sylvain Foret",
                                         "Sylvain Foret",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_double ("xoffset",
                                                        "xoffset",
                                                        "The image's grid horizontal offset",
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_double ("yoffset",
                                                        "yoffset",
                                                        "The image's grid vertical offset",
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                        PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-image-grid-set-offset
   */
  procedure = pika_procedure_new (image_grid_set_offset_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-image-grid-set-offset");
  pika_procedure_set_static_help (procedure,
                                  "Sets the offset of an image's grid.",
                                  "This procedure sets the horizontal and vertical offset of an image's grid.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Sylvain Foret",
                                         "Sylvain Foret",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("xoffset",
                                                    "xoffset",
                                                    "The image's grid horizontal offset",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("yoffset",
                                                    "yoffset",
                                                    "The image's grid vertical offset",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-image-grid-get-foreground-color
   */
  procedure = pika_procedure_new (image_grid_get_foreground_color_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-image-grid-get-foreground-color");
  pika_procedure_set_static_help (procedure,
                                  "Sets the foreground color of an image's grid.",
                                  "This procedure gets the foreground color of an image's grid.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Sylvain Foret",
                                         "Sylvain Foret",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_rgb ("fgcolor",
                                                        "fgcolor",
                                                        "The image's grid foreground color",
                                                        TRUE,
                                                        NULL,
                                                        PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-image-grid-set-foreground-color
   */
  procedure = pika_procedure_new (image_grid_set_foreground_color_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-image-grid-set-foreground-color");
  pika_procedure_set_static_help (procedure,
                                  "Gets the foreground color of an image's grid.",
                                  "This procedure sets the foreground color of an image's grid.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Sylvain Foret",
                                         "Sylvain Foret",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_rgb ("fgcolor",
                                                    "fgcolor",
                                                    "The new foreground color",
                                                    TRUE,
                                                    NULL,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-image-grid-get-background-color
   */
  procedure = pika_procedure_new (image_grid_get_background_color_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-image-grid-get-background-color");
  pika_procedure_set_static_help (procedure,
                                  "Sets the background color of an image's grid.",
                                  "This procedure gets the background color of an image's grid.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Sylvain Foret",
                                         "Sylvain Foret",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_rgb ("bgcolor",
                                                        "bgcolor",
                                                        "The image's grid background color",
                                                        TRUE,
                                                        NULL,
                                                        PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-image-grid-set-background-color
   */
  procedure = pika_procedure_new (image_grid_set_background_color_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-image-grid-set-background-color");
  pika_procedure_set_static_help (procedure,
                                  "Gets the background color of an image's grid.",
                                  "This procedure sets the background color of an image's grid.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Sylvain Foret",
                                         "Sylvain Foret",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_rgb ("bgcolor",
                                                    "bgcolor",
                                                    "The new background color",
                                                    TRUE,
                                                    NULL,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-image-grid-get-style
   */
  procedure = pika_procedure_new (image_grid_get_style_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-image-grid-get-style");
  pika_procedure_set_static_help (procedure,
                                  "Gets the style of an image's grid.",
                                  "This procedure retrieves the style of an image's grid.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Sylvain Foret",
                                         "Sylvain Foret",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_enum ("style",
                                                      "style",
                                                      "The image's grid style",
                                                      PIKA_TYPE_GRID_STYLE,
                                                      PIKA_GRID_DOTS,
                                                      PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-image-grid-set-style
   */
  procedure = pika_procedure_new (image_grid_set_style_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-image-grid-set-style");
  pika_procedure_set_static_help (procedure,
                                  "Sets the style unit of an image's grid.",
                                  "This procedure sets the style of an image's grid. It takes the image and the new style as parameters.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Sylvain Foret",
                                         "Sylvain Foret",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_enum ("style",
                                                  "style",
                                                  "The image's grid style",
                                                  PIKA_TYPE_GRID_STYLE,
                                                  PIKA_GRID_DOTS,
                                                  PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);
}
