484 lines
20 KiB
C
484 lines
20 KiB
C
/* 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 "pdb-types.h"
|
|
|
|
#include "cairo.h"
|
|
#include "core/pikaguide.h"
|
|
#include "core/pikaimage-guides.h"
|
|
#include "core/pikaimage-undo-push.h"
|
|
#include "core/pikaimage.h"
|
|
#include "core/pikaparamspecs.h"
|
|
|
|
#include "pikapdb.h"
|
|
#include "pikapdberror.h"
|
|
#include "pikapdb-utils.h"
|
|
#include "pikaprocedure.h"
|
|
#include "internal-procs.h"
|
|
|
|
#include "pika-intl.h"
|
|
|
|
|
|
static PikaValueArray *
|
|
image_add_hguide_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaImage *image;
|
|
gint yposition;
|
|
guint guide = 0;
|
|
|
|
image = g_value_get_object (pika_value_array_index (args, 0));
|
|
yposition = g_value_get_int (pika_value_array_index (args, 1));
|
|
|
|
if (success)
|
|
{
|
|
if (yposition <= pika_image_get_height (image))
|
|
{
|
|
PikaGuide *g;
|
|
|
|
g = pika_image_add_hguide (image, yposition, TRUE);
|
|
guide = pika_aux_item_get_id (PIKA_AUX_ITEM (g));
|
|
}
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
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), guide);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
image_add_vguide_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaImage *image;
|
|
gint xposition;
|
|
guint guide = 0;
|
|
|
|
image = g_value_get_object (pika_value_array_index (args, 0));
|
|
xposition = g_value_get_int (pika_value_array_index (args, 1));
|
|
|
|
if (success)
|
|
{
|
|
if (xposition <= pika_image_get_width (image))
|
|
{
|
|
PikaGuide *g;
|
|
|
|
g = pika_image_add_vguide (image, xposition, TRUE);
|
|
guide = pika_aux_item_get_id (PIKA_AUX_ITEM (g));
|
|
}
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
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), guide);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
image_delete_guide_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaImage *image;
|
|
guint guide;
|
|
|
|
image = g_value_get_object (pika_value_array_index (args, 0));
|
|
guide = g_value_get_uint (pika_value_array_index (args, 1));
|
|
|
|
if (success)
|
|
{
|
|
PikaGuide *g = pika_pdb_image_get_guide (image, guide, error);
|
|
|
|
if (g)
|
|
pika_image_remove_guide (image, g, TRUE);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
return pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
}
|
|
|
|
static PikaValueArray *
|
|
image_find_next_guide_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaImage *image;
|
|
guint guide;
|
|
guint next_guide = 0;
|
|
|
|
image = g_value_get_object (pika_value_array_index (args, 0));
|
|
guide = g_value_get_uint (pika_value_array_index (args, 1));
|
|
|
|
if (success)
|
|
{
|
|
PikaGuide *g = pika_image_get_next_guide (image, guide, &success);
|
|
|
|
if (g)
|
|
next_guide = pika_aux_item_get_id (PIKA_AUX_ITEM (g));
|
|
|
|
if (! success)
|
|
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
|
|
_("Image '%s' (%d) does not contain guide with ID %d"),
|
|
pika_image_get_display_name (image),
|
|
pika_image_get_id (image),
|
|
guide);
|
|
}
|
|
|
|
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), next_guide);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
image_get_guide_orientation_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaImage *image;
|
|
guint guide;
|
|
gint orientation = 0;
|
|
|
|
image = g_value_get_object (pika_value_array_index (args, 0));
|
|
guide = g_value_get_uint (pika_value_array_index (args, 1));
|
|
|
|
if (success)
|
|
{
|
|
PikaGuide *g = pika_pdb_image_get_guide (image, guide, error);
|
|
|
|
if (g)
|
|
orientation = pika_guide_get_orientation (g);
|
|
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), orientation);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
image_get_guide_position_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaImage *image;
|
|
guint guide;
|
|
gint position = 0;
|
|
|
|
image = g_value_get_object (pika_value_array_index (args, 0));
|
|
guide = g_value_get_uint (pika_value_array_index (args, 1));
|
|
|
|
if (success)
|
|
{
|
|
PikaGuide *g = pika_pdb_image_get_guide (image, guide, error);
|
|
|
|
if (g)
|
|
position = pika_guide_get_position (g);
|
|
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), position);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
void
|
|
register_image_guides_procs (PikaPDB *pdb)
|
|
{
|
|
PikaProcedure *procedure;
|
|
|
|
/*
|
|
* pika-image-add-hguide
|
|
*/
|
|
procedure = pika_procedure_new (image_add_hguide_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-image-add-hguide");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Add a horizontal guide to an image.",
|
|
"This procedure adds a horizontal guide to an image. It takes the input image and the y-position of the new guide as parameters. It returns the guide ID of the new guide.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Adam D. Moss",
|
|
"Adam D. Moss",
|
|
"1998");
|
|
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_int ("yposition",
|
|
"yposition",
|
|
"The guide's y-offset from top of image",
|
|
0, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_uint ("guide",
|
|
"guide",
|
|
"The new guide",
|
|
1, G_MAXUINT32, 1,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-image-add-vguide
|
|
*/
|
|
procedure = pika_procedure_new (image_add_vguide_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-image-add-vguide");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Add a vertical guide to an image.",
|
|
"This procedure adds a vertical guide to an image. It takes the input image and the x-position of the new guide as parameters. It returns the guide ID of the new guide.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Adam D. Moss",
|
|
"Adam D. Moss",
|
|
"1998");
|
|
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_int ("xposition",
|
|
"xposition",
|
|
"The guide's x-offset from left of image",
|
|
0, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_uint ("guide",
|
|
"guide",
|
|
"The new guide",
|
|
1, G_MAXUINT32, 1,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-image-delete-guide
|
|
*/
|
|
procedure = pika_procedure_new (image_delete_guide_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-image-delete-guide");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Deletes a guide from an image.",
|
|
"This procedure takes an image and a guide ID as input and removes the specified guide from the specified image.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Adam D. Moss",
|
|
"Adam D. Moss",
|
|
"1998");
|
|
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_uint ("guide",
|
|
"guide",
|
|
"The ID of the guide to be removed",
|
|
1, G_MAXUINT32, 1,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-image-find-next-guide
|
|
*/
|
|
procedure = pika_procedure_new (image_find_next_guide_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-image-find-next-guide");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Find next guide on an image.",
|
|
"This procedure takes an image and a guide ID as input and finds the guide ID of the successor of the given guide ID in the image's guide list. If the supplied guide ID is 0, the procedure will return the first Guide. The procedure will return 0 if given the final guide ID as an argument or the image has no guides.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Adam D. Moss",
|
|
"Adam D. Moss",
|
|
"1998");
|
|
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_uint ("guide",
|
|
"guide",
|
|
"The ID of the current guide (0 if first invocation)",
|
|
1, G_MAXUINT32, 1,
|
|
PIKA_PARAM_READWRITE | PIKA_PARAM_NO_VALIDATE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_uint ("next-guide",
|
|
"next guide",
|
|
"The next guide's ID",
|
|
1, G_MAXUINT32, 1,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-image-get-guide-orientation
|
|
*/
|
|
procedure = pika_procedure_new (image_get_guide_orientation_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-image-get-guide-orientation");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Get orientation of a guide on an image.",
|
|
"This procedure takes an image and a guide ID as input and returns the orientations of the guide.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Adam D. Moss",
|
|
"Adam D. Moss",
|
|
"1998");
|
|
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_uint ("guide",
|
|
"guide",
|
|
"The guide",
|
|
1, G_MAXUINT32, 1,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
pika_param_spec_enum ("orientation",
|
|
"orientation",
|
|
"The guide's orientation",
|
|
PIKA_TYPE_ORIENTATION_TYPE,
|
|
PIKA_ORIENTATION_HORIZONTAL,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_param_spec_enum_exclude_value (PIKA_PARAM_SPEC_ENUM (procedure->values[0]),
|
|
PIKA_ORIENTATION_UNKNOWN);
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-image-get-guide-position
|
|
*/
|
|
procedure = pika_procedure_new (image_get_guide_position_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-image-get-guide-position");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Get position of a guide on an image.",
|
|
"This procedure takes an image and a guide ID as input and returns the position of the guide relative to the top or left of the image.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Adam D. Moss",
|
|
"Adam D. Moss",
|
|
"1998");
|
|
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_uint ("guide",
|
|
"guide",
|
|
"The guide",
|
|
1, G_MAXUINT32, 1,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("position",
|
|
"position",
|
|
"The guide's position relative to top or left of image",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
}
|