From a2bd2ac28cc10e355a15ebfd1e3cd2f774be116d Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 26 Feb 2002 02:00:02 +0000 Subject: [PATCH] Added some kind of paint core registry. It's ugly and will change... 2002-02-26 Michael Natterer Added some kind of paint core registry. It's ugly and will change... * app/core/gimp.c: call paint_init() and paint_exit(). * app/core/gimptoolinfo.[ch]: added "gchar *paint_core_name" to the GimpToolInfo structure and the contstructor. * app/tools/tool_manager.c: pass the class names of the GimpPaintCore subclasses to gimp_tool_info_new(). * app/paint/Makefile.am * app/paint/paint.[ch]: new files. Simlply ref/unref all paint core classes so we can find them using g_type_from_name(). * app/paint/gimppaintcore-stroke.[ch]: changed to take an array of GimpCoords, not just gdouble. * tools/pdbgen/pdb/paint_tools.pdb: convert the stroke array here. * app/gui/vectors-commands.c: ad-hoc implementation of vectors stroking. Double click now sets the active vectors in the vectors tool. * app/pdb/paint_tools_cmds.c: regenerated. --- ChangeLog | 27 +++++++++ app/actions/vectors-commands.c | 101 +++++++++++++++++++++++++++++-- app/core/gimp.c | 7 ++- app/core/gimptoolinfo.c | 52 +++++++++------- app/core/gimptoolinfo.h | 2 + app/gui/vectors-commands.c | 101 +++++++++++++++++++++++++++++-- app/paint/Makefile.am | 2 + app/paint/gimppaintcore-stroke.c | 26 +++----- app/paint/gimppaintcore-stroke.h | 4 +- app/paint/paint.c | 60 ++++++++++++++++++ app/paint/paint.h | 27 +++++++++ app/pdb/paint_tools_cmds.c | 18 +++++- app/tools/tool_manager.c | 33 +++++++--- tools/pdbgen/pdb/paint_tools.pdb | 18 +++++- 14 files changed, 414 insertions(+), 64 deletions(-) create mode 100644 app/paint/paint.c create mode 100644 app/paint/paint.h diff --git a/ChangeLog b/ChangeLog index b9f9515e10..72552925ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2002-02-26 Michael Natterer + + Added some kind of paint core registry. It's ugly and will change... + + * app/core/gimp.c: call paint_init() and paint_exit(). + + * app/core/gimptoolinfo.[ch]: added "gchar *paint_core_name" to + the GimpToolInfo structure and the contstructor. + + * app/tools/tool_manager.c: pass the class names of the + GimpPaintCore subclasses to gimp_tool_info_new(). + + * app/paint/Makefile.am + * app/paint/paint.[ch]: new files. Simlply ref/unref all paint + core classes so we can find them using g_type_from_name(). + + * app/paint/gimppaintcore-stroke.[ch]: changed to take an array + of GimpCoords, not just gdouble. + + * tools/pdbgen/pdb/paint_tools.pdb: convert the stroke array here. + + * app/gui/vectors-commands.c: ad-hoc implementation of vectors + stroking. Double click now sets the active vectors in the vectors + tool. + + * app/pdb/paint_tools_cmds.c: regenerated. + 2002-02-26 Sven Neumann * app/gui/tips-parser.c: some documentation can't hurt. diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c index f915707e31..3fe23647a1 100644 --- a/app/actions/vectors-commands.c +++ b/app/actions/vectors-commands.c @@ -26,10 +26,16 @@ #include "core/gimp.h" #include "core/gimpchannel.h" +#include "core/gimpcontext.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "core/gimplist.h" +#include "core/gimptoolinfo.h" +#include "paint/gimppaintcore.h" +#include "paint/gimppaintcore-stroke.h" + +#include "vectors/gimpstroke.h" #include "vectors/gimpvectors.h" #include "display/gimpdisplay-foreach.h" @@ -37,6 +43,9 @@ #include "widgets/gimpitemfactory.h" #include "widgets/gimpwidgets-utils.h" +#include "tools/gimpvectortool.h" +#include "tools/tool_manager.h" + #include "vectors-commands.h" #include "undo.h" @@ -307,18 +316,78 @@ void vectors_stroke_vectors_cmd_callback (GtkWidget *widget, gpointer data) { - GimpImage *gimage; - GimpVectors *active_vectors; + GimpImage *gimage; + GimpVectors *active_vectors; + GimpDrawable *active_drawable; gimage = (GimpImage *) gimp_widget_get_callback_context (widget); if (! gimage) return; - active_vectors = gimp_image_get_active_vectors (gimage); + active_vectors = gimp_image_get_active_vectors (gimage); + active_drawable = gimp_image_active_drawable (gimage); - if (active_vectors) + if (! active_drawable) { + g_message (_("There is no active Layer or Channel to stroke to")); + return; + } + + if (active_vectors && active_vectors->strokes) + { + GimpPaintCore *core; + GType core_type; + GimpToolInfo *tool_info; + GimpPaintOptions *paint_options; + GimpDisplay *gdisp; + GimpStroke *stroke; + + tool_info = (GimpToolInfo *) + gimp_container_get_child_by_name (gimage->gimp->tool_info_list, + "gimp:paintbrush_tool"); + + paint_options = (GimpPaintOptions *) tool_info->tool_options; + + core_type = g_type_from_name (tool_info->paint_core_name); + + core = g_object_new (g_type_from_name (tool_info->paint_core_name), NULL); + + gdisp = gimp_context_get_display (gimp_get_current_context (gimage->gimp)); + + tool_manager_control_active (gimage->gimp, PAUSE, gdisp); + + undo_push_group_start (gimage, PAINT_UNDO_GROUP); + + for (stroke = active_vectors->strokes; stroke; stroke = stroke->next) + { + GimpCoords *coords; + gint n_coords; + gboolean closed; + + coords = gimp_stroke_interpolate (stroke, 1.0, + &n_coords, + &closed); + + if (coords) + { + gimp_paint_core_stroke (core, + active_drawable, + paint_options, + coords, + n_coords); + + g_free (coords); + } + } + + undo_push_group_end (gimage); + + tool_manager_control_active (gimage->gimp, RESUME, gdisp); + + g_object_unref (G_OBJECT (core)); + + gdisplays_flush (); } } @@ -529,6 +598,30 @@ vectors_edit_vectors_query (GimpVectors *vectors) GtkWidget *table; GtkWidget *label; + { + Gimp *gimp; + GimpTool *active_tool; + + gimp = GIMP_ITEM (vectors)->gimage->gimp; + + active_tool = tool_manager_get_active (gimp); + + if (! GIMP_IS_VECTOR_TOOL (active_tool)) + { + GimpToolInfo *tool_info; + + tool_info = tool_manager_get_info_by_type (gimp, GIMP_TYPE_VECTOR_TOOL); + + gimp_context_set_tool (gimp_get_current_context (gimp), tool_info); + + active_tool = tool_manager_get_active (gimp); + } + + gimp_vectors_tool_set_vectors (GIMP_VECTOR_TOOL (active_tool), vectors); + + return; + } + options = g_new0 (EditVectorsOptions, 1); options->vectors = vectors; diff --git a/app/core/gimp.c b/app/core/gimp.c index d5d6ba7a22..ed65a85330 100644 --- a/app/core/gimp.c +++ b/app/core/gimp.c @@ -25,11 +25,12 @@ #include "libgimpbase/gimpbase.h" #include "core-types.h" -#include "pdb/pdb-types.h" #include "pdb/procedural_db.h" #include "pdb/internal_procs.h" +#include "paint/paint.h" + #include "xcf/xcf.h" #include "gimp.h" @@ -140,6 +141,8 @@ gimp_init (Gimp *gimp) gimp_parasites_init (gimp); + paint_init (gimp); + gimp_modules_init (gimp); gimp->images = gimp_list_new (GIMP_TYPE_IMAGE, @@ -320,6 +323,8 @@ gimp_finalize (GObject *object) if (gimp->modules) gimp_modules_exit (gimp); + paint_exit (gimp); + if (gimp->parasites) gimp_parasites_exit (gimp); diff --git a/app/core/gimptoolinfo.c b/app/core/gimptoolinfo.c index 52f69e4284..3293c1a27c 100644 --- a/app/core/gimptoolinfo.c +++ b/app/core/gimptoolinfo.c @@ -89,23 +89,26 @@ gimp_tool_info_class_init (GimpToolInfoClass *klass) static void gimp_tool_info_init (GimpToolInfo *tool_info) { - tool_info->tool_type = G_TYPE_NONE; + tool_info->tool_type = G_TYPE_NONE; - tool_info->blurb = NULL; - tool_info->help = NULL; + tool_info->blurb = NULL; + tool_info->help = NULL; - tool_info->menu_path = NULL; - tool_info->menu_accel = NULL; + tool_info->menu_path = NULL; + tool_info->menu_accel = NULL; - tool_info->help_domain = NULL; - tool_info->help_data = NULL; + tool_info->help_domain = NULL; + tool_info->help_data = NULL; - tool_info->stock_id = NULL; - tool_info->stock_pixbuf = NULL; + tool_info->pdb_string = NULL; + tool_info->paint_core_name = NULL; - tool_info->context = NULL; + tool_info->stock_id = NULL; + tool_info->stock_pixbuf = NULL; - tool_info->tool_options = NULL; + tool_info->context = NULL; + + tool_info->tool_options = NULL; } static void @@ -244,6 +247,7 @@ gimp_tool_info_new (Gimp *gimp, const gchar *help_domain, const gchar *help_data, const gchar *pdb_string, + const gchar *paint_core_name, const gchar *stock_id, GdkPixbuf *stock_pixbuf) { @@ -255,6 +259,8 @@ gimp_tool_info_new (Gimp *gimp, g_return_val_if_fail (blurb != NULL, NULL); g_return_val_if_fail (help != NULL, NULL); g_return_val_if_fail (menu_path != NULL, NULL); + g_return_val_if_fail (pdb_string != NULL, NULL); + g_return_val_if_fail (paint_core_name != NULL, NULL); g_return_val_if_fail (stock_id != NULL, NULL); g_return_val_if_fail (! stock_pixbuf || GDK_IS_PIXBUF (stock_pixbuf), NULL); @@ -269,23 +275,23 @@ gimp_tool_info_new (Gimp *gimp, context); } - tool_info->gimp = gimp; - tool_info->tool_type = tool_type; + tool_info->gimp = gimp; + tool_info->tool_type = tool_type; - tool_info->blurb = g_strdup (blurb); - tool_info->help = g_strdup (help); + tool_info->blurb = g_strdup (blurb); + tool_info->help = g_strdup (help); - tool_info->menu_path = g_strdup (menu_path); - tool_info->menu_accel = g_strdup (menu_accel); + tool_info->menu_path = g_strdup (menu_path); + tool_info->menu_accel = g_strdup (menu_accel); - tool_info->help_domain = g_strdup (help_domain); - tool_info->help_data = g_strdup (help_data); + tool_info->help_domain = g_strdup (help_domain); + tool_info->help_data = g_strdup (help_data); - tool_info->pdb_string = (pdb_string ? - g_strdup (pdb_string) : "gimp_paintbrush_default"); + tool_info->pdb_string = g_strdup (pdb_string); + tool_info->paint_core_name = g_strdup (paint_core_name); - tool_info->stock_id = stock_id; - tool_info->stock_pixbuf = stock_pixbuf; + tool_info->stock_id = stock_id; + tool_info->stock_pixbuf = stock_pixbuf; if (stock_pixbuf) g_object_ref (G_OBJECT (stock_pixbuf)); diff --git a/app/core/gimptoolinfo.h b/app/core/gimptoolinfo.h index 6918443e6d..eedc5fe30f 100644 --- a/app/core/gimptoolinfo.h +++ b/app/core/gimptoolinfo.h @@ -53,6 +53,7 @@ struct _GimpToolInfo gchar *help_data; gchar *pdb_string; + gchar *paint_core_name; const gchar *stock_id; GdkPixbuf *stock_pixbuf; @@ -82,6 +83,7 @@ GimpToolInfo * gimp_tool_info_new (Gimp *gimp, const gchar *help_domain, const gchar *help_data, const gchar *pdb_string, + const gchar *paint_core_name, const gchar *stock_id, GdkPixbuf *stock_pixbuf); diff --git a/app/gui/vectors-commands.c b/app/gui/vectors-commands.c index f915707e31..3fe23647a1 100644 --- a/app/gui/vectors-commands.c +++ b/app/gui/vectors-commands.c @@ -26,10 +26,16 @@ #include "core/gimp.h" #include "core/gimpchannel.h" +#include "core/gimpcontext.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "core/gimplist.h" +#include "core/gimptoolinfo.h" +#include "paint/gimppaintcore.h" +#include "paint/gimppaintcore-stroke.h" + +#include "vectors/gimpstroke.h" #include "vectors/gimpvectors.h" #include "display/gimpdisplay-foreach.h" @@ -37,6 +43,9 @@ #include "widgets/gimpitemfactory.h" #include "widgets/gimpwidgets-utils.h" +#include "tools/gimpvectortool.h" +#include "tools/tool_manager.h" + #include "vectors-commands.h" #include "undo.h" @@ -307,18 +316,78 @@ void vectors_stroke_vectors_cmd_callback (GtkWidget *widget, gpointer data) { - GimpImage *gimage; - GimpVectors *active_vectors; + GimpImage *gimage; + GimpVectors *active_vectors; + GimpDrawable *active_drawable; gimage = (GimpImage *) gimp_widget_get_callback_context (widget); if (! gimage) return; - active_vectors = gimp_image_get_active_vectors (gimage); + active_vectors = gimp_image_get_active_vectors (gimage); + active_drawable = gimp_image_active_drawable (gimage); - if (active_vectors) + if (! active_drawable) { + g_message (_("There is no active Layer or Channel to stroke to")); + return; + } + + if (active_vectors && active_vectors->strokes) + { + GimpPaintCore *core; + GType core_type; + GimpToolInfo *tool_info; + GimpPaintOptions *paint_options; + GimpDisplay *gdisp; + GimpStroke *stroke; + + tool_info = (GimpToolInfo *) + gimp_container_get_child_by_name (gimage->gimp->tool_info_list, + "gimp:paintbrush_tool"); + + paint_options = (GimpPaintOptions *) tool_info->tool_options; + + core_type = g_type_from_name (tool_info->paint_core_name); + + core = g_object_new (g_type_from_name (tool_info->paint_core_name), NULL); + + gdisp = gimp_context_get_display (gimp_get_current_context (gimage->gimp)); + + tool_manager_control_active (gimage->gimp, PAUSE, gdisp); + + undo_push_group_start (gimage, PAINT_UNDO_GROUP); + + for (stroke = active_vectors->strokes; stroke; stroke = stroke->next) + { + GimpCoords *coords; + gint n_coords; + gboolean closed; + + coords = gimp_stroke_interpolate (stroke, 1.0, + &n_coords, + &closed); + + if (coords) + { + gimp_paint_core_stroke (core, + active_drawable, + paint_options, + coords, + n_coords); + + g_free (coords); + } + } + + undo_push_group_end (gimage); + + tool_manager_control_active (gimage->gimp, RESUME, gdisp); + + g_object_unref (G_OBJECT (core)); + + gdisplays_flush (); } } @@ -529,6 +598,30 @@ vectors_edit_vectors_query (GimpVectors *vectors) GtkWidget *table; GtkWidget *label; + { + Gimp *gimp; + GimpTool *active_tool; + + gimp = GIMP_ITEM (vectors)->gimage->gimp; + + active_tool = tool_manager_get_active (gimp); + + if (! GIMP_IS_VECTOR_TOOL (active_tool)) + { + GimpToolInfo *tool_info; + + tool_info = tool_manager_get_info_by_type (gimp, GIMP_TYPE_VECTOR_TOOL); + + gimp_context_set_tool (gimp_get_current_context (gimp), tool_info); + + active_tool = tool_manager_get_active (gimp); + } + + gimp_vectors_tool_set_vectors (GIMP_VECTOR_TOOL (active_tool), vectors); + + return; + } + options = g_new0 (EditVectorsOptions, 1); options->vectors = vectors; diff --git a/app/paint/Makefile.am b/app/paint/Makefile.am index f30a123805..c27b5a06f1 100644 --- a/app/paint/Makefile.am +++ b/app/paint/Makefile.am @@ -4,6 +4,8 @@ noinst_LIBRARIES = libapppaint.a libapppaint_a_SOURCES = @STRIP_BEGIN@ \ paint-types.h \ + paint.c \ + paint.h \ gimpairbrush.c \ gimpairbrush.h \ gimpclone.c \ diff --git a/app/paint/gimppaintcore-stroke.c b/app/paint/gimppaintcore-stroke.c index af1da6b099..849348077d 100644 --- a/app/paint/gimppaintcore-stroke.c +++ b/app/paint/gimppaintcore-stroke.c @@ -32,30 +32,21 @@ gboolean gimp_paint_core_stroke (GimpPaintCore *core, GimpDrawable *drawable, GimpPaintOptions *paint_options, - gint n_strokes, - gdouble *strokes) + GimpCoords *strokes, + gint n_strokes) { - GimpCoords coords; - g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), FALSE); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); g_return_val_if_fail (paint_options != NULL, FALSE); - g_return_val_if_fail (n_strokes > 0, FALSE); g_return_val_if_fail (strokes != NULL, FALSE); + g_return_val_if_fail (n_strokes > 0, FALSE); - coords.x = strokes[0]; - coords.y = strokes[1]; - coords.pressure = 1.0; - coords.xtilt = 0.5; - coords.ytilt = 0.5; - coords.wheel = 0.5; - - if (gimp_paint_core_start (core, drawable, &coords)) + if (gimp_paint_core_start (core, drawable, &strokes[0])) { gint i; - core->start_coords = coords; - core->last_coords = coords; + core->start_coords = strokes[0]; + core->last_coords = strokes[0]; gimp_paint_core_paint (core, drawable, paint_options, INIT_PAINT); @@ -63,10 +54,7 @@ gimp_paint_core_stroke (GimpPaintCore *core, for (i = 1; i < n_strokes; i++) { - coords.x = strokes[i * 2 + 0]; - coords.y = strokes[i * 2 + 1]; - - core->cur_coords = coords; + core->cur_coords = strokes[i]; gimp_paint_core_interpolate (core, drawable, paint_options); diff --git a/app/paint/gimppaintcore-stroke.h b/app/paint/gimppaintcore-stroke.h index d857e005b1..d1807b19c4 100644 --- a/app/paint/gimppaintcore-stroke.h +++ b/app/paint/gimppaintcore-stroke.h @@ -23,8 +23,8 @@ gboolean gimp_paint_core_stroke (GimpPaintCore *core, GimpDrawable *drawable, GimpPaintOptions *paint_options, - gint n_strokes, - gdouble *strokes); + GimpCoords *strokes, + gint n_strokes); #endif /* __GIMP_PAINT_CORE_STROKE_H__ */ diff --git a/app/paint/paint.c b/app/paint/paint.c new file mode 100644 index 0000000000..c42f94fc50 --- /dev/null +++ b/app/paint/paint.c @@ -0,0 +1,60 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis and others + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include + +#include "paint-types.h" + +#include "paint.h" +#include "gimpairbrush.h" +#include "gimpclone.h" +#include "gimpconvolve.h" +#include "gimpdodgeburn.h" +#include "gimperaser.h" +#include "gimppaintbrush.h" +#include "gimppencil.h" +#include "gimpsmudge.h" + + +void +paint_init (Gimp *gimp) +{ + g_type_class_ref (GIMP_TYPE_AIRBRUSH); + g_type_class_ref (GIMP_TYPE_CLONE); + g_type_class_ref (GIMP_TYPE_CONVOLVE); + g_type_class_ref (GIMP_TYPE_DODGEBURN); + g_type_class_ref (GIMP_TYPE_ERASER); + g_type_class_ref (GIMP_TYPE_PAINTBRUSH); + g_type_class_ref (GIMP_TYPE_PENCIL); + g_type_class_ref (GIMP_TYPE_SMUDGE); +} + +void +paint_exit (Gimp *gimp) +{ + g_type_class_unref (g_type_class_peek (GIMP_TYPE_AIRBRUSH)); + g_type_class_unref (g_type_class_peek (GIMP_TYPE_CLONE)); + g_type_class_unref (g_type_class_peek (GIMP_TYPE_CONVOLVE)); + g_type_class_unref (g_type_class_peek (GIMP_TYPE_DODGEBURN)); + g_type_class_unref (g_type_class_peek (GIMP_TYPE_ERASER)); + g_type_class_unref (g_type_class_peek (GIMP_TYPE_PAINTBRUSH)); + g_type_class_unref (g_type_class_peek (GIMP_TYPE_PENCIL)); + g_type_class_unref (g_type_class_peek (GIMP_TYPE_SMUDGE)); +} diff --git a/app/paint/paint.h b/app/paint/paint.h new file mode 100644 index 0000000000..50db1b43b8 --- /dev/null +++ b/app/paint/paint.h @@ -0,0 +1,27 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis and others + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __PAINT_H__ +#define __PAINT_H__ + + +void paint_init (Gimp *gimp); +void paint_exit (Gimp *gimp); + + +#endif /* __PAINT_H__ */ diff --git a/app/pdb/paint_tools_cmds.c b/app/pdb/paint_tools_cmds.c index 070f3730af..ee4d8ad74c 100644 --- a/app/pdb/paint_tools_cmds.c +++ b/app/pdb/paint_tools_cmds.c @@ -87,12 +87,28 @@ paint_tools_stroke (Gimp *gimp, gdouble *strokes) { GimpPaintCore *core; + GimpCoords *coords; gboolean retval; + gint i; core = g_object_new (core_type, NULL); + coords = g_new (GimpCoords, n_strokes); + + for (i = 0; i < n_strokes; i++) + { + coords[i].x = strokes[2 * i]; + coords[i].y = strokes[2 * i + 1]; + coords[i].pressure = 1.0; + coords[i].xtilt = 0.5; + coords[i].ytilt = 0.5; + coords[i].wheel = 0.5; + } + retval = gimp_paint_core_stroke (core, drawable, paint_options, - n_strokes, strokes); + coords, n_strokes); + + g_free (coords); g_object_unref (G_OBJECT (core)); diff --git a/app/tools/tool_manager.c b/app/tools/tool_manager.c index 210740bbdb..d3aed5562b 100644 --- a/app/tools/tool_manager.c +++ b/app/tools/tool_manager.c @@ -510,7 +510,8 @@ tool_manager_register_tool (Gimp *gimp, { GimpToolManager *tool_manager; GimpToolInfo *tool_info; - const gchar *pdb_string = "gimp_paintbrush_default"; + const gchar *pdb_string; + const gchar *paint_core_name; GtkIconSet *icon_set; GtkStyle *style; GdkPixbuf *pixbuf; @@ -520,35 +521,48 @@ tool_manager_register_tool (Gimp *gimp, if (tool_type == GIMP_TYPE_PENCIL_TOOL) { - pdb_string = "gimp_pencil"; + pdb_string = "gimp_pencil"; + paint_core_name = "GimpPencil"; } else if (tool_type == GIMP_TYPE_PAINTBRUSH_TOOL) { - pdb_string = "gimp_paintbrush_default"; + pdb_string = "gimp_paintbrush_default"; + paint_core_name = "GimpPaintbrush"; } else if (tool_type == GIMP_TYPE_ERASER_TOOL) { - pdb_string = "gimp_eraser_default"; + pdb_string = "gimp_eraser_default"; + paint_core_name = "GimpEraser"; } else if (tool_type == GIMP_TYPE_AIRBRUSH_TOOL) { - pdb_string = "gimp_airbrush_default"; + pdb_string = "gimp_airbrush_default"; + paint_core_name = "GimpAirbrush"; } else if (tool_type == GIMP_TYPE_CLONE_TOOL) { - pdb_string = "gimp_clone_default"; + pdb_string = "gimp_clone_default"; + paint_core_name = "GimpClone"; } else if (tool_type == GIMP_TYPE_CONVOLVE_TOOL) { - pdb_string = "gimp_convolve_default"; + pdb_string = "gimp_convolve_default"; + paint_core_name = "GimpConvolve"; } else if (tool_type == GIMP_TYPE_SMUDGE_TOOL) { - pdb_string = "gimp_smudge_default"; + pdb_string = "gimp_smudge_default"; + paint_core_name = "GimpSmudge"; } else if (tool_type == GIMP_TYPE_DODGEBURN_TOOL) { - pdb_string = "gimp_dodgeburn_default"; + pdb_string = "gimp_dodgeburn_default"; + paint_core_name = "GimpDodgeBurn"; + } + else + { + pdb_string = "gimp_paintbrush_default"; + paint_core_name = "GimpPaintbrush"; } icon_set = gtk_icon_factory_lookup_default (stock_id); @@ -580,6 +594,7 @@ tool_manager_register_tool (Gimp *gimp, help_domain, help_data, pdb_string, + paint_core_name, stock_id, pixbuf); diff --git a/tools/pdbgen/pdb/paint_tools.pdb b/tools/pdbgen/pdb/paint_tools.pdb index c01e5e6b6d..f6c81b85be 100644 --- a/tools/pdbgen/pdb/paint_tools.pdb +++ b/tools/pdbgen/pdb/paint_tools.pdb @@ -740,12 +740,28 @@ paint_tools_stroke (Gimp *gimp, gdouble *strokes) { GimpPaintCore *core; + GimpCoords *coords; gboolean retval; + gint i; core = g_object_new (core_type, NULL); + coords = g_new (GimpCoords, n_strokes); + + for (i = 0; i < n_strokes; i++) + { + coords[i].x = strokes[2 * i]; + coords[i].y = strokes[2 * i + 1]; + coords[i].pressure = 1.0; + coords[i].xtilt = 0.5; + coords[i].ytilt = 0.5; + coords[i].wheel = 0.5; + } + retval = gimp_paint_core_stroke (core, drawable, paint_options, - n_strokes, strokes); + coords, n_strokes); + + g_free (coords); g_object_unref (G_OBJECT (core));