~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/core/gimpdrawablemodundo.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GIMP - The GNU Image Manipulation Program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#include <glib-object.h>
 
22
 
 
23
#include "core-types.h"
 
24
 
 
25
#include "base/tile-manager.h"
 
26
 
 
27
#include "gimpimage.h"
 
28
#include "gimpdrawable.h"
 
29
#include "gimpdrawablemodundo.h"
 
30
 
 
31
 
 
32
static GObject * gimp_drawable_mod_undo_constructor (GType                  type,
 
33
                                                     guint                  n_params,
 
34
                                                     GObjectConstructParam *params);
 
35
 
 
36
static gint64    gimp_drawable_mod_undo_get_memsize (GimpObject            *object,
 
37
                                                     gint64                *gui_size);
 
38
 
 
39
static void      gimp_drawable_mod_undo_pop         (GimpUndo              *undo,
 
40
                                                     GimpUndoMode           undo_mode,
 
41
                                                     GimpUndoAccumulator   *accum);
 
42
static void      gimp_drawable_mod_undo_free        (GimpUndo              *undo,
 
43
                                                     GimpUndoMode           undo_mode);
 
44
 
 
45
 
 
46
G_DEFINE_TYPE (GimpDrawableModUndo, gimp_drawable_mod_undo, GIMP_TYPE_ITEM_UNDO)
 
47
 
 
48
#define parent_class gimp_drawable_mod_undo_parent_class
 
49
 
 
50
 
 
51
static void
 
52
gimp_drawable_mod_undo_class_init (GimpDrawableModUndoClass *klass)
 
53
{
 
54
  GObjectClass    *object_class      = G_OBJECT_CLASS (klass);
 
55
  GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
 
56
  GimpUndoClass   *undo_class        = GIMP_UNDO_CLASS (klass);
 
57
 
 
58
  object_class->constructor      = gimp_drawable_mod_undo_constructor;
 
59
 
 
60
  gimp_object_class->get_memsize = gimp_drawable_mod_undo_get_memsize;
 
61
 
 
62
  undo_class->pop                = gimp_drawable_mod_undo_pop;
 
63
  undo_class->free               = gimp_drawable_mod_undo_free;
 
64
}
 
65
 
 
66
static void
 
67
gimp_drawable_mod_undo_init (GimpDrawableModUndo *undo)
 
68
{
 
69
}
 
70
 
 
71
static GObject *
 
72
gimp_drawable_mod_undo_constructor (GType                  type,
 
73
                                    guint                  n_params,
 
74
                                    GObjectConstructParam *params)
 
75
{
 
76
  GObject             *object;
 
77
  GimpDrawableModUndo *drawable_mod_undo;
 
78
  GimpDrawable        *drawable;
 
79
 
 
80
  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
 
81
 
 
82
  drawable_mod_undo = GIMP_DRAWABLE_MOD_UNDO (object);
 
83
 
 
84
  g_assert (GIMP_IS_DRAWABLE (GIMP_ITEM_UNDO (object)->item));
 
85
 
 
86
  drawable = GIMP_DRAWABLE (GIMP_ITEM_UNDO (object)->item);
 
87
 
 
88
  drawable_mod_undo->tiles    = tile_manager_ref (drawable->tiles);
 
89
  drawable_mod_undo->type     = drawable->type;
 
90
  drawable_mod_undo->offset_x = GIMP_ITEM (drawable)->offset_x;
 
91
  drawable_mod_undo->offset_y = GIMP_ITEM (drawable)->offset_y;
 
92
 
 
93
  return object;
 
94
}
 
95
 
 
96
static gint64
 
97
gimp_drawable_mod_undo_get_memsize (GimpObject *object,
 
98
                                    gint64     *gui_size)
 
99
{
 
100
  GimpDrawableModUndo *drawable_mod_undo = GIMP_DRAWABLE_MOD_UNDO (object);
 
101
  gint64               memsize           = 0;
 
102
 
 
103
  if (drawable_mod_undo->tiles)
 
104
    memsize += tile_manager_get_memsize (drawable_mod_undo->tiles, FALSE);
 
105
 
 
106
  return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
 
107
                                                                  gui_size);
 
108
}
 
109
 
 
110
static void
 
111
gimp_drawable_mod_undo_pop (GimpUndo            *undo,
 
112
                            GimpUndoMode         undo_mode,
 
113
                            GimpUndoAccumulator *accum)
 
114
{
 
115
  GimpDrawableModUndo *drawable_mod_undo = GIMP_DRAWABLE_MOD_UNDO (undo);
 
116
  GimpDrawable        *drawable          = GIMP_DRAWABLE (GIMP_ITEM_UNDO (undo)->item);
 
117
  TileManager         *tiles;
 
118
  GimpImageType        type;
 
119
  gint                 offset_x, offset_y;
 
120
 
 
121
  GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
 
122
 
 
123
  tiles    = drawable_mod_undo->tiles;
 
124
  type     = drawable_mod_undo->type;
 
125
  offset_x = drawable_mod_undo->offset_x;
 
126
  offset_y = drawable_mod_undo->offset_y;
 
127
 
 
128
  drawable_mod_undo->tiles    = tile_manager_ref (drawable->tiles);
 
129
  drawable_mod_undo->type     = drawable->type;
 
130
  drawable_mod_undo->offset_x = GIMP_ITEM (drawable)->offset_x;
 
131
  drawable_mod_undo->offset_y = GIMP_ITEM (drawable)->offset_y;
 
132
 
 
133
  gimp_drawable_set_tiles_full (drawable, FALSE, NULL,
 
134
                                tiles, type, offset_x, offset_y);
 
135
  tile_manager_unref (tiles);
 
136
}
 
137
 
 
138
static void
 
139
gimp_drawable_mod_undo_free (GimpUndo     *undo,
 
140
                             GimpUndoMode  undo_mode)
 
141
{
 
142
  GimpDrawableModUndo *drawable_mod_undo = GIMP_DRAWABLE_MOD_UNDO (undo);
 
143
 
 
144
  if (drawable_mod_undo->tiles)
 
145
    {
 
146
      tile_manager_unref (drawable_mod_undo->tiles);
 
147
      drawable_mod_undo->tiles = NULL;
 
148
    }
 
149
 
 
150
  GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
 
151
}