plug-ins/script-fu/tinyscheme/scheme.[ch] small changes to tinyscheme -
2007-08-30 Simon Budig <simon@gimp.org> * plug-ins/script-fu/tinyscheme/scheme.[ch] * plug-ins/script-fu/tinyscheme/scheme-private.h: small changes to tinyscheme - mostly removing workarounds for message output. * plug-ins/script-fu/scheme-wrapper.[ch]: try to channel the output through a central function, have various output functions to handle the messages. Remove some hacks. * plug-ins/script-fu/script-fu-text-console.c * plug-ins/script-fu/script-fu-scripts.[ch] * plug-ins/script-fu/script-fu-interface.c * plug-ins/script-fu/script-fu.c * plug-ins/script-fu/script-fu-server.c * plug-ins/script-fu/script-fu-console.[ch]: use the new infrastructure. Remove more hacks. * plug-ins/script-fu/servertest.py: small script to test the communication with the script-fu-server. svn path=/trunk/; revision=23400
This commit is contained in:
@ -88,16 +88,10 @@ static gboolean script_fu_cc_key_function (GtkWidget *widget,
|
||||
GdkEventKey *event,
|
||||
ConsoleInterface *console);
|
||||
|
||||
static void script_fu_open_ts_console (void);
|
||||
static void script_fu_close_ts_console (void);
|
||||
|
||||
|
||||
/*
|
||||
* Local variables
|
||||
*/
|
||||
|
||||
static GtkWidget *output = NULL;
|
||||
|
||||
static void script_fu_output_to_console (TsOutputType type,
|
||||
const gchar *text,
|
||||
gint len,
|
||||
gpointer user_data);
|
||||
|
||||
/*
|
||||
* Function definitions
|
||||
@ -112,12 +106,9 @@ script_fu_console_run (const gchar *name,
|
||||
{
|
||||
static GimpParam values[1];
|
||||
|
||||
script_fu_open_ts_console ();
|
||||
|
||||
ts_set_print_flag (1);
|
||||
script_fu_console_interface ();
|
||||
|
||||
script_fu_close_ts_console ();
|
||||
|
||||
*nreturn_vals = 1;
|
||||
*return_vals = values;
|
||||
|
||||
@ -184,8 +175,6 @@ script_fu_console_interface (void)
|
||||
console->text_view = gtk_text_view_new_with_buffer (console->console);
|
||||
g_object_unref (console->console);
|
||||
|
||||
output = console->text_view;
|
||||
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (console->text_view), FALSE);
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (console->text_view),
|
||||
GTK_WRAP_WORD);
|
||||
@ -267,8 +256,6 @@ script_fu_console_interface (void)
|
||||
|
||||
g_source_remove (console->input_id);
|
||||
|
||||
output = NULL;
|
||||
|
||||
if (console->save_dialog)
|
||||
gtk_widget_destroy (console->save_dialog);
|
||||
|
||||
@ -521,21 +508,31 @@ script_fu_console_scroll_end (GtkWidget *view)
|
||||
g_idle_add ((GSourceFunc) script_fu_console_idle_scroll_end, view);
|
||||
}
|
||||
|
||||
void
|
||||
script_fu_output_to_console (const gchar *text,
|
||||
gint len)
|
||||
static void
|
||||
script_fu_output_to_console (TsOutputType type,
|
||||
const gchar *text,
|
||||
gint len,
|
||||
gpointer user_data)
|
||||
{
|
||||
/* FIXME: This function needs to be passed a pointer to the console.
|
||||
*/
|
||||
if (output)
|
||||
ConsoleInterface *console = user_data;
|
||||
|
||||
if (console && console->text_view)
|
||||
{
|
||||
GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (output));
|
||||
GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (console->text_view));
|
||||
GtkTextIter cursor;
|
||||
|
||||
gtk_text_buffer_get_end_iter (buffer, &cursor);
|
||||
gtk_text_buffer_insert (buffer, &cursor, text, len);
|
||||
|
||||
script_fu_console_scroll_end (output);
|
||||
if (type == TS_OUTPUT_NORMAL)
|
||||
{
|
||||
gtk_text_buffer_insert (buffer, &cursor, text, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
|
||||
text, len, "emphasis",
|
||||
NULL);
|
||||
}
|
||||
script_fu_console_scroll_end (console->text_view);
|
||||
}
|
||||
}
|
||||
|
||||
@ -566,6 +563,7 @@ script_fu_cc_key_function (GtkWidget *widget,
|
||||
GList *list;
|
||||
gint direction = 0;
|
||||
GtkTextIter cursor;
|
||||
GString *output;
|
||||
|
||||
switch (event->keyval)
|
||||
{
|
||||
@ -597,11 +595,23 @@ script_fu_cc_key_function (GtkWidget *widget,
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (console->cc), "");
|
||||
|
||||
output = g_string_new ("");
|
||||
ts_register_output_func (ts_gstring_output_func, output);
|
||||
if (ts_interpret_string (list->data) != 0)
|
||||
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
|
||||
ts_get_error_msg (), -1,
|
||||
"emphasis",
|
||||
NULL);
|
||||
{
|
||||
script_fu_output_to_console (TS_OUTPUT_ERROR,
|
||||
output->str,
|
||||
output->len,
|
||||
console);
|
||||
}
|
||||
else
|
||||
{
|
||||
script_fu_output_to_console (TS_OUTPUT_NORMAL,
|
||||
output->str,
|
||||
output->len,
|
||||
console);
|
||||
}
|
||||
g_string_free (output, TRUE);
|
||||
|
||||
gimp_displays_flush ();
|
||||
|
||||
@ -681,27 +691,6 @@ script_fu_cc_key_function (GtkWidget *widget,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_open_ts_console (void)
|
||||
{
|
||||
ts_set_print_flag (1);
|
||||
ts_set_console_mode (1);
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_close_ts_console (void)
|
||||
{
|
||||
FILE *output_file;
|
||||
|
||||
ts_set_print_flag (0);
|
||||
output_file = ts_get_output_file ();
|
||||
|
||||
if (output_file != stdout)
|
||||
fclose (output_file);
|
||||
|
||||
ts_set_console_mode (0);
|
||||
}
|
||||
|
||||
void
|
||||
script_fu_eval_run (const gchar *name,
|
||||
gint nparams,
|
||||
@ -719,7 +708,7 @@ script_fu_eval_run (const gchar *name,
|
||||
{
|
||||
case GIMP_RUN_NONINTERACTIVE:
|
||||
/* Disable Script-Fu output */
|
||||
ts_set_output_file (stdout);
|
||||
ts_register_output_func (NULL, NULL);
|
||||
if (ts_interpret_string (params[1].data.d_string) != 0)
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user