mirror of https://github.com/GNOME/gimp.git
app/core/Makefile.am app/core/core-types.h new undo class for
2007-01-31 Michael Natterer <mitch@gimp.org> * app/core/Makefile.am * app/core/core-types.h * app/core/gimplayermaskpropundo.[ch]: new undo class for GIMP_UNDO_LAYER_MASK_APPLY and GIMP_UNDO_LAYER_MASK_SHOW. * app/core/gimpimage-undo-push.c: use it here. svn path=/trunk/; revision=21823
This commit is contained in:
parent
d388d58494
commit
a7c0058c62
|
@ -1,3 +1,12 @@
|
|||
2007-01-31 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/Makefile.am
|
||||
* app/core/core-types.h
|
||||
* app/core/gimplayermaskpropundo.[ch]: new undo class for
|
||||
GIMP_UNDO_LAYER_MASK_APPLY and GIMP_UNDO_LAYER_MASK_SHOW.
|
||||
|
||||
* app/core/gimpimage-undo-push.c: use it here.
|
||||
|
||||
2007-01-31 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/Makefile.am
|
||||
|
|
|
@ -212,6 +212,8 @@ libappcore_a_sources = \
|
|||
gimplayer-floating-sel.h \
|
||||
gimplayermask.c \
|
||||
gimplayermask.h \
|
||||
gimplayermaskpropundo.c \
|
||||
gimplayermaskpropundo.h \
|
||||
gimplayermaskundo.c \
|
||||
gimplayermaskundo.h \
|
||||
gimplayerpropundo.c \
|
||||
|
|
|
@ -117,6 +117,7 @@ typedef struct _GimpChannelUndo GimpChannelUndo;
|
|||
typedef struct _GimpChannelPropUndo GimpChannelPropUndo;
|
||||
typedef struct _GimpDrawableUndo GimpDrawableUndo;
|
||||
typedef struct _GimpLayerMaskUndo GimpLayerMaskUndo;
|
||||
typedef struct _GimpLayerMaskPropUndo GimpLayerMaskPropUndo;
|
||||
typedef struct _GimpLayerUndo GimpLayerUndo;
|
||||
typedef struct _GimpLayerPropUndo GimpLayerPropUndo;
|
||||
typedef struct _GimpMaskUndo GimpMaskUndo;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "gimplayer.h"
|
||||
#include "gimplayer-floating-sel.h"
|
||||
#include "gimplayermask.h"
|
||||
#include "gimplayermaskpropundo.h"
|
||||
#include "gimplayermaskundo.h"
|
||||
#include "gimplayerpropundo.h"
|
||||
#include "gimplayerundo.h"
|
||||
|
@ -656,35 +657,26 @@ gimp_image_undo_push_layer_mask_remove (GimpImage *image,
|
|||
}
|
||||
|
||||
|
||||
/******************************/
|
||||
/* Layer Mask Property Undo */
|
||||
/******************************/
|
||||
|
||||
typedef struct _LayerMaskPropertyUndo LayerMaskPropertyUndo;
|
||||
|
||||
struct _LayerMaskPropertyUndo
|
||||
{
|
||||
gboolean old_apply;
|
||||
gboolean old_show;
|
||||
};
|
||||
|
||||
static GimpUndo * undo_push_layer_mask_properties (GimpImage *image,
|
||||
GimpUndoType undo_type,
|
||||
const gchar *undo_desc,
|
||||
GimpLayerMask *mask);
|
||||
static gboolean undo_pop_layer_mask_properties (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void undo_free_layer_mask_properties (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
/*******************************/
|
||||
/* Layer Mask Property Undos */
|
||||
/*******************************/
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push_layer_mask_apply (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
GimpLayerMask *mask)
|
||||
{
|
||||
return undo_push_layer_mask_properties (image, GIMP_UNDO_LAYER_MASK_APPLY,
|
||||
undo_desc, mask);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), NULL);
|
||||
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (mask)), NULL);
|
||||
|
||||
return gimp_image_undo_push (image, GIMP_TYPE_LAYER_MASK_PROP_UNDO,
|
||||
0, 0,
|
||||
GIMP_UNDO_LAYER_MASK_APPLY, undo_desc,
|
||||
GIMP_DIRTY_ITEM_META,
|
||||
NULL, NULL,
|
||||
"item", mask,
|
||||
NULL);
|
||||
}
|
||||
|
||||
GimpUndo *
|
||||
|
@ -692,83 +684,17 @@ gimp_image_undo_push_layer_mask_show (GimpImage *image,
|
|||
const gchar *undo_desc,
|
||||
GimpLayerMask *mask)
|
||||
{
|
||||
return undo_push_layer_mask_properties (image, GIMP_UNDO_LAYER_MASK_SHOW,
|
||||
undo_desc, mask);
|
||||
}
|
||||
|
||||
static GimpUndo *
|
||||
undo_push_layer_mask_properties (GimpImage *image,
|
||||
GimpUndoType undo_type,
|
||||
const gchar *undo_desc,
|
||||
GimpLayerMask *mask)
|
||||
{
|
||||
GimpUndo *new;
|
||||
gint64 size;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), NULL);
|
||||
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (mask)), NULL);
|
||||
|
||||
size = sizeof (LayerMaskPropertyUndo);
|
||||
|
||||
if ((new = gimp_image_undo_push (image, GIMP_TYPE_ITEM_UNDO,
|
||||
size, sizeof (LayerMaskPropertyUndo),
|
||||
undo_type, undo_desc,
|
||||
return gimp_image_undo_push (image, GIMP_TYPE_LAYER_MASK_PROP_UNDO,
|
||||
0, 0,
|
||||
GIMP_UNDO_LAYER_MASK_SHOW, undo_desc,
|
||||
GIMP_DIRTY_ITEM_META,
|
||||
undo_pop_layer_mask_properties,
|
||||
undo_free_layer_mask_properties,
|
||||
NULL, NULL,
|
||||
"item", mask,
|
||||
NULL)))
|
||||
{
|
||||
LayerMaskPropertyUndo *lmp_undo = new->data;
|
||||
|
||||
lmp_undo->old_apply = gimp_layer_mask_get_apply (mask);
|
||||
lmp_undo->old_show = gimp_layer_mask_get_show (mask);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
undo_pop_layer_mask_properties (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
LayerMaskPropertyUndo *lmp_undo = undo->data;
|
||||
GimpLayerMask *mask;
|
||||
gboolean val;
|
||||
|
||||
mask = GIMP_LAYER_MASK (GIMP_ITEM_UNDO (undo)->item);
|
||||
|
||||
switch (undo->undo_type)
|
||||
{
|
||||
case GIMP_UNDO_LAYER_MASK_APPLY:
|
||||
val = gimp_layer_mask_get_apply (mask);
|
||||
gimp_layer_mask_set_apply (mask, lmp_undo->old_apply, FALSE);
|
||||
lmp_undo->old_apply = val;
|
||||
break;
|
||||
|
||||
case GIMP_UNDO_LAYER_MASK_SHOW:
|
||||
val = gimp_layer_mask_get_show (mask);
|
||||
gimp_layer_mask_set_show (mask, lmp_undo->old_show, FALSE);
|
||||
lmp_undo->old_show = val;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_return_val_if_reached (FALSE);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
undo_free_layer_mask_properties (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
g_free (undo->data);
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
/* Gimp - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "gimplayermask.h"
|
||||
#include "gimplayermaskpropundo.h"
|
||||
|
||||
|
||||
static GObject * gimp_layer_mask_prop_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
|
||||
static void gimp_layer_mask_prop_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpLayerMaskPropUndo, gimp_layer_mask_prop_undo,
|
||||
GIMP_TYPE_ITEM_UNDO)
|
||||
|
||||
#define parent_class gimp_layer_mask_prop_undo_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_layer_mask_prop_undo_class_init (GimpLayerMaskPropUndoClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
|
||||
|
||||
object_class->constructor = gimp_layer_mask_prop_undo_constructor;
|
||||
|
||||
undo_class->pop = gimp_layer_mask_prop_undo_pop;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_layer_mask_prop_undo_init (GimpLayerMaskPropUndo *undo)
|
||||
{
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_layer_mask_prop_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
GimpLayerMaskPropUndo *layer_mask_prop_undo;
|
||||
GimpLayerMask *layer_mask;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
layer_mask_prop_undo = GIMP_LAYER_MASK_PROP_UNDO (object);
|
||||
|
||||
g_assert (GIMP_IS_LAYER_MASK (GIMP_ITEM_UNDO (object)->item));
|
||||
|
||||
layer_mask = GIMP_LAYER_MASK (GIMP_ITEM_UNDO (object)->item);
|
||||
|
||||
switch (GIMP_UNDO (object)->undo_type)
|
||||
{
|
||||
case GIMP_UNDO_LAYER_MASK_APPLY:
|
||||
layer_mask_prop_undo->apply = gimp_layer_mask_get_apply (layer_mask);
|
||||
break;
|
||||
|
||||
case GIMP_UNDO_LAYER_MASK_SHOW:
|
||||
layer_mask_prop_undo->show = gimp_layer_mask_get_show (layer_mask);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_layer_mask_prop_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
GimpLayerMaskPropUndo *layer_mask_prop_undo = GIMP_LAYER_MASK_PROP_UNDO (undo);
|
||||
GimpLayerMask *layer_mask = GIMP_LAYER_MASK (GIMP_ITEM_UNDO (undo)->item);
|
||||
|
||||
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
|
||||
|
||||
switch (undo->undo_type)
|
||||
{
|
||||
case GIMP_UNDO_LAYER_MASK_APPLY:
|
||||
{
|
||||
gboolean apply;
|
||||
|
||||
apply = gimp_layer_mask_get_apply (layer_mask);
|
||||
gimp_layer_mask_set_apply (layer_mask, layer_mask_prop_undo->apply, FALSE);
|
||||
layer_mask_prop_undo->apply = apply;
|
||||
}
|
||||
break;
|
||||
|
||||
case GIMP_UNDO_LAYER_MASK_SHOW:
|
||||
{
|
||||
gboolean show;
|
||||
|
||||
show = gimp_layer_mask_get_show (layer_mask);
|
||||
gimp_layer_mask_set_show (layer_mask, layer_mask_prop_undo->show, FALSE);
|
||||
layer_mask_prop_undo->show = show;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_LAYER_MASK_PROP_UNDO_H__
|
||||
#define __GIMP_LAYER_MASK_PROP_UNDO_H__
|
||||
|
||||
|
||||
#include "gimpitemundo.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_LAYER_MASK_PROP_UNDO (gimp_layer_mask_prop_undo_get_type ())
|
||||
#define GIMP_LAYER_MASK_PROP_UNDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_LAYER_MASK_PROP_UNDO, GimpLayerMaskPropUndo))
|
||||
#define GIMP_LAYER_MASK_PROP_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_LAYER_MASK_PROP_UNDO, GimpLayerMaskPropUndoClass))
|
||||
#define GIMP_IS_LAYER_MASK_PROP_UNDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_LAYER_MASK_PROP_UNDO))
|
||||
#define GIMP_IS_LAYER_MASK_PROP_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_LAYER_MASK_PROP_UNDO))
|
||||
#define GIMP_LAYER_MASK_PROP_UNDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_LAYER_MASK_PROP_UNDO, GimpLayerMaskPropUndoClass))
|
||||
|
||||
|
||||
typedef struct _GimpLayerMaskPropUndoClass GimpLayerMaskPropUndoClass;
|
||||
|
||||
struct _GimpLayerMaskPropUndo
|
||||
{
|
||||
GimpItemUndo parent_instance;
|
||||
|
||||
gboolean apply;
|
||||
gboolean show;
|
||||
};
|
||||
|
||||
struct _GimpLayerMaskPropUndoClass
|
||||
{
|
||||
GimpItemUndoClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_layer_mask_prop_undo_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_LAYER_MASK_PROP_UNDO_H__ */
|
Loading…
Reference in New Issue