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
|
|
|
|
*
|
|
|
|
* 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>
|
2006-04-04 04:54:55 +08:00
|
|
|
#include <gobject/gvaluecollector.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"
|
2006-04-26 17:13:47 +08:00
|
|
|
#include "core/gimp-utils.h"
|
2004-04-15 07:37:34 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2006-04-28 03:36:13 +08:00
|
|
|
#include "core/gimpmarshal.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "core/gimpprogress.h"
|
2001-07-05 03:31:35 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
#include "gimppdb.h"
|
2007-12-03 02:05:54 +08:00
|
|
|
#include "gimppdberror.h"
|
2006-03-31 17:15:08 +08:00
|
|
|
#include "gimpprocedure.h"
|
2006-04-26 17:13:47 +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-28 03:36:13 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
REGISTER_PROCEDURE,
|
|
|
|
UNREGISTER_PROCEDURE,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void gimp_pdb_finalize (GObject *object);
|
|
|
|
static gint64 gimp_pdb_get_memsize (GimpObject *object,
|
|
|
|
gint64 *gui_size);
|
|
|
|
static void gimp_pdb_real_register_procedure (GimpPDB *pdb,
|
|
|
|
GimpProcedure *procedure);
|
|
|
|
static void gimp_pdb_real_unregister_procedure (GimpPDB *pdb,
|
|
|
|
GimpProcedure *procedure);
|
|
|
|
static void gimp_pdb_entry_free (gpointer key,
|
|
|
|
gpointer value,
|
|
|
|
gpointer user_data);
|
2007-03-06 04:09:46 +08:00
|
|
|
static gint64 gimp_pdb_entry_get_memsize (GList *procedures,
|
|
|
|
gint64 *gui_size);
|
2006-04-05 01:47:22 +08:00
|
|
|
|
2005-05-14 07:36:45 +08:00
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpPDB, gimp_pdb, GIMP_TYPE_OBJECT)
|
2006-04-26 17:13:47 +08:00
|
|
|
|
|
|
|
#define parent_class gimp_pdb_parent_class
|
|
|
|
|
2006-04-28 03:36:13 +08:00
|
|
|
static guint gimp_pdb_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_pdb_class_init (GimpPDBClass *klass)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-26 17:13:47 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
These changes enable help support for 3rd party plug-ins which install
2000-05-21 Michael Natterer <mitch@gimp.org>
These changes enable help support for 3rd party plug-ins which
install their help files outside GIMP's main help dir.
Instead of calling gimp_help(), gimp_plugin_help_func() etc.,
all help callbacks now have to call gimp_standard_help_func()
which has different implementations in the app and in libgimp.
There is a new function gimp_plugin_help_register() which can
be called during plug-in query. plug_in.c keeps a list of
executable_name/help_path pairs. Plug-ins have to pass their
exec. name to gimp_help() which uses the list to find the plug-in's
help directory.
* app/gimphelp.[ch]: gimp_help() now takes a help_path parameter.
help_path == NULL means the standard help directory. Various
changes to pass the help_path to the help browser.
* app/gimprc.c: save the plug-in's help_path in the pluginrc file.
* app/menus.c: ugly hack to enable help_paths in the "F1" callback.
* app/plug_in.[ch]: many help_path related changes. Use g_basename()
instead of strrchr(str,G_DIR_SEPARATOR), cosmetic cleanups.
* app/internal_procs.c
* app/gimphelp_cmds.c
* tools/pdbgen/pdb/gimphelp.pdb: new procedure
gimp_plugin_help_register(). gimp_help() takes a second parameter
which is the executable name (not the help_path).
* app/color_notebook.c
* app/commands.c
* app/lc_dialog.c
* app/preferences_dialog.c
* app/tools.c: call gimp_standard_help_func() instead of gimp_help().
* libgimp/gimp.c: new function gimp_get_progname() which returns
the full path of the plug-in's executable.
* libgimp/gimp.h: export the new function,
removed gimp_plugin_help_func(), gimp_help() takes the executable
name as second parameter.
* libgimp/gimpcompat.h: added gimp_plugin_help_func().
* libgimp/gimphelp.c: a wrapper for gimp_plugin_help_register(),
changed the calls to gimp_help.
* libgimp/gimphelpui.[ch]: call gimp_standard_help_func() instead
of gimp_help().
* plug-ins/helpbrowser/helpbrowser.c: now called with an additional
help_path parameter. Various changes to enable
help_path != gimp_standard_help_path.
Unrelated stuff:
* app/batch.h: added missing GPL header.
* app/gimpunit.c: had a LGPL header, merged some fprintf's into
one call.
* app/procedural_db.[ch]: cosmetic: g* types, s/g_malloc/g_new/,
prototypes, indentation.
* app/resize.c: use less packing widgets. didn't find the "offset"
redraw bug :(
2000-05-22 01:41:02 +08:00
|
|
|
|
2006-04-28 03:36:13 +08:00
|
|
|
gimp_pdb_signals[REGISTER_PROCEDURE] =
|
|
|
|
g_signal_new ("register-procedure",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpPDBClass, register_procedure),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GIMP_TYPE_PROCEDURE);
|
|
|
|
|
|
|
|
gimp_pdb_signals[UNREGISTER_PROCEDURE] =
|
|
|
|
g_signal_new ("unregister-procedure",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpPDBClass, unregister_procedure),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GIMP_TYPE_PROCEDURE);
|
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
object_class->finalize = gimp_pdb_finalize;
|
2006-04-06 18:01:30 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
gimp_object_class->get_memsize = gimp_pdb_get_memsize;
|
2006-04-28 03:36:13 +08:00
|
|
|
|
|
|
|
klass->register_procedure = gimp_pdb_real_register_procedure;
|
|
|
|
klass->unregister_procedure = gimp_pdb_real_unregister_procedure;
|
2006-04-26 17:13:47 +08:00
|
|
|
}
|
2006-04-06 18:01:30 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
static void
|
|
|
|
gimp_pdb_init (GimpPDB *pdb)
|
|
|
|
{
|
|
|
|
pdb->procedures = g_hash_table_new (g_str_hash, g_str_equal);
|
|
|
|
pdb->compat_proc_names = g_hash_table_new (g_str_hash, g_str_equal);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
static void
|
|
|
|
gimp_pdb_finalize (GObject *object)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-26 17:13:47 +08:00
|
|
|
GimpPDB *pdb = GIMP_PDB (object);
|
2002-09-11 04:23:00 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
if (pdb->procedures)
|
1999-10-28 04:45:57 +08:00
|
|
|
{
|
2006-04-26 17:13:47 +08:00
|
|
|
g_hash_table_foreach (pdb->procedures, gimp_pdb_entry_free, NULL);
|
|
|
|
g_hash_table_destroy (pdb->procedures);
|
|
|
|
pdb->procedures = NULL;
|
2001-07-05 03:31:35 +08:00
|
|
|
}
|
2002-09-11 04:23:00 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
if (pdb->compat_proc_names)
|
2003-12-05 21:02:18 +08:00
|
|
|
{
|
2006-04-26 17:13:47 +08:00
|
|
|
g_hash_table_destroy (pdb->compat_proc_names);
|
|
|
|
pdb->compat_proc_names = NULL;
|
2003-12-05 21:02:18 +08:00
|
|
|
}
|
2006-04-26 17:13:47 +08:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
static gint64
|
|
|
|
gimp_pdb_get_memsize (GimpObject *object,
|
|
|
|
gint64 *gui_size)
|
2003-12-05 21:02:18 +08:00
|
|
|
{
|
2006-04-26 17:13:47 +08:00
|
|
|
GimpPDB *pdb = GIMP_PDB (object);
|
|
|
|
gint64 memsize = 0;
|
2003-12-06 01:08:35 +08:00
|
|
|
|
2007-03-06 04:09:46 +08:00
|
|
|
memsize += gimp_g_hash_table_get_memsize_foreach (pdb->procedures,
|
|
|
|
(GimpMemsizeFunc)
|
|
|
|
gimp_pdb_entry_get_memsize,
|
|
|
|
gui_size);
|
|
|
|
memsize += gimp_g_hash_table_get_memsize (pdb->compat_proc_names, 0);
|
2006-04-26 17:13:47 +08:00
|
|
|
|
|
|
|
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
|
|
|
|
gui_size);
|
|
|
|
}
|
|
|
|
|
2006-04-28 03:36:13 +08:00
|
|
|
static void
|
|
|
|
gimp_pdb_real_register_procedure (GimpPDB *pdb,
|
|
|
|
GimpProcedure *procedure)
|
|
|
|
{
|
|
|
|
const gchar *name;
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
name = gimp_object_get_name (GIMP_OBJECT (procedure));
|
|
|
|
|
|
|
|
list = g_hash_table_lookup (pdb->procedures, name);
|
|
|
|
|
2006-05-24 06:41:05 +08:00
|
|
|
g_hash_table_replace (pdb->procedures, (gpointer) name,
|
|
|
|
g_list_prepend (list, g_object_ref (procedure)));
|
2006-04-28 03:36:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_pdb_real_unregister_procedure (GimpPDB *pdb,
|
|
|
|
GimpProcedure *procedure)
|
|
|
|
{
|
|
|
|
const gchar *name;
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
name = gimp_object_get_name (GIMP_OBJECT (procedure));
|
|
|
|
|
|
|
|
list = g_hash_table_lookup (pdb->procedures, name);
|
|
|
|
|
|
|
|
if (list)
|
|
|
|
{
|
|
|
|
list = g_list_remove (list, procedure);
|
|
|
|
|
|
|
|
if (list)
|
2006-05-24 06:41:05 +08:00
|
|
|
{
|
|
|
|
name = gimp_object_get_name (GIMP_OBJECT (list->data));
|
|
|
|
g_hash_table_replace (pdb->procedures, (gpointer) name, list);
|
|
|
|
}
|
2006-04-28 03:36:13 +08:00
|
|
|
else
|
2006-05-24 06:41:05 +08:00
|
|
|
{
|
|
|
|
g_hash_table_remove (pdb->procedures, name);
|
|
|
|
}
|
2006-04-28 03:36:13 +08:00
|
|
|
|
|
|
|
g_object_unref (procedure);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
GimpPDB *
|
|
|
|
gimp_pdb_new (Gimp *gimp)
|
|
|
|
{
|
|
|
|
GimpPDB *pdb;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
|
|
|
|
pdb = g_object_new (GIMP_TYPE_PDB,
|
|
|
|
"name", "pdb",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
pdb->gimp = gimp;
|
|
|
|
|
|
|
|
return pdb;
|
2003-12-05 21:02:18 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
2006-04-26 17:13:47 +08:00
|
|
|
gimp_pdb_register_procedure (GimpPDB *pdb,
|
|
|
|
GimpProcedure *procedure)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-26 17:13:47 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PDB (pdb));
|
2006-04-01 01:42:13 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
2002-09-11 04:23:00 +08:00
|
|
|
|
2006-09-19 19:58:57 +08:00
|
|
|
if (! procedure->deprecated ||
|
|
|
|
pdb->gimp->pdb_compat_mode != GIMP_PDB_COMPAT_OFF)
|
|
|
|
{
|
|
|
|
g_signal_emit (pdb, gimp_pdb_signals[REGISTER_PROCEDURE], 0,
|
|
|
|
procedure);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-26 17:13:47 +08:00
|
|
|
gimp_pdb_unregister_procedure (GimpPDB *pdb,
|
|
|
|
GimpProcedure *procedure)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-26 17:13:47 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PDB (pdb));
|
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-28 03:36:13 +08:00
|
|
|
g_signal_emit (pdb, gimp_pdb_signals[UNREGISTER_PROCEDURE], 0,
|
|
|
|
procedure);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-04-01 01:42:13 +08:00
|
|
|
GimpProcedure *
|
2006-04-26 17:13:47 +08:00
|
|
|
gimp_pdb_lookup_procedure (GimpPDB *pdb,
|
|
|
|
const gchar *name)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-12-28 01:58:30 +08:00
|
|
|
GList *list;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PDB (pdb), NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2002-09-11 04:23:00 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
list = g_hash_table_lookup (pdb->procedures, name);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-12-28 01:58:30 +08:00
|
|
|
if (list)
|
2005-11-05 20:18:56 +08:00
|
|
|
return list->data;
|
2006-04-05 01:47:22 +08:00
|
|
|
|
|
|
|
return NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
void
|
|
|
|
gimp_pdb_register_compat_proc_name (GimpPDB *pdb,
|
|
|
|
const gchar *old_name,
|
|
|
|
const gchar *new_name)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PDB (pdb));
|
|
|
|
g_return_if_fail (old_name != NULL);
|
|
|
|
g_return_if_fail (new_name != NULL);
|
|
|
|
|
|
|
|
g_hash_table_insert (pdb->compat_proc_names,
|
|
|
|
(gpointer) old_name,
|
|
|
|
(gpointer) new_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
const gchar *
|
|
|
|
gimp_pdb_lookup_compat_proc_name (GimpPDB *pdb,
|
|
|
|
const gchar *old_name)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_PDB (pdb), NULL);
|
|
|
|
g_return_val_if_fail (old_name != NULL, NULL);
|
|
|
|
|
|
|
|
return g_hash_table_lookup (pdb->compat_proc_names, old_name);
|
|
|
|
}
|
|
|
|
|
2006-04-04 18:30:58 +08:00
|
|
|
GValueArray *
|
2007-12-03 02:05:54 +08:00
|
|
|
gimp_pdb_execute_procedure_by_name_args (GimpPDB *pdb,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
GError **error,
|
|
|
|
const gchar *name,
|
|
|
|
GValueArray *args)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-04 18:30:58 +08:00
|
|
|
GValueArray *return_vals = NULL;
|
|
|
|
GList *list;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PDB (pdb), NULL);
|
2004-04-15 07:37:34 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
2004-08-11 02:47:21 +08:00
|
|
|
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
|
2007-12-03 02:05:54 +08:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
2006-04-26 17:13:47 +08:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2002-09-11 04:23:00 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
list = g_hash_table_lookup (pdb->procedures, name);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-28 04:45:57 +08:00
|
|
|
if (list == NULL)
|
|
|
|
{
|
2008-08-16 21:57:57 +08:00
|
|
|
GError *pdb_error = g_error_new (GIMP_PDB_ERROR,
|
|
|
|
GIMP_PDB_PROCEDURE_NOT_FOUND,
|
|
|
|
_("Procedure '%s' not found"), name);
|
2003-02-03 21:45:40 +08:00
|
|
|
|
2008-08-16 21:57:57 +08:00
|
|
|
return_vals = gimp_procedure_get_return_values (NULL, FALSE, pdb_error);
|
|
|
|
g_propagate_error (error, pdb_error);
|
2006-03-30 07:56:07 +08:00
|
|
|
|
|
|
|
return return_vals;
|
1999-10-28 04:45:57 +08:00
|
|
|
}
|
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-04-05 05:11:45 +08:00
|
|
|
g_return_val_if_fail (args != NULL, NULL);
|
|
|
|
|
2003-02-03 21:45:40 +08:00
|
|
|
for (; list; list = g_list_next (list))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-01 01:42:13 +08:00
|
|
|
GimpProcedure *procedure = list->data;
|
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-04-01 01:42:13 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-31 17:15:08 +08:00
|
|
|
return_vals = gimp_procedure_execute (procedure,
|
2006-04-26 17:13:47 +08:00
|
|
|
pdb->gimp, context, progress,
|
2007-12-03 02:05:54 +08:00
|
|
|
args, error);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-04 18:30:58 +08:00
|
|
|
if (g_value_get_enum (&return_vals->values[0]) == GIMP_PDB_PASS_THROUGH)
|
2003-02-03 21:45:40 +08:00
|
|
|
{
|
|
|
|
/* If the return value is GIMP_PDB_PASS_THROUGH and there is
|
|
|
|
* a next procedure in the list, destroy the return values
|
|
|
|
* and run the next procedure.
|
|
|
|
*/
|
|
|
|
if (g_list_next (list))
|
2007-12-03 02:05:54 +08:00
|
|
|
{
|
|
|
|
g_value_array_free (return_vals);
|
|
|
|
g_clear_error (error);
|
|
|
|
}
|
2003-02-03 21:45:40 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* No GIMP_PDB_PASS_THROUGH, break out of the list of
|
|
|
|
* procedures and return the current return values.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
return return_vals;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-04-04 18:30:58 +08:00
|
|
|
GValueArray *
|
2007-12-03 02:05:54 +08:00
|
|
|
gimp_pdb_execute_procedure_by_name (GimpPDB *pdb,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
GError **error,
|
|
|
|
const gchar *name,
|
2006-04-26 17:13:47 +08:00
|
|
|
...)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-01 01:42:13 +08:00
|
|
|
GimpProcedure *procedure;
|
2006-04-04 18:30:58 +08:00
|
|
|
GValueArray *args;
|
|
|
|
GValueArray *return_vals;
|
2006-04-01 04:16:22 +08:00
|
|
|
va_list va_args;
|
2006-04-01 01:42:13 +08:00
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PDB (pdb), NULL);
|
2004-04-15 07:37:34 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
2004-08-11 02:47:21 +08:00
|
|
|
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
|
2007-12-03 02:05:54 +08:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
2006-04-26 17:13:47 +08:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2002-09-11 04:23:00 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
procedure = gimp_pdb_lookup_procedure (pdb, name);
|
2004-09-16 18:32:30 +08:00
|
|
|
|
2008-08-16 21:57:57 +08:00
|
|
|
if (! procedure)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2008-08-16 21:57:57 +08:00
|
|
|
GError *pdb_error = g_error_new (GIMP_PDB_ERROR,
|
|
|
|
GIMP_PDB_PROCEDURE_NOT_FOUND,
|
|
|
|
_("Procedure '%s' not found"), name);
|
2006-03-27 18:53:25 +08:00
|
|
|
|
2008-08-16 21:57:57 +08:00
|
|
|
return_vals = gimp_procedure_get_return_values (NULL, FALSE, pdb_error);
|
|
|
|
g_propagate_error (error, pdb_error);
|
2001-12-28 01:58:30 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return return_vals;
|
|
|
|
}
|
|
|
|
|
2006-04-01 04:16:22 +08:00
|
|
|
args = gimp_procedure_get_arguments (procedure);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
va_start (va_args, name);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-01 01:42:13 +08:00
|
|
|
for (i = 0; i < procedure->num_args; i++)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-04 04:54:55 +08:00
|
|
|
GValue *value;
|
|
|
|
GType arg_type;
|
2007-12-03 02:05:54 +08:00
|
|
|
gchar *error_msg = NULL;
|
2004-09-16 18:32:30 +08:00
|
|
|
|
2006-04-04 04:54:55 +08:00
|
|
|
arg_type = va_arg (va_args, GType);
|
|
|
|
|
|
|
|
if (arg_type == G_TYPE_NONE)
|
2006-03-27 18:53:25 +08:00
|
|
|
break;
|
|
|
|
|
2006-04-04 18:30:58 +08:00
|
|
|
value = &args->values[i];
|
2006-04-04 04:54:55 +08:00
|
|
|
|
|
|
|
if (arg_type != G_VALUE_TYPE (value))
|
2004-03-27 00:49:18 +08:00
|
|
|
{
|
2008-08-16 21:57:57 +08:00
|
|
|
GError *pdb_error;
|
2006-04-04 04:54:55 +08:00
|
|
|
const gchar *expected = g_type_name (G_VALUE_TYPE (value));
|
|
|
|
const gchar *got = g_type_name (arg_type);
|
2005-05-14 07:36:45 +08:00
|
|
|
|
2006-04-04 18:30:58 +08:00
|
|
|
g_value_array_free (args);
|
2003-01-09 20:45:25 +08:00
|
|
|
|
2008-08-16 21:57:57 +08:00
|
|
|
pdb_error = g_error_new (GIMP_PDB_ERROR, GIMP_PDB_INVALID_ARGUMENT,
|
2008-08-16 22:12:38 +08:00
|
|
|
_("Procedure '%s' has been called with a "
|
|
|
|
"wrong type for argument #%d."
|
|
|
|
"Expected %s, got %s."),
|
2008-08-16 21:57:57 +08:00
|
|
|
gimp_object_get_name (GIMP_OBJECT (procedure)),
|
|
|
|
i + 1, expected, got);
|
2005-05-14 07:36:45 +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-27 17:32:39 +08:00
|
|
|
|
2007-10-29 03:17:54 +08:00
|
|
|
va_end (va_args);
|
|
|
|
|
2006-03-27 17:32:39 +08:00
|
|
|
return return_vals;
|
2004-03-27 00:49:18 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2007-12-03 02:05:54 +08:00
|
|
|
G_VALUE_COLLECT (value, va_args, G_VALUE_NOCOPY_CONTENTS, &error_msg);
|
2006-03-30 07:56:07 +08:00
|
|
|
|
2007-12-03 02:05:54 +08:00
|
|
|
if (error_msg)
|
2004-03-27 00:49:18 +08:00
|
|
|
{
|
2008-08-16 21:57:57 +08:00
|
|
|
GError *pdb_error = g_error_new (GIMP_PDB_ERROR,
|
|
|
|
GIMP_PDB_INTERNAL_ERROR,
|
|
|
|
"%s", error_msg);
|
|
|
|
|
2007-12-03 02:05:54 +08:00
|
|
|
g_warning ("%s: %s", G_STRFUNC, error_msg);
|
|
|
|
g_free (error_msg);
|
2006-04-01 09:33:28 +08:00
|
|
|
|
2006-04-04 18:30:58 +08:00
|
|
|
g_value_array_free (args);
|
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-30 07:56:07 +08:00
|
|
|
|
2007-10-29 03:17:54 +08:00
|
|
|
va_end (va_args);
|
|
|
|
|
2006-04-04 04:54:55 +08:00
|
|
|
return return_vals;
|
2004-03-27 00:49:18 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-04-01 04:16:22 +08:00
|
|
|
va_end (va_args);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
return_vals = gimp_pdb_execute_procedure_by_name_args (pdb, context,
|
2007-12-03 02:05:54 +08:00
|
|
|
progress, error,
|
2006-04-26 17:13:47 +08:00
|
|
|
name, args);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-04 18:30:58 +08:00
|
|
|
g_value_array_free (args);
|
2006-03-27 18:53:25 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return return_vals;
|
|
|
|
}
|
2006-04-05 01:47:22 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
2006-04-26 17:13:47 +08:00
|
|
|
gimp_pdb_entry_free (gpointer key,
|
2006-04-05 01:47:22 +08:00
|
|
|
gpointer value,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
if (value)
|
|
|
|
{
|
2006-04-05 05:11:45 +08:00
|
|
|
g_list_foreach (value, (GFunc) g_object_unref, NULL);
|
2006-04-05 01:47:22 +08:00
|
|
|
g_list_free (value);
|
|
|
|
}
|
|
|
|
}
|
2006-04-26 17:13:47 +08:00
|
|
|
|
2007-03-06 04:09:46 +08:00
|
|
|
static gint64
|
|
|
|
gimp_pdb_entry_get_memsize (GList *procedures,
|
|
|
|
gint64 *gui_size)
|
2006-04-26 17:13:47 +08:00
|
|
|
{
|
2007-03-06 04:09:46 +08:00
|
|
|
return gimp_g_list_get_memsize_foreach (procedures,
|
|
|
|
(GimpMemsizeFunc)
|
|
|
|
gimp_object_get_memsize,
|
|
|
|
gui_size);
|
2006-04-26 17:13:47 +08:00
|
|
|
}
|