2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-25 06:05:25 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-25 06:05:25 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
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>
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <sys/types.h>
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2013-10-15 07:58:39 +08:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
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"
|
2006-04-15 23:15:33 +08:00
|
|
|
#include "core/gimp-utils.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"
|
|
|
|
|
2010-09-05 04:17:01 +08:00
|
|
|
#include "gimppdbcontext.h"
|
2007-12-03 02:05:54 +08:00
|
|
|
#include "gimppdberror.h"
|
2006-03-31 17:15:08 +08:00
|
|
|
#include "gimpprocedure.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
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
static void gimp_procedure_finalize (GObject *object);
|
|
|
|
|
|
|
|
static gint64 gimp_procedure_get_memsize (GimpObject *object,
|
|
|
|
gint64 *gui_size);
|
|
|
|
|
|
|
|
static GimpValueArray * gimp_procedure_real_execute (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
GimpValueArray *args,
|
|
|
|
GError **error);
|
|
|
|
static void gimp_procedure_real_execute_async (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
GimpValueArray *args,
|
|
|
|
GimpObject *display);
|
|
|
|
|
|
|
|
static void gimp_procedure_free_strings (GimpProcedure *procedure);
|
|
|
|
static gboolean gimp_procedure_validate_args (GimpProcedure *procedure,
|
|
|
|
GParamSpec **param_specs,
|
|
|
|
gint n_param_specs,
|
|
|
|
GimpValueArray *args,
|
|
|
|
gboolean return_vals,
|
|
|
|
GError **error);
|
2006-04-01 00:17:07 +08:00
|
|
|
|
2005-05-14 07:36:45 +08:00
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpProcedure, gimp_procedure, GIMP_TYPE_OBJECT)
|
2006-04-05 05:11:45 +08:00
|
|
|
|
|
|
|
#define parent_class gimp_procedure_parent_class
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_procedure_class_init (GimpProcedureClass *klass)
|
2006-03-31 19:49:22 +08:00
|
|
|
{
|
2006-04-15 23:15:33 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->finalize = gimp_procedure_finalize;
|
2006-03-31 19:49:22 +08:00
|
|
|
|
2006-04-15 23:15:33 +08:00
|
|
|
gimp_object_class->get_memsize = gimp_procedure_get_memsize;
|
2006-04-05 05:11:45 +08:00
|
|
|
|
2006-04-15 23:15:33 +08:00
|
|
|
klass->execute = gimp_procedure_real_execute;
|
|
|
|
klass->execute_async = gimp_procedure_real_execute_async;
|
2006-03-31 19:49:22 +08:00
|
|
|
}
|
|
|
|
|
2006-04-05 05:11:45 +08:00
|
|
|
static void
|
|
|
|
gimp_procedure_init (GimpProcedure *procedure)
|
2006-03-31 19:49:22 +08:00
|
|
|
{
|
2006-04-06 18:01:30 +08:00
|
|
|
procedure->proc_type = GIMP_INTERNAL;
|
2006-04-05 05:11:45 +08:00
|
|
|
}
|
2006-04-01 00:17:07 +08:00
|
|
|
|
2006-04-05 05:11:45 +08:00
|
|
|
static void
|
|
|
|
gimp_procedure_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpProcedure *procedure = GIMP_PROCEDURE (object);
|
|
|
|
gint i;
|
2006-03-31 19:49:22 +08:00
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
gimp_procedure_free_strings (procedure);
|
|
|
|
|
|
|
|
if (procedure->args)
|
|
|
|
{
|
|
|
|
for (i = 0; i < procedure->num_args; i++)
|
2006-04-04 18:30:58 +08:00
|
|
|
g_param_spec_unref (procedure->args[i]);
|
2006-04-01 00:17:07 +08:00
|
|
|
|
|
|
|
g_free (procedure->args);
|
|
|
|
procedure->args = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (procedure->values)
|
|
|
|
{
|
|
|
|
for (i = 0; i < procedure->num_values; i++)
|
2006-04-04 18:30:58 +08:00
|
|
|
g_param_spec_unref (procedure->values[i]);
|
2006-03-31 19:49:22 +08:00
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
g_free (procedure->values);
|
|
|
|
procedure->values = NULL;
|
|
|
|
}
|
|
|
|
|
2006-04-05 05:11:45 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2006-04-15 23:15:33 +08:00
|
|
|
static gint64
|
|
|
|
gimp_procedure_get_memsize (GimpObject *object,
|
|
|
|
gint64 *gui_size)
|
|
|
|
{
|
|
|
|
GimpProcedure *procedure = GIMP_PROCEDURE (object);
|
|
|
|
gint64 memsize = 0;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
if (! procedure->static_strings)
|
|
|
|
{
|
2007-11-17 02:19:30 +08:00
|
|
|
memsize += gimp_string_get_memsize (procedure->original_name);
|
|
|
|
memsize += gimp_string_get_memsize (procedure->blurb);
|
|
|
|
memsize += gimp_string_get_memsize (procedure->help);
|
|
|
|
memsize += gimp_string_get_memsize (procedure->author);
|
|
|
|
memsize += gimp_string_get_memsize (procedure->copyright);
|
|
|
|
memsize += gimp_string_get_memsize (procedure->date);
|
|
|
|
memsize += gimp_string_get_memsize (procedure->deprecated);
|
2006-04-15 23:15:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
memsize += procedure->num_args * sizeof (GParamSpec *);
|
|
|
|
|
|
|
|
for (i = 0; i < procedure->num_args; i++)
|
|
|
|
memsize += gimp_g_param_spec_get_memsize (procedure->args[i]);
|
|
|
|
|
|
|
|
memsize += procedure->num_values * sizeof (GParamSpec *);
|
|
|
|
|
|
|
|
for (i = 0; i < procedure->num_values; i++)
|
|
|
|
memsize += gimp_g_param_spec_get_memsize (procedure->values[i]);
|
|
|
|
|
|
|
|
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
|
|
|
|
gui_size);
|
|
|
|
}
|
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
static GimpValueArray *
|
|
|
|
gimp_procedure_real_execute (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
GimpValueArray *args,
|
|
|
|
GError **error)
|
2006-04-05 05:11:45 +08:00
|
|
|
{
|
2012-05-04 06:50:23 +08:00
|
|
|
g_return_val_if_fail (gimp_value_array_length (args) >=
|
|
|
|
procedure->num_args, NULL);
|
2006-04-05 05:11:45 +08:00
|
|
|
|
2006-04-06 18:01:30 +08:00
|
|
|
return procedure->marshal_func (procedure, gimp,
|
|
|
|
context, progress,
|
2007-12-03 02:05:54 +08:00
|
|
|
args, error);
|
2006-04-05 05:11:45 +08:00
|
|
|
}
|
|
|
|
|
2006-04-08 02:23:20 +08:00
|
|
|
static void
|
2007-12-03 02:05:54 +08:00
|
|
|
gimp_procedure_real_execute_async (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
2012-05-04 06:50:23 +08:00
|
|
|
GimpValueArray *args,
|
2007-12-03 02:05:54 +08:00
|
|
|
GimpObject *display)
|
2006-04-08 02:23:20 +08:00
|
|
|
{
|
2012-05-04 06:50:23 +08:00
|
|
|
GimpValueArray *return_vals;
|
|
|
|
GError *error = NULL;
|
2006-04-08 02:23:20 +08:00
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
g_return_if_fail (gimp_value_array_length (args) >= procedure->num_args);
|
2006-04-08 02:23:20 +08:00
|
|
|
|
|
|
|
return_vals = GIMP_PROCEDURE_GET_CLASS (procedure)->execute (procedure,
|
|
|
|
gimp,
|
|
|
|
context,
|
|
|
|
progress,
|
2007-12-03 02:05:54 +08:00
|
|
|
args,
|
|
|
|
&error);
|
2006-04-08 02:23:20 +08:00
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
gimp_value_array_unref (return_vals);
|
2007-12-03 02:05:54 +08:00
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR,
|
2013-09-15 00:59:20 +08:00
|
|
|
error->message);
|
2007-12-03 02:05:54 +08:00
|
|
|
g_error_free (error);
|
|
|
|
}
|
2006-04-08 02:23:20 +08:00
|
|
|
}
|
|
|
|
|
2006-04-05 05:11:45 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
GimpProcedure *
|
2006-04-06 18:01:30 +08:00
|
|
|
gimp_procedure_new (GimpMarshalFunc marshal_func)
|
2006-04-05 05:11:45 +08:00
|
|
|
{
|
2006-04-06 18:01:30 +08:00
|
|
|
GimpProcedure *procedure;
|
2006-04-05 05:11:45 +08:00
|
|
|
|
2006-04-06 18:01:30 +08:00
|
|
|
g_return_val_if_fail (marshal_func != NULL, NULL);
|
2006-04-05 05:11:45 +08:00
|
|
|
|
2006-04-06 18:01:30 +08:00
|
|
|
procedure = g_object_new (GIMP_TYPE_PROCEDURE, NULL);
|
2006-04-05 05:11:45 +08:00
|
|
|
|
2006-04-06 18:01:30 +08:00
|
|
|
procedure->marshal_func = marshal_func;
|
2006-04-05 05:11:45 +08:00
|
|
|
|
2006-03-31 19:49:22 +08:00
|
|
|
return procedure;
|
|
|
|
}
|
|
|
|
|
2006-03-31 22:00:50 +08:00
|
|
|
void
|
2006-04-01 01:42:13 +08:00
|
|
|
gimp_procedure_set_strings (GimpProcedure *procedure,
|
2007-07-19 01:23:51 +08:00
|
|
|
const gchar *original_name,
|
|
|
|
const gchar *blurb,
|
|
|
|
const gchar *help,
|
|
|
|
const gchar *author,
|
|
|
|
const gchar *copyright,
|
|
|
|
const gchar *date,
|
|
|
|
const gchar *deprecated)
|
2006-03-31 22:00:50 +08:00
|
|
|
{
|
2006-04-01 01:42:13 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
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->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
|
2006-04-01 01:42:13 +08:00
|
|
|
gimp_procedure_set_static_strings (GimpProcedure *procedure,
|
2008-09-04 04:26:05 +08:00
|
|
|
const gchar *original_name,
|
|
|
|
const gchar *blurb,
|
|
|
|
const gchar *help,
|
|
|
|
const gchar *author,
|
|
|
|
const gchar *copyright,
|
|
|
|
const gchar *date,
|
|
|
|
const gchar *deprecated)
|
2006-04-01 00:17:07 +08:00
|
|
|
{
|
2006-04-01 01:42:13 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
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
|
|
|
|
2008-09-04 04:26:05 +08:00
|
|
|
procedure->original_name = (gchar *) original_name;
|
|
|
|
procedure->blurb = (gchar *) blurb;
|
|
|
|
procedure->help = (gchar *) help;
|
|
|
|
procedure->author = (gchar *) author;
|
|
|
|
procedure->copyright = (gchar *) copyright;
|
|
|
|
procedure->date = (gchar *) date;
|
|
|
|
procedure->deprecated = (gchar *) 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
|
2006-04-01 01:42:13 +08:00
|
|
|
gimp_procedure_take_strings (GimpProcedure *procedure,
|
|
|
|
gchar *original_name,
|
|
|
|
gchar *blurb,
|
|
|
|
gchar *help,
|
|
|
|
gchar *author,
|
|
|
|
gchar *copyright,
|
|
|
|
gchar *date,
|
|
|
|
gchar *deprecated)
|
2006-04-01 00:17:07 +08:00
|
|
|
{
|
2006-04-01 01:42:13 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
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->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
|
|
|
}
|
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
GimpValueArray *
|
|
|
|
gimp_procedure_execute (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
GimpValueArray *args,
|
|
|
|
GError **error)
|
2006-03-30 07:56:07 +08:00
|
|
|
{
|
2012-05-04 06:50:23 +08:00
|
|
|
GimpValueArray *return_vals;
|
|
|
|
GError *pdb_error = NULL;
|
2006-03-30 07:56:07 +08:00
|
|
|
|
2006-04-01 01:42:13 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), 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);
|
2006-04-04 18:30:58 +08:00
|
|
|
g_return_val_if_fail (args != NULL, NULL);
|
2007-12-03 02:05:54 +08:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
2006-03-31 17:15:08 +08:00
|
|
|
|
2007-12-03 02:05:54 +08:00
|
|
|
if (! gimp_procedure_validate_args (procedure,
|
2006-11-23 20:42:58 +08:00
|
|
|
procedure->args, procedure->num_args,
|
2008-08-16 21:57:57 +08:00
|
|
|
args, FALSE, &pdb_error))
|
2006-03-30 07:56:07 +08:00
|
|
|
{
|
2008-08-16 21:57:57 +08:00
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, FALSE,
|
|
|
|
pdb_error);
|
|
|
|
g_propagate_error (error, pdb_error);
|
2006-03-31 19:49:22 +08:00
|
|
|
|
2006-04-08 02:23:20 +08:00
|
|
|
return return_vals;
|
2006-03-30 07:56:07 +08:00
|
|
|
}
|
|
|
|
|
2010-09-05 04:17:01 +08:00
|
|
|
if (GIMP_IS_PDB_CONTEXT (context))
|
|
|
|
context = g_object_ref (context);
|
|
|
|
else
|
|
|
|
context = gimp_pdb_context_new (gimp, context, TRUE);
|
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
/* call the procedure */
|
2006-04-05 05:11:45 +08:00
|
|
|
return_vals = GIMP_PROCEDURE_GET_CLASS (procedure)->execute (procedure,
|
|
|
|
gimp,
|
|
|
|
context,
|
|
|
|
progress,
|
2007-12-03 02:05:54 +08:00
|
|
|
args,
|
|
|
|
error);
|
2006-03-30 07:56:07 +08:00
|
|
|
|
2010-09-05 04:17:01 +08:00
|
|
|
g_object_unref (context);
|
2008-08-17 20:13:46 +08:00
|
|
|
|
|
|
|
if (return_vals)
|
|
|
|
{
|
2012-05-04 06:50:23 +08:00
|
|
|
switch (g_value_get_enum (gimp_value_array_index (return_vals, 0)))
|
2008-08-17 20:13:46 +08:00
|
|
|
{
|
2009-01-29 06:12:34 +08:00
|
|
|
case GIMP_PDB_CALLING_ERROR:
|
|
|
|
case GIMP_PDB_EXECUTION_ERROR:
|
2008-08-17 20:13:46 +08:00
|
|
|
/* If the error has not already been set, construct one
|
|
|
|
* from the error message that is optionally passed with
|
|
|
|
* the return values.
|
|
|
|
*/
|
2014-03-15 00:28:42 +08:00
|
|
|
if (error && *error == NULL &&
|
|
|
|
gimp_value_array_length (return_vals) > 1 &&
|
|
|
|
G_VALUE_HOLDS_STRING (gimp_value_array_index (return_vals, 1)))
|
2008-08-17 20:13:46 +08:00
|
|
|
{
|
2014-03-15 00:28:42 +08:00
|
|
|
GValue *value = gimp_value_array_index (return_vals, 1);
|
|
|
|
const gchar *message = g_value_get_string (value);
|
|
|
|
|
|
|
|
if (message)
|
|
|
|
g_set_error_literal (error, GIMP_PDB_ERROR,
|
|
|
|
GIMP_PDB_ERROR_FAILED,
|
|
|
|
message);
|
2008-08-17 20:13:46 +08:00
|
|
|
}
|
2009-01-29 06:12:34 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2008-08-17 20:13:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2006-03-30 07:56:07 +08:00
|
|
|
{
|
2008-08-17 20:13:46 +08:00
|
|
|
g_warning ("%s: no return values, shouldn't happen", G_STRFUNC);
|
|
|
|
|
2012-03-06 02:36:59 +08:00
|
|
|
pdb_error = g_error_new (GIMP_PDB_ERROR,
|
|
|
|
GIMP_PDB_ERROR_INVALID_RETURN_VALUE,
|
2008-08-16 21:57:57 +08:00
|
|
|
_("Procedure '%s' returned no return values"),
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (procedure));
|
2006-03-30 07:56:07 +08:00
|
|
|
|
2008-08-16 21:57:57 +08:00
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, FALSE,
|
|
|
|
pdb_error);
|
2008-08-17 20:13:46 +08:00
|
|
|
if (error && *error == NULL)
|
|
|
|
g_propagate_error (error, pdb_error);
|
|
|
|
else
|
|
|
|
g_error_free (pdb_error);
|
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return return_vals;
|
|
|
|
}
|
|
|
|
|
2006-04-08 02:23:20 +08:00
|
|
|
void
|
2007-12-03 02:05:54 +08:00
|
|
|
gimp_procedure_execute_async (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
2012-05-04 06:50:23 +08:00
|
|
|
GimpValueArray *args,
|
2007-12-03 02:05:54 +08:00
|
|
|
GimpObject *display,
|
|
|
|
GError **error)
|
2006-04-08 02:23:20 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
|
|
|
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
|
|
|
|
g_return_if_fail (args != NULL);
|
2006-05-05 16:29:33 +08:00
|
|
|
g_return_if_fail (display == NULL || GIMP_IS_OBJECT (display));
|
2007-12-03 02:05:54 +08:00
|
|
|
g_return_if_fail (error == NULL || *error == NULL);
|
2006-04-08 02:23:20 +08:00
|
|
|
|
2007-12-03 02:05:54 +08:00
|
|
|
if (gimp_procedure_validate_args (procedure,
|
2006-11-23 20:42:58 +08:00
|
|
|
procedure->args, procedure->num_args,
|
2007-12-03 02:05:54 +08:00
|
|
|
args, FALSE, error))
|
2006-11-23 20:42:58 +08:00
|
|
|
{
|
2010-09-05 04:17:01 +08:00
|
|
|
if (GIMP_IS_PDB_CONTEXT (context))
|
|
|
|
context = g_object_ref (context);
|
|
|
|
else
|
|
|
|
context = gimp_pdb_context_new (gimp, context, TRUE);
|
|
|
|
|
2006-11-23 20:42:58 +08:00
|
|
|
GIMP_PROCEDURE_GET_CLASS (procedure)->execute_async (procedure, gimp,
|
|
|
|
context, progress,
|
|
|
|
args, display);
|
2010-09-05 04:17:01 +08:00
|
|
|
|
|
|
|
g_object_unref (context);
|
2006-11-23 20:42:58 +08:00
|
|
|
}
|
2006-04-08 02:23:20 +08:00
|
|
|
}
|
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
GimpValueArray *
|
2006-04-01 01:42:13 +08:00
|
|
|
gimp_procedure_get_arguments (GimpProcedure *procedure)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2012-05-04 06:50:23 +08:00
|
|
|
GimpValueArray *args;
|
|
|
|
GValue value = { 0, };
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-01 01:42:13 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
2002-09-11 04:23:00 +08:00
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
args = gimp_value_array_new (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-04-04 18:30:58 +08:00
|
|
|
{
|
|
|
|
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (procedure->args[i]));
|
2012-05-04 06:50:23 +08:00
|
|
|
gimp_value_array_append (args, &value);
|
2006-04-04 18:30:58 +08:00
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
2006-03-28 05:09:32 +08:00
|
|
|
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
GimpValueArray *
|
2006-04-01 01:42:13 +08:00
|
|
|
gimp_procedure_get_return_values (GimpProcedure *procedure,
|
2008-08-16 21:57:57 +08:00
|
|
|
gboolean success,
|
|
|
|
const GError *error)
|
2006-03-28 05:09:32 +08:00
|
|
|
{
|
2012-05-04 06:50:23 +08:00
|
|
|
GimpValueArray *args;
|
|
|
|
GValue value = { 0, };
|
|
|
|
gint i;
|
2006-03-28 05:09:32 +08:00
|
|
|
|
2008-08-16 21:57:57 +08:00
|
|
|
g_return_val_if_fail (success == FALSE || GIMP_IS_PROCEDURE (procedure),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
{
|
2012-05-04 06:50:23 +08:00
|
|
|
args = gimp_value_array_new (procedure->num_values + 1);
|
2008-08-16 21:57:57 +08:00
|
|
|
|
|
|
|
g_value_init (&value, GIMP_TYPE_PDB_STATUS_TYPE);
|
|
|
|
g_value_set_enum (&value, GIMP_PDB_SUCCESS);
|
2012-05-04 06:50:23 +08:00
|
|
|
gimp_value_array_append (args, &value);
|
2008-08-16 21:57:57 +08:00
|
|
|
g_value_unset (&value);
|
2006-03-30 07:56:07 +08:00
|
|
|
|
2008-08-16 21:57:57 +08:00
|
|
|
for (i = 0; i < procedure->num_values; i++)
|
|
|
|
{
|
|
|
|
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (procedure->values[i]));
|
2012-05-04 06:50:23 +08:00
|
|
|
gimp_value_array_append (args, &value);
|
2008-08-16 21:57:57 +08:00
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
|
|
|
}
|
2006-03-30 07:56:07 +08:00
|
|
|
else
|
2008-08-16 21:57:57 +08:00
|
|
|
{
|
2012-05-04 06:50:23 +08:00
|
|
|
args = gimp_value_array_new ((error && error->message) ? 2 : 1);
|
2006-03-28 05:09:32 +08:00
|
|
|
|
2008-08-16 21:57:57 +08:00
|
|
|
g_value_init (&value, GIMP_TYPE_PDB_STATUS_TYPE);
|
2006-03-28 05:09:32 +08:00
|
|
|
|
2008-08-16 21:57:57 +08:00
|
|
|
/* errors in the GIMP_PDB_ERROR domain are calling errors */
|
|
|
|
if (error && error->domain == GIMP_PDB_ERROR)
|
|
|
|
{
|
|
|
|
switch ((GimpPdbErrorCode) error->code)
|
|
|
|
{
|
2012-03-06 02:36:59 +08:00
|
|
|
case GIMP_PDB_ERROR_FAILED:
|
|
|
|
case GIMP_PDB_ERROR_PROCEDURE_NOT_FOUND:
|
|
|
|
case GIMP_PDB_ERROR_INVALID_ARGUMENT:
|
|
|
|
case GIMP_PDB_ERROR_INVALID_RETURN_VALUE:
|
|
|
|
case GIMP_PDB_ERROR_INTERNAL_ERROR:
|
2008-08-16 21:57:57 +08:00
|
|
|
g_value_set_enum (&value, GIMP_PDB_CALLING_ERROR);
|
|
|
|
break;
|
|
|
|
|
2012-03-06 02:36:59 +08:00
|
|
|
case GIMP_PDB_ERROR_CANCELLED:
|
2008-08-16 21:57:57 +08:00
|
|
|
g_value_set_enum (&value, GIMP_PDB_CANCEL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_value_set_enum (&value, GIMP_PDB_EXECUTION_ERROR);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
gimp_value_array_append (args, &value);
|
2008-08-16 21:57:57 +08:00
|
|
|
g_value_unset (&value);
|
|
|
|
|
|
|
|
if (error && error->message)
|
|
|
|
{
|
|
|
|
g_value_init (&value, G_TYPE_STRING);
|
|
|
|
g_value_set_string (&value, error->message);
|
2012-05-04 06:50:23 +08:00
|
|
|
gimp_value_array_append (args, &value);
|
2008-08-16 21:57:57 +08:00
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
|
|
|
}
|
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-04-04 04:54:55 +08:00
|
|
|
gimp_procedure_add_argument (GimpProcedure *procedure,
|
|
|
|
GParamSpec *pspec)
|
2006-03-29 03:58:00 +08:00
|
|
|
{
|
2006-04-01 01:42:13 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
2006-03-29 03:58:00 +08:00
|
|
|
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
|
|
|
|
|
2006-04-06 18:01:30 +08:00
|
|
|
procedure->args = g_renew (GParamSpec *, procedure->args,
|
|
|
|
procedure->num_args + 1);
|
2006-03-29 03:58:00 +08:00
|
|
|
|
2006-04-06 18:01:30 +08:00
|
|
|
procedure->args[procedure->num_args] = pspec;
|
2006-03-29 03:58:00 +08:00
|
|
|
|
2011-11-04 08:31:45 +08:00
|
|
|
g_param_spec_ref_sink (pspec);
|
2006-03-29 03:58:00 +08:00
|
|
|
|
2006-04-06 18:01:30 +08:00
|
|
|
procedure->num_args++;
|
2006-03-29 03:58:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-04 04:54:55 +08:00
|
|
|
gimp_procedure_add_return_value (GimpProcedure *procedure,
|
|
|
|
GParamSpec *pspec)
|
2006-03-29 03:58:00 +08:00
|
|
|
{
|
2006-04-01 01:42:13 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
2006-03-29 03:58:00 +08:00
|
|
|
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
|
|
|
|
|
2006-04-06 18:01:30 +08:00
|
|
|
procedure->values = g_renew (GParamSpec *, procedure->values,
|
|
|
|
procedure->num_values + 1);
|
2006-03-29 03:58:00 +08:00
|
|
|
|
2006-04-06 18:01:30 +08:00
|
|
|
procedure->values[procedure->num_values] = pspec;
|
2006-03-29 03:58:00 +08:00
|
|
|
|
2011-11-04 08:31:45 +08:00
|
|
|
g_param_spec_ref_sink (pspec);
|
2006-03-29 03:58:00 +08:00
|
|
|
|
2006-04-06 18:01:30 +08:00
|
|
|
procedure->num_values++;
|
2006-03-29 03:58:00 +08:00
|
|
|
}
|
|
|
|
|
2009-01-26 04:06:09 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_create_override:
|
|
|
|
* @procedure:
|
|
|
|
* @new_marshal_func:
|
|
|
|
*
|
|
|
|
* Creates a new GimpProcedure that can be used to override the
|
|
|
|
* existing @procedure.
|
|
|
|
*
|
|
|
|
* Returns: The new #GimpProcedure.
|
|
|
|
**/
|
|
|
|
GimpProcedure *
|
|
|
|
gimp_procedure_create_override (GimpProcedure *procedure,
|
|
|
|
GimpMarshalFunc new_marshal_func)
|
|
|
|
{
|
|
|
|
GimpProcedure *new_procedure = NULL;
|
|
|
|
const gchar *name = NULL;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
new_procedure = gimp_procedure_new (new_marshal_func);
|
2009-09-01 04:47:18 +08:00
|
|
|
name = gimp_object_get_name (procedure);
|
2009-01-26 04:06:09 +08:00
|
|
|
|
|
|
|
gimp_object_set_static_name (GIMP_OBJECT (new_procedure), name);
|
|
|
|
|
|
|
|
for (i = 0; i < procedure->num_args; i++)
|
|
|
|
gimp_procedure_add_argument (new_procedure, procedure->args[i]);
|
|
|
|
|
|
|
|
for (i = 0; i < procedure->num_values; i++)
|
|
|
|
gimp_procedure_add_return_value (new_procedure, procedure->values[i]);
|
|
|
|
|
|
|
|
return new_procedure;
|
|
|
|
}
|
|
|
|
|
2011-05-05 06:08:37 +08:00
|
|
|
gint
|
|
|
|
gimp_procedure_name_compare (GimpProcedure *proc1,
|
|
|
|
GimpProcedure *proc2)
|
|
|
|
{
|
|
|
|
/* Assume there always is a name, don't bother with NULL checks */
|
|
|
|
return strcmp (proc1->original_name,
|
|
|
|
proc2->original_name);
|
|
|
|
}
|
2006-04-01 00:17:07 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
2006-04-01 01:42:13 +08:00
|
|
|
gimp_procedure_free_strings (GimpProcedure *procedure)
|
2006-04-01 00:17:07 +08:00
|
|
|
{
|
|
|
|
if (! procedure->static_strings)
|
|
|
|
{
|
|
|
|
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->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;
|
|
|
|
}
|
2006-04-08 02:23:20 +08:00
|
|
|
|
|
|
|
static gboolean
|
2006-11-23 20:42:58 +08:00
|
|
|
gimp_procedure_validate_args (GimpProcedure *procedure,
|
|
|
|
GParamSpec **param_specs,
|
|
|
|
gint n_param_specs,
|
2012-05-04 06:50:23 +08:00
|
|
|
GimpValueArray *args,
|
2007-12-03 02:05:54 +08:00
|
|
|
gboolean return_vals,
|
|
|
|
GError **error)
|
2006-04-08 02:23:20 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
for (i = 0; i < MIN (gimp_value_array_length (args), n_param_specs); i++)
|
2006-04-08 02:23:20 +08:00
|
|
|
{
|
2012-05-04 06:50:23 +08:00
|
|
|
GValue *arg = gimp_value_array_index (args, i);
|
2006-11-23 20:42:58 +08:00
|
|
|
GParamSpec *pspec = param_specs[i];
|
2006-04-08 02:23:20 +08:00
|
|
|
GType arg_type = G_VALUE_TYPE (arg);
|
|
|
|
GType spec_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
|
|
|
|
|
|
|
|
if (arg_type != spec_type)
|
|
|
|
{
|
2006-11-23 20:42:58 +08:00
|
|
|
if (return_vals)
|
|
|
|
{
|
2008-08-16 21:57:57 +08:00
|
|
|
g_set_error (error,
|
2012-03-06 02:36:59 +08:00
|
|
|
GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_RETURN_VALUE,
|
2007-12-03 02:05:54 +08:00
|
|
|
_("Procedure '%s' returned a wrong value type "
|
|
|
|
"for return value '%s' (#%d). "
|
|
|
|
"Expected %s, got %s."),
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (procedure),
|
2007-12-03 02:05:54 +08:00
|
|
|
g_param_spec_get_name (pspec),
|
|
|
|
i + 1, g_type_name (spec_type),
|
|
|
|
g_type_name (arg_type));
|
2006-11-23 20:42:58 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-16 21:57:57 +08:00
|
|
|
g_set_error (error,
|
2012-03-06 02:36:59 +08:00
|
|
|
GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
|
2007-12-03 02:05:54 +08:00
|
|
|
_("Procedure '%s' has been called with a "
|
|
|
|
"wrong value type for argument '%s' (#%d). "
|
|
|
|
"Expected %s, got %s."),
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (procedure),
|
2007-12-03 02:05:54 +08:00
|
|
|
g_param_spec_get_name (pspec),
|
|
|
|
i + 1, g_type_name (spec_type),
|
|
|
|
g_type_name (arg_type));
|
2006-11-23 20:42:58 +08:00
|
|
|
}
|
2006-04-08 02:23:20 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (! (pspec->flags & GIMP_PARAM_NO_VALIDATE))
|
|
|
|
{
|
|
|
|
GValue string_value = { 0, };
|
|
|
|
|
|
|
|
g_value_init (&string_value, G_TYPE_STRING);
|
|
|
|
|
|
|
|
if (g_value_type_transformable (arg_type, G_TYPE_STRING))
|
|
|
|
g_value_transform (arg, &string_value);
|
|
|
|
else
|
|
|
|
g_value_set_static_string (&string_value,
|
|
|
|
"<not transformable to string>");
|
|
|
|
|
|
|
|
if (g_param_value_validate (pspec, arg))
|
|
|
|
{
|
2006-11-23 17:17:07 +08:00
|
|
|
if (GIMP_IS_PARAM_SPEC_DRAWABLE_ID (pspec) &&
|
|
|
|
g_value_get_int (arg) == -1)
|
|
|
|
{
|
2006-11-23 20:42:58 +08:00
|
|
|
if (return_vals)
|
|
|
|
{
|
2007-12-03 02:05:54 +08:00
|
|
|
g_set_error (error,
|
2012-03-06 02:36:59 +08:00
|
|
|
GIMP_PDB_ERROR,
|
|
|
|
GIMP_PDB_ERROR_INVALID_RETURN_VALUE,
|
2007-12-03 02:05:54 +08:00
|
|
|
_("Procedure '%s' returned an "
|
|
|
|
"invalid ID for argument '%s'. "
|
|
|
|
"Most likely a plug-in is trying "
|
|
|
|
"to work on a layer that doesn't "
|
|
|
|
"exist any longer."),
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (procedure),
|
2007-12-03 02:05:54 +08:00
|
|
|
g_param_spec_get_name (pspec));
|
2006-11-23 20:42:58 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-03 02:05:54 +08:00
|
|
|
g_set_error (error,
|
2012-03-06 02:36:59 +08:00
|
|
|
GIMP_PDB_ERROR,
|
|
|
|
GIMP_PDB_ERROR_INVALID_ARGUMENT,
|
2007-12-03 02:05:54 +08:00
|
|
|
_("Procedure '%s' has been called with an "
|
|
|
|
"invalid ID for argument '%s'. "
|
|
|
|
"Most likely a plug-in is trying "
|
|
|
|
"to work on a layer that doesn't "
|
|
|
|
"exist any longer."),
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (procedure),
|
2007-12-03 02:05:54 +08:00
|
|
|
g_param_spec_get_name (pspec));
|
2006-11-23 20:42:58 +08:00
|
|
|
}
|
2006-11-23 17:17:07 +08:00
|
|
|
}
|
|
|
|
else if (GIMP_IS_PARAM_SPEC_IMAGE_ID (pspec) &&
|
|
|
|
g_value_get_int (arg) == -1)
|
|
|
|
{
|
2006-11-23 20:42:58 +08:00
|
|
|
if (return_vals)
|
|
|
|
{
|
2007-12-03 02:05:54 +08:00
|
|
|
g_set_error (error,
|
2012-03-06 02:36:59 +08:00
|
|
|
GIMP_PDB_ERROR,
|
|
|
|
GIMP_PDB_ERROR_INVALID_RETURN_VALUE,
|
2007-12-03 02:05:54 +08:00
|
|
|
_("Procedure '%s' returned an "
|
|
|
|
"invalid ID for argument '%s'. "
|
|
|
|
"Most likely a plug-in is trying "
|
|
|
|
"to work on an image that doesn't "
|
|
|
|
"exist any longer."),
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (procedure),
|
2007-12-03 02:05:54 +08:00
|
|
|
g_param_spec_get_name (pspec));
|
2006-11-23 20:42:58 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-03 02:05:54 +08:00
|
|
|
g_set_error (error,
|
2012-03-06 02:36:59 +08:00
|
|
|
GIMP_PDB_ERROR,
|
|
|
|
GIMP_PDB_ERROR_INVALID_ARGUMENT,
|
2007-12-03 02:05:54 +08:00
|
|
|
_("Procedure '%s' has been called with an "
|
|
|
|
"invalid ID for argument '%s'. "
|
|
|
|
"Most likely a plug-in is trying "
|
|
|
|
"to work on an image that doesn't "
|
|
|
|
"exist any longer."),
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (procedure),
|
2007-12-03 02:05:54 +08:00
|
|
|
g_param_spec_get_name (pspec));
|
2006-11-23 20:42:58 +08:00
|
|
|
}
|
2006-11-23 17:17:07 +08:00
|
|
|
}
|
2006-04-08 02:23:20 +08:00
|
|
|
else
|
2006-11-23 17:17:07 +08:00
|
|
|
{
|
2007-10-27 04:03:07 +08:00
|
|
|
const gchar *value = g_value_get_string (&string_value);
|
|
|
|
|
|
|
|
if (value == NULL)
|
|
|
|
value = "(null)";
|
|
|
|
|
2006-11-23 20:42:58 +08:00
|
|
|
if (return_vals)
|
|
|
|
{
|
2007-12-03 02:05:54 +08:00
|
|
|
g_set_error (error,
|
2012-03-06 02:36:59 +08:00
|
|
|
GIMP_PDB_ERROR,
|
|
|
|
GIMP_PDB_ERROR_INVALID_RETURN_VALUE,
|
2007-12-03 02:05:54 +08:00
|
|
|
_("Procedure '%s' returned "
|
|
|
|
"'%s' as return value '%s' "
|
|
|
|
"(#%d, type %s). "
|
|
|
|
"This value is out of range."),
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (procedure),
|
2007-12-03 02:05:54 +08:00
|
|
|
value,
|
|
|
|
g_param_spec_get_name (pspec),
|
|
|
|
i + 1, g_type_name (spec_type));
|
2006-11-23 20:42:58 +08:00
|
|
|
}
|
2006-11-23 17:17:07 +08:00
|
|
|
else
|
2006-11-23 20:42:58 +08:00
|
|
|
{
|
2007-12-03 02:05:54 +08:00
|
|
|
g_set_error (error,
|
2012-03-06 02:36:59 +08:00
|
|
|
GIMP_PDB_ERROR,
|
|
|
|
GIMP_PDB_ERROR_INVALID_ARGUMENT,
|
2007-12-03 02:05:54 +08:00
|
|
|
_("Procedure '%s' has been called with "
|
|
|
|
"value '%s' for argument '%s' "
|
|
|
|
"(#%d, type %s). "
|
|
|
|
"This value is out of range."),
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (procedure),
|
2007-12-03 02:05:54 +08:00
|
|
|
value,
|
|
|
|
g_param_spec_get_name (pspec),
|
|
|
|
i + 1, g_type_name (spec_type));
|
2006-11-23 20:42:58 +08:00
|
|
|
}
|
2006-11-23 17:17:07 +08:00
|
|
|
}
|
2006-04-08 02:23:20 +08:00
|
|
|
|
2012-02-07 21:06:12 +08:00
|
|
|
g_value_unset (&string_value);
|
2012-02-08 03:36:55 +08:00
|
|
|
|
2006-04-08 02:23:20 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_unset (&string_value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|