gimp/plug-ins/script-fu/script-fu-console.c

659 lines
18 KiB
C
Raw Normal View History

1997-11-24 22:05:25 +00:00
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1997-11-24 22:05:25 +00:00
*/
New file. * plug-ins/makefile.msc: New file. * plug-ins/*/*.c (Well, not really all files, but many): Portability fixes. Include config.h, and guard inclusion of POSIX and Unix headers like <unistd.h>, <dirent.h> and <sys/time.h>. Include <string.h> if functions from it are used. Use g_ntohl() and g_htonl() insteead of ntohl() and htonl(), thus no need to include <netinet/in.h>. Include <io.h> on Win32 when using open/read/write (which actually are defined as _open/_read/_write by glib.h). Define S_* macros if necessary on Win32. Define rint() and M_PI if necessary (these definitions should be factored out somewhere, no sense repeating them in lots of files). Open files in binary mode when needed. * plug-ins/FractalExplorer/FractalExplorer.c: Use g_malloc()/g_free(). Use g_strdup_printf(). * plug-ins/dbbrowser/dbbrowser.c: No need to include <X11/Xlib.h>. * plug-ins/destripe/destripe.c: Guard use of SIGBUS. * plug-ins/{flame/flame,hrz/hrz,pnm/pnm}.c: No need to check for NULL returns from g_malloc() and g_new() as they abort on failure. Use g_strdup_printf(). * plug-ins/gz/gz.c: Win32 version of running the subprocess. * plug-ins/hrz/hrz.c: Win32 version. Use more generic tests for non-Unix (OS/2 and Win32), for instance HAVE_MMAP. * plug-ins/script-fu/interp_slib.c: Win32 version of myruntime(). * plug-ins/script-fu/interp_sliba.c: Handle \\ (escaped backslahsh). * plug-ins/script-fu/script-fu-console.c: Bypass on Win32. * plug-ins/script-fu/script-fu-scripts.c: Portability fixes. Use g_strdup_printf() instead of separate malloc() and sprintf(). Use g_strescape() for strings being passed to Scheme. Some Win32-only stuff.
1999-05-29 01:28:24 +00:00
#include "config.h"
1997-11-24 22:05:25 +00:00
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
1999-04-25 19:30:31 +00:00
#include <sys/types.h>
New file. * plug-ins/makefile.msc: New file. * plug-ins/*/*.c (Well, not really all files, but many): Portability fixes. Include config.h, and guard inclusion of POSIX and Unix headers like <unistd.h>, <dirent.h> and <sys/time.h>. Include <string.h> if functions from it are used. Use g_ntohl() and g_htonl() insteead of ntohl() and htonl(), thus no need to include <netinet/in.h>. Include <io.h> on Win32 when using open/read/write (which actually are defined as _open/_read/_write by glib.h). Define S_* macros if necessary on Win32. Define rint() and M_PI if necessary (these definitions should be factored out somewhere, no sense repeating them in lots of files). Open files in binary mode when needed. * plug-ins/FractalExplorer/FractalExplorer.c: Use g_malloc()/g_free(). Use g_strdup_printf(). * plug-ins/dbbrowser/dbbrowser.c: No need to include <X11/Xlib.h>. * plug-ins/destripe/destripe.c: Guard use of SIGBUS. * plug-ins/{flame/flame,hrz/hrz,pnm/pnm}.c: No need to check for NULL returns from g_malloc() and g_new() as they abort on failure. Use g_strdup_printf(). * plug-ins/gz/gz.c: Win32 version of running the subprocess. * plug-ins/hrz/hrz.c: Win32 version. Use more generic tests for non-Unix (OS/2 and Win32), for instance HAVE_MMAP. * plug-ins/script-fu/interp_slib.c: Win32 version of myruntime(). * plug-ins/script-fu/interp_sliba.c: Handle \\ (escaped backslahsh). * plug-ins/script-fu/script-fu-console.c: Bypass on Win32. * plug-ins/script-fu/script-fu-scripts.c: Portability fixes. Use g_strdup_printf() instead of separate malloc() and sprintf(). Use g_strescape() for strings being passed to Scheme. Some Win32-only stuff.
1999-05-29 01:28:24 +00:00
#if HAVE_DIRENT_H
1997-11-24 22:05:25 +00:00
#include <dirent.h>
New file. * plug-ins/makefile.msc: New file. * plug-ins/*/*.c (Well, not really all files, but many): Portability fixes. Include config.h, and guard inclusion of POSIX and Unix headers like <unistd.h>, <dirent.h> and <sys/time.h>. Include <string.h> if functions from it are used. Use g_ntohl() and g_htonl() insteead of ntohl() and htonl(), thus no need to include <netinet/in.h>. Include <io.h> on Win32 when using open/read/write (which actually are defined as _open/_read/_write by glib.h). Define S_* macros if necessary on Win32. Define rint() and M_PI if necessary (these definitions should be factored out somewhere, no sense repeating them in lots of files). Open files in binary mode when needed. * plug-ins/FractalExplorer/FractalExplorer.c: Use g_malloc()/g_free(). Use g_strdup_printf(). * plug-ins/dbbrowser/dbbrowser.c: No need to include <X11/Xlib.h>. * plug-ins/destripe/destripe.c: Guard use of SIGBUS. * plug-ins/{flame/flame,hrz/hrz,pnm/pnm}.c: No need to check for NULL returns from g_malloc() and g_new() as they abort on failure. Use g_strdup_printf(). * plug-ins/gz/gz.c: Win32 version of running the subprocess. * plug-ins/hrz/hrz.c: Win32 version. Use more generic tests for non-Unix (OS/2 and Win32), for instance HAVE_MMAP. * plug-ins/script-fu/interp_slib.c: Win32 version of myruntime(). * plug-ins/script-fu/interp_sliba.c: Handle \\ (escaped backslahsh). * plug-ins/script-fu/script-fu-console.c: Bypass on Win32. * plug-ins/script-fu/script-fu-scripts.c: Portability fixes. Use g_strdup_printf() instead of separate malloc() and sprintf(). Use g_strescape() for strings being passed to Scheme. Some Win32-only stuff.
1999-05-29 01:28:24 +00:00
#endif
#if HAVE_UNISTD_H
1997-11-24 22:05:25 +00:00
#include <unistd.h>
New file. * plug-ins/makefile.msc: New file. * plug-ins/*/*.c (Well, not really all files, but many): Portability fixes. Include config.h, and guard inclusion of POSIX and Unix headers like <unistd.h>, <dirent.h> and <sys/time.h>. Include <string.h> if functions from it are used. Use g_ntohl() and g_htonl() insteead of ntohl() and htonl(), thus no need to include <netinet/in.h>. Include <io.h> on Win32 when using open/read/write (which actually are defined as _open/_read/_write by glib.h). Define S_* macros if necessary on Win32. Define rint() and M_PI if necessary (these definitions should be factored out somewhere, no sense repeating them in lots of files). Open files in binary mode when needed. * plug-ins/FractalExplorer/FractalExplorer.c: Use g_malloc()/g_free(). Use g_strdup_printf(). * plug-ins/dbbrowser/dbbrowser.c: No need to include <X11/Xlib.h>. * plug-ins/destripe/destripe.c: Guard use of SIGBUS. * plug-ins/{flame/flame,hrz/hrz,pnm/pnm}.c: No need to check for NULL returns from g_malloc() and g_new() as they abort on failure. Use g_strdup_printf(). * plug-ins/gz/gz.c: Win32 version of running the subprocess. * plug-ins/hrz/hrz.c: Win32 version. Use more generic tests for non-Unix (OS/2 and Win32), for instance HAVE_MMAP. * plug-ins/script-fu/interp_slib.c: Win32 version of myruntime(). * plug-ins/script-fu/interp_sliba.c: Handle \\ (escaped backslahsh). * plug-ins/script-fu/script-fu-console.c: Bypass on Win32. * plug-ins/script-fu/script-fu-scripts.c: Portability fixes. Use g_strdup_printf() instead of separate malloc() and sprintf(). Use g_strescape() for strings being passed to Scheme. Some Win32-only stuff.
1999-05-29 01:28:24 +00:00
#endif
1997-11-24 22:05:25 +00:00
#include <sys/stat.h>
New file. * plug-ins/makefile.msc: New file. * plug-ins/*/*.c (Well, not really all files, but many): Portability fixes. Include config.h, and guard inclusion of POSIX and Unix headers like <unistd.h>, <dirent.h> and <sys/time.h>. Include <string.h> if functions from it are used. Use g_ntohl() and g_htonl() insteead of ntohl() and htonl(), thus no need to include <netinet/in.h>. Include <io.h> on Win32 when using open/read/write (which actually are defined as _open/_read/_write by glib.h). Define S_* macros if necessary on Win32. Define rint() and M_PI if necessary (these definitions should be factored out somewhere, no sense repeating them in lots of files). Open files in binary mode when needed. * plug-ins/FractalExplorer/FractalExplorer.c: Use g_malloc()/g_free(). Use g_strdup_printf(). * plug-ins/dbbrowser/dbbrowser.c: No need to include <X11/Xlib.h>. * plug-ins/destripe/destripe.c: Guard use of SIGBUS. * plug-ins/{flame/flame,hrz/hrz,pnm/pnm}.c: No need to check for NULL returns from g_malloc() and g_new() as they abort on failure. Use g_strdup_printf(). * plug-ins/gz/gz.c: Win32 version of running the subprocess. * plug-ins/hrz/hrz.c: Win32 version. Use more generic tests for non-Unix (OS/2 and Win32), for instance HAVE_MMAP. * plug-ins/script-fu/interp_slib.c: Win32 version of myruntime(). * plug-ins/script-fu/interp_sliba.c: Handle \\ (escaped backslahsh). * plug-ins/script-fu/script-fu-console.c: Bypass on Win32. * plug-ins/script-fu/script-fu-scripts.c: Portability fixes. Use g_strdup_printf() instead of separate malloc() and sprintf(). Use g_strescape() for strings being passed to Scheme. Some Win32-only stuff.
1999-05-29 01:28:24 +00:00
1997-11-24 22:05:25 +00:00
#include "gdk/gdkkeysyms.h"
#include "gtk/gtk.h"
New file. * plug-ins/makefile.msc: New file. * plug-ins/*/*.c (Well, not really all files, but many): Portability fixes. Include config.h, and guard inclusion of POSIX and Unix headers like <unistd.h>, <dirent.h> and <sys/time.h>. Include <string.h> if functions from it are used. Use g_ntohl() and g_htonl() insteead of ntohl() and htonl(), thus no need to include <netinet/in.h>. Include <io.h> on Win32 when using open/read/write (which actually are defined as _open/_read/_write by glib.h). Define S_* macros if necessary on Win32. Define rint() and M_PI if necessary (these definitions should be factored out somewhere, no sense repeating them in lots of files). Open files in binary mode when needed. * plug-ins/FractalExplorer/FractalExplorer.c: Use g_malloc()/g_free(). Use g_strdup_printf(). * plug-ins/dbbrowser/dbbrowser.c: No need to include <X11/Xlib.h>. * plug-ins/destripe/destripe.c: Guard use of SIGBUS. * plug-ins/{flame/flame,hrz/hrz,pnm/pnm}.c: No need to check for NULL returns from g_malloc() and g_new() as they abort on failure. Use g_strdup_printf(). * plug-ins/gz/gz.c: Win32 version of running the subprocess. * plug-ins/hrz/hrz.c: Win32 version. Use more generic tests for non-Unix (OS/2 and Win32), for instance HAVE_MMAP. * plug-ins/script-fu/interp_slib.c: Win32 version of myruntime(). * plug-ins/script-fu/interp_sliba.c: Handle \\ (escaped backslahsh). * plug-ins/script-fu/script-fu-console.c: Bypass on Win32. * plug-ins/script-fu/script-fu-scripts.c: Portability fixes. Use g_strdup_printf() instead of separate malloc() and sprintf(). Use g_strescape() for strings being passed to Scheme. Some Win32-only stuff.
1999-05-29 01:28:24 +00:00
1997-11-24 22:05:25 +00:00
#include "libgimp/gimp.h"
#include "libgimp/gimpui.h"
2000-02-27 19:35:39 +00:00
#include "script-fu-intl.h"
New file. * plug-ins/makefile.msc: New file. * plug-ins/*/*.c (Well, not really all files, but many): Portability fixes. Include config.h, and guard inclusion of POSIX and Unix headers like <unistd.h>, <dirent.h> and <sys/time.h>. Include <string.h> if functions from it are used. Use g_ntohl() and g_htonl() insteead of ntohl() and htonl(), thus no need to include <netinet/in.h>. Include <io.h> on Win32 when using open/read/write (which actually are defined as _open/_read/_write by glib.h). Define S_* macros if necessary on Win32. Define rint() and M_PI if necessary (these definitions should be factored out somewhere, no sense repeating them in lots of files). Open files in binary mode when needed. * plug-ins/FractalExplorer/FractalExplorer.c: Use g_malloc()/g_free(). Use g_strdup_printf(). * plug-ins/dbbrowser/dbbrowser.c: No need to include <X11/Xlib.h>. * plug-ins/destripe/destripe.c: Guard use of SIGBUS. * plug-ins/{flame/flame,hrz/hrz,pnm/pnm}.c: No need to check for NULL returns from g_malloc() and g_new() as they abort on failure. Use g_strdup_printf(). * plug-ins/gz/gz.c: Win32 version of running the subprocess. * plug-ins/hrz/hrz.c: Win32 version. Use more generic tests for non-Unix (OS/2 and Win32), for instance HAVE_MMAP. * plug-ins/script-fu/interp_slib.c: Win32 version of myruntime(). * plug-ins/script-fu/interp_sliba.c: Handle \\ (escaped backslahsh). * plug-ins/script-fu/script-fu-console.c: Bypass on Win32. * plug-ins/script-fu/script-fu-scripts.c: Portability fixes. Use g_strdup_printf() instead of separate malloc() and sprintf(). Use g_strescape() for strings being passed to Scheme. Some Win32-only stuff.
1999-05-29 01:28:24 +00:00
new code to call the script_fuc_text_console pdb function. remove batch 2001-07-17 Mathieu Lacage <mathieu@gnome.org> * app/batch.c: new code to call the script_fuc_text_console pdb function. * app/main.c: (main): remove batch command code. * plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c * plug-ins/script-fu/script-fu-console.c: (script_fu_cc_key_function), (script_fu_open_siod_console), (script_fu_close_siod_console): * plug-ins/script-fu/script-fu-scripts.h: * plug-ins/script-fu/script-fu-server.c: (script_fu_server_quit), (script_fu_server_get_mode), (execute_command): Replace all direct calls to the scheme interpreter with calls to the siod-wrapper. * plug-ins/script-fu/script-fu-console.h: remove run_eval. * plug-ins/script-fu/script-fu-server.h: * plug-ins/script-fu/script-fu-text-console.c: (script_fu_text_console_run), (read_command), (script_fu_text_console_interface): The actual new text console. * plug-ins/script-fu/script-fu-text-console.h: header. * plug-ins/script-fu/script-fu.c: (script_fu_quit), (script_fu_query), (script_fu_run): rename to better words. move most of the code to siod-wrapper.c/h * plug-ins/script-fu/siod-wrapper.c: (siod_get_output_file), (siod_set_output_file), (siod_get_verbose_level), (siod_set_verbose_level), (siod_print_welcome), (siod_interpret_string), (siod_get_error_msg), (siod_get_success_msg), (siod_init), (init_procedures), (init_constants), (convert_string), (sputs_fcn), (lprin1s), (marshall_proc_db_call), (script_fu_register_call), (script_fu_quit_call): All the funcitons dealing with the internals of the scheme interpreter. * plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
#include "siod-wrapper.h"
1997-11-24 22:05:25 +00:00
#include "script-fu-console.h"
#include <plug-ins/dbbrowser/dbbrowser_utils.h>
1997-11-24 22:05:25 +00:00
#ifdef G_OS_WIN32
New file. * plug-ins/makefile.msc: New file. * plug-ins/*/*.c (Well, not really all files, but many): Portability fixes. Include config.h, and guard inclusion of POSIX and Unix headers like <unistd.h>, <dirent.h> and <sys/time.h>. Include <string.h> if functions from it are used. Use g_ntohl() and g_htonl() insteead of ntohl() and htonl(), thus no need to include <netinet/in.h>. Include <io.h> on Win32 when using open/read/write (which actually are defined as _open/_read/_write by glib.h). Define S_* macros if necessary on Win32. Define rint() and M_PI if necessary (these definitions should be factored out somewhere, no sense repeating them in lots of files). Open files in binary mode when needed. * plug-ins/FractalExplorer/FractalExplorer.c: Use g_malloc()/g_free(). Use g_strdup_printf(). * plug-ins/dbbrowser/dbbrowser.c: No need to include <X11/Xlib.h>. * plug-ins/destripe/destripe.c: Guard use of SIGBUS. * plug-ins/{flame/flame,hrz/hrz,pnm/pnm}.c: No need to check for NULL returns from g_malloc() and g_new() as they abort on failure. Use g_strdup_printf(). * plug-ins/gz/gz.c: Win32 version of running the subprocess. * plug-ins/hrz/hrz.c: Win32 version. Use more generic tests for non-Unix (OS/2 and Win32), for instance HAVE_MMAP. * plug-ins/script-fu/interp_slib.c: Win32 version of myruntime(). * plug-ins/script-fu/interp_sliba.c: Handle \\ (escaped backslahsh). * plug-ins/script-fu/script-fu-console.c: Bypass on Win32. * plug-ins/script-fu/script-fu-scripts.c: Portability fixes. Use g_strdup_printf() instead of separate malloc() and sprintf(). Use g_strescape() for strings being passed to Scheme. Some Win32-only stuff.
1999-05-29 01:28:24 +00:00
#include <fcntl.h>
#include <io.h>
#endif
1997-11-24 22:05:25 +00:00
#define TEXT_WIDTH 400
#define TEXT_HEIGHT 400
#define ENTRY_WIDTH 400
#define BUFSIZE 256
typedef struct
{
GtkWidget *console;
GtkWidget *cc;
1997-11-24 22:05:25 +00:00
GtkAdjustment *vadj;
GdkFont *font_strong;
GdkFont *font_emphasis;
GdkFont *font_weak;
GdkFont *font;
1997-11-24 22:05:25 +00:00
gint32 input_id;
1997-11-24 22:05:25 +00:00
} ConsoleInterface;
/*
* Local Functions
*/
static void script_fu_console_interface (void);
static void script_fu_close_callback (GtkWidget *widget,
gpointer data);
static void script_fu_browse_callback (GtkWidget *widget,
gpointer data);
static gboolean script_fu_siod_read (GIOChannel *channel,
GIOCondition cond,
gpointer data);
static gboolean script_fu_cc_is_empty (void);
static gboolean script_fu_cc_key_function (GtkWidget *widget,
GdkEventKey *event,
gpointer data);
new code to call the script_fuc_text_console pdb function. remove batch 2001-07-17 Mathieu Lacage <mathieu@gnome.org> * app/batch.c: new code to call the script_fuc_text_console pdb function. * app/main.c: (main): remove batch command code. * plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c * plug-ins/script-fu/script-fu-console.c: (script_fu_cc_key_function), (script_fu_open_siod_console), (script_fu_close_siod_console): * plug-ins/script-fu/script-fu-scripts.h: * plug-ins/script-fu/script-fu-server.c: (script_fu_server_quit), (script_fu_server_get_mode), (execute_command): Replace all direct calls to the scheme interpreter with calls to the siod-wrapper. * plug-ins/script-fu/script-fu-console.h: remove run_eval. * plug-ins/script-fu/script-fu-server.h: * plug-ins/script-fu/script-fu-text-console.c: (script_fu_text_console_run), (read_command), (script_fu_text_console_interface): The actual new text console. * plug-ins/script-fu/script-fu-text-console.h: header. * plug-ins/script-fu/script-fu.c: (script_fu_quit), (script_fu_query), (script_fu_run): rename to better words. move most of the code to siod-wrapper.c/h * plug-ins/script-fu/siod-wrapper.c: (siod_get_output_file), (siod_set_output_file), (siod_get_verbose_level), (siod_set_verbose_level), (siod_print_welcome), (siod_interpret_string), (siod_get_error_msg), (siod_get_success_msg), (siod_init), (init_procedures), (init_constants), (convert_string), (sputs_fcn), (lprin1s), (marshall_proc_db_call), (script_fu_register_call), (script_fu_quit_call): All the funcitons dealing with the internals of the scheme interpreter. * plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
static void script_fu_open_siod_console (void);
static void script_fu_close_siod_console(void);
1997-11-24 22:05:25 +00:00
/*
* Local variables
*/
static ConsoleInterface cint =
{
NULL, /* console */
NULL, /* current command */
NULL, /* vertical adjustment */
NULL, /* strong font */
NULL, /* emphasis font */
NULL, /* weak font */
NULL, /* normal font */
-1 /* input id */
};
static gchar read_buffer[BUFSIZE];
static GList *history = NULL;
static gint history_len = 0;
static gint history_cur = 0;
static gint history_max = 50;
1997-11-24 22:05:25 +00:00
static gint siod_output_pipe[2];
1997-11-24 22:05:25 +00:00
#define message(string) printf("(%s): %d ::: %s\n", __PRETTY_FUNCTION__, __LINE__, string)
1997-11-24 22:05:25 +00:00
/*
* Function definitions
*/
void
script_fu_console_run (gchar *name,
gint nparams,
GimpParam *params,
gint *nreturn_vals,
GimpParam **return_vals)
1997-11-24 22:05:25 +00:00
{
static GimpParam values[1];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
GimpRunModeType run_mode;
1997-11-24 22:05:25 +00:00
run_mode = params[0].data.d_int32;
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
1997-11-24 22:05:25 +00:00
/* Enable SIOD output */
script_fu_open_siod_console ();
/* Run the interface */
script_fu_console_interface ();
/* Clean up */
script_fu_close_siod_console ();
break;
case GIMP_RUN_WITH_LAST_VALS:
case GIMP_RUN_NONINTERACTIVE:
status = GIMP_PDB_CALLING_ERROR;
gimp_message (_("Script-Fu console mode allows only interactive invocation"));
1997-11-24 22:05:25 +00:00
break;
default:
break;
}
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
1997-11-24 22:05:25 +00:00
values[0].data.d_status = status;
}
static void
script_fu_console_interface (void)
1997-11-24 22:05:25 +00:00
{
GtkWidget *dlg;
GtkWidget *button;
GtkWidget *label;
GtkWidget *vsb;
GtkWidget *table;
GtkWidget *hbox;
GIOChannel *input_channel;
1997-11-24 22:05:25 +00:00
INIT_I18N_UI();
gimprc.in replaced "color-cube" by "min-colors". 2000-04-30 Michael Natterer <mitch@gimp.org> * gimprc.in * app/gimprc.[ch]: replaced "color-cube" by "min-colors". * app/app_procs.c: read unitrc/gimprc before displaying the splash. * app/colormaps.c: set min_colors and install_cmap before initializing GdkRGB. * app/gimprc.[ch] * app/gimpunit.c: don't call the splash's progress_update function. * app/plug_in.c: pass min_colors instead of color_cube to plugins. * app/preferences_dialog.c: widget for min_colors. * libgimp/gimp.[ch]: s/color_cube/min_colors/ but left gimp_color_cube() there for source level compatibility. * libgimp/gimpprotocol.[ch]: changed the GPConfig message accordinly and increased the gimp protocol version number because the change breaks binary compatibility. Also actually pass the use_xshm variable over the wire (was only in the GPConfig struct before). Was it the right thing to do to increase the version number?? * libgimp/gimpui.c (gimp_ui_init): use the same code as the app for initializing GdkRGB. Never explicitly activate Gdk's SHM usage (only switch it off). * app/main.c * libgimp/gimp.c: reverted the handling of all signals except SIGCHLD back to plain old signal() because those signals are fatal anyway and sigaction() as used by gimp_signal_*() made debugging (stacktrace) impossible. * plug-ins/AlienMap/AlienMap.c * plug-ins/AlienMap2/AlienMap2.c * plug-ins/FractalExplorer/Dialogs.c * plug-ins/bmp/bmp.c * plug-ins/borderaverage/borderaverage.c * plug-ins/dbbrowser/dbbrowser.c * plug-ins/faxg3/faxg3.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp.c * plug-ins/fp/fp_gtk.c * plug-ins/gdyntext/Makefile.am * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/helpbrowser/helpbrowser.c * plug-ins/ifscompose/ifscompose.c * plug-ins/imagemap/Makefile.am * plug-ins/imagemap/imap_main.c * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print.c * plug-ins/rcm/rcm_dialog.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/Makefile.am * plug-ins/sel2path/sel2path.c * plug-ins/sgi/sgi.c * plug-ins/sinus/sinus.c * plug-ins/struc/struc.c * plug-ins/webbrowser/webbrowser.c * plug-ins/winsnap/winsnap.c * plug-ins/xjt/xjt.c: use gimp_ui_init(). * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c: only switch Gdk SHM usage off, never on. Don't use gimp_ui_init() here because of libgck.
2000-04-30 18:17:55 +00:00
gimp_ui_init ("script-fu", FALSE);
1997-11-24 22:05:25 +00:00
dlg = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (dlg), _("Script-Fu Console"));
gimp_help_connect_help_accel (dlg, gimp_standard_help_func,
"filters/script-fu.html");
1997-11-24 22:05:25 +00:00
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
(GtkSignalFunc) script_fu_close_callback,
NULL);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
&dlg);
added -DGTK_DISABLE_COMPAT_H to CPPFLAGS. 2000-08-28 Michael Natterer <mitch@gimp.org> * configure.in: added -DGTK_DISABLE_COMPAT_H to CPPFLAGS. * app/app_procs.c * app/gdisplay.c * app/layers_dialog.c * app/menus.c * app/tips_dialog.c * libgimp/gimpcolorbutton.c * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/bmp/bmpwrite.c * plug-ins/common/AlienMap.c * plug-ins/common/AlienMap2.c * plug-ins/common/CML_explorer.c * plug-ins/common/animationplay.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/deinterlace.c * plug-ins/common/gee.c * plug-ins/common/glasstile.c * plug-ins/common/iwarp.c * plug-ins/common/mail.c * plug-ins/common/pat.c * plug-ins/common/pixelize.c * plug-ins/common/plugindetails.c * plug-ins/common/png.c * plug-ins/common/sample_colorize.c * plug-ins/common/sel_gauss.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/tga.c * plug-ins/common/tileit.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/waves.c * plug-ins/common/wmf.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/gap/gap_arr_dialog.c * plug-ins/gap/gap_dbbrowser_utils.c * plug-ins/gap/gap_mov_dialog.c * plug-ins/gap/gap_navigator_dialog.c * plug-ins/gap/gap_resi_dialog.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/gfig/gfig.c * plug-ins/gimpressionist/brush.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/gimp_main_window.c * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/xjt/xjt.c: removed COMPAT_CRUFT.
2000-08-28 00:42:32 +00:00
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dlg)->vbox), 2);
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), 0);
1997-11-24 22:05:25 +00:00
/* Action area */
button = gtk_button_new_with_label (_("Close"));
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) gtk_widget_destroy,
(gpointer)dlg);
1997-11-24 22:05:25 +00:00
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0);
gtk_widget_show (button);
/* The info vbox */
label = gtk_label_new (_("SIOD Output"));
1997-11-24 22:05:25 +00:00
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), label, FALSE, TRUE, 0);
gtk_widget_show (label);
/* The output text widget */
cint.vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
vsb = gtk_vscrollbar_new (cint.vadj);
cint.console = gtk_text_new (NULL, cint.vadj);
gtk_text_set_editable (GTK_TEXT (cint.console), FALSE);
gtk_widget_set_usize (cint.console, TEXT_WIDTH, TEXT_HEIGHT);
table = gtk_table_new (1, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), table, TRUE, TRUE, 0);
gtk_table_attach (GTK_TABLE (table), vsb, 1, 2, 0, 1,
0, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table), cint.console, 0, 1, 0, 1,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
added -DGTK_DISABLE_COMPAT_H to CPPFLAGS. 2000-08-28 Michael Natterer <mitch@gimp.org> * configure.in: added -DGTK_DISABLE_COMPAT_H to CPPFLAGS. * app/app_procs.c * app/gdisplay.c * app/layers_dialog.c * app/menus.c * app/tips_dialog.c * libgimp/gimpcolorbutton.c * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/bmp/bmpwrite.c * plug-ins/common/AlienMap.c * plug-ins/common/AlienMap2.c * plug-ins/common/CML_explorer.c * plug-ins/common/animationplay.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/deinterlace.c * plug-ins/common/gee.c * plug-ins/common/glasstile.c * plug-ins/common/iwarp.c * plug-ins/common/mail.c * plug-ins/common/pat.c * plug-ins/common/pixelize.c * plug-ins/common/plugindetails.c * plug-ins/common/png.c * plug-ins/common/sample_colorize.c * plug-ins/common/sel_gauss.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/tga.c * plug-ins/common/tileit.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/waves.c * plug-ins/common/wmf.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/gap/gap_arr_dialog.c * plug-ins/gap/gap_dbbrowser_utils.c * plug-ins/gap/gap_mov_dialog.c * plug-ins/gap/gap_navigator_dialog.c * plug-ins/gap/gap_resi_dialog.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/gfig/gfig.c * plug-ins/gimpressionist/brush.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/gimp_main_window.c * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/xjt/xjt.c: removed COMPAT_CRUFT.
2000-08-28 00:42:32 +00:00
gtk_container_set_border_width (GTK_CONTAINER (table), 2);
1997-11-24 22:05:25 +00:00
cint.font_strong =
gdk_font_load ("-*-helvetica-bold-r-normal-*-*-120-*-*-*-*-*-*");
cint.font_emphasis =
gdk_font_load ("-*-helvetica-medium-o-normal-*-*-100-*-*-*-*-*-*");
cint.font_weak =
gdk_font_load ("-*-helvetica-medium-r-normal-*-*-100-*-*-*-*-*-*");
cint.font =
gdk_fontset_load ("-*-*-medium-r-normal-*-*-100-*-*-c-*-iso8859-1,*");
1997-11-24 22:05:25 +00:00
/* Realize the widget before allowing new text to be inserted */
gtk_widget_realize (cint.console);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_strong, NULL, NULL,
"The GIMP - GNU Image Manipulation Program\n\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_emphasis, NULL, NULL,
"Copyright (C) 1995-2001\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_emphasis, NULL, NULL,
"Spencer Kimball, Peter Mattis and the GIMP Development Team\n", -1);
1997-11-24 22:05:25 +00:00
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
"\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
"This program is free software; you can redistribute it and/or modify\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
"it under the terms of the GNU General Public License as published by\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
"the Free Software Foundation; either version 2 of the License, or\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
"(at your option) any later version.\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
"\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
"This program is distributed in the hope that it will be useful,\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
"See the GNU General Public License for more details.\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
"\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
"You should have received a copy of the GNU General Public License\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
"along with this program; if not, write to the Free Software\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
"Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n", -1);
1997-11-24 22:05:25 +00:00
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
"\n\n", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_strong, NULL, NULL,
"Script-Fu Console - ", -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font_emphasis, NULL, NULL,
"Interactive Scheme Development\n\n", -1);
gtk_widget_show (vsb);
gtk_widget_show (cint.console);
gtk_widget_show (table);
/* The current command */
label = gtk_label_new (_("Current Command"));
1997-11-24 22:05:25 +00:00
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), label, FALSE, TRUE, 0);
gtk_widget_show (label);
hbox = gtk_hbox_new ( FALSE, 0 );
gtk_widget_set_usize (hbox, ENTRY_WIDTH, 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), hbox, FALSE, TRUE, 0);
gtk_widget_show (hbox);
cint.cc = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (hbox), cint.cc,
TRUE, TRUE, 0);
GTK_WIDGET_SET_FLAGS (cint.cc, GTK_CAN_DEFAULT);
gtk_widget_grab_default (cint.cc);
gtk_signal_connect (GTK_OBJECT (cint.cc), "key_press_event",
(GtkSignalFunc) script_fu_cc_key_function,
NULL);
button = gtk_button_new_with_label (_("Browse..."));
1997-11-24 22:05:25 +00:00
gtk_box_pack_start (GTK_BOX (hbox), button,
FALSE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) script_fu_browse_callback,
NULL);
gtk_widget_show (button);
gtk_widget_show (cint.cc);
input_channel = g_io_channel_unix_new (siod_output_pipe[0]);
cint.input_id = g_io_add_watch (input_channel,
G_IO_IN,
script_fu_siod_read,
NULL);
1997-11-24 22:05:25 +00:00
/* Initialize the history */
history = g_list_append (history, NULL);
history_len = 1;
gtk_widget_show (dlg);
gtk_main ();
g_source_remove (cint.input_id);
if (dlg)
gtk_widget_destroy (dlg);
1997-11-24 22:05:25 +00:00
gdk_flush ();
}
static void
script_fu_close_callback (GtkWidget *widget,
gpointer data)
{
gtk_main_quit ();
}
void
apply_callback (gchar *proc_name,
gchar *scheme_proc_name,
gchar *proc_blurb,
gchar *proc_help,
gchar *proc_author,
gchar *proc_copyright,
gchar *proc_date,
GimpPDBProcType proc_type,
gint nparams,
gint nreturn_vals,
GimpParamDef *params,
GimpParamDef *return_vals)
1997-11-24 22:05:25 +00:00
{
gint i;
GString *text;
1997-11-24 22:05:25 +00:00
if (proc_name == NULL)
return;
text = g_string_new ("(");
text = g_string_append (text, scheme_proc_name);
for (i=0; i<nparams; i++)
{
text = g_string_append_c (text, ' ');
text = g_string_append (text, params[i].name);
}
text = g_string_append_c (text, ')');
gtk_entry_set_text (GTK_ENTRY (cint.cc), text->str);
g_string_free (text, TRUE);
1997-11-24 22:05:25 +00:00
}
static void
script_fu_browse_callback (GtkWidget *widget,
gpointer data)
1997-11-24 22:05:25 +00:00
{
gtk_quit_add_destroy (1, (GtkObject*) gimp_db_browser (apply_callback));
1997-11-24 22:05:25 +00:00
}
static gboolean
script_fu_console_scroll_end (gpointer data)
{
/* The Text widget in 1.0.1 doesn't like being scrolled before
* it is size-allocated, so we wait for it
*/
if ((cint.console->allocation.width > 1) &&
(cint.console->allocation.height > 1))
{
cint.vadj->value = cint.vadj->upper - cint.vadj->page_size;
gtk_signal_emit_by_name (GTK_OBJECT (cint.vadj), "changed");
}
else
gtk_idle_add (script_fu_console_scroll_end, NULL);
return FALSE;
}
static gboolean
script_fu_siod_read (GIOChannel *channel,
GIOCondition cond,
gpointer data)
1997-11-24 22:05:25 +00:00
{
static gboolean hack = FALSE;
gint count;
GIOError error;
1997-11-24 22:05:25 +00:00
count = 0;
error = g_io_channel_read (channel, read_buffer, BUFSIZE - 1, &count);
if (error == G_IO_ERROR_NONE)
1997-11-24 22:05:25 +00:00
{
#ifndef G_OS_WIN32
/* Is this needed any longer on Unix? */
if (!hack) /* this is a stupid hack, but as of 10/27/98
* the script-fu-console will hang on my system without it.
* the real cause of this needs to be tracked down.
* posibly a problem with the text widget, or the
* signal handlers not getting fully initialized or...
* no reports of hangs on other platforms, could just be a
* problem with my system.
*/
{
hack = TRUE;
return TRUE;
}
#endif
1997-11-24 22:05:25 +00:00
read_buffer[count] = '\0';
gtk_text_freeze (GTK_TEXT (cint.console));
gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL,
read_buffer, -1);
1997-11-24 22:05:25 +00:00
gtk_text_thaw (GTK_TEXT (cint.console));
script_fu_console_scroll_end (NULL);
1997-11-24 22:05:25 +00:00
}
return TRUE;
1997-11-24 22:05:25 +00:00
}
static gboolean
script_fu_cc_is_empty (void)
1997-11-24 22:05:25 +00:00
{
gchar *str;
1997-11-24 22:05:25 +00:00
if ((str = gtk_entry_get_text (GTK_ENTRY (cint.cc))) == NULL)
return TRUE;
while (*str)
{
if (*str != ' ' && *str != '\t' && *str != '\n')
return FALSE;
str ++;
}
return TRUE;
}
static gboolean
1997-11-24 22:05:25 +00:00
script_fu_cc_key_function (GtkWidget *widget,
GdkEventKey *event,
gpointer data)
{
GList *list;
gint direction = 0;
1997-11-24 22:05:25 +00:00
switch (event->keyval)
{
case GDK_Return:
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
if (script_fu_cc_is_empty ())
return TRUE;
list = g_list_nth (history, (g_list_length (history) - 1));
if (list->data)
g_free (list->data);
list->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (cint.cc)));
gtk_text_freeze (GTK_TEXT (cint.console));
gtk_text_insert (GTK_TEXT (cint.console), cint.font_strong, NULL, NULL,
"=> ", -1);
1997-11-24 22:05:25 +00:00
gtk_text_insert (GTK_TEXT (cint.console), cint.font, NULL, NULL,
gtk_entry_get_text (GTK_ENTRY (cint.cc)), -1);
gtk_text_insert (GTK_TEXT (cint.console), cint.font, NULL, NULL,
"\n\n", -1);
1997-11-24 22:05:25 +00:00
gtk_text_thaw (GTK_TEXT (cint.console));
cint.vadj->value = cint.vadj->upper - cint.vadj->page_size;
gtk_signal_emit_by_name (GTK_OBJECT (cint.vadj), "changed");
gtk_entry_set_text (GTK_ENTRY (cint.cc), "");
gdk_flush ();
new code to call the script_fuc_text_console pdb function. remove batch 2001-07-17 Mathieu Lacage <mathieu@gnome.org> * app/batch.c: new code to call the script_fuc_text_console pdb function. * app/main.c: (main): remove batch command code. * plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c * plug-ins/script-fu/script-fu-console.c: (script_fu_cc_key_function), (script_fu_open_siod_console), (script_fu_close_siod_console): * plug-ins/script-fu/script-fu-scripts.h: * plug-ins/script-fu/script-fu-server.c: (script_fu_server_quit), (script_fu_server_get_mode), (execute_command): Replace all direct calls to the scheme interpreter with calls to the siod-wrapper. * plug-ins/script-fu/script-fu-console.h: remove run_eval. * plug-ins/script-fu/script-fu-server.h: * plug-ins/script-fu/script-fu-text-console.c: (script_fu_text_console_run), (read_command), (script_fu_text_console_interface): The actual new text console. * plug-ins/script-fu/script-fu-text-console.h: header. * plug-ins/script-fu/script-fu.c: (script_fu_quit), (script_fu_query), (script_fu_run): rename to better words. move most of the code to siod-wrapper.c/h * plug-ins/script-fu/siod-wrapper.c: (siod_get_output_file), (siod_set_output_file), (siod_get_verbose_level), (siod_set_verbose_level), (siod_print_welcome), (siod_interpret_string), (siod_get_error_msg), (siod_get_success_msg), (siod_init), (init_procedures), (init_constants), (convert_string), (sputs_fcn), (lprin1s), (marshall_proc_db_call), (script_fu_register_call), (script_fu_quit_call): All the funcitons dealing with the internals of the scheme interpreter. * plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
siod_interpret_string ((char *) list->data);
1997-11-24 22:05:25 +00:00
gimp_displays_flush ();
history = g_list_append (history, NULL);
if (history_len == history_max)
{
history = g_list_remove (history, history->data);
if (history->data)
g_free (history->data);
}
else
history_len++;
history_cur = g_list_length (history) - 1;
return TRUE;
break;
case GDK_KP_Up:
case GDK_Up:
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
direction = -1;
break;
case GDK_KP_Down:
case GDK_Down:
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
direction = 1;
break;
case GDK_P:
case GDK_p:
if (event->state & GDK_CONTROL_MASK)
{
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
direction = -1;
}
break;
case GDK_N:
case GDK_n:
if (event->state & GDK_CONTROL_MASK)
{
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
direction = 1;
}
break;
default:
break;
}
if (direction)
{
/* Make sure we keep track of the current one */
if (history_cur == g_list_length (history) - 1)
{
list = g_list_nth (history, history_cur);
if (list->data)
g_free (list->data);
list->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (cint.cc)));
}
history_cur += direction;
if (history_cur < 0)
history_cur = 0;
if (history_cur >= history_len)
history_cur = history_len - 1;
gtk_entry_set_text (GTK_ENTRY (cint.cc),
(gchar *) (g_list_nth (history, history_cur))->data);
1997-11-24 22:05:25 +00:00
return TRUE;
}
return FALSE;
}
new code to call the script_fuc_text_console pdb function. remove batch 2001-07-17 Mathieu Lacage <mathieu@gnome.org> * app/batch.c: new code to call the script_fuc_text_console pdb function. * app/main.c: (main): remove batch command code. * plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c * plug-ins/script-fu/script-fu-console.c: (script_fu_cc_key_function), (script_fu_open_siod_console), (script_fu_close_siod_console): * plug-ins/script-fu/script-fu-scripts.h: * plug-ins/script-fu/script-fu-server.c: (script_fu_server_quit), (script_fu_server_get_mode), (execute_command): Replace all direct calls to the scheme interpreter with calls to the siod-wrapper. * plug-ins/script-fu/script-fu-console.h: remove run_eval. * plug-ins/script-fu/script-fu-server.h: * plug-ins/script-fu/script-fu-text-console.c: (script_fu_text_console_run), (read_command), (script_fu_text_console_interface): The actual new text console. * plug-ins/script-fu/script-fu-text-console.h: header. * plug-ins/script-fu/script-fu.c: (script_fu_quit), (script_fu_query), (script_fu_run): rename to better words. move most of the code to siod-wrapper.c/h * plug-ins/script-fu/siod-wrapper.c: (siod_get_output_file), (siod_set_output_file), (siod_get_verbose_level), (siod_set_verbose_level), (siod_print_welcome), (siod_interpret_string), (siod_get_error_msg), (siod_get_success_msg), (siod_init), (init_procedures), (init_constants), (convert_string), (sputs_fcn), (lprin1s), (marshall_proc_db_call), (script_fu_register_call), (script_fu_quit_call): All the funcitons dealing with the internals of the scheme interpreter. * plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
static void
script_fu_open_siod_console (void)
1997-11-24 22:05:25 +00:00
{
new code to call the script_fuc_text_console pdb function. remove batch 2001-07-17 Mathieu Lacage <mathieu@gnome.org> * app/batch.c: new code to call the script_fuc_text_console pdb function. * app/main.c: (main): remove batch command code. * plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c * plug-ins/script-fu/script-fu-console.c: (script_fu_cc_key_function), (script_fu_open_siod_console), (script_fu_close_siod_console): * plug-ins/script-fu/script-fu-scripts.h: * plug-ins/script-fu/script-fu-server.c: (script_fu_server_quit), (script_fu_server_get_mode), (execute_command): Replace all direct calls to the scheme interpreter with calls to the siod-wrapper. * plug-ins/script-fu/script-fu-console.h: remove run_eval. * plug-ins/script-fu/script-fu-server.h: * plug-ins/script-fu/script-fu-text-console.c: (script_fu_text_console_run), (read_command), (script_fu_text_console_interface): The actual new text console. * plug-ins/script-fu/script-fu-text-console.h: header. * plug-ins/script-fu/script-fu.c: (script_fu_quit), (script_fu_query), (script_fu_run): rename to better words. move most of the code to siod-wrapper.c/h * plug-ins/script-fu/siod-wrapper.c: (siod_get_output_file), (siod_set_output_file), (siod_get_verbose_level), (siod_set_verbose_level), (siod_print_welcome), (siod_interpret_string), (siod_get_error_msg), (siod_get_success_msg), (siod_init), (init_procedures), (init_constants), (convert_string), (sputs_fcn), (lprin1s), (marshall_proc_db_call), (script_fu_register_call), (script_fu_quit_call): All the funcitons dealing with the internals of the scheme interpreter. * plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
FILE *siod_output;
siod_output = siod_get_output_file ();
1997-11-24 22:05:25 +00:00
if (siod_output == stdout)
{
new code to call the script_fuc_text_console pdb function. remove batch 2001-07-17 Mathieu Lacage <mathieu@gnome.org> * app/batch.c: new code to call the script_fuc_text_console pdb function. * app/main.c: (main): remove batch command code. * plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c * plug-ins/script-fu/script-fu-console.c: (script_fu_cc_key_function), (script_fu_open_siod_console), (script_fu_close_siod_console): * plug-ins/script-fu/script-fu-scripts.h: * plug-ins/script-fu/script-fu-server.c: (script_fu_server_quit), (script_fu_server_get_mode), (execute_command): Replace all direct calls to the scheme interpreter with calls to the siod-wrapper. * plug-ins/script-fu/script-fu-console.h: remove run_eval. * plug-ins/script-fu/script-fu-server.h: * plug-ins/script-fu/script-fu-text-console.c: (script_fu_text_console_run), (read_command), (script_fu_text_console_interface): The actual new text console. * plug-ins/script-fu/script-fu-text-console.h: header. * plug-ins/script-fu/script-fu.c: (script_fu_quit), (script_fu_query), (script_fu_run): rename to better words. move most of the code to siod-wrapper.c/h * plug-ins/script-fu/siod-wrapper.c: (siod_get_output_file), (siod_set_output_file), (siod_get_verbose_level), (siod_set_verbose_level), (siod_print_welcome), (siod_interpret_string), (siod_get_error_msg), (siod_get_success_msg), (siod_init), (init_procedures), (init_constants), (convert_string), (sputs_fcn), (lprin1s), (marshall_proc_db_call), (script_fu_register_call), (script_fu_quit_call): All the funcitons dealing with the internals of the scheme interpreter. * plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
if (pipe (siod_output_pipe) == 0)
{
siod_output = fdopen (siod_output_pipe [1], "w");
if (siod_output != NULL)
{
siod_set_verbose_level (2);
siod_print_welcome ();
}
else
{
gimp_message (_("Unable to open a stream on the SIOD output pipe"));
siod_output = stdout;
}
}
1997-11-24 22:05:25 +00:00
else
new code to call the script_fuc_text_console pdb function. remove batch 2001-07-17 Mathieu Lacage <mathieu@gnome.org> * app/batch.c: new code to call the script_fuc_text_console pdb function. * app/main.c: (main): remove batch command code. * plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c * plug-ins/script-fu/script-fu-console.c: (script_fu_cc_key_function), (script_fu_open_siod_console), (script_fu_close_siod_console): * plug-ins/script-fu/script-fu-scripts.h: * plug-ins/script-fu/script-fu-server.c: (script_fu_server_quit), (script_fu_server_get_mode), (execute_command): Replace all direct calls to the scheme interpreter with calls to the siod-wrapper. * plug-ins/script-fu/script-fu-console.h: remove run_eval. * plug-ins/script-fu/script-fu-server.h: * plug-ins/script-fu/script-fu-text-console.c: (script_fu_text_console_run), (read_command), (script_fu_text_console_interface): The actual new text console. * plug-ins/script-fu/script-fu-text-console.h: header. * plug-ins/script-fu/script-fu.c: (script_fu_quit), (script_fu_query), (script_fu_run): rename to better words. move most of the code to siod-wrapper.c/h * plug-ins/script-fu/siod-wrapper.c: (siod_get_output_file), (siod_set_output_file), (siod_get_verbose_level), (siod_set_verbose_level), (siod_print_welcome), (siod_interpret_string), (siod_get_error_msg), (siod_get_success_msg), (siod_init), (init_procedures), (init_constants), (convert_string), (sputs_fcn), (lprin1s), (marshall_proc_db_call), (script_fu_register_call), (script_fu_quit_call): All the funcitons dealing with the internals of the scheme interpreter. * plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
{
gimp_message (_("Unable to open the SIOD output pipe"));
siod_output = stdout;
}
1997-11-24 22:05:25 +00:00
}
new code to call the script_fuc_text_console pdb function. remove batch 2001-07-17 Mathieu Lacage <mathieu@gnome.org> * app/batch.c: new code to call the script_fuc_text_console pdb function. * app/main.c: (main): remove batch command code. * plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c * plug-ins/script-fu/script-fu-console.c: (script_fu_cc_key_function), (script_fu_open_siod_console), (script_fu_close_siod_console): * plug-ins/script-fu/script-fu-scripts.h: * plug-ins/script-fu/script-fu-server.c: (script_fu_server_quit), (script_fu_server_get_mode), (execute_command): Replace all direct calls to the scheme interpreter with calls to the siod-wrapper. * plug-ins/script-fu/script-fu-console.h: remove run_eval. * plug-ins/script-fu/script-fu-server.h: * plug-ins/script-fu/script-fu-text-console.c: (script_fu_text_console_run), (read_command), (script_fu_text_console_interface): The actual new text console. * plug-ins/script-fu/script-fu-text-console.h: header. * plug-ins/script-fu/script-fu.c: (script_fu_quit), (script_fu_query), (script_fu_run): rename to better words. move most of the code to siod-wrapper.c/h * plug-ins/script-fu/siod-wrapper.c: (siod_get_output_file), (siod_set_output_file), (siod_get_verbose_level), (siod_set_verbose_level), (siod_print_welcome), (siod_interpret_string), (siod_get_error_msg), (siod_get_success_msg), (siod_init), (init_procedures), (init_constants), (convert_string), (sputs_fcn), (lprin1s), (marshall_proc_db_call), (script_fu_register_call), (script_fu_quit_call): All the funcitons dealing with the internals of the scheme interpreter. * plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
siod_set_output_file (siod_output);
1997-11-24 22:05:25 +00:00
}
static void
script_fu_close_siod_console (void)
1997-11-24 22:05:25 +00:00
{
new code to call the script_fuc_text_console pdb function. remove batch 2001-07-17 Mathieu Lacage <mathieu@gnome.org> * app/batch.c: new code to call the script_fuc_text_console pdb function. * app/main.c: (main): remove batch command code. * plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c * plug-ins/script-fu/script-fu-console.c: (script_fu_cc_key_function), (script_fu_open_siod_console), (script_fu_close_siod_console): * plug-ins/script-fu/script-fu-scripts.h: * plug-ins/script-fu/script-fu-server.c: (script_fu_server_quit), (script_fu_server_get_mode), (execute_command): Replace all direct calls to the scheme interpreter with calls to the siod-wrapper. * plug-ins/script-fu/script-fu-console.h: remove run_eval. * plug-ins/script-fu/script-fu-server.h: * plug-ins/script-fu/script-fu-text-console.c: (script_fu_text_console_run), (read_command), (script_fu_text_console_interface): The actual new text console. * plug-ins/script-fu/script-fu-text-console.h: header. * plug-ins/script-fu/script-fu.c: (script_fu_quit), (script_fu_query), (script_fu_run): rename to better words. move most of the code to siod-wrapper.c/h * plug-ins/script-fu/siod-wrapper.c: (siod_get_output_file), (siod_set_output_file), (siod_get_verbose_level), (siod_set_verbose_level), (siod_print_welcome), (siod_interpret_string), (siod_get_error_msg), (siod_get_success_msg), (siod_init), (init_procedures), (init_constants), (convert_string), (sputs_fcn), (lprin1s), (marshall_proc_db_call), (script_fu_register_call), (script_fu_quit_call): All the funcitons dealing with the internals of the scheme interpreter. * plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
FILE *siod_output;
siod_output = siod_get_output_file ();
1997-11-24 22:05:25 +00:00
if (siod_output != stdout)
fclose (siod_output);
new code to call the script_fuc_text_console pdb function. remove batch 2001-07-17 Mathieu Lacage <mathieu@gnome.org> * app/batch.c: new code to call the script_fuc_text_console pdb function. * app/main.c: (main): remove batch command code. * plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c * plug-ins/script-fu/script-fu-console.c: (script_fu_cc_key_function), (script_fu_open_siod_console), (script_fu_close_siod_console): * plug-ins/script-fu/script-fu-scripts.h: * plug-ins/script-fu/script-fu-server.c: (script_fu_server_quit), (script_fu_server_get_mode), (execute_command): Replace all direct calls to the scheme interpreter with calls to the siod-wrapper. * plug-ins/script-fu/script-fu-console.h: remove run_eval. * plug-ins/script-fu/script-fu-server.h: * plug-ins/script-fu/script-fu-text-console.c: (script_fu_text_console_run), (read_command), (script_fu_text_console_interface): The actual new text console. * plug-ins/script-fu/script-fu-text-console.h: header. * plug-ins/script-fu/script-fu.c: (script_fu_quit), (script_fu_query), (script_fu_run): rename to better words. move most of the code to siod-wrapper.c/h * plug-ins/script-fu/siod-wrapper.c: (siod_get_output_file), (siod_set_output_file), (siod_get_verbose_level), (siod_set_verbose_level), (siod_print_welcome), (siod_interpret_string), (siod_get_error_msg), (siod_get_success_msg), (siod_init), (init_procedures), (init_constants), (convert_string), (sputs_fcn), (lprin1s), (marshall_proc_db_call), (script_fu_register_call), (script_fu_quit_call): All the funcitons dealing with the internals of the scheme interpreter. * plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
1997-11-24 22:05:25 +00:00
close (siod_output_pipe[0]);
close (siod_output_pipe[1]);
}
void
script_fu_eval_run (gchar *name,
gint nparams,
GimpParam *params,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[1];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
GimpRunModeType run_mode;
run_mode = params[0].data.d_int32;
switch (run_mode)
{
case GIMP_RUN_NONINTERACTIVE:
if (repl_c_string (params[1].data.d_string, 0, 0, 1) != 0)
status = GIMP_PDB_EXECUTION_ERROR;
break;
case GIMP_RUN_INTERACTIVE:
case GIMP_RUN_WITH_LAST_VALS:
status = GIMP_PDB_CALLING_ERROR;
gimp_message (_("Script-Fu evaluate mode allows only noninteractive invocation"));
break;
default:
break;
}
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;
}
new code to call the script_fuc_text_console pdb function. remove batch 2001-07-17 Mathieu Lacage <mathieu@gnome.org> * app/batch.c: new code to call the script_fuc_text_console pdb function. * app/main.c: (main): remove batch command code. * plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c * plug-ins/script-fu/script-fu-console.c: (script_fu_cc_key_function), (script_fu_open_siod_console), (script_fu_close_siod_console): * plug-ins/script-fu/script-fu-scripts.h: * plug-ins/script-fu/script-fu-server.c: (script_fu_server_quit), (script_fu_server_get_mode), (execute_command): Replace all direct calls to the scheme interpreter with calls to the siod-wrapper. * plug-ins/script-fu/script-fu-console.h: remove run_eval. * plug-ins/script-fu/script-fu-server.h: * plug-ins/script-fu/script-fu-text-console.c: (script_fu_text_console_run), (read_command), (script_fu_text_console_interface): The actual new text console. * plug-ins/script-fu/script-fu-text-console.h: header. * plug-ins/script-fu/script-fu.c: (script_fu_quit), (script_fu_query), (script_fu_run): rename to better words. move most of the code to siod-wrapper.c/h * plug-ins/script-fu/siod-wrapper.c: (siod_get_output_file), (siod_set_output_file), (siod_get_verbose_level), (siod_set_verbose_level), (siod_print_welcome), (siod_interpret_string), (siod_get_error_msg), (siod_get_success_msg), (siod_init), (init_procedures), (init_constants), (convert_string), (sputs_fcn), (lprin1s), (marshall_proc_db_call), (script_fu_register_call), (script_fu_quit_call): All the funcitons dealing with the internals of the scheme interpreter. * plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00