gimp/app/pdb/pattern_cmds.c
Michael Natterer d05d512d9c added struct GimpArray which can keep static or allocated data. Added
2006-04-01  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpparamspecs.[ch]: added struct GimpArray which can
	keep static or allocated data. Added boxed types GIMP_TYPE_ARRAY
	and GIMP_TYPE_STRING_ARRAY. Added GParamSpecs for PDB int32,
	int16, int8, float and string arrays. Added functions to get, dup,
	set and set_static the various arrays from/to GValues.

	* app/pdb/gimpprocedure.c
	* app/pdb/procedural_db.c
	* app/plug-in/plug-in-params.c
	* tools/pdbgen/app.pl
	* tools/pdbgen/pdb.pl: use the new param pspecs and gimp_value
	functions to keep arrays in GimpArguments.

	* app/pdb/gimpargument.[ch] (gimp_arguments_destroy): removed
	parameter "gboolean full_destroy". It's not needed any longer
	because the GValues fully memory-manage all their data now.

	* app/batch.c
	* app/actions/plug-in-commands.c
	* app/actions/vectors-commands.c
	* app/core/gimppdbprogress.c
	* app/dialogs/about-dialog.c
	* app/dialogs/print-size-dialog.c
	* app/dialogs/resize-dialog.c
	* app/display/gimpdisplayshell-handlers.c
	* app/file/file-open.c
	* app/file/file-save.c
	* app/plug-in/plug-in-message.c
	* app/plug-in/plug-in-run.c
	* app/plug-in/plug-ins.c
	* app/widgets/gimphelp.c
	* app/widgets/gimppdbdialog.c
	* tools/pdbgen/pdb/fileops.pdb: changed accordingly.

	* app/pdb/brush_cmds.c
	* app/pdb/brushes_cmds.c
	* app/pdb/buffer_cmds.c
	* app/pdb/color_cmds.c
	* app/pdb/drawable_cmds.c
	* app/pdb/fileops_cmds.c
	* app/pdb/fonts_cmds.c
	* app/pdb/gimpargument.c
	* app/pdb/gimpargument.h
	* app/pdb/gimpprocedure.c
	* app/pdb/gradient_cmds.c
	* app/pdb/gradients_cmds.c
	* app/pdb/image_cmds.c
	* app/pdb/paint_tools_cmds.c
	* app/pdb/palettes_cmds.c
	* app/pdb/parasite_cmds.c
	* app/pdb/paths_cmds.c
	* app/pdb/pattern_cmds.c
	* app/pdb/patterns_cmds.c
	* app/pdb/plug_in_cmds.c
	* app/pdb/procedural_db.c
	* app/pdb/procedural_db_cmds.c
	* app/pdb/selection_tools_cmds.c
	* app/pdb/vectors_cmds.c: regenerated.

	... and ported everything to perl btw...
2006-04-01 01:33:28 +00:00

258 lines
9.7 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 "base/temp-buf.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "core/gimplist.h"
#include "core/gimppattern.h"
static GimpProcedure pattern_get_info_proc;
static GimpProcedure pattern_get_pixels_proc;
void
register_pattern_procs (Gimp *gimp)
{
GimpProcedure *procedure;
/*
* pattern_get_info
*/
procedure = gimp_procedure_init (&pattern_get_info_proc, 1, 3);
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("name",
"name",
"The pattern name.",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("width",
"width",
"The pattern width",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("height",
"height",
"The pattern height",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("bpp",
"bpp",
"The pattern bpp",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* pattern_get_pixels
*/
procedure = gimp_procedure_init (&pattern_get_pixels_proc, 1, 5);
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("name",
"name",
"The pattern name.",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("width",
"width",
"The pattern width",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("height",
"height",
"The pattern height",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("bpp",
"bpp",
"The pattern bpp",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("num-color-bytes",
"num color bytes",
"Number of pattern bytes",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT8ARRAY,
gimp_param_spec_array ("color-bytes",
"color bytes",
"The pattern data.",
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
}
static GimpArgument *
pattern_get_info_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
GimpArgument *args)
{
gboolean success = TRUE;
GimpArgument *return_vals;
gchar *name;
gint32 width = 0;
gint32 height = 0;
gint32 bpp = 0;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
GimpPattern *pattern = (GimpPattern *)
gimp_container_get_child_by_name (gimp->pattern_factory->container, name);
if (pattern)
{
width = pattern->mask->width;
height = pattern->mask->height;
bpp = pattern->mask->bytes;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
{
g_value_set_int (&return_vals[1].value, width);
g_value_set_int (&return_vals[2].value, height);
g_value_set_int (&return_vals[3].value, bpp);
}
return return_vals;
}
static GimpProcedure pattern_get_info_proc =
{
TRUE, TRUE,
"gimp-pattern-get-info",
"gimp-pattern-get-info",
"Retrieve information about the specified pattern.",
"This procedure retrieves information about the specified pattern. This includes the pattern extents (width and height).",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2004",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { pattern_get_info_invoker } }
};
static GimpArgument *
pattern_get_pixels_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
GimpArgument *args)
{
gboolean success = TRUE;
GimpArgument *return_vals;
gchar *name;
gint32 width = 0;
gint32 height = 0;
gint32 bpp = 0;
gint32 num_color_bytes = 0;
guint8 *color_bytes = NULL;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
GimpPattern *pattern = (GimpPattern *)
gimp_container_get_child_by_name (gimp->pattern_factory->container, name);
if (pattern)
{
width = pattern->mask->width;
height = pattern->mask->height;
bpp = pattern->mask->bytes;
num_color_bytes = pattern->mask->height * pattern->mask->width *
pattern->mask->bytes;
color_bytes = g_memdup (temp_buf_data (pattern->mask),
num_color_bytes);
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
{
g_value_set_int (&return_vals[1].value, width);
g_value_set_int (&return_vals[2].value, height);
g_value_set_int (&return_vals[3].value, bpp);
g_value_set_int (&return_vals[4].value, num_color_bytes);
gimp_value_take_int8array (&return_vals[5].value, color_bytes, num_color_bytes);
}
return return_vals;
}
static GimpProcedure pattern_get_pixels_proc =
{
TRUE, TRUE,
"gimp-pattern-get-pixels",
"gimp-pattern-get-pixels",
"Retrieve information about the specified pattern (including pixels).",
"This procedure retrieves information about the specified. This includes the pattern extents (width and height), its bpp and its pixel data.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2004",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { pattern_get_pixels_invoker } }
};