1998-01-25 18:26:47 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
2000-06-01 20:20:13 +08:00
|
|
|
* gimp.c
|
|
|
|
*
|
1998-01-25 18:26:47 +08:00
|
|
|
* This library is free software; you can redistribute it and/or
|
1999-11-18 05:13:50 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1998-01-25 18:26:47 +08:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
1999-11-18 05:13:50 +08:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-04-13 13:44:11 +08:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
1998-01-25 18:26:47 +08:00
|
|
|
*/
|
2000-05-31 07:38:46 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
2000-05-11 19:51:09 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <sys/time.h>
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
2000-05-11 19:51:09 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <sys/param.h>
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
2000-05-11 19:51:09 +08:00
|
|
|
|
2000-05-11 05:21:23 +08:00
|
|
|
#ifdef HAVE_SYS_WAIT_H
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#endif
|
2000-05-11 19:51:09 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <unistd.h>
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
2000-05-11 19:51:09 +08:00
|
|
|
|
|
|
|
#ifndef WAIT_ANY
|
|
|
|
#define WAIT_ANY -1
|
|
|
|
#endif
|
|
|
|
|
2000-05-31 14:15:06 +08:00
|
|
|
#include <glib.h>
|
2000-05-31 07:38:46 +08:00
|
|
|
|
2000-04-23 03:47:01 +08:00
|
|
|
#ifndef G_OS_WIN32
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpsignal.h"
|
2000-04-23 03:47:01 +08:00
|
|
|
#else
|
|
|
|
#include <signal.h>
|
|
|
|
#endif
|
1999-03-07 20:56:03 +08:00
|
|
|
|
1998-08-29 07:01:46 +08:00
|
|
|
#ifdef HAVE_IPC_H
|
|
|
|
#include <sys/ipc.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SHM_H
|
|
|
|
#include <sys/shm.h>
|
|
|
|
#endif
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#ifdef HAVE_SYS_SELECT_H
|
|
|
|
#include <sys/select.h>
|
|
|
|
#endif
|
|
|
|
|
1999-10-07 05:27:18 +08:00
|
|
|
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
1999-03-07 20:56:03 +08:00
|
|
|
# define STRICT
|
|
|
|
# include <windows.h>
|
1999-10-03 08:43:05 +08:00
|
|
|
# undef RGB
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
1999-04-24 17:36:39 +08:00
|
|
|
#ifdef __EMX__
|
|
|
|
# include <fcntl.h>
|
|
|
|
#endif
|
1999-03-07 20:56:03 +08:00
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbasetypes.h"
|
|
|
|
|
|
|
|
#include "libgimpbase/gimpenv.h"
|
|
|
|
#include "libgimpbase/gimpprotocol.h"
|
|
|
|
#include "libgimpbase/gimpwire.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "gimp.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define WRITE_BUFFER_SIZE 1024
|
|
|
|
|
2000-05-31 14:15:06 +08:00
|
|
|
void gimp_extension_process (guint timeout);
|
1997-11-25 06:05:25 +08:00
|
|
|
void gimp_extension_ack (void);
|
2000-05-31 14:15:06 +08:00
|
|
|
void gimp_read_expect_msg (WireMessage *msg,
|
|
|
|
gint type);
|
1998-09-19 08:40:27 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifndef G_OS_WIN32
|
2000-07-31 01:33:37 +08:00
|
|
|
static void gimp_plugin_sigfatal_handler (gint sig_num);
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
|
|
|
#endif
|
2000-07-31 01:33:37 +08:00
|
|
|
static gboolean gimp_plugin_io_error_handler (GIOChannel *channel,
|
|
|
|
GIOCondition cond,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
static gboolean gimp_write (GIOChannel *channel,
|
|
|
|
guint8 *buf,
|
|
|
|
gulong count);
|
|
|
|
static gboolean gimp_flush (GIOChannel *channel);
|
2000-05-11 05:21:23 +08:00
|
|
|
static void gimp_loop (void);
|
2000-07-31 01:33:37 +08:00
|
|
|
static void gimp_config (GPConfig *config);
|
|
|
|
static void gimp_proc_run (GPProcRun *proc_run);
|
|
|
|
static void gimp_temp_proc_run (GPProcRun *proc_run);
|
|
|
|
static void gimp_message_func (const gchar *log_domain,
|
|
|
|
GLogLevelFlags log_level,
|
|
|
|
const gchar *message,
|
|
|
|
gpointer data);
|
|
|
|
static void gimp_process_message (WireMessage *msg);
|
2000-05-11 05:21:23 +08:00
|
|
|
static void gimp_close (void);
|
2000-03-26 02:49:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
GIOChannel *_readchannel = NULL;
|
1999-03-07 20:56:03 +08:00
|
|
|
GIOChannel *_writechannel = NULL;
|
|
|
|
|
2000-03-26 02:49:05 +08:00
|
|
|
gint _shm_ID = -1;
|
1997-11-25 06:05:25 +08:00
|
|
|
guchar *_shm_addr = NULL;
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
guint gimp_major_version = GIMP_MAJOR_VERSION;
|
|
|
|
guint gimp_minor_version = GIMP_MINOR_VERSION;
|
|
|
|
guint gimp_micro_version = GIMP_MICRO_VERSION;
|
|
|
|
|
1999-10-07 05:27:18 +08:00
|
|
|
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
1999-03-07 20:56:03 +08:00
|
|
|
static HANDLE shm_handle;
|
|
|
|
#endif
|
1998-07-15 10:28:31 +08:00
|
|
|
|
2000-03-26 02:49:05 +08:00
|
|
|
static gdouble _gamma_val;
|
|
|
|
static gboolean _install_cmap;
|
2000-05-01 02:17:55 +08:00
|
|
|
static gint _min_colors;
|
2000-03-26 02:49:05 +08:00
|
|
|
static gint _gdisp_ID = -1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-03-26 02:49:05 +08:00
|
|
|
static gchar *progname = NULL;
|
|
|
|
static guint8 write_buffer[WRITE_BUFFER_SIZE];
|
|
|
|
static guint write_buffer_index = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-07-16 20:49:04 +08:00
|
|
|
static GimpStackTraceMode stack_trace_mode = GIMP_STACK_TRACE_NEVER;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static GHashTable *temp_proc_ht = NULL;
|
|
|
|
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifdef G_OS_WIN32
|
2000-05-31 14:15:06 +08:00
|
|
|
static GimpPlugInInfo *PLUG_IN_INFO_PTR;
|
1999-03-07 20:56:03 +08:00
|
|
|
#define PLUG_IN_INFO (*PLUG_IN_INFO_PTR)
|
1999-07-03 10:27:32 +08:00
|
|
|
void
|
2000-05-31 14:15:06 +08:00
|
|
|
set_gimp_PLUG_IN_INFO_PTR (GimpPlugInInfo *p)
|
1999-07-03 10:27:32 +08:00
|
|
|
{
|
|
|
|
PLUG_IN_INFO_PTR = p;
|
|
|
|
}
|
1999-03-07 20:56:03 +08:00
|
|
|
#else
|
1999-04-24 17:36:39 +08:00
|
|
|
#ifndef __EMX__
|
2000-05-31 14:15:06 +08:00
|
|
|
extern GimpPlugInInfo PLUG_IN_INFO;
|
1999-04-24 17:36:39 +08:00
|
|
|
#else
|
2000-05-31 14:15:06 +08:00
|
|
|
static GimpPlugInInfo PLUG_IN_INFO;
|
|
|
|
void set_gimp_PLUG_IN_INFO (const GimpPlugInInfo *p)
|
1999-04-24 17:36:39 +08:00
|
|
|
{
|
|
|
|
PLUG_IN_INFO = *p;
|
|
|
|
}
|
|
|
|
#endif
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
gimp_main (int argc,
|
|
|
|
char *argv[])
|
|
|
|
{
|
2001-08-30 01:48:28 +08:00
|
|
|
gchar *basename;
|
|
|
|
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifdef G_OS_WIN32
|
2001-07-16 04:47:03 +08:00
|
|
|
gint i, j, k;
|
1999-08-29 01:00:33 +08:00
|
|
|
|
2000-07-30 05:32:55 +08:00
|
|
|
g_assert (PLUG_IN_INFO_PTR != NULL);
|
|
|
|
|
1999-08-29 01:00:33 +08:00
|
|
|
/* Check for exe file name with spaces in the path having been split up
|
|
|
|
* by buggy NT C runtime, or something. I don't know why this happens
|
|
|
|
* on NT (including w2k), but not on w95/98.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
k = strlen (argv[i]);
|
|
|
|
if (k > 10)
|
|
|
|
if (g_strcasecmp (argv[i] + k - 4, ".exe") == 0)
|
|
|
|
{
|
|
|
|
/* Found the end of the executable name, most probably.
|
|
|
|
* Splice the parts of the name back together.
|
|
|
|
*/
|
|
|
|
GString *s;
|
|
|
|
|
|
|
|
s = g_string_new (argv[0]);
|
|
|
|
for (j = 1; j <= i; j++)
|
|
|
|
{
|
|
|
|
s = g_string_append_c (s, ' ');
|
|
|
|
s = g_string_append (s, argv[j]);
|
|
|
|
}
|
|
|
|
argv[0] = s->str;
|
|
|
|
/* Move rest of argv down */
|
|
|
|
for (j = 1; j < argc - i; j++)
|
|
|
|
argv[j] = argv[j + i];
|
|
|
|
argv[argc - i] = NULL;
|
|
|
|
argc -= i;
|
|
|
|
break;
|
|
|
|
}
|
2000-05-31 14:15:06 +08:00
|
|
|
}
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
|
|
|
|
2000-07-16 20:49:04 +08:00
|
|
|
if ((argc != 6) || (strcmp (argv[1], "-gimp") != 0))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-07-16 20:49:04 +08:00
|
|
|
g_printerr ("%s is a gimp plug-in and must be run by the gimp to be used\n", argv[0]);
|
1997-11-25 06:05:25 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
progname = argv[0];
|
|
|
|
|
2001-08-30 01:48:28 +08:00
|
|
|
basename = g_path_get_basename (progname);
|
|
|
|
|
|
|
|
g_set_prgname (basename);
|
|
|
|
|
|
|
|
g_free (basename);
|
2000-05-11 05:21:23 +08:00
|
|
|
|
2000-07-31 00:25:19 +08:00
|
|
|
stack_trace_mode = (GimpStackTraceMode) CLAMP (atoi (argv[5]),
|
|
|
|
GIMP_STACK_TRACE_NEVER,
|
|
|
|
GIMP_STACK_TRACE_ALWAYS);
|
|
|
|
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifndef G_OS_WIN32
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
|
|
|
/* No use catching these on Win32, the user won't get any meaningful
|
|
|
|
* stack trace from glib anyhow. It's better to let Windows inform
|
|
|
|
* about the program error, and offer debugging if the plug-in
|
|
|
|
* has been built with MSVC, and the user has MSVC installed.
|
|
|
|
*/
|
2000-05-11 05:21:23 +08:00
|
|
|
gimp_signal_private (SIGHUP, gimp_plugin_sigfatal_handler, 0);
|
|
|
|
gimp_signal_private (SIGINT, gimp_plugin_sigfatal_handler, 0);
|
|
|
|
gimp_signal_private (SIGQUIT, gimp_plugin_sigfatal_handler, 0);
|
|
|
|
gimp_signal_private (SIGBUS, gimp_plugin_sigfatal_handler, 0);
|
|
|
|
gimp_signal_private (SIGSEGV, gimp_plugin_sigfatal_handler, 0);
|
|
|
|
gimp_signal_private (SIGTERM, gimp_plugin_sigfatal_handler, 0);
|
|
|
|
gimp_signal_private (SIGFPE, gimp_plugin_sigfatal_handler, 0);
|
|
|
|
|
|
|
|
/* Ignore SIGPIPE from crashing Gimp */
|
|
|
|
gimp_signal_private (SIGPIPE, SIG_IGN, 0);
|
|
|
|
|
|
|
|
/* Restart syscalls interrupted by SIGCHLD */
|
2000-11-09 05:58:22 +08:00
|
|
|
gimp_signal_private (SIGCHLD, SIG_DFL, SA_RESTART);
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-07-16 20:49:04 +08:00
|
|
|
_readchannel = g_io_channel_unix_new (atoi (argv[2]));
|
1999-03-07 20:56:03 +08:00
|
|
|
_writechannel = g_io_channel_unix_new (atoi (argv[3]));
|
1999-04-24 17:36:39 +08:00
|
|
|
#ifdef __EMX__
|
2000-07-16 20:49:04 +08:00
|
|
|
setmode (g_io_channel_unix_get_fd (_readchannel), O_BINARY);
|
|
|
|
setmode (g_io_channel_unix_get_fd (_writechannel), O_BINARY);
|
1999-04-24 17:36:39 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-08-30 01:48:28 +08:00
|
|
|
g_io_channel_set_encoding (_readchannel, NULL, NULL);
|
|
|
|
g_io_channel_set_encoding (_writechannel, NULL, NULL);
|
|
|
|
|
2001-08-30 09:09:58 +08:00
|
|
|
g_io_channel_set_buffered (_readchannel, FALSE);
|
|
|
|
g_io_channel_set_buffered (_writechannel, FALSE);
|
|
|
|
|
|
|
|
g_io_channel_set_close_on_unref (_readchannel, TRUE);
|
|
|
|
g_io_channel_set_close_on_unref (_writechannel, TRUE);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gp_init ();
|
|
|
|
wire_set_writer (gimp_write);
|
|
|
|
wire_set_flusher (gimp_flush);
|
|
|
|
|
2002-02-12 10:41:01 +08:00
|
|
|
/* set handler both for the "LibGimp" and ""
|
|
|
|
domains */
|
|
|
|
|
2000-07-31 01:33:37 +08:00
|
|
|
g_log_set_handler ("LibGimp",
|
|
|
|
G_LOG_LEVEL_MESSAGE,
|
|
|
|
gimp_message_func,
|
|
|
|
NULL);
|
2000-08-28 04:59:07 +08:00
|
|
|
g_log_set_handler (NULL,
|
2000-07-31 01:33:37 +08:00
|
|
|
G_LOG_LEVEL_MESSAGE,
|
|
|
|
gimp_message_func,
|
|
|
|
NULL);
|
|
|
|
|
2000-07-16 20:49:04 +08:00
|
|
|
if (strcmp (argv[4], "-query") == 0)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
if (PLUG_IN_INFO.query_proc)
|
|
|
|
(* PLUG_IN_INFO.query_proc) ();
|
1999-03-13 05:30:44 +08:00
|
|
|
gimp_close ();
|
1997-11-25 06:05:25 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-02-12 10:41:01 +08:00
|
|
|
if (strcmp (argv[4], "-init") == 0)
|
|
|
|
{
|
|
|
|
if (PLUG_IN_INFO.init_proc)
|
|
|
|
(* PLUG_IN_INFO.init_proc) ();
|
|
|
|
gimp_close ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-10-18 05:38:42 +08:00
|
|
|
temp_proc_ht = g_hash_table_new (g_str_hash, g_str_equal);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-11 05:21:23 +08:00
|
|
|
g_io_add_watch (_readchannel,
|
|
|
|
G_IO_ERR | G_IO_HUP,
|
|
|
|
gimp_plugin_io_error_handler,
|
|
|
|
NULL);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_loop ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-03-13 05:30:44 +08:00
|
|
|
static void
|
1999-10-05 03:26:07 +08:00
|
|
|
gimp_close (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
if (PLUG_IN_INFO.quit_proc)
|
|
|
|
(* PLUG_IN_INFO.quit_proc) ();
|
|
|
|
|
1999-10-07 05:27:18 +08:00
|
|
|
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
1999-03-07 20:56:03 +08:00
|
|
|
CloseHandle (shm_handle);
|
|
|
|
#else
|
1998-08-29 07:01:46 +08:00
|
|
|
#ifdef HAVE_SHM_H
|
1997-11-25 06:05:25 +08:00
|
|
|
if ((_shm_ID != -1) && _shm_addr)
|
|
|
|
shmdt ((char*) _shm_addr);
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
1998-08-29 07:01:46 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
gp_quit_write (_writechannel);
|
1999-03-13 05:30:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-10-05 03:26:07 +08:00
|
|
|
gimp_quit (void)
|
1999-03-13 05:30:44 +08:00
|
|
|
{
|
|
|
|
gimp_close ();
|
1997-11-25 06:05:25 +08:00
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-17 04:22:33 +08:00
|
|
|
gint32
|
|
|
|
gimp_default_display (void)
|
|
|
|
{
|
|
|
|
return _gdisp_ID;
|
|
|
|
}
|
|
|
|
|
1998-05-28 17:03:57 +08:00
|
|
|
static void
|
2000-07-31 01:33:37 +08:00
|
|
|
gimp_message_func (const gchar *log_domain,
|
|
|
|
GLogLevelFlags log_level,
|
|
|
|
const gchar *message,
|
|
|
|
gpointer data)
|
1998-05-28 17:03:57 +08:00
|
|
|
{
|
2000-07-31 01:33:37 +08:00
|
|
|
gimp_message ((gchar *) message);
|
1998-05-28 17:03:57 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
2000-05-31 14:15:06 +08:00
|
|
|
gimp_install_procedure (gchar *name,
|
|
|
|
gchar *blurb,
|
|
|
|
gchar *help,
|
|
|
|
gchar *author,
|
|
|
|
gchar *copyright,
|
|
|
|
gchar *date,
|
|
|
|
gchar *menu_path,
|
|
|
|
gchar *image_types,
|
|
|
|
gint type,
|
|
|
|
gint nparams,
|
|
|
|
gint nreturn_vals,
|
|
|
|
GimpParamDef *params,
|
|
|
|
GimpParamDef *return_vals)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GPProcInstall proc_install;
|
|
|
|
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_install.name = name;
|
|
|
|
proc_install.blurb = blurb;
|
|
|
|
proc_install.help = help;
|
|
|
|
proc_install.author = author;
|
|
|
|
proc_install.copyright = copyright;
|
|
|
|
proc_install.date = date;
|
|
|
|
proc_install.menu_path = menu_path;
|
|
|
|
proc_install.image_types = image_types;
|
|
|
|
proc_install.type = type;
|
|
|
|
proc_install.nparams = nparams;
|
1997-11-25 06:05:25 +08:00
|
|
|
proc_install.nreturn_vals = nreturn_vals;
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_install.params = (GPParamDef *) params;
|
|
|
|
proc_install.return_vals = (GPParamDef *) return_vals;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
if (!gp_proc_install_write (_writechannel, &proc_install))
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_quit ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-05-31 14:15:06 +08:00
|
|
|
gimp_install_temp_proc (gchar *name,
|
|
|
|
gchar *blurb,
|
|
|
|
gchar *help,
|
|
|
|
gchar *author,
|
|
|
|
gchar *copyright,
|
|
|
|
gchar *date,
|
|
|
|
gchar *menu_path,
|
|
|
|
gchar *image_types,
|
|
|
|
gint type,
|
|
|
|
gint nparams,
|
|
|
|
gint nreturn_vals,
|
|
|
|
GimpParamDef *params,
|
|
|
|
GimpParamDef *return_vals,
|
|
|
|
GimpRunProc run_proc)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-31 14:15:06 +08:00
|
|
|
gimp_install_procedure (name,
|
|
|
|
blurb, help,
|
|
|
|
author, copyright, date,
|
|
|
|
menu_path,
|
|
|
|
image_types,
|
|
|
|
type,
|
|
|
|
nparams, nreturn_vals,
|
|
|
|
params, return_vals);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Insert the temp proc run function into the hash table */
|
1999-01-08 03:54:45 +08:00
|
|
|
g_hash_table_insert (temp_proc_ht, g_strdup (name), (gpointer) run_proc);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-03-26 02:49:05 +08:00
|
|
|
gimp_uninstall_temp_proc (gchar *name)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GPProcUninstall proc_uninstall;
|
1999-01-08 03:54:45 +08:00
|
|
|
gpointer hash_name;
|
1999-08-17 22:43:45 +08:00
|
|
|
gboolean found;
|
1997-11-25 06:05:25 +08:00
|
|
|
proc_uninstall.name = name;
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
if (!gp_proc_uninstall_write (_writechannel, &proc_uninstall))
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_quit ();
|
1999-01-08 03:54:45 +08:00
|
|
|
|
1999-08-17 22:43:45 +08:00
|
|
|
found = g_hash_table_lookup_extended (temp_proc_ht, name, &hash_name, NULL);
|
|
|
|
if (found)
|
2000-05-31 14:15:06 +08:00
|
|
|
{
|
|
|
|
g_hash_table_remove (temp_proc_ht, (gpointer) name);
|
2000-10-18 05:38:42 +08:00
|
|
|
g_free (hash_name);
|
2000-05-31 14:15:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-05-31 14:15:06 +08:00
|
|
|
GimpParam *
|
2000-03-26 02:49:05 +08:00
|
|
|
gimp_run_procedure (gchar *name,
|
|
|
|
gint *nreturn_vals,
|
1997-11-25 06:05:25 +08:00
|
|
|
...)
|
|
|
|
{
|
2000-05-31 14:15:06 +08:00
|
|
|
GPProcRun proc_run;
|
|
|
|
GPProcReturn *proc_return;
|
|
|
|
WireMessage msg;
|
|
|
|
GimpPDBArgType param_type;
|
|
|
|
GimpParam *return_vals;
|
|
|
|
va_list args;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
proc_run.name = name;
|
|
|
|
proc_run.nparams = 0;
|
|
|
|
proc_run.params = NULL;
|
|
|
|
|
|
|
|
va_start (args, nreturn_vals);
|
2000-05-31 14:15:06 +08:00
|
|
|
param_type = va_arg (args, GimpPDBArgType);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-03 08:48:55 +08:00
|
|
|
while (param_type != GIMP_PDB_END)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
switch (param_type)
|
|
|
|
{
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_INT32:
|
|
|
|
case GIMP_PDB_DISPLAY:
|
|
|
|
case GIMP_PDB_IMAGE:
|
|
|
|
case GIMP_PDB_LAYER:
|
|
|
|
case GIMP_PDB_CHANNEL:
|
|
|
|
case GIMP_PDB_DRAWABLE:
|
|
|
|
case GIMP_PDB_SELECTION:
|
|
|
|
case GIMP_PDB_BOUNDARY:
|
|
|
|
case GIMP_PDB_PATH:
|
|
|
|
case GIMP_PDB_STATUS:
|
2000-05-31 14:15:06 +08:00
|
|
|
(void) va_arg (args, gint);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_INT16:
|
2000-05-31 14:15:06 +08:00
|
|
|
(void) va_arg (args, gint);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_INT8:
|
2000-05-31 14:15:06 +08:00
|
|
|
(void) va_arg (args, gint);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_FLOAT:
|
2000-05-31 14:15:06 +08:00
|
|
|
(void) va_arg (args, gdouble);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_STRING:
|
2000-05-31 14:15:06 +08:00
|
|
|
(void) va_arg (args, gchar *);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_INT32ARRAY:
|
2000-05-31 14:15:06 +08:00
|
|
|
(void) va_arg (args, gint32 *);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_INT16ARRAY:
|
2000-05-31 14:15:06 +08:00
|
|
|
(void) va_arg (args, gint16 *);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_INT8ARRAY:
|
2000-05-31 14:15:06 +08:00
|
|
|
(void) va_arg (args, gint8 *);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_FLOATARRAY:
|
2000-05-31 14:15:06 +08:00
|
|
|
(void) va_arg (args, gdouble *);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_STRINGARRAY:
|
2000-05-31 14:15:06 +08:00
|
|
|
(void) va_arg (args, gchar **);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_COLOR:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_PARASITE:
|
2000-05-31 14:15:06 +08:00
|
|
|
(void) va_arg (args, GimpParasite *);
|
1998-10-08 16:15:21 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_REGION:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_END:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
proc_run.nparams += 1;
|
2000-05-31 14:15:06 +08:00
|
|
|
param_type = va_arg (args, GimpPDBArgType);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
proc_run.params = g_new (GPParam, proc_run.nparams);
|
|
|
|
|
|
|
|
va_start (args, nreturn_vals);
|
|
|
|
|
|
|
|
for (i = 0; i < proc_run.nparams; i++)
|
|
|
|
{
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_run.params[i].type = va_arg (args, GimpPDBArgType);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
switch (proc_run.params[i].type)
|
|
|
|
{
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_INT32:
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_run.params[i].data.d_int32 = (gint32) va_arg (args, gint);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_INT16:
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_run.params[i].data.d_int16 = (gint16) va_arg (args, gint);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_INT8:
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_run.params[i].data.d_int8 = (gint8) va_arg (args, gint);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_FLOAT:
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_run.params[i].data.d_float = (gdouble) va_arg (args, gdouble);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_STRING:
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_run.params[i].data.d_string = va_arg (args, gchar *);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_INT32ARRAY:
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_run.params[i].data.d_int32array = va_arg (args, gint32 *);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_INT16ARRAY:
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_run.params[i].data.d_int16array = va_arg (args, gint16 *);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_INT8ARRAY:
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_run.params[i].data.d_int8array = va_arg (args, gint8 *);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_FLOATARRAY:
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_run.params[i].data.d_floatarray = va_arg (args, gdouble *);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_STRINGARRAY:
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_run.params[i].data.d_stringarray = va_arg (args, gchar **);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_COLOR:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_REGION:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_DISPLAY:
|
1997-11-25 06:05:25 +08:00
|
|
|
proc_run.params[i].data.d_display = va_arg (args, gint32);
|
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_IMAGE:
|
1997-11-25 06:05:25 +08:00
|
|
|
proc_run.params[i].data.d_image = va_arg (args, gint32);
|
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_LAYER:
|
1997-11-25 06:05:25 +08:00
|
|
|
proc_run.params[i].data.d_layer = va_arg (args, gint32);
|
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_CHANNEL:
|
1997-11-25 06:05:25 +08:00
|
|
|
proc_run.params[i].data.d_channel = va_arg (args, gint32);
|
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_DRAWABLE:
|
1997-11-25 06:05:25 +08:00
|
|
|
proc_run.params[i].data.d_drawable = va_arg (args, gint32);
|
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_SELECTION:
|
1997-11-25 06:05:25 +08:00
|
|
|
proc_run.params[i].data.d_selection = va_arg (args, gint32);
|
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_BOUNDARY:
|
1997-11-25 06:05:25 +08:00
|
|
|
proc_run.params[i].data.d_boundary = va_arg (args, gint32);
|
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_PATH:
|
1997-11-25 06:05:25 +08:00
|
|
|
proc_run.params[i].data.d_path = va_arg (args, gint32);
|
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_PARASITE:
|
1998-11-13 12:00:54 +08:00
|
|
|
{
|
2000-05-31 14:15:06 +08:00
|
|
|
GimpParasite *parasite = va_arg (args, GimpParasite *);
|
|
|
|
|
|
|
|
if (parasite == NULL)
|
2000-05-27 06:28:40 +08:00
|
|
|
{
|
|
|
|
proc_run.params[i].data.d_parasite.name = NULL;
|
|
|
|
proc_run.params[i].data.d_parasite.data = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_run.params[i].data.d_parasite.name = parasite->name;
|
|
|
|
proc_run.params[i].data.d_parasite.flags = parasite->flags;
|
|
|
|
proc_run.params[i].data.d_parasite.size = parasite->size;
|
|
|
|
proc_run.params[i].data.d_parasite.data = parasite->data;
|
2000-05-27 06:28:40 +08:00
|
|
|
}
|
1998-11-13 12:00:54 +08:00
|
|
|
}
|
2000-05-27 06:28:40 +08:00
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_STATUS:
|
1997-11-25 06:05:25 +08:00
|
|
|
proc_run.params[i].data.d_status = va_arg (args, gint32);
|
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_END:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
va_end (args);
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
if (!gp_proc_run_write (_writechannel, &proc_run))
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_quit ();
|
|
|
|
|
2000-03-26 02:49:05 +08:00
|
|
|
gimp_read_expect_msg (&msg, GP_PROC_RETURN);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
proc_return = msg.data;
|
|
|
|
*nreturn_vals = proc_return->nparams;
|
2000-05-31 14:15:06 +08:00
|
|
|
return_vals = (GimpParam*) proc_return->params;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
switch (return_vals[0].data.d_status)
|
|
|
|
{
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_EXECUTION_ERROR:
|
1997-11-25 06:05:25 +08:00
|
|
|
/*g_warning ("an execution error occured while trying to run: \"%s\"", name);*/
|
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_CALLING_ERROR:
|
1997-11-25 06:05:25 +08:00
|
|
|
g_warning ("a calling error occured while trying to run: \"%s\"", name);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (proc_run.params);
|
1998-03-01 09:18:45 +08:00
|
|
|
g_free (proc_return->name);
|
1997-11-25 06:05:25 +08:00
|
|
|
g_free (proc_return);
|
|
|
|
|
|
|
|
return return_vals;
|
|
|
|
}
|
|
|
|
|
1998-09-19 08:40:27 +08:00
|
|
|
void
|
2000-03-26 02:49:05 +08:00
|
|
|
gimp_read_expect_msg (WireMessage *msg,
|
|
|
|
gint type)
|
1998-09-19 08:40:27 +08:00
|
|
|
{
|
2000-03-26 02:49:05 +08:00
|
|
|
while (TRUE)
|
1998-09-19 08:40:27 +08:00
|
|
|
{
|
1999-03-07 20:56:03 +08:00
|
|
|
if (!wire_read_msg (_readchannel, msg))
|
1998-09-19 08:40:27 +08:00
|
|
|
gimp_quit ();
|
|
|
|
|
|
|
|
if (msg->type != type)
|
|
|
|
{
|
2000-03-26 02:49:05 +08:00
|
|
|
if (msg->type == GP_TEMP_PROC_RUN || msg->type == GP_QUIT)
|
1998-09-19 08:40:27 +08:00
|
|
|
{
|
2000-03-26 02:49:05 +08:00
|
|
|
gimp_process_message (msg);
|
1998-09-19 08:40:27 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
g_error ("unexpected message: %d\n", msg->type);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-31 14:15:06 +08:00
|
|
|
GimpParam *
|
|
|
|
gimp_run_procedure2 (gchar *name,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
gint nparams,
|
|
|
|
GimpParam *params)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-31 14:15:06 +08:00
|
|
|
GPProcRun proc_run;
|
1997-11-25 06:05:25 +08:00
|
|
|
GPProcReturn *proc_return;
|
2000-05-31 14:15:06 +08:00
|
|
|
WireMessage msg;
|
|
|
|
GimpParam *return_vals;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_run.name = name;
|
1997-11-25 06:05:25 +08:00
|
|
|
proc_run.nparams = nparams;
|
2000-05-31 14:15:06 +08:00
|
|
|
proc_run.params = (GPParam *) params;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
if (!gp_proc_run_write (_writechannel, &proc_run))
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_quit ();
|
|
|
|
|
1998-09-19 08:40:27 +08:00
|
|
|
gimp_read_expect_msg(&msg,GP_PROC_RETURN);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
proc_return = msg.data;
|
|
|
|
*nreturn_vals = proc_return->nparams;
|
2000-05-31 14:15:06 +08:00
|
|
|
return_vals = (GimpParam *) proc_return->params;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
switch (return_vals[0].data.d_status)
|
|
|
|
{
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_EXECUTION_ERROR:
|
1997-11-25 06:05:25 +08:00
|
|
|
/*g_warning ("an execution error occured while trying to run: \"%s\"", name);*/
|
|
|
|
break;
|
2000-08-03 08:48:55 +08:00
|
|
|
case GIMP_PDB_CALLING_ERROR:
|
1997-11-25 06:05:25 +08:00
|
|
|
g_warning ("a calling error occured while trying to run: \"%s\"", name);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1998-11-11 10:20:29 +08:00
|
|
|
g_free (proc_return->name);
|
1997-11-25 06:05:25 +08:00
|
|
|
g_free (proc_return);
|
|
|
|
|
|
|
|
return return_vals;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-05-31 14:15:06 +08:00
|
|
|
gimp_destroy_params (GimpParam *params,
|
|
|
|
gint nparams)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-03-26 02:49:05 +08:00
|
|
|
extern void _gp_params_destroy (GPParam *params, gint nparams);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
_gp_params_destroy ((GPParam*) params, nparams);
|
|
|
|
}
|
|
|
|
|
1998-11-11 10:20:29 +08:00
|
|
|
void
|
2000-05-31 14:15:06 +08:00
|
|
|
gimp_destroy_paramdefs (GimpParamDef *paramdefs,
|
|
|
|
gint nparams)
|
1998-11-11 10:20:29 +08:00
|
|
|
{
|
|
|
|
while (nparams--)
|
|
|
|
{
|
|
|
|
g_free (paramdefs[nparams].name);
|
|
|
|
g_free (paramdefs[nparams].description);
|
|
|
|
}
|
2000-05-31 14:15:06 +08:00
|
|
|
|
1998-11-11 10:20:29 +08:00
|
|
|
g_free (paramdefs);
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gdouble
|
2000-03-26 02:49:05 +08:00
|
|
|
gimp_gamma (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
return _gamma_val;
|
|
|
|
}
|
|
|
|
|
2000-03-26 02:49:05 +08:00
|
|
|
gboolean
|
|
|
|
gimp_install_cmap (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
return _install_cmap;
|
|
|
|
}
|
|
|
|
|
2000-05-01 02:17:55 +08:00
|
|
|
gint
|
|
|
|
gimp_min_colors (void)
|
|
|
|
{
|
|
|
|
return _min_colors;
|
|
|
|
}
|
|
|
|
|
1998-09-19 08:40:27 +08:00
|
|
|
static void
|
2000-03-26 02:49:05 +08:00
|
|
|
gimp_process_message (WireMessage *msg)
|
1998-09-19 08:40:27 +08:00
|
|
|
{
|
|
|
|
switch (msg->type)
|
|
|
|
{
|
|
|
|
case GP_QUIT:
|
|
|
|
gimp_quit ();
|
|
|
|
break;
|
|
|
|
case GP_CONFIG:
|
|
|
|
gimp_config (msg->data);
|
|
|
|
break;
|
|
|
|
case GP_TILE_REQ:
|
|
|
|
case GP_TILE_ACK:
|
|
|
|
case GP_TILE_DATA:
|
|
|
|
g_warning ("unexpected tile message received (should not happen)\n");
|
|
|
|
break;
|
|
|
|
case GP_PROC_RUN:
|
|
|
|
g_warning ("unexpected proc run message received (should not happen)\n");
|
|
|
|
break;
|
|
|
|
case GP_PROC_RETURN:
|
|
|
|
g_warning ("unexpected proc return message received (should not happen)\n");
|
|
|
|
break;
|
|
|
|
case GP_TEMP_PROC_RUN:
|
|
|
|
gimp_temp_proc_run (msg->data);
|
|
|
|
break;
|
|
|
|
case GP_TEMP_PROC_RETURN:
|
|
|
|
g_warning ("unexpected temp proc return message received (should not happen)\n");
|
|
|
|
break;
|
|
|
|
case GP_PROC_INSTALL:
|
|
|
|
g_warning ("unexpected proc install message received (should not happen)\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-03-26 02:49:05 +08:00
|
|
|
gimp_single_message (void)
|
1998-09-19 08:40:27 +08:00
|
|
|
{
|
|
|
|
WireMessage msg;
|
|
|
|
|
|
|
|
/* Run a temp function */
|
1999-03-07 20:56:03 +08:00
|
|
|
if (!wire_read_msg (_readchannel, &msg))
|
1998-09-19 08:40:27 +08:00
|
|
|
gimp_quit ();
|
|
|
|
|
2000-03-26 02:49:05 +08:00
|
|
|
gimp_process_message (&msg);
|
1998-09-19 08:40:27 +08:00
|
|
|
|
|
|
|
wire_destroy (&msg);
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
|
|
|
gimp_extension_process (guint timeout)
|
|
|
|
{
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifndef G_OS_WIN32
|
1997-11-25 06:05:25 +08:00
|
|
|
fd_set readfds;
|
2000-05-31 14:15:06 +08:00
|
|
|
gint select_val;
|
|
|
|
struct timeval tv;
|
1997-11-25 06:05:25 +08:00
|
|
|
struct timeval *tvp;
|
|
|
|
|
|
|
|
if (timeout)
|
|
|
|
{
|
|
|
|
tv.tv_sec = timeout / 1000;
|
1999-03-07 20:56:03 +08:00
|
|
|
tv.tv_usec = (timeout % 1000) * 1000;
|
1997-11-25 06:05:25 +08:00
|
|
|
tvp = &tv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
tvp = NULL;
|
|
|
|
|
|
|
|
FD_ZERO (&readfds);
|
1999-03-07 20:56:03 +08:00
|
|
|
FD_SET (g_io_channel_unix_get_fd (_readchannel), &readfds);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if ((select_val = select (FD_SETSIZE, &readfds, NULL, NULL, tvp)) > 0)
|
|
|
|
{
|
2000-05-31 14:15:06 +08:00
|
|
|
gimp_single_message ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else if (select_val == -1)
|
|
|
|
{
|
|
|
|
perror ("gimp_process");
|
|
|
|
gimp_quit ();
|
|
|
|
}
|
1999-03-07 20:56:03 +08:00
|
|
|
#else
|
2000-08-02 00:09:16 +08:00
|
|
|
/* Zero means infinite wait for us, but g_poll and
|
2000-09-08 04:04:47 +08:00
|
|
|
* g_io_channel_win32_poll use -1 to indicate
|
2000-08-02 00:09:16 +08:00
|
|
|
* infinite wait.
|
|
|
|
*/
|
2000-09-08 04:04:47 +08:00
|
|
|
GPollFD pollfd;
|
|
|
|
|
2000-08-02 00:09:16 +08:00
|
|
|
if (timeout == 0)
|
|
|
|
timeout = -1;
|
2000-09-08 04:04:47 +08:00
|
|
|
|
|
|
|
g_io_channel_win32_make_pollfd (_readchannel, G_IO_IN, &pollfd);
|
|
|
|
|
|
|
|
if (g_io_channel_win32_poll (&pollfd, 1, timeout) == 1)
|
1999-03-07 20:56:03 +08:00
|
|
|
gimp_single_message ();
|
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-10-05 03:26:07 +08:00
|
|
|
gimp_extension_ack (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
/* Send an extension initialization acknowledgement */
|
1999-03-07 20:56:03 +08:00
|
|
|
if (! gp_extension_ack_write (_writechannel))
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_quit ();
|
|
|
|
}
|
|
|
|
|
1998-09-19 08:40:27 +08:00
|
|
|
void
|
1999-10-05 03:26:07 +08:00
|
|
|
gimp_run_temp (void)
|
1998-09-19 08:40:27 +08:00
|
|
|
{
|
2000-05-31 14:15:06 +08:00
|
|
|
gimp_single_message ();
|
1998-09-19 08:40:27 +08:00
|
|
|
}
|
|
|
|
|
These changes enable help support for 3rd party plug-ins which install
2000-05-21 Michael Natterer <mitch@gimp.org>
These changes enable help support for 3rd party plug-ins which
install their help files outside GIMP's main help dir.
Instead of calling gimp_help(), gimp_plugin_help_func() etc.,
all help callbacks now have to call gimp_standard_help_func()
which has different implementations in the app and in libgimp.
There is a new function gimp_plugin_help_register() which can
be called during plug-in query. plug_in.c keeps a list of
executable_name/help_path pairs. Plug-ins have to pass their
exec. name to gimp_help() which uses the list to find the plug-in's
help directory.
* app/gimphelp.[ch]: gimp_help() now takes a help_path parameter.
help_path == NULL means the standard help directory. Various
changes to pass the help_path to the help browser.
* app/gimprc.c: save the plug-in's help_path in the pluginrc file.
* app/menus.c: ugly hack to enable help_paths in the "F1" callback.
* app/plug_in.[ch]: many help_path related changes. Use g_basename()
instead of strrchr(str,G_DIR_SEPARATOR), cosmetic cleanups.
* app/internal_procs.c
* app/gimphelp_cmds.c
* tools/pdbgen/pdb/gimphelp.pdb: new procedure
gimp_plugin_help_register(). gimp_help() takes a second parameter
which is the executable name (not the help_path).
* app/color_notebook.c
* app/commands.c
* app/lc_dialog.c
* app/preferences_dialog.c
* app/tools.c: call gimp_standard_help_func() instead of gimp_help().
* libgimp/gimp.c: new function gimp_get_progname() which returns
the full path of the plug-in's executable.
* libgimp/gimp.h: export the new function,
removed gimp_plugin_help_func(), gimp_help() takes the executable
name as second parameter.
* libgimp/gimpcompat.h: added gimp_plugin_help_func().
* libgimp/gimphelp.c: a wrapper for gimp_plugin_help_register(),
changed the calls to gimp_help.
* libgimp/gimphelpui.[ch]: call gimp_standard_help_func() instead
of gimp_help().
* plug-ins/helpbrowser/helpbrowser.c: now called with an additional
help_path parameter. Various changes to enable
help_path != gimp_standard_help_path.
Unrelated stuff:
* app/batch.h: added missing GPL header.
* app/gimpunit.c: had a LGPL header, merged some fprintf's into
one call.
* app/procedural_db.[ch]: cosmetic: g* types, s/g_malloc/g_new/,
prototypes, indentation.
* app/resize.c: use less packing widgets. didn't find the "offset"
redraw bug :(
2000-05-22 01:41:02 +08:00
|
|
|
gchar *
|
|
|
|
gimp_get_progname (void)
|
|
|
|
{
|
|
|
|
return progname;
|
|
|
|
}
|
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
void
|
|
|
|
gimp_attach_new_parasite (const gchar *name,
|
|
|
|
gint flags,
|
|
|
|
gint size,
|
|
|
|
const gpointer data)
|
|
|
|
{
|
|
|
|
GimpParasite *parasite = gimp_parasite_new (name, flags, size, data);
|
|
|
|
|
|
|
|
gimp_parasite_attach (parasite);
|
|
|
|
|
|
|
|
gimp_parasite_free (parasite);
|
|
|
|
}
|
|
|
|
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifndef G_OS_WIN32
|
2000-04-22 00:42:11 +08:00
|
|
|
static void
|
2000-05-11 05:21:23 +08:00
|
|
|
gimp_plugin_sigfatal_handler (gint sig_num)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-11 05:21:23 +08:00
|
|
|
switch (sig_num)
|
1998-04-11 13:07:52 +08:00
|
|
|
{
|
2000-05-11 05:21:23 +08:00
|
|
|
case SIGHUP:
|
|
|
|
case SIGINT:
|
|
|
|
case SIGQUIT:
|
|
|
|
case SIGABRT:
|
|
|
|
case SIGTERM:
|
2000-07-16 20:49:04 +08:00
|
|
|
g_printerr ("%s terminated: %s\n", progname, g_strsignal (sig_num));
|
2000-05-11 05:21:23 +08:00
|
|
|
break;
|
|
|
|
|
1998-04-11 13:07:52 +08:00
|
|
|
case SIGBUS:
|
|
|
|
case SIGSEGV:
|
|
|
|
case SIGFPE:
|
2000-05-11 05:21:23 +08:00
|
|
|
case SIGPIPE:
|
1998-04-11 13:07:52 +08:00
|
|
|
default:
|
2000-07-16 20:49:04 +08:00
|
|
|
g_printerr ("%s: fatal error: %s\n", progname, g_strsignal (sig_num));
|
|
|
|
switch (stack_trace_mode)
|
2000-05-11 05:21:23 +08:00
|
|
|
{
|
2000-07-16 20:49:04 +08:00
|
|
|
case GIMP_STACK_TRACE_NEVER:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_STACK_TRACE_QUERY:
|
|
|
|
{
|
|
|
|
sigset_t sigset;
|
|
|
|
|
|
|
|
sigemptyset (&sigset);
|
|
|
|
sigprocmask (SIG_SETMASK, &sigset, NULL);
|
|
|
|
g_on_error_query (progname);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_STACK_TRACE_ALWAYS:
|
|
|
|
{
|
|
|
|
sigset_t sigset;
|
2000-05-11 05:21:23 +08:00
|
|
|
|
2000-07-16 20:49:04 +08:00
|
|
|
sigemptyset (&sigset);
|
|
|
|
sigprocmask (SIG_SETMASK, &sigset, NULL);
|
|
|
|
g_on_error_stack_trace (progname);
|
|
|
|
}
|
|
|
|
break;
|
2000-05-11 05:21:23 +08:00
|
|
|
}
|
1998-04-11 13:07:52 +08:00
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gimp_quit ();
|
|
|
|
}
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-11 05:21:23 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_plugin_io_error_handler (GIOChannel *channel,
|
|
|
|
GIOCondition cond,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2000-07-16 20:49:04 +08:00
|
|
|
g_printerr ("%s: fatal error: GIMP crashed\n", progname);
|
2000-05-11 05:21:23 +08:00
|
|
|
gimp_quit ();
|
2000-05-12 20:39:46 +08:00
|
|
|
|
|
|
|
/* never reached */
|
|
|
|
return TRUE;
|
2000-05-11 05:21:23 +08:00
|
|
|
}
|
|
|
|
|
2000-05-31 14:15:06 +08:00
|
|
|
static gboolean
|
2000-03-26 02:49:05 +08:00
|
|
|
gimp_write (GIOChannel *channel,
|
|
|
|
guint8 *buf,
|
|
|
|
gulong count)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
gulong bytes;
|
|
|
|
|
|
|
|
while (count > 0)
|
|
|
|
{
|
|
|
|
if ((write_buffer_index + count) >= WRITE_BUFFER_SIZE)
|
|
|
|
{
|
|
|
|
bytes = WRITE_BUFFER_SIZE - write_buffer_index;
|
|
|
|
memcpy (&write_buffer[write_buffer_index], buf, bytes);
|
|
|
|
write_buffer_index += bytes;
|
1999-03-07 20:56:03 +08:00
|
|
|
if (!wire_flush (channel))
|
1997-11-25 06:05:25 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bytes = count;
|
|
|
|
memcpy (&write_buffer[write_buffer_index], buf, bytes);
|
|
|
|
write_buffer_index += bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf += bytes;
|
|
|
|
count -= bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-05-31 14:15:06 +08:00
|
|
|
static gboolean
|
1999-03-07 20:56:03 +08:00
|
|
|
gimp_flush (GIOChannel *channel)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-08-30 01:48:28 +08:00
|
|
|
GIOStatus status;
|
2001-08-30 09:09:58 +08:00
|
|
|
GError *error = NULL;
|
2001-08-30 01:48:28 +08:00
|
|
|
gsize count;
|
|
|
|
gsize bytes;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (write_buffer_index > 0)
|
|
|
|
{
|
|
|
|
count = 0;
|
|
|
|
while (count != write_buffer_index)
|
|
|
|
{
|
2000-05-31 14:15:06 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
bytes = 0;
|
2001-08-30 01:48:28 +08:00
|
|
|
status = g_io_channel_write_chars (channel,
|
|
|
|
&write_buffer[count],
|
|
|
|
(write_buffer_index - count),
|
|
|
|
&bytes,
|
|
|
|
&error);
|
2000-05-31 14:15:06 +08:00
|
|
|
}
|
2001-08-30 01:48:28 +08:00
|
|
|
while (status == G_IO_STATUS_AGAIN);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-08-30 01:48:28 +08:00
|
|
|
if (status != G_IO_STATUS_NORMAL)
|
|
|
|
{
|
2001-08-30 09:09:58 +08:00
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
g_warning ("%s: gimp_flush(): error: %s",
|
|
|
|
g_get_prgname (), error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("%s: gimp_flush(): error",
|
|
|
|
g_get_prgname ());
|
|
|
|
}
|
|
|
|
|
2001-08-30 01:48:28 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
count += bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
write_buffer_index = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-03-26 02:49:05 +08:00
|
|
|
gimp_loop (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
WireMessage msg;
|
|
|
|
|
2000-03-26 02:49:05 +08:00
|
|
|
while (TRUE)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-03-07 20:56:03 +08:00
|
|
|
if (!wire_read_msg (_readchannel, &msg))
|
1999-03-13 05:30:44 +08:00
|
|
|
{
|
|
|
|
gimp_close ();
|
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
switch (msg.type)
|
|
|
|
{
|
|
|
|
case GP_QUIT:
|
1999-03-13 05:30:44 +08:00
|
|
|
gimp_close ();
|
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_CONFIG:
|
|
|
|
gimp_config (msg.data);
|
|
|
|
break;
|
|
|
|
case GP_TILE_REQ:
|
|
|
|
case GP_TILE_ACK:
|
|
|
|
case GP_TILE_DATA:
|
|
|
|
g_warning ("unexpected tile message received (should not happen)\n");
|
|
|
|
break;
|
|
|
|
case GP_PROC_RUN:
|
|
|
|
gimp_proc_run (msg.data);
|
1999-03-13 05:30:44 +08:00
|
|
|
gimp_close ();
|
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
case GP_PROC_RETURN:
|
|
|
|
g_warning ("unexpected proc return message received (should not happen)\n");
|
|
|
|
break;
|
|
|
|
case GP_TEMP_PROC_RUN:
|
|
|
|
g_warning ("unexpected temp proc run message received (should not happen\n");
|
|
|
|
break;
|
|
|
|
case GP_TEMP_PROC_RETURN:
|
|
|
|
g_warning ("unexpected temp proc return message received (should not happen\n");
|
|
|
|
break;
|
|
|
|
case GP_PROC_INSTALL:
|
|
|
|
g_warning ("unexpected proc install message received (should not happen)\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
wire_destroy (&msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_config (GPConfig *config)
|
|
|
|
{
|
|
|
|
extern gint _gimp_tile_width;
|
|
|
|
extern gint _gimp_tile_height;
|
|
|
|
|
|
|
|
if (config->version < GP_VERSION)
|
|
|
|
{
|
2001-02-14 12:55:21 +08:00
|
|
|
g_message ("Could not execute plug-in \"%s\"\n(%s)"
|
|
|
|
"because the GIMP is using an older version of the "
|
|
|
|
"plug-in protocol.",
|
2001-08-30 01:48:28 +08:00
|
|
|
g_get_prgname (), progname);
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_quit ();
|
|
|
|
}
|
|
|
|
else if (config->version > GP_VERSION)
|
|
|
|
{
|
2001-02-14 12:55:21 +08:00
|
|
|
g_message ("Could not execute plug-in \"%s\"\n(%s)"
|
|
|
|
"because it uses an obsolete version of the "
|
|
|
|
"plug-in protocol.",
|
2001-08-30 01:48:28 +08:00
|
|
|
g_get_prgname (), progname);
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_quit ();
|
|
|
|
}
|
|
|
|
|
2000-05-01 02:17:55 +08:00
|
|
|
_gimp_tile_width = config->tile_width;
|
1997-11-25 06:05:25 +08:00
|
|
|
_gimp_tile_height = config->tile_height;
|
2000-05-01 02:17:55 +08:00
|
|
|
_shm_ID = config->shm_ID;
|
|
|
|
_gamma_val = config->gamma;
|
|
|
|
_install_cmap = config->install_cmap;
|
|
|
|
_min_colors = config->min_colors;
|
|
|
|
_gdisp_ID = config->gdisp_ID;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (_shm_ID != -1)
|
|
|
|
{
|
1999-10-07 05:27:18 +08:00
|
|
|
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
1999-03-07 20:56:03 +08:00
|
|
|
/*
|
|
|
|
* Use Win32 shared memory mechanisms for
|
|
|
|
* transfering tile data
|
|
|
|
*/
|
2000-03-26 02:49:05 +08:00
|
|
|
gchar fileMapName[128];
|
2000-05-31 14:15:06 +08:00
|
|
|
gint tileByteSize = _gimp_tile_width * _gimp_tile_height * 4;
|
2000-05-12 20:39:46 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
/* From the id, derive the file map name */
|
2000-05-12 20:39:46 +08:00
|
|
|
g_snprintf (fileMapName, sizeof (fileMapName), "GIMP%d.SHM", _shm_ID);
|
1999-03-07 20:56:03 +08:00
|
|
|
|
|
|
|
/* Open the file mapping */
|
|
|
|
shm_handle = OpenFileMapping (FILE_MAP_ALL_ACCESS,
|
|
|
|
0, fileMapName);
|
|
|
|
if (shm_handle)
|
|
|
|
{
|
|
|
|
/* Map the shared memory into our address space for use */
|
|
|
|
_shm_addr = (guchar *) MapViewOfFile (shm_handle,
|
|
|
|
FILE_MAP_ALL_ACCESS,
|
|
|
|
0, 0, tileByteSize);
|
|
|
|
|
|
|
|
/* Verify that we mapped our view */
|
|
|
|
if (!_shm_addr)
|
|
|
|
{
|
|
|
|
g_warning ("MapViewOfFile error: %d... disabling shared memory transport",
|
|
|
|
GetLastError());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("OpenFileMapping error: %d... disabling shared memory transport",
|
|
|
|
GetLastError());
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#ifdef HAVE_SHM_H
|
1997-11-25 06:05:25 +08:00
|
|
|
_shm_addr = (guchar*) shmat (_shm_ID, 0, 0);
|
|
|
|
|
|
|
|
if (_shm_addr == (guchar*) -1)
|
|
|
|
g_error ("could not attach to gimp shared memory segment\n");
|
1998-08-29 07:01:46 +08:00
|
|
|
#endif
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_proc_run (GPProcRun *proc_run)
|
|
|
|
{
|
|
|
|
GPProcReturn proc_return;
|
2000-05-31 14:15:06 +08:00
|
|
|
GimpParam *return_vals;
|
2000-03-26 02:49:05 +08:00
|
|
|
gint nreturn_vals;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (PLUG_IN_INFO.run_proc)
|
|
|
|
{
|
|
|
|
(* PLUG_IN_INFO.run_proc) (proc_run->name,
|
|
|
|
proc_run->nparams,
|
2000-05-31 14:15:06 +08:00
|
|
|
(GimpParam*) proc_run->params,
|
1997-11-25 06:05:25 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
&return_vals);
|
|
|
|
|
|
|
|
proc_return.name = proc_run->name;
|
|
|
|
proc_return.nparams = nreturn_vals;
|
|
|
|
proc_return.params = (GPParam*) return_vals;
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
if (!gp_proc_return_write (_writechannel, &proc_return))
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_quit ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_temp_proc_run (GPProcRun *proc_run)
|
|
|
|
{
|
2000-05-31 14:15:06 +08:00
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
GimpRunProc run_proc;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-31 21:24:14 +08:00
|
|
|
run_proc = (GimpRunProc) g_hash_table_lookup (temp_proc_ht,
|
|
|
|
(gpointer) proc_run->name);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (run_proc)
|
|
|
|
{
|
|
|
|
(* run_proc) (proc_run->name,
|
|
|
|
proc_run->nparams,
|
2000-05-31 14:15:06 +08:00
|
|
|
(GimpParam*) proc_run->params,
|
1997-11-25 06:05:25 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
&return_vals);
|
|
|
|
|
1998-09-19 08:40:27 +08:00
|
|
|
/* No longer a return message */
|
|
|
|
/* proc_return.name = proc_run->name; */
|
|
|
|
/* proc_return.nparams = nreturn_vals; */
|
|
|
|
/* proc_return.params = (GPParam*) return_vals; */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
/* if (!gp_temp_proc_return_write (_writechannel, &proc_return)) */
|
1998-09-19 08:40:27 +08:00
|
|
|
/* gimp_quit (); */
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|