Sven Neumann <sven@gimp.org>

2000-07-16  Michael Natterer  <mitch@gimp.org>
	    Sven Neumann      <sven@gimp.org>

	* AUTHORS
	* gimp.1.in
	* app/about_dialog.c: removed two accidentially added non-authors.

	* app/errors.[ch]
	* app/main.c: added a new command line option
	"--enable-stack-trace" which can be one of {never|query|always}.

	* app/plug_in.c
	* libgimp/gimp.c: pass the stack trace mode as an argv[] element to
	plug-ins. Cleaned up the plug-ins' argv[] (removed unused TILE_WIDTH
	and TILE_HEIGHT arguments, always pass 6 arguments to make the code
	simpler).

	* libgimp/gimpenums.h
	* plug-ins/script-fu/script-fu-constants.c
	* tools/pdbgen/Makefile.am
	* tools/pdbgen/enums.pl: export the app's STACK_TRACE_MODE enum.

	* plug-ins/common/plugindetails.c: made the titles of the tree view
	unclickable, cleanups.
This commit is contained in:
Michael Natterer 2000-07-16 12:49:04 +00:00 committed by Michael Natterer
parent e0e4101d6d
commit df9eeff6ac
38 changed files with 5220 additions and 4675 deletions

View File

@ -25,7 +25,6 @@ Tom Bech
Marc Bless Marc Bless
Edward Blevins Edward Blevins
Reagan Blundell Reagan Blundell
Andreas Bogk
Xavier Bouchoux Xavier Bouchoux
Roberto Boyd Roberto Boyd
Stanislav Brabec Stanislav Brabec
@ -85,7 +84,6 @@ Andrew Kieschnick
Peter Kirchgessner Peter Kirchgessner
Philipp Klaus Philipp Klaus
David Koblas David Koblas
Vincent Kolwitz
Tuomas Kuosmanen Tuomas Kuosmanen
Karin Kylander Karin Kylander
Olof S Kylander Olof S Kylander
@ -173,4 +171,4 @@ Kris Wehner
Nigel Wetten Nigel Wetten
Calvin Williamson Calvin Williamson
Matthew Wilson Matthew Wilson
Shirasaki Yasuhiro Shirasaki Yasuhiro

View File

@ -1,3 +1,28 @@
2000-07-16 Michael Natterer <mitch@gimp.org>
Sven Neumann <sven@gimp.org>
* AUTHORS
* gimp.1.in
* app/about_dialog.c: removed two accidentially added non-authors.
* app/errors.[ch]
* app/main.c: added a new command line option
"--enable-stack-trace" which can be one of {never|query|always}.
* app/plug_in.c
* libgimp/gimp.c: pass the stack trace mode as an argv[] element to
plug-ins. Cleaned up the plug-ins' argv[] (removed unused TILE_WIDTH
and TILE_HEIGHT arguments, always pass 6 arguments to make the code
simpler).
* libgimp/gimpenums.h
* plug-ins/script-fu/script-fu-constants.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/enums.pl: export the app's STACK_TRACE_MODE enum.
* plug-ins/common/plugindetails.c: made the titles of the tree view
unclickable, cleanups.
Sat Jul 15 18:32:04 CEST 2000 Marc Lehmann <pcg@goof.com> Sat Jul 15 18:32:04 CEST 2000 Marc Lehmann <pcg@goof.com>
* plug-ins/common/plasma.c: applied noninteractive fix by David * plug-ins/common/plasma.c: applied noninteractive fix by David

View File

@ -15,6 +15,9 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -22,26 +25,39 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "appenv.h"
#include "about_dialog.h"
#include "gimpdnd.h"
#include "gimphelp.h" #include "gimphelp.h"
#include "libgimp/gimpfeatures.h" #include "libgimp/gimpfeatures.h"
#include "config.h"
#include "libgimp/gimpenv.h" #include "libgimp/gimpenv.h"
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h" #include "libgimp/gimpmath.h"
#include "about_dialog.h" #include "pixmaps/wilber2.xpm"
#define ANIMATION_STEPS 16 #define ANIMATION_STEPS 16
#define ANIMATION_SIZE 2 #define ANIMATION_SIZE 2
static gint about_dialog_load_logo (GtkWidget *window); static gboolean about_dialog_load_logo (GtkWidget *window);
static void about_dialog_destroy (void); static void about_dialog_destroy (GtkObject *object,
static void about_dialog_unmap (void); gpointer data);
static gint about_dialog_logo_expose (GtkWidget *widget, GdkEventExpose *event); static void about_dialog_unmap (GtkWidget *widget,
static gint about_dialog_button (GtkWidget *widget, GdkEventButton *event); GdkEvent *event,
static gint about_dialog_timer (gpointer data); gpointer data);
static gint about_dialog_logo_expose (GtkWidget *widget,
GdkEventExpose *event,
gpointer data);
static gint about_dialog_button (GtkWidget *widget,
GdkEventButton *event,
gpointer data);
static void about_dialog_tool_drop (GtkWidget *widget,
ToolType tool,
gpointer data);
static gint about_dialog_timer (gpointer data);
static GtkWidget *about_dialog = NULL; static GtkWidget *about_dialog = NULL;
@ -74,7 +90,6 @@ static gchar *scroll_text[] =
"Marc Bless", "Marc Bless",
"Edward Blevins", "Edward Blevins",
"Reagan Blundell", "Reagan Blundell",
"Andreas Bogk",
"Xavier Bouchoux", "Xavier Bouchoux",
"Roberto Boyd", "Roberto Boyd",
"Stanislav Brabec", "Stanislav Brabec",
@ -133,7 +148,6 @@ static gchar *scroll_text[] =
"Peter Kirchgessner", "Peter Kirchgessner",
"Philipp Klaus", "Philipp Klaus",
"David Koblas", "David Koblas",
"Vincent Kolwitz",
"Tuomas Kuosmanen", "Tuomas Kuosmanen",
"Karin Kylander", "Karin Kylander",
"Olof S Kylander", "Olof S Kylander",
@ -230,24 +244,32 @@ static gchar *scroll_text[] =
#endif #endif
}; };
static gint nscroll_texts = sizeof (scroll_text) / sizeof (scroll_text[0]); static gint nscroll_texts = sizeof (scroll_text) / sizeof (scroll_text[0]);
static gint scroll_text_widths[ sizeof(scroll_text) / sizeof(scroll_text[0]) ]; static gint scroll_text_widths[sizeof (scroll_text) / sizeof (scroll_text[0])];
static gint cur_scroll_text = 0; static gint cur_scroll_text = 0;
static gint cur_scroll_index; static gint cur_scroll_index = 0;
static gint shuffle_array[ sizeof(scroll_text) / sizeof(scroll_text[0]) ]; static gint shuffle_array[sizeof (scroll_text) / sizeof (scroll_text[0])];
/* dnd stuff */
static GtkTargetEntry tool_target_table[] =
{
GIMP_TARGET_TOOL
};
static guint n_tool_targets = (sizeof (tool_target_table) /
sizeof (tool_target_table[0]));
void void
about_dialog_create () about_dialog_create (void)
{ {
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *aboutframe; GtkWidget *aboutframe;
GtkWidget *label; GtkWidget *label;
GtkWidget *alignment; GtkWidget *alignment;
GtkStyle *style; GtkStyle *style;
GdkFont *font; GdkFont *font;
gint max_width; gint max_width;
gint i; gint i;
gchar *label_text; gchar *label_text;
if (!about_dialog) if (!about_dialog)
{ {
@ -270,6 +292,14 @@ about_dialog_create ()
GTK_SIGNAL_FUNC (about_dialog_button), GTK_SIGNAL_FUNC (about_dialog_button),
NULL); NULL);
/* dnd stuff */
gtk_drag_dest_set (about_dialog,
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
tool_target_table, n_tool_targets,
GDK_ACTION_COPY);
gimp_dnd_tool_dest_set (about_dialog, about_dialog_tool_drop, NULL);
gtk_widget_set_events (about_dialog, GDK_BUTTON_PRESS_MASK); gtk_widget_set_events (about_dialog, GDK_BUTTON_PRESS_MASK);
if (!about_dialog_load_logo (about_dialog)) if (!about_dialog_load_logo (about_dialog))
@ -398,33 +428,37 @@ about_dialog_create ()
} }
static gint static gboolean
about_dialog_load_logo (GtkWidget *window) about_dialog_load_logo (GtkWidget *window)
{ {
GtkWidget *preview; GtkWidget *preview;
GdkGC *gc; GdkGC *gc;
gchar buf[1024]; gchar buf[1024];
guchar *pixelrow; gchar *filename;
FILE *fp; guchar *pixelrow;
gint count; FILE *fp;
gint i, j, k; gint count;
gint i, j, k;
if (logo_pixmap) if (logo_pixmap)
return TRUE; return TRUE;
g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp_logo.ppm", filename = g_strconcat (gimp_data_directory (),
gimp_data_directory ()); G_DIR_SEPARATOR_S,
"gimp_logo.ppm",
NULL);
fp = fopen (filename, "rb");
g_free (filename);
fp = fopen (buf, "rb");
if (!fp) if (!fp)
return 0; return FALSE;
fgets (buf, 1024, fp); fgets (buf, 1024, fp);
if (strncmp (buf, "P6", 2) != 0) if (strncmp (buf, "P6", 2) != 0)
{ {
fclose (fp); fclose (fp);
return 0; return FALSE;
} }
fgets (buf, 1024, fp); fgets (buf, 1024, fp);
@ -435,7 +469,7 @@ about_dialog_load_logo (GtkWidget *window)
if (strncmp (buf, "255", 3) != 0) if (strncmp (buf, "255", 3) != 0)
{ {
fclose (fp); fclose (fp);
return 0; return FALSE;
} }
preview = gtk_preview_new (GTK_PREVIEW_COLOR); preview = gtk_preview_new (GTK_PREVIEW_COLOR);
@ -444,13 +478,13 @@ about_dialog_load_logo (GtkWidget *window)
for (i = 0; i < logo_height; i++) for (i = 0; i < logo_height; i++)
{ {
count = fread (pixelrow, sizeof (unsigned char), logo_width * 3, fp); count = fread (pixelrow, sizeof (guchar), logo_width * 3, fp);
if (count != (logo_width * 3)) if (count != (logo_width * 3))
{ {
gtk_widget_destroy (preview); gtk_widget_destroy (preview);
g_free (pixelrow); g_free (pixelrow);
fclose (fp); fclose (fp);
return 0; return FALSE;
} }
gtk_preview_draw_row (GTK_PREVIEW (preview), pixelrow, 0, i, logo_width); gtk_preview_draw_row (GTK_PREVIEW (preview), pixelrow, 0, i, logo_width);
@ -487,14 +521,17 @@ about_dialog_load_logo (GtkWidget *window)
} }
static void static void
about_dialog_destroy (void) about_dialog_destroy (GtkObject *object,
gpointer data)
{ {
about_dialog = NULL; about_dialog = NULL;
about_dialog_unmap (); about_dialog_unmap (NULL, NULL, NULL);
} }
static void static void
about_dialog_unmap (void) about_dialog_unmap (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{ {
if (timer) if (timer)
{ {
@ -505,7 +542,8 @@ about_dialog_unmap (void)
static gint static gint
about_dialog_logo_expose (GtkWidget *widget, about_dialog_logo_expose (GtkWidget *widget,
GdkEventExpose *event) GdkEventExpose *event,
gpointer data)
{ {
if (do_animation) if (do_animation)
{ {
@ -537,7 +575,8 @@ about_dialog_logo_expose (GtkWidget *widget,
static gint static gint
about_dialog_button (GtkWidget *widget, about_dialog_button (GtkWidget *widget,
GdkEventButton *event) GdkEventButton *event,
gpointer data)
{ {
if (timer) if (timer)
gtk_timeout_remove (timer); gtk_timeout_remove (timer);
@ -549,6 +588,70 @@ about_dialog_button (GtkWidget *widget,
return FALSE; return FALSE;
} }
static void
about_dialog_tool_drop (GtkWidget *widget,
ToolType tool,
gpointer data)
{
GdkPixmap *pixmap = NULL;
GdkBitmap *mask = NULL;
gint width = 0;
gint height = 0;
if (do_animation)
return;
if (timer)
gtk_timeout_remove (timer);
timer = gtk_timeout_add (75, about_dialog_timer, NULL);
frame = 0;
do_animation = TRUE;
do_scrolling = FALSE;
gdk_draw_rectangle (logo_pixmap,
logo_area->style->white_gc,
TRUE,
0, 0,
logo_area->allocation.width,
logo_area->allocation.height);
pixmap =
gdk_pixmap_create_from_xpm_d (widget->window,
&mask,
NULL,
wilber2_xpm);
gdk_window_get_size (pixmap, &width, &height);
if (logo_area->allocation.width >= width &&
logo_area->allocation.height >= height)
{
gint x, y;
x = (logo_area->allocation.width - width) / 2;
y = (logo_area->allocation.height - height) / 2;
gdk_gc_set_clip_mask (logo_area->style->black_gc, mask);
gdk_gc_set_clip_origin (logo_area->style->black_gc, x, y);
gdk_draw_pixmap (logo_pixmap,
logo_area->style->black_gc,
pixmap, 0, 0,
x, y,
width, height);
gdk_gc_set_clip_mask (logo_area->style->black_gc, NULL);
gdk_gc_set_clip_origin (logo_area->style->black_gc, 0, 0);
}
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
double_speed = TRUE;
}
static gint static gint
about_dialog_timer (gpointer data) about_dialog_timer (gpointer data)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,9 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -22,26 +25,39 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "appenv.h"
#include "about_dialog.h"
#include "gimpdnd.h"
#include "gimphelp.h" #include "gimphelp.h"
#include "libgimp/gimpfeatures.h" #include "libgimp/gimpfeatures.h"
#include "config.h"
#include "libgimp/gimpenv.h" #include "libgimp/gimpenv.h"
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h" #include "libgimp/gimpmath.h"
#include "about_dialog.h" #include "pixmaps/wilber2.xpm"
#define ANIMATION_STEPS 16 #define ANIMATION_STEPS 16
#define ANIMATION_SIZE 2 #define ANIMATION_SIZE 2
static gint about_dialog_load_logo (GtkWidget *window); static gboolean about_dialog_load_logo (GtkWidget *window);
static void about_dialog_destroy (void); static void about_dialog_destroy (GtkObject *object,
static void about_dialog_unmap (void); gpointer data);
static gint about_dialog_logo_expose (GtkWidget *widget, GdkEventExpose *event); static void about_dialog_unmap (GtkWidget *widget,
static gint about_dialog_button (GtkWidget *widget, GdkEventButton *event); GdkEvent *event,
static gint about_dialog_timer (gpointer data); gpointer data);
static gint about_dialog_logo_expose (GtkWidget *widget,
GdkEventExpose *event,
gpointer data);
static gint about_dialog_button (GtkWidget *widget,
GdkEventButton *event,
gpointer data);
static void about_dialog_tool_drop (GtkWidget *widget,
ToolType tool,
gpointer data);
static gint about_dialog_timer (gpointer data);
static GtkWidget *about_dialog = NULL; static GtkWidget *about_dialog = NULL;
@ -74,7 +90,6 @@ static gchar *scroll_text[] =
"Marc Bless", "Marc Bless",
"Edward Blevins", "Edward Blevins",
"Reagan Blundell", "Reagan Blundell",
"Andreas Bogk",
"Xavier Bouchoux", "Xavier Bouchoux",
"Roberto Boyd", "Roberto Boyd",
"Stanislav Brabec", "Stanislav Brabec",
@ -133,7 +148,6 @@ static gchar *scroll_text[] =
"Peter Kirchgessner", "Peter Kirchgessner",
"Philipp Klaus", "Philipp Klaus",
"David Koblas", "David Koblas",
"Vincent Kolwitz",
"Tuomas Kuosmanen", "Tuomas Kuosmanen",
"Karin Kylander", "Karin Kylander",
"Olof S Kylander", "Olof S Kylander",
@ -230,24 +244,32 @@ static gchar *scroll_text[] =
#endif #endif
}; };
static gint nscroll_texts = sizeof (scroll_text) / sizeof (scroll_text[0]); static gint nscroll_texts = sizeof (scroll_text) / sizeof (scroll_text[0]);
static gint scroll_text_widths[ sizeof(scroll_text) / sizeof(scroll_text[0]) ]; static gint scroll_text_widths[sizeof (scroll_text) / sizeof (scroll_text[0])];
static gint cur_scroll_text = 0; static gint cur_scroll_text = 0;
static gint cur_scroll_index; static gint cur_scroll_index = 0;
static gint shuffle_array[ sizeof(scroll_text) / sizeof(scroll_text[0]) ]; static gint shuffle_array[sizeof (scroll_text) / sizeof (scroll_text[0])];
/* dnd stuff */
static GtkTargetEntry tool_target_table[] =
{
GIMP_TARGET_TOOL
};
static guint n_tool_targets = (sizeof (tool_target_table) /
sizeof (tool_target_table[0]));
void void
about_dialog_create () about_dialog_create (void)
{ {
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *aboutframe; GtkWidget *aboutframe;
GtkWidget *label; GtkWidget *label;
GtkWidget *alignment; GtkWidget *alignment;
GtkStyle *style; GtkStyle *style;
GdkFont *font; GdkFont *font;
gint max_width; gint max_width;
gint i; gint i;
gchar *label_text; gchar *label_text;
if (!about_dialog) if (!about_dialog)
{ {
@ -270,6 +292,14 @@ about_dialog_create ()
GTK_SIGNAL_FUNC (about_dialog_button), GTK_SIGNAL_FUNC (about_dialog_button),
NULL); NULL);
/* dnd stuff */
gtk_drag_dest_set (about_dialog,
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
tool_target_table, n_tool_targets,
GDK_ACTION_COPY);
gimp_dnd_tool_dest_set (about_dialog, about_dialog_tool_drop, NULL);
gtk_widget_set_events (about_dialog, GDK_BUTTON_PRESS_MASK); gtk_widget_set_events (about_dialog, GDK_BUTTON_PRESS_MASK);
if (!about_dialog_load_logo (about_dialog)) if (!about_dialog_load_logo (about_dialog))
@ -398,33 +428,37 @@ about_dialog_create ()
} }
static gint static gboolean
about_dialog_load_logo (GtkWidget *window) about_dialog_load_logo (GtkWidget *window)
{ {
GtkWidget *preview; GtkWidget *preview;
GdkGC *gc; GdkGC *gc;
gchar buf[1024]; gchar buf[1024];
guchar *pixelrow; gchar *filename;
FILE *fp; guchar *pixelrow;
gint count; FILE *fp;
gint i, j, k; gint count;
gint i, j, k;
if (logo_pixmap) if (logo_pixmap)
return TRUE; return TRUE;
g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp_logo.ppm", filename = g_strconcat (gimp_data_directory (),
gimp_data_directory ()); G_DIR_SEPARATOR_S,
"gimp_logo.ppm",
NULL);
fp = fopen (filename, "rb");
g_free (filename);
fp = fopen (buf, "rb");
if (!fp) if (!fp)
return 0; return FALSE;
fgets (buf, 1024, fp); fgets (buf, 1024, fp);
if (strncmp (buf, "P6", 2) != 0) if (strncmp (buf, "P6", 2) != 0)
{ {
fclose (fp); fclose (fp);
return 0; return FALSE;
} }
fgets (buf, 1024, fp); fgets (buf, 1024, fp);
@ -435,7 +469,7 @@ about_dialog_load_logo (GtkWidget *window)
if (strncmp (buf, "255", 3) != 0) if (strncmp (buf, "255", 3) != 0)
{ {
fclose (fp); fclose (fp);
return 0; return FALSE;
} }
preview = gtk_preview_new (GTK_PREVIEW_COLOR); preview = gtk_preview_new (GTK_PREVIEW_COLOR);
@ -444,13 +478,13 @@ about_dialog_load_logo (GtkWidget *window)
for (i = 0; i < logo_height; i++) for (i = 0; i < logo_height; i++)
{ {
count = fread (pixelrow, sizeof (unsigned char), logo_width * 3, fp); count = fread (pixelrow, sizeof (guchar), logo_width * 3, fp);
if (count != (logo_width * 3)) if (count != (logo_width * 3))
{ {
gtk_widget_destroy (preview); gtk_widget_destroy (preview);
g_free (pixelrow); g_free (pixelrow);
fclose (fp); fclose (fp);
return 0; return FALSE;
} }
gtk_preview_draw_row (GTK_PREVIEW (preview), pixelrow, 0, i, logo_width); gtk_preview_draw_row (GTK_PREVIEW (preview), pixelrow, 0, i, logo_width);
@ -487,14 +521,17 @@ about_dialog_load_logo (GtkWidget *window)
} }
static void static void
about_dialog_destroy (void) about_dialog_destroy (GtkObject *object,
gpointer data)
{ {
about_dialog = NULL; about_dialog = NULL;
about_dialog_unmap (); about_dialog_unmap (NULL, NULL, NULL);
} }
static void static void
about_dialog_unmap (void) about_dialog_unmap (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{ {
if (timer) if (timer)
{ {
@ -505,7 +542,8 @@ about_dialog_unmap (void)
static gint static gint
about_dialog_logo_expose (GtkWidget *widget, about_dialog_logo_expose (GtkWidget *widget,
GdkEventExpose *event) GdkEventExpose *event,
gpointer data)
{ {
if (do_animation) if (do_animation)
{ {
@ -537,7 +575,8 @@ about_dialog_logo_expose (GtkWidget *widget,
static gint static gint
about_dialog_button (GtkWidget *widget, about_dialog_button (GtkWidget *widget,
GdkEventButton *event) GdkEventButton *event,
gpointer data)
{ {
if (timer) if (timer)
gtk_timeout_remove (timer); gtk_timeout_remove (timer);
@ -549,6 +588,70 @@ about_dialog_button (GtkWidget *widget,
return FALSE; return FALSE;
} }
static void
about_dialog_tool_drop (GtkWidget *widget,
ToolType tool,
gpointer data)
{
GdkPixmap *pixmap = NULL;
GdkBitmap *mask = NULL;
gint width = 0;
gint height = 0;
if (do_animation)
return;
if (timer)
gtk_timeout_remove (timer);
timer = gtk_timeout_add (75, about_dialog_timer, NULL);
frame = 0;
do_animation = TRUE;
do_scrolling = FALSE;
gdk_draw_rectangle (logo_pixmap,
logo_area->style->white_gc,
TRUE,
0, 0,
logo_area->allocation.width,
logo_area->allocation.height);
pixmap =
gdk_pixmap_create_from_xpm_d (widget->window,
&mask,
NULL,
wilber2_xpm);
gdk_window_get_size (pixmap, &width, &height);
if (logo_area->allocation.width >= width &&
logo_area->allocation.height >= height)
{
gint x, y;
x = (logo_area->allocation.width - width) / 2;
y = (logo_area->allocation.height - height) / 2;
gdk_gc_set_clip_mask (logo_area->style->black_gc, mask);
gdk_gc_set_clip_origin (logo_area->style->black_gc, x, y);
gdk_draw_pixmap (logo_pixmap,
logo_area->style->black_gc,
pixmap, 0, 0,
x, y,
width, height);
gdk_gc_set_clip_mask (logo_area->style->black_gc, NULL);
gdk_gc_set_clip_origin (logo_area->style->black_gc, 0, 0);
}
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
double_speed = TRUE;
}
static gint static gint
about_dialog_timer (gpointer data) about_dialog_timer (gpointer data)
{ {

View File

@ -15,25 +15,19 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#include <signal.h> #include <signal.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_TIMES_H
#include <sys/times.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#include <time.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "appenv.h" #include "appenv.h"
#include "app_procs.h" #include "app_procs.h"
#include "errorconsole.h" #include "errorconsole.h"
@ -46,49 +40,77 @@
extern gchar *prog_name; extern gchar *prog_name;
StackTraceMode stack_trace_mode = STACK_TRACE_QUERY;
void void
gimp_message_func (gchar *str) gimp_message_func (gchar *str)
{ {
if (console_messages == FALSE) if (console_messages == FALSE)
switch (message_handler) {
{ switch (message_handler)
case MESSAGE_BOX: {
gimp_message_box (str, NULL, NULL); case MESSAGE_BOX:
break; gimp_message_box (str, NULL, NULL);
case ERROR_CONSOLE:
error_console_add (str);
break;
default:
fprintf (stderr, "%s: %s\n", prog_name, str);
break; break;
case ERROR_CONSOLE:
error_console_add (str);
break;
default:
g_printerr ("%s: %s\n", prog_name, str);
break;
}
} }
else else
fprintf (stderr, "%s: %s\n", prog_name, str); {
g_printerr ("%s: %s\n", prog_name, str);
}
} }
void void
gimp_fatal_error (gchar *fmt, ...) gimp_fatal_error (gchar *fmt, ...)
{ {
#ifndef G_OS_WIN32
va_list args; va_list args;
#ifndef G_OS_WIN32
va_start (args, fmt); va_start (args, fmt);
g_print ("%s: fatal error: %s\n", prog_name, g_strdup_vprintf (fmt, args)); g_printerr ("%s: fatal error: %s\n", prog_name, g_strdup_vprintf (fmt, args));
va_end (args); va_end (args);
if (TRUE) switch (stack_trace_mode)
{ {
sigset_t sigset; case STACK_TRACE_NEVER:
break;
sigemptyset (&sigset); case STACK_TRACE_QUERY:
sigprocmask (SIG_SETMASK, &sigset, NULL); {
g_on_error_query (prog_name); sigset_t sigset;
sigemptyset (&sigset);
sigprocmask (SIG_SETMASK, &sigset, NULL);
g_on_error_query (prog_name);
}
break;
case STACK_TRACE_ALWAYS:
{
sigset_t sigset;
sigemptyset (&sigset);
sigprocmask (SIG_SETMASK, &sigset, NULL);
g_on_error_stack_trace (prog_name);
}
break;
default:
break;
} }
#else #else
/* g_on_error_query doesn't do anything reasonable on Win32. */
va_list args; /* g_on_error_* don't do anything reasonable on Win32. */
gchar *msg; gchar *msg;
va_start (args, fmt); va_start (args, fmt);
@ -98,18 +120,21 @@ gimp_fatal_error (gchar *fmt, ...)
MessageBox (NULL, msg, prog_name, MB_OK|MB_ICONERROR); MessageBox (NULL, msg, prog_name, MB_OK|MB_ICONERROR);
/* I don't dare do anything more. */ /* I don't dare do anything more. */
ExitProcess (1); ExitProcess (1);
#endif
#endif /* ! G_OS_WIN32 */
app_exit (TRUE); app_exit (TRUE);
} }
void void
gimp_terminate (gchar *fmt, ...) gimp_terminate (gchar *fmt, ...)
{ {
#ifndef G_OS_WIN32
va_list args; va_list args;
#ifndef G_OS_WIN32
va_start (args, fmt); va_start (args, fmt);
g_print ("%s terminated: %s\n", prog_name, g_strdup_vprintf (fmt, args)); g_printerr ("%s terminated: %s\n", prog_name, g_strdup_vprintf (fmt, args));
va_end (args); va_end (args);
if (use_debug_handler) if (use_debug_handler)
@ -120,9 +145,10 @@ gimp_terminate (gchar *fmt, ...)
sigprocmask (SIG_SETMASK, &sigset, NULL); sigprocmask (SIG_SETMASK, &sigset, NULL);
g_on_error_query (prog_name); g_on_error_query (prog_name);
} }
#else #else
/* g_on_error_query doesn't do anything reasonable on Win32. */
va_list args; /* g_on_error_* don't do anything reasonable on Win32. */
gchar *msg; gchar *msg;
va_start (args, fmt); va_start (args, fmt);
@ -130,6 +156,8 @@ gimp_terminate (gchar *fmt, ...)
va_end (args); va_end (args);
MessageBox (NULL, msg, prog_name, MB_OK|MB_ICONERROR); MessageBox (NULL, msg, prog_name, MB_OK|MB_ICONERROR);
#endif
#endif /* ! G_OS_WIN32 */
gdk_exit (1); gdk_exit (1);
} }

View File

@ -18,6 +18,15 @@
#ifndef __ERRORS_H__ #ifndef __ERRORS_H__
#define __ERRORS_H__ #define __ERRORS_H__
typedef enum
{
STACK_TRACE_NEVER,
STACK_TRACE_QUERY,
STACK_TRACE_ALWAYS
} StackTraceMode;
extern StackTraceMode stack_trace_mode;
void gimp_message_func (gchar *); void gimp_message_func (gchar *);
void gimp_fatal_error (gchar *, ...); void gimp_fatal_error (gchar *, ...);
void gimp_terminate (gchar *, ...); void gimp_terminate (gchar *, ...);

View File

@ -15,6 +15,9 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -22,26 +25,39 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "appenv.h"
#include "about_dialog.h"
#include "gimpdnd.h"
#include "gimphelp.h" #include "gimphelp.h"
#include "libgimp/gimpfeatures.h" #include "libgimp/gimpfeatures.h"
#include "config.h"
#include "libgimp/gimpenv.h" #include "libgimp/gimpenv.h"
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h" #include "libgimp/gimpmath.h"
#include "about_dialog.h" #include "pixmaps/wilber2.xpm"
#define ANIMATION_STEPS 16 #define ANIMATION_STEPS 16
#define ANIMATION_SIZE 2 #define ANIMATION_SIZE 2
static gint about_dialog_load_logo (GtkWidget *window); static gboolean about_dialog_load_logo (GtkWidget *window);
static void about_dialog_destroy (void); static void about_dialog_destroy (GtkObject *object,
static void about_dialog_unmap (void); gpointer data);
static gint about_dialog_logo_expose (GtkWidget *widget, GdkEventExpose *event); static void about_dialog_unmap (GtkWidget *widget,
static gint about_dialog_button (GtkWidget *widget, GdkEventButton *event); GdkEvent *event,
static gint about_dialog_timer (gpointer data); gpointer data);
static gint about_dialog_logo_expose (GtkWidget *widget,
GdkEventExpose *event,
gpointer data);
static gint about_dialog_button (GtkWidget *widget,
GdkEventButton *event,
gpointer data);
static void about_dialog_tool_drop (GtkWidget *widget,
ToolType tool,
gpointer data);
static gint about_dialog_timer (gpointer data);
static GtkWidget *about_dialog = NULL; static GtkWidget *about_dialog = NULL;
@ -74,7 +90,6 @@ static gchar *scroll_text[] =
"Marc Bless", "Marc Bless",
"Edward Blevins", "Edward Blevins",
"Reagan Blundell", "Reagan Blundell",
"Andreas Bogk",
"Xavier Bouchoux", "Xavier Bouchoux",
"Roberto Boyd", "Roberto Boyd",
"Stanislav Brabec", "Stanislav Brabec",
@ -133,7 +148,6 @@ static gchar *scroll_text[] =
"Peter Kirchgessner", "Peter Kirchgessner",
"Philipp Klaus", "Philipp Klaus",
"David Koblas", "David Koblas",
"Vincent Kolwitz",
"Tuomas Kuosmanen", "Tuomas Kuosmanen",
"Karin Kylander", "Karin Kylander",
"Olof S Kylander", "Olof S Kylander",
@ -230,24 +244,32 @@ static gchar *scroll_text[] =
#endif #endif
}; };
static gint nscroll_texts = sizeof (scroll_text) / sizeof (scroll_text[0]); static gint nscroll_texts = sizeof (scroll_text) / sizeof (scroll_text[0]);
static gint scroll_text_widths[ sizeof(scroll_text) / sizeof(scroll_text[0]) ]; static gint scroll_text_widths[sizeof (scroll_text) / sizeof (scroll_text[0])];
static gint cur_scroll_text = 0; static gint cur_scroll_text = 0;
static gint cur_scroll_index; static gint cur_scroll_index = 0;
static gint shuffle_array[ sizeof(scroll_text) / sizeof(scroll_text[0]) ]; static gint shuffle_array[sizeof (scroll_text) / sizeof (scroll_text[0])];
/* dnd stuff */
static GtkTargetEntry tool_target_table[] =
{
GIMP_TARGET_TOOL
};
static guint n_tool_targets = (sizeof (tool_target_table) /
sizeof (tool_target_table[0]));
void void
about_dialog_create () about_dialog_create (void)
{ {
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *aboutframe; GtkWidget *aboutframe;
GtkWidget *label; GtkWidget *label;
GtkWidget *alignment; GtkWidget *alignment;
GtkStyle *style; GtkStyle *style;
GdkFont *font; GdkFont *font;
gint max_width; gint max_width;
gint i; gint i;
gchar *label_text; gchar *label_text;
if (!about_dialog) if (!about_dialog)
{ {
@ -270,6 +292,14 @@ about_dialog_create ()
GTK_SIGNAL_FUNC (about_dialog_button), GTK_SIGNAL_FUNC (about_dialog_button),
NULL); NULL);
/* dnd stuff */
gtk_drag_dest_set (about_dialog,
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
tool_target_table, n_tool_targets,
GDK_ACTION_COPY);
gimp_dnd_tool_dest_set (about_dialog, about_dialog_tool_drop, NULL);
gtk_widget_set_events (about_dialog, GDK_BUTTON_PRESS_MASK); gtk_widget_set_events (about_dialog, GDK_BUTTON_PRESS_MASK);
if (!about_dialog_load_logo (about_dialog)) if (!about_dialog_load_logo (about_dialog))
@ -398,33 +428,37 @@ about_dialog_create ()
} }
static gint static gboolean
about_dialog_load_logo (GtkWidget *window) about_dialog_load_logo (GtkWidget *window)
{ {
GtkWidget *preview; GtkWidget *preview;
GdkGC *gc; GdkGC *gc;
gchar buf[1024]; gchar buf[1024];
guchar *pixelrow; gchar *filename;
FILE *fp; guchar *pixelrow;
gint count; FILE *fp;
gint i, j, k; gint count;
gint i, j, k;
if (logo_pixmap) if (logo_pixmap)
return TRUE; return TRUE;
g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp_logo.ppm", filename = g_strconcat (gimp_data_directory (),
gimp_data_directory ()); G_DIR_SEPARATOR_S,
"gimp_logo.ppm",
NULL);
fp = fopen (filename, "rb");
g_free (filename);
fp = fopen (buf, "rb");
if (!fp) if (!fp)
return 0; return FALSE;
fgets (buf, 1024, fp); fgets (buf, 1024, fp);
if (strncmp (buf, "P6", 2) != 0) if (strncmp (buf, "P6", 2) != 0)
{ {
fclose (fp); fclose (fp);
return 0; return FALSE;
} }
fgets (buf, 1024, fp); fgets (buf, 1024, fp);
@ -435,7 +469,7 @@ about_dialog_load_logo (GtkWidget *window)
if (strncmp (buf, "255", 3) != 0) if (strncmp (buf, "255", 3) != 0)
{ {
fclose (fp); fclose (fp);
return 0; return FALSE;
} }
preview = gtk_preview_new (GTK_PREVIEW_COLOR); preview = gtk_preview_new (GTK_PREVIEW_COLOR);
@ -444,13 +478,13 @@ about_dialog_load_logo (GtkWidget *window)
for (i = 0; i < logo_height; i++) for (i = 0; i < logo_height; i++)
{ {
count = fread (pixelrow, sizeof (unsigned char), logo_width * 3, fp); count = fread (pixelrow, sizeof (guchar), logo_width * 3, fp);
if (count != (logo_width * 3)) if (count != (logo_width * 3))
{ {
gtk_widget_destroy (preview); gtk_widget_destroy (preview);
g_free (pixelrow); g_free (pixelrow);
fclose (fp); fclose (fp);
return 0; return FALSE;
} }
gtk_preview_draw_row (GTK_PREVIEW (preview), pixelrow, 0, i, logo_width); gtk_preview_draw_row (GTK_PREVIEW (preview), pixelrow, 0, i, logo_width);
@ -487,14 +521,17 @@ about_dialog_load_logo (GtkWidget *window)
} }
static void static void
about_dialog_destroy (void) about_dialog_destroy (GtkObject *object,
gpointer data)
{ {
about_dialog = NULL; about_dialog = NULL;
about_dialog_unmap (); about_dialog_unmap (NULL, NULL, NULL);
} }
static void static void
about_dialog_unmap (void) about_dialog_unmap (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{ {
if (timer) if (timer)
{ {
@ -505,7 +542,8 @@ about_dialog_unmap (void)
static gint static gint
about_dialog_logo_expose (GtkWidget *widget, about_dialog_logo_expose (GtkWidget *widget,
GdkEventExpose *event) GdkEventExpose *event,
gpointer data)
{ {
if (do_animation) if (do_animation)
{ {
@ -537,7 +575,8 @@ about_dialog_logo_expose (GtkWidget *widget,
static gint static gint
about_dialog_button (GtkWidget *widget, about_dialog_button (GtkWidget *widget,
GdkEventButton *event) GdkEventButton *event,
gpointer data)
{ {
if (timer) if (timer)
gtk_timeout_remove (timer); gtk_timeout_remove (timer);
@ -549,6 +588,70 @@ about_dialog_button (GtkWidget *widget,
return FALSE; return FALSE;
} }
static void
about_dialog_tool_drop (GtkWidget *widget,
ToolType tool,
gpointer data)
{
GdkPixmap *pixmap = NULL;
GdkBitmap *mask = NULL;
gint width = 0;
gint height = 0;
if (do_animation)
return;
if (timer)
gtk_timeout_remove (timer);
timer = gtk_timeout_add (75, about_dialog_timer, NULL);
frame = 0;
do_animation = TRUE;
do_scrolling = FALSE;
gdk_draw_rectangle (logo_pixmap,
logo_area->style->white_gc,
TRUE,
0, 0,
logo_area->allocation.width,
logo_area->allocation.height);
pixmap =
gdk_pixmap_create_from_xpm_d (widget->window,
&mask,
NULL,
wilber2_xpm);
gdk_window_get_size (pixmap, &width, &height);
if (logo_area->allocation.width >= width &&
logo_area->allocation.height >= height)
{
gint x, y;
x = (logo_area->allocation.width - width) / 2;
y = (logo_area->allocation.height - height) / 2;
gdk_gc_set_clip_mask (logo_area->style->black_gc, mask);
gdk_gc_set_clip_origin (logo_area->style->black_gc, x, y);
gdk_draw_pixmap (logo_pixmap,
logo_area->style->black_gc,
pixmap, 0, 0,
x, y,
width, height);
gdk_gc_set_clip_mask (logo_area->style->black_gc, NULL);
gdk_gc_set_clip_origin (logo_area->style->black_gc, 0, 0);
}
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
double_speed = TRUE;
}
static gint static gint
about_dialog_timer (gpointer data) about_dialog_timer (gpointer data)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -173,32 +173,32 @@ main (int argc,
if (batch_cmds[0] == NULL) /* We need at least one batch command */ if (batch_cmds[0] == NULL) /* We need at least one batch command */
show_help = TRUE; show_help = TRUE;
} }
else if (strcmp (argv[i], "--system-gimprc") == 0) else if (strcmp (argv[i], "--system-gimprc") == 0)
{ {
argv[i] = NULL; argv[i] = NULL;
if (argc <= ++i) if (argc <= ++i)
{ {
show_help = TRUE; show_help = TRUE;
} }
else else
{ {
alternate_system_gimprc = argv[i]; alternate_system_gimprc = argv[i];
argv[i] = NULL; argv[i] = NULL;
} }
} }
else if ((strcmp (argv[i], "--gimprc") == 0) || else if ((strcmp (argv[i], "--gimprc") == 0) ||
(strcmp (argv[i], "-g") == 0)) (strcmp (argv[i], "-g") == 0))
{ {
if (argc <= ++i) if (argc <= ++i)
{ {
show_help = TRUE; show_help = TRUE;
} }
else else
{ {
alternate_gimprc = argv[i]; alternate_gimprc = argv[i];
argv[i] = NULL; argv[i] = NULL;
} }
} }
else if ((strcmp (argv[i], "--help") == 0) || else if ((strcmp (argv[i], "--help") == 0) ||
(strcmp (argv[i], "-h") == 0)) (strcmp (argv[i], "-h") == 0))
{ {
@ -252,11 +252,27 @@ main (int argc,
restore_session = TRUE; restore_session = TRUE;
argv[i] = NULL; argv[i] = NULL;
} }
else if (strcmp (argv[i], "--wilber-on-lsd") == 0) else if (strcmp (argv[i], "--enable-stack-trace") == 0)
{ {
double_speed = TRUE;
argv[i] = NULL; argv[i] = NULL;
} if (argc <= ++i)
{
show_help = TRUE;
}
else
{
if (! strcmp (argv[i], "never"))
stack_trace_mode = STACK_TRACE_NEVER;
else if (! strcmp (argv[i], "query"))
stack_trace_mode = STACK_TRACE_QUERY;
else if (! strcmp (argv[i], "always"))
stack_trace_mode = STACK_TRACE_ALWAYS;
else
show_help = TRUE;
argv[i] = NULL;
}
}
/* /*
* ANYTHING ELSE starting with a '-' is an error. * ANYTHING ELSE starting with a '-' is an error.
*/ */
@ -296,7 +312,9 @@ main (int argc,
g_print (_(" --no-shm Do not use shared memory between GIMP and its plugins.\n")); g_print (_(" --no-shm Do not use shared memory between GIMP and its plugins.\n"));
g_print (_(" --no-xshm Do not use the X Shared Memory extension.\n")); g_print (_(" --no-xshm Do not use the X Shared Memory extension.\n"));
g_print (_(" --console-messages Display warnings to console instead of a dialog box.\n")); g_print (_(" --console-messages Display warnings to console instead of a dialog box.\n"));
g_print (_(" --debug-handlers Enable debugging signal handlers.\n")); g_print (_(" --debug-handlers Enable debugging signal handlers for non-fatal signals.\n"));
g_print (_(" --enable-stack-trace {never|query|always}\n"));
g_print (_(" Debugging mode for fatal signals.\n"));
g_print (_(" --display <display> Use the designated X display.\n")); g_print (_(" --display <display> Use the designated X display.\n"));
g_print (_(" --system-gimprc <gimprc> Use an alternate system gimprc file.\n")); g_print (_(" --system-gimprc <gimprc> Use an alternate system gimprc file.\n"));
} }

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
@ -80,6 +81,7 @@
#include "brush_select.h" /* Need for closing dialogs */ #include "brush_select.h" /* Need for closing dialogs */
#include "drawable.h" #include "drawable.h"
#include "datafiles.h" #include "datafiles.h"
#include "errors.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "general.h" #include "general.h"
#include "gimage.h" #include "gimage.h"
@ -99,7 +101,7 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
typedef struct _PlugInBlocked PlugInBlocked; typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked struct _PlugInBlocked
{ {
@ -154,28 +156,29 @@ static gint plug_in_make_menu_entry (gpointer foo,
static void plug_in_callback (GtkWidget *widget, static void plug_in_callback (GtkWidget *widget,
gpointer client_data); gpointer client_data);
static void plug_in_proc_def_insert (PlugInProcDef *proc_def, static void plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void *)); void (* superceed_fn) (void *));
static void plug_in_proc_def_dead (void *freed_proc_def); static void plug_in_proc_def_dead (void *freed_proc_def);
static void plug_in_proc_def_remove (PlugInProcDef *proc_def); static void plug_in_proc_def_remove (PlugInProcDef *proc_def);
static void plug_in_proc_def_destroy (PlugInProcDef *proc_def, static void plug_in_proc_def_destroy (PlugInProcDef *proc_def,
gboolean data_only); gboolean data_only);
static Argument* plug_in_temp_run (ProcRecord *proc_rec, static Argument * plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc); gint argc);
static Argument* plug_in_params_to_args (GPParam *params, static Argument * plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy); gboolean full_copy);
static GPParam* plug_in_args_to_params (Argument *args, static GPParam * plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy); gboolean full_copy);
static void plug_in_params_destroy (GPParam *params, static void plug_in_params_destroy (GPParam *params,
gint nparams, gint nparams,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_args_destroy (Argument *args, static void plug_in_args_destroy (Argument *args,
gint nargs, gint nargs,
gboolean full_destroy); gboolean full_destroy);
static void plug_in_init_shm (void); static void plug_in_init_shm (void);
PlugIn *current_plug_in = NULL; PlugIn *current_plug_in = NULL;
GSList *proc_defs = NULL; GSList *proc_defs = NULL;
@ -250,8 +253,8 @@ plug_in_init_shm (void)
pid = GetCurrentProcessId (); pid = GetCurrentProcessId ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
sprintf (fileMapName, "GIMP%d.SHM", pid); g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", pid);
/* Create the file mapping into paging space */ /* Create the file mapping into paging space */
shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL, shm_handle = CreateFileMapping ((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, PAGE_READWRITE, 0,
@ -284,11 +287,14 @@ void
plug_in_init (void) plug_in_init (void)
{ {
extern gboolean use_shm; extern gboolean use_shm;
gchar *filename;
GSList *tmp, *tmp2; gchar *filename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
gfloat nplugins, nth; gfloat nplugins;
gfloat nth;
/* initialize the gimp protocol library and set the read and /* initialize the gimp protocol library and set the read and
* write handlers. * write handlers.
@ -302,9 +308,8 @@ plug_in_init (void)
* we'll fall back on sending the data over the pipe. * we'll fall back on sending the data over the pipe.
*/ */
if (use_shm) if (use_shm)
{ plug_in_init_shm ();
plug_in_init_shm ();
}
/* search for binaries in the plug-in directory path */ /* search for binaries in the plug-in directory path */
datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE); datafiles_read_directories (plug_in_path, plug_in_init_file, MODE_EXECUTABLE);
@ -479,7 +484,7 @@ plug_in_add (gchar *prog,
gchar *accelerator) gchar *accelerator)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (strncmp ("plug_in_", prog, 8) != 0) if (strncmp ("plug_in_", prog, 8) != 0)
{ {
@ -512,30 +517,30 @@ plug_in_add (gchar *prog,
g_free (proc_def->image_types); g_free (proc_def->image_types);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
proc_def->prefixes = NULL; proc_def->prefixes = NULL;
proc_def->extensions = NULL; proc_def->extensions = NULL;
proc_def->magics = NULL; proc_def->magics = NULL;
proc_def->image_types = NULL; proc_def->image_types = NULL;
return; return;
} }
} }
proc_def = g_new0 (PlugInProcDef, 1); proc_def = g_new0 (PlugInProcDef, 1);
proc_def->db_info.name = prog; proc_def->db_info.name = prog;
proc_def->menu_path = menu_path; proc_def->menu_path = menu_path;
proc_def->accelerator = accelerator; proc_def->accelerator = accelerator;
gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def); gimprc_proc_defs = g_slist_prepend (gimprc_proc_defs, proc_def);
} }
gchar* gchar *
plug_in_image_types (gchar *name) plug_in_image_types (gchar *name)
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -599,7 +604,7 @@ plug_in_file_handler (gchar *name,
{ {
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
if (current_plug_in) if (current_plug_in)
{ {
@ -680,9 +685,12 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list; GSList *list;
g_free (plug_in_def->prog); g_free (plug_in_def->prog);
if (plug_in_def->locale_domain) g_free (plug_in_def->locale_domain); if (plug_in_def->locale_domain)
if (plug_in_def->locale_path) g_free (plug_in_def->locale_path); g_free (plug_in_def->locale_domain);
if (plug_in_def->help_path) g_free (plug_in_def->help_path); if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
if (free_proc_defs) if (free_proc_defs)
{ {
@ -707,12 +715,13 @@ plug_in_def_add (PlugInDef *plug_in_def)
t1 = g_basename (plug_in_def->prog); t1 = g_basename (plug_in_def->prog);
/* If this is a file load or save plugin, make sure we have /* If this is a file load or save plugin, make sure we have
* something for one of the extensions, prefixes, or magic number. * something for one of the extensions, prefixes, or magic number.
* Other bits of code rely on detecting file plugins by the presence * Other bits of code rely on detecting file plugins by the presence
* of one of these things, but Nick Lamb's alien/unknown format * of one of these things, but Nick Lamb's alien/unknown format
* loader needs to be able to register no extensions, prefixes or * loader needs to be able to register no extensions, prefixes or
* magics. -- austin 13/Feb/99 */ * magics. -- austin 13/Feb/99
*/
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
proc_def = tmp->data; proc_def = tmp->data;
@ -839,8 +848,8 @@ plug_in_new (gchar *name)
plug_in->pid = 0; plug_in->pid = 0;
plug_in->args[0] = g_strdup (path); plug_in->args[0] = g_strdup (path);
plug_in->args[1] = g_strdup ("-gimp"); plug_in->args[1] = g_strdup ("-gimp");
plug_in->args[2] = g_new (gchar, 32); plug_in->args[2] = NULL;
plug_in->args[3] = g_new (gchar, 32); plug_in->args[3] = NULL;
plug_in->args[4] = NULL; plug_in->args[4] = NULL;
plug_in->args[5] = NULL; plug_in->args[5] = NULL;
plug_in->args[6] = NULL; plug_in->args[6] = NULL;
@ -897,7 +906,7 @@ plug_in_destroy (PlugIn *plug_in)
gint gint
xspawnv (gint mode, xspawnv (gint mode,
const gchar *cmdname, const gchar *cmdname,
const gchar *const *argv ) const gchar *const *argv)
{ {
gchar sExecutable[_MAX_PATH*2]; gchar sExecutable[_MAX_PATH*2];
gchar** sArgsList; gchar** sArgsList;
@ -983,17 +992,18 @@ plug_in_open (PlugIn *plug_in)
/* Remember the file descriptors for the pipes. /* Remember the file descriptors for the pipes.
*/ */
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_unix_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d", plug_in->args[3] =
g_io_channel_unix_get_fd (plug_in->his_write)); g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
#else #else
sprintf (plug_in->args[2], "%d", plug_in->args[2] =
g_io_channel_win32_get_fd (plug_in->his_read)); g_strdup_printf ("%d", g_io_channel_win32_get_fd (plug_in->his_read));
sprintf (plug_in->args[3], "%d:%u:%d", plug_in->args[3] =
g_io_channel_win32_get_fd (plug_in->his_write), g_strdup_printf ("%d:%u:%d",
GetCurrentThreadId (), g_io_channel_win32_get_fd (plug_in->his_write),
g_io_channel_win32_get_fd (plug_in->my_read)); GetCurrentThreadId (),
g_io_channel_win32_get_fd (plug_in->my_read));
#endif #endif
/* Set the rest of the command line arguments. /* Set the rest of the command line arguments.
@ -1004,20 +1014,18 @@ plug_in_open (PlugIn *plug_in)
} }
else else
{ {
plug_in->args[4] = g_new (gchar, 16); plug_in->args[4] = g_strdup ("-run");
plug_in->args[5] = g_new (gchar, 16);
sprintf (plug_in->args[4], "%d", TILE_WIDTH);
sprintf (plug_in->args[5], "%d", TILE_WIDTH);
} }
plug_in->args[5] = g_strdup_printf ("%d", (gint) stack_trace_mode);
/* Fork another process. We'll remember the process id /* Fork another process. We'll remember the process id
* so that we can later use it to kill the filter if * so that we can later use it to kill the filter if
* necessary. * necessary.
*/ */
#ifdef __EMX__ #ifdef __EMX__
fcntl(my_read[0], F_SETFD, 1); fcntl (my_read[0], F_SETFD, 1);
fcntl(my_write[1], F_SETFD, 1); fcntl (my_write[1], F_SETFD, 1);
#endif #endif
#if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__) #if defined(G_OS_WIN32) || defined (G_WITH_CYGWIN) || defined(__EMX__)
plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args); plug_in->pid = _spawnv (_P_NOWAIT, plug_in->args[0], plug_in->args);
@ -1119,8 +1127,7 @@ plug_in_close (PlugIn *plug_in,
#endif #endif
} }
/* If necessary, kill the filter. /* If necessary, kill the filter. */
*/
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
if (kill_it && plug_in->pid) if (kill_it && plug_in->pid)
status = kill (plug_in->pid, SIGKILL); status = kill (plug_in->pid, SIGKILL);
@ -1154,13 +1161,11 @@ plug_in_close (PlugIn *plug_in,
} }
#endif #endif
/* Remove the input handler. /* Remove the input handler. */
*/
if (plug_in->input_id) if (plug_in->input_id)
gdk_input_remove (plug_in->input_id); gdk_input_remove (plug_in->input_id);
/* Close the pipes. /* Close the pipes. */
*/
if (plug_in->my_read != NULL) if (plug_in->my_read != NULL)
{ {
g_io_channel_close (plug_in->my_read); g_io_channel_close (plug_in->my_read);
@ -1188,14 +1193,12 @@ plug_in_close (PlugIn *plug_in,
wire_clear_error (); wire_clear_error ();
/* Destroy the progress dialog if it exists /* Destroy the progress dialog if it exists. */
*/
if (plug_in->progress) if (plug_in->progress)
progress_end (plug_in->progress); progress_end (plug_in->progress);
plug_in->progress = NULL; plug_in->progress = NULL;
/* Set the fields to null values. /* Set the fields to null values. */
*/
plug_in->pid = 0; plug_in->pid = 0;
plug_in->input_id = 0; plug_in->input_id = 0;
plug_in->my_read = NULL; plug_in->my_read = NULL;
@ -1207,13 +1210,12 @@ plug_in_close (PlugIn *plug_in,
gtk_main_quit (); gtk_main_quit ();
plug_in->synchronous = FALSE; plug_in->synchronous = FALSE;
plug_in->recurse = FALSE; plug_in->recurse = FALSE;
/* Unregister any temporary procedures /* Unregister any temporary procedures. */
*/
if (plug_in->temp_proc_defs) if (plug_in->temp_proc_defs)
{ {
GSList *list; GSList *list;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list)) for (list = plug_in->temp_proc_defs; list; list = g_slist_next (list))
@ -1239,12 +1241,14 @@ static Argument *
plug_in_get_current_return_vals (ProcRecord *proc_rec) plug_in_get_current_return_vals (ProcRecord *proc_rec)
{ {
Argument *return_vals; Argument *return_vals;
gint nargs; gint nargs;
/* Return the status code plus the current return values. */ /* Return the status code plus the current return values. */
nargs = proc_rec->num_values + 1; nargs = proc_rec->num_values + 1;
if (current_return_vals && current_return_nvals == nargs) if (current_return_vals && current_return_nvals == nargs)
return_vals = current_return_vals; {
return_vals = current_return_vals;
}
else if (current_return_vals) else if (current_return_vals)
{ {
/* Allocate new return values of the correct size. */ /* Allocate new return values of the correct size. */
@ -1267,12 +1271,12 @@ plug_in_get_current_return_vals (ProcRecord *proc_rec)
/* We have consumed any saved values, so clear them. */ /* We have consumed any saved values, so clear them. */
current_return_nvals = 0; current_return_nvals = 0;
current_return_vals = NULL; current_return_vals = NULL;
return return_vals; return return_vals;
} }
Argument* Argument *
plug_in_run (ProcRecord *proc_rec, plug_in_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc, gint argc,
@ -1333,9 +1337,8 @@ plug_in_run (ProcRecord *proc_rec,
plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE); plug_in_params_destroy (proc_run.params, proc_run.nparams, FALSE);
/* /* If this is an automatically installed extension, wait for an
* If this is an automatically installed extension, wait for an * installation-confirmation message
* installation-confirmation message
*/ */
if ((proc_rec->proc_type == PDB_EXTENSION) && if ((proc_rec->proc_type == PDB_EXTENSION) &&
(proc_rec->num_args == 0)) (proc_rec->num_args == 0))
@ -1344,7 +1347,6 @@ plug_in_run (ProcRecord *proc_rec,
if (plug_in->recurse) if (plug_in->recurse)
{ {
gtk_main (); gtk_main ();
return_vals = plug_in_get_current_return_vals (proc_rec); return_vals = plug_in_get_current_return_vals (proc_rec);
} }
} }
@ -1380,7 +1382,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */ /* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */ /* run the plug-in procedure */
@ -1394,8 +1396,8 @@ void
plug_in_set_menu_sensitivity (GimpImageType type) plug_in_set_menu_sensitivity (GimpImageType type)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp)) for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
{ {
@ -1446,9 +1448,9 @@ plug_in_set_menu_sensitivity (GimpImageType type)
} }
static gboolean static gboolean
plug_in_recv_message (GIOChannel *channel, plug_in_recv_message (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
gboolean got_message = FALSE; gboolean got_message = FALSE;
@ -1510,18 +1512,21 @@ plug_in_handle_message (WireMessage *msg)
plug_in_handle_quit (); plug_in_handle_quit ();
break; break;
case GP_CONFIG: case GP_CONFIG:
g_warning ("plug_in_handle_message(): received a config message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a config message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_REQ: case GP_TILE_REQ:
plug_in_handle_tile_req (msg->data); plug_in_handle_tile_req (msg->data);
break; break;
case GP_TILE_ACK: case GP_TILE_ACK:
g_warning ("plug_in_handle_message(): received a tile ack message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile ack message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TILE_DATA: case GP_TILE_DATA:
g_warning ("plug_in_handle_message(): received a tile data message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a tile data message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_PROC_RUN: case GP_PROC_RUN:
@ -1532,7 +1537,8 @@ plug_in_handle_message (WireMessage *msg)
plug_in_close (current_plug_in, FALSE); plug_in_close (current_plug_in, FALSE);
break; break;
case GP_TEMP_PROC_RUN: case GP_TEMP_PROC_RUN:
g_warning ("plug_in_handle_message(): received a temp proc run message (should not happen)"); g_warning ("plug_in_handle_message(): "
"received a temp proc run message (should not happen)");
plug_in_close (current_plug_in, TRUE); plug_in_close (current_plug_in, TRUE);
break; break;
case GP_TEMP_PROC_RETURN: case GP_TEMP_PROC_RETURN:
@ -1576,13 +1582,13 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
if (tile_req->drawable_ID == -1) if (tile_req->drawable_ID == -1)
{ {
tile_data.drawable_ID = -1; tile_data.drawable_ID = -1;
tile_data.tile_num = 0; tile_data.tile_num = 0;
tile_data.shadow = 0; tile_data.shadow = 0;
tile_data.bpp = 0; tile_data.bpp = 0;
tile_data.width = 0; tile_data.width = 0;
tile_data.height = 0; tile_data.height = 0;
tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE;
tile_data.data = NULL; tile_data.data = NULL;
if (!gp_tile_data_write (current_writechannel, &tile_data)) if (!gp_tile_data_write (current_writechannel, &tile_data))
{ {
@ -1769,7 +1775,7 @@ static void
plug_in_handle_proc_return (GPProcReturn *proc_return) plug_in_handle_proc_return (GPProcReturn *proc_return)
{ {
PlugInBlocked *blocked; PlugInBlocked *blocked;
GSList *tmp; GSList *tmp;
if (current_plug_in->recurse) if (current_plug_in->recurse)
{ {
@ -1809,17 +1815,16 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
static void static void
plug_in_handle_proc_install (GPProcInstall *proc_install) plug_in_handle_proc_install (GPProcInstall *proc_install)
{ {
PlugInDef *plug_in_def = NULL; PlugInDef *plug_in_def = NULL;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
ProcRecord *proc = NULL; ProcRecord *proc = NULL;
PlugInMenuEntry *menu_entry; PlugInMenuEntry *menu_entry;
GSList *tmp = NULL; GSList *tmp = NULL;
gchar *prog = NULL; gchar *prog = NULL;
gboolean add_proc_def; gboolean add_proc_def;
gint i; gint i;
/* /* Argument checking
* Argument checking
* --only sanity check arguments when the procedure requests a menu path * --only sanity check arguments when the procedure requests a menu path
*/ */
@ -1903,9 +1908,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
} }
/* /* Sanity check for array arguments */
* Sanity check for array arguments
*/
for (i = 1; i < proc_install->nparams; i++) for (i = 1; i < proc_install->nparams; i++)
{ {
@ -1927,9 +1930,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
} }
/* /* Initialization */
* Initialization
*/
proc_def = NULL; proc_def = NULL;
switch (proc_install->type) switch (proc_install->type)
@ -1988,9 +1990,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc = &proc_def->db_info; proc = &proc_def->db_info;
/* /* The procedural database procedure */
* The procedural database procedure
*/
proc->name = g_strdup (proc_install->name); proc->name = g_strdup (proc_install->name);
proc->blurb = g_strdup (proc_install->blurb); proc->blurb = g_strdup (proc_install->blurb);
proc->help = g_strdup (proc_install->help); proc->help = g_strdup (proc_install->help);
@ -2042,9 +2043,10 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
menu_entry = g_new (PlugInMenuEntry, 1); menu_entry = g_new (PlugInMenuEntry, 1);
menu_entry->proc_def = proc_def; menu_entry->proc_def = proc_def;
/* Below we use a hack to allow translations of Script-Fu paths. /* Below we use a hack to allow translations of Script-Fu paths.
Would be nice if we could solve this properly, but I haven't * Would be nice if we could solve this properly, but I haven't
found a way yet ... (Sven) */ * found a way yet ... (Sven)
*/
if (plug_in_def && plug_in_def->locale_domain) if (plug_in_def && plug_in_def->locale_domain)
menu_entry->domain = plug_in_def->locale_domain; menu_entry->domain = plug_in_def->locale_domain;
else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0) else if (strncmp (proc_def->db_info.name, "script_fu", 9) == 0)
@ -2068,7 +2070,7 @@ static void
plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall) plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp; GSList *tmp;
tmp = current_plug_in->temp_proc_defs; tmp = current_plug_in->temp_proc_defs;
while (tmp) while (tmp)
@ -2120,8 +2122,8 @@ static gboolean
plug_in_flush (GIOChannel *channel) plug_in_flush (GIOChannel *channel)
{ {
GIOError error; GIOError error;
gint count; gint count;
guint bytes; guint bytes;
if (current_write_buffer_index > 0) if (current_write_buffer_index > 0)
{ {
@ -2155,17 +2157,17 @@ plug_in_push (PlugIn *plug_in)
current_plug_in = plug_in; current_plug_in = plug_in;
plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in);
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2186,19 +2188,19 @@ plug_in_pop (void)
if (plug_in_stack) if (plug_in_stack)
{ {
current_plug_in = plug_in_stack->data; current_plug_in = plug_in_stack->data;
current_readchannel = current_plug_in->my_read; current_readchannel = current_plug_in->my_read;
current_writechannel = current_plug_in->my_write; current_writechannel = current_plug_in->my_write;
current_write_buffer_index = current_plug_in->write_buffer_index; current_write_buffer_index = current_plug_in->write_buffer_index;
current_write_buffer = current_plug_in->write_buffer; current_write_buffer = current_plug_in->write_buffer;
} }
else else
{ {
current_plug_in = NULL; current_plug_in = NULL;
current_readchannel = NULL; current_readchannel = NULL;
current_writechannel = NULL; current_writechannel = NULL;
current_write_buffer_index = 0; current_write_buffer_index = 0;
current_write_buffer = NULL; current_write_buffer = NULL;
} }
} }
@ -2241,10 +2243,11 @@ plug_in_write_rc_string (FILE *fp,
static void static void
plug_in_write_rc (gchar *filename) plug_in_write_rc (gchar *filename)
{ {
FILE *fp; FILE *fp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GSList *tmp, *tmp2; GSList *tmp;
GSList *tmp2;
gint i; gint i;
fp = fopen (filename, "w"); fp = fopen (filename, "w");
@ -2354,10 +2357,10 @@ plug_in_write_rc (gchar *filename)
static void static void
plug_in_init_file (gchar *filename) plug_in_init_file (gchar *filename)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
gchar *plug_in_name; gchar *plug_in_name;
gchar *name; gchar *name;
name = g_basename (filename); name = g_basename (filename);
@ -2390,15 +2393,15 @@ plug_in_init_file (gchar *filename)
static void static void
plug_in_query (PlugInDef *plug_in_def) plug_in_query (PlugInDef *plug_in_def)
{ {
PlugIn *plug_in; PlugIn *plug_in;
WireMessage msg; WireMessage msg;
plug_in = plug_in_new (plug_in_def->prog); plug_in = plug_in_new (plug_in_def->prog);
if (plug_in) if (plug_in)
{ {
plug_in->query = TRUE; plug_in->query = TRUE;
plug_in->synchronous = TRUE; plug_in->synchronous = TRUE;
plug_in->user_data = plug_in_def; plug_in->user_data = plug_in_def;
if (plug_in_open (plug_in)) if (plug_in_open (plug_in))
{ {
@ -2425,9 +2428,9 @@ static void
plug_in_add_to_db (void) plug_in_add_to_db (void)
{ {
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
Argument args[4]; Argument args[4];
Argument *return_vals; Argument *return_vals;
GSList *tmp; GSList *tmp;
tmp = proc_defs; tmp = proc_defs;
@ -2449,16 +2452,16 @@ plug_in_add_to_db (void)
if (proc_def->extensions || proc_def->prefixes || proc_def->magics) if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
{ {
args[0].arg_type = PDB_STRING; args[0].arg_type = PDB_STRING;
args[0].value.pdb_pointer = proc_def->db_info.name; args[0].value.pdb_pointer = proc_def->db_info.name;
args[1].arg_type = PDB_STRING; args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = proc_def->extensions; args[1].value.pdb_pointer = proc_def->extensions;
args[2].arg_type = PDB_STRING; args[2].arg_type = PDB_STRING;
args[2].value.pdb_pointer = proc_def->prefixes; args[2].value.pdb_pointer = proc_def->prefixes;
args[3].arg_type = PDB_STRING; args[3].arg_type = PDB_STRING;
args[3].value.pdb_pointer = proc_def->magics; args[3].value.pdb_pointer = proc_def->magics;
if (proc_def->image_types) if (proc_def->image_types)
@ -2475,8 +2478,7 @@ plug_in_add_to_db (void)
} }
} }
/* /* The following function has to be a GTraverseFunction,
* The following function has to be a GTraverseFunction,
* but is also called directly. Please note that it frees the * but is also called directly. Please note that it frees the
* menu_entry strcuture. --Sven * menu_entry strcuture. --Sven
*/ */
@ -2551,15 +2553,15 @@ plug_in_make_menu (void)
tmp = tmp->next; tmp = tmp->next;
procs = plug_in_def->proc_defs; procs = plug_in_def->proc_defs;
if (!procs) if (!procs)
continue; continue;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
{ {
gchar *domain; gchar *domain;
GSList *list; GSList *list;
gboolean found = FALSE; gboolean found = FALSE;
if (plug_in_def->locale_domain) if (plug_in_def->locale_domain)
{ {
@ -2580,7 +2582,7 @@ plug_in_make_menu (void)
} }
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
while (procs) while (procs)
{ {
proc_def = procs->data; proc_def = procs->data;
@ -2615,9 +2617,9 @@ static void
plug_in_callback (GtkWidget *widget, plug_in_callback (GtkWidget *widget,
gpointer client_data) gpointer client_data)
{ {
GDisplay *gdisplay; GDisplay *gdisplay;
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
gint i; gint i;
gint gdisp_ID = -1; gint gdisp_ID = -1;
gint argc = 0; /* calm down a gcc warning. */ gint argc = 0; /* calm down a gcc warning. */
@ -2625,11 +2627,10 @@ plug_in_callback (GtkWidget *widget,
/* get the active gdisplay */ /* get the active gdisplay */
gdisplay = gdisplay_active (); gdisplay = gdisplay_active ();
proc_rec = (ProcRecord*) client_data; proc_rec = (ProcRecord *) client_data;
/* construct the procedures arguments */ /* construct the procedures arguments */
args = g_new (Argument, proc_rec->num_args); args = g_new0 (Argument, proc_rec->num_args);
memset (args, 0, (sizeof (Argument) * proc_rec->num_args));
/* initialize the argument types */ /* initialize the argument types */
for (i = 0; i < proc_rec->num_args; i++) for (i = 0; i < proc_rec->num_args; i++)
@ -2706,11 +2707,12 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
void (*superceed_fn)(void*)) void (*superceed_fn)(void*))
{ {
PlugInProcDef *tmp_proc_def; PlugInProcDef *tmp_proc_def;
GSList *tmp, *prev; GSList *tmp;
GSList *prev;
GSList *list; GSList *list;
prev = NULL; prev = NULL;
tmp = proc_defs; tmp = proc_defs;
while (tmp) while (tmp)
{ {
@ -2725,14 +2727,14 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
if (proc_def->accelerator) if (proc_def->accelerator)
g_free (proc_def->accelerator); g_free (proc_def->accelerator);
proc_def->menu_path = tmp_proc_def->menu_path; proc_def->menu_path = tmp_proc_def->menu_path;
proc_def->accelerator = tmp_proc_def->accelerator; proc_def->accelerator = tmp_proc_def->accelerator;
tmp_proc_def->menu_path = NULL; tmp_proc_def->menu_path = NULL;
tmp_proc_def->accelerator = NULL; tmp_proc_def->accelerator = NULL;
if (superceed_fn) if (superceed_fn)
(*superceed_fn) (tmp_proc_def); (* superceed_fn) (tmp_proc_def);
plug_in_proc_def_destroy (tmp_proc_def, FALSE); plug_in_proc_def_destroy (tmp_proc_def, FALSE);
return; return;
@ -2760,27 +2762,27 @@ plug_in_proc_def_insert (PlugInProcDef *proc_def,
} }
/* called when plug_in_proc_def_insert causes a proc_def to be /* called when plug_in_proc_def_insert causes a proc_def to be
* overridden and thus g_free()d. */ * overridden and thus g_free()d.
*/
static void static void
plug_in_proc_def_dead (void *freed_proc_def) plug_in_proc_def_dead (void *freed_proc_def)
{ {
GSList *tmp; GSList *tmp;
PlugInDef *plug_in_def; PlugInDef *plug_in_def;
PlugInProcDef *proc_def = freed_proc_def; PlugInProcDef *proc_def = freed_proc_def;
g_warning ("removing duplicate PDB procedure \"%s\"", g_warning ("removing duplicate PDB procedure \"%s\"",
proc_def->db_info.name); proc_def->db_info.name);
/* search the plugin list to see if any plugins had references to /* search the plugin list to see if any plugins had references to
* the recently freed proc_def. */ * the recently freed proc_def.
tmp = plug_in_defs; */
while (tmp) for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{ {
plug_in_def = tmp->data; plug_in_def = tmp->data;
plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs, plug_in_def->proc_defs = g_slist_remove (plug_in_def->proc_defs,
freed_proc_def); freed_proc_def);
tmp = tmp->next;
} }
} }
@ -2864,10 +2866,10 @@ plug_in_temp_run (ProcRecord *proc_rec,
Argument *args, Argument *args,
gint argc) gint argc)
{ {
Argument *return_vals; Argument *return_vals;
PlugIn *plug_in; PlugIn *plug_in;
GPProcRun proc_run; GPProcRun proc_run;
gint old_recurse; gint old_recurse;
return_vals = NULL; return_vals = NULL;
@ -2884,9 +2886,9 @@ plug_in_temp_run (ProcRecord *proc_rec,
plug_in->busy = TRUE; plug_in->busy = TRUE;
plug_in_push (plug_in); plug_in_push (plug_in);
proc_run.name = proc_rec->name; proc_run.name = proc_rec->name;
proc_run.nparams = argc; proc_run.nparams = argc;
proc_run.params = plug_in_args_to_params (args, argc, FALSE); proc_run.params = plug_in_args_to_params (args, argc, FALSE);
if (!gp_temp_proc_run_write (current_writechannel, &proc_run) || if (!gp_temp_proc_run_write (current_writechannel, &proc_run) ||
!wire_flush (current_writechannel)) !wire_flush (current_writechannel))
@ -2919,9 +2921,9 @@ plug_in_params_to_args (GPParam *params,
gint nparams, gint nparams,
gboolean full_copy) gboolean full_copy)
{ {
Argument *args; Argument *args;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint count; gint count;
gint i, j; gint i, j;
@ -3018,7 +3020,7 @@ plug_in_params_to_args (GPParam *params,
break; break;
case PDB_COLOR: case PDB_COLOR:
args[i].value.pdb_pointer = g_new (guchar, 3); args[i].value.pdb_pointer = g_new (guchar, 3);
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
colorarray[0] = params[i].data.d_color.red; colorarray[0] = params[i].data.d_color.red;
colorarray[1] = params[i].data.d_color.green; colorarray[1] = params[i].data.d_color.green;
colorarray[2] = params[i].data.d_color.blue; colorarray[2] = params[i].data.d_color.blue;
@ -3070,12 +3072,12 @@ plug_in_params_to_args (GPParam *params,
static GPParam* static GPParam*
plug_in_args_to_params (Argument *args, plug_in_args_to_params (Argument *args,
gint nargs, gint nargs,
gboolean full_copy) gboolean full_copy)
{ {
GPParam *params; GPParam *params;
gchar **stringarray; gchar **stringarray;
guchar *colorarray; guchar *colorarray;
gint i, j; gint i, j;
if (nargs == 0) if (nargs == 0)
@ -3177,15 +3179,15 @@ plug_in_args_to_params (Argument *args,
colorarray = args[i].value.pdb_pointer; colorarray = args[i].value.pdb_pointer;
if( colorarray ) if( colorarray )
{ {
params[i].data.d_color.red = colorarray[0]; params[i].data.d_color.red = colorarray[0];
params[i].data.d_color.green = colorarray[1]; params[i].data.d_color.green = colorarray[1];
params[i].data.d_color.blue = colorarray[2]; params[i].data.d_color.blue = colorarray[2];
} }
else else
{ {
params[i].data.d_color.red = 0; params[i].data.d_color.red = 0;
params[i].data.d_color.green = 0; params[i].data.d_color.green = 0;
params[i].data.d_color.blue = 0; params[i].data.d_color.blue = 0;
} }
break; break;
case PDB_REGION: case PDB_REGION:
@ -3219,13 +3221,14 @@ plug_in_args_to_params (Argument *args,
if (full_copy) if (full_copy)
{ {
GimpParasite *tmp; GimpParasite *tmp;
tmp = gimp_parasite_copy (args[i].value.pdb_pointer); tmp = gimp_parasite_copy (args[i].value.pdb_pointer);
if (tmp == NULL) if (tmp == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
{ {
@ -3238,10 +3241,10 @@ plug_in_args_to_params (Argument *args,
{ {
if (args[i].value.pdb_pointer == NULL) if (args[i].value.pdb_pointer == NULL)
{ {
params[i].data.d_parasite.name = 0; params[i].data.d_parasite.name = 0;
params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.flags = 0;
params[i].data.d_parasite.size = 0; params[i].data.d_parasite.size = 0;
params[i].data.d_parasite.data = 0; params[i].data.d_parasite.data = 0;
} }
else else
memcpy (&params[i].data.d_parasite, memcpy (&params[i].data.d_parasite,
@ -3344,8 +3347,8 @@ plug_in_args_destroy (Argument *args,
gboolean full_destroy) gboolean full_destroy)
{ {
gchar **stringarray; gchar **stringarray;
gint count; gint count;
gint i, j; gint i, j;
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {

View File

@ -87,6 +87,9 @@ Enable debugging signal handlers.
Do not popup dialog boxes on errors or warnings. Print the messages on Do not popup dialog boxes on errors or warnings. Print the messages on
the console instead. the console instead.
.TP 8 .TP 8
.B \-\-enable\-stack\-trace \fI{never|query|always}\fP
If a stack-trace should be generated in case of fatal signals.
.TP 8
.B \-\-system\-gimprc \fI<gimprc>\fP .B \-\-system\-gimprc \fI<gimprc>\fP
Use an alternate system gimprc file. Use an alternate system gimprc file.
@ -277,7 +280,6 @@ Tom Bech,
Marc Bless, Marc Bless,
Edward Blevins, Edward Blevins,
Reagan Blundell, Reagan Blundell,
Andreas Bogk,
Xavier Bouchoux, Xavier Bouchoux,
Roberto Boyd, Roberto Boyd,
Stanislav Brabec, Stanislav Brabec,
@ -337,7 +339,6 @@ Andrew Kieschnick,
Peter Kirchgessner, Peter Kirchgessner,
Philipp Klaus, Philipp Klaus,
David Koblas, David Koblas,
Vincent Kolwitz,
Tuomas Kuosmanen, Tuomas Kuosmanen,
Karin Kylander, Karin Kylander,
Olof S Kylander, Olof S Kylander,

View File

@ -87,6 +87,9 @@ Enable debugging signal handlers.
Do not popup dialog boxes on errors or warnings. Print the messages on Do not popup dialog boxes on errors or warnings. Print the messages on
the console instead. the console instead.
.TP 8 .TP 8
.B \-\-enable\-stack\-trace \fI{never|query|always}\fP
If a stack-trace should be generated in case of fatal signals.
.TP 8
.B \-\-system\-gimprc \fI<gimprc>\fP .B \-\-system\-gimprc \fI<gimprc>\fP
Use an alternate system gimprc file. Use an alternate system gimprc file.
@ -277,7 +280,6 @@ Tom Bech,
Marc Bless, Marc Bless,
Edward Blevins, Edward Blevins,
Reagan Blundell, Reagan Blundell,
Andreas Bogk,
Xavier Bouchoux, Xavier Bouchoux,
Roberto Boyd, Roberto Boyd,
Stanislav Brabec, Stanislav Brabec,
@ -337,7 +339,6 @@ Andrew Kieschnick,
Peter Kirchgessner, Peter Kirchgessner,
Philipp Klaus, Philipp Klaus,
David Koblas, David Koblas,
Vincent Kolwitz,
Tuomas Kuosmanen, Tuomas Kuosmanen,
Karin Kylander, Karin Kylander,
Olof S Kylander, Olof S Kylander,

View File

@ -139,6 +139,8 @@ static gchar *progname = NULL;
static guint8 write_buffer[WRITE_BUFFER_SIZE]; static guint8 write_buffer[WRITE_BUFFER_SIZE];
static guint write_buffer_index = 0; static guint write_buffer_index = 0;
static GimpStackTraceMode stack_trace_mode = GIMP_STACK_TRACE_NEVER;
static GHashTable *temp_proc_ht = NULL; static GHashTable *temp_proc_ht = NULL;
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
@ -208,9 +210,9 @@ gimp_main (int argc,
} }
#endif #endif
if ((argc < 4) || (strcmp (argv[1], "-gimp") != 0)) if ((argc != 6) || (strcmp (argv[1], "-gimp") != 0))
{ {
g_print ("%s is a gimp plug-in and must be run by the gimp to be used\n", argv[0]); g_printerr ("%s is a gimp plug-in and must be run by the gimp to be used\n", argv[0]);
return 1; return 1;
} }
@ -240,26 +242,27 @@ gimp_main (int argc,
#endif #endif
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
_readchannel = g_io_channel_unix_new (atoi (argv[2])); _readchannel = g_io_channel_unix_new (atoi (argv[2]));
_writechannel = g_io_channel_unix_new (atoi (argv[3])); _writechannel = g_io_channel_unix_new (atoi (argv[3]));
#ifdef __EMX__ #ifdef __EMX__
setmode(g_io_channel_unix_get_fd(_readchannel), O_BINARY); setmode (g_io_channel_unix_get_fd (_readchannel), O_BINARY);
setmode(g_io_channel_unix_get_fd(_writechannel), O_BINARY); setmode (g_io_channel_unix_get_fd (_writechannel), O_BINARY);
#endif #endif
#else #else
g_assert (PLUG_IN_INFO_PTR != NULL); g_assert (PLUG_IN_INFO_PTR != NULL);
_readchannel = g_io_channel_win32_new_pipe (atoi (argv[2])); _readchannel = g_io_channel_win32_new_pipe (atoi (argv[2]));
peer = strchr (argv[3], ':') + 1; peer = strchr (argv[3], ':') + 1;
peer_fd = strchr (peer, ':') + 1; peer_fd = strchr (peer, ':') + 1;
_writechannel = g_io_channel_win32_new_pipe_with_wakeups _writechannel = g_io_channel_win32_new_pipe_with_wakeups (atoi (argv[3]),
(atoi (argv[3]), atoi (peer), atoi (peer_fd)); atoi (peer),
atoi (peer_fd));
#endif #endif
gp_init (); gp_init ();
wire_set_writer (gimp_write); wire_set_writer (gimp_write);
wire_set_flusher (gimp_flush); wire_set_flusher (gimp_flush);
if ((argc == 5) && (strcmp (argv[4], "-query") == 0)) if (strcmp (argv[4], "-query") == 0)
{ {
if (PLUG_IN_INFO.query_proc) if (PLUG_IN_INFO.query_proc)
(* PLUG_IN_INFO.query_proc) (); (* PLUG_IN_INFO.query_proc) ();
@ -267,6 +270,10 @@ gimp_main (int argc,
return 0; return 0;
} }
stack_trace_mode = (GimpStackTraceMode) CLAMP (atoi (argv[5]),
GIMP_STACK_TRACE_NEVER,
GIMP_STACK_TRACE_ALWAYS);
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
/* Tell the GIMP our thread id */ /* Tell the GIMP our thread id */
thread = GetCurrentThreadId (); thread = GetCurrentThreadId ();
@ -872,7 +879,7 @@ gimp_plugin_sigfatal_handler (gint sig_num)
case SIGQUIT: case SIGQUIT:
case SIGABRT: case SIGABRT:
case SIGTERM: case SIGTERM:
g_print ("%s terminated: %s\n", progname, g_strsignal (sig_num)); g_printerr ("%s terminated: %s\n", progname, g_strsignal (sig_num));
break; break;
case SIGBUS: case SIGBUS:
@ -880,14 +887,31 @@ gimp_plugin_sigfatal_handler (gint sig_num)
case SIGFPE: case SIGFPE:
case SIGPIPE: case SIGPIPE:
default: default:
g_print ("%s: fatal error: %s\n", progname, g_strsignal (sig_num)); g_printerr ("%s: fatal error: %s\n", progname, g_strsignal (sig_num));
if (TRUE) switch (stack_trace_mode)
{ {
sigset_t sigset; case GIMP_STACK_TRACE_NEVER:
break;
sigemptyset (&sigset); case GIMP_STACK_TRACE_QUERY:
sigprocmask (SIG_SETMASK, &sigset, NULL); {
g_on_error_query (progname); sigset_t sigset;
sigemptyset (&sigset);
sigprocmask (SIG_SETMASK, &sigset, NULL);
g_on_error_query (progname);
}
break;
case GIMP_STACK_TRACE_ALWAYS:
{
sigset_t sigset;
sigemptyset (&sigset);
sigprocmask (SIG_SETMASK, &sigset, NULL);
g_on_error_stack_trace (progname);
}
break;
} }
break; break;
} }
@ -916,7 +940,7 @@ gimp_plugin_io_error_handler (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
gpointer data) gpointer data)
{ {
g_print ("%s: fatal error: GIMP crashed\n", progname); g_printerr ("%s: fatal error: GIMP crashed\n", progname);
gimp_quit (); gimp_quit ();
/* never reached */ /* never reached */

View File

@ -325,6 +325,13 @@ typedef enum
GIMP_POINTS GIMP_POINTS
} GimpSizeType; } GimpSizeType;
typedef enum
{
GIMP_STACK_TRACE_NEVER,
GIMP_STACK_TRACE_QUERY,
GIMP_STACK_TRACE_ALWAYS
} GimpStackTraceMode;
typedef enum typedef enum
{ {
GIMP_SHADOWS, GIMP_SHADOWS,

View File

@ -5,7 +5,7 @@
* *
* Copyright (C) 1999 Andy Thomas alt@picnic.demon.co.uk * Copyright (C) 1999 Andy Thomas alt@picnic.demon.co.uk
* *
* Note some portions of th UI comes from the dbbrowser plugin. * Note some portions of the UI comes from the dbbrowser plugin.
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@ -52,11 +52,11 @@ static gchar *proc_type_str[] =
/* Declare some local functions. /* Declare some local functions.
*/ */
static void query (void); static void query (void);
static void run (gchar *name, static void run (gchar *name,
gint nparams, gint nparams,
GParam *param, GimpParam *param,
gint *nreturn_vals, gint *nreturn_vals,
GParam **return_vals); GimpParam **return_vals);
static GtkWidget * gimp_plugin_desc (void); static GtkWidget * gimp_plugin_desc (void);
@ -70,7 +70,7 @@ static gint procedure_ctree_select_callback (GtkWidget *widget,
gint column, gint column,
gpointer data); gpointer data);
GPlugInInfo PLUG_IN_INFO = GimpPlugInInfo PLUG_IN_INFO =
{ {
NULL, /* init_proc */ NULL, /* init_proc */
NULL, /* quit_proc */ NULL, /* quit_proc */
@ -84,15 +84,20 @@ MAIN ()
static void static void
query (void) query (void)
{ {
static GParamDef args[] = static GimpParamDef args[] =
{ {
{ PARAM_INT32, "run_mode", "Interactive, [non-interactive]" } { GIMP_PDB_INT32, "run_mode", "Interactive, [non-interactive]" }
}; };
static gint nargs = sizeof (args) / sizeof (args[0]); static gint nargs = sizeof (args) / sizeof (args[0]);
gimp_install_procedure ("plug_in_details", gimp_install_procedure ("plug_in_details",
"Displays plugin details", "Displays plugin details",
"Helps browse the plugin menus system. You can search for plugin names, sort by name or menu location and you can view a tree representation of the plugin menus. Can also be of help to find where new plugins have installed themselves in the menuing system", "Helps browse the plugin menus system. You can "
"search for plugin names, sort by name or menu "
"location and you can view a tree representation "
"of the plugin menus. Can also be of help to find "
"where new plugins have installed themselves in "
"the menuing system",
"Andy Thomas", "Andy Thomas",
"Andy Thomas", "Andy Thomas",
"1999", "1999",
@ -104,22 +109,22 @@ query (void)
} }
static void static void
run (gchar *name, run (gchar *name,
gint nparams, gint nparams,
GParam *param, GimpParam *param,
gint *nreturn_vals, gint *nreturn_vals,
GParam **return_vals) GimpParam **return_vals)
{ {
static GParam values[2]; static GimpParam values[2];
GRunModeType run_mode; GimpRunModeType run_mode;
GtkWidget *plugin_dialog; GtkWidget *plugin_dialog;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
*nreturn_vals = 1; *nreturn_vals = 1;
*return_vals = values; *return_vals = values;
values[0].type = PARAM_STATUS; values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = STATUS_CALLING_ERROR; values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
INIT_I18N_UI(); INIT_I18N_UI();
@ -127,7 +132,7 @@ run (gchar *name,
{ {
*nreturn_vals = 1; *nreturn_vals = 1;
values[0].data.d_status = STATUS_SUCCESS; values[0].data.d_status = GIMP_PDB_SUCCESS;
plugin_dialog = gimp_plugin_desc (); plugin_dialog = gimp_plugin_desc ();
@ -233,13 +238,13 @@ details_callback (GtkWidget *widget,
static gchar * static gchar *
format_menu_path (gchar *s) format_menu_path (gchar *s)
{ {
gchar ** str_array; gchar **str_array;
gchar *newstr = NULL; gchar *newstr = NULL;
if (!s) if (!s)
return s; return s;
str_array = g_strsplit (s,"/",0); str_array = g_strsplit (s, "/", 0);
newstr = g_strjoinv ("->", str_array); newstr = g_strjoinv ("->", str_array);
@ -277,16 +282,16 @@ procedure_general_select_callback (PDesc *pdesc,
if (pdesc->descr_scroll == NULL) if (pdesc->descr_scroll == NULL)
return FALSE; return FALSE;
selected_proc_blurb = NULL; selected_proc_blurb = NULL;
selected_proc_help = NULL; selected_proc_help = NULL;
selected_proc_author = NULL; selected_proc_author = NULL;
selected_proc_copyright = NULL; selected_proc_copyright = NULL;
selected_proc_date = NULL; selected_proc_date = NULL;
selected_proc_type = 0; selected_proc_type = 0;
selected_nparams = 0; selected_nparams = 0;
selected_nreturn_vals = 0; selected_nreturn_vals = 0;
selected_params = NULL; selected_params = NULL;
selected_return_vals = NULL; selected_return_vals = NULL;
gimp_query_procedure (pinfo->realname, gimp_query_procedure (pinfo->realname,
&selected_proc_blurb, &selected_proc_blurb,
@ -486,7 +491,7 @@ procedure_general_select_callback (PDesc *pdesc,
g_free (selected_params); g_free (selected_params);
if (selected_return_vals) if (selected_return_vals)
g_free (selected_return_vals); g_free (selected_return_vals);
return FALSE; return FALSE;
} }
@ -544,7 +549,8 @@ procedure_clist_select_callback (GtkWidget *widget,
gtk_widget_show (pdesc->ctree); gtk_widget_show (pdesc->ctree);
gtk_signal_handler_block_by_func (GTK_OBJECT(pdesc->ctree), gtk_signal_handler_block_by_func (GTK_OBJECT(pdesc->ctree),
(GtkSignalFunc)procedure_ctree_select_callback, pdesc); GTK_SIGNAL_FUNC (procedure_ctree_select_callback),
pdesc);
gtk_clist_select_row (GTK_CLIST (pdesc->ctree), sel_row, -1); gtk_clist_select_row (GTK_CLIST (pdesc->ctree), sel_row, -1);
gtk_ctree_select (GTK_CTREE (pdesc->ctree), found_node); gtk_ctree_select (GTK_CTREE (pdesc->ctree), found_node);
@ -555,7 +561,8 @@ procedure_clist_select_callback (GtkWidget *widget,
0.5, 0.5); 0.5, 0.5);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (pdesc->ctree), gtk_signal_handler_unblock_by_func (GTK_OBJECT (pdesc->ctree),
(GtkSignalFunc)procedure_ctree_select_callback, pdesc); GTK_SIGNAL_FUNC (procedure_ctree_select_callback),
pdesc);
pdesc->ctree_row = sel_row; pdesc->ctree_row = sel_row;
} }
@ -640,7 +647,8 @@ procedure_ctree_select_callback (GtkWidget *widget,
/* Block signals */ /* Block signals */
gtk_signal_handler_block_by_func (GTK_OBJECT (pdesc->clist), gtk_signal_handler_block_by_func (GTK_OBJECT (pdesc->clist),
(GtkSignalFunc)procedure_clist_select_callback, pdesc); GTK_SIGNAL_FUNC (procedure_clist_select_callback),
pdesc);
sel_row = gtk_clist_find_row_from_data (GTK_CLIST (pdesc->clist), pinfo); sel_row = gtk_clist_find_row_from_data (GTK_CLIST (pdesc->clist), pinfo);
gtk_clist_select_row (GTK_CLIST (pdesc->clist), sel_row, -1); gtk_clist_select_row (GTK_CLIST (pdesc->clist), sel_row, -1);
@ -650,7 +658,8 @@ procedure_ctree_select_callback (GtkWidget *widget,
0.5, 0.5); 0.5, 0.5);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (pdesc->clist), gtk_signal_handler_unblock_by_func (GTK_OBJECT (pdesc->clist),
(GtkSignalFunc)procedure_clist_select_callback, pdesc); GTK_SIGNAL_FUNC (procedure_clist_select_callback),
pdesc);
pdesc->clist_row = sel_row; pdesc->clist_row = sel_row;
@ -670,7 +679,7 @@ pinfo_free (gpointer p)
g_free (pinfo); g_free (pinfo);
} }
static GtkCTreeNode* static GtkCTreeNode *
get_parent (PDesc *pdesc, get_parent (PDesc *pdesc,
GHashTable *ghash, GHashTable *ghash,
gchar *mpath) gchar *mpath)
@ -820,12 +829,12 @@ get_plugin_info (PDesc *pdesc,
{ {
int loop; int loop;
pdesc->num_plugins = return_vals[1].data.d_int32; pdesc->num_plugins = return_vals[1].data.d_int32;
menu_strs = return_vals[2].data.d_stringarray; menu_strs = return_vals[2].data.d_stringarray;
accel_strs = return_vals[4].data.d_stringarray; accel_strs = return_vals[4].data.d_stringarray;
prog_strs = return_vals[6].data.d_stringarray; prog_strs = return_vals[6].data.d_stringarray;
types_strs = return_vals[8].data.d_stringarray; types_strs = return_vals[8].data.d_stringarray;
time_ints = return_vals[10].data.d_int32array; time_ints = return_vals[10].data.d_int32array;
realname_strs = return_vals[12].data.d_stringarray; realname_strs = return_vals[12].data.d_stringarray;
for (loop = 0; loop < return_vals[1].data.d_int32; loop++) for (loop = 0; loop < return_vals[1].data.d_int32; loop++)
{ {
@ -856,11 +865,11 @@ get_plugin_info (PDesc *pdesc,
else else
strcpy (xtimestr,""); strcpy (xtimestr,"");
pinfo->menu = g_strdup (menu_strs[loop]); pinfo->menu = g_strdup (menu_strs[loop]);
pinfo->accel = g_strdup (accel_strs[loop]); pinfo->accel = g_strdup (accel_strs[loop]);
pinfo->prog = g_strdup (prog_strs[loop]); pinfo->prog = g_strdup (prog_strs[loop]);
pinfo->types = g_strdup (types_strs[loop]); pinfo->types = g_strdup (types_strs[loop]);
pinfo->instime = time_ints[loop]; pinfo->instime = time_ints[loop];
pinfo->realname = g_strdup (realname_strs[loop]); pinfo->realname = g_strdup (realname_strs[loop]);
labels[0] = g_strdup (name); labels[0] = g_strdup (name);
@ -1035,7 +1044,8 @@ gimp_plugin_desc (void)
plugindesc->clist = gtk_clist_new_with_titles (4, clabels); plugindesc->clist = gtk_clist_new_with_titles (4, clabels);
gtk_signal_connect (GTK_OBJECT (plugindesc->clist), "click_column", gtk_signal_connect (GTK_OBJECT (plugindesc->clist), "click_column",
(GtkSignalFunc) clist_click_column, NULL); GTK_SIGNAL_FUNC (clist_click_column),
NULL);
gtk_clist_column_titles_show (GTK_CLIST (plugindesc->clist)); gtk_clist_column_titles_show (GTK_CLIST (plugindesc->clist));
swindow = gtk_scrolled_window_new (NULL, NULL); swindow = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow), gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
@ -1045,7 +1055,7 @@ gimp_plugin_desc (void)
gtk_widget_set_usize (plugindesc->clist, DBL_LIST_WIDTH, DBL_HEIGHT); gtk_widget_set_usize (plugindesc->clist, DBL_LIST_WIDTH, DBL_HEIGHT);
gtk_signal_connect (GTK_OBJECT (plugindesc->clist), "select_row", gtk_signal_connect (GTK_OBJECT (plugindesc->clist), "select_row",
(GtkSignalFunc) procedure_clist_select_callback, GTK_SIGNAL_FUNC (procedure_clist_select_callback),
plugindesc); plugindesc);
label = gtk_label_new (_("List View")); label = gtk_label_new (_("List View"));
@ -1063,21 +1073,24 @@ gimp_plugin_desc (void)
swindow = gtk_scrolled_window_new (NULL, NULL); swindow = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow), gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_set_usize(plugindesc->ctree, DBL_LIST_WIDTH, DBL_HEIGHT); gtk_widget_set_usize (plugindesc->ctree, DBL_LIST_WIDTH, DBL_HEIGHT);
gtk_signal_connect (GTK_OBJECT (plugindesc->ctree), "tree_select_row", gtk_signal_connect (GTK_OBJECT (plugindesc->ctree), "tree_select_row",
(GtkSignalFunc) procedure_ctree_select_callback, GTK_SIGNAL_FUNC (procedure_ctree_select_callback),
plugindesc); plugindesc);
label = gtk_label_new (_("Tree View"));
gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 0, TRUE); gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 0, TRUE);
gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 1, TRUE); gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 1, TRUE);
gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 2, TRUE); gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 2, TRUE);
gtk_clist_column_titles_passive (GTK_CLIST (plugindesc->ctree));
label = gtk_label_new (_("Tree View"));
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), swindow, label); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), swindow, label);
gtk_container_add (GTK_CONTAINER (swindow), plugindesc->ctree); gtk_container_add (GTK_CONTAINER (swindow), plugindesc->ctree);
gtk_widget_show (plugindesc->ctree); gtk_widget_show (plugindesc->ctree);
gtk_widget_show (swindow); gtk_widget_show (swindow);
gtk_signal_connect_after (GTK_OBJECT (notebook), "switch_page", gtk_signal_connect_after (GTK_OBJECT (notebook), "switch_page",
(GtkSignalFunc) page_select_callback, GTK_SIGNAL_FUNC (page_select_callback),
plugindesc); plugindesc);
gtk_widget_show (notebook); gtk_widget_show (notebook);
@ -1102,11 +1115,12 @@ gimp_plugin_desc (void)
button = gtk_button_new_with_label (_("Details >>")); button = gtk_button_new_with_label (_("Details >>"));
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
gtk_widget_show (button);
gtk_signal_connect (GTK_OBJECT (button), "clicked", gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) details_callback, plugindesc); GTK_SIGNAL_FUNC (details_callback),
gtk_box_pack_start (GTK_BOX (searchhbox), plugindesc);
button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (searchhbox), button,
FALSE, FALSE, 0);
gtk_widget_show (button);
/* right = description */ /* right = description */
/* the right description is build on first click of the Details button */ /* the right description is build on first click of the Details button */
@ -1114,6 +1128,9 @@ gimp_plugin_desc (void)
/* now build the list */ /* now build the list */
dialog_search_callback (NULL, (gpointer) plugindesc); dialog_search_callback (NULL, (gpointer) plugindesc);
gtk_clist_set_selection_mode (GTK_CLIST (plugindesc->ctree),
GTK_SELECTION_BROWSE);
gtk_widget_show (plugindesc->clist); gtk_widget_show (plugindesc->clist);
gtk_widget_show (plugindesc->dlg); gtk_widget_show (plugindesc->dlg);

View File

@ -5,7 +5,7 @@
* *
* Copyright (C) 1999 Andy Thomas alt@picnic.demon.co.uk * Copyright (C) 1999 Andy Thomas alt@picnic.demon.co.uk
* *
* Note some portions of th UI comes from the dbbrowser plugin. * Note some portions of the UI comes from the dbbrowser plugin.
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@ -52,11 +52,11 @@ static gchar *proc_type_str[] =
/* Declare some local functions. /* Declare some local functions.
*/ */
static void query (void); static void query (void);
static void run (gchar *name, static void run (gchar *name,
gint nparams, gint nparams,
GParam *param, GimpParam *param,
gint *nreturn_vals, gint *nreturn_vals,
GParam **return_vals); GimpParam **return_vals);
static GtkWidget * gimp_plugin_desc (void); static GtkWidget * gimp_plugin_desc (void);
@ -70,7 +70,7 @@ static gint procedure_ctree_select_callback (GtkWidget *widget,
gint column, gint column,
gpointer data); gpointer data);
GPlugInInfo PLUG_IN_INFO = GimpPlugInInfo PLUG_IN_INFO =
{ {
NULL, /* init_proc */ NULL, /* init_proc */
NULL, /* quit_proc */ NULL, /* quit_proc */
@ -84,15 +84,20 @@ MAIN ()
static void static void
query (void) query (void)
{ {
static GParamDef args[] = static GimpParamDef args[] =
{ {
{ PARAM_INT32, "run_mode", "Interactive, [non-interactive]" } { GIMP_PDB_INT32, "run_mode", "Interactive, [non-interactive]" }
}; };
static gint nargs = sizeof (args) / sizeof (args[0]); static gint nargs = sizeof (args) / sizeof (args[0]);
gimp_install_procedure ("plug_in_details", gimp_install_procedure ("plug_in_details",
"Displays plugin details", "Displays plugin details",
"Helps browse the plugin menus system. You can search for plugin names, sort by name or menu location and you can view a tree representation of the plugin menus. Can also be of help to find where new plugins have installed themselves in the menuing system", "Helps browse the plugin menus system. You can "
"search for plugin names, sort by name or menu "
"location and you can view a tree representation "
"of the plugin menus. Can also be of help to find "
"where new plugins have installed themselves in "
"the menuing system",
"Andy Thomas", "Andy Thomas",
"Andy Thomas", "Andy Thomas",
"1999", "1999",
@ -104,22 +109,22 @@ query (void)
} }
static void static void
run (gchar *name, run (gchar *name,
gint nparams, gint nparams,
GParam *param, GimpParam *param,
gint *nreturn_vals, gint *nreturn_vals,
GParam **return_vals) GimpParam **return_vals)
{ {
static GParam values[2]; static GimpParam values[2];
GRunModeType run_mode; GimpRunModeType run_mode;
GtkWidget *plugin_dialog; GtkWidget *plugin_dialog;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
*nreturn_vals = 1; *nreturn_vals = 1;
*return_vals = values; *return_vals = values;
values[0].type = PARAM_STATUS; values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = STATUS_CALLING_ERROR; values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
INIT_I18N_UI(); INIT_I18N_UI();
@ -127,7 +132,7 @@ run (gchar *name,
{ {
*nreturn_vals = 1; *nreturn_vals = 1;
values[0].data.d_status = STATUS_SUCCESS; values[0].data.d_status = GIMP_PDB_SUCCESS;
plugin_dialog = gimp_plugin_desc (); plugin_dialog = gimp_plugin_desc ();
@ -233,13 +238,13 @@ details_callback (GtkWidget *widget,
static gchar * static gchar *
format_menu_path (gchar *s) format_menu_path (gchar *s)
{ {
gchar ** str_array; gchar **str_array;
gchar *newstr = NULL; gchar *newstr = NULL;
if (!s) if (!s)
return s; return s;
str_array = g_strsplit (s,"/",0); str_array = g_strsplit (s, "/", 0);
newstr = g_strjoinv ("->", str_array); newstr = g_strjoinv ("->", str_array);
@ -277,16 +282,16 @@ procedure_general_select_callback (PDesc *pdesc,
if (pdesc->descr_scroll == NULL) if (pdesc->descr_scroll == NULL)
return FALSE; return FALSE;
selected_proc_blurb = NULL; selected_proc_blurb = NULL;
selected_proc_help = NULL; selected_proc_help = NULL;
selected_proc_author = NULL; selected_proc_author = NULL;
selected_proc_copyright = NULL; selected_proc_copyright = NULL;
selected_proc_date = NULL; selected_proc_date = NULL;
selected_proc_type = 0; selected_proc_type = 0;
selected_nparams = 0; selected_nparams = 0;
selected_nreturn_vals = 0; selected_nreturn_vals = 0;
selected_params = NULL; selected_params = NULL;
selected_return_vals = NULL; selected_return_vals = NULL;
gimp_query_procedure (pinfo->realname, gimp_query_procedure (pinfo->realname,
&selected_proc_blurb, &selected_proc_blurb,
@ -486,7 +491,7 @@ procedure_general_select_callback (PDesc *pdesc,
g_free (selected_params); g_free (selected_params);
if (selected_return_vals) if (selected_return_vals)
g_free (selected_return_vals); g_free (selected_return_vals);
return FALSE; return FALSE;
} }
@ -544,7 +549,8 @@ procedure_clist_select_callback (GtkWidget *widget,
gtk_widget_show (pdesc->ctree); gtk_widget_show (pdesc->ctree);
gtk_signal_handler_block_by_func (GTK_OBJECT(pdesc->ctree), gtk_signal_handler_block_by_func (GTK_OBJECT(pdesc->ctree),
(GtkSignalFunc)procedure_ctree_select_callback, pdesc); GTK_SIGNAL_FUNC (procedure_ctree_select_callback),
pdesc);
gtk_clist_select_row (GTK_CLIST (pdesc->ctree), sel_row, -1); gtk_clist_select_row (GTK_CLIST (pdesc->ctree), sel_row, -1);
gtk_ctree_select (GTK_CTREE (pdesc->ctree), found_node); gtk_ctree_select (GTK_CTREE (pdesc->ctree), found_node);
@ -555,7 +561,8 @@ procedure_clist_select_callback (GtkWidget *widget,
0.5, 0.5); 0.5, 0.5);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (pdesc->ctree), gtk_signal_handler_unblock_by_func (GTK_OBJECT (pdesc->ctree),
(GtkSignalFunc)procedure_ctree_select_callback, pdesc); GTK_SIGNAL_FUNC (procedure_ctree_select_callback),
pdesc);
pdesc->ctree_row = sel_row; pdesc->ctree_row = sel_row;
} }
@ -640,7 +647,8 @@ procedure_ctree_select_callback (GtkWidget *widget,
/* Block signals */ /* Block signals */
gtk_signal_handler_block_by_func (GTK_OBJECT (pdesc->clist), gtk_signal_handler_block_by_func (GTK_OBJECT (pdesc->clist),
(GtkSignalFunc)procedure_clist_select_callback, pdesc); GTK_SIGNAL_FUNC (procedure_clist_select_callback),
pdesc);
sel_row = gtk_clist_find_row_from_data (GTK_CLIST (pdesc->clist), pinfo); sel_row = gtk_clist_find_row_from_data (GTK_CLIST (pdesc->clist), pinfo);
gtk_clist_select_row (GTK_CLIST (pdesc->clist), sel_row, -1); gtk_clist_select_row (GTK_CLIST (pdesc->clist), sel_row, -1);
@ -650,7 +658,8 @@ procedure_ctree_select_callback (GtkWidget *widget,
0.5, 0.5); 0.5, 0.5);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (pdesc->clist), gtk_signal_handler_unblock_by_func (GTK_OBJECT (pdesc->clist),
(GtkSignalFunc)procedure_clist_select_callback, pdesc); GTK_SIGNAL_FUNC (procedure_clist_select_callback),
pdesc);
pdesc->clist_row = sel_row; pdesc->clist_row = sel_row;
@ -670,7 +679,7 @@ pinfo_free (gpointer p)
g_free (pinfo); g_free (pinfo);
} }
static GtkCTreeNode* static GtkCTreeNode *
get_parent (PDesc *pdesc, get_parent (PDesc *pdesc,
GHashTable *ghash, GHashTable *ghash,
gchar *mpath) gchar *mpath)
@ -820,12 +829,12 @@ get_plugin_info (PDesc *pdesc,
{ {
int loop; int loop;
pdesc->num_plugins = return_vals[1].data.d_int32; pdesc->num_plugins = return_vals[1].data.d_int32;
menu_strs = return_vals[2].data.d_stringarray; menu_strs = return_vals[2].data.d_stringarray;
accel_strs = return_vals[4].data.d_stringarray; accel_strs = return_vals[4].data.d_stringarray;
prog_strs = return_vals[6].data.d_stringarray; prog_strs = return_vals[6].data.d_stringarray;
types_strs = return_vals[8].data.d_stringarray; types_strs = return_vals[8].data.d_stringarray;
time_ints = return_vals[10].data.d_int32array; time_ints = return_vals[10].data.d_int32array;
realname_strs = return_vals[12].data.d_stringarray; realname_strs = return_vals[12].data.d_stringarray;
for (loop = 0; loop < return_vals[1].data.d_int32; loop++) for (loop = 0; loop < return_vals[1].data.d_int32; loop++)
{ {
@ -856,11 +865,11 @@ get_plugin_info (PDesc *pdesc,
else else
strcpy (xtimestr,""); strcpy (xtimestr,"");
pinfo->menu = g_strdup (menu_strs[loop]); pinfo->menu = g_strdup (menu_strs[loop]);
pinfo->accel = g_strdup (accel_strs[loop]); pinfo->accel = g_strdup (accel_strs[loop]);
pinfo->prog = g_strdup (prog_strs[loop]); pinfo->prog = g_strdup (prog_strs[loop]);
pinfo->types = g_strdup (types_strs[loop]); pinfo->types = g_strdup (types_strs[loop]);
pinfo->instime = time_ints[loop]; pinfo->instime = time_ints[loop];
pinfo->realname = g_strdup (realname_strs[loop]); pinfo->realname = g_strdup (realname_strs[loop]);
labels[0] = g_strdup (name); labels[0] = g_strdup (name);
@ -1035,7 +1044,8 @@ gimp_plugin_desc (void)
plugindesc->clist = gtk_clist_new_with_titles (4, clabels); plugindesc->clist = gtk_clist_new_with_titles (4, clabels);
gtk_signal_connect (GTK_OBJECT (plugindesc->clist), "click_column", gtk_signal_connect (GTK_OBJECT (plugindesc->clist), "click_column",
(GtkSignalFunc) clist_click_column, NULL); GTK_SIGNAL_FUNC (clist_click_column),
NULL);
gtk_clist_column_titles_show (GTK_CLIST (plugindesc->clist)); gtk_clist_column_titles_show (GTK_CLIST (plugindesc->clist));
swindow = gtk_scrolled_window_new (NULL, NULL); swindow = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow), gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
@ -1045,7 +1055,7 @@ gimp_plugin_desc (void)
gtk_widget_set_usize (plugindesc->clist, DBL_LIST_WIDTH, DBL_HEIGHT); gtk_widget_set_usize (plugindesc->clist, DBL_LIST_WIDTH, DBL_HEIGHT);
gtk_signal_connect (GTK_OBJECT (plugindesc->clist), "select_row", gtk_signal_connect (GTK_OBJECT (plugindesc->clist), "select_row",
(GtkSignalFunc) procedure_clist_select_callback, GTK_SIGNAL_FUNC (procedure_clist_select_callback),
plugindesc); plugindesc);
label = gtk_label_new (_("List View")); label = gtk_label_new (_("List View"));
@ -1063,21 +1073,24 @@ gimp_plugin_desc (void)
swindow = gtk_scrolled_window_new (NULL, NULL); swindow = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow), gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_set_usize(plugindesc->ctree, DBL_LIST_WIDTH, DBL_HEIGHT); gtk_widget_set_usize (plugindesc->ctree, DBL_LIST_WIDTH, DBL_HEIGHT);
gtk_signal_connect (GTK_OBJECT (plugindesc->ctree), "tree_select_row", gtk_signal_connect (GTK_OBJECT (plugindesc->ctree), "tree_select_row",
(GtkSignalFunc) procedure_ctree_select_callback, GTK_SIGNAL_FUNC (procedure_ctree_select_callback),
plugindesc); plugindesc);
label = gtk_label_new (_("Tree View"));
gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 0, TRUE); gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 0, TRUE);
gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 1, TRUE); gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 1, TRUE);
gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 2, TRUE); gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 2, TRUE);
gtk_clist_column_titles_passive (GTK_CLIST (plugindesc->ctree));
label = gtk_label_new (_("Tree View"));
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), swindow, label); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), swindow, label);
gtk_container_add (GTK_CONTAINER (swindow), plugindesc->ctree); gtk_container_add (GTK_CONTAINER (swindow), plugindesc->ctree);
gtk_widget_show (plugindesc->ctree); gtk_widget_show (plugindesc->ctree);
gtk_widget_show (swindow); gtk_widget_show (swindow);
gtk_signal_connect_after (GTK_OBJECT (notebook), "switch_page", gtk_signal_connect_after (GTK_OBJECT (notebook), "switch_page",
(GtkSignalFunc) page_select_callback, GTK_SIGNAL_FUNC (page_select_callback),
plugindesc); plugindesc);
gtk_widget_show (notebook); gtk_widget_show (notebook);
@ -1102,11 +1115,12 @@ gimp_plugin_desc (void)
button = gtk_button_new_with_label (_("Details >>")); button = gtk_button_new_with_label (_("Details >>"));
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
gtk_widget_show (button);
gtk_signal_connect (GTK_OBJECT (button), "clicked", gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) details_callback, plugindesc); GTK_SIGNAL_FUNC (details_callback),
gtk_box_pack_start (GTK_BOX (searchhbox), plugindesc);
button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (searchhbox), button,
FALSE, FALSE, 0);
gtk_widget_show (button);
/* right = description */ /* right = description */
/* the right description is build on first click of the Details button */ /* the right description is build on first click of the Details button */
@ -1114,6 +1128,9 @@ gimp_plugin_desc (void)
/* now build the list */ /* now build the list */
dialog_search_callback (NULL, (gpointer) plugindesc); dialog_search_callback (NULL, (gpointer) plugindesc);
gtk_clist_set_selection_mode (GTK_CLIST (plugindesc->ctree),
GTK_SELECTION_BROWSE);
gtk_widget_show (plugindesc->clist); gtk_widget_show (plugindesc->clist);
gtk_widget_show (plugindesc->dlg); gtk_widget_show (plugindesc->dlg);

View File

@ -5,7 +5,7 @@
* *
* Copyright (C) 1999 Andy Thomas alt@picnic.demon.co.uk * Copyright (C) 1999 Andy Thomas alt@picnic.demon.co.uk
* *
* Note some portions of th UI comes from the dbbrowser plugin. * Note some portions of the UI comes from the dbbrowser plugin.
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@ -52,11 +52,11 @@ static gchar *proc_type_str[] =
/* Declare some local functions. /* Declare some local functions.
*/ */
static void query (void); static void query (void);
static void run (gchar *name, static void run (gchar *name,
gint nparams, gint nparams,
GParam *param, GimpParam *param,
gint *nreturn_vals, gint *nreturn_vals,
GParam **return_vals); GimpParam **return_vals);
static GtkWidget * gimp_plugin_desc (void); static GtkWidget * gimp_plugin_desc (void);
@ -70,7 +70,7 @@ static gint procedure_ctree_select_callback (GtkWidget *widget,
gint column, gint column,
gpointer data); gpointer data);
GPlugInInfo PLUG_IN_INFO = GimpPlugInInfo PLUG_IN_INFO =
{ {
NULL, /* init_proc */ NULL, /* init_proc */
NULL, /* quit_proc */ NULL, /* quit_proc */
@ -84,15 +84,20 @@ MAIN ()
static void static void
query (void) query (void)
{ {
static GParamDef args[] = static GimpParamDef args[] =
{ {
{ PARAM_INT32, "run_mode", "Interactive, [non-interactive]" } { GIMP_PDB_INT32, "run_mode", "Interactive, [non-interactive]" }
}; };
static gint nargs = sizeof (args) / sizeof (args[0]); static gint nargs = sizeof (args) / sizeof (args[0]);
gimp_install_procedure ("plug_in_details", gimp_install_procedure ("plug_in_details",
"Displays plugin details", "Displays plugin details",
"Helps browse the plugin menus system. You can search for plugin names, sort by name or menu location and you can view a tree representation of the plugin menus. Can also be of help to find where new plugins have installed themselves in the menuing system", "Helps browse the plugin menus system. You can "
"search for plugin names, sort by name or menu "
"location and you can view a tree representation "
"of the plugin menus. Can also be of help to find "
"where new plugins have installed themselves in "
"the menuing system",
"Andy Thomas", "Andy Thomas",
"Andy Thomas", "Andy Thomas",
"1999", "1999",
@ -104,22 +109,22 @@ query (void)
} }
static void static void
run (gchar *name, run (gchar *name,
gint nparams, gint nparams,
GParam *param, GimpParam *param,
gint *nreturn_vals, gint *nreturn_vals,
GParam **return_vals) GimpParam **return_vals)
{ {
static GParam values[2]; static GimpParam values[2];
GRunModeType run_mode; GimpRunModeType run_mode;
GtkWidget *plugin_dialog; GtkWidget *plugin_dialog;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
*nreturn_vals = 1; *nreturn_vals = 1;
*return_vals = values; *return_vals = values;
values[0].type = PARAM_STATUS; values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = STATUS_CALLING_ERROR; values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
INIT_I18N_UI(); INIT_I18N_UI();
@ -127,7 +132,7 @@ run (gchar *name,
{ {
*nreturn_vals = 1; *nreturn_vals = 1;
values[0].data.d_status = STATUS_SUCCESS; values[0].data.d_status = GIMP_PDB_SUCCESS;
plugin_dialog = gimp_plugin_desc (); plugin_dialog = gimp_plugin_desc ();
@ -233,13 +238,13 @@ details_callback (GtkWidget *widget,
static gchar * static gchar *
format_menu_path (gchar *s) format_menu_path (gchar *s)
{ {
gchar ** str_array; gchar **str_array;
gchar *newstr = NULL; gchar *newstr = NULL;
if (!s) if (!s)
return s; return s;
str_array = g_strsplit (s,"/",0); str_array = g_strsplit (s, "/", 0);
newstr = g_strjoinv ("->", str_array); newstr = g_strjoinv ("->", str_array);
@ -277,16 +282,16 @@ procedure_general_select_callback (PDesc *pdesc,
if (pdesc->descr_scroll == NULL) if (pdesc->descr_scroll == NULL)
return FALSE; return FALSE;
selected_proc_blurb = NULL; selected_proc_blurb = NULL;
selected_proc_help = NULL; selected_proc_help = NULL;
selected_proc_author = NULL; selected_proc_author = NULL;
selected_proc_copyright = NULL; selected_proc_copyright = NULL;
selected_proc_date = NULL; selected_proc_date = NULL;
selected_proc_type = 0; selected_proc_type = 0;
selected_nparams = 0; selected_nparams = 0;
selected_nreturn_vals = 0; selected_nreturn_vals = 0;
selected_params = NULL; selected_params = NULL;
selected_return_vals = NULL; selected_return_vals = NULL;
gimp_query_procedure (pinfo->realname, gimp_query_procedure (pinfo->realname,
&selected_proc_blurb, &selected_proc_blurb,
@ -486,7 +491,7 @@ procedure_general_select_callback (PDesc *pdesc,
g_free (selected_params); g_free (selected_params);
if (selected_return_vals) if (selected_return_vals)
g_free (selected_return_vals); g_free (selected_return_vals);
return FALSE; return FALSE;
} }
@ -544,7 +549,8 @@ procedure_clist_select_callback (GtkWidget *widget,
gtk_widget_show (pdesc->ctree); gtk_widget_show (pdesc->ctree);
gtk_signal_handler_block_by_func (GTK_OBJECT(pdesc->ctree), gtk_signal_handler_block_by_func (GTK_OBJECT(pdesc->ctree),
(GtkSignalFunc)procedure_ctree_select_callback, pdesc); GTK_SIGNAL_FUNC (procedure_ctree_select_callback),
pdesc);
gtk_clist_select_row (GTK_CLIST (pdesc->ctree), sel_row, -1); gtk_clist_select_row (GTK_CLIST (pdesc->ctree), sel_row, -1);
gtk_ctree_select (GTK_CTREE (pdesc->ctree), found_node); gtk_ctree_select (GTK_CTREE (pdesc->ctree), found_node);
@ -555,7 +561,8 @@ procedure_clist_select_callback (GtkWidget *widget,
0.5, 0.5); 0.5, 0.5);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (pdesc->ctree), gtk_signal_handler_unblock_by_func (GTK_OBJECT (pdesc->ctree),
(GtkSignalFunc)procedure_ctree_select_callback, pdesc); GTK_SIGNAL_FUNC (procedure_ctree_select_callback),
pdesc);
pdesc->ctree_row = sel_row; pdesc->ctree_row = sel_row;
} }
@ -640,7 +647,8 @@ procedure_ctree_select_callback (GtkWidget *widget,
/* Block signals */ /* Block signals */
gtk_signal_handler_block_by_func (GTK_OBJECT (pdesc->clist), gtk_signal_handler_block_by_func (GTK_OBJECT (pdesc->clist),
(GtkSignalFunc)procedure_clist_select_callback, pdesc); GTK_SIGNAL_FUNC (procedure_clist_select_callback),
pdesc);
sel_row = gtk_clist_find_row_from_data (GTK_CLIST (pdesc->clist), pinfo); sel_row = gtk_clist_find_row_from_data (GTK_CLIST (pdesc->clist), pinfo);
gtk_clist_select_row (GTK_CLIST (pdesc->clist), sel_row, -1); gtk_clist_select_row (GTK_CLIST (pdesc->clist), sel_row, -1);
@ -650,7 +658,8 @@ procedure_ctree_select_callback (GtkWidget *widget,
0.5, 0.5); 0.5, 0.5);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (pdesc->clist), gtk_signal_handler_unblock_by_func (GTK_OBJECT (pdesc->clist),
(GtkSignalFunc)procedure_clist_select_callback, pdesc); GTK_SIGNAL_FUNC (procedure_clist_select_callback),
pdesc);
pdesc->clist_row = sel_row; pdesc->clist_row = sel_row;
@ -670,7 +679,7 @@ pinfo_free (gpointer p)
g_free (pinfo); g_free (pinfo);
} }
static GtkCTreeNode* static GtkCTreeNode *
get_parent (PDesc *pdesc, get_parent (PDesc *pdesc,
GHashTable *ghash, GHashTable *ghash,
gchar *mpath) gchar *mpath)
@ -820,12 +829,12 @@ get_plugin_info (PDesc *pdesc,
{ {
int loop; int loop;
pdesc->num_plugins = return_vals[1].data.d_int32; pdesc->num_plugins = return_vals[1].data.d_int32;
menu_strs = return_vals[2].data.d_stringarray; menu_strs = return_vals[2].data.d_stringarray;
accel_strs = return_vals[4].data.d_stringarray; accel_strs = return_vals[4].data.d_stringarray;
prog_strs = return_vals[6].data.d_stringarray; prog_strs = return_vals[6].data.d_stringarray;
types_strs = return_vals[8].data.d_stringarray; types_strs = return_vals[8].data.d_stringarray;
time_ints = return_vals[10].data.d_int32array; time_ints = return_vals[10].data.d_int32array;
realname_strs = return_vals[12].data.d_stringarray; realname_strs = return_vals[12].data.d_stringarray;
for (loop = 0; loop < return_vals[1].data.d_int32; loop++) for (loop = 0; loop < return_vals[1].data.d_int32; loop++)
{ {
@ -856,11 +865,11 @@ get_plugin_info (PDesc *pdesc,
else else
strcpy (xtimestr,""); strcpy (xtimestr,"");
pinfo->menu = g_strdup (menu_strs[loop]); pinfo->menu = g_strdup (menu_strs[loop]);
pinfo->accel = g_strdup (accel_strs[loop]); pinfo->accel = g_strdup (accel_strs[loop]);
pinfo->prog = g_strdup (prog_strs[loop]); pinfo->prog = g_strdup (prog_strs[loop]);
pinfo->types = g_strdup (types_strs[loop]); pinfo->types = g_strdup (types_strs[loop]);
pinfo->instime = time_ints[loop]; pinfo->instime = time_ints[loop];
pinfo->realname = g_strdup (realname_strs[loop]); pinfo->realname = g_strdup (realname_strs[loop]);
labels[0] = g_strdup (name); labels[0] = g_strdup (name);
@ -1035,7 +1044,8 @@ gimp_plugin_desc (void)
plugindesc->clist = gtk_clist_new_with_titles (4, clabels); plugindesc->clist = gtk_clist_new_with_titles (4, clabels);
gtk_signal_connect (GTK_OBJECT (plugindesc->clist), "click_column", gtk_signal_connect (GTK_OBJECT (plugindesc->clist), "click_column",
(GtkSignalFunc) clist_click_column, NULL); GTK_SIGNAL_FUNC (clist_click_column),
NULL);
gtk_clist_column_titles_show (GTK_CLIST (plugindesc->clist)); gtk_clist_column_titles_show (GTK_CLIST (plugindesc->clist));
swindow = gtk_scrolled_window_new (NULL, NULL); swindow = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow), gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
@ -1045,7 +1055,7 @@ gimp_plugin_desc (void)
gtk_widget_set_usize (plugindesc->clist, DBL_LIST_WIDTH, DBL_HEIGHT); gtk_widget_set_usize (plugindesc->clist, DBL_LIST_WIDTH, DBL_HEIGHT);
gtk_signal_connect (GTK_OBJECT (plugindesc->clist), "select_row", gtk_signal_connect (GTK_OBJECT (plugindesc->clist), "select_row",
(GtkSignalFunc) procedure_clist_select_callback, GTK_SIGNAL_FUNC (procedure_clist_select_callback),
plugindesc); plugindesc);
label = gtk_label_new (_("List View")); label = gtk_label_new (_("List View"));
@ -1063,21 +1073,24 @@ gimp_plugin_desc (void)
swindow = gtk_scrolled_window_new (NULL, NULL); swindow = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow), gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_set_usize(plugindesc->ctree, DBL_LIST_WIDTH, DBL_HEIGHT); gtk_widget_set_usize (plugindesc->ctree, DBL_LIST_WIDTH, DBL_HEIGHT);
gtk_signal_connect (GTK_OBJECT (plugindesc->ctree), "tree_select_row", gtk_signal_connect (GTK_OBJECT (plugindesc->ctree), "tree_select_row",
(GtkSignalFunc) procedure_ctree_select_callback, GTK_SIGNAL_FUNC (procedure_ctree_select_callback),
plugindesc); plugindesc);
label = gtk_label_new (_("Tree View"));
gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 0, TRUE); gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 0, TRUE);
gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 1, TRUE); gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 1, TRUE);
gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 2, TRUE); gtk_clist_set_column_auto_resize (GTK_CLIST (plugindesc->ctree), 2, TRUE);
gtk_clist_column_titles_passive (GTK_CLIST (plugindesc->ctree));
label = gtk_label_new (_("Tree View"));
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), swindow, label); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), swindow, label);
gtk_container_add (GTK_CONTAINER (swindow), plugindesc->ctree); gtk_container_add (GTK_CONTAINER (swindow), plugindesc->ctree);
gtk_widget_show (plugindesc->ctree); gtk_widget_show (plugindesc->ctree);
gtk_widget_show (swindow); gtk_widget_show (swindow);
gtk_signal_connect_after (GTK_OBJECT (notebook), "switch_page", gtk_signal_connect_after (GTK_OBJECT (notebook), "switch_page",
(GtkSignalFunc) page_select_callback, GTK_SIGNAL_FUNC (page_select_callback),
plugindesc); plugindesc);
gtk_widget_show (notebook); gtk_widget_show (notebook);
@ -1102,11 +1115,12 @@ gimp_plugin_desc (void)
button = gtk_button_new_with_label (_("Details >>")); button = gtk_button_new_with_label (_("Details >>"));
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
gtk_widget_show (button);
gtk_signal_connect (GTK_OBJECT (button), "clicked", gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) details_callback, plugindesc); GTK_SIGNAL_FUNC (details_callback),
gtk_box_pack_start (GTK_BOX (searchhbox), plugindesc);
button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (searchhbox), button,
FALSE, FALSE, 0);
gtk_widget_show (button);
/* right = description */ /* right = description */
/* the right description is build on first click of the Details button */ /* the right description is build on first click of the Details button */
@ -1114,6 +1128,9 @@ gimp_plugin_desc (void)
/* now build the list */ /* now build the list */
dialog_search_callback (NULL, (gpointer) plugindesc); dialog_search_callback (NULL, (gpointer) plugindesc);
gtk_clist_set_selection_mode (GTK_CLIST (plugindesc->ctree),
GTK_SELECTION_BROWSE);
gtk_widget_show (plugindesc->clist); gtk_widget_show (plugindesc->clist);
gtk_widget_show (plugindesc->dlg); gtk_widget_show (plugindesc->dlg);

View File

@ -220,6 +220,10 @@ init_generated_constants (void)
setvar (cintern ("PIXELS"), flocons (0), NIL); setvar (cintern ("PIXELS"), flocons (0), NIL);
setvar (cintern ("POINTS"), flocons (1), NIL); setvar (cintern ("POINTS"), flocons (1), NIL);
setvar (cintern ("STACK-TRACE-NEVER"), flocons (0), NIL);
setvar (cintern ("STACK-TRACE-QUERY"), flocons (1), NIL);
setvar (cintern ("STACK-TRACE-ALWAYS"), flocons (2), NIL);
setvar (cintern ("SHADOWS"), flocons (0), NIL); setvar (cintern ("SHADOWS"), flocons (0), NIL);
setvar (cintern ("MIDTONES"), flocons (1), NIL); setvar (cintern ("MIDTONES"), flocons (1), NIL);
setvar (cintern ("HIGHLIGHTS"), flocons (2), NIL); setvar (cintern ("HIGHLIGHTS"), flocons (2), NIL);

View File

@ -60,6 +60,7 @@ enum_headers = \
../../app/convert.h \ ../../app/convert.h \
../../app/convolve.h \ ../../app/convolve.h \
../../app/dodgeburn.h \ ../../app/dodgeburn.h \
../../app/errors.h \
../../app/eraser.h \ ../../app/eraser.h \
../../app/gimpdrawable.h \ ../../app/gimpdrawable.h \
../../app/gimpimage.h \ ../../app/gimpimage.h \

View File

@ -283,6 +283,15 @@ package Gimp::CodeGen::enums;
DODGEBURN_MIDTONES => '1', DODGEBURN_MIDTONES => '1',
DODGEBURN_SHADOWS => '2' } DODGEBURN_SHADOWS => '2' }
}, },
StackTraceMode =>
{ contig => 1,
header => 'errors.h',
symbols => [ qw(STACK_TRACE_NEVER STACK_TRACE_QUERY
STACK_TRACE_ALWAYS) ],
mapping => { STACK_TRACE_NEVER => '0',
STACK_TRACE_QUERY => '1',
STACK_TRACE_ALWAYS => '2' }
},
OrientationType => OrientationType =>
{ contig => 1, { contig => 1,
header => 'gimpimage.h', header => 'gimpimage.h',