mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-23 13:01:42 +00:00
f65bd53e58
2006-04-26 Michael Natterer <mitch@gimp.org> * app/pdb/Makefile.am * app/pdb/pdb-types.h * app/pdb/gimppdb.[ch]: new object GimpPDB which keeps all procedures and functions to register and run them. Renamed all functions and did some cleanups. * app/pdb/gimp-pdb.[ch] * app/core/gimp.[ch]: removed the same stuff here. * app/pdb/gimp-pdb-query.[ch]: removed these files... * app/pdb/gimppdb-query.[ch]: ...added here as members of GimpPDB. * app/pdb/gimp-pdb-compat.h: fix include guard. * app/batch.c * app/actions/vectors-commands.c * app/dialogs/about-dialog.c * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-in-message.c * app/plug-in/plug-ins.c * app/widgets/gimpfiledialog.c * app/widgets/gimphelp.c * app/xcf/xcf.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/font_select.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/palette_select.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/procedural_db.pdb: changed includes and function calls accordingly. * tools/pdbgen/app.pl: pass around GimpPDB instead of Gimp pointers to register the internal procedures with. Changed some newlines in the generated code. * app/pdb/*_cmds.c * app/pdb/internal_procs.[ch]: regenerated. * app/core/gimppdbprogress.[ch] * app/widgets/gimppdbdialog.[ch]: added "pdb" CONSTRUCT_ONLY properties. * app/plug-in/plug-in-progress.c * app/gui/gui-vtable.c: pass gimp->pdb when creating them. * app/widgets/gimpbrushselect.c * app/widgets/gimpfontselect.c * app/widgets/gimpgradientselect.c * app/widgets/gimppaletteselect.c * app/widgets/gimppatternselect.c: use the new local pdb pointers instead of some foo->bar->gimp->pdb overkill.
443 lines
18 KiB
C
443 lines
18 KiB
C
/* The GIMP -- an image manipulation program
|
|
* 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 2 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, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
/* NOTE: This file is autogenerated by pdbgen.pl. */
|
|
|
|
#include "config.h"
|
|
|
|
|
|
#include <glib-object.h>
|
|
|
|
#include "pdb-types.h"
|
|
#include "gimppdb.h"
|
|
#include "gimpprocedure.h"
|
|
#include "core/gimpparamspecs.h"
|
|
|
|
#include "core/gimpimage-guides.h"
|
|
#include "core/gimpimage-undo-push.h"
|
|
#include "core/gimpimage.h"
|
|
|
|
|
|
static GValueArray *
|
|
image_add_hguide_invoker (GimpProcedure *procedure,
|
|
Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
const GValueArray *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
GValueArray *return_vals;
|
|
GimpImage *image;
|
|
gint32 yposition;
|
|
gint32 guide = 0;
|
|
|
|
image = gimp_value_get_image (&args->values[0], gimp);
|
|
yposition = g_value_get_int (&args->values[1]);
|
|
|
|
if (success)
|
|
{
|
|
if (yposition <= image->height)
|
|
{
|
|
GimpGuide *g;
|
|
|
|
g = gimp_image_add_hguide (image, yposition, TRUE);
|
|
guide = g->guide_ID;
|
|
}
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success);
|
|
|
|
if (success)
|
|
g_value_set_uint (&return_vals->values[1], guide);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static GValueArray *
|
|
image_add_vguide_invoker (GimpProcedure *procedure,
|
|
Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
const GValueArray *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
GValueArray *return_vals;
|
|
GimpImage *image;
|
|
gint32 xposition;
|
|
gint32 guide = 0;
|
|
|
|
image = gimp_value_get_image (&args->values[0], gimp);
|
|
xposition = g_value_get_int (&args->values[1]);
|
|
|
|
if (success)
|
|
{
|
|
if (xposition <= image->width)
|
|
{
|
|
GimpGuide *g;
|
|
|
|
g = gimp_image_add_vguide (image, xposition, TRUE);
|
|
guide = g->guide_ID;
|
|
}
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success);
|
|
|
|
if (success)
|
|
g_value_set_uint (&return_vals->values[1], guide);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static GValueArray *
|
|
image_delete_guide_invoker (GimpProcedure *procedure,
|
|
Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
const GValueArray *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
GimpImage *image;
|
|
gint32 guide;
|
|
|
|
image = gimp_value_get_image (&args->values[0], gimp);
|
|
guide = g_value_get_uint (&args->values[1]);
|
|
|
|
if (success)
|
|
{
|
|
GimpGuide *g = gimp_image_get_guide (image, guide);
|
|
|
|
if (g)
|
|
gimp_image_remove_guide (image, g, TRUE);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
return gimp_procedure_get_return_values (procedure, success);
|
|
}
|
|
|
|
static GValueArray *
|
|
image_find_next_guide_invoker (GimpProcedure *procedure,
|
|
Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
const GValueArray *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
GValueArray *return_vals;
|
|
GimpImage *image;
|
|
gint32 guide;
|
|
gint32 next_guide = 0;
|
|
|
|
image = gimp_value_get_image (&args->values[0], gimp);
|
|
guide = g_value_get_uint (&args->values[1]);
|
|
|
|
if (success)
|
|
{
|
|
GimpGuide *g = gimp_image_get_next_guide (image, guide, &success);
|
|
|
|
if (g)
|
|
next_guide = g->guide_ID;
|
|
}
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success);
|
|
|
|
if (success)
|
|
g_value_set_uint (&return_vals->values[1], next_guide);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static GValueArray *
|
|
image_get_guide_orientation_invoker (GimpProcedure *procedure,
|
|
Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
const GValueArray *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
GValueArray *return_vals;
|
|
GimpImage *image;
|
|
gint32 guide;
|
|
gint32 orientation = 0;
|
|
|
|
image = gimp_value_get_image (&args->values[0], gimp);
|
|
guide = g_value_get_uint (&args->values[1]);
|
|
|
|
if (success)
|
|
{
|
|
GimpGuide *g = gimp_image_get_guide (image, guide);
|
|
|
|
if (g)
|
|
orientation = g->orientation;
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success);
|
|
|
|
if (success)
|
|
g_value_set_enum (&return_vals->values[1], orientation);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static GValueArray *
|
|
image_get_guide_position_invoker (GimpProcedure *procedure,
|
|
Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
const GValueArray *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
GValueArray *return_vals;
|
|
GimpImage *image;
|
|
gint32 guide;
|
|
gint32 position = 0;
|
|
|
|
image = gimp_value_get_image (&args->values[0], gimp);
|
|
guide = g_value_get_uint (&args->values[1]);
|
|
|
|
if (success)
|
|
{
|
|
GimpGuide *g = gimp_image_get_guide (image, guide);
|
|
|
|
if (g)
|
|
position = g->position;
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success);
|
|
|
|
if (success)
|
|
g_value_set_int (&return_vals->values[1], position);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
void
|
|
register_guides_procs (GimpPDB *pdb)
|
|
{
|
|
GimpProcedure *procedure;
|
|
|
|
/*
|
|
* gimp-image-add-hguide
|
|
*/
|
|
procedure = gimp_procedure_new (image_add_hguide_invoker);
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-image-add-hguide");
|
|
gimp_procedure_set_static_strings (procedure,
|
|
"gimp-image-add-hguide",
|
|
"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.",
|
|
"Adam D. Moss",
|
|
"Adam D. Moss",
|
|
"1998",
|
|
NULL);
|
|
gimp_procedure_add_argument (procedure,
|
|
gimp_param_spec_image_id ("image",
|
|
"image",
|
|
"The image",
|
|
pdb->gimp,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_argument (procedure,
|
|
gimp_param_spec_int32 ("yposition",
|
|
"yposition",
|
|
"The guide's y-offset from top of image",
|
|
0, G_MAXINT32, 0,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_return_value (procedure,
|
|
g_param_spec_uint ("guide",
|
|
"guide",
|
|
"The new guide",
|
|
1, G_MAXUINT32, 1,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* gimp-image-add-vguide
|
|
*/
|
|
procedure = gimp_procedure_new (image_add_vguide_invoker);
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-image-add-vguide");
|
|
gimp_procedure_set_static_strings (procedure,
|
|
"gimp-image-add-vguide",
|
|
"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.",
|
|
"Adam D. Moss",
|
|
"Adam D. Moss",
|
|
"1998",
|
|
NULL);
|
|
gimp_procedure_add_argument (procedure,
|
|
gimp_param_spec_image_id ("image",
|
|
"image",
|
|
"The image",
|
|
pdb->gimp,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_argument (procedure,
|
|
gimp_param_spec_int32 ("xposition",
|
|
"xposition",
|
|
"The guide's x-offset from left of image",
|
|
0, G_MAXINT32, 0,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_return_value (procedure,
|
|
g_param_spec_uint ("guide",
|
|
"guide",
|
|
"The new guide",
|
|
1, G_MAXUINT32, 1,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* gimp-image-delete-guide
|
|
*/
|
|
procedure = gimp_procedure_new (image_delete_guide_invoker);
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-image-delete-guide");
|
|
gimp_procedure_set_static_strings (procedure,
|
|
"gimp-image-delete-guide",
|
|
"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.",
|
|
"Adam D. Moss",
|
|
"Adam D. Moss",
|
|
"1998",
|
|
NULL);
|
|
gimp_procedure_add_argument (procedure,
|
|
gimp_param_spec_image_id ("image",
|
|
"image",
|
|
"The image",
|
|
pdb->gimp,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_argument (procedure,
|
|
g_param_spec_uint ("guide",
|
|
"guide",
|
|
"The ID of the guide to be removed",
|
|
1, G_MAXUINT32, 1,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* gimp-image-find-next-guide
|
|
*/
|
|
procedure = gimp_procedure_new (image_find_next_guide_invoker);
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-image-find-next-guide");
|
|
gimp_procedure_set_static_strings (procedure,
|
|
"gimp-image-find-next-guide",
|
|
"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.",
|
|
"Adam D. Moss",
|
|
"Adam D. Moss",
|
|
"1998",
|
|
NULL);
|
|
gimp_procedure_add_argument (procedure,
|
|
gimp_param_spec_image_id ("image",
|
|
"image",
|
|
"The image",
|
|
pdb->gimp,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_argument (procedure,
|
|
g_param_spec_uint ("guide",
|
|
"guide",
|
|
"The ID of the current guide (0 if first invocation)",
|
|
1, G_MAXUINT32, 1,
|
|
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
|
|
gimp_procedure_add_return_value (procedure,
|
|
g_param_spec_uint ("next-guide",
|
|
"next guide",
|
|
"The next guide's ID",
|
|
1, G_MAXUINT32, 1,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* gimp-image-get-guide-orientation
|
|
*/
|
|
procedure = gimp_procedure_new (image_get_guide_orientation_invoker);
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-image-get-guide-orientation");
|
|
gimp_procedure_set_static_strings (procedure,
|
|
"gimp-image-get-guide-orientation",
|
|
"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.",
|
|
"Adam D. Moss",
|
|
"Adam D. Moss",
|
|
"1998",
|
|
NULL);
|
|
gimp_procedure_add_argument (procedure,
|
|
gimp_param_spec_image_id ("image",
|
|
"image",
|
|
"The image",
|
|
pdb->gimp,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_argument (procedure,
|
|
g_param_spec_uint ("guide",
|
|
"guide",
|
|
"The guide",
|
|
1, G_MAXUINT32, 1,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_return_value (procedure,
|
|
gimp_param_spec_enum ("orientation",
|
|
"orientation",
|
|
"The guide's orientation: { GIMP_ORIENTATION_HORIZONTAL (0), GIMP_ORIENTATION_VERTICAL (1) }",
|
|
GIMP_TYPE_ORIENTATION_TYPE,
|
|
GIMP_ORIENTATION_HORIZONTAL,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->values[0]),
|
|
GIMP_ORIENTATION_UNKNOWN);
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* gimp-image-get-guide-position
|
|
*/
|
|
procedure = gimp_procedure_new (image_get_guide_position_invoker);
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-image-get-guide-position");
|
|
gimp_procedure_set_static_strings (procedure,
|
|
"gimp-image-get-guide-position",
|
|
"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.",
|
|
"Adam D. Moss",
|
|
"Adam D. Moss",
|
|
"1998",
|
|
NULL);
|
|
gimp_procedure_add_argument (procedure,
|
|
gimp_param_spec_image_id ("image",
|
|
"image",
|
|
"The image",
|
|
pdb->gimp,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_argument (procedure,
|
|
g_param_spec_uint ("guide",
|
|
"guide",
|
|
"The guide",
|
|
1, G_MAXUINT32, 1,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_return_value (procedure,
|
|
gimp_param_spec_int32 ("position",
|
|
"position",
|
|
"The guide's position relative to top or left of image",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
}
|