app/core/gimpundo.[ch] app/core/gimpitemundo.[ch] removed all _new()
2004-07-12 Michael Natterer <mitch@gimp.org> * app/core/gimpundo.[ch] * app/core/gimpitemundo.[ch] * app/text/gimptextundo.[ch]: removed all _new() functions and added properties and GObject::constructor() implementations instead. * app/core/gimpimage-undo.[ch] (gimp_image_undo_push): added "GType undo_gtype" parameter and allow to pass name-value pairs as "...". Une the new GParameter utility functions to construct the appropriate undo step with g_object_newv(). (gimp_image_undo_push_item): removed. (gimp_image_undo_push_undo): removed. Merged its code back into gimp_image_undo_push(), where it originally came from. * app/core/gimpimage-undo-push.c * app/core/gimpundostack.c * app/paint/gimppaintcore-undo.c * app/tools/gimptransformtool-undo.c * app/widgets/gimpundoeditor.c: changed accordingly.
This commit is contained in:

committed by
Michael Natterer

parent
9593e52ef2
commit
da74f1269e
24
ChangeLog
24
ChangeLog
@ -1,3 +1,27 @@
|
||||
2004-07-12 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpundo.[ch]
|
||||
* app/core/gimpitemundo.[ch]
|
||||
* app/text/gimptextundo.[ch]: removed all _new() functions and
|
||||
added properties and GObject::constructor() implementations
|
||||
instead.
|
||||
|
||||
* app/core/gimpimage-undo.[ch] (gimp_image_undo_push): added
|
||||
"GType undo_gtype" parameter and allow to pass name-value pairs as
|
||||
"...". Une the new GParameter utility functions to construct the
|
||||
appropriate undo step with g_object_newv().
|
||||
|
||||
(gimp_image_undo_push_item): removed.
|
||||
|
||||
(gimp_image_undo_push_undo): removed. Merged its code back into
|
||||
gimp_image_undo_push(), where it originally came from.
|
||||
|
||||
* app/core/gimpimage-undo-push.c
|
||||
* app/core/gimpundostack.c
|
||||
* app/paint/gimppaintcore-undo.c
|
||||
* app/tools/gimptransformtool-undo.c
|
||||
* app/widgets/gimpundoeditor.c: changed accordingly.
|
||||
|
||||
2004-07-12 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/gfig/gfig-dialog.c
|
||||
|
@ -82,13 +82,14 @@ gimp_image_undo_push_image_type (GimpImage *gimage,
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push (gimage,
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
|
||||
sizeof (ImageTypeUndo),
|
||||
sizeof (ImageTypeUndo),
|
||||
GIMP_UNDO_IMAGE_TYPE, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_image_type,
|
||||
undo_free_image_type)))
|
||||
undo_free_image_type,
|
||||
NULL)))
|
||||
{
|
||||
ImageTypeUndo *itu = new->data;
|
||||
|
||||
@ -154,13 +155,14 @@ gimp_image_undo_push_image_size (GimpImage *gimage,
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push (gimage,
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
|
||||
sizeof (ImageSizeUndo),
|
||||
sizeof (ImageSizeUndo),
|
||||
GIMP_UNDO_IMAGE_SIZE, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_image_size,
|
||||
undo_free_image_size)))
|
||||
undo_free_image_size,
|
||||
NULL)))
|
||||
{
|
||||
ImageSizeUndo *isu = new->data;
|
||||
|
||||
@ -235,13 +237,14 @@ gimp_image_undo_push_image_resolution (GimpImage *gimage,
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push (gimage,
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
|
||||
sizeof (ResolutionUndo),
|
||||
sizeof (ResolutionUndo),
|
||||
GIMP_UNDO_IMAGE_RESOLUTION, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_image_resolution,
|
||||
undo_free_image_resolution)))
|
||||
undo_free_image_resolution,
|
||||
NULL)))
|
||||
{
|
||||
ResolutionUndo *ru = new->data;
|
||||
|
||||
@ -329,13 +332,14 @@ gimp_image_undo_push_image_grid (GimpImage *gimage,
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_GRID (grid), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push (gimage,
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
|
||||
sizeof (GridUndo),
|
||||
sizeof (GridUndo),
|
||||
GIMP_UNDO_IMAGE_GRID, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_image_grid,
|
||||
undo_free_image_grid)))
|
||||
undo_free_image_grid,
|
||||
NULL)))
|
||||
{
|
||||
GridUndo *gu = new->data;
|
||||
|
||||
@ -407,13 +411,14 @@ gimp_image_undo_push_image_guide (GimpImage *gimage,
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (guide != NULL, FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push (gimage,
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
|
||||
sizeof (GuideUndo),
|
||||
sizeof (GuideUndo),
|
||||
GIMP_UNDO_IMAGE_GUIDE, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_image_guide,
|
||||
undo_free_image_guide)))
|
||||
undo_free_image_guide,
|
||||
NULL)))
|
||||
{
|
||||
GuideUndo *gu = new->data;
|
||||
|
||||
@ -502,13 +507,14 @@ gimp_image_undo_push_image_colormap (GimpImage *gimage,
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push (gimage,
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
|
||||
sizeof (ColormapUndo),
|
||||
sizeof (ColormapUndo),
|
||||
GIMP_UNDO_IMAGE_COLORMAP, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_image_colormap,
|
||||
undo_free_image_colormap)))
|
||||
undo_free_image_colormap,
|
||||
NULL)))
|
||||
{
|
||||
ColormapUndo *cu = new->data;
|
||||
|
||||
@ -612,12 +618,14 @@ gimp_image_undo_push_drawable (GimpImage *gimage,
|
||||
|
||||
size = sizeof (DrawableUndo) + tile_manager_get_memsize (tiles);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, item,
|
||||
size, sizeof (DrawableUndo),
|
||||
GIMP_UNDO_DRAWABLE, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_drawable,
|
||||
undo_free_drawable)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
size, sizeof (DrawableUndo),
|
||||
GIMP_UNDO_DRAWABLE, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_drawable,
|
||||
undo_free_drawable,
|
||||
"item", item,
|
||||
NULL)))
|
||||
{
|
||||
DrawableUndo *drawable_undo = new->data;
|
||||
|
||||
@ -700,12 +708,14 @@ gimp_image_undo_push_drawable_mod (GimpImage *gimage,
|
||||
|
||||
size = sizeof (DrawableModUndo) + tile_manager_get_memsize (drawable->tiles);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (drawable),
|
||||
size, sizeof (DrawableModUndo),
|
||||
GIMP_UNDO_DRAWABLE_MOD, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_drawable_mod,
|
||||
undo_free_drawable_mod)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
size, sizeof (DrawableModUndo),
|
||||
GIMP_UNDO_DRAWABLE_MOD, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_drawable_mod,
|
||||
undo_free_drawable_mod,
|
||||
"item", drawable,
|
||||
NULL)))
|
||||
{
|
||||
DrawableModUndo *drawable_undo = new->data;
|
||||
|
||||
@ -814,12 +824,14 @@ gimp_image_undo_push_mask (GimpImage *gimage,
|
||||
size += tile_manager_get_memsize (undo_tiles);
|
||||
}
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (mask),
|
||||
size, sizeof (MaskUndo),
|
||||
GIMP_UNDO_MASK, undo_desc,
|
||||
FALSE,
|
||||
undo_pop_mask,
|
||||
undo_free_mask)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
size, sizeof (MaskUndo),
|
||||
GIMP_UNDO_MASK, undo_desc,
|
||||
FALSE,
|
||||
undo_pop_mask,
|
||||
undo_free_mask,
|
||||
"item", mask,
|
||||
NULL)))
|
||||
{
|
||||
MaskUndo *mask_undo = new->data;
|
||||
|
||||
@ -974,12 +986,14 @@ gimp_image_undo_push_item_rename (GimpImage *gimage,
|
||||
|
||||
size = sizeof (ItemRenameUndo) + strlen (name) + 1;
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, item,
|
||||
size, sizeof (ItemRenameUndo),
|
||||
GIMP_UNDO_ITEM_RENAME, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_item_rename,
|
||||
undo_free_item_rename)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
size, sizeof (ItemRenameUndo),
|
||||
GIMP_UNDO_ITEM_RENAME, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_item_rename,
|
||||
undo_free_item_rename,
|
||||
"item", item,
|
||||
NULL)))
|
||||
{
|
||||
ItemRenameUndo *iru = new->data;
|
||||
|
||||
@ -1051,13 +1065,15 @@ gimp_image_undo_push_item_displace (GimpImage *gimage,
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, item,
|
||||
sizeof (ItemDisplaceUndo),
|
||||
sizeof (ItemDisplaceUndo),
|
||||
GIMP_UNDO_ITEM_DISPLACE, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_item_displace,
|
||||
undo_free_item_displace)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
sizeof (ItemDisplaceUndo),
|
||||
sizeof (ItemDisplaceUndo),
|
||||
GIMP_UNDO_ITEM_DISPLACE, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_item_displace,
|
||||
undo_free_item_displace,
|
||||
"item", item,
|
||||
NULL)))
|
||||
{
|
||||
ItemDisplaceUndo *idu = new->data;
|
||||
|
||||
@ -1127,13 +1143,15 @@ gimp_image_undo_push_item_visibility (GimpImage *gimage,
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, item,
|
||||
sizeof (ItemVisibilityUndo),
|
||||
sizeof (ItemVisibilityUndo),
|
||||
GIMP_UNDO_ITEM_VISIBILITY, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_item_visibility,
|
||||
undo_free_item_visibility)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
sizeof (ItemVisibilityUndo),
|
||||
sizeof (ItemVisibilityUndo),
|
||||
GIMP_UNDO_ITEM_VISIBILITY, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_item_visibility,
|
||||
undo_free_item_visibility,
|
||||
"item", item,
|
||||
NULL)))
|
||||
{
|
||||
ItemVisibilityUndo *ivu = new->data;
|
||||
|
||||
@ -1196,13 +1214,15 @@ gimp_image_undo_push_item_linked (GimpImage *gimage,
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, item,
|
||||
sizeof (ItemLinkedUndo),
|
||||
sizeof (ItemLinkedUndo),
|
||||
GIMP_UNDO_ITEM_LINKED, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_item_linked,
|
||||
undo_free_item_linked)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
sizeof (ItemLinkedUndo),
|
||||
sizeof (ItemLinkedUndo),
|
||||
GIMP_UNDO_ITEM_LINKED, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_item_linked,
|
||||
undo_free_item_linked,
|
||||
"item", item,
|
||||
NULL)))
|
||||
{
|
||||
ItemLinkedUndo *ilu = new->data;
|
||||
|
||||
@ -1307,12 +1327,14 @@ undo_push_layer (GimpImage *gimage,
|
||||
if (type == GIMP_UNDO_LAYER_REMOVE)
|
||||
size += gimp_object_get_memsize (GIMP_OBJECT (layer), NULL);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (layer),
|
||||
size, sizeof (LayerUndo),
|
||||
type, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_layer,
|
||||
undo_free_layer)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
size, sizeof (LayerUndo),
|
||||
type, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_layer,
|
||||
undo_free_layer,
|
||||
"item", layer,
|
||||
NULL)))
|
||||
{
|
||||
LayerUndo *lu = new->data;
|
||||
|
||||
@ -1483,12 +1505,14 @@ undo_push_layer_mask (GimpImage *gimage,
|
||||
if (type == GIMP_UNDO_LAYER_MASK_REMOVE)
|
||||
size += gimp_object_get_memsize (GIMP_OBJECT (mask), NULL);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (layer),
|
||||
size, sizeof (LayerMaskUndo),
|
||||
type, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_layer_mask,
|
||||
undo_free_layer_mask)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
size, sizeof (LayerMaskUndo),
|
||||
type, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_layer_mask,
|
||||
undo_free_layer_mask,
|
||||
"item", layer,
|
||||
NULL)))
|
||||
{
|
||||
LayerMaskUndo *lmu = new->data;
|
||||
|
||||
@ -1571,13 +1595,15 @@ gimp_image_undo_push_layer_reposition (GimpImage *gimage,
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (layer),
|
||||
sizeof (LayerRepositionUndo),
|
||||
sizeof (LayerRepositionUndo),
|
||||
GIMP_UNDO_LAYER_REPOSITION, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_layer_reposition,
|
||||
undo_free_layer_reposition)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
sizeof (LayerRepositionUndo),
|
||||
sizeof (LayerRepositionUndo),
|
||||
GIMP_UNDO_LAYER_REPOSITION, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_layer_reposition,
|
||||
undo_free_layer_reposition,
|
||||
"item", layer,
|
||||
NULL)))
|
||||
{
|
||||
LayerRepositionUndo *lru = new->data;
|
||||
|
||||
@ -1676,13 +1702,15 @@ undo_push_layer_properties (GimpImage *gimage,
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (layer),
|
||||
sizeof (LayerPropertiesUndo),
|
||||
sizeof (LayerPropertiesUndo),
|
||||
undo_type, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_layer_properties,
|
||||
undo_free_layer_properties)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
sizeof (LayerPropertiesUndo),
|
||||
sizeof (LayerPropertiesUndo),
|
||||
undo_type, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_layer_properties,
|
||||
undo_free_layer_properties,
|
||||
"item", layer,
|
||||
NULL)))
|
||||
{
|
||||
LayerPropertiesUndo *lpu = new->data;
|
||||
|
||||
@ -1750,19 +1778,25 @@ gimp_image_undo_push_text_layer (GimpImage *gimage,
|
||||
GimpTextLayer *layer,
|
||||
const GParamSpec *pspec)
|
||||
{
|
||||
GimpUndo *undo;
|
||||
GimpUndo *new;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_TEXT_LAYER (layer), FALSE);
|
||||
|
||||
gimp_image_dirty (gimage);
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_TEXT_UNDO,
|
||||
0, 0,
|
||||
GIMP_UNDO_TEXT_LAYER, undo_desc,
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL,
|
||||
"item", layer,
|
||||
"param", pspec,
|
||||
NULL)))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (gimage->undo_freeze_count > 0)
|
||||
return FALSE;
|
||||
|
||||
undo = gimp_text_undo_new (layer, pspec, undo_desc);
|
||||
|
||||
return gimp_image_undo_push_undo (gimage, undo);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@ -1793,13 +1827,15 @@ gimp_image_undo_push_text_layer_modified (GimpImage *gimage,
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_TEXT_LAYER (layer), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (layer),
|
||||
sizeof (TextLayerModifiedUndo),
|
||||
sizeof (TextLayerModifiedUndo),
|
||||
GIMP_UNDO_TEXT_LAYER_MODIFIED, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_text_layer_modified,
|
||||
undo_free_text_layer_modified)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
sizeof (TextLayerModifiedUndo),
|
||||
sizeof (TextLayerModifiedUndo),
|
||||
GIMP_UNDO_TEXT_LAYER_MODIFIED, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_text_layer_modified,
|
||||
undo_free_text_layer_modified,
|
||||
"item", layer,
|
||||
NULL)))
|
||||
{
|
||||
TextLayerModifiedUndo *modified_undo = new->data;
|
||||
|
||||
@ -1914,12 +1950,14 @@ undo_push_channel (GimpImage *gimage,
|
||||
if (type == GIMP_UNDO_CHANNEL_REMOVE)
|
||||
size += gimp_object_get_memsize (GIMP_OBJECT (channel), NULL);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (channel),
|
||||
size, sizeof (ChannelUndo),
|
||||
type, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_channel,
|
||||
undo_free_channel)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
size, sizeof (ChannelUndo),
|
||||
type, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_channel,
|
||||
undo_free_channel,
|
||||
"item", channel,
|
||||
NULL)))
|
||||
{
|
||||
ChannelUndo *cu = new->data;
|
||||
|
||||
@ -2018,13 +2056,15 @@ gimp_image_undo_push_channel_reposition (GimpImage *gimage,
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (channel),
|
||||
sizeof (ChannelRepositionUndo),
|
||||
sizeof (ChannelRepositionUndo),
|
||||
GIMP_UNDO_CHANNEL_REPOSITION, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_channel_reposition,
|
||||
undo_free_channel_reposition)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
sizeof (ChannelRepositionUndo),
|
||||
sizeof (ChannelRepositionUndo),
|
||||
GIMP_UNDO_CHANNEL_REPOSITION, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_channel_reposition,
|
||||
undo_free_channel_reposition,
|
||||
"item", channel,
|
||||
NULL)))
|
||||
{
|
||||
ChannelRepositionUndo *cru = new->data;
|
||||
|
||||
@ -2088,13 +2128,15 @@ gimp_image_undo_push_channel_color (GimpImage *gimage,
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (channel),
|
||||
sizeof (ChannelColorUndo),
|
||||
sizeof (ChannelColorUndo),
|
||||
GIMP_UNDO_CHANNEL_COLOR, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_channel_color,
|
||||
undo_free_channel_color)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
sizeof (ChannelColorUndo),
|
||||
sizeof (ChannelColorUndo),
|
||||
GIMP_UNDO_CHANNEL_COLOR, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_channel_color,
|
||||
undo_free_channel_color,
|
||||
"item", channel,
|
||||
NULL)))
|
||||
{
|
||||
ChannelColorUndo *ccu = new->data;
|
||||
|
||||
@ -2199,12 +2241,14 @@ undo_push_vectors (GimpImage *gimage,
|
||||
if (type == GIMP_UNDO_VECTORS_REMOVE)
|
||||
size += gimp_object_get_memsize (GIMP_OBJECT (vectors), NULL);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (vectors),
|
||||
size, sizeof (VectorsUndo),
|
||||
type, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_vectors,
|
||||
undo_free_vectors)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
size, sizeof (VectorsUndo),
|
||||
type, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_vectors,
|
||||
undo_free_vectors,
|
||||
"item", vectors,
|
||||
NULL)))
|
||||
{
|
||||
VectorsUndo *vu = new->data;
|
||||
|
||||
@ -2307,12 +2351,14 @@ gimp_image_undo_push_vectors_mod (GimpImage *gimage,
|
||||
size = (sizeof (VectorsModUndo) +
|
||||
gimp_object_get_memsize (GIMP_OBJECT (copy), NULL));
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (vectors),
|
||||
size, sizeof (VectorsModUndo),
|
||||
GIMP_UNDO_VECTORS_MOD, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_vectors_mod,
|
||||
undo_free_vectors_mod)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
size, sizeof (VectorsModUndo),
|
||||
GIMP_UNDO_VECTORS_MOD, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_vectors_mod,
|
||||
undo_free_vectors_mod,
|
||||
"item", vectors,
|
||||
NULL)))
|
||||
{
|
||||
VectorsModUndo *vmu = new->data;
|
||||
|
||||
@ -2401,13 +2447,15 @@ gimp_image_undo_push_vectors_reposition (GimpImage *gimage,
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (vectors),
|
||||
sizeof (VectorsRepositionUndo),
|
||||
sizeof (VectorsRepositionUndo),
|
||||
GIMP_UNDO_VECTORS_REPOSITION, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_vectors_reposition,
|
||||
undo_free_vectors_reposition)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
sizeof (VectorsRepositionUndo),
|
||||
sizeof (VectorsRepositionUndo),
|
||||
GIMP_UNDO_VECTORS_REPOSITION, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_vectors_reposition,
|
||||
undo_free_vectors_reposition,
|
||||
"item", vectors,
|
||||
NULL)))
|
||||
{
|
||||
VectorsRepositionUndo *vru = new->data;
|
||||
|
||||
@ -2475,13 +2523,14 @@ gimp_image_undo_push_fs_to_layer (GimpImage *gimage,
|
||||
g_return_val_if_fail (GIMP_IS_LAYER (floating_layer), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push (gimage,
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
|
||||
sizeof (FStoLayerUndo),
|
||||
sizeof (FStoLayerUndo),
|
||||
GIMP_UNDO_FS_TO_LAYER, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_fs_to_layer,
|
||||
undo_free_fs_to_layer)))
|
||||
undo_free_fs_to_layer,
|
||||
NULL)))
|
||||
{
|
||||
FStoLayerUndo *fsu = new->data;
|
||||
|
||||
@ -2591,12 +2640,14 @@ gimp_image_undo_push_fs_rigor (GimpImage *gimage,
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_LAYER (floating_layer), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (floating_layer),
|
||||
0, 0,
|
||||
GIMP_UNDO_FS_RIGOR, undo_desc,
|
||||
FALSE,
|
||||
undo_pop_fs_rigor,
|
||||
NULL)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
0, 0,
|
||||
GIMP_UNDO_FS_RIGOR, undo_desc,
|
||||
FALSE,
|
||||
undo_pop_fs_rigor,
|
||||
NULL,
|
||||
"item", floating_layer,
|
||||
NULL)))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@ -2649,12 +2700,14 @@ gimp_image_undo_push_fs_relax (GimpImage *gimage,
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_LAYER (floating_layer), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (floating_layer),
|
||||
0, 0,
|
||||
GIMP_UNDO_FS_RELAX, undo_desc,
|
||||
FALSE,
|
||||
undo_pop_fs_relax,
|
||||
NULL)))
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO,
|
||||
0, 0,
|
||||
GIMP_UNDO_FS_RELAX, undo_desc,
|
||||
FALSE,
|
||||
undo_pop_fs_relax,
|
||||
NULL,
|
||||
"item", floating_layer,
|
||||
NULL)))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@ -2718,13 +2771,14 @@ gimp_image_undo_push_image_parasite (GimpImage *gimage,
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push (gimage,
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
|
||||
sizeof (ParasiteUndo),
|
||||
sizeof (ParasiteUndo),
|
||||
GIMP_UNDO_PARASITE_ATTACH, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_parasite,
|
||||
undo_free_parasite)))
|
||||
undo_free_parasite,
|
||||
NULL)))
|
||||
{
|
||||
ParasiteUndo *pu = new->data;
|
||||
|
||||
@ -2749,13 +2803,14 @@ gimp_image_undo_push_image_parasite_remove (GimpImage *gimage,
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push (gimage,
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
|
||||
sizeof (ParasiteUndo),
|
||||
sizeof (ParasiteUndo),
|
||||
GIMP_UNDO_PARASITE_REMOVE, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_parasite,
|
||||
undo_free_parasite)))
|
||||
undo_free_parasite,
|
||||
NULL)))
|
||||
{
|
||||
ParasiteUndo *pu = new->data;
|
||||
|
||||
@ -2781,13 +2836,14 @@ gimp_image_undo_push_item_parasite (GimpImage *gimage,
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push (gimage,
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
|
||||
sizeof (ParasiteUndo),
|
||||
sizeof (ParasiteUndo),
|
||||
GIMP_UNDO_PARASITE_ATTACH, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_parasite,
|
||||
undo_free_parasite)))
|
||||
undo_free_parasite,
|
||||
NULL)))
|
||||
{
|
||||
ParasiteUndo *pu = new->data;
|
||||
|
||||
@ -2812,13 +2868,14 @@ gimp_image_undo_push_item_parasite_remove (GimpImage *gimage,
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push (gimage,
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
|
||||
sizeof (ParasiteUndo),
|
||||
sizeof (ParasiteUndo),
|
||||
GIMP_UNDO_PARASITE_REMOVE, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_parasite,
|
||||
undo_free_parasite)))
|
||||
undo_free_parasite,
|
||||
NULL)))
|
||||
{
|
||||
ParasiteUndo *pu = new->data;
|
||||
|
||||
@ -2913,11 +2970,12 @@ gimp_image_undo_push_cantundo (GimpImage *gimage,
|
||||
* any adequate undo facility.
|
||||
*/
|
||||
|
||||
if ((new = gimp_image_undo_push (gimage,
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
|
||||
0, 0,
|
||||
GIMP_UNDO_CANT, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_cantundo,
|
||||
NULL,
|
||||
NULL)))
|
||||
{
|
||||
return TRUE;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "config/gimpcoreconfig.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimp-utils.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-undo.h"
|
||||
#include "gimpitem.h"
|
||||
@ -184,36 +185,24 @@ gimp_image_undo_group_end (GimpImage *gimage)
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push (GimpImage *gimage,
|
||||
GType undo_gtype,
|
||||
gint64 size,
|
||||
gsize struct_size,
|
||||
GimpUndoType type,
|
||||
const gchar *name,
|
||||
gboolean dirties_image,
|
||||
GimpUndoPopFunc pop_func,
|
||||
GimpUndoFreeFunc free_func)
|
||||
GimpUndoFreeFunc free_func,
|
||||
...)
|
||||
{
|
||||
return gimp_image_undo_push_item (gimage, NULL,
|
||||
size, struct_size,
|
||||
type, name, dirties_image,
|
||||
pop_func, free_func);
|
||||
}
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push_item (GimpImage *gimage,
|
||||
GimpItem *item,
|
||||
gint64 size,
|
||||
gsize struct_size,
|
||||
GimpUndoType type,
|
||||
const gchar *name,
|
||||
gboolean dirties_image,
|
||||
GimpUndoPopFunc pop_func,
|
||||
GimpUndoFreeFunc free_func)
|
||||
{
|
||||
GimpUndo *undo;
|
||||
gpointer undo_struct = NULL;
|
||||
GParameter *params = NULL;
|
||||
gint n_params = 0;
|
||||
va_list args;
|
||||
GimpUndo *undo;
|
||||
gpointer undo_struct = NULL;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (item == NULL || GIMP_IS_ITEM (item), NULL);
|
||||
g_return_val_if_fail (g_type_is_a (undo_gtype, GIMP_TYPE_UNDO), NULL);
|
||||
g_return_val_if_fail (type > GIMP_UNDO_GROUP_LAST, NULL);
|
||||
|
||||
/* Does this undo dirty the image? If so, we always want to mark
|
||||
@ -225,40 +214,30 @@ gimp_image_undo_push_item (GimpImage *gimage,
|
||||
if (gimage->undo_freeze_count > 0)
|
||||
return NULL;
|
||||
|
||||
if (! name)
|
||||
name = gimp_undo_type_to_name (type);
|
||||
|
||||
if (struct_size > 0)
|
||||
undo_struct = g_malloc0 (struct_size);
|
||||
|
||||
if (item)
|
||||
{
|
||||
undo = gimp_item_undo_new (gimage, item,
|
||||
type, name,
|
||||
undo_struct, size,
|
||||
dirties_image,
|
||||
pop_func, free_func);
|
||||
}
|
||||
else
|
||||
{
|
||||
undo = gimp_undo_new (gimage,
|
||||
type, name,
|
||||
undo_struct, size,
|
||||
dirties_image,
|
||||
pop_func, free_func);
|
||||
}
|
||||
params = gimp_parameters_append (undo_gtype, params, &n_params,
|
||||
"name", name,
|
||||
"image", gimage,
|
||||
"undo-type", type,
|
||||
"dirties-image", dirties_image,
|
||||
"data", undo_struct,
|
||||
"size", size,
|
||||
"pop-func", pop_func,
|
||||
"free-func", free_func,
|
||||
NULL);
|
||||
|
||||
if (gimp_image_undo_push_undo (gimage, undo))
|
||||
return undo;
|
||||
va_start (args, free_func);
|
||||
params = gimp_parameters_append_valist (undo_gtype, params, &n_params, args);
|
||||
va_end (args);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
undo = g_object_newv (undo_gtype, n_params, params);
|
||||
|
||||
gboolean
|
||||
gimp_image_undo_push_undo (GimpImage *gimage,
|
||||
GimpUndo *undo)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_UNDO (undo), FALSE);
|
||||
g_return_val_if_fail (undo->gimage == gimage, FALSE);
|
||||
g_return_val_if_fail (gimage->undo_freeze_count == 0, FALSE);
|
||||
gimp_parameters_free (params, n_params);
|
||||
|
||||
/* nuke the redo stack */
|
||||
gimp_image_undo_free_redo (gimage);
|
||||
@ -282,7 +261,7 @@ gimp_image_undo_push_undo (GimpImage *gimage,
|
||||
|
||||
/* freeing undo space may have freed the newly pushed undo */
|
||||
if (gimp_undo_stack_peek (gimage->undo_stack) == undo)
|
||||
return TRUE;
|
||||
return undo;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -292,10 +271,10 @@ gimp_image_undo_push_undo (GimpImage *gimage,
|
||||
|
||||
gimp_undo_stack_push_undo (undo_group, undo);
|
||||
|
||||
return TRUE;
|
||||
return undo;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,24 +31,15 @@ gboolean gimp_image_undo_group_start (GimpImage *gimage,
|
||||
gboolean gimp_image_undo_group_end (GimpImage *gimage);
|
||||
|
||||
GimpUndo * gimp_image_undo_push (GimpImage *gimage,
|
||||
GType undo_gtype,
|
||||
gint64 size,
|
||||
gsize struct_size,
|
||||
GimpUndoType type,
|
||||
const gchar *name,
|
||||
gboolean dirties_image,
|
||||
GimpUndoPopFunc pop_func,
|
||||
GimpUndoFreeFunc free_func);
|
||||
GimpUndo * gimp_image_undo_push_item (GimpImage *gimage,
|
||||
GimpItem *item,
|
||||
gint64 size,
|
||||
gsize struct_size,
|
||||
GimpUndoType type,
|
||||
const gchar *name,
|
||||
gboolean dirties_image,
|
||||
GimpUndoPopFunc pop_func,
|
||||
GimpUndoFreeFunc free_func);
|
||||
gboolean gimp_image_undo_push_undo (GimpImage *gimage,
|
||||
GimpUndo *undo);
|
||||
GimpUndoFreeFunc free_func,
|
||||
...);
|
||||
|
||||
|
||||
#endif /* __GIMP_IMAGE_UNDO_H__ */
|
||||
|
@ -27,11 +27,29 @@
|
||||
#include "gimpitemundo.h"
|
||||
|
||||
|
||||
static void gimp_item_undo_class_init (GimpItemUndoClass *klass);
|
||||
static void gimp_item_undo_init (GimpItemUndo *undo);
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_ITEM
|
||||
};
|
||||
|
||||
static void gimp_item_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
static void gimp_item_undo_class_init (GimpItemUndoClass *klass);
|
||||
|
||||
static GObject * gimp_item_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_item_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_item_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_item_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
|
||||
static GimpUndoClass *parent_class = NULL;
|
||||
@ -47,19 +65,19 @@ gimp_item_undo_get_type (void)
|
||||
static const GTypeInfo undo_info =
|
||||
{
|
||||
sizeof (GimpItemUndoClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gimp_item_undo_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpItemUndo),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_item_undo_init,
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gimp_item_undo_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpItemUndo),
|
||||
0, /* n_preallocs */
|
||||
NULL /* instance_init */
|
||||
};
|
||||
|
||||
undo_type = g_type_register_static (GIMP_TYPE_UNDO,
|
||||
"GimpItemUndo",
|
||||
&undo_info, 0);
|
||||
"GimpItemUndo",
|
||||
&undo_info, 0);
|
||||
}
|
||||
|
||||
return undo_type;
|
||||
@ -68,30 +86,84 @@ gimp_item_undo_get_type (void)
|
||||
static void
|
||||
gimp_item_undo_class_init (GimpItemUndoClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GimpUndoClass *undo_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
undo_class = GIMP_UNDO_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
undo_class->free = gimp_item_undo_free;
|
||||
object_class->constructor = gimp_item_undo_constructor;
|
||||
object_class->set_property = gimp_item_undo_set_property;
|
||||
object_class->get_property = gimp_item_undo_get_property;
|
||||
|
||||
undo_class->free = gimp_item_undo_free;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_ITEM,
|
||||
g_param_spec_object ("item", NULL, NULL,
|
||||
GIMP_TYPE_ITEM,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_item_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
GimpItemUndo *item_undo;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
item_undo = GIMP_ITEM_UNDO (object);
|
||||
|
||||
g_assert (GIMP_IS_ITEM (item_undo->item));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_item_undo_init (GimpItemUndo *undo)
|
||||
gimp_item_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
undo->item = NULL;
|
||||
GimpItemUndo *item_undo = GIMP_ITEM_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_ITEM:
|
||||
item_undo->item = (GimpItem *) g_value_dup_object (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_item_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpItemUndo *item_undo = GIMP_ITEM_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_ITEM:
|
||||
g_value_set_object (value, item_undo->item);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_item_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
GimpItemUndo *item_undo;
|
||||
|
||||
item_undo = GIMP_ITEM_UNDO (undo);
|
||||
GimpItemUndo *item_undo = GIMP_ITEM_UNDO (undo);
|
||||
|
||||
GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
|
||||
|
||||
@ -101,40 +173,3 @@ gimp_item_undo_free (GimpUndo *undo,
|
||||
item_undo->item = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
GimpUndo *
|
||||
gimp_item_undo_new (GimpImage *gimage,
|
||||
GimpItem *item,
|
||||
GimpUndoType undo_type,
|
||||
const gchar *name,
|
||||
gpointer data,
|
||||
gint64 size,
|
||||
gboolean dirties_image,
|
||||
GimpUndoPopFunc pop_func,
|
||||
GimpUndoFreeFunc free_func)
|
||||
{
|
||||
GimpUndo *undo;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
|
||||
g_return_val_if_fail (size == 0 || data != NULL, NULL);
|
||||
|
||||
if (! name)
|
||||
name = gimp_undo_type_to_name (undo_type);
|
||||
|
||||
undo = g_object_new (GIMP_TYPE_ITEM_UNDO,
|
||||
"name", name,
|
||||
NULL);
|
||||
|
||||
undo->gimage = gimage;
|
||||
undo->undo_type = undo_type;
|
||||
undo->data = data;
|
||||
undo->size = size;
|
||||
undo->dirties_image = dirties_image ? TRUE : FALSE;
|
||||
undo->pop_func = pop_func;
|
||||
undo->free_func = free_func;
|
||||
|
||||
GIMP_ITEM_UNDO (undo)->item = g_object_ref (item);
|
||||
|
||||
return undo;
|
||||
}
|
||||
|
@ -46,17 +46,7 @@ struct _GimpItemUndoClass
|
||||
};
|
||||
|
||||
|
||||
GType gimp_item_undo_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GimpUndo * gimp_item_undo_new (GimpImage *gimage,
|
||||
GimpItem *item,
|
||||
GimpUndoType undo_type,
|
||||
const gchar *name,
|
||||
gpointer data,
|
||||
gint64 size,
|
||||
gboolean dirties_image,
|
||||
GimpUndoPopFunc pop_func,
|
||||
GimpUndoFreeFunc free_func);
|
||||
GType gimp_item_undo_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_ITEM_UNDO_H__ */
|
||||
|
@ -42,11 +42,33 @@ enum
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_IMAGE,
|
||||
PROP_UNDO_TYPE,
|
||||
PROP_DIRTIES_IMAGE,
|
||||
PROP_DATA,
|
||||
PROP_SIZE,
|
||||
PROP_POP_FUNC,
|
||||
PROP_FREE_FUNC
|
||||
};
|
||||
|
||||
|
||||
static void gimp_undo_class_init (GimpUndoClass *klass);
|
||||
static void gimp_undo_init (GimpUndo *undo);
|
||||
|
||||
static GObject * gimp_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_undo_finalize (GObject *object);
|
||||
static void gimp_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static gint64 gimp_undo_get_memsize (GimpObject *object,
|
||||
gint64 *gui_size);
|
||||
@ -86,19 +108,19 @@ gimp_undo_get_type (void)
|
||||
static const GTypeInfo undo_info =
|
||||
{
|
||||
sizeof (GimpUndoClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gimp_undo_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpUndo),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_undo_init,
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gimp_undo_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpUndo),
|
||||
0, /* n_preallocs */
|
||||
NULL /* instance_init */
|
||||
};
|
||||
|
||||
undo_type = g_type_register_static (GIMP_TYPE_VIEWABLE,
|
||||
"GimpUndo",
|
||||
&undo_info, 0);
|
||||
"GimpUndo",
|
||||
&undo_info, 0);
|
||||
}
|
||||
|
||||
return undo_type;
|
||||
@ -107,38 +129,37 @@ gimp_undo_get_type (void)
|
||||
static void
|
||||
gimp_undo_class_init (GimpUndoClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GimpObjectClass *gimp_object_class;
|
||||
GimpViewableClass *viewable_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
||||
viewable_class = GIMP_VIEWABLE_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
||||
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
undo_signals[POP] =
|
||||
g_signal_new ("pop",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpUndoClass, pop),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__ENUM_POINTER,
|
||||
G_TYPE_NONE, 2,
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpUndoClass, pop),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__ENUM_POINTER,
|
||||
G_TYPE_NONE, 2,
|
||||
GIMP_TYPE_UNDO_MODE,
|
||||
G_TYPE_POINTER);
|
||||
|
||||
undo_signals[FREE] =
|
||||
g_signal_new ("free",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpUndoClass, free),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__ENUM,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpUndoClass, free),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__ENUM,
|
||||
G_TYPE_NONE, 1,
|
||||
GIMP_TYPE_UNDO_MODE);
|
||||
|
||||
object_class->constructor = gimp_undo_constructor;
|
||||
object_class->finalize = gimp_undo_finalize;
|
||||
object_class->set_property = gimp_undo_set_property;
|
||||
object_class->get_property = gimp_undo_get_property;
|
||||
|
||||
gimp_object_class->get_memsize = gimp_undo_get_memsize;
|
||||
|
||||
@ -148,18 +169,64 @@ gimp_undo_class_init (GimpUndoClass *klass)
|
||||
|
||||
klass->pop = gimp_undo_real_pop;
|
||||
klass->free = gimp_undo_real_free;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_IMAGE,
|
||||
g_param_spec_object ("image", NULL, NULL,
|
||||
GIMP_TYPE_IMAGE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_UNDO_TYPE,
|
||||
g_param_spec_enum ("undo-type", NULL, NULL,
|
||||
GIMP_TYPE_UNDO_TYPE,
|
||||
GIMP_UNDO_GROUP_NONE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_DIRTIES_IMAGE,
|
||||
g_param_spec_boolean ("dirties-image",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_DATA,
|
||||
g_param_spec_pointer ("data", NULL, NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_SIZE,
|
||||
g_param_spec_int64 ("size", NULL, NULL,
|
||||
0, G_MAXINT64, 0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_POP_FUNC,
|
||||
g_param_spec_pointer ("pop-func", NULL, NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_FREE_FUNC,
|
||||
g_param_spec_pointer ("free-func", NULL, NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_undo_init (GimpUndo *undo)
|
||||
static GObject *
|
||||
gimp_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
undo->gimage = NULL;
|
||||
undo->undo_type = 0;
|
||||
undo->data = NULL;
|
||||
undo->dirties_image = FALSE;
|
||||
undo->pop_func = NULL;
|
||||
undo->free_func = NULL;
|
||||
undo->preview = NULL;
|
||||
GObject *object;
|
||||
GimpUndo *undo;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
undo = GIMP_UNDO (object);
|
||||
|
||||
g_assert (GIMP_IS_IMAGE (undo->gimage));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -182,6 +249,81 @@ gimp_undo_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpUndo *undo = GIMP_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_IMAGE:
|
||||
/* don't ref */
|
||||
undo->gimage = (GimpImage *) g_value_get_object (value);
|
||||
break;
|
||||
case PROP_UNDO_TYPE:
|
||||
undo->undo_type = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_DIRTIES_IMAGE:
|
||||
undo->dirties_image = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_DATA:
|
||||
undo->data = g_value_get_pointer (value);
|
||||
break;
|
||||
case PROP_SIZE:
|
||||
undo->size = g_value_get_int64 (value);
|
||||
break;
|
||||
case PROP_POP_FUNC:
|
||||
undo->pop_func = g_value_get_pointer (value);
|
||||
break;
|
||||
case PROP_FREE_FUNC:
|
||||
undo->free_func = g_value_get_pointer (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpUndo *undo = GIMP_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_IMAGE:
|
||||
g_value_set_object (value, undo->gimage);
|
||||
break;
|
||||
case PROP_UNDO_TYPE:
|
||||
g_value_set_enum (value, undo->undo_type);
|
||||
break;
|
||||
case PROP_DIRTIES_IMAGE:
|
||||
g_value_set_boolean (value, undo->dirties_image);
|
||||
break;
|
||||
case PROP_DATA:
|
||||
g_value_set_pointer (value, undo->data);
|
||||
break;
|
||||
case PROP_SIZE:
|
||||
g_value_set_int64 (value, undo->size);
|
||||
break;
|
||||
case PROP_POP_FUNC:
|
||||
g_value_set_pointer (value, undo->pop_func);
|
||||
break;
|
||||
case PROP_FREE_FUNC:
|
||||
g_value_set_pointer (value, undo->free_func);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static gint64
|
||||
gimp_undo_get_memsize (GimpObject *object,
|
||||
gint64 *gui_size)
|
||||
@ -268,39 +410,6 @@ gimp_undo_real_free (GimpUndo *undo,
|
||||
undo->free_func (undo, undo_mode);
|
||||
}
|
||||
|
||||
GimpUndo *
|
||||
gimp_undo_new (GimpImage *gimage,
|
||||
GimpUndoType undo_type,
|
||||
const gchar *name,
|
||||
gpointer data,
|
||||
gint64 size,
|
||||
gboolean dirties_image,
|
||||
GimpUndoPopFunc pop_func,
|
||||
GimpUndoFreeFunc free_func)
|
||||
{
|
||||
GimpUndo *undo;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (size == 0 || data != NULL, NULL);
|
||||
|
||||
if (! name)
|
||||
name = gimp_undo_type_to_name (undo_type);
|
||||
|
||||
undo = g_object_new (GIMP_TYPE_UNDO,
|
||||
"name", name,
|
||||
NULL);
|
||||
|
||||
undo->gimage = gimage;
|
||||
undo->undo_type = undo_type;
|
||||
undo->data = data;
|
||||
undo->size = size;
|
||||
undo->dirties_image = dirties_image ? TRUE : FALSE;
|
||||
undo->pop_func = pop_func;
|
||||
undo->free_func = free_func;
|
||||
|
||||
return undo;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
|
@ -76,15 +76,6 @@ struct _GimpUndoClass
|
||||
|
||||
GType gimp_undo_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GimpUndo * gimp_undo_new (GimpImage *gimage,
|
||||
GimpUndoType undo_type,
|
||||
const gchar *name,
|
||||
gpointer data,
|
||||
gint64 size,
|
||||
gboolean dirties_image,
|
||||
GimpUndoPopFunc pop_func,
|
||||
GimpUndoFreeFunc free_func);
|
||||
|
||||
void gimp_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
|
@ -168,15 +168,11 @@ gimp_undo_stack_free (GimpUndo *undo,
|
||||
GimpUndoStack *
|
||||
gimp_undo_stack_new (GimpImage *gimage)
|
||||
{
|
||||
GimpUndoStack *stack;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
|
||||
stack = g_object_new (GIMP_TYPE_UNDO_STACK, NULL);
|
||||
|
||||
GIMP_UNDO (stack)->gimage = gimage;
|
||||
|
||||
return stack;
|
||||
return g_object_new (GIMP_TYPE_UNDO_STACK,
|
||||
"image", gimage,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -59,17 +59,16 @@ gimp_paint_core_push_undo (GimpImage *gimage,
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push (gimage,
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
|
||||
sizeof (PaintUndo),
|
||||
sizeof (PaintUndo),
|
||||
GIMP_UNDO_PAINT, undo_desc,
|
||||
FALSE,
|
||||
undo_pop_paint,
|
||||
undo_free_paint)))
|
||||
undo_free_paint,
|
||||
NULL)))
|
||||
{
|
||||
PaintUndo *pu;
|
||||
|
||||
pu = new->data;
|
||||
PaintUndo *pu = new->data;
|
||||
|
||||
pu->core = core;
|
||||
pu->last_coords = core->start_coords;
|
||||
@ -87,9 +86,7 @@ undo_pop_paint (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
PaintUndo *pu;
|
||||
|
||||
pu = (PaintUndo *) undo->data;
|
||||
PaintUndo *pu = undo->data;
|
||||
|
||||
/* only pop if the core still exists */
|
||||
if (pu->core)
|
||||
@ -108,9 +105,7 @@ static void
|
||||
undo_free_paint (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
PaintUndo *pu;
|
||||
|
||||
pu = (PaintUndo *) undo->data;
|
||||
PaintUndo *pu = undo->data;
|
||||
|
||||
if (pu->core)
|
||||
g_object_remove_weak_pointer (G_OBJECT (pu->core), (gpointer) &pu->core);
|
||||
|
@ -35,16 +35,35 @@
|
||||
#include "gimptextundo.h"
|
||||
|
||||
|
||||
static void gimp_text_undo_class_init (GimpTextUndoClass *klass);
|
||||
static void gimp_text_undo_init (GimpTextUndo *undo);
|
||||
static gint64 gimp_text_undo_get_memsize (GimpObject *object,
|
||||
gint64 *gui_size);
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_PARAM
|
||||
};
|
||||
|
||||
static void gimp_text_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void gimp_text_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
static void gimp_text_undo_class_init (GimpTextUndoClass *klass);
|
||||
|
||||
static GObject * gimp_text_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_text_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_text_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static gint64 gimp_text_undo_get_memsize (GimpObject *object,
|
||||
gint64 *gui_size);
|
||||
|
||||
static void gimp_text_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void gimp_text_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
|
||||
static GimpUndoClass *parent_class = NULL;
|
||||
@ -67,7 +86,7 @@ gimp_text_undo_get_type (void)
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpTextUndo),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_text_undo_init,
|
||||
NULL /* instance_init */
|
||||
};
|
||||
|
||||
undo_type = g_type_register_static (GIMP_TYPE_ITEM_UNDO, "GimpTextUndo",
|
||||
@ -80,23 +99,101 @@ gimp_text_undo_get_type (void)
|
||||
static void
|
||||
gimp_text_undo_class_init (GimpTextUndoClass *klass)
|
||||
{
|
||||
GimpObjectClass *object_class = GIMP_OBJECT_CLASS (klass);
|
||||
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
||||
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->get_memsize = gimp_text_undo_get_memsize;
|
||||
object_class->constructor = gimp_text_undo_constructor;
|
||||
object_class->set_property = gimp_text_undo_set_property;
|
||||
object_class->get_property = gimp_text_undo_get_property;
|
||||
|
||||
undo_class->pop = gimp_text_undo_pop;
|
||||
undo_class->free = gimp_text_undo_free;
|
||||
gimp_object_class->get_memsize = gimp_text_undo_get_memsize;
|
||||
|
||||
undo_class->pop = gimp_text_undo_pop;
|
||||
undo_class->free = gimp_text_undo_free;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_PARAM,
|
||||
g_param_spec_param ("param", NULL, NULL,
|
||||
G_TYPE_PARAM,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_text_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
GimpTextUndo *text_undo;
|
||||
GimpTextLayer *layer;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
text_undo = GIMP_TEXT_UNDO (object);
|
||||
|
||||
g_assert (GIMP_IS_TEXT_LAYER (GIMP_ITEM_UNDO (text_undo)->item));
|
||||
|
||||
layer = GIMP_TEXT_LAYER (GIMP_ITEM_UNDO (text_undo)->item);
|
||||
|
||||
text_undo->time = time (NULL);
|
||||
|
||||
if (text_undo->pspec)
|
||||
{
|
||||
g_assert (text_undo->pspec->owner_type == GIMP_TYPE_TEXT);
|
||||
|
||||
text_undo->value = g_new0 (GValue, 1);
|
||||
|
||||
g_value_init (text_undo->value, text_undo->pspec->value_type);
|
||||
g_object_get_property (G_OBJECT (layer->text),
|
||||
text_undo->pspec->name, text_undo->value);
|
||||
}
|
||||
else if (layer->text)
|
||||
{
|
||||
text_undo->text = gimp_config_duplicate (GIMP_CONFIG (layer->text));
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_undo_init (GimpTextUndo *undo)
|
||||
gimp_text_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
undo->text = NULL;
|
||||
undo->pspec = NULL;
|
||||
undo->time = 0;
|
||||
GimpTextUndo *text_undo = GIMP_TEXT_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_PARAM:
|
||||
text_undo->pspec = g_value_get_param (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpTextUndo *text_undo = GIMP_TEXT_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_PARAM:
|
||||
g_value_set_param (value, (GParamSpec *) text_undo->pspec);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static gint64
|
||||
@ -193,51 +290,3 @@ gimp_text_undo_free (GimpUndo *undo,
|
||||
|
||||
GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
|
||||
}
|
||||
|
||||
GimpUndo *
|
||||
gimp_text_undo_new (GimpTextLayer *layer,
|
||||
const GParamSpec *pspec,
|
||||
const gchar *name)
|
||||
{
|
||||
GimpUndo *undo;
|
||||
GimpTextUndo *text_undo;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_TEXT_LAYER (layer), NULL);
|
||||
g_return_val_if_fail (pspec == NULL ||
|
||||
pspec->owner_type == GIMP_TYPE_TEXT, NULL);
|
||||
g_return_val_if_fail (pspec == NULL || layer->text != NULL, NULL);
|
||||
|
||||
if (! name)
|
||||
name = gimp_undo_type_to_name (GIMP_UNDO_TEXT_LAYER);
|
||||
|
||||
undo = g_object_new (GIMP_TYPE_TEXT_UNDO,
|
||||
"name", name,
|
||||
NULL);
|
||||
|
||||
undo->gimage = gimp_item_get_image (GIMP_ITEM (layer));
|
||||
undo->undo_type = GIMP_UNDO_TEXT_LAYER;
|
||||
undo->size = 0;
|
||||
undo->dirties_image = TRUE;
|
||||
|
||||
GIMP_ITEM_UNDO (undo)->item = g_object_ref (layer);
|
||||
|
||||
text_undo = GIMP_TEXT_UNDO (undo);
|
||||
|
||||
text_undo->time = time (NULL);
|
||||
|
||||
if (pspec)
|
||||
{
|
||||
text_undo->pspec = pspec;
|
||||
text_undo->value = g_new0 (GValue, 1);
|
||||
|
||||
g_value_init (text_undo->value, pspec->value_type);
|
||||
g_object_get_property (G_OBJECT (layer->text),
|
||||
pspec->name, text_undo->value);
|
||||
}
|
||||
else if (layer->text)
|
||||
{
|
||||
text_undo->text = gimp_config_duplicate (GIMP_CONFIG (layer->text));
|
||||
}
|
||||
|
||||
return undo;
|
||||
}
|
||||
|
@ -51,9 +51,5 @@ struct _GimpTextUndoClass
|
||||
|
||||
GType gimp_text_undo_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GimpUndo * gimp_text_undo_new (GimpTextLayer *layer,
|
||||
const GParamSpec *pspec,
|
||||
const gchar *name);
|
||||
|
||||
|
||||
#endif /* __GIMP_TEXT_UNDO_H__ */
|
||||
|
@ -67,19 +67,18 @@ gimp_transform_tool_push_undo (GimpImage *gimage,
|
||||
{
|
||||
GimpUndo *new;
|
||||
|
||||
if ((new = gimp_image_undo_push (gimage,
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
|
||||
sizeof (TransformUndo),
|
||||
sizeof (TransformUndo),
|
||||
GIMP_UNDO_TRANSFORM, undo_desc,
|
||||
FALSE,
|
||||
undo_pop_transform,
|
||||
undo_free_transform)))
|
||||
undo_free_transform,
|
||||
NULL)))
|
||||
{
|
||||
TransformUndo *tu;
|
||||
TransformUndo *tu = new->data;
|
||||
gint i;
|
||||
|
||||
tu = new->data;
|
||||
|
||||
tu->tool_ID = tool_ID;
|
||||
tu->tool_type = tool_type;
|
||||
|
||||
@ -106,11 +105,8 @@ undo_pop_transform (GimpUndo *undo,
|
||||
|
||||
if (GIMP_IS_TRANSFORM_TOOL (active_tool))
|
||||
{
|
||||
GimpTransformTool *tt;
|
||||
TransformUndo *tu;
|
||||
|
||||
tt = GIMP_TRANSFORM_TOOL (active_tool);
|
||||
tu = (TransformUndo *) undo->data;
|
||||
GimpTransformTool *tt = GIMP_TRANSFORM_TOOL (active_tool);
|
||||
TransformUndo *tu = undo->data;
|
||||
|
||||
/* only pop if the active tool is the tool that pushed this undo */
|
||||
if (tu->tool_ID == active_tool->ID)
|
||||
@ -150,9 +146,7 @@ static void
|
||||
undo_free_transform (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
TransformUndo * tu;
|
||||
|
||||
tu = (TransformUndo *) undo->data;
|
||||
TransformUndo * tu = undo->data;
|
||||
|
||||
if (tu->original)
|
||||
tile_manager_unref (tu->original);
|
||||
|
@ -250,9 +250,10 @@ gimp_undo_editor_fill (GimpUndoEditor *editor)
|
||||
|
||||
/* create a container as model for the undo history list */
|
||||
editor->container = gimp_list_new (GIMP_TYPE_UNDO, FALSE);
|
||||
editor->base_item = gimp_undo_new (gimage, GIMP_UNDO_GROUP_NONE,
|
||||
_("[ Base Image ]"),
|
||||
NULL, 0, FALSE, NULL, NULL);
|
||||
editor->base_item = g_object_new (GIMP_TYPE_UNDO,
|
||||
"image", gimage,
|
||||
"name", _("[ Base Image ]"),
|
||||
NULL);
|
||||
|
||||
/* the list prepends its items, so first add the redo items... */
|
||||
for (list = GIMP_LIST (gimage->redo_stack->undos)->list;
|
||||
|
Reference in New Issue
Block a user