Commit 2efad8a9 authored by Kevin Cozens's avatar Kevin Cozens Committed by Kevin Cozens

Updated.

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

	* TODO: Updated.

	* tiny-fu/tiny-fu-console.c
	* tiny-fu/tiny-fu-console.h: Fixed some minor user interface and
	coding style issues. From a change made by Sven Neumann to Script-Fu.

	* tinyscheme/scheme.c: Eliminated compiler warnings.

	* scripts/script-fu-compat.init: Added 'nil'.
parent b745abc5
2006-10-16 Kevin Cozens <kcozens@cvs.gnome.org>
* TODO: Updated.
* tiny-fu/tiny-fu-console.c
* tiny-fu/tiny-fu-console.h: Fixed some minor user interface and
coding style issues. From a change made by Sven Neumann to Script-Fu.
* tinyscheme/scheme.c: Eliminated compiler warnings.
* scripts/script-fu-compat.init: Added 'nil'.
2006-10-16 Kevin Cozens <kcozens@cvs.gnome.org>
* scripts/script-fu-compat.init: Added 'the-environment'.
......
- Change TinyScheme to use a symbol instead of a string for the type argument
of make-array.
- Update the Tiny-Fu web page.
- Add SF-RADIO parameter type to register block
Comments from joao on #gimp:
It is really simple in Python. No more than a few gtk calls - all of which
have C equivalents. The whole code uses less than 20 lines. Should be less
then 35 lines in C.
Try looking at the code for SF_SPINNER and class SpinnerEntry in gimpfu.py
then look at class RadioEntry in gimpfu.py
- Review handling of brushes.
The non-deprecated set and get calls only take one parameter and not a list.
- Update the autogen.sh script based on the newer version in GIMP.
- Update the Tiny-Fu web page to mention the translation files are incomplete
since the intltool-update script doesn't recognize file names which end in
.scm as ones containing Scheme code.
- Is tiny-fu-util-image-resize-from-layer still needed or can the built-in
function 'Fit Canvas to Layers' be used instead?
- Get some examples of how to work with parasites in Scheme.
......@@ -12,18 +19,6 @@ In tiny-fu-scripts.c
- Check number of items in list for SF_ADJUSTMENT type
- Check number of items in list for SF_SELECT type
Replacing Script-Fu with Tiny-Fu:
- Add something to autogen.sh(? or at least TF) to make it easier for TF to
be reconfigured so that it steals the namespace of Script-Fu.
Use --enable-script-fu-namespace?
- Pull Script-Fu out of the GIMP source tree.
Update Script-Fu to build as a standalone plug-in.
Use Tiny-Fu as a template for this.
* Sven doesn't seem to want Script-Fu as a separate module
Building of Script-Fu is now optional.
- Update Tiny-Fu to use the Script-Fu namespace.
- Fix up the Tiny-Fu scripts to register in the right menu locations.
Bugs:
- Script doesn't abort when encountering an uncaught script error.
......@@ -45,13 +40,6 @@ ToDo (for CVS GIMP after branching Tiny-Fu):
- Test Tiny-Fu batch mode
- Test Tiny-Fu server mode
- Add test scripts for server mode to CVS
- Add SF-RADIO parameter type to register block
Comments from joao on #gimp:
It is really simple in Python. No more than a few gtk calls - all of which
have C equivalents. The whole code uses less than 20 lines. Should be less
then 35 lines in C.
Try looking at the code for SF_SPINNER and class SpinnerEntry in gimpfu.py
then look at class RadioEntry in gimpfu.py
- Add SF-MULTI(?) parameter type to register block
It would allow a user to choose multiple items and return a STRINGARRAY
- Put the gimp-text-wrapper.scm stuff in one of the .init routines??
......
......@@ -140,6 +140,7 @@
(define fopen open-input-file)
(define mapcar map)
(define nreverse reverse)
(define nil '())
(define pow expt)
(define string-lessp string<?)
(define symbol-bound? defined?)
......
......@@ -19,26 +19,24 @@
#include "config.h"
#include <errno.h>
#include <gdk/gdkkeysyms.h>
#include "libgimp/gimp.h"
#include "libgimp/gimpui.h"
#include "tiny-fu-intl.h"
#include <gdk/gdkkeysyms.h>
#include "tinyscheme/scheme.h"
#include "ts-wrapper.h"
#include "tiny-fu-console.h"
#include "tiny-fu-intl.h"
#define TEXT_WIDTH 480
#define TEXT_HEIGHT 400
#define BUFSIZE 256
#define PROC_NAME "plug-in-script-fu-console"
typedef struct
{
GtkWidget *dialog;
......@@ -46,6 +44,7 @@ typedef struct
GtkWidget *cc;
GtkWidget *text_view;
GtkWidget *proc_browser;
GtkWidget *save_dialog;
gint32 input_id;
......@@ -57,53 +56,41 @@ typedef struct
enum TF_RESPONSES {
RESPONSE_CLEAR, RESPONSE_SAVE
RESPONSE_CLEAR,
RESPONSE_SAVE
};
/*
* Local Functions
*/
static void tiny_fu_console_interface (void);
static void tiny_fu_response (GtkWidget *widget,
static void tiny_fu_console_interface (void);
static void tiny_fu_console_response (GtkWidget *widget,
gint response_id,
ConsoleInterface *console);
static void tiny_fu_save_dialog (GtkWidget *parent);
static void tiny_fu_save_output (GtkWidget *dialog,
gint response_id,
gpointer data);
static void tiny_fu_browse_callback (GtkWidget *widget,
static void tiny_fu_console_save_dialog (ConsoleInterface *console);
static void tiny_fu_console_save_response (GtkWidget *dialog,
gint response_id,
ConsoleInterface *console);
static void tiny_fu_browse_callback (GtkWidget *widget,
ConsoleInterface *console);
static void tiny_fu_browse_response (GtkWidget *widget,
static void tiny_fu_browse_response (GtkWidget *widget,
gint response_id,
ConsoleInterface *console);
static void tiny_fu_browse_row_activated (GtkDialog *dialog);
static gboolean tiny_fu_cc_is_empty (ConsoleInterface *console);
static gboolean tiny_fu_cc_key_function (GtkWidget *widget,
static void tiny_fu_browse_row_activated (GtkDialog *dialog);
static gboolean tiny_fu_cc_is_empty (ConsoleInterface *console);
static gboolean tiny_fu_cc_key_function (GtkWidget *widget,
GdkEventKey *event,
ConsoleInterface *console);
static void tiny_fu_open_ts_console (void);
static void tiny_fu_close_ts_console (void);
static void tiny_fu_open_ts_console (void);
static void tiny_fu_close_ts_console (void);
/*
* Local variables
*/
static ConsoleInterface cint =
{
NULL, /* dialog */
NULL, /* console */
NULL, /* current command */
NULL, /* text view */
NULL, /* proc browser */
-1, /* input id */
NULL,
0,
0,
50
};
static GtkWidget *output = NULL;
/*
......@@ -143,12 +130,9 @@ tiny_fu_console_interface (void)
gimp_ui_init ("tiny-fu", FALSE);
console = &cint;
console = g_new0 (ConsoleInterface, 1);
console->input_id = -1;
console->history = NULL;
console->history_len = 0;
console->history_cur = 0;
console->history_max = 50;
console->dialog = gimp_dialog_new (_("Script-Fu Console"),
......@@ -156,18 +140,25 @@ tiny_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,
GTK_STOCK_SAVE, RESPONSE_SAVE,
GTK_STOCK_CLEAR, RESPONSE_CLEAR,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL);
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);
g_signal_connect (console->dialog, "response",
G_CALLBACK (tiny_fu_response),
G_CALLBACK (tiny_fu_console_response),
console);
g_signal_connect (console->dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&console->dialog);
/* The main vbox */
vbox = gtk_vbox_new (FALSE, 12);
......@@ -188,6 +179,8 @@ tiny_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_left_margin (GTK_TEXT_VIEW (console->text_view), 12);
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (console->text_view), 12);
......@@ -264,68 +257,80 @@ tiny_fu_console_interface (void)
g_source_remove (console->input_id);
if (console->dialog)
gtk_widget_destroy (console->dialog);
output = NULL;
if (console->save_dialog)
gtk_widget_destroy (console->save_dialog);
if (console->dialog)
gtk_widget_destroy (console->dialog);
g_free (console);
}
static void
tiny_fu_response (GtkWidget *widget,
gint response_id,
ConsoleInterface *console)
tiny_fu_console_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:
tiny_fu_save_dialog(widget);
break;
default:
gtk_main_quit ();
break;
}
{
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:
tiny_fu_console_save_dialog (console);
break;
default:
gtk_main_quit ();
break;
}
}
static void
tiny_fu_save_dialog(GtkWidget *parent)
tiny_fu_console_save_dialog (ConsoleInterface *console)
{
static GtkWidget *dialog = NULL;
if (! dialog)
if (! console->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);
console->save_dialog =
gtk_file_chooser_dialog_new (_("Save Tiny-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);
g_signal_connect (dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&dialog);
g_signal_connect (dialog, "response",
G_CALLBACK (tiny_fu_save_output),
NULL);
g_object_add_weak_pointer (G_OBJECT (console->save_dialog),
(gpointer) &console->save_dialog);
g_signal_connect (console->save_dialog, "response",
G_CALLBACK (tiny_fu_console_save_response),
console);
}
gtk_window_present (GTK_WINDOW (dialog));
gtk_window_present (GTK_WINDOW (console->dialog));
}
static void
tiny_fu_save_output (GtkWidget *dialog,
gint response_id,
gpointer data)
tiny_fu_console_save_response (GtkWidget *dialog,
gint response_id,
ConsoleInterface *console)
{
GtkTextIter start, end;
if (response_id == GTK_RESPONSE_ACCEPT)
if (response_id == GTK_RESPONSE_OK)
{
gchar *filename;
gchar *str;
......@@ -334,29 +339,29 @@ tiny_fu_save_output (GtkWidget *dialog,
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 (_("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);
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, TRUE);
fputs (str, fh);
fclose (fh);
g_free (str);
}
gtk_widget_destroy (dialog);
gtk_widget_hide (dialog);
}
static void
......@@ -377,6 +382,10 @@ tiny_fu_browse_callback (GtkWidget *widget,
gtk_dialog_set_default_response (GTK_DIALOG (console->proc_browser),
GTK_RESPONSE_APPLY);
gtk_dialog_set_alternative_button_order (GTK_DIALOG (console->proc_browser),
GTK_RESPONSE_CLOSE,
GTK_RESPONSE_APPLY,
-1);
g_object_add_weak_pointer (G_OBJECT (console->proc_browser),
(gpointer) &console->proc_browser);
......@@ -466,35 +475,45 @@ tiny_fu_browse_row_activated (GtkDialog *dialog)
}
static gboolean
tiny_fu_console_idle_scroll_end (ConsoleInterface *console)
tiny_fu_console_idle_scroll_end (GtkWidget *view)
{
GtkAdjustment *adj = GTK_TEXT_VIEW (console->text_view)->vadjustment;
GtkAdjustment *adj = GTK_TEXT_VIEW (view)->vadjustment;
gtk_adjustment_set_value (adj, adj->upper - adj->page_size);
g_object_unref (view);
return FALSE;
}
static void
tiny_fu_console_scroll_end (ConsoleInterface *console)
tiny_fu_console_scroll_end (GtkWidget *view)
{
/* the text view idle updates so we need to idle scroll too
/* the text view idle updates, so we need to idle scroll too
*/
g_idle_add ((GSourceFunc) tiny_fu_console_idle_scroll_end, console);
g_object_ref (view);
g_idle_add ((GSourceFunc) tiny_fu_console_idle_scroll_end, view);
}
void
tiny_fu_output_to_console (gchar *text)
{
GtkTextIter cursor;
/* 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;
gtk_text_buffer_get_end_iter (cint.console, &cursor);
gtk_text_buffer_insert_with_tags_by_name (cint.console, &cursor,
text, -1,
"weak",
NULL);
gtk_text_buffer_get_end_iter (buffer, &cursor);
gtk_text_buffer_insert_with_tags_by_name (buffer, &cursor,
text, -1,
"weak",
NULL);
tiny_fu_console_scroll_end (&cint);
tiny_fu_console_scroll_end (output);
}
}
static gboolean
......@@ -540,7 +559,7 @@ tiny_fu_cc_key_function (GtkWidget *widget,
gtk_text_buffer_get_end_iter (console->console, &cursor);
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
"\n=> ", -1,
"\n> ", -1,
"strong",
NULL);
......@@ -554,7 +573,7 @@ tiny_fu_cc_key_function (GtkWidget *widget,
"weak",
NULL);
tiny_fu_console_scroll_end (console);
tiny_fu_console_scroll_end (console->text_view);
gtk_entry_set_text (GTK_ENTRY (console->cc), "");
......@@ -562,6 +581,7 @@ tiny_fu_cc_key_function (GtkWidget *widget,
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,
......@@ -570,7 +590,10 @@ tiny_fu_cc_key_function (GtkWidget *widget,
g_free (console->history->data);
}
else
console->history_len++;
{
console->history_len++;
}
console->history_cur = g_list_length (console->history) - 1;
return TRUE;
......@@ -608,14 +631,16 @@ tiny_fu_cc_key_function (GtkWidget *widget,
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);
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;
if (console->history_cur >= console->history_len)
console->history_cur = console->history_len - 1;
......
......@@ -21,15 +21,15 @@
void tiny_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);
void tiny_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);
void tiny_fu_output_to_console (gchar *text);
......
......@@ -77,7 +77,7 @@
#else
static int stricmp(const char *s1, const char *s2)
{
unsigned char *s1a, *s2a;
char *s1a, *s2a;
int result;
s1a = g_utf8_strdown(s1, -1);
......@@ -1887,7 +1887,7 @@ static int token(scheme *sc) {
static void printslashstring(scheme *sc, char *p, int len) {
int i;
gunichar c;
unsigned char *s=(unsigned char*)p;
char *s=(char*)p;
putcharacter(sc,'"');
for (i=0; i<len; i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment