1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-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
|
|
|
|
1999-06-22 04:04:04 +08:00
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
|
|
#include <sys/param.h>
|
|
|
|
#endif
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
1999-06-15 06:18:02 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <signal.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
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
|
|
|
|
#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
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <time.h>
|
1999-03-07 20:56:03 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <unistd.h>
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
|
|
|
|
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
|
1999-03-07 20:56:03 +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 */
|
|
|
|
#endif
|
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
#endif /* G_OS_WIN32 || G_WITH_CYGWIN */
|
1999-03-07 20:56:03 +08:00
|
|
|
|
1999-04-25 03:12:12 +08:00
|
|
|
#ifdef __EMX__
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <process.h>
|
|
|
|
#define _O_BINARY O_BINARY
|
|
|
|
#define _P_NOWAIT P_NOWAIT
|
|
|
|
#endif
|
|
|
|
|
1998-08-29 07:01:46 +08:00
|
|
|
#ifdef HAVE_IPC_H
|
|
|
|
#include <sys/ipc.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SHM_H
|
|
|
|
#include <sys/shm.h>
|
|
|
|
#endif
|
|
|
|
|
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-05-15 19:25:25 +08:00
|
|
|
#include "base/tile.h"
|
|
|
|
#include "base/tile-manager.h"
|
|
|
|
|
2003-01-08 01:00:49 +08:00
|
|
|
#include "config/gimpguiconfig.h"
|
2002-11-19 04:50:31 +08:00
|
|
|
|
2001-07-11 20:39:49 +08:00
|
|
|
#include "core/gimp.h"
|
2001-10-17 19:33:43 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
2002-11-12 11:34:11 +08:00
|
|
|
#include "core/gimpenvirontable.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
|
|
|
#include "gui/brush-select.h"
|
|
|
|
#include "gui/gradient-select.h"
|
2002-03-13 05:02:10 +08:00
|
|
|
#include "gui/palette-select.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "gui/pattern-select.h"
|
|
|
|
|
2001-12-01 08:14:14 +08:00
|
|
|
#include "plug-in.h"
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-ins.h"
|
|
|
|
#include "plug-in-def.h"
|
|
|
|
#include "plug-in-params.h"
|
2001-12-19 08:13:16 +08:00
|
|
|
#include "plug-in-proc.h"
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-in-progress.h"
|
2001-12-01 08:14:14 +08:00
|
|
|
|
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
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
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
|
|
|
|
2000-07-16 20:49:04 +08:00
|
|
|
typedef struct _PlugInBlocked PlugInBlocked;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
struct _PlugInBlocked
|
|
|
|
{
|
|
|
|
PlugIn *plug_in;
|
2000-02-25 00:11:26 +08:00
|
|
|
gchar *proc_name;
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-02-25 00:11:26 +08:00
|
|
|
static gboolean plug_in_write (GIOChannel *channel,
|
1997-11-25 06:05:25 +08:00
|
|
|
guint8 *buf,
|
2002-05-17 01:41:38 +08:00
|
|
|
gulong count,
|
|
|
|
gpointer user_data);
|
|
|
|
static gboolean plug_in_flush (GIOChannel *channel,
|
|
|
|
gpointer user_data);
|
2000-02-25 00:11:26 +08:00
|
|
|
static void plug_in_push (PlugIn *plug_in);
|
|
|
|
static void plug_in_pop (void);
|
1999-03-07 20:56:03 +08:00
|
|
|
static gboolean plug_in_recv_message (GIOChannel *channel,
|
|
|
|
GIOCondition cond,
|
|
|
|
gpointer data);
|
2002-03-21 01:46:13 +08:00
|
|
|
static void plug_in_handle_message (PlugIn *plug_in,
|
|
|
|
WireMessage *msg);
|
|
|
|
static void plug_in_handle_quit (PlugIn *plug_in);
|
|
|
|
static void plug_in_handle_tile_req (PlugIn *plug_in,
|
|
|
|
GPTileReq *tile_req);
|
2002-05-16 19:45:30 +08:00
|
|
|
static void plug_in_handle_proc_run (PlugIn *plug_in,
|
2002-03-21 01:46:13 +08:00
|
|
|
GPProcRun *proc_run);
|
2002-05-16 19:45:30 +08:00
|
|
|
static void plug_in_handle_proc_return (PlugIn *plug_in,
|
2002-03-21 01:46:13 +08:00
|
|
|
GPProcReturn *proc_return);
|
2002-05-16 19:45:30 +08:00
|
|
|
static void plug_in_handle_proc_install (PlugIn *plug_in,
|
2002-03-21 01:46:13 +08:00
|
|
|
GPProcInstall *proc_install);
|
2002-05-16 19:45:30 +08:00
|
|
|
static void plug_in_handle_proc_uninstall (PlugIn *plug_in,
|
2002-03-21 01:46:13 +08:00
|
|
|
GPProcUninstall *proc_uninstall);
|
2002-05-21 18:58:50 +08:00
|
|
|
static void plug_in_handle_extension_ack (PlugIn *plug_in);
|
2002-05-16 19:45:30 +08:00
|
|
|
static void plug_in_handle_has_init (PlugIn *plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-11-17 03:01:46 +08:00
|
|
|
static Argument * plug_in_temp_run (ProcRecord *proc_rec,
|
|
|
|
Argument *args,
|
|
|
|
gint argc);
|
2000-07-16 20:49:04 +08:00
|
|
|
static void plug_in_init_shm (void);
|
|
|
|
|
2002-11-17 03:01:46 +08:00
|
|
|
static void plug_in_prep_for_exec (gpointer data);
|
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
|
|
|
|
2001-11-18 00:32:34 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
PlugIn *current_plug_in = NULL;
|
|
|
|
ProcRecord *last_plug_in = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
static GSList *open_plug_ins = NULL;
|
|
|
|
static GSList *blocked_plug_ins = NULL;
|
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
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
static GSList *plug_in_stack = NULL;
|
|
|
|
static Argument *current_return_vals = NULL;
|
|
|
|
static gint current_return_nvals = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
static gint shm_ID = -1;
|
|
|
|
static guchar *shm_addr = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-07 05:27:18 +08:00
|
|
|
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
1999-03-07 20:56:03 +08:00
|
|
|
static HANDLE shm_handle;
|
|
|
|
#endif
|
|
|
|
|
1999-05-07 04:56:07 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
plug_in_init_shm (void)
|
|
|
|
{
|
|
|
|
/* allocate a piece of shared memory for use in transporting tiles
|
|
|
|
* to plug-ins. if we can't allocate a piece of shared memory then
|
|
|
|
* we'll fall back on sending the data over the pipe.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_SHM_H
|
2002-06-13 20:02:06 +08:00
|
|
|
shm_ID = shmget (IPC_PRIVATE,
|
|
|
|
TILE_WIDTH * TILE_HEIGHT * 4,
|
|
|
|
IPC_CREAT | 0600);
|
|
|
|
|
1999-05-07 04:56:07 +08:00
|
|
|
if (shm_ID == -1)
|
2000-05-17 20:29:38 +08:00
|
|
|
g_message ("shmget() failed: Disabling shared memory tile transport.");
|
1999-05-07 04:56:07 +08:00
|
|
|
else
|
|
|
|
{
|
2000-04-11 23:24:15 +08:00
|
|
|
shm_addr = (guchar *) shmat (shm_ID, NULL, 0);
|
|
|
|
if (shm_addr == (guchar *) -1)
|
1999-05-07 04:56:07 +08:00
|
|
|
{
|
2000-05-17 20:29:38 +08:00
|
|
|
g_message ("shmat() failed: Disabling shared memory tile transport.");
|
2000-04-11 23:24:15 +08:00
|
|
|
shmctl (shm_ID, IPC_RMID, NULL);
|
1999-05-07 04:56:07 +08:00
|
|
|
shm_ID = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef IPC_RMID_DEFERRED_RELEASE
|
2000-04-11 23:24:15 +08:00
|
|
|
if (shm_addr != (guchar *) -1)
|
|
|
|
shmctl (shm_ID, IPC_RMID, NULL);
|
1999-05-07 04:56:07 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#else
|
1999-10-07 05:27:18 +08:00
|
|
|
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
1999-05-07 04:56:07 +08:00
|
|
|
/* Use Win32 shared memory mechanisms for
|
|
|
|
* transfering tile data.
|
|
|
|
*/
|
2000-05-17 20:29:38 +08:00
|
|
|
gint pid;
|
|
|
|
gchar fileMapName[MAX_PATH];
|
|
|
|
gint tileByteSize = TILE_WIDTH * TILE_HEIGHT * 4;
|
1999-05-07 04:56:07 +08:00
|
|
|
|
|
|
|
/* Our shared memory id will be our process ID */
|
|
|
|
pid = GetCurrentProcessId ();
|
|
|
|
|
|
|
|
/* From the id, derive the file map name */
|
2000-07-16 20:49:04 +08:00
|
|
|
g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
|
|
|
|
|
1999-05-07 04:56:07 +08:00
|
|
|
/* Create the file mapping into paging space */
|
|
|
|
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
|
|
|
|
PAGE_READWRITE, 0,
|
|
|
|
tileByteSize, fileMapName);
|
|
|
|
|
|
|
|
if (shm_handle)
|
|
|
|
{
|
|
|
|
/* Map the shared memory into our address space for use */
|
|
|
|
shm_addr = (guchar *) MapViewOfFile(shm_handle,
|
2000-04-11 23:24:15 +08:00
|
|
|
FILE_MAP_ALL_ACCESS,
|
1999-05-07 04:56:07 +08:00
|
|
|
0, 0, tileByteSize);
|
|
|
|
|
|
|
|
/* Verify that we mapped our view */
|
|
|
|
if (shm_addr)
|
|
|
|
shm_ID = pid;
|
2000-04-11 23:24:15 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("MapViewOfFile error: %d... disabling shared memory transport\n", GetLastError());
|
|
|
|
}
|
1999-05-07 04:56:07 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("CreateFileMapping error: %d... disabling shared memory transport\n", GetLastError());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_init (Gimp *gimp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-10-20 00:41:09 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* initialize the gimp protocol library and set the read and
|
|
|
|
* write handlers.
|
|
|
|
*/
|
|
|
|
gp_init ();
|
|
|
|
wire_set_writer (plug_in_write);
|
|
|
|
wire_set_flusher (plug_in_flush);
|
|
|
|
|
|
|
|
/* allocate a piece of shared memory for use in transporting tiles
|
|
|
|
* to plug-ins. if we can't allocate a piece of shared memory then
|
|
|
|
* we'll fall back on sending the data over the pipe.
|
|
|
|
*/
|
2002-12-01 20:16:03 +08:00
|
|
|
if (gimp->use_shm)
|
2000-07-16 20:49:04 +08:00
|
|
|
plug_in_init_shm ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_kill (Gimp *gimp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GSList *tmp;
|
|
|
|
PlugIn *plug_in;
|
|
|
|
|
1999-10-07 05:27:18 +08:00
|
|
|
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
1999-03-07 20:56:03 +08:00
|
|
|
CloseHandle (shm_handle);
|
|
|
|
#else
|
1998-08-29 07:01:46 +08:00
|
|
|
#ifdef HAVE_SHM_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#ifndef IPC_RMID_DEFERRED_RELEASE
|
|
|
|
if (shm_ID != -1)
|
|
|
|
{
|
2000-04-11 23:24:15 +08:00
|
|
|
shmdt ((gchar *) shm_addr);
|
|
|
|
shmctl (shm_ID, IPC_RMID, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
#else /* IPC_RMID_DEFERRED_RELEASE */
|
|
|
|
if (shm_ID != -1)
|
2000-04-11 23:24:15 +08:00
|
|
|
shmdt ((gchar *) shm_addr);
|
1997-11-25 06:05:25 +08:00
|
|
|
#endif
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
1998-08-29 07:01:46 +08:00
|
|
|
#endif
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
tmp = open_plug_ins;
|
|
|
|
while (tmp)
|
|
|
|
{
|
|
|
|
plug_in = tmp->data;
|
|
|
|
tmp = tmp->next;
|
|
|
|
|
|
|
|
plug_in_destroy (plug_in);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_call_query (Gimp *gimp,
|
|
|
|
PlugInDef *plug_in_def)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
PlugIn *plug_in;
|
|
|
|
WireMessage msg;
|
2001-01-14 23:18:37 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in = plug_in_new (gimp, 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))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_push (plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
while (plug_in->open)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-05-17 01:41:38 +08:00
|
|
|
if (! 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
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_handle_message (plug_in, &msg);
|
2002-03-21 01:46:13 +08:00
|
|
|
wire_destroy (&msg);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_pop ();
|
|
|
|
plug_in_destroy (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
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_call_init (Gimp *gimp,
|
|
|
|
PlugInDef *plug_in_def)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
PlugIn *plug_in;
|
|
|
|
WireMessage msg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in = plug_in_new (gimp, 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))
|
1999-11-25 19:35:48 +08:00
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_push (plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
while (plug_in->open)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-05-17 01:41:38 +08:00
|
|
|
if (! 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
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_handle_message (plug_in, &msg);
|
2002-03-21 01:46:13 +08:00
|
|
|
wire_destroy (&msg);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-07-27 23:18:20 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_pop ();
|
|
|
|
plug_in_destroy (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 *
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_new (Gimp *gimp,
|
|
|
|
gchar *name)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
PlugIn *plug_in;
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
2003-01-20 20:17:32 +08:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
g_return_val_if_fail (g_path_is_absolute (name), NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in = g_new0 (PlugIn, 1);
|
|
|
|
|
|
|
|
plug_in->gimp = gimp;
|
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
|
|
|
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->recurse = FALSE;
|
|
|
|
plug_in->busy = FALSE;
|
|
|
|
plug_in->pid = 0;
|
2003-01-20 20:17:32 +08:00
|
|
|
plug_in->args[0] = g_strdup (name);
|
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->args[1] = g_strdup ("-gimp");
|
2000-07-16 20:49:04 +08:00
|
|
|
plug_in->args[2] = NULL;
|
|
|
|
plug_in->args[3] = NULL;
|
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->args[4] = NULL;
|
|
|
|
plug_in->args[5] = NULL;
|
|
|
|
plug_in->args[6] = NULL;
|
|
|
|
plug_in->my_read = NULL;
|
|
|
|
plug_in->my_write = NULL;
|
|
|
|
plug_in->his_read = NULL;
|
|
|
|
plug_in->his_write = NULL;
|
|
|
|
plug_in->input_id = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
plug_in->write_buffer_index = 0;
|
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->temp_proc_defs = NULL;
|
|
|
|
plug_in->progress = NULL;
|
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
|
|
|
|
plug_in_destroy (PlugIn *plug_in)
|
|
|
|
{
|
2003-01-20 20:17:32 +08:00
|
|
|
g_return_if_fail (plug_in != NULL);
|
|
|
|
|
|
|
|
if (plug_in->open)
|
|
|
|
plug_in_close (plug_in, TRUE);
|
|
|
|
|
|
|
|
if (plug_in->args[0])
|
|
|
|
g_free (plug_in->args[0]);
|
|
|
|
if (plug_in->args[1])
|
|
|
|
g_free (plug_in->args[1]);
|
|
|
|
if (plug_in->args[2])
|
|
|
|
g_free (plug_in->args[2]);
|
|
|
|
if (plug_in->args[3])
|
|
|
|
g_free (plug_in->args[3]);
|
|
|
|
if (plug_in->args[4])
|
|
|
|
g_free (plug_in->args[4]);
|
|
|
|
if (plug_in->args[5])
|
|
|
|
g_free (plug_in->args[5]);
|
|
|
|
|
|
|
|
if (plug_in->progress)
|
|
|
|
plug_in_progress_end (plug_in);
|
|
|
|
|
|
|
|
if (plug_in == current_plug_in)
|
|
|
|
plug_in_pop ();
|
|
|
|
|
|
|
|
g_free (plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
#if !defined(G_OS_WIN32) && !defined (G_WITH_CYGWIN) && !defined(__EMX__)
|
|
|
|
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;
|
|
|
|
#endif
|
|
|
|
}
|
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
|
|
|
|
2000-02-25 00:11:26 +08:00
|
|
|
gboolean
|
1997-11-25 06:05:25 +08:00
|
|
|
plug_in_open (PlugIn *plug_in)
|
|
|
|
{
|
2003-01-20 20:17:32 +08:00
|
|
|
gint my_read[2];
|
|
|
|
gint my_write[2];
|
2002-11-17 03:01:46 +08:00
|
|
|
gchar **envp;
|
|
|
|
GError *error = NULL;
|
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
|
|
|
{
|
2003-01-20 20:17:32 +08:00
|
|
|
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
|
|
|
g_path_get_basename (plug_in->args[0]),
|
|
|
|
plug_in->args[0]);
|
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-07 05:27:18 +08:00
|
|
|
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
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.
|
|
|
|
*/
|
|
|
|
plug_in->args[2] =
|
|
|
|
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
|
|
|
plug_in->args[3] =
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
plug_in->args[4] = g_strdup ("-query");
|
|
|
|
}
|
|
|
|
else if (plug_in->init)
|
|
|
|
{
|
|
|
|
plug_in->args[4] = g_strdup ("-init");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
plug_in->args[4] = g_strdup ("-run");
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
2000-07-16 20:49:04 +08:00
|
|
|
|
1999-04-25 03:12:12 +08:00
|
|
|
#ifdef __EMX__
|
2003-01-20 20:17:32 +08:00
|
|
|
fcntl (my_read[0], F_SETFD, 1);
|
|
|
|
fcntl (my_write[1], F_SETFD, 1);
|
1999-04-25 03:12:12 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
/* Fork another process. We'll remember the process id
|
|
|
|
* so that we can later use it to kill the filter if
|
|
|
|
* necessary.
|
|
|
|
*/
|
|
|
|
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
|
|
|
if (! g_spawn_async (NULL, plug_in->args, envp,
|
|
|
|
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
|
|
|
G_SPAWN_DO_NOT_REAP_CHILD,
|
|
|
|
plug_in_prep_for_exec, plug_in,
|
|
|
|
&plug_in->pid,
|
|
|
|
&error))
|
|
|
|
{
|
|
|
|
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
|
|
|
g_path_get_basename (plug_in->args[0]),
|
|
|
|
plug_in->args[0],
|
|
|
|
error->message);
|
|
|
|
g_error_free (error);
|
2002-11-17 03:01:46 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
plug_in_destroy (plug_in);
|
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
g_io_channel_unref (plug_in->his_read);
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
plug_in->input_id = g_io_add_watch (plug_in->my_read,
|
|
|
|
G_IO_IN | G_IO_PRI |
|
|
|
|
G_IO_ERR | G_IO_HUP,
|
|
|
|
plug_in_recv_message,
|
|
|
|
plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
open_plug_ins = g_slist_prepend (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;
|
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-02-25 00:11:26 +08:00
|
|
|
plug_in_close (PlugIn *plug_in,
|
|
|
|
gboolean kill_it)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-11-25 19:35:48 +08:00
|
|
|
gint status;
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifndef G_OS_WIN32
|
1997-11-25 06:05:25 +08:00
|
|
|
struct timeval tv;
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
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
|
|
|
|
2001-09-03 21:03:34 +08:00
|
|
|
/* Ask the filter to exit gracefully */
|
|
|
|
if (kill_it && plug_in->pid)
|
|
|
|
{
|
|
|
|
plug_in_push (plug_in);
|
2002-05-17 01:41:38 +08:00
|
|
|
gp_quit_write (plug_in->my_write, plug_in);
|
2001-09-03 21:03:34 +08:00
|
|
|
plug_in_pop ();
|
|
|
|
|
|
|
|
/* give the plug-in some time (10 ms) */
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifndef G_OS_WIN32
|
2001-09-03 21:03:34 +08:00
|
|
|
tv.tv_sec = 0;
|
|
|
|
tv.tv_usec = 100; /* But this is 0.1 ms? */
|
|
|
|
select (0, NULL, NULL, NULL, &tv);
|
1999-03-07 20:56:03 +08:00
|
|
|
#else
|
2001-09-03 21:03:34 +08:00
|
|
|
Sleep (10);
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
2001-09-03 21:03:34 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-03 21:03:34 +08:00
|
|
|
/* If necessary, kill the filter. */
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifndef G_OS_WIN32
|
2001-09-03 21:03:34 +08:00
|
|
|
if (kill_it && plug_in->pid)
|
|
|
|
status = kill (plug_in->pid, SIGKILL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-03 21:03:34 +08:00
|
|
|
/* Wait for the process to exit. This will happen
|
|
|
|
* immediately if it was just killed.
|
|
|
|
*/
|
|
|
|
if (plug_in->pid)
|
|
|
|
waitpid (plug_in->pid, &status, 0);
|
1999-03-07 20:56:03 +08:00
|
|
|
#else
|
2001-09-03 21:03:34 +08:00
|
|
|
if (kill_it && plug_in->pid)
|
|
|
|
{
|
|
|
|
/* 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 ((STILL_ACTIVE == dwExitCode)
|
2003-01-20 20:17:32 +08:00
|
|
|
&& GetExitCodeProcess ((HANDLE) plug_in->pid, &dwExitCode)
|
2001-09-03 21:03:34 +08:00
|
|
|
&& (dwTries > 0))
|
1999-03-07 20:56:03 +08:00
|
|
|
{
|
2001-09-03 21:03:34 +08:00
|
|
|
Sleep(10);
|
|
|
|
dwTries--;
|
1999-03-07 20:56:03 +08:00
|
|
|
}
|
2001-09-03 21:03:34 +08:00
|
|
|
if (STILL_ACTIVE == dwExitCode)
|
1999-03-07 20:56:03 +08:00
|
|
|
{
|
2003-01-20 20:17:32 +08:00
|
|
|
g_warning ("Terminating %s ...", plug_in->args[0]);
|
2001-09-03 21:03:34 +08:00
|
|
|
TerminateProcess ((HANDLE) plug_in->pid, 0);
|
1999-03-07 20:56:03 +08:00
|
|
|
}
|
2001-09-03 21:03:34 +08:00
|
|
|
}
|
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-03 21:03:34 +08:00
|
|
|
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
|
|
|
|
2001-09-03 21:03:34 +08:00
|
|
|
wire_clear_error ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-03 21:03:34 +08:00
|
|
|
if (plug_in->progress)
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_progress_end (plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-03 21:03:34 +08:00
|
|
|
if (plug_in->recurse)
|
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
gimp_main_loop_quit (plug_in->gimp);
|
2001-11-18 00:32:34 +08:00
|
|
|
|
2001-09-03 21:03:34 +08:00
|
|
|
plug_in->recurse = FALSE;
|
|
|
|
}
|
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. */
|
|
|
|
if (plug_in->temp_proc_defs)
|
|
|
|
{
|
2003-01-18 02:07:37 +08:00
|
|
|
GSList *list;
|
|
|
|
|
|
|
|
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
|
|
|
|
plug_ins_temp_proc_def_remove (plug_in->gimp,
|
|
|
|
(PlugInProcDef *) list->data);
|
|
|
|
|
2001-09-03 21:03:34 +08:00
|
|
|
g_slist_free (plug_in->temp_proc_defs);
|
|
|
|
plug_in->temp_proc_defs = NULL;
|
|
|
|
}
|
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 */
|
|
|
|
brush_select_dialogs_check ();
|
|
|
|
gradient_select_dialogs_check ();
|
2002-03-13 05:02:10 +08:00
|
|
|
palette_select_dialogs_check ();
|
|
|
|
pattern_select_dialogs_check ();
|
1998-09-19 08:40:27 +08:00
|
|
|
|
2001-09-03 21:03:34 +08:00
|
|
|
open_plug_ins = g_slist_remove (open_plug_ins, plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Argument *
|
|
|
|
plug_in_get_current_return_vals (ProcRecord *proc_rec)
|
|
|
|
{
|
|
|
|
Argument *return_vals;
|
2000-07-16 20:49:04 +08:00
|
|
|
gint nargs;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Return the status code plus the current return values. */
|
|
|
|
nargs = proc_rec->num_values + 1;
|
|
|
|
if (current_return_vals && current_return_nvals == nargs)
|
2000-07-16 20:49:04 +08:00
|
|
|
{
|
|
|
|
return_vals = current_return_vals;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else if (current_return_vals)
|
|
|
|
{
|
|
|
|
/* Allocate new return values of the correct size. */
|
|
|
|
return_vals = procedural_db_return_args (proc_rec, FALSE);
|
|
|
|
|
|
|
|
/* Copy all of the arguments we can. */
|
|
|
|
memcpy (return_vals, current_return_vals,
|
|
|
|
sizeof (Argument) * MIN (current_return_nvals, nargs));
|
|
|
|
|
|
|
|
/* Free the old argument pointer. This will cause a memory leak
|
|
|
|
only if there were more values returned than we need (which
|
|
|
|
shouldn't ever happen). */
|
|
|
|
g_free (current_return_vals);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Just return a dummy set of values. */
|
|
|
|
return_vals = procedural_db_return_args (proc_rec, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have consumed any saved values, so clear them. */
|
|
|
|
current_return_nvals = 0;
|
2000-07-16 20:49:04 +08:00
|
|
|
current_return_vals = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return return_vals;
|
|
|
|
}
|
|
|
|
|
2000-07-16 20:49:04 +08:00
|
|
|
Argument *
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_run (Gimp *gimp,
|
|
|
|
ProcRecord *proc_rec,
|
1997-11-25 06:05:25 +08:00
|
|
|
Argument *args,
|
2000-02-25 00:11:26 +08:00
|
|
|
gint argc,
|
|
|
|
gboolean synchronous,
|
|
|
|
gboolean destroy_values,
|
|
|
|
gint gdisp_ID)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-17 20:29:38 +08:00
|
|
|
GPConfig config;
|
|
|
|
GPProcRun proc_run;
|
|
|
|
Argument *return_vals;
|
|
|
|
PlugIn *plug_in;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return_vals = NULL;
|
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
if (proc_rec->proc_type == GIMP_TEMPORARY)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-10-22 03:10:14 +08:00
|
|
|
return_vals = plug_in_temp_run (proc_rec, args, argc);
|
1997-11-25 06:05:25 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in = plug_in_new (gimp, proc_rec->exec_method.plug_in.filename);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (plug_in)
|
|
|
|
{
|
|
|
|
if (plug_in_open (plug_in))
|
|
|
|
{
|
|
|
|
plug_in->recurse = synchronous;
|
|
|
|
|
|
|
|
plug_in_push (plug_in);
|
|
|
|
|
2003-01-08 01:00:49 +08:00
|
|
|
config.version = GP_VERSION;
|
|
|
|
config.tile_width = TILE_WIDTH;
|
|
|
|
config.tile_height = TILE_HEIGHT;
|
|
|
|
config.shm_ID = shm_ID;
|
|
|
|
config.gamma = gimp->config->gamma_val;
|
|
|
|
config.install_cmap = gimp->config->install_cmap;
|
|
|
|
config.show_tool_tips = GIMP_GUI_CONFIG (gimp->config)->show_tool_tips;
|
|
|
|
config.min_colors = CLAMP (gimp->config->min_colors, 27, 256);
|
|
|
|
config.gdisp_ID = gdisp_ID;
|
2000-05-01 02:17:55 +08:00
|
|
|
|
|
|
|
proc_run.name = proc_rec->name;
|
1998-10-22 03:10:14 +08:00
|
|
|
proc_run.nparams = argc;
|
2000-05-01 02:17:55 +08:00
|
|
|
proc_run.params = plug_in_args_to_params (args, argc, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-17 01:41:38 +08:00
|
|
|
if (! gp_config_write (plug_in->my_write, &config, plug_in) ||
|
|
|
|
! gp_proc_run_write (plug_in->my_write, &proc_run, plug_in) ||
|
|
|
|
! wire_flush (plug_in->my_write, plug_in))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
return_vals = procedural_db_return_args (proc_rec, FALSE);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
plug_in_pop ();
|
|
|
|
|
|
|
|
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
|
|
|
|
|
2000-07-16 20:49:04 +08:00
|
|
|
/* If this is an automatically installed extension, wait for an
|
|
|
|
* installation-confirmation message
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2001-05-21 21:58:46 +08:00
|
|
|
if ((proc_rec->proc_type == GIMP_EXTENSION) &&
|
2000-05-17 20:29:38 +08:00
|
|
|
(proc_rec->num_args == 0))
|
2001-11-18 00:32:34 +08:00
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
gimp_main_loop (gimp);
|
2001-11-18 00:32:34 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (plug_in->recurse)
|
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
gimp_main_loop (gimp);
|
2001-11-18 00:32:34 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return_vals = plug_in_get_current_return_vals (proc_rec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
done:
|
1997-11-25 06:05:25 +08:00
|
|
|
if (return_vals && destroy_values)
|
|
|
|
{
|
|
|
|
procedural_db_destroy_args (return_vals, proc_rec->num_values);
|
|
|
|
return_vals = NULL;
|
|
|
|
}
|
|
|
|
return return_vals;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_repeat (Gimp *gimp,
|
|
|
|
gint display_ID,
|
|
|
|
gint image_ID,
|
|
|
|
gint drawable_ID,
|
|
|
|
gboolean with_interface)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
Argument *args;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (last_plug_in)
|
|
|
|
{
|
|
|
|
/* construct the procedures arguments */
|
1998-10-22 03:10:14 +08:00
|
|
|
args = g_new (Argument, 3);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-10-22 03:10:14 +08:00
|
|
|
/* initialize the first three argument types */
|
|
|
|
for (i = 0; i < 3; i++)
|
1997-11-25 06:05:25 +08:00
|
|
|
args[i].arg_type = last_plug_in->args[i].arg_type;
|
|
|
|
|
1998-10-22 03:10:14 +08:00
|
|
|
/* initialize the first three plug-in arguments */
|
2001-12-19 08:13:16 +08:00
|
|
|
args[0].value.pdb_int = (with_interface ?
|
|
|
|
GIMP_RUN_INTERACTIVE : GIMP_RUN_WITH_LAST_VALS);
|
2002-03-21 01:46:13 +08:00
|
|
|
args[1].value.pdb_int = image_ID;
|
|
|
|
args[2].value.pdb_int = drawable_ID;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* run the plug-in procedure */
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_run (gimp, last_plug_in, args, 3, FALSE, TRUE, display_ID);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
g_free (args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
static gboolean
|
2000-07-16 20:49:04 +08:00
|
|
|
plug_in_recv_message (GIOChannel *channel,
|
|
|
|
GIOCondition cond,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
PlugIn *plug_in;
|
|
|
|
gboolean got_message = FALSE;
|
2000-05-11 05:21:23 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in = (PlugIn *) data;
|
|
|
|
|
|
|
|
if (plug_in != current_plug_in)
|
|
|
|
plug_in_push (plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
WireMessage msg;
|
|
|
|
|
|
|
|
memset (&msg, 0, sizeof (WireMessage));
|
|
|
|
|
2002-05-17 01:41:38 +08:00
|
|
|
if (! wire_read_msg (plug_in->my_read, &msg, plug_in))
|
2000-05-11 05:21:23 +08:00
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
2000-05-11 05:21:23 +08:00
|
|
|
}
|
2002-03-21 01:46:13 +08:00
|
|
|
else
|
2000-05-11 05:21:23 +08:00
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_handle_message (plug_in, &msg);
|
2000-05-11 05:21:23 +08:00
|
|
|
wire_destroy (&msg);
|
|
|
|
got_message = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2000-05-11 05:21:23 +08:00
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
2000-05-11 05:21:23 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
if (! got_message)
|
2000-05-17 20:29:38 +08:00
|
|
|
g_message (_("Plug-In crashed: \"%s\"\n(%s)\n\n"
|
|
|
|
"The dying Plug-In may have messed up GIMP's internal state.\n"
|
|
|
|
"You may want to save your images and restart GIMP\n"
|
|
|
|
"to be on the safe side."),
|
2002-03-21 01:46:13 +08:00
|
|
|
g_path_get_basename (plug_in->args[0]),
|
|
|
|
plug_in->args[0]);
|
2000-05-11 05:21:23 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
if (! plug_in->open)
|
|
|
|
plug_in_destroy (plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
|
|
|
plug_in_pop ();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_handle_message (PlugIn *plug_in,
|
|
|
|
WireMessage *msg)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
switch (msg->type)
|
|
|
|
{
|
|
|
|
case GP_QUIT:
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_handle_quit (plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_CONFIG:
|
2000-07-16 20:49:04 +08:00
|
|
|
g_warning ("plug_in_handle_message(): "
|
|
|
|
"received a config message (should not happen)");
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_TILE_REQ:
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_handle_tile_req (plug_in, msg->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_TILE_ACK:
|
2000-07-16 20:49:04 +08:00
|
|
|
g_warning ("plug_in_handle_message(): "
|
|
|
|
"received a tile ack message (should not happen)");
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_TILE_DATA:
|
2000-07-16 20:49:04 +08:00
|
|
|
g_warning ("plug_in_handle_message(): "
|
|
|
|
"received a tile data message (should not happen)");
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_PROC_RUN:
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_handle_proc_run (plug_in, msg->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_PROC_RETURN:
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_handle_proc_return (plug_in, msg->data);
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_TEMP_PROC_RUN:
|
2000-07-16 20:49:04 +08:00
|
|
|
g_warning ("plug_in_handle_message(): "
|
|
|
|
"received a temp proc run message (should not happen)");
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_TEMP_PROC_RETURN:
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_handle_proc_return (plug_in, msg->data);
|
2002-03-21 01:46:13 +08:00
|
|
|
gimp_main_loop_quit (plug_in->gimp);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_PROC_INSTALL:
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_handle_proc_install (plug_in, msg->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_PROC_UNINSTALL:
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_handle_proc_uninstall (plug_in, msg->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_EXTENSION_ACK:
|
2002-05-21 18:58:50 +08:00
|
|
|
plug_in_handle_extension_ack (plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2002-05-21 18:58:50 +08:00
|
|
|
|
2002-02-12 15:59:16 +08:00
|
|
|
case GP_HAS_INIT:
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_handle_has_init (plug_in);
|
2002-05-21 18:58:50 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_handle_quit (PlugIn *plug_in)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_handle_tile_req (PlugIn *plug_in,
|
|
|
|
GPTileReq *tile_req)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-17 20:29:38 +08:00
|
|
|
GPTileData tile_data;
|
|
|
|
GPTileData *tile_info;
|
|
|
|
WireMessage msg;
|
1997-11-25 06:05:25 +08:00
|
|
|
TileManager *tm;
|
2000-05-17 20:29:38 +08:00
|
|
|
Tile *tile;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (tile_req->drawable_ID == -1)
|
|
|
|
{
|
2002-05-21 18:58:50 +08:00
|
|
|
/* this branch communicates with libgimp/gimptile.c:gimp_tile_put() */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
tile_data.drawable_ID = -1;
|
2000-07-16 20:49:04 +08:00
|
|
|
tile_data.tile_num = 0;
|
|
|
|
tile_data.shadow = 0;
|
|
|
|
tile_data.bpp = 0;
|
|
|
|
tile_data.width = 0;
|
|
|
|
tile_data.height = 0;
|
|
|
|
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
|
|
|
|
tile_data.data = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-17 01:41:38 +08:00
|
|
|
if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-06-06 07:41:45 +08:00
|
|
|
g_warning ("plug_in_handle_tile_req: ERROR");
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-05-17 01:41:38 +08:00
|
|
|
if (! wire_read_msg (plug_in->my_read, &msg, plug_in))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-06-06 07:41:45 +08:00
|
|
|
g_warning ("plug_in_handle_tile_req: ERROR");
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msg.type != GP_TILE_DATA)
|
|
|
|
{
|
1999-06-06 07:41:45 +08:00
|
|
|
g_warning ("expected tile data and received: %d", msg.type);
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tile_info = msg.data;
|
|
|
|
|
|
|
|
if (tile_info->shadow)
|
2002-03-21 01:46:13 +08:00
|
|
|
tm = gimp_drawable_shadow ((GimpDrawable *)
|
|
|
|
gimp_item_get_by_ID (plug_in->gimp,
|
|
|
|
tile_info->drawable_ID));
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2002-03-21 01:46:13 +08:00
|
|
|
tm = gimp_drawable_data ((GimpDrawable *)
|
|
|
|
gimp_item_get_by_ID (plug_in->gimp,
|
|
|
|
tile_info->drawable_ID));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (!tm)
|
|
|
|
{
|
1999-06-06 07:41:45 +08:00
|
|
|
g_warning ("plug-in requested invalid drawable (killing)");
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-08-16 03:17:36 +08:00
|
|
|
tile = tile_manager_get (tm, tile_info->tile_num, TRUE, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
if (!tile)
|
|
|
|
{
|
1999-06-06 07:41:45 +08:00
|
|
|
g_warning ("plug-in requested invalid tile (killing)");
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tile_data.use_shm)
|
1998-08-12 01:35:34 +08:00
|
|
|
memcpy (tile_data_pointer (tile, 0, 0), shm_addr, tile_size (tile));
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
1998-08-12 01:35:34 +08:00
|
|
|
memcpy (tile_data_pointer (tile, 0, 0), tile_info->data, tile_size (tile));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-10 10:43:12 +08:00
|
|
|
tile_release (tile, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
wire_destroy (&msg);
|
2002-05-17 01:41:38 +08:00
|
|
|
if (! gp_tile_ack_write (plug_in->my_write, plug_in))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-06-06 07:41:45 +08:00
|
|
|
g_warning ("plug_in_handle_tile_req: ERROR");
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-05-21 18:58:50 +08:00
|
|
|
/* this branch communicates with libgimp/gimptile.c:gimp_tile_get() */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (tile_req->shadow)
|
2002-03-21 01:46:13 +08:00
|
|
|
tm = gimp_drawable_shadow ((GimpDrawable *)
|
|
|
|
gimp_item_get_by_ID (plug_in->gimp,
|
|
|
|
tile_req->drawable_ID));
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2002-03-21 01:46:13 +08:00
|
|
|
tm = gimp_drawable_data ((GimpDrawable *)
|
|
|
|
gimp_item_get_by_ID (plug_in->gimp,
|
|
|
|
tile_req->drawable_ID));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
if (! tm)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-06-06 07:41:45 +08:00
|
|
|
g_warning ("plug-in requested invalid drawable (killing)");
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-08-16 03:17:36 +08:00
|
|
|
tile = tile_manager_get (tm, tile_req->tile_num, TRUE, FALSE);
|
2002-03-21 01:46:13 +08:00
|
|
|
if (! tile)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-06-06 07:41:45 +08:00
|
|
|
g_warning ("plug-in requested invalid tile (killing)");
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tile_data.drawable_ID = tile_req->drawable_ID;
|
2000-05-17 20:29:38 +08:00
|
|
|
tile_data.tile_num = tile_req->tile_num;
|
|
|
|
tile_data.shadow = tile_req->shadow;
|
|
|
|
tile_data.bpp = tile_bpp (tile);
|
|
|
|
tile_data.width = tile_ewidth (tile);
|
|
|
|
tile_data.height = tile_eheight (tile);
|
|
|
|
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (tile_data.use_shm)
|
1998-08-12 01:35:34 +08:00
|
|
|
memcpy (shm_addr, tile_data_pointer (tile, 0, 0), tile_size (tile));
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
1998-08-12 01:35:34 +08:00
|
|
|
tile_data.data = tile_data_pointer (tile, 0, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-17 01:41:38 +08:00
|
|
|
if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-06-06 07:41:45 +08:00
|
|
|
g_message ("plug_in_handle_tile_req: ERROR");
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-07-10 10:43:12 +08:00
|
|
|
tile_release (tile, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-17 01:41:38 +08:00
|
|
|
if (! wire_read_msg (plug_in->my_read, &msg, plug_in))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-06-06 07:41:45 +08:00
|
|
|
g_message ("plug_in_handle_tile_req: ERROR");
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msg.type != GP_TILE_ACK)
|
|
|
|
{
|
1999-06-06 07:41:45 +08:00
|
|
|
g_warning ("expected tile ack and received: %d", msg.type);
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wire_destroy (&msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_handle_proc_run (PlugIn *plug_in,
|
2002-03-21 01:46:13 +08:00
|
|
|
GPProcRun *proc_run)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-17 20:29:38 +08:00
|
|
|
GPProcReturn proc_return;
|
|
|
|
ProcRecord *proc_rec;
|
|
|
|
Argument *args;
|
|
|
|
Argument *return_vals;
|
1997-11-25 06:05:25 +08:00
|
|
|
PlugInBlocked *blocked;
|
|
|
|
|
|
|
|
args = plug_in_params_to_args (proc_run->params, proc_run->nparams, FALSE);
|
2002-05-16 19:45:30 +08:00
|
|
|
proc_rec = procedural_db_lookup (plug_in->gimp, proc_run->name);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-06-28 21:28:37 +08:00
|
|
|
if (proc_rec)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-05-16 19:45:30 +08:00
|
|
|
return_vals = procedural_db_execute (plug_in->gimp, proc_run->name, args);
|
1999-06-28 21:28:37 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* if the name lookup failed, construct a
|
|
|
|
* dummy "executiuon error" return value --Michael
|
|
|
|
*/
|
|
|
|
return_vals = g_new (Argument, 1);
|
2002-03-21 01:46:13 +08:00
|
|
|
return_vals[0].arg_type = GIMP_PDB_STATUS;
|
2001-05-21 21:58:46 +08:00
|
|
|
return_vals[0].value.pdb_int = GIMP_PDB_EXECUTION_ERROR;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (return_vals)
|
|
|
|
{
|
|
|
|
proc_return.name = proc_run->name;
|
|
|
|
|
|
|
|
if (proc_rec)
|
|
|
|
{
|
|
|
|
proc_return.nparams = proc_rec->num_values + 1;
|
|
|
|
proc_return.params = plug_in_args_to_params (return_vals, proc_rec->num_values + 1, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
proc_return.nparams = 1;
|
|
|
|
proc_return.params = plug_in_args_to_params (return_vals, 1, FALSE);
|
|
|
|
}
|
|
|
|
|
2002-05-17 01:41:38 +08:00
|
|
|
if (! gp_proc_return_write (plug_in->my_write, &proc_return, plug_in))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-06-06 07:41:45 +08:00
|
|
|
g_warning ("plug_in_handle_proc_run: ERROR");
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_close (plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
plug_in_args_destroy (args, proc_run->nparams, FALSE);
|
|
|
|
plug_in_args_destroy (return_vals, (proc_rec ? (proc_rec->num_values + 1) : 1), TRUE);
|
|
|
|
plug_in_params_destroy (proc_return.params, proc_return.nparams, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
blocked = g_new0 (PlugInBlocked, 1);
|
|
|
|
|
2002-05-16 19:45:30 +08:00
|
|
|
blocked->plug_in = plug_in;
|
1997-11-25 06:05:25 +08:00
|
|
|
blocked->proc_name = g_strdup (proc_run->name);
|
2002-03-21 01:46:13 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
blocked_plug_ins = g_slist_prepend (blocked_plug_ins, blocked);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_handle_proc_return (PlugIn *plug_in,
|
2002-03-21 01:46:13 +08:00
|
|
|
GPProcReturn *proc_return)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
PlugInBlocked *blocked;
|
2000-07-16 20:49:04 +08:00
|
|
|
GSList *tmp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-17 01:41:38 +08:00
|
|
|
if (plug_in->recurse)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
current_return_vals = plug_in_params_to_args (proc_return->params,
|
|
|
|
proc_return->nparams,
|
|
|
|
TRUE);
|
|
|
|
current_return_nvals = proc_return->nparams;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-05-21 18:58:50 +08:00
|
|
|
for (tmp = blocked_plug_ins; tmp; tmp = g_slist_next (tmp))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
blocked = tmp->data;
|
|
|
|
|
2001-01-14 23:18:37 +08:00
|
|
|
if (blocked->proc_name && proc_return->name &&
|
|
|
|
strcmp (blocked->proc_name, proc_return->name) == 0)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
plug_in_push (blocked->plug_in);
|
2002-05-16 19:45:30 +08:00
|
|
|
|
|
|
|
if (! gp_proc_return_write (blocked->plug_in->my_write,
|
2002-05-17 01:41:38 +08:00
|
|
|
proc_return,
|
|
|
|
blocked->plug_in))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-06-06 07:41:45 +08:00
|
|
|
g_message ("plug_in_handle_proc_run: ERROR");
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_close (blocked->plug_in, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
2002-05-16 19:45:30 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
plug_in_pop ();
|
|
|
|
|
|
|
|
blocked_plug_ins = g_slist_remove (blocked_plug_ins, blocked);
|
|
|
|
g_free (blocked->proc_name);
|
|
|
|
g_free (blocked);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_handle_proc_install (PlugIn *plug_in,
|
2002-03-21 01:46:13 +08:00
|
|
|
GPProcInstall *proc_install)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-12-11 00:38:16 +08:00
|
|
|
PlugInDef *plug_in_def = NULL;
|
2003-01-20 20:17:32 +08:00
|
|
|
PlugInProcDef *proc_def = NULL;
|
|
|
|
ProcRecord *proc = NULL;
|
|
|
|
GSList *tmp = NULL;
|
|
|
|
gchar *prog = NULL;
|
|
|
|
gboolean valid_utf8 = FALSE;
|
2002-12-11 00:38:16 +08:00
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-07-16 20:49:04 +08:00
|
|
|
/* Argument checking
|
1997-11-25 06:05:25 +08:00
|
|
|
* --only sanity check arguments when the procedure requests a menu path
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (proc_install->menu_path)
|
|
|
|
{
|
|
|
|
if (strncmp (proc_install->menu_path, "<Toolbox>", 9) == 0)
|
|
|
|
{
|
|
|
|
if ((proc_install->nparams < 1) ||
|
2001-05-21 21:58:46 +08:00
|
|
|
(proc_install->params[0].type != GIMP_PDB_INT32))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-17 20:29:38 +08:00
|
|
|
g_message ("Plug-In \"%s\"\n(%s)\n"
|
|
|
|
"attempted to install procedure \"%s\"\n"
|
|
|
|
"which does not take the standard Plug-In args.",
|
2002-05-16 19:45:30 +08:00
|
|
|
g_path_get_basename (plug_in->args[0]),
|
|
|
|
plug_in->args[0],
|
2000-05-17 20:29:38 +08:00
|
|
|
proc_install->name);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strncmp (proc_install->menu_path, "<Image>", 7) == 0)
|
|
|
|
{
|
|
|
|
if ((proc_install->nparams < 3) ||
|
2001-05-21 21:58:46 +08:00
|
|
|
(proc_install->params[0].type != GIMP_PDB_INT32) ||
|
|
|
|
(proc_install->params[1].type != GIMP_PDB_IMAGE) ||
|
|
|
|
(proc_install->params[2].type != GIMP_PDB_DRAWABLE))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-17 20:29:38 +08:00
|
|
|
g_message ("Plug-In \"%s\"\n(%s)\n"
|
|
|
|
"attempted to install procedure \"%s\"\n"
|
|
|
|
"which does not take the standard Plug-In args.",
|
2002-05-16 19:45:30 +08:00
|
|
|
g_path_get_basename (plug_in->args[0]),
|
|
|
|
plug_in->args[0],
|
2000-05-17 20:29:38 +08:00
|
|
|
proc_install->name);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strncmp (proc_install->menu_path, "<Load>", 6) == 0)
|
|
|
|
{
|
|
|
|
if ((proc_install->nparams < 3) ||
|
2001-05-21 21:58:46 +08:00
|
|
|
(proc_install->params[0].type != GIMP_PDB_INT32) ||
|
|
|
|
(proc_install->params[1].type != GIMP_PDB_STRING) ||
|
|
|
|
(proc_install->params[2].type != GIMP_PDB_STRING))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-17 20:29:38 +08:00
|
|
|
g_message ("Plug-In \"%s\"\n(%s)\n"
|
|
|
|
"attempted to install procedure \"%s\"\n"
|
|
|
|
"which does not take the standard Plug-In args.",
|
2002-05-16 19:45:30 +08:00
|
|
|
g_path_get_basename (plug_in->args[0]),
|
|
|
|
plug_in->args[0],
|
2000-05-17 20:29:38 +08:00
|
|
|
proc_install->name);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strncmp (proc_install->menu_path, "<Save>", 6) == 0)
|
|
|
|
{
|
|
|
|
if ((proc_install->nparams < 5) ||
|
2001-09-03 08:26:06 +08:00
|
|
|
(proc_install->params[0].type != GIMP_PDB_INT32) ||
|
|
|
|
(proc_install->params[1].type != GIMP_PDB_IMAGE) ||
|
2001-05-21 21:58:46 +08:00
|
|
|
(proc_install->params[2].type != GIMP_PDB_DRAWABLE) ||
|
2001-09-03 08:26:06 +08:00
|
|
|
(proc_install->params[3].type != GIMP_PDB_STRING) ||
|
2001-05-21 21:58:46 +08:00
|
|
|
(proc_install->params[4].type != GIMP_PDB_STRING))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-17 20:29:38 +08:00
|
|
|
g_message ("Plug-In \"%s\"\n(%s)\n"
|
|
|
|
"attempted to install procedure \"%s\"\n"
|
|
|
|
"which does not take the standard Plug-In args.",
|
2002-05-16 19:45:30 +08:00
|
|
|
g_path_get_basename (plug_in->args[0]),
|
|
|
|
plug_in->args[0],
|
2000-05-17 20:29:38 +08:00
|
|
|
proc_install->name);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-05-17 20:29:38 +08:00
|
|
|
g_message ("Plug-In \"%s\"\n(%s)\n"
|
|
|
|
"attempted to install procedure \"%s\"\n"
|
|
|
|
"in an invalid menu location.\n"
|
|
|
|
"Use either \"<Toolbox>\", \"<Image>\", "
|
1999-09-23 19:49:16 +08:00
|
|
|
"\"<Load>\", or \"<Save>\".",
|
2002-05-16 19:45:30 +08:00
|
|
|
g_path_get_basename (plug_in->args[0]),
|
|
|
|
plug_in->args[0],
|
2000-05-17 20:29:38 +08:00
|
|
|
proc_install->name);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-07-16 20:49:04 +08:00
|
|
|
/* Sanity check for array arguments */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (i = 1; i < proc_install->nparams; i++)
|
|
|
|
{
|
2001-05-21 21:58:46 +08:00
|
|
|
if ((proc_install->params[i].type == GIMP_PDB_INT32ARRAY ||
|
2001-09-03 08:26:06 +08:00
|
|
|
proc_install->params[i].type == GIMP_PDB_INT8ARRAY ||
|
2001-05-21 21:58:46 +08:00
|
|
|
proc_install->params[i].type == GIMP_PDB_FLOATARRAY ||
|
2001-09-03 08:26:06 +08:00
|
|
|
proc_install->params[i].type == GIMP_PDB_STRINGARRAY)
|
|
|
|
&&
|
2001-05-21 21:58:46 +08:00
|
|
|
proc_install->params[i-1].type != GIMP_PDB_INT32)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-17 20:29:38 +08:00
|
|
|
g_message ("Plug-In \"%s\"\n(%s)\n"
|
|
|
|
"attempted to install procedure \"%s\"\n"
|
|
|
|
"which fails to comply with the array parameter\n"
|
1999-09-23 19:49:16 +08:00
|
|
|
"passing standard. Argument %d is noncompliant.",
|
2002-05-16 19:45:30 +08:00
|
|
|
g_path_get_basename (plug_in->args[0]),
|
|
|
|
plug_in->args[0],
|
2000-05-17 20:29:38 +08:00
|
|
|
proc_install->name, i);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2001-09-03 08:26:06 +08:00
|
|
|
|
|
|
|
/* Sanity check strings for UTF-8 validity */
|
|
|
|
|
|
|
|
if ((proc_install->menu_path == NULL ||
|
|
|
|
g_utf8_validate (proc_install->menu_path, -1, NULL)) &&
|
|
|
|
(g_utf8_validate (proc_install->name, -1, NULL)) &&
|
|
|
|
(proc_install->blurb == NULL ||
|
|
|
|
g_utf8_validate (proc_install->blurb, -1, NULL)) &&
|
|
|
|
(proc_install->help == NULL ||
|
|
|
|
g_utf8_validate (proc_install->help, -1, NULL)) &&
|
|
|
|
(proc_install->author == NULL ||
|
|
|
|
g_utf8_validate (proc_install->author, -1, NULL)) &&
|
|
|
|
(proc_install->copyright == NULL ||
|
|
|
|
g_utf8_validate (proc_install->copyright, -1, NULL)) &&
|
|
|
|
(proc_install->date == NULL ||
|
|
|
|
g_utf8_validate (proc_install->date, -1, NULL)))
|
|
|
|
{
|
2003-01-20 20:17:32 +08:00
|
|
|
valid_utf8 = TRUE;
|
2001-09-03 08:26:06 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
for (i = 0; i < proc_install->nparams && valid_utf8; i++)
|
2001-09-03 08:26:06 +08:00
|
|
|
{
|
|
|
|
if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) &&
|
|
|
|
(proc_install->params[i].description == NULL ||
|
|
|
|
g_utf8_validate (proc_install->params[i].description, -1, NULL))))
|
2003-01-20 20:17:32 +08:00
|
|
|
valid_utf8 = FALSE;
|
2001-09-03 08:26:06 +08:00
|
|
|
}
|
2003-01-20 20:17:32 +08:00
|
|
|
for (i = 0; i < proc_install->nreturn_vals && valid_utf8; i++)
|
2001-09-03 08:26:06 +08:00
|
|
|
{
|
|
|
|
if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) &&
|
|
|
|
(proc_install->return_vals[i].description == NULL ||
|
|
|
|
g_utf8_validate (proc_install->return_vals[i].description, -1, NULL))))
|
2003-01-20 20:17:32 +08:00
|
|
|
valid_utf8 = FALSE;
|
2001-09-03 08:26:06 +08:00
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-20 20:17:32 +08:00
|
|
|
if (! valid_utf8)
|
2001-09-03 08:26:06 +08:00
|
|
|
{
|
|
|
|
g_message ("Plug-In \"%s\"\n(%s)\n"
|
|
|
|
"attempted to install a procedure with invalid UTF-8 strings.\n",
|
2002-05-16 19:45:30 +08:00
|
|
|
g_path_get_basename (plug_in->args[0]),
|
|
|
|
plug_in->args[0]);
|
2001-09-03 08:26:06 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-07-16 20:49:04 +08:00
|
|
|
/* Initialization */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (proc_install->type)
|
|
|
|
{
|
2001-05-21 21:58:46 +08:00
|
|
|
case GIMP_PLUGIN:
|
|
|
|
case GIMP_EXTENSION:
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_in_def = plug_in->plug_in_def;
|
|
|
|
prog = plug_in_def->prog;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
tmp = plug_in_def->proc_defs;
|
|
|
|
break;
|
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
case GIMP_TEMPORARY:
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_in_def = NULL;
|
|
|
|
prog = "none";
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-16 19:45:30 +08:00
|
|
|
tmp = plug_in->temp_proc_defs;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (tmp)
|
|
|
|
{
|
|
|
|
proc_def = tmp->data;
|
|
|
|
tmp = tmp->next;
|
|
|
|
|
|
|
|
if (strcmp (proc_def->db_info.name, proc_install->name) == 0)
|
|
|
|
{
|
2001-05-21 21:58:46 +08:00
|
|
|
if (proc_install->type == GIMP_TEMPORARY)
|
2003-01-18 02:07:37 +08:00
|
|
|
{
|
|
|
|
plug_in->temp_proc_defs = g_slist_remove (plug_in->temp_proc_defs,
|
|
|
|
proc_def);
|
|
|
|
|
|
|
|
plug_ins_temp_proc_def_remove (plug_in->gimp, proc_def);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2003-01-18 02:07:37 +08:00
|
|
|
{
|
|
|
|
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
|
|
|
|
proc_def);
|
|
|
|
|
|
|
|
plug_in_proc_def_free (proc_def);
|
|
|
|
}
|
2000-02-25 00:11:26 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-18 02:07:37 +08:00
|
|
|
proc_def = plug_in_proc_def_new ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
proc_def->prog = g_strdup (prog);
|
|
|
|
|
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
|
|
|
proc_def->menu_path = g_strdup (proc_install->menu_path);
|
|
|
|
proc_def->accelerator = NULL;
|
|
|
|
proc_def->extensions = NULL;
|
|
|
|
proc_def->prefixes = NULL;
|
|
|
|
proc_def->magics = NULL;
|
|
|
|
proc_def->image_types = g_strdup (proc_install->image_types);
|
2002-03-21 01:46:13 +08:00
|
|
|
proc_def->image_types_val = plug_ins_image_types_parse (proc_def->image_types);
|
1999-01-31 09:08:26 +08:00
|
|
|
/* Install temp one use todays time */
|
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
|
|
|
proc_def->mtime = time (NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
proc = &proc_def->db_info;
|
|
|
|
|
2000-07-16 20:49:04 +08:00
|
|
|
/* The procedural database procedure */
|
|
|
|
|
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
|
|
|
proc->name = g_strdup (proc_install->name);
|
|
|
|
proc->blurb = g_strdup (proc_install->blurb);
|
|
|
|
proc->help = g_strdup (proc_install->help);
|
|
|
|
proc->author = g_strdup (proc_install->author);
|
1997-11-25 06:05:25 +08:00
|
|
|
proc->copyright = g_strdup (proc_install->copyright);
|
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
|
|
|
proc->date = g_strdup (proc_install->date);
|
1997-11-25 06:05:25 +08:00
|
|
|
proc->proc_type = proc_install->type;
|
|
|
|
|
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
|
|
|
proc->num_args = proc_install->nparams;
|
1997-11-25 06:05:25 +08:00
|
|
|
proc->num_values = proc_install->nreturn_vals;
|
|
|
|
|
2003-01-18 02:07:37 +08:00
|
|
|
proc->args = g_new0 (ProcArg, proc->num_args);
|
|
|
|
proc->values = g_new0 (ProcArg, proc->num_values);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (i = 0; i < proc->num_args; i++)
|
|
|
|
{
|
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
|
|
|
proc->args[i].arg_type = proc_install->params[i].type;
|
|
|
|
proc->args[i].name = g_strdup (proc_install->params[i].name);
|
1997-11-25 06:05:25 +08:00
|
|
|
proc->args[i].description = g_strdup (proc_install->params[i].description);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < proc->num_values; i++)
|
|
|
|
{
|
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
|
|
|
proc->values[i].arg_type = proc_install->return_vals[i].type;
|
|
|
|
proc->values[i].name = g_strdup (proc_install->return_vals[i].name);
|
1997-11-25 06:05:25 +08:00
|
|
|
proc->values[i].description = g_strdup (proc_install->return_vals[i].description);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (proc_install->type)
|
|
|
|
{
|
2001-05-21 21:58:46 +08:00
|
|
|
case GIMP_PLUGIN:
|
|
|
|
case GIMP_EXTENSION:
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_in_def->proc_defs = g_slist_prepend (plug_in_def->proc_defs,
|
|
|
|
proc_def);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
case GIMP_TEMPORARY:
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_in->temp_proc_defs = g_slist_prepend (plug_in->temp_proc_defs,
|
|
|
|
proc_def);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-16 19:45:30 +08:00
|
|
|
proc->exec_method.temporary.plug_in = plug_in;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_ins_temp_proc_def_add (plug_in->gimp, proc_def,
|
|
|
|
plug_ins_locale_domain (plug_in->gimp,
|
|
|
|
plug_in->args[0],
|
|
|
|
NULL),
|
|
|
|
plug_ins_help_path (plug_in->gimp,
|
|
|
|
plug_in->args[0]));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_handle_proc_uninstall (PlugIn *plug_in,
|
2002-03-21 01:46:13 +08:00
|
|
|
GPProcUninstall *proc_uninstall)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-01-18 02:07:37 +08:00
|
|
|
GSList *tmp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-21 18:58:50 +08:00
|
|
|
for (tmp = plug_in->temp_proc_defs; tmp; tmp = g_slist_next (tmp))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-01-18 02:07:37 +08:00
|
|
|
PlugInProcDef *proc_def;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
proc_def = tmp->data;
|
|
|
|
|
2002-05-21 18:58:50 +08:00
|
|
|
if (! strcmp (proc_def->db_info.name, proc_uninstall->name))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in->temp_proc_defs = g_slist_remove (plug_in->temp_proc_defs,
|
|
|
|
proc_def);
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_ins_temp_proc_def_remove (plug_in->gimp, proc_def);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-03-21 01:46:13 +08:00
|
|
|
|
2002-05-21 18:58:50 +08:00
|
|
|
static void
|
|
|
|
plug_in_handle_extension_ack (PlugIn *plug_in)
|
|
|
|
{
|
|
|
|
gimp_main_loop_quit (plug_in->gimp);
|
|
|
|
}
|
|
|
|
|
2002-02-12 15:59:16 +08:00
|
|
|
static void
|
2002-05-16 19:45:30 +08:00
|
|
|
plug_in_handle_has_init (PlugIn *plug_in)
|
2002-02-12 15:59:16 +08:00
|
|
|
{
|
2003-01-18 02:07:37 +08:00
|
|
|
if (plug_in->query)
|
|
|
|
plug_in_def_set_has_init (plug_in->plug_in_def, TRUE);
|
2002-02-12 15:59:16 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-25 00:11:26 +08:00
|
|
|
static gboolean
|
1999-03-07 20:56:03 +08:00
|
|
|
plug_in_write (GIOChannel *channel,
|
|
|
|
guint8 *buf,
|
2002-05-17 01:41:38 +08:00
|
|
|
gulong count,
|
|
|
|
gpointer user_data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-05-17 01:41:38 +08:00
|
|
|
PlugIn *plug_in;
|
|
|
|
gulong bytes;
|
|
|
|
|
|
|
|
plug_in = (PlugIn *) user_data;
|
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)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-05-17 01:41:38 +08:00
|
|
|
bytes = WRITE_BUFFER_SIZE - plug_in->write_buffer_index;
|
|
|
|
memcpy (&plug_in->write_buffer[plug_in->write_buffer_index],
|
|
|
|
buf, bytes);
|
|
|
|
plug_in->write_buffer_index += bytes;
|
|
|
|
if (! wire_flush (channel, plug_in))
|
1997-11-25 06:05:25 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bytes = count;
|
2002-05-17 01:41:38 +08:00
|
|
|
memcpy (&plug_in->write_buffer[plug_in->write_buffer_index],
|
|
|
|
buf, bytes);
|
|
|
|
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
|
|
|
{
|
2002-05-17 01:41:38 +08:00
|
|
|
PlugIn *plug_in;
|
2001-08-30 01:48:28 +08:00
|
|
|
GIOStatus status;
|
2001-08-30 09:09:58 +08:00
|
|
|
GError *error = NULL;
|
2001-08-30 01:48:28 +08:00
|
|
|
gint count;
|
2003-01-06 04:38:21 +08:00
|
|
|
gsize bytes;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-17 01:41:38 +08:00
|
|
|
plug_in = (PlugIn *) user_data;
|
|
|
|
|
|
|
|
if (plug_in->write_buffer_index > 0)
|
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
|
|
|
{
|
2001-08-30 01:48:28 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
bytes = 0;
|
|
|
|
status = g_io_channel_write_chars (channel,
|
2002-05-17 01:41:38 +08:00
|
|
|
&plug_in->write_buffer[count],
|
|
|
|
(plug_in->write_buffer_index - count),
|
2001-08-30 01:48:28 +08:00
|
|
|
&bytes,
|
|
|
|
&error);
|
|
|
|
}
|
|
|
|
while (status == G_IO_STATUS_AGAIN);
|
|
|
|
|
|
|
|
if (status != G_IO_STATUS_NORMAL)
|
2001-08-30 09:09:58 +08:00
|
|
|
{
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
g_warning ("%s: plug_in_flush(): error: %s",
|
|
|
|
g_get_prgname (), error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("%s: plug_in_flush(): error",
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
plug_in_push (PlugIn *plug_in)
|
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
g_return_if_fail (plug_in != NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
current_plug_in = plug_in;
|
|
|
|
|
|
|
|
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-05-04 03:22:58 +08:00
|
|
|
plug_in_pop (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GSList *tmp;
|
|
|
|
|
|
|
|
if (current_plug_in)
|
|
|
|
{
|
|
|
|
tmp = plug_in_stack;
|
|
|
|
plug_in_stack = plug_in_stack->next;
|
|
|
|
tmp->next = NULL;
|
|
|
|
g_slist_free (tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plug_in_stack)
|
|
|
|
{
|
2002-05-17 01:41:38 +08:00
|
|
|
current_plug_in = plug_in_stack->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-05-17 01:41:38 +08:00
|
|
|
current_plug_in = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
static Argument *
|
|
|
|
plug_in_temp_run (ProcRecord *proc_rec,
|
|
|
|
Argument *args,
|
|
|
|
gint argc)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
Argument *return_vals;
|
|
|
|
PlugIn *plug_in;
|
|
|
|
GPProcRun proc_run;
|
|
|
|
gint old_recurse;
|
2002-02-12 10:41:01 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
return_vals = NULL;
|
2002-02-12 10:41:01 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in = (PlugIn *) proc_rec->exec_method.temporary.plug_in;
|
2002-02-12 10:41:01 +08:00
|
|
|
|
|
|
|
if (plug_in)
|
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
if (plug_in->busy)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
return_vals = procedural_db_return_args (proc_rec, FALSE);
|
|
|
|
goto done;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in->busy = TRUE;
|
|
|
|
plug_in_push (plug_in);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
proc_run.name = proc_rec->name;
|
|
|
|
proc_run.nparams = argc;
|
|
|
|
proc_run.params = plug_in_args_to_params (args, argc, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-17 01:41:38 +08:00
|
|
|
if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run, plug_in) ||
|
|
|
|
! wire_flush (plug_in->my_write, plug_in))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-03-21 01:46:13 +08:00
|
|
|
return_vals = procedural_db_return_args (proc_rec, FALSE);
|
|
|
|
goto done;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_pop ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
|
2001-08-30 01:48:28 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
old_recurse = plug_in->recurse;
|
|
|
|
plug_in->recurse = TRUE;
|
2001-08-30 01:48:28 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
/* gtk_main (); */
|
|
|
|
|
|
|
|
/* return_vals = plug_in_get_current_return_vals (proc_rec); */
|
|
|
|
return_vals = procedural_db_return_args (proc_rec, TRUE);
|
|
|
|
plug_in->recurse = old_recurse;
|
|
|
|
plug_in->busy = 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
|
|
|
}
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
done:
|
1997-11-25 06:05:25 +08:00
|
|
|
return return_vals;
|
|
|
|
}
|