1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <sys/types.h>
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2004-07-10 03:26:34 +08:00
|
|
|
#include <glib-object.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2006-03-29 03:58:00 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2002-03-21 01:46:13 +08:00
|
|
|
|
2001-08-17 22:27:31 +08:00
|
|
|
#include "pdb-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "core/gimp.h"
|
2004-04-15 07:37:34 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2006-03-29 03:58:00 +08:00
|
|
|
#include "core/gimpchannel.h"
|
|
|
|
#include "core/gimplayer.h"
|
|
|
|
#include "core/gimpparamspecs.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "core/gimpprogress.h"
|
2001-07-05 03:31:35 +08:00
|
|
|
|
2006-03-29 03:58:00 +08:00
|
|
|
#include "vectors/gimpvectors.h"
|
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
#include "plug-in/plug-in-run.h"
|
2001-02-04 06:05:41 +08:00
|
|
|
|
2006-03-31 17:15:08 +08:00
|
|
|
#include "gimpprocedure.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "procedural_db.h"
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
|
|
|
static void gimp_procedure_free_strings (ProcRecord *procedure);
|
|
|
|
|
|
|
|
|
2005-05-14 07:36:45 +08:00
|
|
|
/* public functions */
|
|
|
|
|
2006-03-31 19:49:22 +08:00
|
|
|
ProcRecord *
|
|
|
|
gimp_procedure_new (void)
|
|
|
|
{
|
|
|
|
ProcRecord *procedure = g_new0 (ProcRecord, 1);
|
|
|
|
|
|
|
|
return procedure;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_procedure_free (ProcRecord *procedure)
|
|
|
|
{
|
2006-04-01 00:17:07 +08:00
|
|
|
gint i;
|
|
|
|
|
2006-03-31 19:49:22 +08:00
|
|
|
g_return_if_fail (procedure != NULL);
|
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
gimp_procedure_free_strings (procedure);
|
|
|
|
|
|
|
|
if (procedure->args)
|
|
|
|
{
|
|
|
|
for (i = 0; i < procedure->num_args; i++)
|
|
|
|
g_param_spec_unref (procedure->args[i].pspec);
|
|
|
|
|
|
|
|
g_free (procedure->args);
|
|
|
|
procedure->args = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (procedure->values)
|
|
|
|
{
|
|
|
|
for (i = 0; i < procedure->num_values; i++)
|
|
|
|
g_param_spec_unref (procedure->values[i].pspec);
|
2006-03-31 19:49:22 +08:00
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
g_free (procedure->values);
|
|
|
|
procedure->values = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! procedure->static_proc)
|
|
|
|
g_free (procedure);
|
2006-03-31 19:49:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ProcRecord *
|
|
|
|
gimp_procedure_init (ProcRecord *procedure,
|
|
|
|
gint n_arguments,
|
|
|
|
gint n_return_values)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (procedure != NULL, procedure);
|
|
|
|
g_return_val_if_fail (procedure->args == NULL, procedure);
|
|
|
|
g_return_val_if_fail (procedure->values == NULL, procedure);
|
|
|
|
g_return_val_if_fail (n_arguments >= 0, procedure);
|
|
|
|
g_return_val_if_fail (n_return_values >= 0, procedure);
|
|
|
|
|
|
|
|
procedure->num_args = n_arguments;
|
|
|
|
procedure->args = g_new0 (ProcArg, n_arguments);
|
|
|
|
|
|
|
|
procedure->num_values = n_return_values;
|
|
|
|
procedure->values = g_new0 (ProcArg, n_return_values);
|
|
|
|
|
|
|
|
return procedure;
|
|
|
|
}
|
|
|
|
|
2006-03-31 22:00:50 +08:00
|
|
|
void
|
2006-04-01 00:17:07 +08:00
|
|
|
gimp_procedure_set_strings (ProcRecord *procedure,
|
|
|
|
gchar *name,
|
|
|
|
gchar *original_name,
|
|
|
|
gchar *blurb,
|
|
|
|
gchar *help,
|
|
|
|
gchar *author,
|
|
|
|
gchar *copyright,
|
|
|
|
gchar *date,
|
|
|
|
gchar *deprecated)
|
2006-03-31 22:00:50 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (procedure != NULL);
|
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
gimp_procedure_free_strings (procedure);
|
2006-03-31 22:00:50 +08:00
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
procedure->name = g_strdup (name);
|
|
|
|
procedure->original_name = g_strdup (original_name);
|
|
|
|
procedure->blurb = g_strdup (blurb);
|
|
|
|
procedure->help = g_strdup (help);
|
|
|
|
procedure->author = g_strdup (author);
|
|
|
|
procedure->copyright = g_strdup (copyright);
|
|
|
|
procedure->date = g_strdup (date);
|
|
|
|
procedure->deprecated = g_strdup (deprecated);
|
2006-03-31 22:00:50 +08:00
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
procedure->static_strings = FALSE;
|
|
|
|
}
|
2006-03-31 22:00:50 +08:00
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
void
|
|
|
|
gimp_procedure_set_static_strings (ProcRecord *procedure,
|
|
|
|
gchar *name,
|
|
|
|
gchar *original_name,
|
|
|
|
gchar *blurb,
|
|
|
|
gchar *help,
|
|
|
|
gchar *author,
|
|
|
|
gchar *copyright,
|
|
|
|
gchar *date,
|
|
|
|
gchar *deprecated)
|
|
|
|
{
|
|
|
|
g_return_if_fail (procedure != NULL);
|
2006-03-31 22:00:50 +08:00
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
gimp_procedure_free_strings (procedure);
|
2006-03-31 22:00:50 +08:00
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
procedure->name = name;
|
|
|
|
procedure->original_name = original_name;
|
|
|
|
procedure->blurb = blurb;
|
|
|
|
procedure->help = help;
|
|
|
|
procedure->author = author;
|
|
|
|
procedure->copyright = copyright;
|
|
|
|
procedure->date = date;
|
|
|
|
procedure->deprecated = deprecated;
|
2006-03-31 22:00:50 +08:00
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
procedure->static_strings = TRUE;
|
|
|
|
}
|
2006-03-31 22:00:50 +08:00
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
void
|
|
|
|
gimp_procedure_take_strings (ProcRecord *procedure,
|
|
|
|
gchar *name,
|
|
|
|
gchar *original_name,
|
|
|
|
gchar *blurb,
|
|
|
|
gchar *help,
|
|
|
|
gchar *author,
|
|
|
|
gchar *copyright,
|
|
|
|
gchar *date,
|
|
|
|
gchar *deprecated)
|
|
|
|
{
|
|
|
|
g_return_if_fail (procedure != NULL);
|
2006-03-31 22:00:50 +08:00
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
gimp_procedure_free_strings (procedure);
|
2006-03-31 22:00:50 +08:00
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
procedure->name = name;
|
|
|
|
procedure->original_name = original_name;
|
|
|
|
procedure->blurb = blurb;
|
|
|
|
procedure->help = help;
|
|
|
|
procedure->author = author;
|
|
|
|
procedure->copyright = copyright;
|
|
|
|
procedure->date = date;
|
|
|
|
procedure->deprecated = deprecated;
|
2006-03-31 22:00:50 +08:00
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
procedure->static_strings = FALSE;
|
2006-03-31 22:00:50 +08:00
|
|
|
}
|
|
|
|
|
2006-03-31 17:15:08 +08:00
|
|
|
Argument *
|
|
|
|
gimp_procedure_execute (ProcRecord *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
Argument *args,
|
|
|
|
gint n_args,
|
|
|
|
gint *n_return_vals)
|
2006-03-30 07:56:07 +08:00
|
|
|
{
|
|
|
|
Argument *return_vals = NULL;
|
|
|
|
gint i;
|
|
|
|
|
2006-03-31 17:15:08 +08:00
|
|
|
g_return_val_if_fail (procedure != NULL, NULL);
|
2006-04-01 00:17:07 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
|
|
|
|
g_return_val_if_fail (n_return_vals != NULL, NULL);
|
2006-03-31 17:15:08 +08:00
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
*n_return_vals = procedure->num_values + 1;
|
|
|
|
|
|
|
|
for (i = 0; i < MIN (n_args, procedure->num_args); i++)
|
|
|
|
{
|
2006-03-30 18:06:54 +08:00
|
|
|
if (args[i].type != procedure->args[i].type)
|
2006-03-30 07:56:07 +08:00
|
|
|
{
|
2006-03-30 18:06:54 +08:00
|
|
|
gchar *type_name = procedural_db_type_name (procedure->args[i].type);
|
|
|
|
gchar *got = procedural_db_type_name (args[i].type);
|
2006-03-30 07:56:07 +08:00
|
|
|
|
|
|
|
g_message (_("PDB calling error for procedure '%s':\n"
|
|
|
|
"Argument '%s' (#%d, type %s) type mismatch "
|
|
|
|
"(got %s)."),
|
|
|
|
procedure->name,
|
|
|
|
g_param_spec_get_name (procedure->args[i].pspec),
|
|
|
|
i + 1, type_name, got);
|
|
|
|
|
|
|
|
g_free (type_name);
|
|
|
|
g_free (got);
|
|
|
|
|
2006-03-31 17:15:08 +08:00
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, FALSE);
|
2006-03-30 07:56:07 +08:00
|
|
|
g_value_set_enum (&return_vals->value, GIMP_PDB_CALLING_ERROR);
|
|
|
|
|
|
|
|
return return_vals;
|
|
|
|
}
|
2006-03-31 19:49:22 +08:00
|
|
|
else if (! (procedure->args[i].pspec->flags & GIMP_PARAM_NO_VALIDATE))
|
2006-03-30 07:56:07 +08:00
|
|
|
{
|
2006-03-31 19:49:22 +08:00
|
|
|
GValue string_value = { 0, };
|
2006-03-30 07:56:07 +08:00
|
|
|
|
2006-03-31 19:49:22 +08:00
|
|
|
g_value_init (&string_value, G_TYPE_STRING);
|
2006-03-30 07:56:07 +08:00
|
|
|
|
2006-03-31 19:49:22 +08:00
|
|
|
if (g_value_type_transformable (args[i].value.g_type,
|
|
|
|
G_TYPE_STRING))
|
|
|
|
g_value_transform (&args[i].value, &string_value);
|
|
|
|
else
|
|
|
|
g_value_set_static_string (&string_value,
|
|
|
|
"<not transformable to string>");
|
2006-03-30 07:56:07 +08:00
|
|
|
|
2006-03-31 19:49:22 +08:00
|
|
|
if (g_param_value_validate (procedure->args[i].pspec,
|
|
|
|
&args[i].value))
|
|
|
|
{
|
|
|
|
gchar *type_name;
|
|
|
|
gchar *old_value;
|
|
|
|
gchar *new_value;
|
2006-03-30 07:56:07 +08:00
|
|
|
|
2006-03-31 19:49:22 +08:00
|
|
|
type_name = procedural_db_type_name (procedure->args[i].type);
|
|
|
|
|
|
|
|
old_value = g_value_dup_string (&string_value);
|
|
|
|
|
|
|
|
if (g_value_type_transformable (args[i].value.g_type,
|
|
|
|
G_TYPE_STRING))
|
|
|
|
g_value_transform (&args[i].value, &string_value);
|
|
|
|
else
|
|
|
|
g_value_set_static_string (&string_value,
|
|
|
|
"<not transformable to string>");
|
|
|
|
|
|
|
|
new_value = g_value_dup_string (&string_value);
|
|
|
|
g_value_unset (&string_value);
|
|
|
|
|
|
|
|
g_message (_("PDB calling error for procedure '%s':\n"
|
|
|
|
"Argument '%s' (#%d, type %s) out of bounds "
|
2006-04-01 00:17:07 +08:00
|
|
|
"(validation changed '%s' to '%s')"),
|
2006-03-31 19:49:22 +08:00
|
|
|
procedure->name,
|
|
|
|
g_param_spec_get_name (procedure->args[i].pspec),
|
|
|
|
i + 1, type_name,
|
|
|
|
old_value, new_value);
|
|
|
|
|
|
|
|
g_free (type_name);
|
|
|
|
g_free (old_value);
|
|
|
|
g_free (new_value);
|
|
|
|
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, FALSE);
|
|
|
|
g_value_set_enum (&return_vals->value, GIMP_PDB_CALLING_ERROR);
|
|
|
|
|
|
|
|
return return_vals;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_unset (&string_value);
|
2006-03-30 07:56:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* call the procedure */
|
|
|
|
switch (procedure->proc_type)
|
|
|
|
{
|
|
|
|
case GIMP_INTERNAL:
|
2006-04-01 00:17:07 +08:00
|
|
|
g_return_val_if_fail (n_args >= procedure->num_args, NULL);
|
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
return_vals = procedure->exec_method.internal.marshal_func (procedure,
|
|
|
|
gimp, context,
|
|
|
|
progress,
|
|
|
|
args);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PLUGIN:
|
|
|
|
case GIMP_EXTENSION:
|
|
|
|
case GIMP_TEMPORARY:
|
|
|
|
return_vals = plug_in_run (gimp, context, progress, procedure,
|
|
|
|
args, n_args,
|
|
|
|
TRUE, FALSE, -1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If there are no return arguments, assume an execution error */
|
|
|
|
if (! return_vals)
|
|
|
|
{
|
2006-03-31 17:15:08 +08:00
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, FALSE);
|
2006-03-30 07:56:07 +08:00
|
|
|
g_value_set_enum (&return_vals->value, GIMP_PDB_EXECUTION_ERROR);
|
|
|
|
|
|
|
|
return return_vals;
|
|
|
|
}
|
|
|
|
|
|
|
|
return return_vals;
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
Argument *
|
2006-03-31 17:15:08 +08:00
|
|
|
gimp_procedure_get_arguments (const ProcRecord *procedure)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-03-28 05:09:32 +08:00
|
|
|
Argument *args;
|
2001-07-05 03:31:35 +08:00
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-09-11 04:23:00 +08:00
|
|
|
g_return_val_if_fail (procedure != NULL, NULL);
|
|
|
|
|
2006-03-28 05:09:32 +08:00
|
|
|
args = g_new0 (Argument, procedure->num_args);
|
Changed the semantics of GIMP_EXTENSION and (to some extent) of
2003-06-19 Michael Natterer <mitch@gimp.org>
Changed the semantics of GIMP_EXTENSION and (to some extent)
of GIMP_PLUGIN:
The old meaning of EXTENSION was "I live in the toolbox" and
PLUGIN meant "I take RUN-MODE,IMAGE,DRAWABLE args (but only if I
am invoked interactively)". This is completely useless, since
living in the toolbox means having "<Toolbox>" in the menu_path
and taking RUN-MODE,IMAGE,DRAWABLE means just that, regardless of
what type of procedure we are.
The new meaning of GIMP_PLUGIN is just "I am an ordinary procedure,
I am invoked, do my job and finish", while GIMP_EXTENSION means
"I will install temporary procedures and I will keep running to
keep them available".
(A GIMP_EXTENSION *must* call gimp_extension_ack() now to tell the
core that it's ready to run, or the core will block waiting for
the message !!!).
* configure.in: bumped version number to 1.3.16.
* libgimpbase/gimpprotocol.h: increased protocol version number so
old extensions will refuse to load.
* app/gui/plug-in-commands.c (plug_in_run_cmd_callback): don't
blindly pass RUN-MODE,IMAGE,DRAWABLE to GIMP_PLUGIN procedures but
look at their parameters and pass them either RUN-MODE, or
RUN-MODE,IMAGE, or RUN-MODE,IMAGE,DRAWABLE.
* app/pdb/procedural_db.c: cleaned up, better error reporting,
replaced an impossible error message by g_return_if_fail()
* app/plug-in/plug-in-message.c (plug_in_handle_proc_install):
better error messages.
* app/plug-in/plug-in-params.c: allocate parameter arrays using
g_new0() so we don't have to worry about uninitialized stuff
later.
* app/plug-in/plug-in-run.c (plug_in_run): wait for
gimp_extension_ack() installation confirmation for ALL extensions,
not just for automatically started ones.
* app/plug-in/plug-ins.c: cleanup.
* libgimp/gimp.[ch]: cleaned up and API-documented massively. Made
all magic values given in the GPConfig message static and added
accessor functions for them. Added gimp_tile_width()/height().
Added new function gimp_extension_enable() which turns on
asynchronous processing of temp_proc run requests without having
to enter an endless gimp_extension_process() loop. Moved all
private functions to the end of the file. Added tons of
g_return_if_fail() all over the place. Call gimp_run_procedure2()
from gimp_run_procedure() instead of duplicating the
code. Indentation, spacing, stuff...
* libgimp/gimptile.[ch]: removed gimp_tile_width()/height().
* libgimp/gimpdrawable.c
* libgimp/gimppixelrgn.c
* libgimp/gimptile.c: use the gimp_tile_width()/height() accessor
functions.
* libgimp/gimp.def: added gimp_extension_enable.
* libgimp/gimpmenu.c: removed evil code which connected to
_readchannel manually and use gimp_extension_enable() for watching
temp_procs.
* plug-ins/helpbrowser/helpbrowser.c: removed the same evil code
here and call gimp_extension_enable(). Call gimp_extension_ack()
to let the core know that the temp_proc is installed.
* plug-ins/script-fu/script-fu.c: made all procedures except the
permanently running "extension_script_fu" ordinary GIMP_PLUGIN
procedures.
* plug-ins/common/curve_bend.c
* plug-ins/common/plugindetails.c
* plug-ins/common/screenshot.c
* plug-ins/common/uniteditor.c
* plug-ins/common/winclipboard.c
* plug-ins/dbbrowser/dbbrowser.c
* plug-ins/gfli/gfli.c
* plug-ins/twain/twain.c
* plug-ins/webbrowser/webbrowser.c
* plug-ins/winsnap/winsnap.c: made them all ordinary GIMP_PLUGIN
procedures and renamed them from "extension_*" to "plug_in_*".
Random cleanups.
* app/widgets/gimphelp.c
* plug-ins/maze/maze_face.c: call "plug_in_web_browser" now.
2003-06-20 01:12:00 +08:00
|
|
|
|
2006-03-28 05:09:32 +08:00
|
|
|
for (i = 0; i < procedure->num_args; i++)
|
2006-03-30 07:56:07 +08:00
|
|
|
procedural_db_argument_init (&args[i], &procedure->args[i]);
|
2006-03-28 05:09:32 +08:00
|
|
|
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
|
|
|
|
Argument *
|
2006-03-31 17:15:08 +08:00
|
|
|
gimp_procedure_get_return_values (const ProcRecord *procedure,
|
|
|
|
gboolean success)
|
2006-03-28 05:09:32 +08:00
|
|
|
{
|
|
|
|
Argument *args;
|
2006-03-30 07:56:07 +08:00
|
|
|
gint n_args;
|
2006-03-28 05:09:32 +08:00
|
|
|
gint i;
|
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
g_return_val_if_fail (procedure != NULL || success == FALSE, NULL);
|
|
|
|
|
|
|
|
if (procedure)
|
|
|
|
n_args = procedure->num_values + 1;
|
|
|
|
else
|
|
|
|
n_args = 1;
|
2006-03-28 05:09:32 +08:00
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
args = g_new0 (Argument, n_args);
|
2006-03-28 05:09:32 +08:00
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
procedural_db_compat_arg_init (&args[0], GIMP_PDB_STATUS);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (success)
|
2006-03-30 07:56:07 +08:00
|
|
|
g_value_set_enum (&args[0].value, GIMP_PDB_SUCCESS);
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2006-03-30 07:56:07 +08:00
|
|
|
g_value_set_enum (&args[0].value, GIMP_PDB_EXECUTION_ERROR);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
if (procedure)
|
|
|
|
for (i = 0; i < procedure->num_values; i++)
|
|
|
|
procedural_db_argument_init (&args[i + 1], &procedure->values[i]);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-28 05:09:32 +08:00
|
|
|
return args;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-03-29 03:58:00 +08:00
|
|
|
void
|
2006-03-31 17:15:08 +08:00
|
|
|
gimp_procedure_add_argument (ProcRecord *procedure,
|
|
|
|
GimpPDBArgType arg_type,
|
|
|
|
GParamSpec *pspec)
|
2006-03-29 03:58:00 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_if_fail (procedure != NULL);
|
|
|
|
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
|
|
|
|
|
|
|
|
for (i = 0; i < procedure->num_args; i++)
|
|
|
|
if (procedure->args[i].pspec == NULL)
|
|
|
|
{
|
2006-03-30 18:06:54 +08:00
|
|
|
procedure->args[i].type = arg_type;
|
|
|
|
procedure->args[i].pspec = pspec;
|
2006-03-29 03:58:00 +08:00
|
|
|
|
|
|
|
g_param_spec_ref (pspec);
|
|
|
|
g_param_spec_sink (pspec);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_warning ("%s: can't register more than %d arguments for procedure %s",
|
|
|
|
G_STRFUNC, procedure->num_args, procedure->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-03-31 17:15:08 +08:00
|
|
|
gimp_procedure_add_return_value (ProcRecord *procedure,
|
|
|
|
GimpPDBArgType arg_type,
|
|
|
|
GParamSpec *pspec)
|
2006-03-29 03:58:00 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_if_fail (procedure != NULL);
|
|
|
|
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
|
|
|
|
|
|
|
|
for (i = 0; i < procedure->num_values; i++)
|
|
|
|
if (procedure->values[i].pspec == NULL)
|
|
|
|
{
|
2006-03-30 18:06:54 +08:00
|
|
|
procedure->values[i].type = arg_type;
|
|
|
|
procedure->values[i].pspec = pspec;
|
2006-03-29 03:58:00 +08:00
|
|
|
|
|
|
|
g_param_spec_ref (pspec);
|
|
|
|
g_param_spec_sink (pspec);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_warning ("%s: can't register more than %d return values for procedure %s",
|
|
|
|
G_STRFUNC, procedure->num_values, procedure->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GParamSpec *
|
2006-03-31 17:15:08 +08:00
|
|
|
gimp_procedure_compat_pspec (Gimp *gimp,
|
|
|
|
GimpPDBArgType arg_type,
|
|
|
|
const gchar *name,
|
|
|
|
const gchar *desc)
|
2006-03-29 03:58:00 +08:00
|
|
|
{
|
|
|
|
GParamSpec *pspec = NULL;
|
|
|
|
|
|
|
|
switch (arg_type)
|
|
|
|
{
|
|
|
|
case GIMP_PDB_INT32:
|
|
|
|
pspec = g_param_spec_int (name, name, desc,
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_INT16:
|
|
|
|
pspec = g_param_spec_int (name, name, desc,
|
|
|
|
G_MININT16, G_MAXINT16, 0,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_INT8:
|
|
|
|
pspec = g_param_spec_uint (name, name, desc,
|
|
|
|
0, G_MAXUINT8, 0,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_FLOAT:
|
|
|
|
pspec = g_param_spec_double (name, name, desc,
|
|
|
|
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_STRING:
|
|
|
|
pspec = g_param_spec_string (name, name, desc,
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_INT32ARRAY:
|
|
|
|
case GIMP_PDB_INT16ARRAY:
|
|
|
|
case GIMP_PDB_INT8ARRAY:
|
|
|
|
case GIMP_PDB_FLOATARRAY:
|
|
|
|
case GIMP_PDB_STRINGARRAY:
|
|
|
|
pspec = g_param_spec_pointer (name, name, desc,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_COLOR:
|
|
|
|
pspec = gimp_param_spec_rgb (name, name, desc,
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_REGION:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_DISPLAY:
|
|
|
|
pspec = gimp_param_spec_display_id (name, name, desc,
|
|
|
|
gimp,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_IMAGE:
|
|
|
|
pspec = gimp_param_spec_image_id (name, name, desc,
|
|
|
|
gimp,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_LAYER:
|
|
|
|
pspec = gimp_param_spec_item_id (name, name, desc,
|
|
|
|
gimp, GIMP_TYPE_LAYER,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_CHANNEL:
|
|
|
|
pspec = gimp_param_spec_item_id (name, name, desc,
|
|
|
|
gimp, GIMP_TYPE_CHANNEL,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_DRAWABLE:
|
|
|
|
pspec = gimp_param_spec_item_id (name, name, desc,
|
|
|
|
gimp, GIMP_TYPE_DRAWABLE,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_SELECTION:
|
|
|
|
pspec = gimp_param_spec_item_id (name, name, desc,
|
|
|
|
gimp, GIMP_TYPE_CHANNEL,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_BOUNDARY:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_VECTORS:
|
|
|
|
pspec = gimp_param_spec_item_id (name, name, desc,
|
|
|
|
gimp, GIMP_TYPE_VECTORS,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_PARASITE:
|
|
|
|
pspec = gimp_param_spec_parasite (name, name, desc,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_STATUS:
|
|
|
|
pspec = g_param_spec_enum (name, name, desc,
|
|
|
|
GIMP_TYPE_PDB_STATUS_TYPE,
|
|
|
|
GIMP_PDB_EXECUTION_ERROR,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_END:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! pspec)
|
|
|
|
g_warning ("%s: returning NULL for %s (%s)",
|
|
|
|
G_STRFUNC, name, procedural_db_type_name (arg_type));
|
|
|
|
|
|
|
|
return pspec;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-03-31 17:15:08 +08:00
|
|
|
gimp_procedure_add_compat_arg (ProcRecord *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpPDBArgType arg_type,
|
|
|
|
const gchar *name,
|
|
|
|
const gchar *desc)
|
2006-03-29 03:58:00 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (procedure != NULL);
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
g_return_if_fail (name != NULL);
|
|
|
|
|
2006-03-31 17:15:08 +08:00
|
|
|
gimp_procedure_add_argument (procedure, arg_type,
|
|
|
|
gimp_procedure_compat_pspec (gimp, arg_type,
|
|
|
|
name, desc));
|
2006-03-29 03:58:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-03-31 17:15:08 +08:00
|
|
|
gimp_procedure_add_compat_value (ProcRecord *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpPDBArgType arg_type,
|
|
|
|
const gchar *name,
|
|
|
|
const gchar *desc)
|
2006-03-29 03:58:00 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (procedure != NULL);
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
g_return_if_fail (name != NULL);
|
|
|
|
|
2006-03-31 17:15:08 +08:00
|
|
|
gimp_procedure_add_return_value (procedure, arg_type,
|
|
|
|
gimp_procedure_compat_pspec (gimp, arg_type,
|
|
|
|
name, desc));
|
2005-05-14 07:36:45 +08:00
|
|
|
}
|
2006-04-01 00:17:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_procedure_free_strings (ProcRecord *procedure)
|
|
|
|
{
|
|
|
|
if (! procedure->static_strings)
|
|
|
|
{
|
|
|
|
g_free (procedure->name);
|
|
|
|
g_free (procedure->original_name);
|
|
|
|
g_free (procedure->blurb);
|
|
|
|
g_free (procedure->help);
|
|
|
|
g_free (procedure->author);
|
|
|
|
g_free (procedure->copyright);
|
|
|
|
g_free (procedure->date);
|
|
|
|
g_free (procedure->deprecated);
|
|
|
|
}
|
|
|
|
|
|
|
|
procedure->name = NULL;
|
|
|
|
procedure->original_name = NULL;
|
|
|
|
procedure->blurb = NULL;
|
|
|
|
procedure->help = NULL;
|
|
|
|
procedure->author = NULL;
|
|
|
|
procedure->copyright = NULL;
|
|
|
|
procedure->date = NULL;
|
|
|
|
procedure->deprecated = NULL;
|
|
|
|
|
|
|
|
procedure->static_strings = FALSE;
|
|
|
|
}
|