Commit a44d24cc authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

added construct-only property "undo-desc". Use this when pushing an undo

2006-09-03  Sven Neumann  <sven@gimp.org>

        * app/paint/gimppaintcore.[ch]: added construct-only property
        "undo-desc". Use this when pushing an undo instead of attempting
        an unsuccessful lookup of the GimpPaintInfo object.

        * tools/pdbgen/pdb/paint_tools.pdb
        * app/tools/gimppainttool.c: use paint_info->blurb as undo
        description when constructing the paint core.

        * app/pdb/paint_tools_cmds.c: regenerated.
parent e27d62c0
...@@ -32,11 +32,9 @@ ...@@ -32,11 +32,9 @@
#include "paint-funcs/paint-funcs.h" #include "paint-funcs/paint-funcs.h"
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpimage-undo.h" #include "core/gimpimage-undo.h"
#include "core/gimppaintinfo.h"
#include "core/gimppickable.h" #include "core/gimppickable.h"
#include "gimppaintcore.h" #include "gimppaintcore.h"
...@@ -48,9 +46,24 @@ ...@@ -48,9 +46,24 @@
#include "gimp-intl.h" #include "gimp-intl.h"
enum
{
PROP_0,
PROP_UNDO_DESC
};
/* local function prototypes */ /* local function prototypes */
static void gimp_paint_core_finalize (GObject *object); 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, static gboolean gimp_paint_core_real_start (GimpPaintCore *core,
GimpDrawable *drawable, GimpDrawable *drawable,
...@@ -100,15 +113,23 @@ gimp_paint_core_class_init (GimpPaintCoreClass *klass) ...@@ -100,15 +113,23 @@ gimp_paint_core_class_init (GimpPaintCoreClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gimp_paint_core_finalize; object_class->finalize = gimp_paint_core_finalize;
object_class->set_property = gimp_paint_core_set_property;
klass->start = gimp_paint_core_real_start; object_class->get_property = gimp_paint_core_get_property;
klass->pre_paint = gimp_paint_core_real_pre_paint;
klass->paint = gimp_paint_core_real_paint; klass->start = gimp_paint_core_real_start;
klass->post_paint = gimp_paint_core_real_post_paint; klass->pre_paint = gimp_paint_core_real_pre_paint;
klass->interpolate = gimp_paint_core_real_interpolate; klass->paint = gimp_paint_core_real_paint;
klass->get_paint_area = gimp_paint_core_real_get_paint_area; klass->post_paint = gimp_paint_core_real_post_paint;
klass->push_undo = gimp_paint_core_real_push_undo; 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 static void
...@@ -116,6 +137,8 @@ gimp_paint_core_init (GimpPaintCore *core) ...@@ -116,6 +137,8 @@ gimp_paint_core_init (GimpPaintCore *core)
{ {
core->ID = global_core_ID++; core->ID = global_core_ID++;
core->undo_desc = NULL;
core->distance = 0.0; core->distance = 0.0;
core->pixel_dist = 0.0; core->pixel_dist = 0.0;
core->x1 = 0; core->x1 = 0;
...@@ -142,9 +165,53 @@ gimp_paint_core_finalize (GObject *object) ...@@ -142,9 +165,53 @@ gimp_paint_core_finalize (GObject *object)
gimp_paint_core_cleanup (core); gimp_paint_core_cleanup (core);
g_free (core->undo_desc);
core->undo_desc = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object); 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 static gboolean
gimp_paint_core_real_start (GimpPaintCore *core, gimp_paint_core_real_start (GimpPaintCore *core,
GimpDrawable *drawable, GimpDrawable *drawable,
...@@ -312,8 +379,7 @@ void ...@@ -312,8 +379,7 @@ void
gimp_paint_core_finish (GimpPaintCore *core, gimp_paint_core_finish (GimpPaintCore *core,
GimpDrawable *drawable) GimpDrawable *drawable)
{ {
GimpPaintInfo *paint_info; GimpImage *image;
GimpImage *image;
g_return_if_fail (GIMP_IS_PAINT_CORE (core)); g_return_if_fail (GIMP_IS_PAINT_CORE (core));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
...@@ -327,12 +393,7 @@ gimp_paint_core_finish (GimpPaintCore *core, ...@@ -327,12 +393,7 @@ gimp_paint_core_finish (GimpPaintCore *core,
if ((core->x2 == core->x1) || (core->y2 == core->y1)) if ((core->x2 == core->x1) || (core->y2 == core->y1))
return; return;
paint_info = (GimpPaintInfo *) gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_PAINT, core->undo_desc);
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_PAINT_CORE_GET_CLASS (core)->push_undo (core, image, NULL); GIMP_PAINT_CORE_GET_CLASS (core)->push_undo (core, image, NULL);
......
...@@ -39,6 +39,8 @@ struct _GimpPaintCore ...@@ -39,6 +39,8 @@ struct _GimpPaintCore
gint ID; /* unique instance ID */ gint ID; /* unique instance ID */
gchar *undo_desc; /* undo description */
GimpCoords start_coords; /* starting coords (for undo only) */ GimpCoords start_coords; /* starting coords (for undo only) */
GimpCoords cur_coords; /* current coords */ GimpCoords cur_coords; /* current coords */
......
...@@ -126,7 +126,9 @@ airbrush_invoker (GimpProcedure *procedure, ...@@ -126,7 +126,9 @@ airbrush_invoker (GimpProcedure *procedure,
NULL); NULL);
success = paint_tools_stroke (gimp, context, options, drawable, 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, ...@@ -161,7 +163,9 @@ airbrush_default_invoker (GimpProcedure *procedure,
GimpPaintOptions *options = gimp_paint_options_new (info); GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable, 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, ...@@ -209,6 +213,7 @@ clone_invoker (GimpProcedure *procedure,
success = paint_tools_stroke (gimp, context, options, drawable, success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, num_strokes, strokes,
"undo-desc", info->blurb,
"src-drawable", src_drawable, "src-drawable", src_drawable,
"src-x", src_x, "src-x", src_x,
"src-y", src_y, "src-y", src_y,
...@@ -247,7 +252,9 @@ clone_default_invoker (GimpProcedure *procedure, ...@@ -247,7 +252,9 @@ clone_default_invoker (GimpProcedure *procedure,
GimpPaintOptions *options = gimp_paint_options_new (info); GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable, 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, ...@@ -291,7 +298,9 @@ convolve_invoker (GimpProcedure *procedure,
NULL); NULL);
success = paint_tools_stroke (gimp, context, options, drawable, 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, ...@@ -326,7 +335,9 @@ convolve_default_invoker (GimpProcedure *procedure,
GimpPaintOptions *options = gimp_paint_options_new (info); GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable, 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, ...@@ -373,7 +384,9 @@ dodgeburn_invoker (GimpProcedure *procedure,
NULL); NULL);
success = paint_tools_stroke (gimp, context, options, drawable, 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, ...@@ -408,7 +421,9 @@ dodgeburn_default_invoker (GimpProcedure *procedure,
GimpPaintOptions *options = gimp_paint_options_new (info); GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable, 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, ...@@ -452,7 +467,9 @@ eraser_invoker (GimpProcedure *procedure,
NULL); NULL);
success = paint_tools_stroke (gimp, context, options, drawable, 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, ...@@ -487,7 +504,9 @@ eraser_default_invoker (GimpProcedure *procedure,
GimpPaintOptions *options = gimp_paint_options_new (info); GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable, 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, ...@@ -529,6 +548,7 @@ heal_invoker (GimpProcedure *procedure,
success = paint_tools_stroke (gimp, context, options, drawable, success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, num_strokes, strokes,
"undo-desc", info->blurb,
"src-drawable", src_drawable, "src-drawable", src_drawable,
"src-x", src_x, "src-x", src_x,
"src-y", src_y, "src-y", src_y,
...@@ -567,7 +587,9 @@ heal_default_invoker (GimpProcedure *procedure, ...@@ -567,7 +587,9 @@ heal_default_invoker (GimpProcedure *procedure,
GimpPaintOptions *options = gimp_paint_options_new (info); GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable, 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, ...@@ -616,7 +638,9 @@ paintbrush_invoker (GimpProcedure *procedure,
NULL); NULL);
success = paint_tools_stroke (gimp, context, options, drawable, 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, ...@@ -651,7 +675,9 @@ paintbrush_default_invoker (GimpProcedure *procedure,
GimpPaintOptions *options = gimp_paint_options_new (info); GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable, 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, ...@@ -686,7 +712,9 @@ pencil_invoker (GimpProcedure *procedure,
GimpPaintOptions *options = gimp_paint_options_new (info); GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable, 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, ...@@ -727,7 +755,9 @@ smudge_invoker (GimpProcedure *procedure,
NULL); NULL);
success = paint_tools_stroke (gimp, context, options, drawable, 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, ...@@ -762,7 +792,9 @@ smudge_default_invoker (GimpProcedure *procedure,
GimpPaintOptions *options = gimp_paint_options_new (info); GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable, success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, NULL); num_strokes, strokes,
"undo-desc", info->blurb,
NULL);
} }
} }
......
...@@ -142,6 +142,7 @@ gimp_paint_tool_constructor (GType type, ...@@ -142,6 +142,7 @@ gimp_paint_tool_constructor (GType type,
{ {
GObject *object; GObject *object;
GimpTool *tool; GimpTool *tool;
GimpPaintInfo *paint_info;
GimpPaintTool *paint_tool; GimpPaintTool *paint_tool;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params); object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
...@@ -151,10 +152,13 @@ gimp_paint_tool_constructor (GType type, ...@@ -151,10 +152,13 @@ gimp_paint_tool_constructor (GType type,
g_assert (GIMP_IS_TOOL_INFO (tool->tool_info)); g_assert (GIMP_IS_TOOL_INFO (tool->tool_info));
g_assert (GIMP_IS_PAINT_INFO (tool->tool_info->paint_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); NULL);
return object; return object;
......
...@@ -67,7 +67,9 @@ HELP ...@@ -67,7 +67,9 @@ HELP
NULL); NULL);
success = paint_tools_stroke (gimp, context, options, drawable, success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, NULL); num_strokes, strokes,
"undo-desc", info->blurb,
NULL);
} }
} }
CODE CODE
...@@ -107,7 +109,9 @@ HELP ...@@ -107,7 +109,9 @@ HELP
GimpPaintOptions *options = gimp_paint_options_new (info); GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable, success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, NULL); num_strokes, strokes,
"undo-desc", info->blurb,
NULL);
} }
} }
CODE CODE
...@@ -167,6 +171,7 @@ HELP ...@@ -167,6 +171,7 @@ HELP
success = paint_tools_stroke (gimp, context, options, drawable, success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, num_strokes, strokes,
"undo-desc", info->blurb,
"src-drawable", src_drawable, "src-drawable", src_drawable,
"src-x", src_x, "src-x", src_x,
"src-y", src_y, "src-y", src_y,
...@@ -211,7 +216,9 @@ HELP ...@@ -211,7 +216,9 @@ HELP
GimpPaintOptions *options = gimp_paint_options_new (info); GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable, success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, NULL); num_strokes, strokes,
"undo-desc", info->blurb,
NULL);
} }
} }
CODE CODE
...@@ -251,7 +258,9 @@ HELP ...@@ -251,7 +258,9 @@ HELP
GimpPaintOptions *options = gimp_paint_options_new (info); GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable, success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, NULL); num_strokes, strokes,
"undo-desc", info->blurb,
NULL);
} }
} }
CODE CODE
...@@ -298,7 +307,9 @@ HELP ...@@ -298,7 +307,9 @@ HELP
NULL); NULL);
success = paint_tools_stroke (gimp, context, options, drawable, success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, NULL); num_strokes, strokes,
"undo-desc", info->blurb,
NULL);
} }
} }
CODE CODE
...@@ -336,7 +347,9 @@ HELP ...@@ -336,7 +347,9 @@ HELP
GimpPaintOptions *options = gimp_paint_options_new (info); GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable, success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, NULL); num_strokes, strokes,
"undo-desc", info->blurb,
NULL);
} }
} }
CODE CODE
...@@ -384,7 +397,9 @@ HELP ...@@ -384,7 +397,9 @@ HELP
NULL); NULL);
success = paint_tools_stroke (gimp, context, options, drawable, success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, NULL); num_strokes, strokes,
"undo-desc", info->blurb,
NULL);
} }
} }
CODE CODE
...@@ -433,7 +448,9 @@ HELP ...@@ -433,7 +448,9 @@ HELP
NULL); NULL);
success = paint_tools_stroke (gimp, context, options, drawable, success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, NULL); num_strokes, strokes,
"undo-desc", info->blurb,
NULL);
} }
} }
CODE CODE
...@@ -481,6 +498,7 @@ HELP ...@@ -481,6 +498,7 @@ HELP
success = paint_tools_stroke (gimp, context, options, drawable, success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, num_strokes, strokes,
"undo-desc", info->blurb,
"src-drawable", src_drawable, "src-drawable", src_drawable,
"src-x", src_x, "src-x", src_x,
"src-y", src_y, "src-y", src_y,
...@@ -525,7 +543,9 @@ HELP ...@@ -525,7 +543,9 @@ HELP
GimpPaintOptions *options = gimp_paint_options_new (info); GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable, success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, NULL); num_strokes, strokes,
"undo-desc", info->blurb,
NULL);
} }
} }
CODE CODE
...@@ -584,7 +604,9 @@ HELP ...@@ -584,7 +604,9 @@ HELP
NULL);