From 2afd3ffb7574f612e2a4d8622dfe3d44923f2d92 Mon Sep 17 00:00:00 2001 From: Manish Singh Date: Sun, 1 Mar 1998 01:18:45 +0000 Subject: [PATCH] From the Changelog: * Makefile.am: don't do docs generation by default * configure.in: -lXt for webbrowser plugin * libgimp/gimp.c * libgimp/gimpprotocol.c * libgimp/gimptile.c * libgimp/gimpwire.c * app/plug_in.c: applied memory leak patch from Mattias Gronlund * app/eraser.c * app/eraser.h * app/internal_procs.c * app/paintbrush.c * app/paintbrush.h: incremental modes for eraser and paintbrush, as well as a "hard eraser" * plug-ins/ifscompose/ifscompose.c: pixmap visual fixups -Yosh --- ChangeLog | 21 +++ Makefile.am | 2 +- app/about_dialog.c | 9 -- app/actions/plug-in-commands.c | 4 +- app/dialogs/about-dialog.c | 9 -- app/eraser.c | 223 ++++++++++++++++++++++++++- app/eraser.h | 1 + app/gui/about-dialog.c | 9 -- app/gui/plug-in-commands.c | 4 +- app/gui/plug-in-menus.c | 4 +- app/internal_procs.c | 2 + app/menus/plug-in-menus.c | 4 +- app/paint/gimperaser.c | 223 ++++++++++++++++++++++++++- app/paint/gimperaser.h | 1 + app/paintbrush.c | 185 +++++++++++++++++++++- app/paintbrush.h | 1 + app/plug-in/gimpplugin-message.c | 4 +- app/plug-in/gimpplugin-progress.c | 4 +- app/plug-in/gimpplugin.c | 4 +- app/plug-in/gimppluginmanager-call.c | 4 +- app/plug-in/gimppluginmanager-run.c | 4 +- app/plug-in/gimppluginmanager.c | 4 +- app/plug-in/gimppluginshm.c | 4 +- app/plug-in/plug-in-def.c | 4 +- app/plug-in/plug-in-message.c | 4 +- app/plug-in/plug-in-params.c | 4 +- app/plug-in/plug-in-progress.c | 4 +- app/plug-in/plug-in-run.c | 4 +- app/plug-in/plug-in-shm.c | 4 +- app/plug-in/plug-in.c | 4 +- app/plug-in/plug-ins.c | 4 +- app/plug_in.c | 4 +- app/tools/eraser.c | 223 ++++++++++++++++++++++++++- app/tools/eraser.h | 1 + app/tools/gimperasertool.c | 223 ++++++++++++++++++++++++++- app/tools/gimperasertool.h | 1 + app/tools/paintbrush.c | 185 +++++++++++++++++++++- app/tools/paintbrush.h | 1 + configure.in | 2 +- libgimp/gimp.c | 1 + libgimp/gimpprotocol.c | 8 +- libgimp/gimptile.c | 4 + libgimp/gimpwire.c | 5 +- libgimpbase/gimpprotocol.c | 8 +- libgimpbase/gimpwire.c | 5 +- plug-ins/ifscompose/ifscompose.c | 4 +- 46 files changed, 1320 insertions(+), 117 deletions(-) diff --git a/ChangeLog b/ChangeLog index 57ec755f38..a3db5a324a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +Sat Feb 28 16:57:49 PST 1998 Manish Singh + + * Makefile.am: don't do docs generation by default + + * configure.in: -lXt for webbrowser plugin + + * libgimp/gimp.c + * libgimp/gimpprotocol.c + * libgimp/gimptile.c + * libgimp/gimpwire.c + * app/plug_in.c: applied memory leak patch from Mattias Gronlund + + * app/eraser.c + * app/eraser.h + * app/internal_procs.c + * app/paintbrush.c + * app/paintbrush.h: incremental modes for eraser and paintbrush, + as well as a "hard eraser" + + * plug-ins/ifscompose/ifscompose.c: pixmap visual fixups + Sat Feb 28 00:09:46 1998 Scott Goehring * app/gimage_cmds.c (duplicate): Duplicate image wasn't copying diff --git a/Makefile.am b/Makefile.am index 79ac24732a..4dcbeb5b7e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS = libgimp plug-ins app docs +SUBDIRS = libgimp plug-ins app EXTRA_DIST = TODO TODO-DIST NOTES gtkrc gimp_logo.ppm gimp_splash.ppm rmshm user_install gimp_tips.txt ps-menurc diff --git a/app/about_dialog.c b/app/about_dialog.c index 47c8e5254e..28a683d480 100644 --- a/app/about_dialog.c +++ b/app/about_dialog.c @@ -492,12 +492,3 @@ about_dialog_timer (gpointer data) return return_val; } - - - - - - - - - diff --git a/app/actions/plug-in-commands.c b/app/actions/plug-in-commands.c index e4638e0bc5..f473508ad8 100644 --- a/app/actions/plug-in-commands.c +++ b/app/actions/plug-in-commands.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/dialogs/about-dialog.c b/app/dialogs/about-dialog.c index 47c8e5254e..28a683d480 100644 --- a/app/dialogs/about-dialog.c +++ b/app/dialogs/about-dialog.c @@ -492,12 +492,3 @@ about_dialog_timer (gpointer data) return return_val; } - - - - - - - - - diff --git a/app/eraser.c b/app/eraser.c index 50b5ae9823..c529eb37c5 100644 --- a/app/eraser.c +++ b/app/eraser.c @@ -29,11 +29,81 @@ #include "tools.h" /* forward function declarations */ -static void eraser_motion (PaintCore *, GimpDrawable *); +static void eraser_motion (PaintCore *, GimpDrawable *, gboolean, gboolean); static Argument * eraser_invoker (Argument *); +static Argument * eraser_extended_invoker (Argument *); -static void * eraser_options = NULL; +static gboolean non_gui_hard, non_gui_incremental; + +typedef struct _EraserOptions EraserOptions; +struct _EraserOptions +{ + gboolean hard; + gboolean incremental; +}; + +static EraserOptions *eraser_options = NULL; + +static void +eraser_toggle_update (GtkWidget *w, + gpointer data) +{ + gboolean *toggle_val; + + toggle_val = (gboolean *) data; + + if (GTK_TOGGLE_BUTTON (w)->active) + *toggle_val = TRUE; + else + *toggle_val = FALSE; +} + +static EraserOptions * +create_eraser_options (void) +{ + EraserOptions *options; + GtkWidget *vbox; + GtkWidget *label; + GtkWidget *hard_toggle; + GtkWidget *incremental_toggle; + + options = (EraserOptions *) g_malloc (sizeof (EraserOptions)); + options->hard = FALSE; + options->incremental = FALSE; + + /* the main vbox */ + vbox = gtk_vbox_new (FALSE, 1); + + /* the main label */ + label = gtk_label_new ("Eraser Options"); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + /* the hard toggle */ + hard_toggle = gtk_check_button_new_with_label ("Hard edge"); + gtk_box_pack_start (GTK_BOX (vbox), hard_toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (hard_toggle), "toggled", + (GtkSignalFunc) eraser_toggle_update, + &options->hard); + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (hard_toggle), options->hard); + gtk_widget_show (hard_toggle); + + /* the incremental toggle */ + incremental_toggle = gtk_check_button_new_with_label ("Incremental"); + gtk_box_pack_start (GTK_BOX (vbox), incremental_toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (incremental_toggle), "toggled", + (GtkSignalFunc) eraser_toggle_update, + &options->incremental); + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (incremental_toggle), options->incremental); + gtk_widget_show (incremental_toggle); + + /* Register this eraser options widget with the main tools options dialog */ + tools_register_options (ERASER, vbox); + + return options; +} + void * eraser_paint_func (paint_core, drawable, state) PaintCore *paint_core; @@ -46,7 +116,7 @@ eraser_paint_func (paint_core, drawable, state) break; case MOTION_PAINT : - eraser_motion (paint_core, drawable); + eraser_motion (paint_core, drawable, eraser_options->hard, eraser_options->incremental); break; case FINISH_PAINT : @@ -67,7 +137,7 @@ tools_new_eraser () PaintCore * private; if (! eraser_options) - eraser_options = tools_register_no_options (ERASER, "Eraser Options"); + eraser_options = create_eraser_options (); tool = paint_core_new (ERASER); @@ -87,9 +157,11 @@ tools_free_eraser (tool) void -eraser_motion (paint_core, drawable) +eraser_motion (paint_core, drawable, hard, incremental) PaintCore *paint_core; GimpDrawable *drawable; + gboolean hard; + gboolean incremental; { GImage *gimage; TempBuf * area; @@ -114,20 +186,48 @@ eraser_motion (paint_core, drawable) /* paste the newly painted canvas to the gimage which is being worked on */ paint_core_paste_canvas (paint_core, drawable, OPAQUE_OPACITY, (int) (get_brush_opacity () * 255), - ERASE_MODE, SOFT, CONSTANT); + ERASE_MODE, hard? HARD : SOFT, incremental ? INCREMENTAL : CONSTANT); } static void * eraser_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, int state) { - eraser_motion (paint_core, drawable); + eraser_motion (paint_core, drawable, non_gui_hard, non_gui_incremental); return NULL; } /* The eraser procedure definition */ +ProcArg eraser_extended_args[] = +{ + { PDB_IMAGE, + "image", + "the image" + }, + { PDB_DRAWABLE, + "drawable", + "the drawable" + }, + { PDB_INT32, + "num_strokes", + "number of stroke control points (count each coordinate as 2 points)" + }, + { PDB_FLOATARRAY, + "strokes", + "array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}" + }, + { PDB_INT32, + "hardness", + "SOFT(0) or HARD(1)" + }, + { PDB_INT32, + "method", + "CONTINUOUS(0) or INCREMENTAL(1)" + } +}; + ProcArg eraser_args[] = { { PDB_IMAGE, @@ -171,6 +271,27 @@ ProcRecord eraser_proc = { { eraser_invoker } }, }; +ProcRecord eraser_extended_proc = +{ + "gimp_eraser_extended", + "Erase using the current brush", + "This tool erases using the current brush mask. If the specified drawable contains an alpha channel, then the erased pixels will become transparent. Otherwise, the eraser tool replaces the contents of the drawable with the background color. Like paintbrush, this tool linearly interpolates between the specified stroke coordinates.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + PDB_INTERNAL, + + /* Input arguments */ + 6, + eraser_extended_args, + + /* Output arguments */ + 0, + NULL, + + /* Exec method */ + { { eraser_extended_invoker } }, +}; static Argument * eraser_invoker (args) @@ -221,6 +342,94 @@ eraser_invoker (args) success = paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1]); + if (success) + { + non_gui_hard=0; non_gui_incremental = 0; + /* set the paint core's paint func */ + non_gui_paint_core.paint_func = eraser_non_gui_paint_func; + + non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0]; + non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1]; + + if (num_strokes == 1) + eraser_non_gui_paint_func (&non_gui_paint_core, drawable, 0); + + for (i = 1; i < num_strokes; i++) + { + non_gui_paint_core.curx = stroke_array[i * 2 + 0]; + non_gui_paint_core.cury = stroke_array[i * 2 + 1]; + + paint_core_interpolate (&non_gui_paint_core, drawable); + + non_gui_paint_core.lastx = non_gui_paint_core.curx; + non_gui_paint_core.lasty = non_gui_paint_core.cury; + } + + /* finish the painting */ + paint_core_finish (&non_gui_paint_core, drawable, -1); + + /* cleanup */ + paint_core_cleanup (); + } + + return procedural_db_return_args (&eraser_proc, success); +} + +static Argument * +eraser_extended_invoker (args) + Argument *args; +{ + int success = TRUE; + GImage *gimage; + GimpDrawable *drawable; + int num_strokes; + double *stroke_array; + int int_value; + int i; + + drawable = NULL; + num_strokes = 0; + + /* the gimage */ + if (success) + { + int_value = args[0].value.pdb_int; + if (! (gimage = gimage_get_ID (int_value))) + success = FALSE; + } + /* the drawable */ + if (success) + { + int_value = args[1].value.pdb_int; + drawable = drawable_get_ID (int_value); + if (drawable == NULL || gimage != drawable_gimage (drawable)) + success = FALSE; + } + /* num strokes */ + if (success) + { + int_value = args[2].value.pdb_int; + if (int_value > 0) + num_strokes = int_value / 2; + else + success = FALSE; + } + + /* point array */ + if (success) + stroke_array = (double *) args[3].value.pdb_pointer; + + if (success) + /* init the paint core */ + success = paint_core_init (&non_gui_paint_core, drawable, + stroke_array[0], stroke_array[1]); + + if (success) + { + non_gui_hard = args[4].value.pdb_int; + non_gui_incremental = args[5].value.pdb_int; + } + if (success) { /* set the paint core's paint func */ diff --git a/app/eraser.h b/app/eraser.h index 4c1bd031a9..9b57d7bad2 100644 --- a/app/eraser.h +++ b/app/eraser.h @@ -28,5 +28,6 @@ void tools_free_eraser (Tool *); /* Procedure definition and marshalling function */ extern ProcRecord eraser_proc; +extern ProcRecord eraser_extended_proc; #endif /* __ERASER_H__ */ diff --git a/app/gui/about-dialog.c b/app/gui/about-dialog.c index 47c8e5254e..28a683d480 100644 --- a/app/gui/about-dialog.c +++ b/app/gui/about-dialog.c @@ -492,12 +492,3 @@ about_dialog_timer (gpointer data) return return_val; } - - - - - - - - - diff --git a/app/gui/plug-in-commands.c b/app/gui/plug-in-commands.c index e4638e0bc5..f473508ad8 100644 --- a/app/gui/plug-in-commands.c +++ b/app/gui/plug-in-commands.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/gui/plug-in-menus.c b/app/gui/plug-in-menus.c index e4638e0bc5..f473508ad8 100644 --- a/app/gui/plug-in-menus.c +++ b/app/gui/plug-in-menus.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/internal_procs.c b/app/internal_procs.c index 3a3281e3fb..b64667c0b1 100644 --- a/app/internal_procs.c +++ b/app/internal_procs.c @@ -92,10 +92,12 @@ internal_procs_init () procedural_db_register (&crop_proc); pcount++; procedural_db_register (&ellipse_select_proc); pcount++; procedural_db_register (&eraser_proc); pcount++; + procedural_db_register (&eraser_extended_proc); pcount++; procedural_db_register (&flip_proc); pcount++; procedural_db_register (&free_select_proc); pcount++; procedural_db_register (&fuzzy_select_proc); pcount++; procedural_db_register (&paintbrush_proc); pcount++; + procedural_db_register (&paintbrush_extended_proc); pcount++; procedural_db_register (&pencil_proc); pcount++; procedural_db_register (&perspective_proc); pcount++; procedural_db_register (&rect_select_proc); pcount++; diff --git a/app/menus/plug-in-menus.c b/app/menus/plug-in-menus.c index e4638e0bc5..f473508ad8 100644 --- a/app/menus/plug-in-menus.c +++ b/app/menus/plug-in-menus.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/paint/gimperaser.c b/app/paint/gimperaser.c index 50b5ae9823..c529eb37c5 100644 --- a/app/paint/gimperaser.c +++ b/app/paint/gimperaser.c @@ -29,11 +29,81 @@ #include "tools.h" /* forward function declarations */ -static void eraser_motion (PaintCore *, GimpDrawable *); +static void eraser_motion (PaintCore *, GimpDrawable *, gboolean, gboolean); static Argument * eraser_invoker (Argument *); +static Argument * eraser_extended_invoker (Argument *); -static void * eraser_options = NULL; +static gboolean non_gui_hard, non_gui_incremental; + +typedef struct _EraserOptions EraserOptions; +struct _EraserOptions +{ + gboolean hard; + gboolean incremental; +}; + +static EraserOptions *eraser_options = NULL; + +static void +eraser_toggle_update (GtkWidget *w, + gpointer data) +{ + gboolean *toggle_val; + + toggle_val = (gboolean *) data; + + if (GTK_TOGGLE_BUTTON (w)->active) + *toggle_val = TRUE; + else + *toggle_val = FALSE; +} + +static EraserOptions * +create_eraser_options (void) +{ + EraserOptions *options; + GtkWidget *vbox; + GtkWidget *label; + GtkWidget *hard_toggle; + GtkWidget *incremental_toggle; + + options = (EraserOptions *) g_malloc (sizeof (EraserOptions)); + options->hard = FALSE; + options->incremental = FALSE; + + /* the main vbox */ + vbox = gtk_vbox_new (FALSE, 1); + + /* the main label */ + label = gtk_label_new ("Eraser Options"); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + /* the hard toggle */ + hard_toggle = gtk_check_button_new_with_label ("Hard edge"); + gtk_box_pack_start (GTK_BOX (vbox), hard_toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (hard_toggle), "toggled", + (GtkSignalFunc) eraser_toggle_update, + &options->hard); + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (hard_toggle), options->hard); + gtk_widget_show (hard_toggle); + + /* the incremental toggle */ + incremental_toggle = gtk_check_button_new_with_label ("Incremental"); + gtk_box_pack_start (GTK_BOX (vbox), incremental_toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (incremental_toggle), "toggled", + (GtkSignalFunc) eraser_toggle_update, + &options->incremental); + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (incremental_toggle), options->incremental); + gtk_widget_show (incremental_toggle); + + /* Register this eraser options widget with the main tools options dialog */ + tools_register_options (ERASER, vbox); + + return options; +} + void * eraser_paint_func (paint_core, drawable, state) PaintCore *paint_core; @@ -46,7 +116,7 @@ eraser_paint_func (paint_core, drawable, state) break; case MOTION_PAINT : - eraser_motion (paint_core, drawable); + eraser_motion (paint_core, drawable, eraser_options->hard, eraser_options->incremental); break; case FINISH_PAINT : @@ -67,7 +137,7 @@ tools_new_eraser () PaintCore * private; if (! eraser_options) - eraser_options = tools_register_no_options (ERASER, "Eraser Options"); + eraser_options = create_eraser_options (); tool = paint_core_new (ERASER); @@ -87,9 +157,11 @@ tools_free_eraser (tool) void -eraser_motion (paint_core, drawable) +eraser_motion (paint_core, drawable, hard, incremental) PaintCore *paint_core; GimpDrawable *drawable; + gboolean hard; + gboolean incremental; { GImage *gimage; TempBuf * area; @@ -114,20 +186,48 @@ eraser_motion (paint_core, drawable) /* paste the newly painted canvas to the gimage which is being worked on */ paint_core_paste_canvas (paint_core, drawable, OPAQUE_OPACITY, (int) (get_brush_opacity () * 255), - ERASE_MODE, SOFT, CONSTANT); + ERASE_MODE, hard? HARD : SOFT, incremental ? INCREMENTAL : CONSTANT); } static void * eraser_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, int state) { - eraser_motion (paint_core, drawable); + eraser_motion (paint_core, drawable, non_gui_hard, non_gui_incremental); return NULL; } /* The eraser procedure definition */ +ProcArg eraser_extended_args[] = +{ + { PDB_IMAGE, + "image", + "the image" + }, + { PDB_DRAWABLE, + "drawable", + "the drawable" + }, + { PDB_INT32, + "num_strokes", + "number of stroke control points (count each coordinate as 2 points)" + }, + { PDB_FLOATARRAY, + "strokes", + "array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}" + }, + { PDB_INT32, + "hardness", + "SOFT(0) or HARD(1)" + }, + { PDB_INT32, + "method", + "CONTINUOUS(0) or INCREMENTAL(1)" + } +}; + ProcArg eraser_args[] = { { PDB_IMAGE, @@ -171,6 +271,27 @@ ProcRecord eraser_proc = { { eraser_invoker } }, }; +ProcRecord eraser_extended_proc = +{ + "gimp_eraser_extended", + "Erase using the current brush", + "This tool erases using the current brush mask. If the specified drawable contains an alpha channel, then the erased pixels will become transparent. Otherwise, the eraser tool replaces the contents of the drawable with the background color. Like paintbrush, this tool linearly interpolates between the specified stroke coordinates.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + PDB_INTERNAL, + + /* Input arguments */ + 6, + eraser_extended_args, + + /* Output arguments */ + 0, + NULL, + + /* Exec method */ + { { eraser_extended_invoker } }, +}; static Argument * eraser_invoker (args) @@ -221,6 +342,94 @@ eraser_invoker (args) success = paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1]); + if (success) + { + non_gui_hard=0; non_gui_incremental = 0; + /* set the paint core's paint func */ + non_gui_paint_core.paint_func = eraser_non_gui_paint_func; + + non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0]; + non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1]; + + if (num_strokes == 1) + eraser_non_gui_paint_func (&non_gui_paint_core, drawable, 0); + + for (i = 1; i < num_strokes; i++) + { + non_gui_paint_core.curx = stroke_array[i * 2 + 0]; + non_gui_paint_core.cury = stroke_array[i * 2 + 1]; + + paint_core_interpolate (&non_gui_paint_core, drawable); + + non_gui_paint_core.lastx = non_gui_paint_core.curx; + non_gui_paint_core.lasty = non_gui_paint_core.cury; + } + + /* finish the painting */ + paint_core_finish (&non_gui_paint_core, drawable, -1); + + /* cleanup */ + paint_core_cleanup (); + } + + return procedural_db_return_args (&eraser_proc, success); +} + +static Argument * +eraser_extended_invoker (args) + Argument *args; +{ + int success = TRUE; + GImage *gimage; + GimpDrawable *drawable; + int num_strokes; + double *stroke_array; + int int_value; + int i; + + drawable = NULL; + num_strokes = 0; + + /* the gimage */ + if (success) + { + int_value = args[0].value.pdb_int; + if (! (gimage = gimage_get_ID (int_value))) + success = FALSE; + } + /* the drawable */ + if (success) + { + int_value = args[1].value.pdb_int; + drawable = drawable_get_ID (int_value); + if (drawable == NULL || gimage != drawable_gimage (drawable)) + success = FALSE; + } + /* num strokes */ + if (success) + { + int_value = args[2].value.pdb_int; + if (int_value > 0) + num_strokes = int_value / 2; + else + success = FALSE; + } + + /* point array */ + if (success) + stroke_array = (double *) args[3].value.pdb_pointer; + + if (success) + /* init the paint core */ + success = paint_core_init (&non_gui_paint_core, drawable, + stroke_array[0], stroke_array[1]); + + if (success) + { + non_gui_hard = args[4].value.pdb_int; + non_gui_incremental = args[5].value.pdb_int; + } + if (success) { /* set the paint core's paint func */ diff --git a/app/paint/gimperaser.h b/app/paint/gimperaser.h index 4c1bd031a9..9b57d7bad2 100644 --- a/app/paint/gimperaser.h +++ b/app/paint/gimperaser.h @@ -28,5 +28,6 @@ void tools_free_eraser (Tool *); /* Procedure definition and marshalling function */ extern ProcRecord eraser_proc; +extern ProcRecord eraser_extended_proc; #endif /* __ERASER_H__ */ diff --git a/app/paintbrush.c b/app/paintbrush.c index 8815b7958f..c82fe77afe 100644 --- a/app/paintbrush.c +++ b/app/paintbrush.c @@ -30,10 +30,11 @@ #include "tools.h" /* forward function declarations */ -static void paintbrush_motion (PaintCore *, GimpDrawable *, double); +static void paintbrush_motion (PaintCore *, GimpDrawable *, double, gboolean); static Argument * paintbrush_invoker (Argument *); +static Argument * paintbrush_extended_invoker (Argument *); -static double non_gui_fade_out; +static double non_gui_fade_out, non_gui_incremental; /* defines */ @@ -43,12 +44,27 @@ typedef struct _PaintOptions PaintOptions; struct _PaintOptions { double fade_out; + gboolean incremental; }; /* local variables */ static PaintOptions *paint_options = NULL; +static void +paintbrush_toggle_update (GtkWidget *w, + gpointer data) +{ + gboolean *toggle_val; + + toggle_val = (gboolean *) data; + + if (GTK_TOGGLE_BUTTON (w)->active) + *toggle_val = TRUE; + else + *toggle_val = FALSE; +} + static void paintbrush_scale_update (GtkAdjustment *adjustment, double *scale_val) @@ -65,10 +81,12 @@ create_paint_options (void) GtkWidget *label; GtkWidget *fade_out_scale; GtkObject *fade_out_scale_data; + GtkWidget *incremental_toggle; /* the new options structure */ options = (PaintOptions *) g_malloc (sizeof (PaintOptions)); options->fade_out = 0.0; + options->incremental = FALSE; /* the main vbox */ vbox = gtk_vbox_new (FALSE, 1); @@ -97,6 +115,16 @@ create_paint_options (void) gtk_widget_show (fade_out_scale); gtk_widget_show (hbox); + + /* the incremental toggle */ + incremental_toggle = gtk_check_button_new_with_label ("Incremental"); + gtk_box_pack_start (GTK_BOX (vbox), incremental_toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (incremental_toggle), "toggled", + (GtkSignalFunc) paintbrush_toggle_update, + &options->incremental); + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (incremental_toggle), options->incremental); + gtk_widget_show (incremental_toggle); + /* Register this selection options widget with the main tools options dialog */ tools_register_options (PAINTBRUSH, vbox); @@ -114,7 +142,7 @@ paintbrush_paint_func (PaintCore *paint_core, break; case MOTION_PAINT : - paintbrush_motion (paint_core, drawable, paint_options->fade_out); + paintbrush_motion (paint_core, drawable, paint_options->fade_out, paint_options->incremental); break; case FINISH_PAINT : @@ -156,7 +184,8 @@ tools_free_paintbrush (Tool *tool) void paintbrush_motion (PaintCore *paint_core, GimpDrawable *drawable, - double fade_out) + double fade_out, + gboolean incremental) { GImage *gimage; TempBuf * area; @@ -195,7 +224,8 @@ paintbrush_motion (PaintCore *paint_core, /* paste the newly painted canvas to the gimage which is being worked on */ paint_core_paste_canvas (paint_core, drawable, blend, (int) (get_brush_opacity () * 255), - get_brush_paint_mode (), SOFT, CONSTANT); + get_brush_paint_mode (), SOFT, + incremental ? INCREMENTAL : CONSTANT); } } @@ -204,8 +234,8 @@ static void * paintbrush_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, int state) -{ - paintbrush_motion (paint_core, drawable, non_gui_fade_out); +{ + paintbrush_motion (paint_core, drawable, non_gui_fade_out, non_gui_incremental); return NULL; } @@ -236,6 +266,34 @@ ProcArg paintbrush_args[] = } }; +ProcArg paintbrush_extended_args[] = +{ + { PDB_IMAGE, + "image", + "the image" + }, + { PDB_DRAWABLE, + "drawable", + "the drawable" + }, + { PDB_FLOAT, + "fade_out", + "fade out parameter: fade_out > 0" + }, + { PDB_INT32, + "num_strokes", + "number of stroke control points (count each coordinate as 2 points)" + }, + { PDB_FLOATARRAY, + "strokes", + "array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}" + }, + { PDB_INT32, + "method", + "CONTINUOUS(0) or INCREMENTAL(1)" + } +}; + ProcRecord paintbrush_proc = { @@ -259,6 +317,28 @@ ProcRecord paintbrush_proc = { { paintbrush_invoker } }, }; +ProcRecord paintbrush_extended_proc = +{ + "gimp_paintbrush_exteneded", + "Paint in the current brush with optional fade out parameter", + "This tool is the standard paintbrush. It draws linearly interpolated lines through the specified stroke coordinates. It operates on the specified drawable in the foreground color with the active brush. The \"fade_out\" parameter is measured in pixels and allows the brush stroke to linearly fall off. The pressure is set to the maximum at the beginning of the stroke. As the distance of the stroke nears the fade_out value, the pressure will approach zero.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + PDB_INTERNAL, + + /* Input arguments */ + 6, + paintbrush_extended_args, + + /* Output arguments */ + 0, + NULL, + + /* Exec method */ + { { paintbrush_extended_invoker } }, +}; + static Argument * paintbrush_invoker (Argument *args) { @@ -319,6 +399,97 @@ paintbrush_invoker (Argument *args) if (success) { + non_gui_incremental = 0; + /* set the paint core's paint func */ + non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func; + + non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0]; + non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1]; + + if (num_strokes == 1) + paintbrush_non_gui_paint_func (&non_gui_paint_core, drawable, 0); + + for (i = 1; i < num_strokes; i++) + { + non_gui_paint_core.curx = stroke_array[i * 2 + 0]; + non_gui_paint_core.cury = stroke_array[i * 2 + 1]; + + paint_core_interpolate (&non_gui_paint_core, drawable); + + non_gui_paint_core.lastx = non_gui_paint_core.curx; + non_gui_paint_core.lasty = non_gui_paint_core.cury; + } + + /* finish the painting */ + paint_core_finish (&non_gui_paint_core, drawable, -1); + + /* cleanup */ + paint_core_cleanup (); + } + + return procedural_db_return_args (&paintbrush_proc, success); +} +static Argument * +paintbrush_extended_invoker (Argument *args) +{ + int success = TRUE; + GImage *gimage; + GimpDrawable *drawable; + int num_strokes; + double *stroke_array; + int int_value; + double fp_value; + int i; + + drawable = NULL; + num_strokes = 0; + + /* the gimage */ + if (success) + { + int_value = args[0].value.pdb_int; + if (! (gimage = gimage_get_ID (int_value))) + success = FALSE; + } + /* the drawable */ + if (success) + { + int_value = args[1].value.pdb_int; + drawable = drawable_get_ID (int_value); + if (drawable == NULL || gimage != drawable_gimage (drawable)) + success = FALSE; + } + /* fade out */ + if (success) + { + fp_value = args[2].value.pdb_float; + if (fp_value >= 0.0) + non_gui_fade_out = fp_value; + else + success = FALSE; + } + /* num strokes */ + if (success) + { + int_value = args[3].value.pdb_int; + if (int_value > 0) + num_strokes = int_value / 2; + else + success = FALSE; + } + + /* point array */ + if (success) + stroke_array = (double *) args[4].value.pdb_pointer; + + if (success) + /* init the paint core */ + success = paint_core_init (&non_gui_paint_core, drawable, + stroke_array[0], stroke_array[1]); + + if (success) + { + non_gui_incremental = args[5].value.pdb_int; /* set the paint core's paint func */ non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func; diff --git a/app/paintbrush.h b/app/paintbrush.h index bf63b8bb2e..fc5138b93d 100644 --- a/app/paintbrush.h +++ b/app/paintbrush.h @@ -28,5 +28,6 @@ void tools_free_paintbrush (Tool *); /* Procedure definition and marshalling function */ extern ProcRecord paintbrush_proc; +extern ProcRecord paintbrush_extended_proc; #endif /* __PAINTBRUSH_H__ */ diff --git a/app/plug-in/gimpplugin-message.c b/app/plug-in/gimpplugin-message.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug-in/gimpplugin-message.c +++ b/app/plug-in/gimpplugin-message.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/plug-in/gimpplugin-progress.c b/app/plug-in/gimpplugin-progress.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug-in/gimpplugin-progress.c +++ b/app/plug-in/gimpplugin-progress.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/plug-in/gimpplugin.c b/app/plug-in/gimpplugin.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug-in/gimpplugin.c +++ b/app/plug-in/gimpplugin.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/plug-in/gimppluginmanager-call.c b/app/plug-in/gimppluginmanager-call.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug-in/gimppluginmanager-call.c +++ b/app/plug-in/gimppluginmanager-call.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/plug-in/gimppluginmanager-run.c b/app/plug-in/gimppluginmanager-run.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug-in/gimppluginmanager-run.c +++ b/app/plug-in/gimppluginmanager-run.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/plug-in/gimppluginmanager.c b/app/plug-in/gimppluginmanager.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug-in/gimppluginmanager.c +++ b/app/plug-in/gimppluginmanager.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/plug-in/gimppluginshm.c b/app/plug-in/gimppluginshm.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug-in/gimppluginshm.c +++ b/app/plug-in/gimppluginshm.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/plug-in/plug-in-def.c b/app/plug-in/plug-in-def.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug-in/plug-in-def.c +++ b/app/plug-in/plug-in-def.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/plug-in/plug-in-message.c b/app/plug-in/plug-in-message.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug-in/plug-in-message.c +++ b/app/plug-in/plug-in-message.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/plug-in/plug-in-params.c b/app/plug-in/plug-in-params.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug-in/plug-in-params.c +++ b/app/plug-in/plug-in-params.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/plug-in/plug-in-progress.c b/app/plug-in/plug-in-progress.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug-in/plug-in-progress.c +++ b/app/plug-in/plug-in-progress.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/plug-in/plug-in-run.c b/app/plug-in/plug-in-run.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug-in/plug-in-run.c +++ b/app/plug-in/plug-in-run.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/plug-in/plug-in-shm.c b/app/plug-in/plug-in-shm.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug-in/plug-in-shm.c +++ b/app/plug-in/plug-in-shm.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/plug-in/plug-in.c b/app/plug-in/plug-in.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug-in/plug-in.c +++ b/app/plug-in/plug-in.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/plug-in/plug-ins.c b/app/plug-in/plug-ins.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug-in/plug-ins.c +++ b/app/plug-in/plug-ins.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/plug_in.c b/app/plug_in.c index e4638e0bc5..f473508ad8 100644 --- a/app/plug_in.c +++ b/app/plug_in.c @@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) break; case PDB_TEMPORARY: - prog = g_strdup ("none"); + prog = "none"; tmp = current_plug_in->temp_proc_defs; break; @@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install) /* If there is a menu path specified, create a menu entry */ if (proc_install->menu_path) { - entry.path = g_strdup (proc_install->menu_path); + entry.path = proc_install->menu_path; entry.accelerator = NULL; entry.callback = plug_in_callback; entry.callback_data = proc; diff --git a/app/tools/eraser.c b/app/tools/eraser.c index 50b5ae9823..c529eb37c5 100644 --- a/app/tools/eraser.c +++ b/app/tools/eraser.c @@ -29,11 +29,81 @@ #include "tools.h" /* forward function declarations */ -static void eraser_motion (PaintCore *, GimpDrawable *); +static void eraser_motion (PaintCore *, GimpDrawable *, gboolean, gboolean); static Argument * eraser_invoker (Argument *); +static Argument * eraser_extended_invoker (Argument *); -static void * eraser_options = NULL; +static gboolean non_gui_hard, non_gui_incremental; + +typedef struct _EraserOptions EraserOptions; +struct _EraserOptions +{ + gboolean hard; + gboolean incremental; +}; + +static EraserOptions *eraser_options = NULL; + +static void +eraser_toggle_update (GtkWidget *w, + gpointer data) +{ + gboolean *toggle_val; + + toggle_val = (gboolean *) data; + + if (GTK_TOGGLE_BUTTON (w)->active) + *toggle_val = TRUE; + else + *toggle_val = FALSE; +} + +static EraserOptions * +create_eraser_options (void) +{ + EraserOptions *options; + GtkWidget *vbox; + GtkWidget *label; + GtkWidget *hard_toggle; + GtkWidget *incremental_toggle; + + options = (EraserOptions *) g_malloc (sizeof (EraserOptions)); + options->hard = FALSE; + options->incremental = FALSE; + + /* the main vbox */ + vbox = gtk_vbox_new (FALSE, 1); + + /* the main label */ + label = gtk_label_new ("Eraser Options"); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + /* the hard toggle */ + hard_toggle = gtk_check_button_new_with_label ("Hard edge"); + gtk_box_pack_start (GTK_BOX (vbox), hard_toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (hard_toggle), "toggled", + (GtkSignalFunc) eraser_toggle_update, + &options->hard); + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (hard_toggle), options->hard); + gtk_widget_show (hard_toggle); + + /* the incremental toggle */ + incremental_toggle = gtk_check_button_new_with_label ("Incremental"); + gtk_box_pack_start (GTK_BOX (vbox), incremental_toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (incremental_toggle), "toggled", + (GtkSignalFunc) eraser_toggle_update, + &options->incremental); + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (incremental_toggle), options->incremental); + gtk_widget_show (incremental_toggle); + + /* Register this eraser options widget with the main tools options dialog */ + tools_register_options (ERASER, vbox); + + return options; +} + void * eraser_paint_func (paint_core, drawable, state) PaintCore *paint_core; @@ -46,7 +116,7 @@ eraser_paint_func (paint_core, drawable, state) break; case MOTION_PAINT : - eraser_motion (paint_core, drawable); + eraser_motion (paint_core, drawable, eraser_options->hard, eraser_options->incremental); break; case FINISH_PAINT : @@ -67,7 +137,7 @@ tools_new_eraser () PaintCore * private; if (! eraser_options) - eraser_options = tools_register_no_options (ERASER, "Eraser Options"); + eraser_options = create_eraser_options (); tool = paint_core_new (ERASER); @@ -87,9 +157,11 @@ tools_free_eraser (tool) void -eraser_motion (paint_core, drawable) +eraser_motion (paint_core, drawable, hard, incremental) PaintCore *paint_core; GimpDrawable *drawable; + gboolean hard; + gboolean incremental; { GImage *gimage; TempBuf * area; @@ -114,20 +186,48 @@ eraser_motion (paint_core, drawable) /* paste the newly painted canvas to the gimage which is being worked on */ paint_core_paste_canvas (paint_core, drawable, OPAQUE_OPACITY, (int) (get_brush_opacity () * 255), - ERASE_MODE, SOFT, CONSTANT); + ERASE_MODE, hard? HARD : SOFT, incremental ? INCREMENTAL : CONSTANT); } static void * eraser_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, int state) { - eraser_motion (paint_core, drawable); + eraser_motion (paint_core, drawable, non_gui_hard, non_gui_incremental); return NULL; } /* The eraser procedure definition */ +ProcArg eraser_extended_args[] = +{ + { PDB_IMAGE, + "image", + "the image" + }, + { PDB_DRAWABLE, + "drawable", + "the drawable" + }, + { PDB_INT32, + "num_strokes", + "number of stroke control points (count each coordinate as 2 points)" + }, + { PDB_FLOATARRAY, + "strokes", + "array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}" + }, + { PDB_INT32, + "hardness", + "SOFT(0) or HARD(1)" + }, + { PDB_INT32, + "method", + "CONTINUOUS(0) or INCREMENTAL(1)" + } +}; + ProcArg eraser_args[] = { { PDB_IMAGE, @@ -171,6 +271,27 @@ ProcRecord eraser_proc = { { eraser_invoker } }, }; +ProcRecord eraser_extended_proc = +{ + "gimp_eraser_extended", + "Erase using the current brush", + "This tool erases using the current brush mask. If the specified drawable contains an alpha channel, then the erased pixels will become transparent. Otherwise, the eraser tool replaces the contents of the drawable with the background color. Like paintbrush, this tool linearly interpolates between the specified stroke coordinates.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + PDB_INTERNAL, + + /* Input arguments */ + 6, + eraser_extended_args, + + /* Output arguments */ + 0, + NULL, + + /* Exec method */ + { { eraser_extended_invoker } }, +}; static Argument * eraser_invoker (args) @@ -221,6 +342,94 @@ eraser_invoker (args) success = paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1]); + if (success) + { + non_gui_hard=0; non_gui_incremental = 0; + /* set the paint core's paint func */ + non_gui_paint_core.paint_func = eraser_non_gui_paint_func; + + non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0]; + non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1]; + + if (num_strokes == 1) + eraser_non_gui_paint_func (&non_gui_paint_core, drawable, 0); + + for (i = 1; i < num_strokes; i++) + { + non_gui_paint_core.curx = stroke_array[i * 2 + 0]; + non_gui_paint_core.cury = stroke_array[i * 2 + 1]; + + paint_core_interpolate (&non_gui_paint_core, drawable); + + non_gui_paint_core.lastx = non_gui_paint_core.curx; + non_gui_paint_core.lasty = non_gui_paint_core.cury; + } + + /* finish the painting */ + paint_core_finish (&non_gui_paint_core, drawable, -1); + + /* cleanup */ + paint_core_cleanup (); + } + + return procedural_db_return_args (&eraser_proc, success); +} + +static Argument * +eraser_extended_invoker (args) + Argument *args; +{ + int success = TRUE; + GImage *gimage; + GimpDrawable *drawable; + int num_strokes; + double *stroke_array; + int int_value; + int i; + + drawable = NULL; + num_strokes = 0; + + /* the gimage */ + if (success) + { + int_value = args[0].value.pdb_int; + if (! (gimage = gimage_get_ID (int_value))) + success = FALSE; + } + /* the drawable */ + if (success) + { + int_value = args[1].value.pdb_int; + drawable = drawable_get_ID (int_value); + if (drawable == NULL || gimage != drawable_gimage (drawable)) + success = FALSE; + } + /* num strokes */ + if (success) + { + int_value = args[2].value.pdb_int; + if (int_value > 0) + num_strokes = int_value / 2; + else + success = FALSE; + } + + /* point array */ + if (success) + stroke_array = (double *) args[3].value.pdb_pointer; + + if (success) + /* init the paint core */ + success = paint_core_init (&non_gui_paint_core, drawable, + stroke_array[0], stroke_array[1]); + + if (success) + { + non_gui_hard = args[4].value.pdb_int; + non_gui_incremental = args[5].value.pdb_int; + } + if (success) { /* set the paint core's paint func */ diff --git a/app/tools/eraser.h b/app/tools/eraser.h index 4c1bd031a9..9b57d7bad2 100644 --- a/app/tools/eraser.h +++ b/app/tools/eraser.h @@ -28,5 +28,6 @@ void tools_free_eraser (Tool *); /* Procedure definition and marshalling function */ extern ProcRecord eraser_proc; +extern ProcRecord eraser_extended_proc; #endif /* __ERASER_H__ */ diff --git a/app/tools/gimperasertool.c b/app/tools/gimperasertool.c index 50b5ae9823..c529eb37c5 100644 --- a/app/tools/gimperasertool.c +++ b/app/tools/gimperasertool.c @@ -29,11 +29,81 @@ #include "tools.h" /* forward function declarations */ -static void eraser_motion (PaintCore *, GimpDrawable *); +static void eraser_motion (PaintCore *, GimpDrawable *, gboolean, gboolean); static Argument * eraser_invoker (Argument *); +static Argument * eraser_extended_invoker (Argument *); -static void * eraser_options = NULL; +static gboolean non_gui_hard, non_gui_incremental; + +typedef struct _EraserOptions EraserOptions; +struct _EraserOptions +{ + gboolean hard; + gboolean incremental; +}; + +static EraserOptions *eraser_options = NULL; + +static void +eraser_toggle_update (GtkWidget *w, + gpointer data) +{ + gboolean *toggle_val; + + toggle_val = (gboolean *) data; + + if (GTK_TOGGLE_BUTTON (w)->active) + *toggle_val = TRUE; + else + *toggle_val = FALSE; +} + +static EraserOptions * +create_eraser_options (void) +{ + EraserOptions *options; + GtkWidget *vbox; + GtkWidget *label; + GtkWidget *hard_toggle; + GtkWidget *incremental_toggle; + + options = (EraserOptions *) g_malloc (sizeof (EraserOptions)); + options->hard = FALSE; + options->incremental = FALSE; + + /* the main vbox */ + vbox = gtk_vbox_new (FALSE, 1); + + /* the main label */ + label = gtk_label_new ("Eraser Options"); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + /* the hard toggle */ + hard_toggle = gtk_check_button_new_with_label ("Hard edge"); + gtk_box_pack_start (GTK_BOX (vbox), hard_toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (hard_toggle), "toggled", + (GtkSignalFunc) eraser_toggle_update, + &options->hard); + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (hard_toggle), options->hard); + gtk_widget_show (hard_toggle); + + /* the incremental toggle */ + incremental_toggle = gtk_check_button_new_with_label ("Incremental"); + gtk_box_pack_start (GTK_BOX (vbox), incremental_toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (incremental_toggle), "toggled", + (GtkSignalFunc) eraser_toggle_update, + &options->incremental); + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (incremental_toggle), options->incremental); + gtk_widget_show (incremental_toggle); + + /* Register this eraser options widget with the main tools options dialog */ + tools_register_options (ERASER, vbox); + + return options; +} + void * eraser_paint_func (paint_core, drawable, state) PaintCore *paint_core; @@ -46,7 +116,7 @@ eraser_paint_func (paint_core, drawable, state) break; case MOTION_PAINT : - eraser_motion (paint_core, drawable); + eraser_motion (paint_core, drawable, eraser_options->hard, eraser_options->incremental); break; case FINISH_PAINT : @@ -67,7 +137,7 @@ tools_new_eraser () PaintCore * private; if (! eraser_options) - eraser_options = tools_register_no_options (ERASER, "Eraser Options"); + eraser_options = create_eraser_options (); tool = paint_core_new (ERASER); @@ -87,9 +157,11 @@ tools_free_eraser (tool) void -eraser_motion (paint_core, drawable) +eraser_motion (paint_core, drawable, hard, incremental) PaintCore *paint_core; GimpDrawable *drawable; + gboolean hard; + gboolean incremental; { GImage *gimage; TempBuf * area; @@ -114,20 +186,48 @@ eraser_motion (paint_core, drawable) /* paste the newly painted canvas to the gimage which is being worked on */ paint_core_paste_canvas (paint_core, drawable, OPAQUE_OPACITY, (int) (get_brush_opacity () * 255), - ERASE_MODE, SOFT, CONSTANT); + ERASE_MODE, hard? HARD : SOFT, incremental ? INCREMENTAL : CONSTANT); } static void * eraser_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, int state) { - eraser_motion (paint_core, drawable); + eraser_motion (paint_core, drawable, non_gui_hard, non_gui_incremental); return NULL; } /* The eraser procedure definition */ +ProcArg eraser_extended_args[] = +{ + { PDB_IMAGE, + "image", + "the image" + }, + { PDB_DRAWABLE, + "drawable", + "the drawable" + }, + { PDB_INT32, + "num_strokes", + "number of stroke control points (count each coordinate as 2 points)" + }, + { PDB_FLOATARRAY, + "strokes", + "array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}" + }, + { PDB_INT32, + "hardness", + "SOFT(0) or HARD(1)" + }, + { PDB_INT32, + "method", + "CONTINUOUS(0) or INCREMENTAL(1)" + } +}; + ProcArg eraser_args[] = { { PDB_IMAGE, @@ -171,6 +271,27 @@ ProcRecord eraser_proc = { { eraser_invoker } }, }; +ProcRecord eraser_extended_proc = +{ + "gimp_eraser_extended", + "Erase using the current brush", + "This tool erases using the current brush mask. If the specified drawable contains an alpha channel, then the erased pixels will become transparent. Otherwise, the eraser tool replaces the contents of the drawable with the background color. Like paintbrush, this tool linearly interpolates between the specified stroke coordinates.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + PDB_INTERNAL, + + /* Input arguments */ + 6, + eraser_extended_args, + + /* Output arguments */ + 0, + NULL, + + /* Exec method */ + { { eraser_extended_invoker } }, +}; static Argument * eraser_invoker (args) @@ -221,6 +342,94 @@ eraser_invoker (args) success = paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1]); + if (success) + { + non_gui_hard=0; non_gui_incremental = 0; + /* set the paint core's paint func */ + non_gui_paint_core.paint_func = eraser_non_gui_paint_func; + + non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0]; + non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1]; + + if (num_strokes == 1) + eraser_non_gui_paint_func (&non_gui_paint_core, drawable, 0); + + for (i = 1; i < num_strokes; i++) + { + non_gui_paint_core.curx = stroke_array[i * 2 + 0]; + non_gui_paint_core.cury = stroke_array[i * 2 + 1]; + + paint_core_interpolate (&non_gui_paint_core, drawable); + + non_gui_paint_core.lastx = non_gui_paint_core.curx; + non_gui_paint_core.lasty = non_gui_paint_core.cury; + } + + /* finish the painting */ + paint_core_finish (&non_gui_paint_core, drawable, -1); + + /* cleanup */ + paint_core_cleanup (); + } + + return procedural_db_return_args (&eraser_proc, success); +} + +static Argument * +eraser_extended_invoker (args) + Argument *args; +{ + int success = TRUE; + GImage *gimage; + GimpDrawable *drawable; + int num_strokes; + double *stroke_array; + int int_value; + int i; + + drawable = NULL; + num_strokes = 0; + + /* the gimage */ + if (success) + { + int_value = args[0].value.pdb_int; + if (! (gimage = gimage_get_ID (int_value))) + success = FALSE; + } + /* the drawable */ + if (success) + { + int_value = args[1].value.pdb_int; + drawable = drawable_get_ID (int_value); + if (drawable == NULL || gimage != drawable_gimage (drawable)) + success = FALSE; + } + /* num strokes */ + if (success) + { + int_value = args[2].value.pdb_int; + if (int_value > 0) + num_strokes = int_value / 2; + else + success = FALSE; + } + + /* point array */ + if (success) + stroke_array = (double *) args[3].value.pdb_pointer; + + if (success) + /* init the paint core */ + success = paint_core_init (&non_gui_paint_core, drawable, + stroke_array[0], stroke_array[1]); + + if (success) + { + non_gui_hard = args[4].value.pdb_int; + non_gui_incremental = args[5].value.pdb_int; + } + if (success) { /* set the paint core's paint func */ diff --git a/app/tools/gimperasertool.h b/app/tools/gimperasertool.h index 4c1bd031a9..9b57d7bad2 100644 --- a/app/tools/gimperasertool.h +++ b/app/tools/gimperasertool.h @@ -28,5 +28,6 @@ void tools_free_eraser (Tool *); /* Procedure definition and marshalling function */ extern ProcRecord eraser_proc; +extern ProcRecord eraser_extended_proc; #endif /* __ERASER_H__ */ diff --git a/app/tools/paintbrush.c b/app/tools/paintbrush.c index 8815b7958f..c82fe77afe 100644 --- a/app/tools/paintbrush.c +++ b/app/tools/paintbrush.c @@ -30,10 +30,11 @@ #include "tools.h" /* forward function declarations */ -static void paintbrush_motion (PaintCore *, GimpDrawable *, double); +static void paintbrush_motion (PaintCore *, GimpDrawable *, double, gboolean); static Argument * paintbrush_invoker (Argument *); +static Argument * paintbrush_extended_invoker (Argument *); -static double non_gui_fade_out; +static double non_gui_fade_out, non_gui_incremental; /* defines */ @@ -43,12 +44,27 @@ typedef struct _PaintOptions PaintOptions; struct _PaintOptions { double fade_out; + gboolean incremental; }; /* local variables */ static PaintOptions *paint_options = NULL; +static void +paintbrush_toggle_update (GtkWidget *w, + gpointer data) +{ + gboolean *toggle_val; + + toggle_val = (gboolean *) data; + + if (GTK_TOGGLE_BUTTON (w)->active) + *toggle_val = TRUE; + else + *toggle_val = FALSE; +} + static void paintbrush_scale_update (GtkAdjustment *adjustment, double *scale_val) @@ -65,10 +81,12 @@ create_paint_options (void) GtkWidget *label; GtkWidget *fade_out_scale; GtkObject *fade_out_scale_data; + GtkWidget *incremental_toggle; /* the new options structure */ options = (PaintOptions *) g_malloc (sizeof (PaintOptions)); options->fade_out = 0.0; + options->incremental = FALSE; /* the main vbox */ vbox = gtk_vbox_new (FALSE, 1); @@ -97,6 +115,16 @@ create_paint_options (void) gtk_widget_show (fade_out_scale); gtk_widget_show (hbox); + + /* the incremental toggle */ + incremental_toggle = gtk_check_button_new_with_label ("Incremental"); + gtk_box_pack_start (GTK_BOX (vbox), incremental_toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (incremental_toggle), "toggled", + (GtkSignalFunc) paintbrush_toggle_update, + &options->incremental); + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (incremental_toggle), options->incremental); + gtk_widget_show (incremental_toggle); + /* Register this selection options widget with the main tools options dialog */ tools_register_options (PAINTBRUSH, vbox); @@ -114,7 +142,7 @@ paintbrush_paint_func (PaintCore *paint_core, break; case MOTION_PAINT : - paintbrush_motion (paint_core, drawable, paint_options->fade_out); + paintbrush_motion (paint_core, drawable, paint_options->fade_out, paint_options->incremental); break; case FINISH_PAINT : @@ -156,7 +184,8 @@ tools_free_paintbrush (Tool *tool) void paintbrush_motion (PaintCore *paint_core, GimpDrawable *drawable, - double fade_out) + double fade_out, + gboolean incremental) { GImage *gimage; TempBuf * area; @@ -195,7 +224,8 @@ paintbrush_motion (PaintCore *paint_core, /* paste the newly painted canvas to the gimage which is being worked on */ paint_core_paste_canvas (paint_core, drawable, blend, (int) (get_brush_opacity () * 255), - get_brush_paint_mode (), SOFT, CONSTANT); + get_brush_paint_mode (), SOFT, + incremental ? INCREMENTAL : CONSTANT); } } @@ -204,8 +234,8 @@ static void * paintbrush_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, int state) -{ - paintbrush_motion (paint_core, drawable, non_gui_fade_out); +{ + paintbrush_motion (paint_core, drawable, non_gui_fade_out, non_gui_incremental); return NULL; } @@ -236,6 +266,34 @@ ProcArg paintbrush_args[] = } }; +ProcArg paintbrush_extended_args[] = +{ + { PDB_IMAGE, + "image", + "the image" + }, + { PDB_DRAWABLE, + "drawable", + "the drawable" + }, + { PDB_FLOAT, + "fade_out", + "fade out parameter: fade_out > 0" + }, + { PDB_INT32, + "num_strokes", + "number of stroke control points (count each coordinate as 2 points)" + }, + { PDB_FLOATARRAY, + "strokes", + "array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}" + }, + { PDB_INT32, + "method", + "CONTINUOUS(0) or INCREMENTAL(1)" + } +}; + ProcRecord paintbrush_proc = { @@ -259,6 +317,28 @@ ProcRecord paintbrush_proc = { { paintbrush_invoker } }, }; +ProcRecord paintbrush_extended_proc = +{ + "gimp_paintbrush_exteneded", + "Paint in the current brush with optional fade out parameter", + "This tool is the standard paintbrush. It draws linearly interpolated lines through the specified stroke coordinates. It operates on the specified drawable in the foreground color with the active brush. The \"fade_out\" parameter is measured in pixels and allows the brush stroke to linearly fall off. The pressure is set to the maximum at the beginning of the stroke. As the distance of the stroke nears the fade_out value, the pressure will approach zero.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + PDB_INTERNAL, + + /* Input arguments */ + 6, + paintbrush_extended_args, + + /* Output arguments */ + 0, + NULL, + + /* Exec method */ + { { paintbrush_extended_invoker } }, +}; + static Argument * paintbrush_invoker (Argument *args) { @@ -319,6 +399,97 @@ paintbrush_invoker (Argument *args) if (success) { + non_gui_incremental = 0; + /* set the paint core's paint func */ + non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func; + + non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0]; + non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1]; + + if (num_strokes == 1) + paintbrush_non_gui_paint_func (&non_gui_paint_core, drawable, 0); + + for (i = 1; i < num_strokes; i++) + { + non_gui_paint_core.curx = stroke_array[i * 2 + 0]; + non_gui_paint_core.cury = stroke_array[i * 2 + 1]; + + paint_core_interpolate (&non_gui_paint_core, drawable); + + non_gui_paint_core.lastx = non_gui_paint_core.curx; + non_gui_paint_core.lasty = non_gui_paint_core.cury; + } + + /* finish the painting */ + paint_core_finish (&non_gui_paint_core, drawable, -1); + + /* cleanup */ + paint_core_cleanup (); + } + + return procedural_db_return_args (&paintbrush_proc, success); +} +static Argument * +paintbrush_extended_invoker (Argument *args) +{ + int success = TRUE; + GImage *gimage; + GimpDrawable *drawable; + int num_strokes; + double *stroke_array; + int int_value; + double fp_value; + int i; + + drawable = NULL; + num_strokes = 0; + + /* the gimage */ + if (success) + { + int_value = args[0].value.pdb_int; + if (! (gimage = gimage_get_ID (int_value))) + success = FALSE; + } + /* the drawable */ + if (success) + { + int_value = args[1].value.pdb_int; + drawable = drawable_get_ID (int_value); + if (drawable == NULL || gimage != drawable_gimage (drawable)) + success = FALSE; + } + /* fade out */ + if (success) + { + fp_value = args[2].value.pdb_float; + if (fp_value >= 0.0) + non_gui_fade_out = fp_value; + else + success = FALSE; + } + /* num strokes */ + if (success) + { + int_value = args[3].value.pdb_int; + if (int_value > 0) + num_strokes = int_value / 2; + else + success = FALSE; + } + + /* point array */ + if (success) + stroke_array = (double *) args[4].value.pdb_pointer; + + if (success) + /* init the paint core */ + success = paint_core_init (&non_gui_paint_core, drawable, + stroke_array[0], stroke_array[1]); + + if (success) + { + non_gui_incremental = args[5].value.pdb_int; /* set the paint core's paint func */ non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func; diff --git a/app/tools/paintbrush.h b/app/tools/paintbrush.h index bf63b8bb2e..fc5138b93d 100644 --- a/app/tools/paintbrush.h +++ b/app/tools/paintbrush.h @@ -28,5 +28,6 @@ void tools_free_paintbrush (Tool *); /* Procedure definition and marshalling function */ extern ProcRecord paintbrush_proc; +extern ProcRecord paintbrush_extended_proc; #endif /* __PAINTBRUSH_H__ */ diff --git a/configure.in b/configure.in index 10675f5640..d5ee84d444 100644 --- a/configure.in +++ b/configure.in @@ -121,7 +121,7 @@ fi dnl Test for Xmu if test -z "$LIBXMU_LIB"; then AC_CHECK_LIB(Xmu, XmuClientWindow, - WEBBROWSER="webbrowser"; LIBXMU_LIB='-lXmu -lSM -lICE', + WEBBROWSER="webbrowser"; LIBXMU_LIB='-lXmu -lXt -lSM -lICE', AC_MSG_WARN(*** webbrowser plug-in will not be built ***), -lXt -lSM -lICE) fi diff --git a/libgimp/gimp.c b/libgimp/gimp.c index bda9f753c0..ffa7369ded 100644 --- a/libgimp/gimp.c +++ b/libgimp/gimp.c @@ -677,6 +677,7 @@ gimp_run_procedure (char *name, } g_free (proc_run.params); + g_free (proc_return->name); g_free (proc_return); return return_vals; diff --git a/libgimp/gimpprotocol.c b/libgimp/gimpprotocol.c index fb07036043..b707f2cef0 100644 --- a/libgimp/gimpprotocol.c +++ b/libgimp/gimpprotocol.c @@ -504,7 +504,10 @@ _gp_proc_run_read (int fd, WireMessage *msg) proc_run = g_new (GPProcRun, 1); if (!wire_read_string (fd, &proc_run->name, 1)) - return; + { + g_free (proc_run); + return; + } _gp_params_read (fd, &proc_run->params, (guint*) &proc_run->nparams); msg->data = proc_run; @@ -529,6 +532,7 @@ _gp_proc_run_destroy (WireMessage *msg) proc_run = msg->data; _gp_params_destroy (proc_run->params, proc_run->nparams); + g_free (proc_run->name); g_free (proc_run); } @@ -743,6 +747,8 @@ _gp_proc_install_destroy (WireMessage *msg) g_free (proc_install->return_vals[i].description); } + g_free (proc_install->params); + g_free (proc_install->return_vals); g_free (proc_install); } diff --git a/libgimp/gimptile.c b/libgimp/gimptile.c index 8c7ae9bda6..c8180a2a31 100644 --- a/libgimp/gimptile.c +++ b/libgimp/gimptile.c @@ -184,6 +184,8 @@ gimp_tile_get (GTile *tile) if (!gp_tile_ack_write (_writefd)) gimp_quit (); + + wire_destroy (&msg); } static void @@ -240,6 +242,8 @@ gimp_tile_put (GTile *tile) g_warning ("unexpected message: %d\n", msg.type); gimp_quit (); } + + wire_destroy (&msg); } /* This function is nearly identical to the function 'tile_cache_insert' diff --git a/libgimp/gimpwire.c b/libgimp/gimpwire.c index 57a69f3704..b047efdec9 100644 --- a/libgimp/gimpwire.c +++ b/libgimp/gimpwire.c @@ -334,7 +334,10 @@ wire_read_string (int fd, { data[i] = g_new (gchar, tmp); if (!wire_read_int8 (fd, (guint8*) data[i], tmp)) - return FALSE; + { + g_free (data[i]); + return FALSE; + } } else { diff --git a/libgimpbase/gimpprotocol.c b/libgimpbase/gimpprotocol.c index fb07036043..b707f2cef0 100644 --- a/libgimpbase/gimpprotocol.c +++ b/libgimpbase/gimpprotocol.c @@ -504,7 +504,10 @@ _gp_proc_run_read (int fd, WireMessage *msg) proc_run = g_new (GPProcRun, 1); if (!wire_read_string (fd, &proc_run->name, 1)) - return; + { + g_free (proc_run); + return; + } _gp_params_read (fd, &proc_run->params, (guint*) &proc_run->nparams); msg->data = proc_run; @@ -529,6 +532,7 @@ _gp_proc_run_destroy (WireMessage *msg) proc_run = msg->data; _gp_params_destroy (proc_run->params, proc_run->nparams); + g_free (proc_run->name); g_free (proc_run); } @@ -743,6 +747,8 @@ _gp_proc_install_destroy (WireMessage *msg) g_free (proc_install->return_vals[i].description); } + g_free (proc_install->params); + g_free (proc_install->return_vals); g_free (proc_install); } diff --git a/libgimpbase/gimpwire.c b/libgimpbase/gimpwire.c index 57a69f3704..b047efdec9 100644 --- a/libgimpbase/gimpwire.c +++ b/libgimpbase/gimpwire.c @@ -334,7 +334,10 @@ wire_read_string (int fd, { data[i] = g_new (gchar, tmp); if (!wire_read_int8 (fd, (guint8*) data[i], tmp)) - return FALSE; + { + g_free (data[i]); + return FALSE; + } } else { diff --git a/plug-ins/ifscompose/ifscompose.c b/plug-ins/ifscompose/ifscompose.c index 077fc41009..d5dc5321ec 100644 --- a/plug-ins/ifscompose/ifscompose.c +++ b/plug-ins/ifscompose/ifscompose.c @@ -1103,7 +1103,7 @@ design_op_menu_create(GtkWidget *window) GtkAcceleratorTable *accelerator_table; ifsDesign->op_menu = gtk_menu_new(); - gtk_object_ref (ifsDesign->op_menu); + gtk_object_ref (GTK_OBJECT (ifsDesign->op_menu)); gtk_object_sink (GTK_OBJECT (ifsDesign->op_menu)); accelerator_table = gtk_accelerator_table_new(); @@ -1572,7 +1572,7 @@ design_area_configure(GtkWidget *widget, GdkEventConfigure *event) ifsDesign->pixmap = gdk_pixmap_new(widget->window, widget->allocation.width, widget->allocation.height, - -1); + gtk_preview_get_visual()->depth); return FALSE; }