~ubuntu-branches/ubuntu/vivid/gimp/vivid

« back to all changes in this revision

Viewing changes to app/core/gimpimageundo.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach
  • Date: 2012-05-08 18:50:03 UTC
  • mto: (1.1.26) (0.5.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 71.
  • Revision ID: package-import@ubuntu.com-20120508185003-tltkvbaysf8d2426
ImportĀ upstreamĀ versionĀ 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
 
 * This program is free software; you can redistribute it and/or modify
 
4
 * This program is free software: you can redistribute it and/or modify
5
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
 
6
 * the Free Software Foundation; either version 3 of the License, or
7
7
 * (at your option) any later version.
8
8
 *
9
9
 * This program is distributed in the hope that it will be useful,
12
12
 * GNU General Public License for more details.
13
13
 *
14
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.
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
16
 */
18
17
 
19
18
#include "config.h"
20
19
 
21
20
#include <string.h>
22
21
 
23
 
#include <glib-object.h>
 
22
#include <cairo.h>
 
23
#include <gegl.h>
24
24
 
25
25
#include "libgimpbase/gimpbase.h"
26
26
#include "libgimpcolor/gimpcolor.h"
34
34
#include "gimpimage.h"
35
35
#include "gimpimage-colormap.h"
36
36
#include "gimpimage-grid.h"
 
37
#include "gimpimage-private.h"
37
38
#include "gimpimageundo.h"
38
39
#include "gimpparasitelist.h"
39
40
 
50
51
};
51
52
 
52
53
 
53
 
static GObject * gimp_image_undo_constructor  (GType                  type,
54
 
                                               guint                  n_params,
55
 
                                               GObjectConstructParam *params);
56
 
static void      gimp_image_undo_set_property (GObject               *object,
57
 
                                               guint                  property_id,
58
 
                                               const GValue          *value,
59
 
                                               GParamSpec            *pspec);
60
 
static void      gimp_image_undo_get_property (GObject               *object,
61
 
                                               guint                  property_id,
62
 
                                               GValue                *value,
63
 
                                               GParamSpec            *pspec);
64
 
 
65
 
static gint64    gimp_image_undo_get_memsize  (GimpObject            *object,
66
 
                                               gint64                *gui_size);
67
 
 
68
 
static void      gimp_image_undo_pop          (GimpUndo              *undo,
69
 
                                               GimpUndoMode           undo_mode,
70
 
                                               GimpUndoAccumulator   *accum);
71
 
static void      gimp_image_undo_free         (GimpUndo              *undo,
72
 
                                               GimpUndoMode           undo_mode);
 
54
static void     gimp_image_undo_constructed  (GObject             *object);
 
55
static void     gimp_image_undo_set_property (GObject             *object,
 
56
                                              guint                property_id,
 
57
                                              const GValue        *value,
 
58
                                              GParamSpec          *pspec);
 
59
static void     gimp_image_undo_get_property (GObject             *object,
 
60
                                              guint                property_id,
 
61
                                              GValue              *value,
 
62
                                              GParamSpec          *pspec);
 
63
 
 
64
static gint64   gimp_image_undo_get_memsize  (GimpObject          *object,
 
65
                                              gint64              *gui_size);
 
66
 
 
67
static void     gimp_image_undo_pop          (GimpUndo            *undo,
 
68
                                              GimpUndoMode         undo_mode,
 
69
                                              GimpUndoAccumulator *accum);
 
70
static void     gimp_image_undo_free         (GimpUndo            *undo,
 
71
                                              GimpUndoMode         undo_mode);
73
72
 
74
73
 
75
74
G_DEFINE_TYPE (GimpImageUndo, gimp_image_undo, GIMP_TYPE_UNDO)
84
83
  GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
85
84
  GimpUndoClass   *undo_class        = GIMP_UNDO_CLASS (klass);
86
85
 
87
 
  object_class->constructor      = gimp_image_undo_constructor;
 
86
  object_class->constructed      = gimp_image_undo_constructed;
88
87
  object_class->set_property     = gimp_image_undo_set_property;
89
88
  object_class->get_property     = gimp_image_undo_get_property;
90
89
 
144
143
{
145
144
}
146
145
 
147
 
static GObject *
148
 
gimp_image_undo_constructor (GType                  type,
149
 
                             guint                  n_params,
150
 
                             GObjectConstructParam *params)
 
146
static void
 
147
gimp_image_undo_constructed (GObject *object)
151
148
{
152
 
  GObject       *object;
153
 
  GimpImageUndo *image_undo;
 
149
  GimpImageUndo *image_undo = GIMP_IMAGE_UNDO (object);
154
150
  GimpImage     *image;
155
151
 
156
 
  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
157
 
 
158
 
  image_undo = GIMP_IMAGE_UNDO (object);
 
152
  if (G_OBJECT_CLASS (parent_class)->constructed)
 
153
    G_OBJECT_CLASS (parent_class)->constructed (object);
159
154
 
160
155
  image = GIMP_UNDO (object)->image;
161
156
 
198
193
    default:
199
194
      g_assert_not_reached ();
200
195
    }
201
 
 
202
 
  return object;
203
196
}
204
197
 
205
198
static void
301
294
                     GimpUndoMode         undo_mode,
302
295
                     GimpUndoAccumulator *accum)
303
296
{
304
 
  GimpImageUndo *image_undo = GIMP_IMAGE_UNDO (undo);
305
 
  GimpImage     *image      = undo->image;
 
297
  GimpImageUndo    *image_undo = GIMP_IMAGE_UNDO (undo);
 
298
  GimpImage        *image      = undo->image;
 
299
  GimpImagePrivate *private    = GIMP_IMAGE_GET_PRIVATE (image);
306
300
 
307
301
  GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
308
302
 
377
371
        if (ABS (image_undo->xresolution - xres) >= 1e-5 ||
378
372
            ABS (image_undo->yresolution - yres) >= 1e-5)
379
373
          {
380
 
            image->xresolution = image_undo->xresolution;
381
 
            image->yresolution = image_undo->yresolution;
 
374
            private->xresolution = image_undo->xresolution;
 
375
            private->yresolution = image_undo->yresolution;
382
376
 
383
377
            image_undo->xresolution = xres;
384
378
            image_undo->yresolution = yres;
392
386
          GimpUnit unit;
393
387
 
394
388
          unit = gimp_image_get_unit (image);
395
 
          image->resolution_unit = image_undo->resolution_unit;
 
389
          private->resolution_unit = image_undo->resolution_unit;
396
390
          image_undo->resolution_unit = unit;
397
391
 
398
392
          accum->unit_changed = TRUE;
403
397
      {
404
398
        GimpGrid *grid;
405
399
 
406
 
        grid = gimp_config_duplicate (GIMP_CONFIG (image->grid));
 
400
        grid = gimp_config_duplicate (GIMP_CONFIG (gimp_image_get_grid (image)));
407
401
 
408
402
        gimp_image_set_grid (image, image_undo->grid, FALSE);
409
403
 
443
437
          (gimp_image_parasite_find (image, image_undo->parasite_name));
444
438
 
445
439
        if (parasite)
446
 
          gimp_parasite_list_add (image->parasites, parasite);
 
440
          gimp_parasite_list_add (private->parasites, parasite);
447
441
        else
448
 
          gimp_parasite_list_remove (image->parasites,
 
442
          gimp_parasite_list_remove (private->parasites,
449
443
                                     image_undo->parasite_name);
450
444
 
451
445
        name = parasite ? parasite->name : image_undo->parasite_name;