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
|
|
|
|
*
|
2006-05-04 02:05:06 +08:00
|
|
|
* gimpplugin.c
|
2004-09-22 23:12:24 +08:00
|
|
|
*
|
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-07-16 20:49:04 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "config.h"
|
1999-03-07 20:56:03 +08:00
|
|
|
|
2008-10-01 20:27:32 +08:00
|
|
|
#ifndef _WIN32
|
2006-09-20 18:31:22 +08:00
|
|
|
#define _GNU_SOURCE
|
2008-10-01 20:27:32 +08:00
|
|
|
#endif
|
2006-09-20 18:31:22 +08:00
|
|
|
|
2003-12-08 21:29:14 +08:00
|
|
|
#include <errno.h>
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <signal.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2003-01-30 19:20:12 +08:00
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
#ifdef HAVE_SYS_WAIT_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <sys/wait.h>
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
2003-01-30 19:20:12 +08:00
|
|
|
|
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
|
|
#include <sys/param.h>
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
|
|
|
|
2012-03-30 01:19:01 +08:00
|
|
|
#include <gegl.h>
|
2003-01-30 19:20:12 +08:00
|
|
|
|
1999-10-07 05:27:18 +08:00
|
|
|
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
2003-01-20 20:17:32 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
#define STRICT
|
|
|
|
#include <windows.h>
|
|
|
|
#include <process.h>
|
|
|
|
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifdef G_OS_WIN32
|
1999-03-07 20:56:03 +08:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <io.h>
|
2007-06-20 17:22:34 +08:00
|
|
|
|
|
|
|
#ifndef pipe
|
|
|
|
#define pipe(fds) _pipe(fds, 4096, _O_BINARY)
|
|
|
|
#endif
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
|
|
|
|
1999-10-07 05:27:18 +08:00
|
|
|
#ifdef G_WITH_CYGWIN
|
2006-05-04 02:05:06 +08:00
|
|
|
#define O_TEXT 0x0100 /* text file */
|
|
|
|
#define _O_TEXT 0x0100 /* text file */
|
|
|
|
#define O_BINARY 0x0200 /* binary file */
|
|
|
|
#define _O_BINARY 0x0200 /* binary file */
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
#endif /* G_OS_WIN32 || G_WITH_CYGWIN */
|
1999-03-07 20:56:03 +08:00
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
#include "libgimpbase/gimpprotocol.h"
|
|
|
|
#include "libgimpbase/gimpwire.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2001-12-01 08:14:14 +08:00
|
|
|
#include "plug-in-types.h"
|
2001-05-22 04:30:16 +08:00
|
|
|
|
2001-07-11 20:39:49 +08:00
|
|
|
#include "core/gimp.h"
|
2004-09-22 20:27:18 +08:00
|
|
|
#include "core/gimpprogress.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2010-09-05 04:17:01 +08:00
|
|
|
#include "pdb/gimppdbcontext.h"
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
#include "gimpenvirontable.h"
|
|
|
|
#include "gimpinterpreterdb.h"
|
2006-05-04 02:05:06 +08:00
|
|
|
#include "gimpplugin.h"
|
|
|
|
#include "gimpplugin-message.h"
|
|
|
|
#include "gimpplugin-progress.h"
|
2006-04-29 06:26:51 +08:00
|
|
|
#include "gimpplugindebug.h"
|
2007-02-19 09:16:05 +08:00
|
|
|
#include "gimpplugindef.h"
|
2006-04-29 06:26:51 +08:00
|
|
|
#include "gimppluginmanager.h"
|
2007-02-18 22:25:34 +08:00
|
|
|
#include "gimppluginmanager-help-domain.h"
|
2006-04-29 06:26:51 +08:00
|
|
|
#include "gimppluginmanager-locale-domain.h"
|
2006-08-06 05:21:01 +08:00
|
|
|
#include "gimptemporaryprocedure.h"
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-in-params.h"
|
2001-12-01 08:14:14 +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
|
|
|
|
Bit of a large checkin this - it's basically three things: 1 - GimpModules
Sun Jan 11 00:24:21 GMT 1999 Austin Donnelly <austin@greenend.org.uk>
Bit of a large checkin this - it's basically three things:
1 - GimpModules using gmodules to dynamically load and
initialise modules at gimp start of day.
2 - Color selectors now register themselves with a color
notebook.
3 - progress bars have been cleaned up a bit, so now have
progress indictations on all transform tool and gradient
fill operations. Not done bucket fill, but that seems to
be the next candidate.
New directories:
* modules/: new directory for dynamically loadable modules.
New files:
* modules/.cvsignore
* modules/Makefile.am
* modules/colorsel_gtk.c: GTK color selector wrapped up as a
color selector the gimp can use.
* app/gimpprogress.[ch]: progress bars within gimp core, either as
popups, or in the status bar. This is mainly code moved out
of plug-in.c
* app/color_notebook.[ch]: color selector notebook, implementing
very similar interface to color_select.h so it can be used as
a drop-in replacement for it.
* libgimp/color_selector.h: API color selectors need to implement
to become a page in the color_notebook.
* libgimp/gimpmodule.h: API gimp modules need to implement to be
initialised by gimp at start of day.
Modified files:
* Makefile.am: add modules/ to SUBDIRS
* libgimp/Makefile.am: install gimpmodule.h and color_selector.h
* app/gimprc.[ch]: recognise module-path variable.
* gimprc.in: set module-path variable to something sensible
(currently "${gimp_dir}/modules:${gimp_plugin_dir}/modules").
* app/Makefile.am: build color notebook and gimpprogress
* app/app_procs.c: register internal GIMP color selector with
color notebook.
* app/asupsample.c: call progress function less frequently for
better performance.
* app/asupsample.h: progress_func_t typedef moved to gimpprogress.h
* app/blend.c: make callbacks to a progress function
* app/color_area.c: use a color notebook rather than a color selector
* app/color_panel.c: ditto
* app/color_select.c: export color selector interface for notebook
* app/color_select.h: color_select_init() prototype
* app/flip_tool.c: flip the image every time, rather than every
second click.
* app/interface.c: move progress bar stuff out to
gimpprogress.c. Make the code actually work while we're at it.
* app/interface.h: move prototypes for progress functions out to
gimpprogress.h
* app/plug_in.c: load and initialise modules (if possible). Move
progress bar handling code out to gimpprogress.c
* app/plug_in.h: keep only a gimp_progress * for each plugin, not
a whole bunch of GtkWidgets.
* app/scale_tool.c
* app/rotate_tool.c
* app/shear_tool.c
* app/perspective_tool.c: progress bar during operation.
De-sensitise the dialog to discourage the user from running
two transforms in parallel.
* app/transform_core.c: recalculate grid coords when bounding box
changes. Only initialise the action area of the dialog once,
to avoid multiple "ok" / "reset" buttons appearing. Undraw
transform tool with correct matrix to get rid of handle
remains on screen. Call a progress function as we apply the
transform matrix. A few new i18n markups. Invalidate
floating selection marching ants after applying matrix.
* app/transform_core.h: transform_core_do() takes an optional
progress callback argument (and data).
* plug-ins/oilify/oilify.c: send progress bar updates after every
pixel region, not only if they processed a multiple of 5
pixels (which was quite unlikely, and therefore gave a jerky
progress indication).
1999-01-11 08:57:33 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
static void gimp_plug_in_finalize (GObject *object);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
static gboolean gimp_plug_in_write (GIOChannel *channel,
|
|
|
|
const guint8 *buf,
|
|
|
|
gulong count,
|
|
|
|
gpointer data);
|
|
|
|
static gboolean gimp_plug_in_flush (GIOChannel *channel,
|
|
|
|
gpointer data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
static gboolean gimp_plug_in_recv_message (GIOChannel *channel,
|
|
|
|
GIOCondition cond,
|
|
|
|
gpointer data);
|
1999-03-07 20:56:03 +08:00
|
|
|
|
2005-08-26 20:03:24 +08:00
|
|
|
#if !defined(G_OS_WIN32) && !defined (G_WITH_CYGWIN)
|
2006-05-04 02:05:06 +08:00
|
|
|
static void gimp_plug_in_prep_for_exec (gpointer data);
|
|
|
|
#else
|
|
|
|
#define gimp_plug_in_prep_for_exec NULL
|
2005-08-26 20:03:24 +08:00
|
|
|
#endif
|
2002-06-13 20:02:06 +08:00
|
|
|
|
2006-04-10 00:25:47 +08:00
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpPlugIn, gimp_plug_in, GIMP_TYPE_OBJECT)
|
2001-10-20 00:41:09 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
#define parent_class gimp_plug_in_parent_class
|
2005-12-13 22:11:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
static void
|
|
|
|
gimp_plug_in_class_init (GimpPlugInClass *klass)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2003-01-30 19:20:12 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
object_class->finalize = gimp_plug_in_finalize;
|
2003-02-03 21:21:31 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
/* initialize the gimp protocol library and set the read and
|
|
|
|
* write handlers.
|
|
|
|
*/
|
|
|
|
gp_init ();
|
|
|
|
gimp_wire_set_writer (gimp_plug_in_write);
|
|
|
|
gimp_wire_set_flusher (gimp_plug_in_flush);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
static void
|
|
|
|
gimp_plug_in_init (GimpPlugIn *plug_in)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-05-04 19:58:10 +08:00
|
|
|
plug_in->manager = NULL;
|
|
|
|
plug_in->prog = NULL;
|
|
|
|
|
2006-05-03 02:27:31 +08:00
|
|
|
plug_in->call_mode = GIMP_PLUG_IN_CALL_NONE;
|
2006-05-04 19:58:10 +08:00
|
|
|
plug_in->open = FALSE;
|
2007-07-31 00:24:14 +08:00
|
|
|
plug_in->hup = FALSE;
|
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
|
|
|
plug_in->pid = 0;
|
2003-01-30 19:20:12 +08:00
|
|
|
|
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
|
|
|
plug_in->my_read = NULL;
|
|
|
|
plug_in->my_write = NULL;
|
|
|
|
plug_in->his_read = NULL;
|
|
|
|
plug_in->his_write = NULL;
|
2003-01-30 19:20:12 +08:00
|
|
|
|
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
|
|
|
plug_in->input_id = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
plug_in->write_buffer_index = 0;
|
2003-01-30 19:20:12 +08:00
|
|
|
|
2006-04-07 16:16:26 +08:00
|
|
|
plug_in->temp_procedures = NULL;
|
2003-01-30 19:20:12 +08:00
|
|
|
|
2003-06-24 02:27:03 +08:00
|
|
|
plug_in->ext_main_loop = NULL;
|
2004-01-20 08:54:43 +08:00
|
|
|
|
2004-09-22 07:56:40 +08:00
|
|
|
plug_in->temp_proc_frames = NULL;
|
2003-01-30 19:20:12 +08:00
|
|
|
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_in->plug_in_def = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-05-04 19:58:10 +08:00
|
|
|
static void
|
|
|
|
gimp_plug_in_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpPlugIn *plug_in = GIMP_PLUG_IN (object);
|
|
|
|
|
|
|
|
g_free (plug_in->prog);
|
|
|
|
|
|
|
|
gimp_plug_in_proc_frame_dispose (&plug_in->main_proc_frame, plug_in);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
GimpPlugIn *
|
|
|
|
gimp_plug_in_new (GimpPlugInManager *manager,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
GimpPlugInProcedure *procedure,
|
|
|
|
const gchar *prog)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
GimpPlugIn *plug_in;
|
2003-01-20 20:17:32 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), NULL);
|
2010-09-05 04:17:01 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PDB_CONTEXT (context), NULL);
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
|
|
|
|
g_return_val_if_fail (procedure == NULL ||
|
|
|
|
GIMP_IS_PLUG_IN_PROCEDURE (procedure), NULL);
|
2007-03-15 04:03:10 +08:00
|
|
|
g_return_val_if_fail (prog == NULL || g_path_is_absolute (prog), NULL);
|
|
|
|
g_return_val_if_fail ((procedure != NULL || prog != NULL) &&
|
|
|
|
! (procedure != NULL && prog != NULL), NULL);
|
2006-05-04 02:05:06 +08:00
|
|
|
|
|
|
|
plug_in = g_object_new (GIMP_TYPE_PLUG_IN, NULL);
|
|
|
|
|
2007-03-15 04:03:10 +08:00
|
|
|
if (! prog)
|
|
|
|
prog = gimp_plug_in_procedure_get_progname (procedure);
|
|
|
|
|
2006-05-04 19:58:10 +08:00
|
|
|
gimp_object_take_name (GIMP_OBJECT (plug_in),
|
|
|
|
g_filename_display_basename (prog));
|
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
plug_in->manager = manager;
|
|
|
|
plug_in->prog = g_strdup (prog);
|
|
|
|
|
|
|
|
gimp_plug_in_proc_frame_init (&plug_in->main_proc_frame,
|
|
|
|
context, progress, procedure);
|
|
|
|
|
|
|
|
return plug_in;
|
2003-02-03 21:21:31 +08:00
|
|
|
}
|
2003-01-20 20:17:32 +08:00
|
|
|
|
2000-02-25 00:11:26 +08:00
|
|
|
gboolean
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_open (GimpPlugIn *plug_in,
|
|
|
|
GimpPlugInCallMode call_mode,
|
|
|
|
gboolean synchronous)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2008-09-05 23:46:00 +08:00
|
|
|
gint my_read[2];
|
|
|
|
gint my_write[2];
|
|
|
|
gchar **envp;
|
|
|
|
const gchar *args[9];
|
|
|
|
gchar **argv;
|
|
|
|
gint argc;
|
|
|
|
gchar *interp, *interp_arg;
|
|
|
|
gchar *read_fd, *write_fd;
|
|
|
|
const gchar *mode;
|
|
|
|
gchar *stm;
|
|
|
|
GError *error = NULL;
|
|
|
|
gboolean debug;
|
|
|
|
guint debug_flag;
|
|
|
|
guint spawn_flags;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE);
|
2006-05-03 02:27:31 +08:00
|
|
|
g_return_val_if_fail (plug_in->call_mode == GIMP_PLUG_IN_CALL_NONE, FALSE);
|
2002-03-21 01:46:13 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
/* Open two pipes. (Bidirectional communication).
|
|
|
|
*/
|
|
|
|
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Unable to run plug-in \"%s\"\n(%s)\n\npipe() failed: %s",
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (plug_in),
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_filename_to_utf8 (plug_in->prog),
|
|
|
|
g_strerror (errno));
|
2003-01-20 20:17:32 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-12 05:25:24 +08:00
|
|
|
#if defined(G_WITH_CYGWIN)
|
2003-01-20 20:17:32 +08:00
|
|
|
/* Set to binary mode */
|
|
|
|
setmode (my_read[0], _O_BINARY);
|
|
|
|
setmode (my_write[0], _O_BINARY);
|
|
|
|
setmode (my_read[1], _O_BINARY);
|
|
|
|
setmode (my_write[1], _O_BINARY);
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
|
|
|
|
2007-01-25 19:38:04 +08:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
/* Prevent the plug-in from inheriting our ends of the pipes */
|
|
|
|
SetHandleInformation ((HANDLE) _get_osfhandle (my_read[0]), HANDLE_FLAG_INHERIT, 0);
|
|
|
|
SetHandleInformation ((HANDLE) _get_osfhandle (my_write[1]), HANDLE_FLAG_INHERIT, 0);
|
|
|
|
#endif
|
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
|
|
|
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
|
|
|
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
|
|
|
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
|
|
|
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
|
|
|
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
|
|
|
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
2001-08-30 01:48:28 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
|
|
|
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
|
|
|
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
|
|
|
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
2001-08-30 09:09:58 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
|
|
|
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
|
|
|
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
|
|
|
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
2001-08-30 01:48:28 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
/* Remember the file descriptors for the pipes.
|
|
|
|
*/
|
2003-06-24 02:27:03 +08:00
|
|
|
read_fd = g_strdup_printf ("%d",
|
|
|
|
g_io_channel_unix_get_fd (plug_in->his_read));
|
|
|
|
write_fd = g_strdup_printf ("%d",
|
|
|
|
g_io_channel_unix_get_fd (plug_in->his_write));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-05-03 02:27:31 +08:00
|
|
|
switch (call_mode)
|
2003-01-20 20:17:32 +08:00
|
|
|
{
|
2006-05-03 02:27:31 +08:00
|
|
|
case GIMP_PLUG_IN_CALL_QUERY:
|
2003-02-11 09:21:21 +08:00
|
|
|
mode = "-query";
|
|
|
|
debug_flag = GIMP_DEBUG_WRAP_QUERY;
|
2006-05-03 02:27:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PLUG_IN_CALL_INIT:
|
2003-02-11 09:21:21 +08:00
|
|
|
mode = "-init";
|
|
|
|
debug_flag = GIMP_DEBUG_WRAP_INIT;
|
2006-05-03 02:27:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PLUG_IN_CALL_RUN:
|
2003-02-11 09:21:21 +08:00
|
|
|
mode = "-run";
|
|
|
|
debug_flag = GIMP_DEBUG_WRAP_RUN;
|
2006-05-03 02:27:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
2003-01-20 20:17:32 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
stm = g_strdup_printf ("%d", plug_in->manager->gimp->stack_trace_mode);
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
interp = gimp_interpreter_db_resolve (plug_in->manager->interpreter_db,
|
2005-02-21 10:56:29 +08:00
|
|
|
plug_in->prog, &interp_arg);
|
|
|
|
|
|
|
|
argc = 0;
|
|
|
|
|
|
|
|
if (interp)
|
|
|
|
args[argc++] = interp;
|
2005-08-25 06:02:02 +08:00
|
|
|
|
2005-02-21 10:56:29 +08:00
|
|
|
if (interp_arg)
|
|
|
|
args[argc++] = interp_arg;
|
|
|
|
|
|
|
|
args[argc++] = plug_in->prog;
|
|
|
|
args[argc++] = "-gimp";
|
|
|
|
args[argc++] = read_fd;
|
|
|
|
args[argc++] = write_fd;
|
|
|
|
args[argc++] = mode;
|
|
|
|
args[argc++] = stm;
|
|
|
|
args[argc++] = NULL;
|
2003-02-11 09:21:21 +08:00
|
|
|
|
2008-09-05 23:46:00 +08:00
|
|
|
argv = (gchar **) args;
|
2006-04-29 06:26:51 +08:00
|
|
|
envp = gimp_environ_table_get_envp (plug_in->manager->environ_table);
|
2003-03-22 00:50:55 +08:00
|
|
|
spawn_flags = (G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
|
|
|
G_SPAWN_DO_NOT_REAP_CHILD |
|
|
|
|
G_SPAWN_CHILD_INHERITS_STDIN);
|
2003-02-11 09:21:21 +08:00
|
|
|
|
|
|
|
debug = FALSE;
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
if (plug_in->manager->debug)
|
2003-02-11 09:21:21 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
gchar **debug_argv = gimp_plug_in_debug_argv (plug_in->manager->debug,
|
2006-05-04 19:58:10 +08:00
|
|
|
plug_in->prog,
|
2006-04-29 06:26:51 +08:00
|
|
|
debug_flag, args);
|
2003-02-11 09:21:21 +08:00
|
|
|
|
|
|
|
if (debug_argv)
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
debug = TRUE;
|
|
|
|
argv = debug_argv;
|
|
|
|
spawn_flags |= G_SPAWN_SEARCH_PATH;
|
|
|
|
}
|
2003-02-11 09:21:21 +08:00
|
|
|
}
|
|
|
|
|
2003-02-03 21:21:31 +08:00
|
|
|
/* Fork another process. We'll remember the process id so that we
|
|
|
|
* can later use it to kill the filter if necessary.
|
2003-01-20 20:17:32 +08:00
|
|
|
*/
|
2003-02-11 09:21:21 +08:00
|
|
|
if (! g_spawn_async (NULL, argv, envp, spawn_flags,
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_prep_for_exec, plug_in,
|
2003-01-20 20:17:32 +08:00
|
|
|
&plug_in->pid,
|
|
|
|
&error))
|
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Unable to run plug-in \"%s\"\n(%s)\n\n%s",
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (plug_in),
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_filename_to_utf8 (plug_in->prog),
|
|
|
|
error->message);
|
2003-01-20 20:17:32 +08:00
|
|
|
g_error_free (error);
|
2003-02-11 09:21:21 +08:00
|
|
|
goto cleanup;
|
2003-01-20 20:17:32 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
g_io_channel_unref (plug_in->his_read);
|
2003-01-30 19:20:12 +08:00
|
|
|
plug_in->his_read = NULL;
|
2001-08-30 01:48:28 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
g_io_channel_unref (plug_in->his_write);
|
|
|
|
plug_in->his_write = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-05-03 02:27:31 +08:00
|
|
|
if (! synchronous)
|
2003-01-20 20:17:32 +08:00
|
|
|
{
|
2004-08-30 06:21:53 +08:00
|
|
|
GSource *source;
|
|
|
|
|
|
|
|
source = g_io_create_watch (plug_in->my_read,
|
|
|
|
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP);
|
|
|
|
|
2004-09-01 04:30:23 +08:00
|
|
|
g_source_set_callback (source,
|
2006-05-04 02:05:06 +08:00
|
|
|
(GSourceFunc) gimp_plug_in_recv_message, plug_in,
|
2004-09-01 04:30:23 +08:00
|
|
|
NULL);
|
|
|
|
|
2004-08-30 06:21:53 +08:00
|
|
|
g_source_set_can_recurse (source, TRUE);
|
|
|
|
|
|
|
|
plug_in->input_id = g_source_attach (source, NULL);
|
|
|
|
g_source_unref (source);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-05-03 02:27:31 +08:00
|
|
|
plug_in->open = TRUE;
|
|
|
|
plug_in->call_mode = call_mode;
|
2003-02-11 09:21:21 +08:00
|
|
|
|
2006-05-05 06:51:21 +08:00
|
|
|
gimp_plug_in_manager_add_open_plug_in (plug_in->manager, plug_in);
|
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
cleanup:
|
2003-02-11 09:21:21 +08:00
|
|
|
|
|
|
|
if (debug)
|
|
|
|
g_free (argv);
|
|
|
|
|
|
|
|
g_free (read_fd);
|
|
|
|
g_free (write_fd);
|
|
|
|
g_free (stm);
|
2005-02-21 10:56:29 +08:00
|
|
|
g_free (interp);
|
|
|
|
g_free (interp_arg);
|
|
|
|
|
2003-02-11 09:21:21 +08:00
|
|
|
return plug_in->open;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (GimpPlugIn *plug_in,
|
|
|
|
gboolean kill_it)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
2006-05-15 18:31:04 +08:00
|
|
|
g_return_if_fail (plug_in->open);
|
2001-09-03 21:03:34 +08:00
|
|
|
|
|
|
|
plug_in->open = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-02-09 06:38:58 +08:00
|
|
|
if (plug_in->pid)
|
2001-09-03 21:03:34 +08:00
|
|
|
{
|
2006-04-30 03:03:44 +08:00
|
|
|
#ifndef G_OS_WIN32
|
|
|
|
gint status;
|
|
|
|
#endif
|
|
|
|
|
2007-07-31 00:24:14 +08:00
|
|
|
/* Ask the filter to exit gracefully,
|
|
|
|
but not if it is closed because of a broken pipe. */
|
|
|
|
if (kill_it && ! plug_in->hup)
|
2005-02-09 06:38:58 +08:00
|
|
|
{
|
|
|
|
gp_quit_write (plug_in->my_write, plug_in);
|
2001-09-03 21:03:34 +08:00
|
|
|
|
2005-02-09 06:38:58 +08:00
|
|
|
/* give the plug-in some time (10 ms) */
|
2006-04-29 07:23:19 +08:00
|
|
|
g_usleep (10000);
|
2005-02-09 06:38:58 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-02-09 06:38:58 +08:00
|
|
|
/* If necessary, kill the filter. */
|
2006-04-30 03:03:44 +08:00
|
|
|
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifndef G_OS_WIN32
|
2004-10-30 05:54:32 +08:00
|
|
|
|
2005-02-09 06:38:58 +08:00
|
|
|
if (kill_it)
|
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
if (plug_in->manager->gimp->be_verbose)
|
2007-04-17 22:25:09 +08:00
|
|
|
g_print ("Terminating plug-in: '%s'\n",
|
2004-10-30 05:54:32 +08:00
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
|
|
|
|
2006-09-20 18:31:22 +08:00
|
|
|
/* If the plug-in opened a process group, kill the group instead
|
|
|
|
* of only the plug-in, so we kill the plug-in's children too
|
|
|
|
*/
|
|
|
|
if (getpgid (0) != getpgid (plug_in->pid))
|
|
|
|
status = kill (- plug_in->pid, SIGKILL);
|
|
|
|
else
|
|
|
|
status = kill (plug_in->pid, SIGKILL);
|
2005-02-09 06:38:58 +08:00
|
|
|
}
|
2003-07-31 09:08:08 +08:00
|
|
|
|
2005-02-09 06:38:58 +08:00
|
|
|
/* Wait for the process to exit. This will happen
|
2008-06-10 17:16:48 +08:00
|
|
|
* immediately if it was just killed.
|
2005-02-09 06:38:58 +08:00
|
|
|
*/
|
|
|
|
waitpid (plug_in->pid, &status, 0);
|
|
|
|
|
|
|
|
#else /* G_OS_WIN32 */
|
|
|
|
|
|
|
|
if (kill_it)
|
|
|
|
{
|
|
|
|
/* Trying to avoid TerminateProcess (does mostly work).
|
|
|
|
* Otherwise some of our needed DLLs may get into an
|
|
|
|
* unstable state (see Win32 API docs).
|
|
|
|
*/
|
|
|
|
DWORD dwExitCode = STILL_ACTIVE;
|
|
|
|
DWORD dwTries = 10;
|
|
|
|
|
2012-08-04 09:20:36 +08:00
|
|
|
while (dwExitCode == STILL_ACTIVE &&
|
2005-02-09 06:38:58 +08:00
|
|
|
GetExitCodeProcess ((HANDLE) plug_in->pid, &dwExitCode) &&
|
|
|
|
(dwTries > 0))
|
|
|
|
{
|
|
|
|
Sleep (10);
|
|
|
|
dwTries--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dwExitCode == STILL_ACTIVE)
|
|
|
|
{
|
2006-04-29 07:23:19 +08:00
|
|
|
if (plug_in->manager->gimp->be_verbose)
|
2007-04-17 22:25:09 +08:00
|
|
|
g_print ("Terminating plug-in: '%s'\n",
|
2005-02-09 06:38:58 +08:00
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
|
|
|
|
|
|
|
TerminateProcess ((HANDLE) plug_in->pid, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* G_OS_WIN32 */
|
|
|
|
|
|
|
|
g_spawn_close_pid (plug_in->pid);
|
|
|
|
plug_in->pid = 0;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-03 21:03:34 +08:00
|
|
|
/* Remove the input handler. */
|
|
|
|
if (plug_in->input_id)
|
|
|
|
{
|
|
|
|
g_source_remove (plug_in->input_id);
|
1997-11-25 06:05:25 +08:00
|
|
|
plug_in->input_id = 0;
|
2001-09-03 21:03:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Close the pipes. */
|
|
|
|
if (plug_in->my_read != NULL)
|
|
|
|
{
|
|
|
|
g_io_channel_unref (plug_in->my_read);
|
1999-03-07 20:56:03 +08:00
|
|
|
plug_in->my_read = NULL;
|
2001-09-03 21:03:34 +08:00
|
|
|
}
|
|
|
|
if (plug_in->my_write != NULL)
|
|
|
|
{
|
|
|
|
g_io_channel_unref (plug_in->my_write);
|
1999-03-07 20:56:03 +08:00
|
|
|
plug_in->my_write = NULL;
|
2001-09-03 21:03:34 +08:00
|
|
|
}
|
|
|
|
if (plug_in->his_read != NULL)
|
|
|
|
{
|
|
|
|
g_io_channel_unref (plug_in->his_read);
|
1999-03-07 20:56:03 +08:00
|
|
|
plug_in->his_read = NULL;
|
2001-09-03 21:03:34 +08:00
|
|
|
}
|
|
|
|
if (plug_in->his_write != NULL)
|
|
|
|
{
|
|
|
|
g_io_channel_unref (plug_in->his_write);
|
1999-03-07 20:56:03 +08:00
|
|
|
plug_in->his_write = NULL;
|
2001-09-03 21:03:34 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-12-13 22:11:56 +08:00
|
|
|
gimp_wire_clear_error ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2012-11-05 08:12:21 +08:00
|
|
|
while (plug_in->temp_proc_frames)
|
2001-09-03 21:03:34 +08:00
|
|
|
{
|
2012-11-05 08:12:21 +08:00
|
|
|
GimpPlugInProcFrame *proc_frame = plug_in->temp_proc_frames->data;
|
2004-11-17 09:38:07 +08:00
|
|
|
|
2004-02-11 21:18:51 +08:00
|
|
|
#ifdef GIMP_UNSTABLE
|
2006-08-16 21:11:12 +08:00
|
|
|
g_printerr ("plug-in '%s' aborted before sending its "
|
|
|
|
"temporary procedure return values\n",
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (plug_in));
|
2004-02-11 21:18:51 +08:00
|
|
|
#endif
|
2004-11-17 09:38:07 +08:00
|
|
|
|
|
|
|
if (proc_frame->main_loop &&
|
|
|
|
g_main_loop_is_running (proc_frame->main_loop))
|
|
|
|
{
|
|
|
|
g_main_loop_quit (proc_frame->main_loop);
|
|
|
|
}
|
2012-11-05 08:12:21 +08:00
|
|
|
|
|
|
|
/* pop the frame here, because normally this only happens in
|
|
|
|
* gimp_plug_in_handle_temp_proc_return(), which can't
|
|
|
|
* be called after plug_in_close()
|
|
|
|
*/
|
|
|
|
gimp_plug_in_proc_frame_pop (plug_in);
|
2003-06-24 02:27:03 +08:00
|
|
|
}
|
2001-11-18 00:32:34 +08:00
|
|
|
|
2004-09-22 07:56:40 +08:00
|
|
|
if (plug_in->main_proc_frame.main_loop &&
|
|
|
|
g_main_loop_is_running (plug_in->main_proc_frame.main_loop))
|
2003-06-24 02:27:03 +08:00
|
|
|
{
|
2004-02-11 21:18:51 +08:00
|
|
|
#ifdef GIMP_UNSTABLE
|
2006-08-16 21:11:12 +08:00
|
|
|
g_printerr ("plug-in '%s' aborted before sending its "
|
|
|
|
"procedure return values\n",
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (plug_in));
|
2004-02-11 21:18:51 +08:00
|
|
|
#endif
|
2004-11-17 09:38:07 +08:00
|
|
|
|
2004-09-22 07:56:40 +08:00
|
|
|
g_main_loop_quit (plug_in->main_proc_frame.main_loop);
|
2003-06-24 02:27:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (plug_in->ext_main_loop &&
|
|
|
|
g_main_loop_is_running (plug_in->ext_main_loop))
|
|
|
|
{
|
2004-02-11 21:18:51 +08:00
|
|
|
#ifdef GIMP_UNSTABLE
|
2006-08-16 21:11:12 +08:00
|
|
|
g_printerr ("extension '%s' aborted before sending its "
|
|
|
|
"extension_ack message\n",
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (plug_in));
|
2004-02-11 21:18:51 +08:00
|
|
|
#endif
|
2004-11-17 09:38:07 +08:00
|
|
|
|
2003-06-24 02:27:03 +08:00
|
|
|
g_main_loop_quit (plug_in->ext_main_loop);
|
2001-09-03 21:03:34 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-03 21:03:34 +08:00
|
|
|
/* Unregister any temporary procedures. */
|
2006-04-07 16:16:26 +08:00
|
|
|
while (plug_in->temp_procedures)
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_remove_temp_proc (plug_in, plug_in->temp_procedures->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-05-05 06:51:21 +08:00
|
|
|
gimp_plug_in_manager_remove_open_plug_in (plug_in->manager, plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
static gboolean
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_recv_message (GIOChannel *channel,
|
|
|
|
GIOCondition cond,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
GimpPlugIn *plug_in = data;
|
|
|
|
gboolean got_message = FALSE;
|
2000-05-11 05:21:23 +08:00
|
|
|
|
2004-03-23 04:57:26 +08:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
/* Workaround for GLib bug #137968: sometimes we are called for no
|
|
|
|
* reason...
|
|
|
|
*/
|
|
|
|
if (cond == 0)
|
|
|
|
return TRUE;
|
|
|
|
#endif
|
|
|
|
|
2002-05-16 19:45:30 +08:00
|
|
|
if (plug_in->my_read == NULL)
|
1999-03-07 20:56:03 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
g_object_ref (plug_in);
|
|
|
|
|
2000-05-11 05:21:23 +08:00
|
|
|
if (cond & (G_IO_IN | G_IO_PRI))
|
|
|
|
{
|
2005-12-13 22:11:56 +08:00
|
|
|
GimpWireMessage msg;
|
2000-05-11 05:21:23 +08:00
|
|
|
|
2005-12-13 22:11:56 +08:00
|
|
|
memset (&msg, 0, sizeof (GimpWireMessage));
|
2000-05-11 05:21:23 +08:00
|
|
|
|
2005-12-13 22:11:56 +08:00
|
|
|
if (! gimp_wire_read_msg (plug_in->my_read, &msg, plug_in))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
2006-04-12 20:49:29 +08:00
|
|
|
}
|
2002-03-21 01:46:13 +08:00
|
|
|
else
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_handle_message (plug_in, &msg);
|
2006-04-12 20:49:29 +08:00
|
|
|
gimp_wire_destroy (&msg);
|
|
|
|
got_message = TRUE;
|
|
|
|
}
|
2000-05-11 05:21:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cond & (G_IO_ERR | G_IO_HUP))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2007-07-31 00:24:14 +08:00
|
|
|
if (cond & G_IO_HUP)
|
|
|
|
plug_in->hup = TRUE;
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
if (plug_in->open)
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
if (! got_message)
|
2006-08-29 19:08:31 +08:00
|
|
|
{
|
|
|
|
GimpPlugInProcFrame *frame = gimp_plug_in_get_proc_frame (plug_in);
|
|
|
|
GimpProgress *progress = frame ? frame->progress : NULL;
|
|
|
|
|
2006-10-09 16:17:22 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, G_OBJECT (progress),
|
|
|
|
GIMP_MESSAGE_ERROR,
|
2006-08-29 19:08:31 +08:00
|
|
|
_("Plug-in crashed: \"%s\"\n(%s)\n\n"
|
|
|
|
"The dying plug-in may have messed up GIMP's internal "
|
|
|
|
"state. You may want to save your images and restart "
|
|
|
|
"GIMP to be on the safe side."),
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (plug_in),
|
2006-08-29 19:08:31 +08:00
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
|
|
|
}
|
2000-05-11 05:21:23 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
g_object_unref (plug_in);
|
2000-05-11 05:21:23 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-02-25 00:11:26 +08:00
|
|
|
static gboolean
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_write (GIOChannel *channel,
|
|
|
|
const guint8 *buf,
|
|
|
|
gulong count,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
GimpPlugIn *plug_in = data;
|
|
|
|
gulong bytes;
|
2002-05-17 01:41:38 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
while (count > 0)
|
|
|
|
{
|
2002-05-17 01:41:38 +08:00
|
|
|
if ((plug_in->write_buffer_index + count) >= WRITE_BUFFER_SIZE)
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
bytes = WRITE_BUFFER_SIZE - plug_in->write_buffer_index;
|
|
|
|
memcpy (&plug_in->write_buffer[plug_in->write_buffer_index],
|
2002-05-17 01:41:38 +08:00
|
|
|
buf, bytes);
|
2006-04-12 20:49:29 +08:00
|
|
|
plug_in->write_buffer_index += bytes;
|
|
|
|
if (! gimp_wire_flush (channel, plug_in))
|
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
bytes = count;
|
|
|
|
memcpy (&plug_in->write_buffer[plug_in->write_buffer_index],
|
2002-05-17 01:41:38 +08:00
|
|
|
buf, bytes);
|
2006-04-12 20:49:29 +08:00
|
|
|
plug_in->write_buffer_index += bytes;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
buf += bytes;
|
|
|
|
count -= bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-02-25 00:11:26 +08:00
|
|
|
static gboolean
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_flush (GIOChannel *channel,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
GimpPlugIn *plug_in = data;
|
2002-05-17 01:41:38 +08:00
|
|
|
|
|
|
|
if (plug_in->write_buffer_index > 0)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-01-30 19:20:12 +08:00
|
|
|
GIOStatus status;
|
|
|
|
GError *error = NULL;
|
|
|
|
gint count;
|
|
|
|
gsize bytes;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
count = 0;
|
2002-05-17 01:41:38 +08:00
|
|
|
while (count != plug_in->write_buffer_index)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-12 20:49:29 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
bytes = 0;
|
|
|
|
status = g_io_channel_write_chars (channel,
|
|
|
|
&plug_in->write_buffer[count],
|
|
|
|
(plug_in->write_buffer_index - count),
|
|
|
|
&bytes,
|
|
|
|
&error);
|
|
|
|
}
|
|
|
|
while (status == G_IO_STATUS_AGAIN);
|
|
|
|
|
|
|
|
if (status != G_IO_STATUS_NORMAL)
|
|
|
|
{
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
g_warning ("%s: plug_in_flush(): error: %s",
|
|
|
|
gimp_filename_to_utf8 (g_get_prgname ()),
|
|
|
|
error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("%s: plug_in_flush(): error",
|
|
|
|
gimp_filename_to_utf8 (g_get_prgname ()));
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
count += bytes;
|
|
|
|
}
|
|
|
|
|
2002-05-17 01:41:38 +08:00
|
|
|
plug_in->write_buffer_index = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-05-04 19:58:10 +08:00
|
|
|
#if !defined(G_OS_WIN32) && !defined (G_WITH_CYGWIN)
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_plug_in_prep_for_exec (gpointer data)
|
|
|
|
{
|
|
|
|
GimpPlugIn *plug_in = data;
|
|
|
|
|
|
|
|
g_io_channel_unref (plug_in->my_read);
|
|
|
|
plug_in->my_read = NULL;
|
|
|
|
|
|
|
|
g_io_channel_unref (plug_in->my_write);
|
|
|
|
plug_in->my_write = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
GimpPlugInProcFrame *
|
|
|
|
gimp_plug_in_get_proc_frame (GimpPlugIn *plug_in)
|
2004-09-22 23:26:58 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), NULL);
|
2004-09-22 23:26:58 +08:00
|
|
|
|
|
|
|
if (plug_in->temp_proc_frames)
|
|
|
|
return plug_in->temp_proc_frames->data;
|
|
|
|
else
|
|
|
|
return &plug_in->main_proc_frame;
|
|
|
|
}
|
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
GimpPlugInProcFrame *
|
|
|
|
gimp_plug_in_proc_frame_push (GimpPlugIn *plug_in,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
GimpTemporaryProcedure *procedure)
|
2004-09-22 07:56:40 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
GimpPlugInProcFrame *proc_frame;
|
2004-09-22 07:56:40 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), NULL);
|
2010-09-05 04:17:01 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PDB_CONTEXT (context), NULL);
|
2004-12-15 06:42:00 +08:00
|
|
|
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_TEMPORARY_PROCEDURE (procedure), NULL);
|
2004-09-22 07:56:40 +08:00
|
|
|
|
2006-05-04 16:23:20 +08:00
|
|
|
proc_frame = gimp_plug_in_proc_frame_new (context, progress,
|
|
|
|
GIMP_PLUG_IN_PROCEDURE (procedure));
|
2004-09-22 07:56:40 +08:00
|
|
|
|
|
|
|
plug_in->temp_proc_frames = g_list_prepend (plug_in->temp_proc_frames,
|
|
|
|
proc_frame);
|
2004-12-15 06:42:00 +08:00
|
|
|
|
|
|
|
return proc_frame;
|
2004-09-22 07:56:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_proc_frame_pop (GimpPlugIn *plug_in)
|
2004-09-22 07:56:40 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
GimpPlugInProcFrame *proc_frame;
|
2004-09-22 07:56:40 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
2004-09-22 07:56:40 +08:00
|
|
|
g_return_if_fail (plug_in->temp_proc_frames != NULL);
|
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
proc_frame = (GimpPlugInProcFrame *) plug_in->temp_proc_frames->data;
|
2004-09-22 07:56:40 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_proc_frame_unref (proc_frame, plug_in);
|
2004-09-22 20:27:18 +08:00
|
|
|
|
2004-09-22 07:56:40 +08:00
|
|
|
plug_in->temp_proc_frames = g_list_remove (plug_in->temp_proc_frames,
|
|
|
|
proc_frame);
|
|
|
|
}
|
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_main_loop (GimpPlugIn *plug_in)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
GimpPlugInProcFrame *proc_frame;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
2004-09-22 07:56:40 +08:00
|
|
|
g_return_if_fail (plug_in->temp_proc_frames != NULL);
|
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
proc_frame = (GimpPlugInProcFrame *) plug_in->temp_proc_frames->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-22 07:56:40 +08:00
|
|
|
g_return_if_fail (proc_frame->main_loop == NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-22 07:56:40 +08:00
|
|
|
proc_frame->main_loop = g_main_loop_new (NULL, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_threads_leave (plug_in->manager->gimp);
|
2004-09-22 07:56:40 +08:00
|
|
|
g_main_loop_run (proc_frame->main_loop);
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_threads_enter (plug_in->manager->gimp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-22 07:56:40 +08:00
|
|
|
g_main_loop_unref (proc_frame->main_loop);
|
|
|
|
proc_frame->main_loop = NULL;
|
2003-01-30 19:20:12 +08:00
|
|
|
}
|
2001-08-30 01:48:28 +08:00
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_main_loop_quit (GimpPlugIn *plug_in)
|
2003-01-30 19:20:12 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
GimpPlugInProcFrame *proc_frame;
|
2003-06-24 02:27:03 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
2004-09-22 07:56:40 +08:00
|
|
|
g_return_if_fail (plug_in->temp_proc_frames != NULL);
|
2001-08-30 01:48:28 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
proc_frame = (GimpPlugInProcFrame *) plug_in->temp_proc_frames->data;
|
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
|
|
|
|
2004-09-22 07:56:40 +08:00
|
|
|
g_return_if_fail (proc_frame->main_loop != NULL);
|
2003-06-24 02:27:03 +08:00
|
|
|
|
2004-09-22 07:56:40 +08:00
|
|
|
g_main_loop_quit (proc_frame->main_loop);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2003-02-18 22:08:14 +08:00
|
|
|
|
2007-03-12 21:04:32 +08:00
|
|
|
const gchar *
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_get_undo_desc (GimpPlugIn *plug_in)
|
2003-02-18 22:08:14 +08:00
|
|
|
{
|
2007-03-12 21:04:32 +08:00
|
|
|
GimpPlugInProcFrame *proc_frame;
|
2007-03-12 21:07:18 +08:00
|
|
|
const gchar *undo_desc = NULL;
|
2003-02-18 22:08:14 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), NULL);
|
2003-02-18 22:08:14 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
|
2004-09-22 07:56:40 +08:00
|
|
|
|
|
|
|
if (proc_frame)
|
2007-03-12 21:04:32 +08:00
|
|
|
{
|
|
|
|
GimpPlugInProcedure *proc;
|
2003-02-18 22:08:14 +08:00
|
|
|
|
2007-03-12 21:04:32 +08:00
|
|
|
proc = GIMP_PLUG_IN_PROCEDURE (proc_frame->procedure);
|
2003-02-18 22:08:14 +08:00
|
|
|
|
2007-03-12 21:04:32 +08:00
|
|
|
if (proc)
|
2007-03-12 21:07:18 +08:00
|
|
|
undo_desc = gimp_plug_in_procedure_get_label (proc);
|
2007-03-12 21:04:32 +08:00
|
|
|
}
|
2004-05-18 17:04:12 +08:00
|
|
|
|
2009-09-01 04:47:18 +08:00
|
|
|
return undo_desc ? undo_desc : gimp_object_get_name (plug_in);
|
2003-02-18 22:08:14 +08:00
|
|
|
}
|
2006-01-12 03:41:25 +08:00
|
|
|
|
|
|
|
/* called from the PDB (gimp_plugin_menu_register) */
|
|
|
|
gboolean
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_menu_register (GimpPlugIn *plug_in,
|
|
|
|
const gchar *proc_name,
|
|
|
|
const gchar *menu_path)
|
2006-01-12 03:41:25 +08:00
|
|
|
{
|
2006-04-05 16:38:33 +08:00
|
|
|
GimpPlugInProcedure *proc = NULL;
|
|
|
|
GError *error = NULL;
|
2006-01-12 03:41:25 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE);
|
2006-01-12 03:41:25 +08:00
|
|
|
g_return_val_if_fail (proc_name != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (menu_path != NULL, FALSE);
|
|
|
|
|
|
|
|
if (plug_in->plug_in_def)
|
2006-04-07 16:16:26 +08:00
|
|
|
proc = gimp_plug_in_procedure_find (plug_in->plug_in_def->procedures,
|
2006-04-05 16:38:33 +08:00
|
|
|
proc_name);
|
2006-01-12 03:41:25 +08:00
|
|
|
|
2006-04-05 16:38:33 +08:00
|
|
|
if (! proc)
|
2006-04-07 16:16:26 +08:00
|
|
|
proc = gimp_plug_in_procedure_find (plug_in->temp_procedures, proc_name);
|
2006-01-12 03:41:25 +08:00
|
|
|
|
2006-04-05 16:38:33 +08:00
|
|
|
if (! proc)
|
2006-01-12 03:41:25 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-in \"%s\"\n(%s)\n"
|
|
|
|
"attempted to register the menu item \"%s\" "
|
|
|
|
"for the procedure \"%s\".\n"
|
|
|
|
"It has however not installed that procedure. This "
|
|
|
|
"is not allowed.",
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (plug_in),
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_filename_to_utf8 (plug_in->prog),
|
|
|
|
menu_path, proc_name);
|
2006-01-12 03:41:25 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-04-10 01:08:56 +08:00
|
|
|
switch (GIMP_PROCEDURE (proc)->proc_type)
|
|
|
|
{
|
|
|
|
case GIMP_INTERNAL:
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
case GIMP_PLUGIN:
|
|
|
|
case GIMP_EXTENSION:
|
2006-05-03 02:27:31 +08:00
|
|
|
if (plug_in->call_mode != GIMP_PLUG_IN_CALL_QUERY &&
|
|
|
|
plug_in->call_mode != GIMP_PLUG_IN_CALL_INIT)
|
2006-04-10 01:08:56 +08:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
case GIMP_TEMPORARY:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-04-05 16:38:33 +08:00
|
|
|
if (! proc->menu_label)
|
2006-01-12 03:41:25 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-in \"%s\"\n(%s)\n"
|
|
|
|
"attempted to register the menu item \"%s\" "
|
|
|
|
"for procedure \"%s\".\n"
|
|
|
|
"The menu label given in gimp_install_procedure() "
|
|
|
|
"already contained a path. To make this work, "
|
|
|
|
"pass just the menu's label to "
|
|
|
|
"gimp_install_procedure().",
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (plug_in),
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_filename_to_utf8 (plug_in->prog),
|
|
|
|
menu_path, proc_name);
|
2006-01-12 03:41:25 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-04-08 03:27:51 +08:00
|
|
|
if (! strlen (proc->menu_label))
|
|
|
|
{
|
|
|
|
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
"Plug-in \"%s\"\n(%s)\n"
|
|
|
|
"attempted to register the procedure \"%s\" "
|
|
|
|
"in the menu \"%s\", but the procedure has no label. "
|
|
|
|
"This is not allowed.",
|
|
|
|
gimp_object_get_name (plug_in),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog),
|
|
|
|
proc_name, menu_path);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-04-10 01:08:56 +08:00
|
|
|
if (! gimp_plug_in_procedure_add_menu_path (proc, menu_path, &error))
|
2006-01-12 03:41:25 +08:00
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
2013-09-15 00:59:20 +08:00
|
|
|
error->message);
|
2006-01-12 03:41:25 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-08-19 06:54:26 +08:00
|
|
|
void
|
|
|
|
gimp_plug_in_set_error_handler (GimpPlugIn *plug_in,
|
|
|
|
GimpPDBErrorHandler handler)
|
|
|
|
{
|
2008-08-19 16:24:48 +08:00
|
|
|
GimpPlugInProcFrame *proc_frame;
|
|
|
|
|
2008-08-19 06:54:26 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
|
|
|
|
2008-08-19 16:24:48 +08:00
|
|
|
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
|
|
|
|
|
|
|
|
if (proc_frame)
|
|
|
|
proc_frame->error_handler = handler;
|
2008-08-19 06:54:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GimpPDBErrorHandler
|
|
|
|
gimp_plug_in_get_error_handler (GimpPlugIn *plug_in)
|
|
|
|
{
|
2008-08-19 16:24:48 +08:00
|
|
|
GimpPlugInProcFrame *proc_frame;
|
|
|
|
|
2008-08-19 06:54:26 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in),
|
|
|
|
GIMP_PDB_ERROR_HANDLER_INTERNAL);
|
|
|
|
|
2008-08-19 16:24:48 +08:00
|
|
|
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
|
|
|
|
|
|
|
|
if (proc_frame)
|
|
|
|
return proc_frame->error_handler;
|
|
|
|
|
|
|
|
return GIMP_PDB_ERROR_HANDLER_INTERNAL;
|
2008-08-19 06:54:26 +08:00
|
|
|
}
|
|
|
|
|
2006-04-07 16:16:26 +08:00
|
|
|
void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_add_temp_proc (GimpPlugIn *plug_in,
|
|
|
|
GimpTemporaryProcedure *proc)
|
2006-04-07 16:16:26 +08:00
|
|
|
{
|
2007-02-19 17:36:19 +08:00
|
|
|
GimpPlugInProcedure *overridden;
|
|
|
|
const gchar *locale_domain;
|
|
|
|
const gchar *help_domain;
|
2007-02-18 22:25:34 +08:00
|
|
|
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
2006-04-07 16:16:26 +08:00
|
|
|
g_return_if_fail (GIMP_IS_TEMPORARY_PROCEDURE (proc));
|
|
|
|
|
2007-02-19 17:36:19 +08:00
|
|
|
overridden = gimp_plug_in_procedure_find (plug_in->temp_procedures,
|
2009-08-29 18:40:40 +08:00
|
|
|
gimp_object_get_name (proc));
|
2007-02-19 17:36:19 +08:00
|
|
|
|
|
|
|
if (overridden)
|
|
|
|
gimp_plug_in_remove_temp_proc (plug_in,
|
|
|
|
GIMP_TEMPORARY_PROCEDURE (overridden));
|
|
|
|
|
2007-02-18 22:25:34 +08:00
|
|
|
locale_domain = gimp_plug_in_manager_get_locale_domain (plug_in->manager,
|
|
|
|
plug_in->prog,
|
|
|
|
NULL);
|
|
|
|
help_domain = gimp_plug_in_manager_get_help_domain (plug_in->manager,
|
|
|
|
plug_in->prog,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gimp_plug_in_procedure_set_locale_domain (GIMP_PLUG_IN_PROCEDURE (proc),
|
|
|
|
locale_domain);
|
|
|
|
gimp_plug_in_procedure_set_help_domain (GIMP_PLUG_IN_PROCEDURE (proc),
|
|
|
|
help_domain);
|
|
|
|
|
2006-04-07 16:16:26 +08:00
|
|
|
plug_in->temp_procedures = g_slist_prepend (plug_in->temp_procedures,
|
|
|
|
g_object_ref (proc));
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_add_temp_proc (plug_in->manager, proc);
|
2006-04-07 16:16:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-05-04 02:05:06 +08:00
|
|
|
gimp_plug_in_remove_temp_proc (GimpPlugIn *plug_in,
|
|
|
|
GimpTemporaryProcedure *proc)
|
2006-04-07 16:16:26 +08:00
|
|
|
{
|
2006-05-04 02:05:06 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
2006-04-07 16:16:26 +08:00
|
|
|
g_return_if_fail (GIMP_IS_TEMPORARY_PROCEDURE (proc));
|
|
|
|
|
2006-07-19 14:50:34 +08:00
|
|
|
plug_in->temp_procedures = g_slist_remove (plug_in->temp_procedures, proc);
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_remove_temp_proc (plug_in->manager, proc);
|
2006-04-07 16:16:26 +08:00
|
|
|
g_object_unref (proc);
|
|
|
|
}
|
2012-04-25 03:45:35 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
gimp_plug_in_enable_precision (GimpPlugIn *plug_in)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
|
|
|
|
|
|
|
plug_in->precision = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_plug_in_precision_enabled (GimpPlugIn *plug_in)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE);
|
|
|
|
|
|
|
|
return plug_in->precision;
|
|
|
|
}
|