1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2004-09-22 23:12:24 +08:00
|
|
|
* plug-in.c
|
|
|
|
*
|
1997-11-25 06:05:25 +08:00
|
|
|
* 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-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
|
|
|
|
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
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#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
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <sys/time.h>
|
1999-03-07 21:23:06 +08:00
|
|
|
#endif
|
2002-02-18 22:34:50 +08:00
|
|
|
|
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
|
|
|
|
|
2003-09-11 06:06:45 +08:00
|
|
|
#include <glib-object.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>
|
|
|
|
#endif
|
|
|
|
|
1999-10-07 05:27:18 +08:00
|
|
|
#ifdef G_WITH_CYGWIN
|
2006-04-12 20:49:29 +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-04-15 21:10:51 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2004-09-22 20:27:18 +08:00
|
|
|
#include "core/gimpprogress.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2006-04-07 16:16:26 +08:00
|
|
|
#include "pdb/gimptemporaryprocedure.h"
|
2006-03-31 19:49:22 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
#include "gimpenvirontable.h"
|
|
|
|
#include "gimpinterpreterdb.h"
|
|
|
|
#include "gimpplugindebug.h"
|
|
|
|
#include "gimppluginmanager.h"
|
|
|
|
#include "gimppluginmanager-locale-domain.h"
|
2001-12-01 08:14:14 +08:00
|
|
|
#include "plug-in.h"
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-in-def.h"
|
2003-01-30 19:20:12 +08:00
|
|
|
#include "plug-in-message.h"
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-in-params.h"
|
|
|
|
#include "plug-in-progress.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
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
/* local funcion prototypes */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
static gboolean plug_in_write (GIOChannel *channel,
|
2006-03-12 01:33:36 +08:00
|
|
|
const guint8 *buf,
|
2003-01-30 19:20:12 +08:00
|
|
|
gulong count,
|
|
|
|
gpointer user_data);
|
|
|
|
static gboolean plug_in_flush (GIOChannel *channel,
|
|
|
|
gpointer user_data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
static gboolean 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)
|
2003-01-30 19:20:12 +08:00
|
|
|
static void plug_in_prep_for_exec (gpointer data);
|
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
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
2006-04-29 06:26:51 +08:00
|
|
|
plug_in_init (GimpPlugInManager *manager)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
2001-10-20 00:41:09 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* initialize the gimp protocol library and set the read and
|
|
|
|
* write handlers.
|
|
|
|
*/
|
|
|
|
gp_init ();
|
2005-12-13 22:11:56 +08:00
|
|
|
|
|
|
|
gimp_wire_set_writer (plug_in_write);
|
|
|
|
gimp_wire_set_flusher (plug_in_flush);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 06:26:51 +08:00
|
|
|
plug_in_exit (GimpPlugInManager *manager)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-01-30 19:20:12 +08:00
|
|
|
GSList *list;
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
2003-02-11 09:21:21 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
list = manager->open_plug_ins;
|
2003-01-30 19:20:12 +08:00
|
|
|
while (list)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-03-12 01:33:36 +08:00
|
|
|
PlugIn *plug_in = list->data;
|
2003-01-30 19:20:12 +08:00
|
|
|
|
|
|
|
list = list->next;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-03 21:21:31 +08:00
|
|
|
if (plug_in->open)
|
|
|
|
plug_in_close (plug_in, TRUE);
|
|
|
|
|
|
|
|
plug_in_unref (plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 06:26:51 +08:00
|
|
|
plug_in_call_query (GimpPlugInManager *manager,
|
|
|
|
GimpContext *context,
|
|
|
|
PlugInDef *plug_in_def)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-01-30 19:20:12 +08:00
|
|
|
PlugIn *plug_in;
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
2004-04-15 21:10:51 +08:00
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
2003-01-30 19:20:12 +08:00
|
|
|
g_return_if_fail (plug_in_def != NULL);
|
2001-01-14 23:18:37 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
plug_in = plug_in_new (manager, context, NULL, NULL, plug_in_def->prog);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
if (plug_in)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in->query = TRUE;
|
|
|
|
plug_in->synchronous = TRUE;
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_in->plug_in_def = plug_in_def;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
if (plug_in_open (plug_in))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
while (plug_in->open)
|
|
|
|
{
|
2005-12-13 22:11:56 +08:00
|
|
|
GimpWireMessage msg;
|
2003-01-30 19:20:12 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
if (! gimp_wire_read_msg (plug_in->my_read, &msg, plug_in))
|
2002-03-21 01:46:13 +08:00
|
|
|
{
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
2002-03-21 01:46:13 +08:00
|
|
|
}
|
2006-04-12 20:49:29 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
plug_in_handle_message (plug_in, &msg);
|
|
|
|
gimp_wire_destroy (&msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-01-30 19:20:12 +08:00
|
|
|
|
2003-02-03 21:21:31 +08:00
|
|
|
plug_in_unref (plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-11-25 04:31:15 +08:00
|
|
|
}
|
2000-02-24 02:07:53 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
2006-04-29 06:26:51 +08:00
|
|
|
plug_in_call_init (GimpPlugInManager *manager,
|
|
|
|
GimpContext *context,
|
|
|
|
PlugInDef *plug_in_def)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-01-30 19:20:12 +08:00
|
|
|
PlugIn *plug_in;
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
2004-04-15 21:10:51 +08:00
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
2003-01-30 19:20:12 +08:00
|
|
|
g_return_if_fail (plug_in_def != NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
plug_in = plug_in_new (manager, context, NULL, NULL, plug_in_def->prog);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
if (plug_in)
|
1999-02-14 09:53:23 +08:00
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in->init = TRUE;
|
|
|
|
plug_in->synchronous = TRUE;
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_in->plug_in_def = plug_in_def;
|
1999-02-14 09:53:23 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
if (plug_in_open (plug_in))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
while (plug_in->open)
|
|
|
|
{
|
2005-12-13 22:11:56 +08:00
|
|
|
GimpWireMessage msg;
|
2003-01-30 19:20:12 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
if (! gimp_wire_read_msg (plug_in->my_read, &msg, plug_in))
|
2002-03-21 01:46:13 +08:00
|
|
|
{
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
2002-03-21 01:46:13 +08:00
|
|
|
}
|
2006-04-12 20:49:29 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
plug_in_handle_message (plug_in, &msg);
|
|
|
|
gimp_wire_destroy (&msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-01-30 19:20:12 +08:00
|
|
|
|
2003-02-03 21:21:31 +08:00
|
|
|
plug_in_unref (plug_in);
|
1997-11-25 06:05:25 +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
|
|
|
}
|
|
|
|
|
2000-05-17 20:29:38 +08:00
|
|
|
PlugIn *
|
2006-04-29 06:26:51 +08:00
|
|
|
plug_in_new (GimpPlugInManager *manager,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
GimpProcedure *procedure,
|
|
|
|
const gchar *prog)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-09-22 20:27:18 +08:00
|
|
|
PlugIn *plug_in;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), NULL);
|
2004-04-15 21:10:51 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
2004-09-22 20:27:18 +08:00
|
|
|
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
|
2003-02-11 09:21:21 +08:00
|
|
|
g_return_val_if_fail (prog != NULL, NULL);
|
|
|
|
g_return_val_if_fail (g_path_is_absolute (prog), NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in = g_new0 (PlugIn, 1);
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
plug_in->manager = manager;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-03 21:21:31 +08:00
|
|
|
plug_in->ref_count = 1;
|
|
|
|
|
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->open = FALSE;
|
|
|
|
plug_in->query = FALSE;
|
2002-02-12 10:41:01 +08:00
|
|
|
plug_in->init = 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->synchronous = FALSE;
|
|
|
|
plug_in->pid = 0;
|
2003-01-30 19:20:12 +08:00
|
|
|
|
2003-02-11 09:21:21 +08:00
|
|
|
plug_in->name = g_path_get_basename (prog);
|
|
|
|
plug_in->prog = g_strdup (prog);
|
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 20:27:18 +08:00
|
|
|
plug_in_proc_frame_init (&plug_in->main_proc_frame,
|
2006-04-01 01:42:13 +08:00
|
|
|
context, progress, procedure);
|
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
|
|
|
|
|
|
|
return plug_in;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-02-03 21:21:31 +08:00
|
|
|
plug_in_ref (PlugIn *plug_in)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-01-20 20:17:32 +08:00
|
|
|
g_return_if_fail (plug_in != NULL);
|
|
|
|
|
2003-02-03 21:21:31 +08:00
|
|
|
plug_in->ref_count++;
|
|
|
|
}
|
2003-01-20 20:17:32 +08:00
|
|
|
|
2003-02-03 21:21:31 +08:00
|
|
|
void
|
|
|
|
plug_in_unref (PlugIn *plug_in)
|
|
|
|
{
|
|
|
|
g_return_if_fail (plug_in != NULL);
|
2003-01-20 20:17:32 +08:00
|
|
|
|
2003-02-03 21:21:31 +08:00
|
|
|
plug_in->ref_count--;
|
2003-01-20 20:17:32 +08:00
|
|
|
|
2003-02-03 21:21:31 +08:00
|
|
|
if (plug_in->ref_count < 1)
|
|
|
|
{
|
|
|
|
if (plug_in->open)
|
|
|
|
plug_in_close (plug_in, TRUE);
|
|
|
|
|
2003-02-11 09:21:21 +08:00
|
|
|
g_free (plug_in->name);
|
|
|
|
g_free (plug_in->prog);
|
2003-02-03 21:21:31 +08:00
|
|
|
|
2004-09-22 20:27:18 +08:00
|
|
|
plug_in_proc_frame_dispose (&plug_in->main_proc_frame, plug_in);
|
2004-04-15 21:10:51 +08:00
|
|
|
|
2003-02-03 21:21:31 +08:00
|
|
|
g_free (plug_in);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2005-08-26 20:03:24 +08:00
|
|
|
#if !defined(G_OS_WIN32) && !defined (G_WITH_CYGWIN)
|
|
|
|
|
2002-11-17 03:01:46 +08:00
|
|
|
static void
|
|
|
|
plug_in_prep_for_exec (gpointer data)
|
Add gimpcolorspace object.
2000-01-04 Tor Lillqvist <tml@iki.fi>
* libgimp/makefile.{cygwin.msc}: Add gimpcolorspace object.
* libgimp/gimp.def: Add functions from it.
Fixes from Hans Breuer:
* app/datafiles.c: redefine the executable flag for Win32
to _S_IREAD, to get _all_ files from the plug-in dirs as
executables (including scripts)
* app/main.c: Win32-specific changes to allow building Gimp as a
console application, with all its benefits (like inheriting the
console), but hide it if the user doesn't want it. Also, if stdout
goes to a console, give the user a chance to read the help or
version messages. (tml: I am not convinced that it is better to
build gimp as a console application, but let's try it this way for
a while.)
* app/makefile.{cygwin,msc}: Build as console application, and
link with shell32 library.
* app/paint_core.c (paint_core_motion): Pass the value of a call
to the function gimage_active_drawable() to the paint_func,
instead of just passing the address of gimage_active_drawable...
(tml: This code is only called when the TOOL_TRACES_ON_WINDOW flag
is on, and only the clone tool sets that, and the clone tool's
paint_func doesn't use the drawable argument, so this hasn't
caused any trouble.)
* app/plug_in.c: On Win32, to support scripts, use new function
xspawn() instead of _spawnv. Add some more code to properly kill
plug-ins.
* libgimp/color_display.h: Add G_MODULE_EXPORT declarations.
2000-01-05 01:46:41 +08:00
|
|
|
{
|
2002-11-17 03:01:46 +08:00
|
|
|
PlugIn *plug_in = data;
|
Add gimpcolorspace object.
2000-01-04 Tor Lillqvist <tml@iki.fi>
* libgimp/makefile.{cygwin.msc}: Add gimpcolorspace object.
* libgimp/gimp.def: Add functions from it.
Fixes from Hans Breuer:
* app/datafiles.c: redefine the executable flag for Win32
to _S_IREAD, to get _all_ files from the plug-in dirs as
executables (including scripts)
* app/main.c: Win32-specific changes to allow building Gimp as a
console application, with all its benefits (like inheriting the
console), but hide it if the user doesn't want it. Also, if stdout
goes to a console, give the user a chance to read the help or
version messages. (tml: I am not convinced that it is better to
build gimp as a console application, but let's try it this way for
a while.)
* app/makefile.{cygwin,msc}: Build as console application, and
link with shell32 library.
* app/paint_core.c (paint_core_motion): Pass the value of a call
to the function gimage_active_drawable() to the paint_func,
instead of just passing the address of gimage_active_drawable...
(tml: This code is only called when the TOOL_TRACES_ON_WINDOW flag
is on, and only the clone tool sets that, and the clone tool's
paint_func doesn't use the drawable argument, so this hasn't
caused any trouble.)
* app/plug_in.c: On Win32, to support scripts, use new function
xspawn() instead of _spawnv. Add some more code to properly kill
plug-ins.
* libgimp/color_display.h: Add G_MODULE_EXPORT declarations.
2000-01-05 01:46:41 +08:00
|
|
|
|
2002-11-17 03:01:46 +08:00
|
|
|
g_io_channel_unref (plug_in->my_read);
|
|
|
|
plug_in->my_read = NULL;
|
Add gimpcolorspace object.
2000-01-04 Tor Lillqvist <tml@iki.fi>
* libgimp/makefile.{cygwin.msc}: Add gimpcolorspace object.
* libgimp/gimp.def: Add functions from it.
Fixes from Hans Breuer:
* app/datafiles.c: redefine the executable flag for Win32
to _S_IREAD, to get _all_ files from the plug-in dirs as
executables (including scripts)
* app/main.c: Win32-specific changes to allow building Gimp as a
console application, with all its benefits (like inheriting the
console), but hide it if the user doesn't want it. Also, if stdout
goes to a console, give the user a chance to read the help or
version messages. (tml: I am not convinced that it is better to
build gimp as a console application, but let's try it this way for
a while.)
* app/makefile.{cygwin,msc}: Build as console application, and
link with shell32 library.
* app/paint_core.c (paint_core_motion): Pass the value of a call
to the function gimage_active_drawable() to the paint_func,
instead of just passing the address of gimage_active_drawable...
(tml: This code is only called when the TOOL_TRACES_ON_WINDOW flag
is on, and only the clone tool sets that, and the clone tool's
paint_func doesn't use the drawable argument, so this hasn't
caused any trouble.)
* app/plug_in.c: On Win32, to support scripts, use new function
xspawn() instead of _spawnv. Add some more code to properly kill
plug-ins.
* libgimp/color_display.h: Add G_MODULE_EXPORT declarations.
2000-01-05 01:46:41 +08:00
|
|
|
|
2002-11-17 03:01:46 +08:00
|
|
|
g_io_channel_unref (plug_in->my_write);
|
|
|
|
plug_in->my_write = NULL;
|
|
|
|
}
|
Add gimpcolorspace object.
2000-01-04 Tor Lillqvist <tml@iki.fi>
* libgimp/makefile.{cygwin.msc}: Add gimpcolorspace object.
* libgimp/gimp.def: Add functions from it.
Fixes from Hans Breuer:
* app/datafiles.c: redefine the executable flag for Win32
to _S_IREAD, to get _all_ files from the plug-in dirs as
executables (including scripts)
* app/main.c: Win32-specific changes to allow building Gimp as a
console application, with all its benefits (like inheriting the
console), but hide it if the user doesn't want it. Also, if stdout
goes to a console, give the user a chance to read the help or
version messages. (tml: I am not convinced that it is better to
build gimp as a console application, but let's try it this way for
a while.)
* app/makefile.{cygwin,msc}: Build as console application, and
link with shell32 library.
* app/paint_core.c (paint_core_motion): Pass the value of a call
to the function gimage_active_drawable() to the paint_func,
instead of just passing the address of gimage_active_drawable...
(tml: This code is only called when the TOOL_TRACES_ON_WINDOW flag
is on, and only the clone tool sets that, and the clone tool's
paint_func doesn't use the drawable argument, so this hasn't
caused any trouble.)
* app/plug_in.c: On Win32, to support scripts, use new function
xspawn() instead of _spawnv. Add some more code to properly kill
plug-ins.
* libgimp/color_display.h: Add G_MODULE_EXPORT declarations.
2000-01-05 01:46:41 +08:00
|
|
|
|
2005-08-26 20:03:24 +08:00
|
|
|
#else
|
|
|
|
|
|
|
|
#define plug_in_prep_for_exec NULL
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2000-02-25 00:11:26 +08:00
|
|
|
gboolean
|
1997-11-25 06:05:25 +08:00
|
|
|
plug_in_open (PlugIn *plug_in)
|
|
|
|
{
|
2003-02-11 09:21:21 +08:00
|
|
|
gint my_read[2];
|
|
|
|
gint my_write[2];
|
|
|
|
gchar **envp;
|
2006-04-29 06:26:51 +08:00
|
|
|
gchar *args[9], **argv;
|
2005-02-21 10:56:29 +08:00
|
|
|
gint argc;
|
|
|
|
gchar *interp, *interp_arg;
|
2003-02-11 09:21:21 +08:00
|
|
|
gchar *read_fd, *write_fd;
|
|
|
|
gchar *mode, *stm;
|
|
|
|
GError *error = NULL;
|
|
|
|
gboolean debug;
|
|
|
|
guint debug_flag;
|
|
|
|
guint spawn_flags;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
g_return_val_if_fail (plug_in != NULL, FALSE);
|
|
|
|
|
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-03-29 18:45:18 +08:00
|
|
|
g_message ("Unable to run plug-in \"%s\"\n(%s)\n\npipe() failed: %s",
|
2004-01-19 09:08:43 +08:00
|
|
|
gimp_filename_to_utf8 (plug_in->name),
|
2006-04-12 20:49:29 +08:00
|
|
|
gimp_filename_to_utf8 (plug_in->prog),
|
2003-12-08 21:29:14 +08:00
|
|
|
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
|
|
|
|
|
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
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
/* Set the rest of the command line arguments.
|
|
|
|
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
|
|
|
*/
|
|
|
|
if (plug_in->query)
|
|
|
|
{
|
2003-02-11 09:21:21 +08:00
|
|
|
mode = "-query";
|
|
|
|
debug_flag = GIMP_DEBUG_WRAP_QUERY;
|
2003-01-20 20:17:32 +08:00
|
|
|
}
|
|
|
|
else if (plug_in->init)
|
|
|
|
{
|
2003-02-11 09:21:21 +08:00
|
|
|
mode = "-init";
|
|
|
|
debug_flag = GIMP_DEBUG_WRAP_INIT;
|
2003-01-20 20:17:32 +08:00
|
|
|
}
|
2003-12-08 21:29:14 +08:00
|
|
|
else
|
2003-01-20 20:17:32 +08:00
|
|
|
{
|
2003-02-11 09:21:21 +08:00
|
|
|
mode = "-run";
|
|
|
|
debug_flag = GIMP_DEBUG_WRAP_RUN;
|
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
|
|
|
|
|
|
|
argv = 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,
|
|
|
|
plug_in->name,
|
|
|
|
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,
|
2003-01-20 20:17:32 +08:00
|
|
|
plug_in_prep_for_exec, plug_in,
|
|
|
|
&plug_in->pid,
|
|
|
|
&error))
|
|
|
|
{
|
2006-03-29 18:45:18 +08:00
|
|
|
g_message ("Unable to run plug-in \"%s\"\n(%s)\n\n%s",
|
2004-01-19 09:08:43 +08:00
|
|
|
gimp_filename_to_utf8 (plug_in->name),
|
2006-04-12 20:49:29 +08:00
|
|
|
gimp_filename_to_utf8 (plug_in->prog),
|
2003-01-20 20:17:32 +08:00
|
|
|
error->message);
|
|
|
|
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
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
if (! plug_in->synchronous)
|
|
|
|
{
|
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,
|
|
|
|
(GSourceFunc) plug_in_recv_message, plug_in,
|
|
|
|
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-04-29 06:26:51 +08:00
|
|
|
plug_in->manager->open_plug_ins =
|
|
|
|
g_slist_prepend (plug_in->manager->open_plug_ins, plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
plug_in->open = TRUE;
|
2003-02-11 09:21:21 +08:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
|
|
|
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
|
2000-02-25 00:11:26 +08:00
|
|
|
plug_in_close (PlugIn *plug_in,
|
2006-04-12 20:49:29 +08:00
|
|
|
gboolean kill_it)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifndef G_OS_WIN32
|
2004-11-17 09:38:07 +08:00
|
|
|
gint status;
|
1997-11-25 06:05:25 +08:00
|
|
|
struct timeval tv;
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
2004-11-17 09:38:07 +08:00
|
|
|
GList *list;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-03 21:03:34 +08:00
|
|
|
g_return_if_fail (plug_in != NULL);
|
|
|
|
g_return_if_fail (plug_in->open == TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-03 21:03:34 +08:00
|
|
|
if (! plug_in->open)
|
|
|
|
return;
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2005-02-09 06:38:58 +08:00
|
|
|
/* Ask the filter to exit gracefully */
|
|
|
|
if (kill_it)
|
|
|
|
{
|
|
|
|
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. */
|
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)
|
2004-10-30 05:54:32 +08:00
|
|
|
g_print (_("Terminating plug-in: '%s'\n"),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
|
|
|
|
2005-02-09 06:38:58 +08:00
|
|
|
status = kill (plug_in->pid, SIGKILL);
|
|
|
|
}
|
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
|
|
|
|
* immediately if it was just killed.
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
|
|
|
|
while (dwExitCode == dwExitCode &&
|
|
|
|
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)
|
2005-02-09 06:38:58 +08:00
|
|
|
g_print (_("Terminating plug-in: '%s'\n"),
|
|
|
|
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
|
|
|
|
2004-11-17 09:38:07 +08:00
|
|
|
for (list = plug_in->temp_proc_frames; list; list = g_list_next (list))
|
2001-09-03 21:03:34 +08:00
|
|
|
{
|
2004-11-17 09:38:07 +08:00
|
|
|
PlugInProcFrame *proc_frame = list->data;
|
|
|
|
|
2004-02-11 21:18:51 +08:00
|
|
|
#ifdef GIMP_UNSTABLE
|
|
|
|
g_printerr ("plug_in_close: plug-in aborted before sending its "
|
|
|
|
"temporary procedure return values\n");
|
|
|
|
#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);
|
|
|
|
}
|
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
|
|
|
|
g_printerr ("plug_in_close: plug-in aborted before sending its "
|
|
|
|
"procedure return values\n");
|
|
|
|
#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
|
|
|
}
|
|
|
|
|
2004-09-22 20:27:18 +08:00
|
|
|
plug_in_proc_frame_dispose (&plug_in->main_proc_frame, plug_in);
|
|
|
|
|
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
|
|
|
|
g_printerr ("plug_in_close: extension aborted before sending its "
|
|
|
|
"extension_ack message\n");
|
|
|
|
#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
|
|
|
plug_in->synchronous = FALSE;
|
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)
|
|
|
|
plug_in_remove_temp_proc (plug_in, plug_in->temp_procedures->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-03 21:03:34 +08:00
|
|
|
/* Close any dialogs that this plugin might have opened */
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_pdb_dialogs_check (plug_in->manager->gimp);
|
1998-09-19 08:40:27 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
plug_in->manager->open_plug_ins =
|
|
|
|
g_slist_remove (plug_in->manager->open_plug_ins, plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
static gboolean
|
2000-07-16 20:49:04 +08:00
|
|
|
plug_in_recv_message (GIOChannel *channel,
|
2006-04-12 20:49:29 +08:00
|
|
|
GIOCondition cond,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-12-13 22:11:56 +08:00
|
|
|
PlugIn *plug_in = data;
|
2002-03-21 01:46:13 +08:00
|
|
|
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
|
|
|
|
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
|
|
|
{
|
|
|
|
plug_in_close (plug_in, TRUE);
|
|
|
|
}
|
2002-03-21 01:46:13 +08:00
|
|
|
else
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
plug_in_handle_message (plug_in, &msg);
|
|
|
|
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
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
if (plug_in->open)
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
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-03-29 18:45:18 +08:00
|
|
|
g_message (_("Plug-in crashed: \"%s\"\n(%s)\n\n"
|
2006-04-12 20:49:29 +08:00
|
|
|
"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."),
|
|
|
|
gimp_filename_to_utf8 (plug_in->name),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog));
|
2000-05-11 05:21:23 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
if (! plug_in->open)
|
2003-02-03 21:21:31 +08:00
|
|
|
plug_in_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-03-12 01:33:36 +08:00
|
|
|
plug_in_write (GIOChannel *channel,
|
2006-04-12 20:49:29 +08:00
|
|
|
const guint8 *buf,
|
|
|
|
gulong count,
|
2006-03-12 01:33:36 +08:00
|
|
|
gpointer user_data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-12-13 22:11:56 +08:00
|
|
|
PlugIn *plug_in = user_data;
|
2002-05-17 01:41:38 +08:00
|
|
|
gulong bytes;
|
|
|
|
|
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
|
2002-05-17 01:41:38 +08:00
|
|
|
plug_in_flush (GIOChannel *channel,
|
|
|
|
gpointer user_data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-12-13 22:11:56 +08:00
|
|
|
PlugIn *plug_in = user_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;
|
|
|
|
}
|
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
void
|
2006-04-29 06:26:51 +08:00
|
|
|
plug_in_push (GimpPlugInManager *manager,
|
|
|
|
PlugIn *plug_in)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
2002-03-21 01:46:13 +08:00
|
|
|
g_return_if_fail (plug_in != NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
manager->current_plug_in = plug_in;
|
2002-03-21 01:46:13 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
manager->plug_in_stack = g_slist_prepend (manager->plug_in_stack,
|
|
|
|
manager->current_plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
void
|
2006-04-29 06:26:51 +08:00
|
|
|
plug_in_pop (GimpPlugInManager *manager)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
2003-02-11 20:07:31 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
if (manager->current_plug_in)
|
|
|
|
manager->plug_in_stack = g_slist_remove (manager->plug_in_stack,
|
|
|
|
manager->plug_in_stack->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
if (manager->plug_in_stack)
|
|
|
|
manager->current_plug_in = manager->plug_in_stack->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2006-04-29 06:26:51 +08:00
|
|
|
manager->current_plug_in = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2004-09-22 23:26:58 +08:00
|
|
|
PlugInProcFrame *
|
|
|
|
plug_in_get_proc_frame (PlugIn *plug_in)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (plug_in != NULL, NULL);
|
|
|
|
|
|
|
|
if (plug_in->temp_proc_frames)
|
|
|
|
return plug_in->temp_proc_frames->data;
|
|
|
|
else
|
|
|
|
return &plug_in->main_proc_frame;
|
|
|
|
}
|
|
|
|
|
2004-12-15 06:42:00 +08:00
|
|
|
PlugInProcFrame *
|
2006-04-01 01:42:13 +08:00
|
|
|
plug_in_proc_frame_push (PlugIn *plug_in,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
GimpProcedure *procedure)
|
2004-09-22 07:56:40 +08:00
|
|
|
{
|
|
|
|
PlugInProcFrame *proc_frame;
|
|
|
|
|
2004-12-15 06:42:00 +08:00
|
|
|
g_return_val_if_fail (plug_in != NULL, 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-01 01:42:13 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
2004-09-22 07:56:40 +08:00
|
|
|
|
2006-04-01 01:42:13 +08:00
|
|
|
proc_frame = plug_in_proc_frame_new (context, progress, 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
|
|
|
|
plug_in_proc_frame_pop (PlugIn *plug_in)
|
|
|
|
{
|
|
|
|
PlugInProcFrame *proc_frame;
|
|
|
|
|
|
|
|
g_return_if_fail (plug_in != NULL);
|
|
|
|
g_return_if_fail (plug_in->temp_proc_frames != NULL);
|
|
|
|
|
|
|
|
proc_frame = (PlugInProcFrame *) plug_in->temp_proc_frames->data;
|
|
|
|
|
2004-12-15 06:42:00 +08:00
|
|
|
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
|
|
|
|
plug_in_main_loop (PlugIn *plug_in)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-09-22 07:56:40 +08:00
|
|
|
PlugInProcFrame *proc_frame;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
g_return_if_fail (plug_in != NULL);
|
2004-09-22 07:56:40 +08:00
|
|
|
g_return_if_fail (plug_in->temp_proc_frames != NULL);
|
|
|
|
|
|
|
|
proc_frame = (PlugInProcFrame *) 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
|
|
|
|
plug_in_main_loop_quit (PlugIn *plug_in)
|
|
|
|
{
|
2004-09-22 07:56:40 +08:00
|
|
|
PlugInProcFrame *proc_frame;
|
2003-06-24 02:27:03 +08:00
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
g_return_if_fail (plug_in != NULL);
|
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
|
|
|
|
2004-09-22 07:56:40 +08:00
|
|
|
proc_frame = (PlugInProcFrame *) 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
|
|
|
|
|
|
|
gchar *
|
|
|
|
plug_in_get_undo_desc (PlugIn *plug_in)
|
|
|
|
{
|
2006-04-05 16:38:33 +08:00
|
|
|
PlugInProcFrame *proc_frame = NULL;
|
|
|
|
GimpPlugInProcedure *proc = NULL;
|
|
|
|
gchar *undo_desc = NULL;
|
2003-02-18 22:08:14 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (plug_in != NULL, NULL);
|
|
|
|
|
2004-09-22 23:26:58 +08:00
|
|
|
proc_frame = plug_in_get_proc_frame (plug_in);
|
2004-09-22 07:56:40 +08:00
|
|
|
|
|
|
|
if (proc_frame)
|
2006-04-05 16:38:33 +08:00
|
|
|
proc = GIMP_PLUG_IN_PROCEDURE (proc_frame->procedure);
|
2003-02-18 22:08:14 +08:00
|
|
|
|
2006-04-05 16:38:33 +08:00
|
|
|
if (proc)
|
2003-02-18 22:08:14 +08:00
|
|
|
{
|
2006-04-29 06:26:51 +08:00
|
|
|
const gchar *domain;
|
|
|
|
|
|
|
|
domain = gimp_plug_in_manager_get_locale_domain (plug_in->manager,
|
|
|
|
plug_in->prog, NULL);
|
2003-02-18 22:08:14 +08:00
|
|
|
|
2006-04-05 16:38:33 +08:00
|
|
|
undo_desc = gimp_plug_in_procedure_get_label (proc, domain);
|
2003-02-18 22:08:14 +08:00
|
|
|
}
|
|
|
|
|
2004-05-18 17:04:12 +08:00
|
|
|
if (! undo_desc)
|
2005-02-21 05:49:53 +08:00
|
|
|
undo_desc = g_filename_display_name (plug_in->name);
|
2004-05-18 17:04:12 +08:00
|
|
|
|
2003-02-18 22:08:14 +08:00
|
|
|
return undo_desc;
|
|
|
|
}
|
2006-01-12 03:41:25 +08:00
|
|
|
|
|
|
|
/* called from the PDB (gimp_plugin_menu_register) */
|
|
|
|
gboolean
|
|
|
|
plug_in_menu_register (PlugIn *plug_in,
|
|
|
|
const gchar *proc_name,
|
|
|
|
const gchar *menu_path)
|
|
|
|
{
|
2006-04-05 16:38:33 +08:00
|
|
|
GimpPlugInProcedure *proc = NULL;
|
|
|
|
GError *error = NULL;
|
2006-01-12 03:41:25 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (plug_in != NULL, FALSE);
|
|
|
|
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
|
|
|
{
|
|
|
|
g_message ("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.",
|
|
|
|
gimp_filename_to_utf8 (plug_in->name),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog),
|
|
|
|
menu_path, proc_name);
|
|
|
|
|
|
|
|
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:
|
|
|
|
if (! plug_in->query && ! plug_in->init)
|
|
|
|
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
|
|
|
{
|
|
|
|
g_message ("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().",
|
|
|
|
gimp_filename_to_utf8 (plug_in->name),
|
|
|
|
gimp_filename_to_utf8 (plug_in->prog),
|
|
|
|
menu_path, proc_name);
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
g_message (error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-04-07 16:16:26 +08:00
|
|
|
void
|
|
|
|
plug_in_add_temp_proc (PlugIn *plug_in,
|
|
|
|
GimpTemporaryProcedure *proc)
|
|
|
|
{
|
|
|
|
g_return_if_fail (plug_in != NULL);
|
|
|
|
g_return_if_fail (GIMP_IS_TEMPORARY_PROCEDURE (proc));
|
|
|
|
|
|
|
|
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
|
|
|
|
plug_in_remove_temp_proc (PlugIn *plug_in,
|
|
|
|
GimpTemporaryProcedure *proc)
|
|
|
|
{
|
|
|
|
g_return_if_fail (plug_in != NULL);
|
|
|
|
g_return_if_fail (GIMP_IS_TEMPORARY_PROCEDURE (proc));
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|