diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c index 2bc0349952a9bc1669c1b5ba0afdd97211b3cd96..c9fb3e7fb76b1d2eab329601ad64686c24a51f7f 100644 --- a/app/paint/gimppaintcore.c +++ b/app/paint/gimppaintcore.c @@ -32,11 +32,9 @@ #include "paint-funcs/paint-funcs.h" #include "core/gimp.h" -#include "core/gimpcontainer.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimpimage-undo.h" -#include "core/gimppaintinfo.h" #include "core/gimppickable.h" #include "gimppaintcore.h" @@ -48,9 +46,24 @@ #include "gimp-intl.h" +enum +{ + PROP_0, + PROP_UNDO_DESC +}; + + /* local function prototypes */ static void gimp_paint_core_finalize (GObject *object); +static void gimp_paint_core_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gimp_paint_core_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); static gboolean gimp_paint_core_real_start (GimpPaintCore *core, GimpDrawable *drawable, @@ -100,15 +113,23 @@ gimp_paint_core_class_init (GimpPaintCoreClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->finalize = gimp_paint_core_finalize; - - klass->start = gimp_paint_core_real_start; - klass->pre_paint = gimp_paint_core_real_pre_paint; - klass->paint = gimp_paint_core_real_paint; - klass->post_paint = gimp_paint_core_real_post_paint; - klass->interpolate = gimp_paint_core_real_interpolate; - klass->get_paint_area = gimp_paint_core_real_get_paint_area; - klass->push_undo = gimp_paint_core_real_push_undo; + object_class->finalize = gimp_paint_core_finalize; + object_class->set_property = gimp_paint_core_set_property; + object_class->get_property = gimp_paint_core_get_property; + + klass->start = gimp_paint_core_real_start; + klass->pre_paint = gimp_paint_core_real_pre_paint; + klass->paint = gimp_paint_core_real_paint; + klass->post_paint = gimp_paint_core_real_post_paint; + klass->interpolate = gimp_paint_core_real_interpolate; + klass->get_paint_area = gimp_paint_core_real_get_paint_area; + klass->push_undo = gimp_paint_core_real_push_undo; + + g_object_class_install_property (object_class, PROP_UNDO_DESC, + g_param_spec_string ("undo-desc", NULL, NULL, + _("Paint"), + GIMP_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); } static void @@ -116,6 +137,8 @@ gimp_paint_core_init (GimpPaintCore *core) { core->ID = global_core_ID++; + core->undo_desc = NULL; + core->distance = 0.0; core->pixel_dist = 0.0; core->x1 = 0; @@ -142,9 +165,53 @@ gimp_paint_core_finalize (GObject *object) gimp_paint_core_cleanup (core); + g_free (core->undo_desc); + core->undo_desc = NULL; + G_OBJECT_CLASS (parent_class)->finalize (object); } +static void +gimp_paint_core_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GimpPaintCore *core = GIMP_PAINT_CORE (object); + + switch (property_id) + { + case PROP_UNDO_DESC: + g_free (core->undo_desc); + core->undo_desc = g_value_dup_string (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gimp_paint_core_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GimpPaintCore *core = GIMP_PAINT_CORE (object); + + switch (property_id) + { + case PROP_UNDO_DESC: + g_value_set_string (value, core->undo_desc); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + static gboolean gimp_paint_core_real_start (GimpPaintCore *core, GimpDrawable *drawable, @@ -312,8 +379,7 @@ void gimp_paint_core_finish (GimpPaintCore *core, GimpDrawable *drawable) { - GimpPaintInfo *paint_info; - GimpImage *image; + GimpImage *image; g_return_if_fail (GIMP_IS_PAINT_CORE (core)); g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); @@ -327,12 +393,7 @@ gimp_paint_core_finish (GimpPaintCore *core, if ((core->x2 == core->x1) || (core->y2 == core->y1)) return; - paint_info = (GimpPaintInfo *) - gimp_container_get_child_by_name (image->gimp->paint_info_list, - g_type_name (G_TYPE_FROM_INSTANCE (core))); - - gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_PAINT, - paint_info ? paint_info->blurb : _("Paint")); + gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_PAINT, core->undo_desc); GIMP_PAINT_CORE_GET_CLASS (core)->push_undo (core, image, NULL); diff --git a/app/paint/gimppaintcore.h b/app/paint/gimppaintcore.h index 544000db7ca5a4148be732931af45db38d56ef07..a4fb1003f781f9b6bb69fb343c0eb251041fec60 100644 --- a/app/paint/gimppaintcore.h +++ b/app/paint/gimppaintcore.h @@ -39,6 +39,8 @@ struct _GimpPaintCore gint ID; /* unique instance ID */ + gchar *undo_desc; /* undo description */ + GimpCoords start_coords; /* starting coords (for undo only) */ GimpCoords cur_coords; /* current coords */ diff --git a/app/pdb/paint_tools_cmds.c b/app/pdb/paint_tools_cmds.c index 2e92548e32675efb3ae7b35d75f49247ca13584d..33843ebb41af2c0933297284c7f86d518fcf5035 100644 --- a/app/pdb/paint_tools_cmds.c +++ b/app/pdb/paint_tools_cmds.c @@ -126,7 +126,9 @@ airbrush_invoker (GimpProcedure *procedure, NULL); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } @@ -161,7 +163,9 @@ airbrush_default_invoker (GimpProcedure *procedure, GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } @@ -209,6 +213,7 @@ clone_invoker (GimpProcedure *procedure, success = paint_tools_stroke (gimp, context, options, drawable, num_strokes, strokes, + "undo-desc", info->blurb, "src-drawable", src_drawable, "src-x", src_x, "src-y", src_y, @@ -247,7 +252,9 @@ clone_default_invoker (GimpProcedure *procedure, GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } @@ -291,7 +298,9 @@ convolve_invoker (GimpProcedure *procedure, NULL); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } @@ -326,7 +335,9 @@ convolve_default_invoker (GimpProcedure *procedure, GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } @@ -373,7 +384,9 @@ dodgeburn_invoker (GimpProcedure *procedure, NULL); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } @@ -408,7 +421,9 @@ dodgeburn_default_invoker (GimpProcedure *procedure, GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } @@ -452,7 +467,9 @@ eraser_invoker (GimpProcedure *procedure, NULL); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } @@ -487,7 +504,9 @@ eraser_default_invoker (GimpProcedure *procedure, GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } @@ -529,6 +548,7 @@ heal_invoker (GimpProcedure *procedure, success = paint_tools_stroke (gimp, context, options, drawable, num_strokes, strokes, + "undo-desc", info->blurb, "src-drawable", src_drawable, "src-x", src_x, "src-y", src_y, @@ -567,7 +587,9 @@ heal_default_invoker (GimpProcedure *procedure, GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } @@ -616,7 +638,9 @@ paintbrush_invoker (GimpProcedure *procedure, NULL); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } @@ -651,7 +675,9 @@ paintbrush_default_invoker (GimpProcedure *procedure, GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } @@ -686,7 +712,9 @@ pencil_invoker (GimpProcedure *procedure, GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } @@ -727,7 +755,9 @@ smudge_invoker (GimpProcedure *procedure, NULL); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } @@ -762,7 +792,9 @@ smudge_default_invoker (GimpProcedure *procedure, GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c index 942b0e1920ecf8bfa6fd789b8a13b9da05d0c61b..a5b79d46ac852f70f1056f759682154038d205b8 100644 --- a/app/tools/gimppainttool.c +++ b/app/tools/gimppainttool.c @@ -142,6 +142,7 @@ gimp_paint_tool_constructor (GType type, { GObject *object; GimpTool *tool; + GimpPaintInfo *paint_info; GimpPaintTool *paint_tool; object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params); @@ -151,10 +152,13 @@ gimp_paint_tool_constructor (GType type, g_assert (GIMP_IS_TOOL_INFO (tool->tool_info)); g_assert (GIMP_IS_PAINT_INFO (tool->tool_info->paint_info)); - g_assert (g_type_is_a (tool->tool_info->paint_info->paint_type, - GIMP_TYPE_PAINT_CORE)); - paint_tool->core = g_object_new (tool->tool_info->paint_info->paint_type, + paint_info = tool->tool_info->paint_info; + + g_assert (g_type_is_a (paint_info->paint_type, GIMP_TYPE_PAINT_CORE)); + + paint_tool->core = g_object_new (paint_info->paint_type, + "undo-desc", paint_info->blurb, NULL); return object; diff --git a/tools/pdbgen/pdb/paint_tools.pdb b/tools/pdbgen/pdb/paint_tools.pdb index db3ced6b47d6e87e1c25254abeb98530bb3087e8..2d7844d6bf768d5821942b4996ec3aea6c666e5a 100644 --- a/tools/pdbgen/pdb/paint_tools.pdb +++ b/tools/pdbgen/pdb/paint_tools.pdb @@ -67,7 +67,9 @@ HELP NULL); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE @@ -107,7 +109,9 @@ HELP GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE @@ -167,6 +171,7 @@ HELP success = paint_tools_stroke (gimp, context, options, drawable, num_strokes, strokes, + "undo-desc", info->blurb, "src-drawable", src_drawable, "src-x", src_x, "src-y", src_y, @@ -211,7 +216,9 @@ HELP GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE @@ -251,7 +258,9 @@ HELP GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE @@ -298,7 +307,9 @@ HELP NULL); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE @@ -336,7 +347,9 @@ HELP GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE @@ -384,7 +397,9 @@ HELP NULL); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE @@ -433,7 +448,9 @@ HELP NULL); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE @@ -481,6 +498,7 @@ HELP success = paint_tools_stroke (gimp, context, options, drawable, num_strokes, strokes, + "undo-desc", info->blurb, "src-drawable", src_drawable, "src-x", src_x, "src-y", src_y, @@ -525,7 +543,9 @@ HELP GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE @@ -584,7 +604,9 @@ HELP NULL); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE @@ -632,7 +654,9 @@ HELP GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE @@ -671,7 +695,9 @@ HELP GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE @@ -713,7 +739,9 @@ HELP NULL); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE @@ -753,7 +781,9 @@ HELP GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE @@ -802,7 +832,9 @@ HELP NULL); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE @@ -842,7 +874,9 @@ HELP GimpPaintOptions *options = gimp_paint_options_new (info); success = paint_tools_stroke (gimp, context, options, drawable, - num_strokes, strokes, NULL); + num_strokes, strokes, + "undo-desc", info->blurb, + NULL); } } CODE