Commit 6239dddd authored by Kevin Cozens's avatar Kevin Cozens Committed by Kevin Cozens

With this commit we finally say goodbye to SIOD. This large set of changes

2006-10-15  Kevin Cozens  <kcozens@cvs.gnome.org>

	With this commit we finally say goodbye to SIOD. This large set of
	changes updates the Script-Fu plug-in to use the TinyScheme Scheme
	interpreter. These changes originated with changes originally made
	to Script-Fu which created Tiny-Fu (aka. the gimp-tiny-fu module).

	* plug-ins/script-fu/Makefile.am
	* plug-ins/script-fu/script-fu-console.c
	* plug-ins/script-fu/script-fu-interface.c
	* plug-ins/script-fu/script-fu-scripts.c
	* plug-ins/script-fu/script-fu-scripts.h
	* plug-ins/script-fu/script-fu-server.c
	* plug-ins/script-fu/script-fu-text-console.c
	* plug-ins/script-fu/script-fu.c: Updated with the changes made to
	these files as part of the work on the Tiny-Fu project.

	* plug-ins/script-fu/scheme-wrapper.c
	* plug-ins/script-fu/scheme-wrapper.h: Renamed from siod-wrapper.[ch]
	and updated based on differences to ts-wrapper.[ch] from gimp-tiny-fu.

	* plug-ins/script-fu/ftx/*
	* plug-ins/script-fu/re/*
	* plug-ins/script-fu/tinyscheme/*
	* plug-ins/script-fu/scripts/script-fu.init
	* plug-ins/script-fu/scripts/script-fu-compat.init
	* plug-ins/script-fu/scripts/contactsheet.scm
	* plug-ins/script-fu/scripts/script-fu-set-cmap.scm
	* plug-ins/script-fu/scripts/script-fu-util-setpt.scm
	* plug-ins/script-fu/scripts/ts-helloworld.scm: Added all of these
	files and directories from Tiny-Fu. Updated the Makefile.am files
	of ftx, re, and tinyscheme now they are in the GIMP source tree.

	* plug-ins/script-fu/scripts/*.scm: All scripts have been updated as
	needed to ensure they will work with the TinyScheme interpreter. Most
	of the files have been reformatted making it easier to see the syntax
	of Scheme and making them easier to read.

	* plug-ins/script-fu/scripts/Makefile.am: Updated script file lists.

	* plug-ins/script-fu/siod-wrapper.c
	* plug-ins/script-fu/siod-wrapper.h
	* plug-ins/script-fu/siod/*: Removed obsolete files.

	* configure.in: Updated list of files in AC_CONFIG_FILES. Changed
	--disable-script-fu to --without-script-fu which it should have
	been when originally added.

	* INSTALL: Updated to show change to --without-script-fu.
parent 9314c3ea
2006-10-15 Kevin Cozens <kcozens@cvs.gnome.org>
With this commit we finally say goodbye to SIOD. This large set of
changes updates the Script-Fu plug-in to use the TinyScheme Scheme
interpreter. These changes originated with changes originally made
to Script-Fu which created Tiny-Fu (aka. the gimp-tiny-fu module).
* plug-ins/script-fu/Makefile.am
* plug-ins/script-fu/script-fu-console.c
* plug-ins/script-fu/script-fu-interface.c
* plug-ins/script-fu/script-fu-scripts.c
* plug-ins/script-fu/script-fu-scripts.h
* plug-ins/script-fu/script-fu-server.c
* plug-ins/script-fu/script-fu-text-console.c
* plug-ins/script-fu/script-fu.c: Updated with the changes made to
these files as part of the work on the Tiny-Fu project.
* plug-ins/script-fu/scheme-wrapper.c
* plug-ins/script-fu/scheme-wrapper.h: Renamed from siod-wrapper.[ch]
and updated based on differences to ts-wrapper.[ch] from gimp-tiny-fu.
* plug-ins/script-fu/ftx/*
* plug-ins/script-fu/re/*
* plug-ins/script-fu/tinyscheme/*
* plug-ins/script-fu/scripts/script-fu.init
* plug-ins/script-fu/scripts/script-fu-compat.init
* plug-ins/script-fu/scripts/contactsheet.scm
* plug-ins/script-fu/scripts/script-fu-set-cmap.scm
* plug-ins/script-fu/scripts/script-fu-util-setpt.scm
* plug-ins/script-fu/scripts/ts-helloworld.scm: Added all of these
files and directories from Tiny-Fu. Updated the Makefile.am files
of ftx, re, and tinyscheme now they are in the GIMP source tree.
* plug-ins/script-fu/scripts/*.scm: All scripts have been updated as
needed to ensure they will work with the TinyScheme interpreter. Most
of the files have been reformatted making it easier to see the syntax
of Scheme and making them easier to read.
* plug-ins/script-fu/scripts/Makefile.am: Updated script file lists.
* plug-ins/script-fu/siod-wrapper.c
* plug-ins/script-fu/siod-wrapper.h
* plug-ins/script-fu/siod/*: Removed obsolete files.
* configure.in: Updated list of files in AC_CONFIG_FILES. Changed
--disable-script-fu to --without-script-fu which it should have
been when originally added.
* INSTALL: Updated to show change to --without-script-fu.
2006-10-15 Michael Natterer <mitch@gimp.org>
* app/file/file-utils.c (file_utils_filename_to_uri): if the
......
......@@ -197,8 +197,8 @@ These are:
--disable-python. If for some reason you don't want to build the
Python based pygimp plug-in, you can use --disable-python.
--disable-script-fu. If for some reason you don't want to build the
Script-Fu plug-in, you can use --disable-script-fu.
--without-script-fu. If for some reason you don't want to build the
Script-Fu plug-in, you can use --without-script-fu.
The `make' command builds several things:
- A bunch of public libraries in the directories starting with 'libgimp'.
......
......@@ -1479,16 +1479,17 @@ AM_CONDITIONAL(BUILD_PYTHON, test "x$enable_python" != xno)
# Check whether script_fu should be built
#########################################
AC_ARG_ENABLE(script-fu,
AC_HELP_STRING([--disable-script-fu],
have_script_fu=yes
AC_ARG_WITH(script-fu,
AC_HELP_STRING([--without-script-fu],
[do not build the script-fu extension]))
if test "x$enable_script_fu" != "xno"; then
enable_script_fu="yes"
if test "x$have_script_fu" = "xyes"; then
have_script_fu="yes"
else
enable_script_fu="no (script-fu extension disabled)"
have_script_fu="no (script-fu extension disabled)"
fi
AM_CONDITIONAL(BUILD_SCRIPT_FU, test "x$enable_script_fu" == "xyes")
AM_CONDITIONAL(BUILD_SCRIPT_FU, test "x$have_script_fu" == "xyes")
###########################################################
......@@ -1737,7 +1738,9 @@ app/widgets/Makefile
app/xcf/Makefile
plug-ins/Makefile
plug-ins/script-fu/Makefile
plug-ins/script-fu/siod/Makefile
plug-ins/script-fu/ftx/Makefile
plug-ins/script-fu/re/Makefile
plug-ins/script-fu/tinyscheme/Makefile
plug-ins/script-fu/scripts/Makefile
plug-ins/script-fu/scripts/images/Makefile
plug-ins/xjt/Makefile
......@@ -1878,7 +1881,8 @@ Optional Plug-Ins:
PNG: $have_libpng
Print: $enable_print
PSP: $have_zlib
Script-Fu: $enable_script_fu
Python: $enable_python
Script-Fu: $have_script_fu
SVG: $have_librsvg
TIFF: $have_libtiff
TWAIN (MacOS X): $mac_twain_ok
......
......@@ -8,14 +8,27 @@ libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la
libtinyscheme=tinyscheme/libtinyscheme.a
libftx=ftx/libftx.a
libre=re/libre.a
if OS_WIN32
mwindows = -mwindows
WINSOCK_LIBS = -lws2_32
endif
AM_CFLAGS = \
-DUSE_INTERFACE=1 \
-DUSE_STRCASECMP=1 \
-DUSE_STRLWR=1 \
-I$(top_srcdir) \
$(GTK_CFLAGS) \
-I$(includedir)
AM_LDFLAGS = $(mwindows)
SUBDIRS = siod scripts
SUBDIRS = tinyscheme ftx re scripts
libexecdir = $(gimpplugindir)/plug-ins
......@@ -36,13 +49,8 @@ script_fu_SOURCES = \
script-fu-server.h \
script-fu-types.h \
script-fu-enums.h \
siod-wrapper.c \
siod-wrapper.h
INCLUDES = \
-I$(top_srcdir) \
$(GTK_CFLAGS) \
-I$(includedir)
scheme-wrapper.c \
scheme-wrapper.h
if HAVE_GLIBC_REGEX
REGEXREPL =
......@@ -58,7 +66,9 @@ LDADD = \
$(libgimp) \
$(libgimpcolor) \
$(libgimpbase) \
siod/libsiod.a \
$(libtinyscheme) \
$(libftx) \
$(libre) \
$(REGEXREPL) \
$(GTK_LIBS) \
$(SOCKET_LIBS) \
......
......@@ -2,8 +2,8 @@
AM_CFLAGS = \
-DUSE_INTERFACE=1 \
-I$(top_srcdir) \
$(GIMP_CFLAGS)
-I.. \
$(GLIB_CFLAGS)
noinst_LIBRARIES = libftx.a
......
......@@ -2,8 +2,8 @@
AM_CFLAGS = \
-DUSE_INTERFACE=1 \
-I$(top_srcdir) \
$(GIMP_CFLAGS)
-I.. \
$(GLIB_CFLAGS)
noinst_LIBRARIES = libre.a
......
This diff is collapsed.
......@@ -16,31 +16,29 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef SIOD_WRAPPER_H
#define SIOD_WRAPPER_H
#ifndef SCHEME_WRAPPER_H
#define SCHEME_WRAPPER_H
FILE * ts_get_output_file (void);
void ts_set_output_file (FILE *file);
void siod_init (gboolean register_scripts);
void ts_set_console_mode (int flag);
FILE * siod_get_output_file (void);
void siod_set_output_file (FILE *file);
gint ts_get_verbose_level (void);
void ts_set_verbose_level (gint);
void siod_set_console_mode (int flag);
void ts_set_print_flag (gint);
void ts_print_welcome (void);
gint siod_get_verbose_level (void);
void siod_set_verbose_level (gint verbose_level);
const gchar * ts_get_error_msg (void);
const gchar * ts_get_success_msg (void);
void siod_print_welcome (void);
void tinyscheme_init (gboolean);
void tinyscheme_deinit (void);
const gchar * siod_get_error_msg (void);
const gchar * siod_get_success_msg (void);
void siod_output_string (FILE *fp,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
void ts_output_string (FILE *fp, char *string, int len);
/* if the return value is 0, success. error otherwise. */
gint siod_interpret_string (const gchar *expr);
gint ts_interpret_string (const gchar *);
#endif /* SIOD_WRAPPER_H */
#endif /* SCHEME_WRAPPER_H */
......@@ -18,6 +18,7 @@
#include "config.h"
#include <errno.h>
#include <gdk/gdkkeysyms.h>
#include "libgimp/gimp.h"
......@@ -25,7 +26,8 @@
#include "script-fu-intl.h"
#include "siod-wrapper.h"
#include "tinyscheme/scheme.h"
#include "scheme-wrapper.h"
#include "script-fu-console.h"
......@@ -54,6 +56,10 @@ typedef struct
} ConsoleInterface;
enum TF_RESPONSES {
RESPONSE_CLEAR, RESPONSE_SAVE
};
/*
* Local Functions
*/
......@@ -61,6 +67,10 @@ static void script_fu_console_interface (void);
static void script_fu_response (GtkWidget *widget,
gint response_id,
ConsoleInterface *console);
static void script_fu_save_dialog (GtkWidget *parent);
static void script_fu_save_output (GtkWidget *dialog,
gint response_id,
gpointer data);
static void script_fu_browse_callback (GtkWidget *widget,
ConsoleInterface *console);
static void script_fu_browse_response (GtkWidget *widget,
......@@ -72,8 +82,8 @@ static gboolean script_fu_cc_key_function (GtkWidget *widget,
GdkEventKey *event,
ConsoleInterface *console);
static void script_fu_open_siod_console (void);
static void script_fu_close_siod_console (void);
static void script_fu_open_ts_console (void);
static void script_fu_close_ts_console (void);
/*
......@@ -102,18 +112,18 @@ static ConsoleInterface cint =
void
script_fu_console_run (const gchar *name,
gint nparams,
const GimpParam *params,
gint *nreturn_vals,
GimpParam **return_vals)
gint nparams,
const GimpParam *params,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[1];
script_fu_open_siod_console ();
script_fu_open_ts_console ();
script_fu_console_interface ();
script_fu_close_siod_console ();
script_fu_close_ts_console ();
*nreturn_vals = 1;
*return_vals = values;
......@@ -146,29 +156,31 @@ script_fu_console_interface (void)
NULL, 0,
gimp_standard_help_func, PROC_NAME,
_("_Save Output"), RESPONSE_SAVE,
_("Cl_ear Output"), RESPONSE_CLEAR,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL);
g_signal_connect (console->dialog, "response",
G_CALLBACK (script_fu_response),
console);
G_CALLBACK (script_fu_response),
console);
g_signal_connect (console->dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&console->dialog);
G_CALLBACK (gtk_widget_destroyed),
&console->dialog);
/* The main vbox */
vbox = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (console->dialog)->vbox), vbox,
TRUE, TRUE, 0);
TRUE, TRUE, 0);
gtk_widget_show (vbox);
/* The output text widget */
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_ALWAYS);
GTK_POLICY_AUTOMATIC,
GTK_POLICY_ALWAYS);
gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
gtk_widget_show (scrolled_window);
......@@ -184,25 +196,24 @@ script_fu_console_interface (void)
gtk_widget_show (console->text_view);
gtk_text_buffer_create_tag (console->console, "strong",
"weight", PANGO_WEIGHT_BOLD,
"size", 12 * PANGO_SCALE,
NULL);
"weight", PANGO_WEIGHT_BOLD,
"size", 12 * PANGO_SCALE,
NULL);
gtk_text_buffer_create_tag (console->console, "emphasis",
"style", PANGO_STYLE_OBLIQUE,
"size", 10 * PANGO_SCALE,
NULL);
"style", PANGO_STYLE_OBLIQUE,
"size", 10 * PANGO_SCALE,
NULL);
gtk_text_buffer_create_tag (console->console, "weak",
"size", 10 * PANGO_SCALE,
NULL);
"size", 10 * PANGO_SCALE,
NULL);
{
const gchar *greeting_texts[] =
{
"weak", "\n",
"strong", "Welcome to SIOD, Scheme In One Defun\n",
"weak", "(C) Copyright 1988-1994 Paradigm Associates Inc.\n\n",
"strong", "Script-Fu Console - ",
"emphasis", "Interactive Scheme Development\n",
"strong", _("Welcome to TinyScheme\n"),
"weak", _("Copyright (c) Dimitrios Souflis\n\n"),
"strong", _("Script-Fu Console - "),
"emphasis", _("Interactive Scheme Development"),
NULL
};
......@@ -213,10 +224,10 @@ script_fu_console_interface (void)
for (i = 0; greeting_texts[i]; i += 2)
{
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
greeting_texts[i + 1], -1,
greeting_texts[i],
NULL);
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
greeting_texts[i + 1], -1,
greeting_texts[i],
NULL);
}
}
......@@ -231,8 +242,8 @@ script_fu_console_interface (void)
gtk_widget_show (console->cc);
g_signal_connect (console->cc, "key-press-event",
G_CALLBACK (script_fu_cc_key_function),
console);
G_CALLBACK (script_fu_cc_key_function),
console);
button = gtk_button_new_with_mnemonic (_("_Browse..."));
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
......@@ -240,8 +251,8 @@ script_fu_console_interface (void)
gtk_widget_show (button);
g_signal_connect (button, "clicked",
G_CALLBACK (script_fu_browse_callback),
console);
G_CALLBACK (script_fu_browse_callback),
console);
/* Initialize the history */
console->history = g_list_append (console->history, NULL);
......@@ -262,12 +273,95 @@ script_fu_response (GtkWidget *widget,
gint response_id,
ConsoleInterface *console)
{
GtkTextIter start, end;
switch (response_id)
{
case RESPONSE_CLEAR:
gtk_text_buffer_get_start_iter (console->console, &start);
gtk_text_buffer_get_end_iter (console->console, &end);
gtk_text_buffer_delete (console->console, &start, &end);
break;
case RESPONSE_SAVE:
script_fu_save_dialog(widget);
break;
default:
gtk_main_quit ();
break;
}
}
static void
script_fu_save_dialog(GtkWidget *parent)
{
static GtkWidget *dialog = NULL;
if (! dialog)
{
dialog =
gtk_file_chooser_dialog_new (_("Save TinyScheme Output"),
NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
g_signal_connect (dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&dialog);
g_signal_connect (dialog, "response",
G_CALLBACK (script_fu_save_output),
NULL);
}
gtk_window_present (GTK_WINDOW (dialog));
}
static void
script_fu_save_output (GtkWidget *dialog,
gint response_id,
gpointer data)
{
GtkTextIter start, end;
if (response_id == GTK_RESPONSE_ACCEPT)
{
gchar *filename;
gchar *str;
FILE *fh;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
fh = fopen (filename, "w");
if (! fh)
{
gchar *message =
g_strdup_printf ("Could not open '%s' for writing: %s",
gimp_filename_to_utf8 (filename),
g_strerror (errno));
g_message (message);
g_free (message);
g_free (filename);
return;
}
gtk_text_buffer_get_start_iter (cint.console, &start);
gtk_text_buffer_get_end_iter (cint.console, &end);
str = gtk_text_buffer_get_text (cint.console, &start, &end, TRUE);
fputs (str, fh);
fclose (fh);
}
gtk_widget_destroy (dialog);
}
static void
script_fu_browse_callback (GtkWidget *widget,
ConsoleInterface *console)
ConsoleInterface *console)
{
if (! console->proc_browser)
{
......@@ -415,7 +509,7 @@ script_fu_cc_is_empty (ConsoleInterface *console)
while (*str)
{
if (*str != ' ' && *str != '\t' && *str != '\n')
return FALSE;
return FALSE;
str ++;
}
......@@ -425,8 +519,8 @@ script_fu_cc_is_empty (ConsoleInterface *console)
static gboolean
script_fu_cc_key_function (GtkWidget *widget,
GdkEventKey *event,
ConsoleInterface *console)
GdkEventKey *event,
ConsoleInterface *console)
{
GList *list;
gint direction = 0;
......@@ -436,20 +530,20 @@ script_fu_cc_key_function (GtkWidget *widget,
{
case GDK_Return:
if (script_fu_cc_is_empty (console))
return TRUE;
return TRUE;
list = g_list_nth (console->history,
(g_list_length (console->history) - 1));
if (list->data)
g_free (list->data);
g_free (list->data);
list->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (console->cc)));
gtk_text_buffer_get_end_iter (console->console, &cursor);
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
"\n=> ", -1,
"strong",
NULL);
"\n=> ", -1,
"strong",
NULL);
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
gtk_entry_get_text (GTK_ENTRY (console->cc)), -1,
......@@ -457,27 +551,27 @@ script_fu_cc_key_function (GtkWidget *widget,
NULL);
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
"\n", -1,
"weak",
NULL);
"\n", -1,
"weak",
NULL);
script_fu_console_scroll_end (console);
gtk_entry_set_text (GTK_ENTRY (console->cc), "");
siod_interpret_string ((const gchar *) list->data);
ts_interpret_string ((char *) list->data);
gimp_displays_flush ();
console->history = g_list_append (console->history, NULL);
if (console->history_len == console->history_max)
{
console->history = g_list_remove (console->history,
console->history->data);
if (console->history->data)
g_free (console->history->data);
}
{
console->history = g_list_remove (console->history,
console->history->data);
if (console->history->data)
g_free (console->history->data);
}
else
console->history_len++;
console->history_len++;
console->history_cur = g_list_length (console->history) - 1;
return TRUE;
......@@ -513,21 +607,21 @@ script_fu_cc_key_function (GtkWidget *widget,
{
/* Make sure we keep track of the current one */
if (console->history_cur == g_list_length (console->history) - 1)
{
list = g_list_nth (console->history, console->history_cur);
if (list->data)
g_free (list->data);
list->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (console->cc)));
}
{
list = g_list_nth (console->history, console->history_cur);
if (list->data)
g_free (list->data);
list->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (console->cc)));
}
console->history_cur += direction;
if (console->history_cur < 0)
console->history_cur = 0;
console->history_cur = 0;
if (console->history_cur >= console->history_len)
console->history_cur = console->history_len - 1;
console->history_cur = console->history_len - 1;
gtk_entry_set_text (GTK_ENTRY (console->cc),
(gchar *) (g_list_nth (console->history,
(gchar *) (g_list_nth (console->history,
console->history_cur))->data);
gtk_editable_set_position (GTK_EDITABLE (console->cc), -1);
......@@ -539,31 +633,34 @@ script_fu_cc_key_function (GtkWidget *widget,
}
static void
script_fu_open_siod_console (void)
script_fu_open_ts_console (void)
{
siod_set_console_mode (1);
siod_set_verbose_level (2);
ts_set_print_flag (1);
ts_set_console_mode (1);
ts_set_verbose_level (2);
ts_print_welcome ();
}
static void
script_fu_close_siod_console (void)
script_fu_close_ts_console (void)
{
FILE *siod_output;
FILE *output_file;
siod_output = siod_get_output_file ();
ts_set_print_flag (0);
output_file = ts_get_output_file ();
if (siod_output != stdout)
fclose (siod_output);
if (output_file != stdout)
fclose (output_file);
siod_set_console_mode (0);
ts_set_console_mode (0);
}
void
script_fu_eval_run (const gchar *name,
gint nparams,
const GimpParam *params,
gint *nreturn_vals,
GimpParam **return_vals)
gint nparams,
const GimpParam *params,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[1];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
......@@ -574,15 +671,11 @@ script_fu_eval_run (const gchar *name,
switch (run_mode)