gimp/app/pdb/edit_cmds.c

1383 lines
59 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 <string.h>
#include <glib-object.h>
#include "pdb-types.h"
#include "gimpargument.h"
#include "gimpprocedure.h"
#include "procedural_db.h"
#include "core/gimpparamspecs.h"
#include "core/gimp-edit.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontainer.h"
#include "core/gimpdrawable-blend.h"
#include "core/gimpdrawable-bucket-fill.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "core/gimpprogress.h"
#include "core/gimpstrokedesc.h"
#include "gimp-intl.h"
static GimpProcedure edit_cut_proc;
static GimpProcedure edit_copy_proc;
static GimpProcedure edit_copy_visible_proc;
static GimpProcedure edit_paste_proc;
static GimpProcedure edit_paste_as_new_proc;
static GimpProcedure edit_named_cut_proc;
static GimpProcedure edit_named_copy_proc;
static GimpProcedure edit_named_copy_visible_proc;
static GimpProcedure edit_named_paste_proc;
static GimpProcedure edit_named_paste_as_new_proc;
static GimpProcedure edit_clear_proc;
static GimpProcedure edit_fill_proc;
static GimpProcedure edit_bucket_fill_proc;
static GimpProcedure edit_blend_proc;
static GimpProcedure edit_stroke_proc;
void
register_edit_procs (Gimp *gimp)
{
GimpProcedure *procedure;
/*
* edit_cut
*/
procedure = gimp_procedure_init (&edit_cut_proc, 1, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_DRAWABLE,
gimp_param_spec_item_id ("drawable",
"drawable",
"The drawable to cut from",
gimp,
GIMP_TYPE_DRAWABLE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("non-empty",
"non empty",
"TRUE if the cut was successful, FALSE if the selection contained only transparent pixels",
FALSE,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* edit_copy
*/
procedure = gimp_procedure_init (&edit_copy_proc, 1, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_DRAWABLE,
gimp_param_spec_item_id ("drawable",
"drawable",
"The drawable to copy from",
gimp,
GIMP_TYPE_DRAWABLE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("non-empty",
"non empty",
"TRUE if the copy was successful, FALSE if the selection contained only transparent pixels",
FALSE,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* edit_copy_visible
*/
procedure = gimp_procedure_init (&edit_copy_visible_proc, 1, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image to copy from",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("non-empty",
"non empty",
"TRUE if the copy was successful, FALSE if the selection contained only transparent pixels",
FALSE,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* edit_paste
*/
procedure = gimp_procedure_init (&edit_paste_proc, 2, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_DRAWABLE,
gimp_param_spec_item_id ("drawable",
"drawable",
"The drawable to paste to",
gimp,
GIMP_TYPE_DRAWABLE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("paste-into",
"paste into",
"Clear selection, or paste behind it?",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_LAYER,
gimp_param_spec_item_id ("floating-sel",
"floating sel",
"The new floating selection",
gimp,
GIMP_TYPE_LAYER,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* edit_paste_as_new
*/
procedure = gimp_procedure_init (&edit_paste_as_new_proc, 0, 1);
gimp_procedure_add_return_value (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The new image",
gimp,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* edit_named_cut
*/
procedure = gimp_procedure_init (&edit_named_cut_proc, 2, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_DRAWABLE,
gimp_param_spec_item_id ("drawable",
"drawable",
"The drawable to cut from",
gimp,
GIMP_TYPE_DRAWABLE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("buffer-name",
"buffer name",
"The name of the buffer to create",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("real-name",
"real name",
"The real name given to the buffer, or NULL if the selection contained only transparent pixels",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* edit_named_copy
*/
procedure = gimp_procedure_init (&edit_named_copy_proc, 2, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_DRAWABLE,
gimp_param_spec_item_id ("drawable",
"drawable",
"The drawable to copy from",
gimp,
GIMP_TYPE_DRAWABLE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("buffer-name",
"buffer name",
"The name of the buffer to create",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("real-name",
"real name",
"The real name given to the buffer, or NULL if the selection contained only transparent pixels",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* edit_named_copy_visible
*/
procedure = gimp_procedure_init (&edit_named_copy_visible_proc, 2, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image to copy from",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("buffer-name",
"buffer name",
"The name of the buffer to create",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("real-name",
"real name",
"The real name given to the buffer",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* edit_named_paste
*/
procedure = gimp_procedure_init (&edit_named_paste_proc, 3, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_DRAWABLE,
gimp_param_spec_item_id ("drawable",
"drawable",
"The drawable to paste to",
gimp,
GIMP_TYPE_DRAWABLE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("buffer-name",
"buffer name",
"The name of the buffer to paste",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("paste-into",
"paste into",
"Clear selection, or paste behind it?",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_LAYER,
gimp_param_spec_item_id ("floating-sel",
"floating sel",
"The new floating selection",
gimp,
GIMP_TYPE_LAYER,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* edit_named_paste_as_new
*/
procedure = gimp_procedure_init (&edit_named_paste_as_new_proc, 1, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("buffer-name",
"buffer name",
"The name of the buffer to paste",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The new image",
gimp,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* edit_clear
*/
procedure = gimp_procedure_init (&edit_clear_proc, 1, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_DRAWABLE,
gimp_param_spec_item_id ("drawable",
"drawable",
"The drawable to clear from",
gimp,
GIMP_TYPE_DRAWABLE,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* edit_fill
*/
procedure = gimp_procedure_init (&edit_fill_proc, 2, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_DRAWABLE,
gimp_param_spec_item_id ("drawable",
"drawable",
"The drawable to fill to",
gimp,
GIMP_TYPE_DRAWABLE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("fill-type",
"fill type",
"The type of fill: { GIMP_FOREGROUND_FILL (0), GIMP_BACKGROUND_FILL (1), GIMP_WHITE_FILL (2), GIMP_TRANSPARENT_FILL (3), GIMP_PATTERN_FILL (4) }",
GIMP_TYPE_FILL_TYPE,
GIMP_FOREGROUND_FILL,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* edit_bucket_fill
*/
procedure = gimp_procedure_init (&edit_bucket_fill_proc, 8, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_DRAWABLE,
gimp_param_spec_item_id ("drawable",
"drawable",
"The affected drawable",
gimp,
GIMP_TYPE_DRAWABLE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("fill-mode",
"fill mode",
"The type of fill: { GIMP_FG_BUCKET_FILL (0), GIMP_BG_BUCKET_FILL (1), GIMP_PATTERN_BUCKET_FILL (2) }",
GIMP_TYPE_BUCKET_FILL_MODE,
GIMP_FG_BUCKET_FILL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("paint-mode",
"paint mode",
"The paint application mode: { GIMP_NORMAL_MODE (0), GIMP_DISSOLVE_MODE (1), GIMP_BEHIND_MODE (2), GIMP_MULTIPLY_MODE (3), GIMP_SCREEN_MODE (4), GIMP_OVERLAY_MODE (5), GIMP_DIFFERENCE_MODE (6), GIMP_ADDITION_MODE (7), GIMP_SUBTRACT_MODE (8), GIMP_DARKEN_ONLY_MODE (9), GIMP_LIGHTEN_ONLY_MODE (10), GIMP_HUE_MODE (11), GIMP_SATURATION_MODE (12), GIMP_COLOR_MODE (13), GIMP_VALUE_MODE (14), GIMP_DIVIDE_MODE (15), GIMP_DODGE_MODE (16), GIMP_BURN_MODE (17), GIMP_HARDLIGHT_MODE (18), GIMP_SOFTLIGHT_MODE (19), GIMP_GRAIN_EXTRACT_MODE (20), GIMP_GRAIN_MERGE_MODE (21), GIMP_COLOR_ERASE_MODE (22) }",
GIMP_TYPE_LAYER_MODE_EFFECTS,
GIMP_NORMAL_MODE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("opacity",
"opacity",
"The opacity of the final bucket fill (0 <= opacity <= 100)",
0, 100, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("threshold",
"threshold",
"The threshold determines how extensive the seed fill will be. It's value is specified in terms of intensity levels (0 <= threshold <= 255). This parameter is only valid when there is no selection in the specified image.",
0, 255, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("sample-merged",
"sample merged",
"Use the composite image, not the drawable",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("x",
"x",
"The x coordinate of this bucket fill's application. This parameter is only valid when there is no selection in the specified image.",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("y",
"y",
"The y coordinate of this bucket fill's application. This parameter is only valid when there is no selection in the specified image.",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* edit_blend
*/
procedure = gimp_procedure_init (&edit_blend_proc, 16, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_DRAWABLE,
gimp_param_spec_item_id ("drawable",
"drawable",
"The affected drawable",
gimp,
GIMP_TYPE_DRAWABLE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("blend-mode",
"blend mode",
"The type of blend: { GIMP_FG_BG_RGB_MODE (0), GIMP_FG_BG_HSV_MODE (1), GIMP_FG_TRANSPARENT_MODE (2), GIMP_CUSTOM_MODE (3) }",
GIMP_TYPE_BLEND_MODE,
GIMP_FG_BG_RGB_MODE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("paint-mode",
"paint mode",
"The paint application mode: { GIMP_NORMAL_MODE (0), GIMP_DISSOLVE_MODE (1), GIMP_BEHIND_MODE (2), GIMP_MULTIPLY_MODE (3), GIMP_SCREEN_MODE (4), GIMP_OVERLAY_MODE (5), GIMP_DIFFERENCE_MODE (6), GIMP_ADDITION_MODE (7), GIMP_SUBTRACT_MODE (8), GIMP_DARKEN_ONLY_MODE (9), GIMP_LIGHTEN_ONLY_MODE (10), GIMP_HUE_MODE (11), GIMP_SATURATION_MODE (12), GIMP_COLOR_MODE (13), GIMP_VALUE_MODE (14), GIMP_DIVIDE_MODE (15), GIMP_DODGE_MODE (16), GIMP_BURN_MODE (17), GIMP_HARDLIGHT_MODE (18), GIMP_SOFTLIGHT_MODE (19), GIMP_GRAIN_EXTRACT_MODE (20), GIMP_GRAIN_MERGE_MODE (21), GIMP_COLOR_ERASE_MODE (22) }",
GIMP_TYPE_LAYER_MODE_EFFECTS,
GIMP_NORMAL_MODE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("gradient-type",
"gradient type",
"The type of gradient: { GIMP_GRADIENT_LINEAR (0), GIMP_GRADIENT_BILINEAR (1), GIMP_GRADIENT_RADIAL (2), GIMP_GRADIENT_SQUARE (3), GIMP_GRADIENT_CONICAL_SYMMETRIC (4), GIMP_GRADIENT_CONICAL_ASYMMETRIC (5), GIMP_GRADIENT_SHAPEBURST_ANGULAR (6), GIMP_GRADIENT_SHAPEBURST_SPHERICAL (7), GIMP_GRADIENT_SHAPEBURST_DIMPLED (8), GIMP_GRADIENT_SPIRAL_CLOCKWISE (9), GIMP_GRADIENT_SPIRAL_ANTICLOCKWISE (10) }",
GIMP_TYPE_GRADIENT_TYPE,
GIMP_GRADIENT_LINEAR,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("opacity",
"opacity",
"The opacity of the final blend (0 <= opacity <= 100)",
0, 100, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("offset",
"offset",
"Offset relates to the starting and ending coordinates specified for the blend. This parameter is mode dependent (0 <= offset)",
0, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("repeat",
"repeat",
"Repeat mode: { GIMP_REPEAT_NONE (0), GIMP_REPEAT_SAWTOOTH (1), GIMP_REPEAT_TRIANGULAR (2) }",
GIMP_TYPE_REPEAT_MODE,
GIMP_REPEAT_NONE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("reverse",
"reverse",
"Use the reverse gradient (TRUE or FALSE)",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("supersample",
"supersample",
"Do adaptive supersampling (TRUE or FALSE)",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("max-depth",
"max depth",
"Maximum recursion levels for supersampling",
1, 9, 1,
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("threshold",
"threshold",
"Supersampling threshold",
0, 4, 0,
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("dither",
"dither",
"Use dithering to reduce banding (TRUE or FALSE)",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("x1",
"x1",
"The x coordinate of this blend's starting point",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("y1",
"y1",
"The y coordinate of this blend's starting point",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("x2",
"x2",
"The x coordinate of this blend's ending point",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("y2",
"y2",
"The y coordinate of this blend's ending point",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* edit_stroke
*/
procedure = gimp_procedure_init (&edit_stroke_proc, 1, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_DRAWABLE,
gimp_param_spec_item_id ("drawable",
"drawable",
"The drawable to stroke to",
gimp,
GIMP_TYPE_DRAWABLE,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
}
static Argument *
edit_cut_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpDrawable *drawable;
gboolean non_empty = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
non_empty = gimp_edit_cut (image, drawable, context) != NULL;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_set_boolean (&return_vals[1].value, non_empty);
return return_vals;
}
static GimpProcedure edit_cut_proc =
{
TRUE, TRUE,
"gimp-edit-cut",
"gimp-edit-cut",
"Cut from the specified drawable.",
"If there is a selection in the image, then the area specified by the selection is cut from the specified drawable and placed in an internal GIMP edit buffer. It can subsequently be retrieved using the 'gimp-edit-paste' command. If there is no selection, then the specified drawable will be removed and its contents stored in the internal GIMP edit buffer.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { edit_cut_invoker } }
};
static Argument *
edit_copy_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpDrawable *drawable;
gboolean non_empty = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
non_empty = gimp_edit_copy (image, drawable, context) != NULL;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_set_boolean (&return_vals[1].value, non_empty);
return return_vals;
}
static GimpProcedure edit_copy_proc =
{
TRUE, TRUE,
"gimp-edit-copy",
"gimp-edit-copy",
"Copy from the specified drawable.",
"If there is a selection in the image, then the area specified by the selection is copied from the specified drawable and placed in an internal GIMP edit buffer. It can subsequently be retrieved using the 'gimp-edit-paste' command. If there is no selection, then the specified drawable's contents will be stored in the internal GIMP edit buffer.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { edit_copy_invoker } }
};
static Argument *
edit_copy_visible_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpImage *image;
gboolean non_empty = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
non_empty = gimp_edit_copy_visible (image, context) != NULL;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_set_boolean (&return_vals[1].value, non_empty);
return return_vals;
}
static GimpProcedure edit_copy_visible_proc =
{
TRUE, TRUE,
"gimp-edit-copy-visible",
"gimp-edit-copy-visible",
"Copy from the projection.",
"If there is a selection in the image, then the area specified by the selection is copied from the projection and placed in an internal GIMP edit buffer. It can subsequently be retrieved using the 'gimp-edit-paste' command. If there is no selection, then the projection's contents will be stored in the internal GIMP edit buffer.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2004",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { edit_copy_visible_invoker } }
};
static Argument *
edit_paste_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpDrawable *drawable;
gboolean paste_into;
GimpLayer *floating_sel = NULL;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
paste_into = g_value_get_boolean (&args[1].value);
if (success)
{
if (gimp->global_buffer && gimp_item_is_attached (GIMP_ITEM (drawable)))
{
floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
drawable, gimp->global_buffer,
paste_into, -1, -1, -1, -1);
if (! floating_sel)
success = FALSE;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (floating_sel));
return return_vals;
}
static GimpProcedure edit_paste_proc =
{
TRUE, TRUE,
"gimp-edit-paste",
"gimp-edit-paste",
"Paste buffer to the specified drawable.",
"This procedure pastes a copy of the internal GIMP edit buffer to the specified drawable. The GIMP edit buffer will be empty unless a call was previously made to either 'gimp-edit-cut' or 'gimp-edit-copy'. The \"paste_into\" option specifies whether to clear the current image selection, or to paste the buffer \"behind\" the selection. This allows the selection to act as a mask for the pasted buffer. Anywhere that the selection mask is non-zero, the pasted buffer will show through. The pasted buffer will be a new layer in the image which is designated as the image floating selection. If the image has a floating selection at the time of pasting, the old floating selection will be anchored to it's drawable before the new floating selection is added. This procedure returns the new floating layer. The resulting floating selection will already be attached to the specified drawable, and a subsequent call to floating_sel_attach is not needed.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { edit_paste_invoker } }
};
static Argument *
edit_paste_as_new_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpImage *image = NULL;
if (gimp->global_buffer)
{
image = gimp_edit_paste_as_new (gimp, NULL, gimp->global_buffer);
if (! image)
success = FALSE;
}
else
success = FALSE;
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
gimp_value_set_image (&return_vals[1].value, image);
return return_vals;
}
static GimpProcedure edit_paste_as_new_proc =
{
TRUE, TRUE,
"gimp-edit-paste-as-new",
"gimp-edit-paste-as-new",
"Paste buffer to a new image.",
"This procedure pastes a copy of the internal GIMP edit buffer to a new image. The GIMP edit buffer will be empty unless a call was previously made to either 'gimp-edit-cut' or 'gimp-edit-copy'. This procedure returns the new image.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2005",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { edit_paste_as_new_invoker } }
};
static Argument *
edit_named_cut_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpDrawable *drawable;
gchar *buffer_name;
gchar *real_name = NULL;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
buffer_name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
if (strlen (buffer_name) && gimp_item_is_attached (GIMP_ITEM (drawable)))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
real_name = (gchar *) gimp_edit_named_cut (image, buffer_name,
drawable, context);
if (real_name)
real_name = g_strdup (real_name);
else
success = FALSE;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_take_string (&return_vals[1].value, real_name);
return return_vals;
}
static GimpProcedure edit_named_cut_proc =
{
TRUE, TRUE,
"gimp-edit-named-cut",
"gimp-edit-named-cut",
"Cut into a named buffer.",
"This procedure works like gimp-edit-cut, but additionally stores the cut buffer into a named buffer that will stay available for later pasting, regardless of any intermediate copy or cut operations.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2005",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { edit_named_cut_invoker } }
};
static Argument *
edit_named_copy_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpDrawable *drawable;
gchar *buffer_name;
gchar *real_name = NULL;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
buffer_name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
if (strlen (buffer_name) && gimp_item_is_attached (GIMP_ITEM (drawable)))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
real_name = (gchar *) gimp_edit_named_copy (image, buffer_name,
drawable, context);
if (real_name)
real_name = g_strdup (real_name);
else
success = FALSE;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_take_string (&return_vals[1].value, real_name);
return return_vals;
}
static GimpProcedure edit_named_copy_proc =
{
TRUE, TRUE,
"gimp-edit-named-copy",
"gimp-edit-named-copy",
"Copy into a named buffer.",
"This procedure works like gimp-edit-copy, but additionally stores the copied buffer into a named buffer that will stay available for later pasting, regardless of any intermediate copy or cut operations.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2005",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { edit_named_copy_invoker } }
};
static Argument *
edit_named_copy_visible_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpImage *image;
gchar *buffer_name;
gchar *real_name = NULL;
image = gimp_value_get_image (&args[0].value, gimp);
buffer_name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
if (strlen (buffer_name))
{
real_name = (gchar *) gimp_edit_named_copy_visible (image, buffer_name,
context);
if (real_name)
real_name = g_strdup (real_name);
else
success = FALSE;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_take_string (&return_vals[1].value, real_name);
return return_vals;
}
static GimpProcedure edit_named_copy_visible_proc =
{
TRUE, TRUE,
"gimp-edit-named-copy-visible",
"gimp-edit-named-copy-visible",
"Copy from the projection into a named buffer.",
"This procedure works like gimp-edit-copy-visible, but additionally stores the copied buffer into a named buffer that will stay available for later pasting, regardless of any intermediate copy or cut operations.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2005",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { edit_named_copy_visible_invoker } }
};
static Argument *
edit_named_paste_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpDrawable *drawable;
gchar *buffer_name;
gboolean paste_into;
GimpLayer *floating_sel = NULL;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
buffer_name = (gchar *) g_value_get_string (&args[1].value);
paste_into = g_value_get_boolean (&args[2].value);
if (success)
{
GimpBuffer *buffer = (GimpBuffer *)
gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
if (buffer && gimp_item_is_attached (GIMP_ITEM (drawable)))
{
floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
drawable, buffer,
paste_into, -1, -1, -1, -1);
if (! floating_sel)
success = FALSE;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (floating_sel));
return return_vals;
}
static GimpProcedure edit_named_paste_proc =
{
TRUE, TRUE,
"gimp-edit-named-paste",
"gimp-edit-named-paste",
"Paste named buffer to the specified drawable.",
"This procedure works like gimp-edit-paste but pastes a named buffer instead of the global buffer.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2005",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { edit_named_paste_invoker } }
};
static Argument *
edit_named_paste_as_new_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
gchar *buffer_name;
GimpImage *image = NULL;
buffer_name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
GimpBuffer *buffer = (GimpBuffer *)
gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
if (buffer)
{
image = gimp_edit_paste_as_new (gimp, NULL, buffer);
if (! image)
success = FALSE;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
gimp_value_set_image (&return_vals[1].value, image);
return return_vals;
}
static GimpProcedure edit_named_paste_as_new_proc =
{
TRUE, TRUE,
"gimp-edit-named-paste-as-new",
"gimp-edit-named-paste-as-new",
"Paste named buffer to a new image.",
"This procedure works like gimp-edit-paste-as-new but pastes a named buffer instead of the global buffer.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2005",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { edit_named_paste_as_new_invoker } }
};
static Argument *
edit_clear_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpDrawable *drawable;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
success = gimp_edit_clear (image, drawable, context);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure edit_clear_proc =
{
TRUE, TRUE,
"gimp-edit-clear",
"gimp-edit-clear",
"Clear selected area of drawable.",
"This procedure clears the specified drawable. If the drawable has an alpha channel, the cleared pixels will become transparent. If the drawable does not have an alpha channel, cleared pixels will be set to the background color. This procedure only affects regions within a selection if there is a selection active.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { edit_clear_invoker } }
};
static Argument *
edit_fill_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gint32 fill_type;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
fill_type = g_value_get_enum (&args[1].value);
if (success)
{
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
success = gimp_edit_fill (image, drawable, context,
(GimpFillType) fill_type);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure edit_fill_proc =
{
TRUE, TRUE,
"gimp-edit-fill",
"gimp-edit-fill",
"Fill selected area of drawable.",
"This procedure fills the specified drawable with the fill mode. If the fill mode is foreground, the current foreground color is used. If the fill mode is background, the current background color is used. Other fill modes should not be used. This procedure only affects regions within a selection if there is a selection active. If you want to fill the whole drawable, regardless of the selection, use gimp_drawable_fill().",
"Spencer Kimball & Peter Mattis & Raphael Quinet",
"Spencer Kimball & Peter Mattis",
"1995-2000",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { edit_fill_invoker } }
};
static Argument *
edit_bucket_fill_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gint32 fill_mode;
gint32 paint_mode;
gdouble opacity;
gdouble threshold;
gboolean sample_merged;
gdouble x;
gdouble y;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
fill_mode = g_value_get_enum (&args[1].value);
paint_mode = g_value_get_enum (&args[2].value);
opacity = g_value_get_double (&args[3].value);
threshold = g_value_get_double (&args[4].value);
sample_merged = g_value_get_boolean (&args[5].value);
x = g_value_get_double (&args[6].value);
y = g_value_get_double (&args[7].value);
if (success)
{
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
gboolean do_seed_fill;
do_seed_fill = gimp_channel_is_empty (gimp_image_get_mask (image));
gimp_drawable_bucket_fill (drawable, context, fill_mode,
paint_mode, opacity / 100.0,
do_seed_fill,
FALSE /* don't fill transparent */,
threshold, sample_merged, x, y);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure edit_bucket_fill_proc =
{
TRUE, TRUE,
"gimp-edit-bucket-fill",
"gimp-edit-bucket-fill",
"Fill the area specified either by the current selection if there is one, or by a seed fill starting at the specified coordinates.",
"This tool requires information on the paint application mode, and the fill mode, which can either be in the foreground color, or in the currently active pattern. If there is no selection, a seed fill is executed at the specified coordinates and extends outward in keeping with the threshold parameter. If there is a selection in the target image, the threshold, sample merged, x, and y arguments are unused. If the sample_merged parameter is TRUE, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of merged sampling, the x and y coordinates are relative to the image's origin; otherwise, they are relative to the drawable's origin.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { edit_bucket_fill_invoker } }
};
static Argument *
edit_blend_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gint32 blend_mode;
gint32 paint_mode;
gint32 gradient_type;
gdouble opacity;
gdouble offset;
gint32 repeat;
gboolean reverse;
gboolean supersample;
gint32 max_depth;
gdouble threshold;
gboolean dither;
gdouble x1;
gdouble y1;
gdouble x2;
gdouble y2;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
blend_mode = g_value_get_enum (&args[1].value);
paint_mode = g_value_get_enum (&args[2].value);
gradient_type = g_value_get_enum (&args[3].value);
opacity = g_value_get_double (&args[4].value);
offset = g_value_get_double (&args[5].value);
repeat = g_value_get_enum (&args[6].value);
reverse = g_value_get_boolean (&args[7].value);
supersample = g_value_get_boolean (&args[8].value);
max_depth = g_value_get_int (&args[9].value);
threshold = g_value_get_double (&args[10].value);
dither = g_value_get_boolean (&args[11].value);
x1 = g_value_get_double (&args[12].value);
y1 = g_value_get_double (&args[13].value);
x2 = g_value_get_double (&args[14].value);
y2 = g_value_get_double (&args[15].value);
if (success)
{
success = gimp_item_is_attached (GIMP_ITEM (drawable));
if (success && supersample)
{
if (max_depth < 1 || max_depth > 9)
success = FALSE;
if (threshold < 0.0 || threshold > 4.0)
success = FALSE;
}
if (success)
{
if (progress)
gimp_progress_start (progress, _("Blending"), FALSE);
gimp_drawable_blend (drawable,
context,
blend_mode,
paint_mode,
gradient_type,
opacity / 100.0,
offset, repeat, reverse,
supersample, max_depth,
threshold, dither,
x1, y1, x2, y2,
progress);
if (progress)
gimp_progress_end (progress);
}
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure edit_blend_proc =
{
TRUE, TRUE,
"gimp-edit-blend",
"gimp-edit-blend",
"Blend between the starting and ending coordinates with the specified blend mode and gradient type.",
"This tool requires information on the paint application mode, the blend mode, and the gradient type. It creates the specified variety of blend using the starting and ending coordinates as defined for each gradient type.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { edit_blend_invoker } }
};
static Argument *
edit_stroke_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpDrawable *drawable;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpStrokeDesc *desc = gimp_stroke_desc_new (gimp, context);
g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (image)),
drawable, context, desc, TRUE);
g_object_unref (desc);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure edit_stroke_proc =
{
TRUE, TRUE,
"gimp-edit-stroke",
"gimp-edit-stroke",
"Stroke the current selection",
"This procedure strokes the current selection, painting along the selection boundary with the active brush and foreground color. The paint is applied to the specified drawable regardless of the active selection.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { edit_stroke_invoker } }
};