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

« back to all changes in this revision

Viewing changes to app/paint/gimppaintcoreundo.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 "paint-types.h"
 
24
 
 
25
#include "gimppaintcore.h"
 
26
#include "gimppaintcoreundo.h"
 
27
 
 
28
 
 
29
enum
 
30
{
 
31
  PROP_0,
 
32
  PROP_PAINT_CORE
 
33
};
 
34
 
 
35
 
 
36
static GObject * gimp_paint_core_undo_constructor  (GType                  type,
 
37
                                                    guint                  n_params,
 
38
                                                    GObjectConstructParam *params);
 
39
static void      gimp_paint_core_undo_set_property (GObject               *object,
 
40
                                                    guint                  property_id,
 
41
                                                    const GValue          *value,
 
42
                                                    GParamSpec            *pspec);
 
43
static void      gimp_paint_core_undo_get_property (GObject               *object,
 
44
                                                    guint                  property_id,
 
45
                                                    GValue                *value,
 
46
                                                    GParamSpec            *pspec);
 
47
 
 
48
static void      gimp_paint_core_undo_pop          (GimpUndo              *undo,
 
49
                                                    GimpUndoMode           undo_mode,
 
50
                                                    GimpUndoAccumulator   *accum);
 
51
static void      gimp_paint_core_undo_free         (GimpUndo              *undo,
 
52
                                                    GimpUndoMode           undo_mode);
 
53
 
 
54
 
 
55
G_DEFINE_TYPE (GimpPaintCoreUndo, gimp_paint_core_undo, GIMP_TYPE_UNDO)
 
56
 
 
57
#define parent_class gimp_paint_core_undo_parent_class
 
58
 
 
59
 
 
60
static void
 
61
gimp_paint_core_undo_class_init (GimpPaintCoreUndoClass *klass)
 
62
{
 
63
  GObjectClass  *object_class = G_OBJECT_CLASS (klass);
 
64
  GimpUndoClass *undo_class   = GIMP_UNDO_CLASS (klass);
 
65
 
 
66
  object_class->constructor  = gimp_paint_core_undo_constructor;
 
67
  object_class->set_property = gimp_paint_core_undo_set_property;
 
68
  object_class->get_property = gimp_paint_core_undo_get_property;
 
69
 
 
70
  undo_class->pop            = gimp_paint_core_undo_pop;
 
71
  undo_class->free           = gimp_paint_core_undo_free;
 
72
 
 
73
  g_object_class_install_property (object_class, PROP_PAINT_CORE,
 
74
                                   g_param_spec_object ("paint-core", NULL, NULL,
 
75
                                                        GIMP_TYPE_PAINT_CORE,
 
76
                                                        GIMP_PARAM_READWRITE |
 
77
                                                        G_PARAM_CONSTRUCT_ONLY));
 
78
}
 
79
 
 
80
static void
 
81
gimp_paint_core_undo_init (GimpPaintCoreUndo *undo)
 
82
{
 
83
}
 
84
 
 
85
static GObject *
 
86
gimp_paint_core_undo_constructor (GType                  type,
 
87
                                  guint                  n_params,
 
88
                                  GObjectConstructParam *params)
 
89
{
 
90
  GObject           *object;
 
91
  GimpPaintCoreUndo *paint_core_undo;
 
92
 
 
93
  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
 
94
 
 
95
  paint_core_undo = GIMP_PAINT_CORE_UNDO (object);
 
96
 
 
97
  g_assert (GIMP_IS_PAINT_CORE (paint_core_undo->paint_core));
 
98
 
 
99
  paint_core_undo->last_coords = paint_core_undo->paint_core->start_coords;
 
100
 
 
101
  g_object_add_weak_pointer (G_OBJECT (paint_core_undo->paint_core),
 
102
                             (gpointer) &paint_core_undo->paint_core);
 
103
 
 
104
  return object;
 
105
}
 
106
 
 
107
static void
 
108
gimp_paint_core_undo_set_property (GObject      *object,
 
109
                                   guint         property_id,
 
110
                                   const GValue *value,
 
111
                                   GParamSpec   *pspec)
 
112
{
 
113
  GimpPaintCoreUndo *paint_core_undo = GIMP_PAINT_CORE_UNDO (object);
 
114
 
 
115
  switch (property_id)
 
116
    {
 
117
    case PROP_PAINT_CORE:
 
118
      paint_core_undo->paint_core = g_value_get_object (value);
 
119
      break;
 
120
 
 
121
    default:
 
122
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
123
      break;
 
124
    }
 
125
}
 
126
 
 
127
static void
 
128
gimp_paint_core_undo_get_property (GObject    *object,
 
129
                                   guint       property_id,
 
130
                                   GValue     *value,
 
131
                                   GParamSpec *pspec)
 
132
{
 
133
  GimpPaintCoreUndo *paint_core_undo = GIMP_PAINT_CORE_UNDO (object);
 
134
 
 
135
  switch (property_id)
 
136
    {
 
137
    case PROP_PAINT_CORE:
 
138
      g_value_set_object (value, paint_core_undo->paint_core);
 
139
      break;
 
140
 
 
141
    default:
 
142
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
143
      break;
 
144
    }
 
145
}
 
146
 
 
147
static void
 
148
gimp_paint_core_undo_pop (GimpUndo              *undo,
 
149
                          GimpUndoMode           undo_mode,
 
150
                          GimpUndoAccumulator   *accum)
 
151
{
 
152
  GimpPaintCoreUndo *paint_core_undo = GIMP_PAINT_CORE_UNDO (undo);
 
153
 
 
154
  GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
 
155
 
 
156
  /*  only pop if the core still exists  */
 
157
  if (paint_core_undo->paint_core)
 
158
    {
 
159
      GimpCoords tmp_coords;
 
160
 
 
161
      tmp_coords = paint_core_undo->paint_core->last_coords;
 
162
      paint_core_undo->paint_core->last_coords = paint_core_undo->last_coords;
 
163
      paint_core_undo->last_coords = tmp_coords;
 
164
    }
 
165
}
 
166
 
 
167
static void
 
168
gimp_paint_core_undo_free (GimpUndo     *undo,
 
169
                           GimpUndoMode  undo_mode)
 
170
{
 
171
  GimpPaintCoreUndo *paint_core_undo = GIMP_PAINT_CORE_UNDO (undo);
 
172
 
 
173
  if (paint_core_undo->paint_core)
 
174
    {
 
175
      g_object_remove_weak_pointer (G_OBJECT (paint_core_undo->paint_core),
 
176
                                    (gpointer) &paint_core_undo->paint_core);
 
177
      paint_core_undo->paint_core = NULL;
 
178
    }
 
179
 
 
180
  GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
 
181
}