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 @@
#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);
......
......@@ -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 */
......
......@@ -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);
}
}
......
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment