1997-11-25 06:05:25 +08: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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
1999-05-29 09:28:24 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2006-10-16 09:08:54 +08:00
|
|
|
#include <errno.h>
|
1999-05-29 09:28:24 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "libgimp/gimp.h"
|
|
|
|
#include "libgimp/gimpui.h"
|
1999-09-25 09:59:43 +08:00
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
1999-05-29 09:28:24 +08:00
|
|
|
|
2006-10-16 09:08:54 +08:00
|
|
|
#include "tinyscheme/scheme.h"
|
2006-10-16 17:24:59 +08:00
|
|
|
|
2006-10-16 09:08:54 +08:00
|
|
|
#include "scheme-wrapper.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "script-fu-console.h"
|
2000-02-28 08:45:58 +08:00
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
#include "script-fu-intl.h"
|
|
|
|
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2004-05-26 02:36:52 +08:00
|
|
|
#define TEXT_WIDTH 480
|
1997-11-25 06:05:25 +08:00
|
|
|
#define TEXT_HEIGHT 400
|
|
|
|
|
2005-09-28 00:35:48 +08:00
|
|
|
#define PROC_NAME "plug-in-script-fu-console"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2005-08-03 00:49:42 +08:00
|
|
|
GtkWidget *dialog;
|
2001-07-30 08:46:09 +08:00
|
|
|
GtkTextBuffer *console;
|
2001-01-22 04:06:26 +08:00
|
|
|
GtkWidget *cc;
|
2001-07-30 08:46:09 +08:00
|
|
|
GtkWidget *text_view;
|
2005-08-03 00:49:42 +08:00
|
|
|
GtkWidget *proc_browser;
|
2006-10-16 17:24:59 +08:00
|
|
|
GtkWidget *save_dialog;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-22 04:06:26 +08:00
|
|
|
gint32 input_id;
|
2005-08-03 00:49:42 +08:00
|
|
|
|
|
|
|
GList *history;
|
|
|
|
gint history_len;
|
|
|
|
gint history_cur;
|
|
|
|
gint history_max;
|
1997-11-25 06:05:25 +08:00
|
|
|
} ConsoleInterface;
|
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
RESPONSE_CLEAR,
|
|
|
|
RESPONSE_SAVE
|
2006-10-16 09:08:54 +08:00
|
|
|
};
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/*
|
|
|
|
* Local Functions
|
|
|
|
*/
|
2006-10-16 17:24:59 +08:00
|
|
|
static void script_fu_console_interface (void);
|
|
|
|
static void script_fu_console_response (GtkWidget *widget,
|
2005-08-18 21:55:14 +08:00
|
|
|
gint response_id,
|
|
|
|
ConsoleInterface *console);
|
2006-10-16 17:24:59 +08:00
|
|
|
static void script_fu_console_save_dialog (ConsoleInterface *console);
|
|
|
|
static void script_fu_console_save_response (GtkWidget *dialog,
|
2006-10-16 09:08:54 +08:00
|
|
|
gint response_id,
|
2005-08-18 21:55:14 +08:00
|
|
|
ConsoleInterface *console);
|
2006-10-16 17:24:59 +08:00
|
|
|
|
|
|
|
static void script_fu_browse_callback (GtkWidget *widget,
|
|
|
|
ConsoleInterface *console);
|
|
|
|
static void script_fu_browse_response (GtkWidget *widget,
|
2005-08-18 21:55:14 +08:00
|
|
|
gint response_id,
|
|
|
|
ConsoleInterface *console);
|
2006-10-16 17:24:59 +08:00
|
|
|
static void script_fu_browse_row_activated (GtkDialog *dialog);
|
|
|
|
|
|
|
|
static gboolean script_fu_cc_is_empty (ConsoleInterface *console);
|
|
|
|
static gboolean script_fu_cc_key_function (GtkWidget *widget,
|
2005-08-18 21:55:14 +08:00
|
|
|
GdkEventKey *event,
|
|
|
|
ConsoleInterface *console);
|
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
static void script_fu_open_ts_console (void);
|
|
|
|
static void script_fu_close_ts_console (void);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables
|
|
|
|
*/
|
2006-10-16 17:24:59 +08:00
|
|
|
|
|
|
|
static GtkWidget *output = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function definitions
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2003-07-02 07:21:36 +08:00
|
|
|
script_fu_console_run (const gchar *name,
|
2006-10-16 09:08:54 +08:00
|
|
|
gint nparams,
|
|
|
|
const GimpParam *params,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-22 04:06:26 +08:00
|
|
|
static GimpParam values[1];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-10-16 09:08:54 +08:00
|
|
|
script_fu_open_ts_console ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-10-27 00:45:56 +08:00
|
|
|
script_fu_console_interface ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-10-16 09:08:54 +08:00
|
|
|
script_fu_close_ts_console ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
*nreturn_vals = 1;
|
2005-10-27 00:45:56 +08:00
|
|
|
*return_vals = values;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-22 04:06:26 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
2005-10-27 00:45:56 +08:00
|
|
|
values[0].data.d_status = GIMP_PDB_SUCCESS;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-01-10 05:19:46 +08:00
|
|
|
script_fu_console_interface (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-08-03 00:49:42 +08:00
|
|
|
ConsoleInterface *console;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
GtkWidget *hbox;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-01 02:17:55 +08:00
|
|
|
gimp_ui_init ("script-fu", FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
console = g_new0 (ConsoleInterface, 1);
|
2005-08-03 00:49:42 +08:00
|
|
|
|
|
|
|
console->input_id = -1;
|
|
|
|
console->history_max = 50;
|
|
|
|
|
2005-09-28 00:35:48 +08:00
|
|
|
console->dialog = gimp_dialog_new (_("Script-Fu Console"),
|
|
|
|
"script-fu-console",
|
2005-08-03 00:49:42 +08:00
|
|
|
NULL, 0,
|
2005-09-28 00:35:48 +08:00
|
|
|
gimp_standard_help_func, PROC_NAME,
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
GTK_STOCK_SAVE, RESPONSE_SAVE,
|
|
|
|
GTK_STOCK_CLEAR, RESPONSE_CLEAR,
|
2005-08-03 00:49:42 +08:00
|
|
|
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
NULL);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (console->dialog),
|
|
|
|
GTK_RESPONSE_CLOSE,
|
|
|
|
RESPONSE_CLEAR,
|
|
|
|
RESPONSE_SAVE,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (console->dialog),
|
|
|
|
(gpointer) &console->dialog);
|
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
g_signal_connect (console->dialog, "response",
|
2006-10-16 17:24:59 +08:00
|
|
|
G_CALLBACK (script_fu_console_response),
|
2006-10-16 09:08:54 +08:00
|
|
|
console);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
|
|
|
/* The main vbox */
|
2005-06-24 00:06:53 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 12);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (console->dialog)->vbox), vbox,
|
2006-10-16 09:08:54 +08:00
|
|
|
TRUE, TRUE, 0);
|
2004-05-26 02:36:52 +08:00
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* The output text widget */
|
2001-07-30 08:46:09 +08:00
|
|
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
2006-10-16 09:08:54 +08:00
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_ALWAYS);
|
2004-05-26 02:36:52 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
|
2001-07-30 08:46:09 +08:00
|
|
|
gtk_widget_show (scrolled_window);
|
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
console->console = gtk_text_buffer_new (NULL);
|
|
|
|
console->text_view = gtk_text_view_new_with_buffer (console->console);
|
|
|
|
g_object_unref (console->console);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
output = console->text_view;
|
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_text_view_set_editable (GTK_TEXT_VIEW (console->text_view), FALSE);
|
|
|
|
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (console->text_view), 12);
|
|
|
|
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (console->text_view), 12);
|
|
|
|
gtk_widget_set_size_request (console->text_view, TEXT_WIDTH, TEXT_HEIGHT);
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_window), console->text_view);
|
|
|
|
gtk_widget_show (console->text_view);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_text_buffer_create_tag (console->console, "strong",
|
2006-10-16 09:08:54 +08:00
|
|
|
"weight", PANGO_WEIGHT_BOLD,
|
|
|
|
"size", 12 * PANGO_SCALE,
|
|
|
|
NULL);
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_text_buffer_create_tag (console->console, "emphasis",
|
2006-10-16 09:08:54 +08:00
|
|
|
"style", PANGO_STYLE_OBLIQUE,
|
|
|
|
"size", 10 * PANGO_SCALE,
|
|
|
|
NULL);
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_text_buffer_create_tag (console->console, "weak",
|
2006-10-16 09:08:54 +08:00
|
|
|
"size", 10 * PANGO_SCALE,
|
|
|
|
NULL);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
|
|
|
{
|
|
|
|
const gchar *greeting_texts[] =
|
|
|
|
{
|
2006-10-16 09:08:54 +08:00
|
|
|
"strong", _("Welcome to TinyScheme\n"),
|
|
|
|
"weak", _("Copyright (c) Dimitrios Souflis\n\n"),
|
|
|
|
"strong", _("Script-Fu Console - "),
|
|
|
|
"emphasis", _("Interactive Scheme Development"),
|
2001-07-30 08:46:09 +08:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
GtkTextIter cursor;
|
|
|
|
gint i;
|
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_text_buffer_get_end_iter (console->console, &cursor);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
|
|
|
for (i = 0; greeting_texts[i]; i += 2)
|
|
|
|
{
|
2006-10-16 09:08:54 +08:00
|
|
|
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
|
|
|
|
greeting_texts[i + 1], -1,
|
|
|
|
greeting_texts[i],
|
|
|
|
NULL);
|
2001-07-30 08:46:09 +08:00
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The current command */
|
2004-05-26 02:36:52 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (hbox);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
console->cc = gtk_entry_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), console->cc, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_grab_focus (console->cc);
|
|
|
|
gtk_widget_show (console->cc);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
g_signal_connect (console->cc, "key-press-event",
|
2006-10-16 09:08:54 +08:00
|
|
|
G_CALLBACK (script_fu_cc_key_function),
|
|
|
|
console);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-30 08:33:34 +08:00
|
|
|
button = gtk_button_new_with_mnemonic (_("_Browse..."));
|
2001-07-30 08:46:09 +08:00
|
|
|
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (button);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2006-10-16 09:08:54 +08:00
|
|
|
G_CALLBACK (script_fu_browse_callback),
|
|
|
|
console);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Initialize the history */
|
2005-08-03 00:49:42 +08:00
|
|
|
console->history = g_list_append (console->history, NULL);
|
|
|
|
console->history_len = 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_widget_show (console->dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gtk_main ();
|
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
g_source_remove (console->input_id);
|
2001-01-22 04:06:26 +08:00
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
output = NULL;
|
|
|
|
|
|
|
|
if (console->save_dialog)
|
|
|
|
gtk_widget_destroy (console->save_dialog);
|
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
if (console->dialog)
|
|
|
|
gtk_widget_destroy (console->dialog);
|
2006-10-16 17:24:59 +08:00
|
|
|
|
|
|
|
g_free (console);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-16 17:24:59 +08:00
|
|
|
script_fu_console_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
ConsoleInterface *console)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-10-16 09:08:54 +08:00
|
|
|
GtkTextIter start, end;
|
|
|
|
|
|
|
|
switch (response_id)
|
2006-10-16 17:24:59 +08:00
|
|
|
{
|
|
|
|
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_console_save_dialog (console);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
gtk_main_quit ();
|
|
|
|
break;
|
2006-10-17 07:24:43 +08:00
|
|
|
}
|
2006-10-16 09:08:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2006-10-16 17:24:59 +08:00
|
|
|
script_fu_console_save_dialog (ConsoleInterface *console)
|
2006-10-16 09:08:54 +08:00
|
|
|
{
|
2006-10-16 17:24:59 +08:00
|
|
|
if (! console->save_dialog)
|
2006-10-16 09:08:54 +08:00
|
|
|
{
|
2006-10-16 17:24:59 +08:00
|
|
|
console->save_dialog =
|
|
|
|
gtk_file_chooser_dialog_new (_("Save Script-Fu Console Output"),
|
|
|
|
GTK_WINDOW (console->dialog),
|
|
|
|
GTK_FILE_CHOOSER_ACTION_SAVE,
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (console->save_dialog),
|
|
|
|
GTK_RESPONSE_OK);
|
|
|
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (console->save_dialog),
|
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
2006-10-16 09:08:54 +08:00
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (console->save_dialog),
|
|
|
|
(gpointer) &console->save_dialog);
|
|
|
|
|
|
|
|
g_signal_connect (console->save_dialog, "response",
|
|
|
|
G_CALLBACK (script_fu_console_save_response),
|
|
|
|
console);
|
2006-10-16 09:08:54 +08:00
|
|
|
}
|
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (console->save_dialog));
|
2006-10-16 09:08:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-16 17:24:59 +08:00
|
|
|
script_fu_console_save_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
ConsoleInterface *console)
|
2006-10-16 09:08:54 +08:00
|
|
|
{
|
|
|
|
GtkTextIter start, end;
|
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
2006-10-16 09:08:54 +08:00
|
|
|
{
|
|
|
|
gchar *filename;
|
|
|
|
gchar *str;
|
|
|
|
FILE *fh;
|
|
|
|
|
|
|
|
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
|
|
|
|
|
|
|
fh = fopen (filename, "w");
|
2006-10-16 17:24:59 +08:00
|
|
|
|
2006-10-16 09:08:54 +08:00
|
|
|
if (! fh)
|
|
|
|
{
|
2006-10-16 17:24:59 +08:00
|
|
|
g_message (_("Could not open '%s' for writing: %s"),
|
|
|
|
gimp_filename_to_utf8 (filename),
|
|
|
|
g_strerror (errno));
|
2006-10-16 09:08:54 +08:00
|
|
|
|
|
|
|
g_free (filename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
gtk_text_buffer_get_start_iter (console->console, &start);
|
|
|
|
gtk_text_buffer_get_end_iter (console->console, &end);
|
|
|
|
|
|
|
|
str = gtk_text_buffer_get_text (console->console, &start, &end, FALSE);
|
|
|
|
|
2006-10-16 09:08:54 +08:00
|
|
|
fputs (str, fh);
|
|
|
|
fclose (fh);
|
2006-10-16 17:24:59 +08:00
|
|
|
|
|
|
|
g_free (str);
|
2006-10-16 09:08:54 +08:00
|
|
|
}
|
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
gtk_widget_hide (dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
static void
|
2005-08-03 00:49:42 +08:00
|
|
|
script_fu_browse_callback (GtkWidget *widget,
|
2006-10-16 09:08:54 +08:00
|
|
|
ConsoleInterface *console)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-08-03 00:49:42 +08:00
|
|
|
if (! console->proc_browser)
|
|
|
|
{
|
2005-09-28 00:35:48 +08:00
|
|
|
console->proc_browser =
|
|
|
|
gimp_proc_browser_dialog_new (_("Script-Fu Procedure Browser"),
|
|
|
|
"script-fu-procedure-browser",
|
|
|
|
gimp_standard_help_func, PROC_NAME,
|
|
|
|
|
|
|
|
GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
|
|
|
|
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
|
|
|
|
|
|
|
|
NULL);
|
2005-08-03 07:45:24 +08:00
|
|
|
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (console->proc_browser),
|
|
|
|
GTK_RESPONSE_APPLY);
|
2006-10-16 17:24:59 +08:00
|
|
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (console->proc_browser),
|
|
|
|
GTK_RESPONSE_CLOSE,
|
|
|
|
GTK_RESPONSE_APPLY,
|
|
|
|
-1);
|
2005-08-03 00:49:42 +08:00
|
|
|
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (console->proc_browser),
|
|
|
|
(gpointer) &console->proc_browser);
|
|
|
|
|
|
|
|
g_signal_connect (console->proc_browser, "response",
|
|
|
|
G_CALLBACK (script_fu_browse_response),
|
|
|
|
console);
|
2005-08-18 21:55:14 +08:00
|
|
|
g_signal_connect (console->proc_browser, "row-activated",
|
|
|
|
G_CALLBACK (script_fu_browse_row_activated),
|
|
|
|
console);
|
2005-08-03 00:49:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (console->proc_browser));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
script_fu_browse_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
ConsoleInterface *console)
|
|
|
|
{
|
|
|
|
GimpProcBrowserDialog *dialog = GIMP_PROC_BROWSER_DIALOG (widget);
|
|
|
|
gchar *proc_name;
|
|
|
|
gchar *proc_blurb;
|
|
|
|
gchar *proc_help;
|
|
|
|
gchar *proc_author;
|
|
|
|
gchar *proc_copyright;
|
|
|
|
gchar *proc_date;
|
|
|
|
GimpPDBProcType proc_type;
|
|
|
|
gint n_params;
|
|
|
|
gint n_return_vals;
|
|
|
|
GimpParamDef *params;
|
|
|
|
GimpParamDef *return_vals;
|
|
|
|
gint i;
|
|
|
|
GString *text;
|
|
|
|
|
|
|
|
if (response_id != GTK_RESPONSE_APPLY)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (widget);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
proc_name = gimp_proc_browser_dialog_get_selected (dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (proc_name == NULL)
|
2000-01-10 05:19:46 +08:00
|
|
|
return;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
gimp_procedural_db_proc_info (proc_name,
|
|
|
|
&proc_blurb,
|
|
|
|
&proc_help,
|
|
|
|
&proc_author,
|
|
|
|
&proc_copyright,
|
|
|
|
&proc_date,
|
|
|
|
&proc_type,
|
|
|
|
&n_params,
|
|
|
|
&n_return_vals,
|
|
|
|
¶ms,
|
|
|
|
&return_vals);
|
|
|
|
|
2000-01-10 05:19:46 +08:00
|
|
|
text = g_string_new ("(");
|
2004-11-17 22:30:35 +08:00
|
|
|
text = g_string_append (text, proc_name);
|
2004-09-30 08:33:34 +08:00
|
|
|
|
|
|
|
for (i = 0; i < n_params; i++)
|
2000-01-10 05:19:46 +08:00
|
|
|
{
|
|
|
|
text = g_string_append_c (text, ' ');
|
|
|
|
text = g_string_append (text, params[i].name);
|
|
|
|
}
|
2004-09-30 08:33:34 +08:00
|
|
|
|
2000-01-10 05:19:46 +08:00
|
|
|
text = g_string_append_c (text, ')');
|
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (console->cc), text->str);
|
2000-01-10 05:19:46 +08:00
|
|
|
g_string_free (text, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
g_free (proc_name);
|
|
|
|
g_free (proc_blurb);
|
|
|
|
g_free (proc_help);
|
|
|
|
g_free (proc_author);
|
|
|
|
g_free (proc_copyright);
|
|
|
|
g_free (proc_date);
|
|
|
|
|
|
|
|
gimp_destroy_paramdefs (params, n_params);
|
|
|
|
gimp_destroy_paramdefs (return_vals, n_return_vals);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2005-08-18 21:55:14 +08:00
|
|
|
static void
|
|
|
|
script_fu_browse_row_activated (GtkDialog *dialog)
|
|
|
|
{
|
|
|
|
gtk_dialog_response (dialog, GTK_RESPONSE_APPLY);
|
|
|
|
}
|
|
|
|
|
2001-01-22 04:06:26 +08:00
|
|
|
static gboolean
|
2006-10-16 17:24:59 +08:00
|
|
|
script_fu_console_idle_scroll_end (GtkWidget *view)
|
1998-05-09 11:52:19 +08:00
|
|
|
{
|
2006-10-16 17:24:59 +08:00
|
|
|
GtkAdjustment *adj = GTK_TEXT_VIEW (view)->vadjustment;
|
2001-07-30 08:46:09 +08:00
|
|
|
|
|
|
|
gtk_adjustment_set_value (adj, adj->upper - adj->page_size);
|
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
g_object_unref (view);
|
|
|
|
|
1998-05-09 11:52:19 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-07-30 08:46:09 +08:00
|
|
|
static void
|
2006-10-16 17:24:59 +08:00
|
|
|
script_fu_console_scroll_end (GtkWidget *view)
|
2001-07-30 08:46:09 +08:00
|
|
|
{
|
2006-10-16 17:24:59 +08:00
|
|
|
/* the text view idle updates, so we need to idle scroll too
|
2001-07-30 08:46:09 +08:00
|
|
|
*/
|
2006-10-16 17:24:59 +08:00
|
|
|
g_object_ref (view);
|
|
|
|
|
|
|
|
g_idle_add ((GSourceFunc) script_fu_console_idle_scroll_end, view);
|
2001-07-30 08:46:09 +08:00
|
|
|
}
|
|
|
|
|
2004-07-15 00:03:58 +08:00
|
|
|
void
|
2006-10-16 17:24:59 +08:00
|
|
|
script_fu_output_to_console (const gchar *text)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-10-16 17:24:59 +08:00
|
|
|
/* FIXME: This function needs to be passed a pointer to the console.
|
|
|
|
*/
|
|
|
|
if (output)
|
|
|
|
{
|
|
|
|
GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (output));
|
|
|
|
GtkTextIter cursor;
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
gtk_text_buffer_get_end_iter (buffer, &cursor);
|
|
|
|
gtk_text_buffer_insert_with_tags_by_name (buffer, &cursor,
|
|
|
|
text, -1,
|
|
|
|
"weak",
|
|
|
|
NULL);
|
2001-01-22 04:06:26 +08:00
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
script_fu_console_scroll_end (output);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-01-22 04:06:26 +08:00
|
|
|
static gboolean
|
2005-08-03 00:49:42 +08:00
|
|
|
script_fu_cc_is_empty (ConsoleInterface *console)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-30 08:46:09 +08:00
|
|
|
const gchar *str;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
if ((str = gtk_entry_get_text (GTK_ENTRY (console->cc))) == NULL)
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
while (*str)
|
|
|
|
{
|
|
|
|
if (*str != ' ' && *str != '\t' && *str != '\n')
|
2006-10-16 09:08:54 +08:00
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
str ++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-01-22 04:06:26 +08:00
|
|
|
static gboolean
|
2005-08-03 00:49:42 +08:00
|
|
|
script_fu_cc_key_function (GtkWidget *widget,
|
2006-10-16 09:08:54 +08:00
|
|
|
GdkEventKey *event,
|
|
|
|
ConsoleInterface *console)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-30 08:46:09 +08:00
|
|
|
GList *list;
|
|
|
|
gint direction = 0;
|
|
|
|
GtkTextIter cursor;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
switch (event->keyval)
|
|
|
|
{
|
|
|
|
case GDK_Return:
|
2005-08-03 00:49:42 +08:00
|
|
|
if (script_fu_cc_is_empty (console))
|
2006-10-16 09:08:54 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
list = g_list_nth (console->history,
|
|
|
|
(g_list_length (console->history) - 1));
|
1997-11-25 06:05:25 +08:00
|
|
|
if (list->data)
|
2006-10-16 09:08:54 +08:00
|
|
|
g_free (list->data);
|
2005-08-03 00:49:42 +08:00
|
|
|
list->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (console->cc)));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_text_buffer_get_end_iter (console->console, &cursor);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
|
2006-10-16 17:24:59 +08:00
|
|
|
"\n> ", -1,
|
2006-10-16 09:08:54 +08:00
|
|
|
"strong",
|
|
|
|
NULL);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
|
|
|
|
gtk_entry_get_text (GTK_ENTRY (console->cc)), -1,
|
2001-12-29 21:26:29 +08:00
|
|
|
"weak",
|
|
|
|
NULL);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
|
2006-10-16 09:08:54 +08:00
|
|
|
"\n", -1,
|
|
|
|
"weak",
|
|
|
|
NULL);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2006-10-16 17:24:59 +08:00
|
|
|
script_fu_console_scroll_end (console->text_view);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (console->cc), "");
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-10-16 09:08:54 +08:00
|
|
|
ts_interpret_string ((char *) list->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_displays_flush ();
|
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
console->history = g_list_append (console->history, NULL);
|
2006-10-16 17:24:59 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
if (console->history_len == console->history_max)
|
2006-10-16 17:24:59 +08:00
|
|
|
{
|
|
|
|
console->history = g_list_remove (console->history,
|
|
|
|
console->history->data);
|
|
|
|
if (console->history->data)
|
|
|
|
g_free (console->history->data);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2006-10-16 17:24:59 +08:00
|
|
|
{
|
|
|
|
console->history_len++;
|
|
|
|
}
|
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
console->history_cur = g_list_length (console->history) - 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_KP_Up:
|
|
|
|
case GDK_Up:
|
|
|
|
direction = -1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_KP_Down:
|
|
|
|
case GDK_Down:
|
|
|
|
direction = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_P:
|
|
|
|
case GDK_p:
|
|
|
|
if (event->state & GDK_CONTROL_MASK)
|
2001-12-29 21:26:29 +08:00
|
|
|
direction = -1;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_N:
|
|
|
|
case GDK_n:
|
|
|
|
if (event->state & GDK_CONTROL_MASK)
|
2001-12-29 21:26:29 +08:00
|
|
|
direction = 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (direction)
|
|
|
|
{
|
|
|
|
/* Make sure we keep track of the current one */
|
2005-08-03 00:49:42 +08:00
|
|
|
if (console->history_cur == g_list_length (console->history) - 1)
|
2006-10-16 17:24:59 +08:00
|
|
|
{
|
|
|
|
list = g_list_nth (console->history, console->history_cur);
|
|
|
|
|
2006-10-16 09:08:54 +08:00
|
|
|
g_free (list->data);
|
2006-10-16 17:24:59 +08:00
|
|
|
list->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (console->cc)));
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
console->history_cur += direction;
|
2006-10-16 17:24:59 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
if (console->history_cur < 0)
|
2006-10-16 09:08:54 +08:00
|
|
|
console->history_cur = 0;
|
2006-10-16 17:24:59 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
if (console->history_cur >= console->history_len)
|
2006-10-16 09:08:54 +08:00
|
|
|
console->history_cur = console->history_len - 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (console->cc),
|
2006-10-16 09:08:54 +08:00
|
|
|
(gchar *) (g_list_nth (console->history,
|
2005-08-03 00:49:42 +08:00
|
|
|
console->history_cur))->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_editable_set_position (GTK_EDITABLE (console->cc), -1);
|
2004-01-06 18:04:31 +08:00
|
|
|
|
1997-11-25 06:05:25 +08: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-18 06:53:21 +08:00
|
|
|
static void
|
2006-10-16 09:08:54 +08:00
|
|
|
script_fu_open_ts_console (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-10-16 09:08:54 +08:00
|
|
|
ts_set_print_flag (1);
|
|
|
|
ts_set_console_mode (1);
|
|
|
|
ts_set_verbose_level (2);
|
|
|
|
ts_print_welcome ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-16 09:08:54 +08:00
|
|
|
script_fu_close_ts_console (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-10-16 09:08:54 +08:00
|
|
|
FILE *output_file;
|
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-18 06:53:21 +08:00
|
|
|
|
2006-10-16 09:08:54 +08:00
|
|
|
ts_set_print_flag (0);
|
|
|
|
output_file = ts_get_output_file ();
|
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-18 06:53:21 +08:00
|
|
|
|
2006-10-16 09:08:54 +08:00
|
|
|
if (output_file != stdout)
|
|
|
|
fclose (output_file);
|
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-18 06:53:21 +08:00
|
|
|
|
2006-10-16 09:08:54 +08:00
|
|
|
ts_set_console_mode (0);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-09-11 03:03:20 +08:00
|
|
|
|
|
|
|
void
|
2003-07-02 07:21:36 +08:00
|
|
|
script_fu_eval_run (const gchar *name,
|
2006-10-16 09:08:54 +08:00
|
|
|
gint nparams,
|
|
|
|
const GimpParam *params,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1998-09-11 03:03:20 +08:00
|
|
|
{
|
2001-01-22 04:06:26 +08:00
|
|
|
static GimpParam values[1];
|
2000-08-22 11:27:14 +08:00
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
2006-06-08 22:45:56 +08:00
|
|
|
GimpRunMode run_mode;
|
1998-09-11 03:03:20 +08:00
|
|
|
|
|
|
|
run_mode = params[0].data.d_int32;
|
|
|
|
|
|
|
|
switch (run_mode)
|
|
|
|
{
|
2000-08-22 11:27:14 +08:00
|
|
|
case GIMP_RUN_NONINTERACTIVE:
|
2006-10-16 09:08:54 +08:00
|
|
|
/* Disable Script-Fu output */
|
|
|
|
ts_set_output_file (stdout);
|
|
|
|
ts_set_verbose_level (0);
|
|
|
|
if (ts_interpret_string (params[1].data.d_string) != 0)
|
2006-06-08 22:45:56 +08:00
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
1998-09-11 03:03:20 +08:00
|
|
|
break;
|
|
|
|
|
2000-08-22 11:27:14 +08:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
2006-06-08 22:45:56 +08:00
|
|
|
g_message (_("Script-Fu evaluation mode only allows "
|
|
|
|
"non-interactive invocation"));
|
1998-09-11 03:03:20 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
*nreturn_vals = 1;
|
|
|
|
*return_vals = values;
|
|
|
|
|
2001-01-22 04:06:26 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
1998-09-11 03:03:20 +08:00
|
|
|
values[0].data.d_status = status;
|
|
|
|
}
|