1
/* The GIMP -- an image manipulation program
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
#include <glib-object.h>
23
#include "paint-types.h"
25
#include "core/gimpimage-undo.h"
26
#include "core/gimpimage.h"
27
#include "core/gimpundo.h"
29
#include "gimppaintcore.h"
31
#include "gimp-intl.h"
38
typedef struct _PaintUndo PaintUndo;
43
GimpCoords last_coords;
46
static gboolean undo_pop_paint (GimpUndo *undo,
47
GimpUndoMode undo_mode,
48
GimpUndoAccumulator *accum);
49
static void undo_free_paint (GimpUndo *undo,
50
GimpUndoMode undo_mode);
53
gimp_paint_core_real_push_undo (GimpPaintCore *core,
55
const gchar *undo_desc)
59
g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), FALSE);
60
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
62
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
65
GIMP_UNDO_PAINT, undo_desc,
71
PaintUndo *pu = new->data;
74
pu->last_coords = core->start_coords;
76
g_object_add_weak_pointer (G_OBJECT (core), (gpointer) &pu->core);
85
undo_pop_paint (GimpUndo *undo,
86
GimpUndoMode undo_mode,
87
GimpUndoAccumulator *accum)
89
PaintUndo *pu = undo->data;
91
/* only pop if the core still exists */
94
GimpCoords tmp_coords;
96
tmp_coords = pu->core->last_coords;
97
pu->core->last_coords = pu->last_coords;
98
pu->last_coords = tmp_coords;
105
undo_free_paint (GimpUndo *undo,
106
GimpUndoMode undo_mode)
108
PaintUndo *pu = undo->data;
111
g_object_remove_weak_pointer (G_OBJECT (pu->core), (gpointer) &pu->core);