diff --git a/ChangeLog b/ChangeLog index a039ef2636..4d9995e449 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2004-01-22 Michael Natterer + + * app/core/gimpitem.[ch]: added "gboolean use_default_values" + to GimpItem::stroke(). + + * app/core/gimpselection.c: changed accordingly. + + * app/core/gimpchannel.c + * app/vectors/gimpvectors.c: if use_default_values is TRUE, don't + use the GimpPaintOptions passed in the GimpPaintInfo, but create a + new one. + + * app/gui/stroke-dialog.c: pass FALSE so the values as set in the + tool options are used. + + * tools/pdbgen/pdb/edit.pdb + * tools/pdbgen/pdb/paths.pdb: pass TRUE so tool options settings + don't affect PDB stroke calls. Fixes part 2 of bug #132145. + + * app/pdb/edit_cmds.c + * app/pdb/paths_cmds.c: regenerated. + 2004-01-22 Simon Budig * app/gui/dialogs-commands.c: replaced the indexed palette in diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c index 3de2f123f6..9a83488306 100644 --- a/app/core/gimpchannel.c +++ b/app/core/gimpchannel.c @@ -37,13 +37,16 @@ #include "paint-funcs/paint-funcs.h" #include "paint/gimppaintcore-stroke.h" +#include "paint/gimppaintoptions.h" +#include "gimp.h" #include "gimp-utils.h" #include "gimpimage.h" #include "gimpimage-projection.h" #include "gimpimage-undo.h" #include "gimpimage-undo-push.h" #include "gimpchannel.h" +#include "gimpcontext.h" #include "gimpdrawable-stroke.h" #include "gimplayer.h" #include "gimppaintinfo.h" @@ -96,7 +99,8 @@ static void gimp_channel_transform (GimpItem *item, gpointer progress_data); static gboolean gimp_channel_stroke (GimpItem *item, GimpDrawable *drawable, - GimpObject *stroke_desc); + GimpObject *stroke_desc, + gboolean use_default_values); static void gimp_channel_invalidate_boundary (GimpDrawable *drawable); static void gimp_channel_get_active_components (const GimpDrawable *drawable, @@ -593,11 +597,11 @@ gimp_channel_transform (GimpItem *item, static gboolean gimp_channel_stroke (GimpItem *item, GimpDrawable *drawable, - GimpObject *stroke_desc) + GimpObject *stroke_desc, + gboolean use_default_values) { - GimpChannel *channel; - GimpImage *gimage; + GimpChannel *channel = GIMP_CHANNEL (item); const BoundSeg *segs_in; const BoundSeg *segs_out; gint n_segs_in; @@ -605,12 +609,6 @@ gimp_channel_stroke (GimpItem *item, gboolean retval = FALSE; gint offset_x, offset_y; - channel = GIMP_CHANNEL (item); - - gimage = gimp_item_get_image (GIMP_ITEM (channel)); - - g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); - if (! gimp_channel_boundary (channel, &segs_in, &segs_out, &n_segs_in, &n_segs_out, 0, 0, 0, 0)) @@ -631,18 +629,41 @@ gimp_channel_stroke (GimpItem *item, } else if (GIMP_IS_PAINT_INFO (stroke_desc)) { - GimpPaintInfo *paint_info; - GimpPaintCore *core; + GimpImage *gimage = gimp_item_get_image (item); + GimpPaintInfo *paint_info = GIMP_PAINT_INFO (stroke_desc);; + GimpPaintOptions *paint_options; + GimpPaintCore *core; - paint_info = GIMP_PAINT_INFO (stroke_desc); + if (use_default_values) + { + paint_options = + gimp_paint_options_new (gimage->gimp, + paint_info->paint_options_type); + + /* undefine the paint-relevant context properties and get them + * from the current context + */ + gimp_context_define_properties (GIMP_CONTEXT (paint_options), + GIMP_CONTEXT_PAINT_PROPS_MASK, + FALSE); + gimp_context_set_parent (GIMP_CONTEXT (paint_options), + gimp_get_current_context (gimage->gimp)); + } + else + { + paint_options = paint_info->paint_options; + } core = g_object_new (paint_info->paint_type, NULL); retval = gimp_paint_core_stroke_boundary (core, drawable, - paint_info->paint_options, + paint_options, segs_in, n_segs_in, offset_x, offset_y); g_object_unref (core); + + if (use_default_values) + g_object_unref (paint_options); } return retval; diff --git a/app/core/gimpitem.c b/app/core/gimpitem.c index ed2cd1b879..454c73835b 100644 --- a/app/core/gimpitem.c +++ b/app/core/gimpitem.c @@ -799,7 +799,8 @@ gimp_item_transform (GimpItem *item, gboolean gimp_item_stroke (GimpItem *item, GimpDrawable *drawable, - GimpObject *stroke_desc) + GimpObject *stroke_desc, + gboolean use_default_values) { GimpItemClass *item_class; @@ -811,7 +812,7 @@ gimp_item_stroke (GimpItem *item, item_class = GIMP_ITEM_GET_CLASS (item); if (item_class->stroke) - return item_class->stroke (item, drawable, stroke_desc); + return item_class->stroke (item, drawable, stroke_desc, use_default_values); return FALSE; } diff --git a/app/core/gimpitem.h b/app/core/gimpitem.h index b94b872458..86543fde73 100644 --- a/app/core/gimpitem.h +++ b/app/core/gimpitem.h @@ -106,7 +106,8 @@ struct _GimpItemClass gpointer progress_data); gboolean (* stroke) (GimpItem *item, GimpDrawable *drawable, - GimpObject *stroke_desc); + GimpObject *stroke_desc, + gboolean use_default_values); const gchar *default_name; const gchar *rename_desc; @@ -193,7 +194,8 @@ void gimp_item_transform (GimpItem *item, gboolean gimp_item_stroke (GimpItem *item, GimpDrawable *drawable, - GimpObject *stroke_desc); + GimpObject *stroke_desc, + gboolean use_default_values); gint gimp_item_get_ID (GimpItem *item); GimpItem * gimp_item_get_by_ID (Gimp *gimp, diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c index 9f73633b06..3b583be7ff 100644 --- a/app/core/gimpselection.c +++ b/app/core/gimpselection.c @@ -70,7 +70,8 @@ static void gimp_selection_rotate (GimpItem *item, gboolean clip_result); static gboolean gimp_selection_stroke (GimpItem *item, GimpDrawable *drawable, - GimpObject *stroke_desc); + GimpObject *stroke_desc, + gboolean use_default_values); static void gimp_selection_invalidate_boundary (GimpDrawable *drawable); @@ -272,11 +273,12 @@ gimp_selection_rotate (GimpItem *item, } static gboolean -gimp_selection_stroke (GimpItem *item, - GimpDrawable *drawable, - GimpObject *stroke_desc) +gimp_selection_stroke (GimpItem *item, + GimpDrawable *drawable, + GimpObject *stroke_desc, + gboolean use_default_values) { - GimpSelection *selection; + GimpSelection *selection = GIMP_SELECTION (item); GimpImage *gimage; const BoundSeg *dummy_in; const BoundSeg *dummy_out; @@ -284,8 +286,6 @@ gimp_selection_stroke (GimpItem *item, gint num_dummy_out; gboolean retval; - selection = GIMP_SELECTION (item); - if (! gimp_channel_boundary (GIMP_CHANNEL (selection), &dummy_in, &dummy_out, &num_dummy_in, &num_dummy_out, @@ -302,7 +302,8 @@ gimp_selection_stroke (GimpItem *item, gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_PAINT, _("Stroke Selection")); - retval = GIMP_ITEM_CLASS (parent_class)->stroke (item, drawable, stroke_desc); + retval = GIMP_ITEM_CLASS (parent_class)->stroke (item, drawable, stroke_desc, + use_default_values); gimp_image_undo_group_end (gimage); diff --git a/app/dialogs/stroke-dialog.c b/app/dialogs/stroke-dialog.c index f23a8bc06a..769a60c365 100644 --- a/app/dialogs/stroke-dialog.c +++ b/app/dialogs/stroke-dialog.c @@ -331,7 +331,7 @@ stroke_dialog_response (GtkWidget *widget, options = g_object_get_data (G_OBJECT (dialog), "gimp-paint-info"); } - gimp_item_stroke (item, drawable, options); + gimp_item_stroke (item, drawable, options, FALSE); gimp_image_flush (image); } /* fallthrough */ diff --git a/app/gui/stroke-dialog.c b/app/gui/stroke-dialog.c index f23a8bc06a..769a60c365 100644 --- a/app/gui/stroke-dialog.c +++ b/app/gui/stroke-dialog.c @@ -331,7 +331,7 @@ stroke_dialog_response (GtkWidget *widget, options = g_object_get_data (G_OBJECT (dialog), "gimp-paint-info"); } - gimp_item_stroke (item, drawable, options); + gimp_item_stroke (item, drawable, options, FALSE); gimp_image_flush (image); } /* fallthrough */ diff --git a/app/pdb/edit_cmds.c b/app/pdb/edit_cmds.c index a465975326..3aa0908cb8 100644 --- a/app/pdb/edit_cmds.c +++ b/app/pdb/edit_cmds.c @@ -669,7 +669,8 @@ edit_stroke_invoker (Gimp *gimp, success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)), drawable, - GIMP_OBJECT (tool_info->paint_info)); + GIMP_OBJECT (tool_info->paint_info), + TRUE /* use defaults, not tool option values */); } return procedural_db_return_args (&edit_stroke_proc, success); diff --git a/app/pdb/paths_cmds.c b/app/pdb/paths_cmds.c index 02fe463951..3e5ffd857d 100644 --- a/app/pdb/paths_cmds.c +++ b/app/pdb/paths_cmds.c @@ -602,7 +602,8 @@ path_stroke_current_invoker (Gimp *gimp, tool_info = gimp_context_get_tool (gimp_get_current_context (gimp)); success = gimp_item_stroke (GIMP_ITEM (vectors), drawable, - GIMP_OBJECT (tool_info->paint_info)); + GIMP_OBJECT (tool_info->paint_info), + TRUE /* use defaults, not tool option values */); } else success = FALSE; diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c index 79ad0eb366..b1720f7436 100644 --- a/app/vectors/gimpvectors.c +++ b/app/vectors/gimpvectors.c @@ -23,6 +23,8 @@ #include +#include "libgimpcolor/gimpcolor.h" + #include "vectors-types.h" #include "core/gimp.h" @@ -35,8 +37,8 @@ #include "core/gimppaintinfo.h" #include "core/gimpstrokeoptions.h" -#include "libgimpcolor/gimpcolor.h" #include "paint/gimppaintcore-stroke.h" +#include "paint/gimppaintoptions.h" #include "gimpanchor.h" #include "gimpstroke.h" @@ -102,7 +104,8 @@ static void gimp_vectors_transform (GimpItem *item, gpointer progress_data); static gboolean gimp_vectors_stroke (GimpItem *item, GimpDrawable *drawable, - GimpObject *stroke_desc); + GimpObject *stroke_desc, + gboolean use_default_values); # @@ -340,11 +343,9 @@ gimp_vectors_translate (GimpItem *item, gint offset_y, gboolean push_undo) { - GimpVectors *vectors; + GimpVectors *vectors = GIMP_VECTORS (item); GList *list; - vectors = GIMP_VECTORS (item); - gimp_vectors_freeze (vectors); if (push_undo) @@ -370,11 +371,9 @@ gimp_vectors_scale (GimpItem *item, gint new_offset_y, GimpInterpolationType interpolation_type) { - GimpVectors *vectors; + GimpVectors *vectors = GIMP_VECTORS (item); GList *list; - vectors = GIMP_VECTORS (item); - gimp_vectors_freeze (vectors); gimp_image_undo_push_vectors_mod (gimp_item_get_image (item), @@ -404,11 +403,9 @@ gimp_vectors_resize (GimpItem *item, gint offset_x, gint offset_y) { - GimpVectors *vectors; + GimpVectors *vectors = GIMP_VECTORS (item); GList *list; - vectors = GIMP_VECTORS (item); - gimp_vectors_freeze (vectors); gimp_image_undo_push_vectors_mod (gimp_item_get_image (item), @@ -434,14 +431,12 @@ gimp_vectors_flip (GimpItem *item, gdouble axis, gboolean clip_result) { - GimpVectors *vectors; + GimpVectors *vectors = GIMP_VECTORS (item); GList *list; GimpMatrix3 matrix; gimp_transform_matrix_flip (flip_type, axis, &matrix); - vectors = GIMP_VECTORS (item); - gimp_vectors_freeze (vectors); gimp_image_undo_push_vectors_mod (gimp_item_get_image (item), @@ -465,7 +460,7 @@ gimp_vectors_rotate (GimpItem *item, gdouble center_y, gboolean clip_result) { - GimpVectors *vectors; + GimpVectors *vectors = GIMP_VECTORS (item); GList *list; GimpMatrix3 matrix; gdouble angle = 0.0; @@ -485,8 +480,6 @@ gimp_vectors_rotate (GimpItem *item, gimp_transform_matrix_rotate_center (center_x, center_y, angle, &matrix); - vectors = GIMP_VECTORS (item); - gimp_vectors_freeze (vectors); gimp_image_undo_push_vectors_mod (gimp_item_get_image (item), @@ -512,12 +505,10 @@ gimp_vectors_transform (GimpItem *item, GimpProgressFunc progress_callback, gpointer progress_data) { - GimpVectors *vectors; + GimpVectors *vectors = GIMP_VECTORS (item); GimpMatrix3 local_matrix; GList *list; - vectors = GIMP_VECTORS (item); - gimp_vectors_freeze (vectors); gimp_image_undo_push_vectors_mod (gimp_item_get_image (item), @@ -542,15 +533,11 @@ gimp_vectors_transform (GimpItem *item, static gboolean gimp_vectors_stroke (GimpItem *item, GimpDrawable *drawable, - GimpObject *stroke_desc) + GimpObject *stroke_desc, + gboolean use_default_values) { - GimpVectors *vectors; - gboolean retval = FALSE; - - g_return_val_if_fail (GIMP_IS_PAINT_INFO (stroke_desc) || - GIMP_IS_STROKE_OPTIONS (stroke_desc), FALSE); - - vectors = GIMP_VECTORS (item); + GimpVectors *vectors = GIMP_VECTORS (item);; + gboolean retval = FALSE; if (! vectors->strokes) { @@ -567,18 +554,41 @@ gimp_vectors_stroke (GimpItem *item, } else if (GIMP_IS_PAINT_INFO (stroke_desc)) { - GimpPaintInfo *paint_info; - GimpPaintCore *core; + GimpImage *gimage = gimp_item_get_image (item); + GimpPaintInfo *paint_info = GIMP_PAINT_INFO (stroke_desc);; + GimpPaintOptions *paint_options; + GimpPaintCore *core; - paint_info = GIMP_PAINT_INFO (stroke_desc); + if (use_default_values) + { + paint_options = + gimp_paint_options_new (gimage->gimp, + paint_info->paint_options_type); + + /* undefine the paint-relevant context properties and get them + * from the current context + */ + gimp_context_define_properties (GIMP_CONTEXT (paint_options), + GIMP_CONTEXT_PAINT_PROPS_MASK, + FALSE); + gimp_context_set_parent (GIMP_CONTEXT (paint_options), + gimp_get_current_context (gimage->gimp)); + } + else + { + paint_options = paint_info->paint_options; + } core = g_object_new (paint_info->paint_type, NULL); retval = gimp_paint_core_stroke_vectors (core, drawable, - paint_info->paint_options, + paint_options, vectors); g_object_unref (core); + + if (use_default_values) + g_object_unref (paint_options); } return retval; diff --git a/tools/pdbgen/pdb/edit.pdb b/tools/pdbgen/pdb/edit.pdb index cb0739ff75..1e2b52a0b4 100644 --- a/tools/pdbgen/pdb/edit.pdb +++ b/tools/pdbgen/pdb/edit.pdb @@ -339,7 +339,8 @@ HELP success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)), drawable, - GIMP_OBJECT (tool_info->paint_info)); + GIMP_OBJECT (tool_info->paint_info), + TRUE /* use defaults, not tool option values */); } CODE ); diff --git a/tools/pdbgen/pdb/paths.pdb b/tools/pdbgen/pdb/paths.pdb index 531fa21e3b..b755c04299 100644 --- a/tools/pdbgen/pdb/paths.pdb +++ b/tools/pdbgen/pdb/paths.pdb @@ -313,7 +313,8 @@ HELP tool_info = gimp_context_get_tool (gimp_get_current_context (gimp)); success = gimp_item_stroke (GIMP_ITEM (vectors), drawable, - GIMP_OBJECT (tool_info->paint_info)); + GIMP_OBJECT (tool_info->paint_info), + TRUE /* use defaults, not tool option values */); } else success = FALSE;