From efb6d15acf9ed2eec99d00fab0928bfe3b31e79c Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sat, 25 Oct 2008 08:52:20 +0000 Subject: [PATCH] add "gboolean use_context_color" parameter to gimp_stroke_options_new() 2008-10-25 Michael Natterer * app/core/gimpstrokeoptions.[ch]: add "gboolean use_context_color" parameter to gimp_stroke_options_new() and set the passed context as parent of the new options only if it's TRUE. Also fixed the GimpConfig::duplicate() implementation to really duplicate the object and not just return an object containing default values. * app/core/gimpfilloptions.[ch]: add gimp_fill_options_new(). * app/actions/select-commands.c * app/dialogs/stroke-dialog.c * app/actions/vectors-commands.c * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/paths.pdb: pass TRUE to gimp_stroke_options_new(). * app/pdb/edit-cmds.c * app/pdb/paths-cmds.c: regenerated. svn path=/trunk/; revision=27393 --- ChangeLog | 19 +++++++++++++++++++ app/actions/select-commands.c | 2 +- app/actions/vectors-commands.c | 2 +- app/core/gimpfilloptions.c | 14 ++++++++++++++ app/core/gimpfilloptions.h | 4 +++- app/core/gimpstrokeoptions.c | 28 +++++++++++++++++++--------- app/core/gimpstrokeoptions.h | 3 ++- app/dialogs/stroke-dialog.c | 4 ++-- app/pdb/edit-cmds.c | 4 ++-- app/pdb/paths-cmds.c | 2 +- tools/pdbgen/pdb/edit.pdb | 4 ++-- tools/pdbgen/pdb/paths.pdb | 2 +- 12 files changed, 67 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1b1137b9c8..3edc61c82f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2008-10-25 Michael Natterer + + * app/core/gimpstrokeoptions.[ch]: add "gboolean use_context_color" + parameter to gimp_stroke_options_new() and set the passed context + as parent of the new options only if it's TRUE. Also fixed the + GimpConfig::duplicate() implementation to really duplicate the + object and not just return an object containing default values. + + * app/core/gimpfilloptions.[ch]: add gimp_fill_options_new(). + + * app/actions/select-commands.c + * app/dialogs/stroke-dialog.c + * app/actions/vectors-commands.c + * tools/pdbgen/pdb/edit.pdb + * tools/pdbgen/pdb/paths.pdb: pass TRUE to gimp_stroke_options_new(). + + * app/pdb/edit-cmds.c + * app/pdb/paths-cmds.c: regenerated. + 2008-10-25 Michael Natterer * app/core/gimpfilloptions.[ch]: add non-serializable properties diff --git a/app/actions/select-commands.c b/app/actions/select-commands.c index f7d7a232e5..b1621da8b0 100644 --- a/app/actions/select-commands.c +++ b/app/actions/select-commands.c @@ -369,7 +369,7 @@ select_stroke_last_vals_cmd_callback (GtkAction *action, if (options) g_object_ref (options); else - options = gimp_stroke_options_new (image->gimp, context); + options = gimp_stroke_options_new (image->gimp, context, TRUE); if (! gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (image)), drawable, context, options, FALSE, NULL, &error)) diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c index 868d199051..db276b6e9b 100644 --- a/app/actions/vectors-commands.c +++ b/app/actions/vectors-commands.c @@ -420,7 +420,7 @@ vectors_stroke_last_vals_cmd_callback (GtkAction *action, if (options) g_object_ref (options); else - options = gimp_stroke_options_new (image->gimp, context); + options = gimp_stroke_options_new (image->gimp, context, TRUE); if (! gimp_item_stroke (GIMP_ITEM (vectors), drawable, context, options, FALSE, NULL, &error)) diff --git a/app/core/gimpfilloptions.c b/app/core/gimpfilloptions.c index 7b7f31e7c8..d54c4f07b2 100644 --- a/app/core/gimpfilloptions.c +++ b/app/core/gimpfilloptions.c @@ -28,6 +28,7 @@ #include "core-types.h" +#include "gimp.h" #include "gimpfilloptions.h" #include "gimpviewable.h" @@ -156,3 +157,16 @@ gimp_fill_options_get_property (GObject *object, break; } } + + +/* public functions */ + +GimpFillOptions * +gimp_fill_options_new (Gimp *gimp) +{ + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + + return g_object_new (GIMP_TYPE_FILL_OPTIONS, + "gimp", gimp, + NULL); +} diff --git a/app/core/gimpfilloptions.h b/app/core/gimpfilloptions.h index af448acc9a..8fcc55c15e 100644 --- a/app/core/gimpfilloptions.h +++ b/app/core/gimpfilloptions.h @@ -54,7 +54,9 @@ struct _GimpFillOptionsClass }; -GType gimp_fill_options_get_type (void) G_GNUC_CONST; +GType gimp_fill_options_get_type (void) G_GNUC_CONST; + +GimpFillOptions * gimp_fill_options_new (Gimp *gimp); #endif /* __GIMP_FILL_OPTIONS_H__ */ diff --git a/app/core/gimpstrokeoptions.c b/app/core/gimpstrokeoptions.c index c5e1e78d08..ea765c47aa 100644 --- a/app/core/gimpstrokeoptions.c +++ b/app/core/gimpstrokeoptions.c @@ -94,6 +94,8 @@ G_DEFINE_TYPE_WITH_CODE (GimpStrokeOptions, gimp_stroke_options, #define parent_class gimp_stroke_options_parent_class +static GimpConfigInterface *parent_config_iface = NULL; + static guint stroke_options_signals[LAST_SIGNAL] = { 0 }; @@ -185,6 +187,11 @@ gimp_stroke_options_config_iface_init (gpointer iface, { GimpConfigInterface *config_iface = (GimpConfigInterface *) iface; + parent_config_iface = g_type_interface_peek_parent (config_iface); + + if (! parent_config_iface) + parent_config_iface = g_type_default_interface_peek (GIMP_TYPE_CONFIG); + config_iface->duplicate = gimp_stroke_options_duplicate; } @@ -325,8 +332,7 @@ gimp_stroke_options_duplicate (GimpConfig *config) GimpStrokeOptions *options = GIMP_STROKE_OPTIONS (config); GimpStrokeOptions *new_options; - new_options = gimp_stroke_options_new (GIMP_CONTEXT (options)->gimp, - GIMP_CONTEXT (options)); + new_options = GIMP_STROKE_OPTIONS (parent_config_iface->duplicate (config)); if (options->paint_options) { @@ -345,13 +351,15 @@ gimp_stroke_options_duplicate (GimpConfig *config) GimpStrokeOptions * gimp_stroke_options_new (Gimp *gimp, - GimpContext *context) + GimpContext *context, + gboolean use_context_color) { GimpPaintInfo *paint_info = NULL; GimpStrokeOptions *options; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL); + g_return_val_if_fail (use_context_color == FALSE || context != NULL, NULL); if (context) paint_info = gimp_context_get_paint_info (context); @@ -364,13 +372,15 @@ gimp_stroke_options_new (Gimp *gimp, "paint-info", paint_info, NULL); - gimp_context_define_properties (GIMP_CONTEXT (options), - GIMP_CONTEXT_FOREGROUND_MASK | - GIMP_CONTEXT_PATTERN_MASK, - FALSE); + if (use_context_color) + { + gimp_context_define_properties (GIMP_CONTEXT (options), + GIMP_CONTEXT_FOREGROUND_MASK | + GIMP_CONTEXT_PATTERN_MASK, + FALSE); - if (context) - gimp_context_set_parent (GIMP_CONTEXT (options), context); + gimp_context_set_parent (GIMP_CONTEXT (options), context); + } return options; } diff --git a/app/core/gimpstrokeoptions.h b/app/core/gimpstrokeoptions.h index 9958a0e099..4be812ee79 100644 --- a/app/core/gimpstrokeoptions.h +++ b/app/core/gimpstrokeoptions.h @@ -71,7 +71,8 @@ struct _GimpStrokeOptionsClass GType gimp_stroke_options_get_type (void) G_GNUC_CONST; GimpStrokeOptions * gimp_stroke_options_new (Gimp *gimp, - GimpContext *context); + GimpContext *context, + gboolean use_context_color); void gimp_stroke_options_take_dash_pattern (GimpStrokeOptions *options, GimpDashPreset preset, GArray *pattern); diff --git a/app/dialogs/stroke-dialog.c b/app/dialogs/stroke-dialog.c index 9007afe48d..62208e4292 100644 --- a/app/dialogs/stroke-dialog.c +++ b/app/dialogs/stroke-dialog.c @@ -88,7 +88,7 @@ stroke_dialog_new (GimpItem *item, image = gimp_item_get_image (item); - options = gimp_stroke_options_new (context->gimp, context); + options = gimp_stroke_options_new (context->gimp, context, TRUE); saved_options = g_object_get_data (G_OBJECT (context->gimp), "saved-stroke-options"); @@ -307,7 +307,7 @@ stroke_dialog_response (GtkWidget *widget, if (saved_options) g_object_ref (saved_options); else - saved_options = gimp_stroke_options_new (context->gimp, context); + saved_options = gimp_stroke_options_new (context->gimp, context, TRUE); gimp_config_sync (G_OBJECT (options), G_OBJECT (saved_options), 0); diff --git a/app/pdb/edit-cmds.c b/app/pdb/edit-cmds.c index be8f48cff4..c29ed99636 100644 --- a/app/pdb/edit-cmds.c +++ b/app/pdb/edit-cmds.c @@ -747,7 +747,7 @@ edit_stroke_invoker (GimpProcedure *procedure, if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error)) { GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); - GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context); + GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE); g_object_set (options, "method", GIMP_STROKE_METHOD_PAINT_CORE, @@ -787,7 +787,7 @@ edit_stroke_vectors_invoker (GimpProcedure *procedure, if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) && gimp_pdb_item_is_attached (GIMP_ITEM (vectors), error)) { - GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context); + GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE); g_object_set (options, "method", GIMP_STROKE_METHOD_PAINT_CORE, diff --git a/app/pdb/paths-cmds.c b/app/pdb/paths-cmds.c index 434289228d..7d199a959f 100644 --- a/app/pdb/paths-cmds.c +++ b/app/pdb/paths-cmds.c @@ -333,7 +333,7 @@ path_stroke_current_invoker (GimpProcedure *procedure, if (vectors && drawable) { - GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context); + GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE); g_object_set (options, "method", GIMP_STROKE_METHOD_PAINT_CORE, diff --git a/tools/pdbgen/pdb/edit.pdb b/tools/pdbgen/pdb/edit.pdb index d2657c3bce..8bd5092831 100644 --- a/tools/pdbgen/pdb/edit.pdb +++ b/tools/pdbgen/pdb/edit.pdb @@ -833,7 +833,7 @@ HELP if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error)) { GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); - GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context); + GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE); g_object_set (options, "method", GIMP_STROKE_METHOD_PAINT_CORE, @@ -876,7 +876,7 @@ HELP if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) && gimp_pdb_item_is_attached (GIMP_ITEM (vectors), error)) { - GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context); + GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE); g_object_set (options, "method", GIMP_STROKE_METHOD_PAINT_CORE, diff --git a/tools/pdbgen/pdb/paths.pdb b/tools/pdbgen/pdb/paths.pdb index ebaedb61a8..e8b856292a 100644 --- a/tools/pdbgen/pdb/paths.pdb +++ b/tools/pdbgen/pdb/paths.pdb @@ -268,7 +268,7 @@ sub path_stroke_current { if (vectors && drawable) { - GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context); + GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE); g_object_set (options, "method", GIMP_STROKE_METHOD_PAINT_CORE,