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 3 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, see <https://www.gnu.org/licenses/>.
16 */
17
18 #include "config.h"
19
20 #include <gdk-pixbuf/gdk-pixbuf.h>
21 #include <gegl.h>
22
23 #include "libgimpbase/gimpbase.h"
24
25 #include "core-types.h"
26
27 #include "gimp.h"
28 #include "gimpchannelpropundo.h"
29 #include "gimpchannelundo.h"
30 #include "gimpdrawablemodundo.h"
31 #include "gimpdrawableundo.h"
32 #include "gimpfloatingselectionundo.h"
33 #include "gimpgrid.h"
34 #include "gimpgrouplayer.h"
35 #include "gimpgrouplayerundo.h"
36 #include "gimpguide.h"
37 #include "gimpguideundo.h"
38 #include "gimpimage.h"
39 #include "gimpimage-undo.h"
40 #include "gimpimage-undo-push.h"
41 #include "gimpimageundo.h"
42 #include "gimpitempropundo.h"
43 #include "gimplayermask.h"
44 #include "gimplayermaskpropundo.h"
45 #include "gimplayermaskundo.h"
46 #include "gimplayerpropundo.h"
47 #include "gimplayerundo.h"
48 #include "gimpmaskundo.h"
49 #include "gimpsamplepoint.h"
50 #include "gimpsamplepointundo.h"
51 #include "gimpselection.h"
52
53 #include "text/gimptextlayer.h"
54 #include "text/gimptextundo.h"
55
56 #include "vectors/gimpvectors.h"
57 #include "vectors/gimpvectorsmodundo.h"
58 #include "vectors/gimpvectorspropundo.h"
59 #include "vectors/gimpvectorsundo.h"
60
61 #include "gimp-intl.h"
62
63
64 /**************************/
65 /* Image Property Undos */
66 /**************************/
67
68 GimpUndo *
gimp_image_undo_push_image_type(GimpImage * image,const gchar * undo_desc)69 gimp_image_undo_push_image_type (GimpImage *image,
70 const gchar *undo_desc)
71 {
72 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
73
74 return gimp_image_undo_push (image, GIMP_TYPE_IMAGE_UNDO,
75 GIMP_UNDO_IMAGE_TYPE, undo_desc,
76 GIMP_DIRTY_IMAGE,
77 NULL);
78 }
79
80 GimpUndo *
gimp_image_undo_push_image_precision(GimpImage * image,const gchar * undo_desc)81 gimp_image_undo_push_image_precision (GimpImage *image,
82 const gchar *undo_desc)
83 {
84 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
85
86 return gimp_image_undo_push (image, GIMP_TYPE_IMAGE_UNDO,
87 GIMP_UNDO_IMAGE_PRECISION, undo_desc,
88 GIMP_DIRTY_IMAGE,
89 NULL);
90 }
91
92 GimpUndo *
gimp_image_undo_push_image_size(GimpImage * image,const gchar * undo_desc,gint previous_origin_x,gint previous_origin_y,gint previous_width,gint previous_height)93 gimp_image_undo_push_image_size (GimpImage *image,
94 const gchar *undo_desc,
95 gint previous_origin_x,
96 gint previous_origin_y,
97 gint previous_width,
98 gint previous_height)
99 {
100 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
101
102 return gimp_image_undo_push (image, GIMP_TYPE_IMAGE_UNDO,
103 GIMP_UNDO_IMAGE_SIZE, undo_desc,
104 GIMP_DIRTY_IMAGE | GIMP_DIRTY_IMAGE_SIZE,
105 "previous-origin-x", previous_origin_x,
106 "previous-origin-y", previous_origin_y,
107 "previous-width", previous_width,
108 "previous-height", previous_height,
109 NULL);
110 }
111
112 GimpUndo *
gimp_image_undo_push_image_resolution(GimpImage * image,const gchar * undo_desc)113 gimp_image_undo_push_image_resolution (GimpImage *image,
114 const gchar *undo_desc)
115 {
116 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
117
118 return gimp_image_undo_push (image, GIMP_TYPE_IMAGE_UNDO,
119 GIMP_UNDO_IMAGE_RESOLUTION, undo_desc,
120 GIMP_DIRTY_IMAGE,
121 NULL);
122 }
123
124 GimpUndo *
gimp_image_undo_push_image_grid(GimpImage * image,const gchar * undo_desc,GimpGrid * grid)125 gimp_image_undo_push_image_grid (GimpImage *image,
126 const gchar *undo_desc,
127 GimpGrid *grid)
128 {
129 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
130 g_return_val_if_fail (GIMP_IS_GRID (grid), NULL);
131
132 return gimp_image_undo_push (image, GIMP_TYPE_IMAGE_UNDO,
133 GIMP_UNDO_IMAGE_GRID, undo_desc,
134 GIMP_DIRTY_IMAGE_META,
135 "grid", grid,
136 NULL);
137 }
138
139 GimpUndo *
gimp_image_undo_push_image_colormap(GimpImage * image,const gchar * undo_desc)140 gimp_image_undo_push_image_colormap (GimpImage *image,
141 const gchar *undo_desc)
142 {
143 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
144
145 return gimp_image_undo_push (image, GIMP_TYPE_IMAGE_UNDO,
146 GIMP_UNDO_IMAGE_COLORMAP, undo_desc,
147 GIMP_DIRTY_IMAGE,
148 NULL);
149 }
150
151 GimpUndo *
gimp_image_undo_push_image_color_managed(GimpImage * image,const gchar * undo_desc)152 gimp_image_undo_push_image_color_managed (GimpImage *image,
153 const gchar *undo_desc)
154 {
155 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
156
157 return gimp_image_undo_push (image, GIMP_TYPE_IMAGE_UNDO,
158 GIMP_UNDO_IMAGE_COLOR_MANAGED, undo_desc,
159 GIMP_DIRTY_IMAGE,
160 NULL);
161 }
162
163 GimpUndo *
gimp_image_undo_push_image_metadata(GimpImage * image,const gchar * undo_desc)164 gimp_image_undo_push_image_metadata (GimpImage *image,
165 const gchar *undo_desc)
166 {
167 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
168
169 return gimp_image_undo_push (image, GIMP_TYPE_IMAGE_UNDO,
170 GIMP_UNDO_IMAGE_METADATA, undo_desc,
171 GIMP_DIRTY_IMAGE_META,
172 NULL);
173 }
174
175 GimpUndo *
gimp_image_undo_push_image_parasite(GimpImage * image,const gchar * undo_desc,const GimpParasite * parasite)176 gimp_image_undo_push_image_parasite (GimpImage *image,
177 const gchar *undo_desc,
178 const GimpParasite *parasite)
179 {
180 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
181 g_return_val_if_fail (parasite != NULL, NULL);
182
183 return gimp_image_undo_push (image, GIMP_TYPE_IMAGE_UNDO,
184 GIMP_UNDO_PARASITE_ATTACH, undo_desc,
185 GIMP_DIRTY_IMAGE_META,
186 "parasite-name", gimp_parasite_name (parasite),
187 NULL);
188 }
189
190 GimpUndo *
gimp_image_undo_push_image_parasite_remove(GimpImage * image,const gchar * undo_desc,const gchar * name)191 gimp_image_undo_push_image_parasite_remove (GimpImage *image,
192 const gchar *undo_desc,
193 const gchar *name)
194 {
195 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
196 g_return_val_if_fail (name != NULL, NULL);
197
198 return gimp_image_undo_push (image, GIMP_TYPE_IMAGE_UNDO,
199 GIMP_UNDO_PARASITE_REMOVE, undo_desc,
200 GIMP_DIRTY_IMAGE_META,
201 "parasite-name", name,
202 NULL);
203 }
204
205
206 /********************************/
207 /* Guide & Sample Point Undos */
208 /********************************/
209
210 GimpUndo *
gimp_image_undo_push_guide(GimpImage * image,const gchar * undo_desc,GimpGuide * guide)211 gimp_image_undo_push_guide (GimpImage *image,
212 const gchar *undo_desc,
213 GimpGuide *guide)
214 {
215 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
216 g_return_val_if_fail (GIMP_IS_GUIDE (guide), NULL);
217
218 return gimp_image_undo_push (image, GIMP_TYPE_GUIDE_UNDO,
219 GIMP_UNDO_GUIDE, undo_desc,
220 GIMP_DIRTY_IMAGE_META,
221 "aux-item", guide,
222 NULL);
223 }
224
225 GimpUndo *
gimp_image_undo_push_sample_point(GimpImage * image,const gchar * undo_desc,GimpSamplePoint * sample_point)226 gimp_image_undo_push_sample_point (GimpImage *image,
227 const gchar *undo_desc,
228 GimpSamplePoint *sample_point)
229 {
230 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
231 g_return_val_if_fail (GIMP_IS_SAMPLE_POINT (sample_point), NULL);
232
233 return gimp_image_undo_push (image, GIMP_TYPE_SAMPLE_POINT_UNDO,
234 GIMP_UNDO_SAMPLE_POINT, undo_desc,
235 GIMP_DIRTY_IMAGE_META,
236 "aux-item", sample_point,
237 NULL);
238 }
239
240
241 /********************/
242 /* Drawable Undos */
243 /********************/
244
245 GimpUndo *
gimp_image_undo_push_drawable(GimpImage * image,const gchar * undo_desc,GimpDrawable * drawable,GeglBuffer * buffer,gint x,gint y)246 gimp_image_undo_push_drawable (GimpImage *image,
247 const gchar *undo_desc,
248 GimpDrawable *drawable,
249 GeglBuffer *buffer,
250 gint x,
251 gint y)
252 {
253 GimpItem *item;
254
255 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
256 g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
257 g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
258
259 item = GIMP_ITEM (drawable);
260
261 g_return_val_if_fail (gimp_item_is_attached (item), NULL);
262
263 return gimp_image_undo_push (image, GIMP_TYPE_DRAWABLE_UNDO,
264 GIMP_UNDO_DRAWABLE, undo_desc,
265 GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
266 "item", item,
267 "buffer", buffer,
268 "x", x,
269 "y", y,
270 NULL);
271 }
272
273 GimpUndo *
gimp_image_undo_push_drawable_mod(GimpImage * image,const gchar * undo_desc,GimpDrawable * drawable,gboolean copy_buffer)274 gimp_image_undo_push_drawable_mod (GimpImage *image,
275 const gchar *undo_desc,
276 GimpDrawable *drawable,
277 gboolean copy_buffer)
278 {
279 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
280 g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
281 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
282
283 return gimp_image_undo_push (image, GIMP_TYPE_DRAWABLE_MOD_UNDO,
284 GIMP_UNDO_DRAWABLE_MOD, undo_desc,
285 GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
286 "item", drawable,
287 "copy-buffer", copy_buffer,
288 NULL);
289 }
290
291
292 /****************/
293 /* Mask Undos */
294 /****************/
295
296 GimpUndo *
gimp_image_undo_push_mask(GimpImage * image,const gchar * undo_desc,GimpChannel * mask)297 gimp_image_undo_push_mask (GimpImage *image,
298 const gchar *undo_desc,
299 GimpChannel *mask)
300 {
301 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
302 g_return_val_if_fail (GIMP_IS_CHANNEL (mask), NULL);
303 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (mask)), NULL);
304
305 return gimp_image_undo_push (image, GIMP_TYPE_MASK_UNDO,
306 GIMP_UNDO_MASK, undo_desc,
307 GIMP_IS_SELECTION (mask) ?
308 GIMP_DIRTY_SELECTION :
309 GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
310 "item", mask,
311 NULL);
312 }
313
314 GimpUndo *
gimp_image_undo_push_mask_precision(GimpImage * image,const gchar * undo_desc,GimpChannel * mask)315 gimp_image_undo_push_mask_precision (GimpImage *image,
316 const gchar *undo_desc,
317 GimpChannel *mask)
318 {
319 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
320 g_return_val_if_fail (GIMP_IS_CHANNEL (mask), NULL);
321 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (mask)), NULL);
322
323 return gimp_image_undo_push (image, GIMP_TYPE_MASK_UNDO,
324 GIMP_UNDO_MASK, undo_desc,
325 GIMP_IS_SELECTION (mask) ?
326 GIMP_DIRTY_SELECTION :
327 GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
328 "item", mask,
329 "convert-format", TRUE,
330 NULL);
331 }
332
333
334 /****************/
335 /* Item Undos */
336 /****************/
337
338 GimpUndo *
gimp_image_undo_push_item_reorder(GimpImage * image,const gchar * undo_desc,GimpItem * item)339 gimp_image_undo_push_item_reorder (GimpImage *image,
340 const gchar *undo_desc,
341 GimpItem *item)
342 {
343 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
344 g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
345 g_return_val_if_fail (gimp_item_is_attached (item), NULL);
346
347 return gimp_image_undo_push (image, GIMP_TYPE_ITEM_PROP_UNDO,
348 GIMP_UNDO_ITEM_REORDER, undo_desc,
349 GIMP_DIRTY_IMAGE_STRUCTURE,
350 "item", item,
351 NULL);
352 }
353
354 GimpUndo *
gimp_image_undo_push_item_rename(GimpImage * image,const gchar * undo_desc,GimpItem * item)355 gimp_image_undo_push_item_rename (GimpImage *image,
356 const gchar *undo_desc,
357 GimpItem *item)
358 {
359 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
360 g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
361 g_return_val_if_fail (gimp_item_is_attached (item), NULL);
362
363 return gimp_image_undo_push (image, GIMP_TYPE_ITEM_PROP_UNDO,
364 GIMP_UNDO_ITEM_RENAME, undo_desc,
365 GIMP_DIRTY_ITEM_META,
366 "item", item,
367 NULL);
368 }
369
370 GimpUndo *
gimp_image_undo_push_item_displace(GimpImage * image,const gchar * undo_desc,GimpItem * item)371 gimp_image_undo_push_item_displace (GimpImage *image,
372 const gchar *undo_desc,
373 GimpItem *item)
374 {
375 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
376 g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
377 g_return_val_if_fail (gimp_item_is_attached (item), NULL);
378
379 return gimp_image_undo_push (image, GIMP_TYPE_ITEM_PROP_UNDO,
380 GIMP_UNDO_ITEM_DISPLACE, undo_desc,
381 GIMP_IS_DRAWABLE (item) ?
382 GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE :
383 GIMP_DIRTY_ITEM | GIMP_DIRTY_VECTORS,
384 "item", item,
385 NULL);
386 }
387
388 GimpUndo *
gimp_image_undo_push_item_visibility(GimpImage * image,const gchar * undo_desc,GimpItem * item)389 gimp_image_undo_push_item_visibility (GimpImage *image,
390 const gchar *undo_desc,
391 GimpItem *item)
392 {
393 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
394 g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
395 g_return_val_if_fail (gimp_item_is_attached (item), NULL);
396
397 return gimp_image_undo_push (image, GIMP_TYPE_ITEM_PROP_UNDO,
398 GIMP_UNDO_ITEM_VISIBILITY, undo_desc,
399 GIMP_DIRTY_ITEM_META,
400 "item", item,
401 NULL);
402 }
403
404 GimpUndo *
gimp_image_undo_push_item_linked(GimpImage * image,const gchar * undo_desc,GimpItem * item)405 gimp_image_undo_push_item_linked (GimpImage *image,
406 const gchar *undo_desc,
407 GimpItem *item)
408 {
409 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
410 g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
411 g_return_val_if_fail (gimp_item_is_attached (item), NULL);
412
413 return gimp_image_undo_push (image, GIMP_TYPE_ITEM_PROP_UNDO,
414 GIMP_UNDO_ITEM_LINKED, undo_desc,
415 GIMP_DIRTY_ITEM_META,
416 "item", item,
417 NULL);
418 }
419
420 GimpUndo *
gimp_image_undo_push_item_color_tag(GimpImage * image,const gchar * undo_desc,GimpItem * item)421 gimp_image_undo_push_item_color_tag (GimpImage *image,
422 const gchar *undo_desc,
423 GimpItem *item)
424 {
425 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
426 g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
427 g_return_val_if_fail (gimp_item_is_attached (item), NULL);
428
429 return gimp_image_undo_push (image, GIMP_TYPE_ITEM_PROP_UNDO,
430 GIMP_UNDO_ITEM_COLOR_TAG, undo_desc,
431 GIMP_DIRTY_ITEM_META,
432 "item", item,
433 NULL);
434 }
435
436 GimpUndo *
gimp_image_undo_push_item_lock_content(GimpImage * image,const gchar * undo_desc,GimpItem * item)437 gimp_image_undo_push_item_lock_content (GimpImage *image,
438 const gchar *undo_desc,
439 GimpItem *item)
440 {
441 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
442 g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
443 g_return_val_if_fail (gimp_item_is_attached (item), NULL);
444
445 return gimp_image_undo_push (image, GIMP_TYPE_ITEM_PROP_UNDO,
446 GIMP_UNDO_ITEM_LOCK_CONTENT, undo_desc,
447 GIMP_DIRTY_ITEM_META,
448 "item", item,
449 NULL);
450 }
451
452 GimpUndo *
gimp_image_undo_push_item_lock_position(GimpImage * image,const gchar * undo_desc,GimpItem * item)453 gimp_image_undo_push_item_lock_position (GimpImage *image,
454 const gchar *undo_desc,
455 GimpItem *item)
456 {
457 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
458 g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
459 g_return_val_if_fail (gimp_item_is_attached (item), NULL);
460
461 return gimp_image_undo_push (image, GIMP_TYPE_ITEM_PROP_UNDO,
462 GIMP_UNDO_ITEM_LOCK_POSITION, undo_desc,
463 GIMP_DIRTY_ITEM_META,
464 "item", item,
465 NULL);
466 }
467
468 GimpUndo *
gimp_image_undo_push_item_parasite(GimpImage * image,const gchar * undo_desc,GimpItem * item,const GimpParasite * parasite)469 gimp_image_undo_push_item_parasite (GimpImage *image,
470 const gchar *undo_desc,
471 GimpItem *item,
472 const GimpParasite *parasite)
473 {
474 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
475 g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
476 g_return_val_if_fail (gimp_item_is_attached (item), NULL);
477 g_return_val_if_fail (parasite != NULL, NULL);
478
479 return gimp_image_undo_push (image, GIMP_TYPE_ITEM_PROP_UNDO,
480 GIMP_UNDO_PARASITE_ATTACH, undo_desc,
481 GIMP_DIRTY_ITEM_META,
482 "item", item,
483 "parasite-name", gimp_parasite_name (parasite),
484 NULL);
485 }
486
487 GimpUndo *
gimp_image_undo_push_item_parasite_remove(GimpImage * image,const gchar * undo_desc,GimpItem * item,const gchar * name)488 gimp_image_undo_push_item_parasite_remove (GimpImage *image,
489 const gchar *undo_desc,
490 GimpItem *item,
491 const gchar *name)
492 {
493 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
494 g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
495 g_return_val_if_fail (gimp_item_is_attached (item), NULL);
496 g_return_val_if_fail (name != NULL, NULL);
497
498 return gimp_image_undo_push (image, GIMP_TYPE_ITEM_PROP_UNDO,
499 GIMP_UNDO_PARASITE_REMOVE, undo_desc,
500 GIMP_DIRTY_ITEM_META,
501 "item", item,
502 "parasite-name", name,
503 NULL);
504 }
505
506
507 /*****************/
508 /* Layer Undos */
509 /*****************/
510
511 GimpUndo *
gimp_image_undo_push_layer_add(GimpImage * image,const gchar * undo_desc,GimpLayer * layer,GimpLayer * prev_layer)512 gimp_image_undo_push_layer_add (GimpImage *image,
513 const gchar *undo_desc,
514 GimpLayer *layer,
515 GimpLayer *prev_layer)
516 {
517 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
518 g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
519 g_return_val_if_fail (! gimp_item_is_attached (GIMP_ITEM (layer)), NULL);
520 g_return_val_if_fail (prev_layer == NULL || GIMP_IS_LAYER (prev_layer),
521 NULL);
522
523 return gimp_image_undo_push (image, GIMP_TYPE_LAYER_UNDO,
524 GIMP_UNDO_LAYER_ADD, undo_desc,
525 GIMP_DIRTY_IMAGE_STRUCTURE,
526 "item", layer,
527 "prev-layer", prev_layer,
528 NULL);
529 }
530
531 GimpUndo *
gimp_image_undo_push_layer_remove(GimpImage * image,const gchar * undo_desc,GimpLayer * layer,GimpLayer * prev_parent,gint prev_position,GimpLayer * prev_layer)532 gimp_image_undo_push_layer_remove (GimpImage *image,
533 const gchar *undo_desc,
534 GimpLayer *layer,
535 GimpLayer *prev_parent,
536 gint prev_position,
537 GimpLayer *prev_layer)
538 {
539 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
540 g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
541 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL);
542 g_return_val_if_fail (prev_parent == NULL || GIMP_IS_LAYER (prev_parent),
543 NULL);
544 g_return_val_if_fail (prev_layer == NULL || GIMP_IS_LAYER (prev_layer),
545 NULL);
546
547 return gimp_image_undo_push (image, GIMP_TYPE_LAYER_UNDO,
548 GIMP_UNDO_LAYER_REMOVE, undo_desc,
549 GIMP_DIRTY_IMAGE_STRUCTURE,
550 "item", layer,
551 "prev-parent", prev_parent,
552 "prev-position", prev_position,
553 "prev-layer", prev_layer,
554 NULL);
555 }
556
557 GimpUndo *
gimp_image_undo_push_layer_mode(GimpImage * image,const gchar * undo_desc,GimpLayer * layer)558 gimp_image_undo_push_layer_mode (GimpImage *image,
559 const gchar *undo_desc,
560 GimpLayer *layer)
561 {
562 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
563 g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
564 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL);
565
566 return gimp_image_undo_push (image, GIMP_TYPE_LAYER_PROP_UNDO,
567 GIMP_UNDO_LAYER_MODE, undo_desc,
568 GIMP_DIRTY_ITEM_META,
569 "item", layer,
570 NULL);
571 }
572
573 GimpUndo *
gimp_image_undo_push_layer_opacity(GimpImage * image,const gchar * undo_desc,GimpLayer * layer)574 gimp_image_undo_push_layer_opacity (GimpImage *image,
575 const gchar *undo_desc,
576 GimpLayer *layer)
577 {
578 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
579 g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
580 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL);
581
582 return gimp_image_undo_push (image, GIMP_TYPE_LAYER_PROP_UNDO,
583 GIMP_UNDO_LAYER_OPACITY, undo_desc,
584 GIMP_DIRTY_ITEM_META,
585 "item", layer,
586 NULL);
587 }
588
589 GimpUndo *
gimp_image_undo_push_layer_lock_alpha(GimpImage * image,const gchar * undo_desc,GimpLayer * layer)590 gimp_image_undo_push_layer_lock_alpha (GimpImage *image,
591 const gchar *undo_desc,
592 GimpLayer *layer)
593 {
594 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
595 g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
596 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL);
597
598 return gimp_image_undo_push (image, GIMP_TYPE_LAYER_PROP_UNDO,
599 GIMP_UNDO_LAYER_LOCK_ALPHA, undo_desc,
600 GIMP_DIRTY_ITEM_META,
601 "item", layer,
602 NULL);
603 }
604
605
606 /***********************/
607 /* Group Layer Undos */
608 /***********************/
609
610 GimpUndo *
gimp_image_undo_push_group_layer_suspend_resize(GimpImage * image,const gchar * undo_desc,GimpGroupLayer * group)611 gimp_image_undo_push_group_layer_suspend_resize (GimpImage *image,
612 const gchar *undo_desc,
613 GimpGroupLayer *group)
614 {
615 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
616 g_return_val_if_fail (GIMP_IS_GROUP_LAYER (group), NULL);
617 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (group)), NULL);
618
619 return gimp_image_undo_push (image, GIMP_TYPE_GROUP_LAYER_UNDO,
620 GIMP_UNDO_GROUP_LAYER_SUSPEND_RESIZE, undo_desc,
621 GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
622 "item", group,
623 NULL);
624 }
625
626 GimpUndo *
gimp_image_undo_push_group_layer_resume_resize(GimpImage * image,const gchar * undo_desc,GimpGroupLayer * group)627 gimp_image_undo_push_group_layer_resume_resize (GimpImage *image,
628 const gchar *undo_desc,
629 GimpGroupLayer *group)
630 {
631 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
632 g_return_val_if_fail (GIMP_IS_GROUP_LAYER (group), NULL);
633 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (group)), NULL);
634
635 return gimp_image_undo_push (image, GIMP_TYPE_GROUP_LAYER_UNDO,
636 GIMP_UNDO_GROUP_LAYER_RESUME_RESIZE, undo_desc,
637 GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
638 "item", group,
639 NULL);
640 }
641
642 GimpUndo *
gimp_image_undo_push_group_layer_suspend_mask(GimpImage * image,const gchar * undo_desc,GimpGroupLayer * group)643 gimp_image_undo_push_group_layer_suspend_mask (GimpImage *image,
644 const gchar *undo_desc,
645 GimpGroupLayer *group)
646 {
647 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
648 g_return_val_if_fail (GIMP_IS_GROUP_LAYER (group), NULL);
649 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (group)), NULL);
650
651 return gimp_image_undo_push (image, GIMP_TYPE_GROUP_LAYER_UNDO,
652 GIMP_UNDO_GROUP_LAYER_SUSPEND_MASK, undo_desc,
653 GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
654 "item", group,
655 NULL);
656 }
657
658 GimpUndo *
gimp_image_undo_push_group_layer_resume_mask(GimpImage * image,const gchar * undo_desc,GimpGroupLayer * group)659 gimp_image_undo_push_group_layer_resume_mask (GimpImage *image,
660 const gchar *undo_desc,
661 GimpGroupLayer *group)
662 {
663 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
664 g_return_val_if_fail (GIMP_IS_GROUP_LAYER (group), NULL);
665 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (group)), NULL);
666
667 return gimp_image_undo_push (image, GIMP_TYPE_GROUP_LAYER_UNDO,
668 GIMP_UNDO_GROUP_LAYER_RESUME_MASK, undo_desc,
669 GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
670 "item", group,
671 NULL);
672 }
673
674 GimpUndo *
gimp_image_undo_push_group_layer_start_transform(GimpImage * image,const gchar * undo_desc,GimpGroupLayer * group)675 gimp_image_undo_push_group_layer_start_transform (GimpImage *image,
676 const gchar *undo_desc,
677 GimpGroupLayer *group)
678 {
679 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
680 g_return_val_if_fail (GIMP_IS_GROUP_LAYER (group), NULL);
681 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (group)), NULL);
682
683 return gimp_image_undo_push (image, GIMP_TYPE_GROUP_LAYER_UNDO,
684 GIMP_UNDO_GROUP_LAYER_START_TRANSFORM, undo_desc,
685 GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
686 "item", group,
687 NULL);
688 }
689
690 GimpUndo *
gimp_image_undo_push_group_layer_end_transform(GimpImage * image,const gchar * undo_desc,GimpGroupLayer * group)691 gimp_image_undo_push_group_layer_end_transform (GimpImage *image,
692 const gchar *undo_desc,
693 GimpGroupLayer *group)
694 {
695 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
696 g_return_val_if_fail (GIMP_IS_GROUP_LAYER (group), NULL);
697 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (group)), NULL);
698
699 return gimp_image_undo_push (image, GIMP_TYPE_GROUP_LAYER_UNDO,
700 GIMP_UNDO_GROUP_LAYER_END_TRANSFORM, undo_desc,
701 GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
702 "item", group,
703 NULL);
704 }
705
706 GimpUndo *
gimp_image_undo_push_group_layer_convert(GimpImage * image,const gchar * undo_desc,GimpGroupLayer * group)707 gimp_image_undo_push_group_layer_convert (GimpImage *image,
708 const gchar *undo_desc,
709 GimpGroupLayer *group)
710 {
711 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
712 g_return_val_if_fail (GIMP_IS_GROUP_LAYER (group), NULL);
713 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (group)), NULL);
714
715 return gimp_image_undo_push (image, GIMP_TYPE_GROUP_LAYER_UNDO,
716 GIMP_UNDO_GROUP_LAYER_CONVERT, undo_desc,
717 GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
718 "item", group,
719 NULL);
720 }
721
722
723 /**********************/
724 /* Text Layer Undos */
725 /**********************/
726
727 GimpUndo *
gimp_image_undo_push_text_layer(GimpImage * image,const gchar * undo_desc,GimpTextLayer * layer,const GParamSpec * pspec)728 gimp_image_undo_push_text_layer (GimpImage *image,
729 const gchar *undo_desc,
730 GimpTextLayer *layer,
731 const GParamSpec *pspec)
732 {
733 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
734 g_return_val_if_fail (GIMP_IS_TEXT_LAYER (layer), NULL);
735 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL);
736
737 return gimp_image_undo_push (image, GIMP_TYPE_TEXT_UNDO,
738 GIMP_UNDO_TEXT_LAYER, undo_desc,
739 GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
740 "item", layer,
741 "param", pspec,
742 NULL);
743 }
744
745 GimpUndo *
gimp_image_undo_push_text_layer_modified(GimpImage * image,const gchar * undo_desc,GimpTextLayer * layer)746 gimp_image_undo_push_text_layer_modified (GimpImage *image,
747 const gchar *undo_desc,
748 GimpTextLayer *layer)
749 {
750 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
751 g_return_val_if_fail (GIMP_IS_TEXT_LAYER (layer), NULL);
752 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL);
753
754 return gimp_image_undo_push (image, GIMP_TYPE_TEXT_UNDO,
755 GIMP_UNDO_TEXT_LAYER_MODIFIED, undo_desc,
756 GIMP_DIRTY_ITEM_META,
757 "item", layer,
758 NULL);
759 }
760
761 GimpUndo *
gimp_image_undo_push_text_layer_convert(GimpImage * image,const gchar * undo_desc,GimpTextLayer * layer)762 gimp_image_undo_push_text_layer_convert (GimpImage *image,
763 const gchar *undo_desc,
764 GimpTextLayer *layer)
765 {
766 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
767 g_return_val_if_fail (GIMP_IS_TEXT_LAYER (layer), NULL);
768 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL);
769
770 return gimp_image_undo_push (image, GIMP_TYPE_TEXT_UNDO,
771 GIMP_UNDO_TEXT_LAYER_CONVERT, undo_desc,
772 GIMP_DIRTY_ITEM,
773 "item", layer,
774 NULL);
775 }
776
777
778 /**********************/
779 /* Layer Mask Undos */
780 /**********************/
781
782 GimpUndo *
gimp_image_undo_push_layer_mask_add(GimpImage * image,const gchar * undo_desc,GimpLayer * layer,GimpLayerMask * mask)783 gimp_image_undo_push_layer_mask_add (GimpImage *image,
784 const gchar *undo_desc,
785 GimpLayer *layer,
786 GimpLayerMask *mask)
787 {
788 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
789 g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
790 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL);
791 g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), NULL);
792 g_return_val_if_fail (! gimp_item_is_attached (GIMP_ITEM (mask)), NULL);
793
794 return gimp_image_undo_push (image, GIMP_TYPE_LAYER_MASK_UNDO,
795 GIMP_UNDO_LAYER_MASK_ADD, undo_desc,
796 GIMP_DIRTY_IMAGE_STRUCTURE,
797 "item", layer,
798 "layer-mask", mask,
799 NULL);
800 }
801
802 GimpUndo *
gimp_image_undo_push_layer_mask_remove(GimpImage * image,const gchar * undo_desc,GimpLayer * layer,GimpLayerMask * mask)803 gimp_image_undo_push_layer_mask_remove (GimpImage *image,
804 const gchar *undo_desc,
805 GimpLayer *layer,
806 GimpLayerMask *mask)
807 {
808 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
809 g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
810 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL);
811 g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), NULL);
812 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (mask)), NULL);
813 g_return_val_if_fail (gimp_layer_mask_get_layer (mask) == layer, NULL);
814 g_return_val_if_fail (gimp_layer_get_mask (layer) == mask, NULL);
815
816 return gimp_image_undo_push (image, GIMP_TYPE_LAYER_MASK_UNDO,
817 GIMP_UNDO_LAYER_MASK_REMOVE, undo_desc,
818 GIMP_DIRTY_IMAGE_STRUCTURE,
819 "item", layer,
820 "layer-mask", mask,
821 NULL);
822 }
823
824 GimpUndo *
gimp_image_undo_push_layer_mask_apply(GimpImage * image,const gchar * undo_desc,GimpLayer * layer)825 gimp_image_undo_push_layer_mask_apply (GimpImage *image,
826 const gchar *undo_desc,
827 GimpLayer *layer)
828 {
829 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
830 g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
831 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL);
832
833 return gimp_image_undo_push (image, GIMP_TYPE_LAYER_MASK_PROP_UNDO,
834 GIMP_UNDO_LAYER_MASK_APPLY, undo_desc,
835 GIMP_DIRTY_ITEM_META,
836 "item", layer,
837 NULL);
838 }
839
840 GimpUndo *
gimp_image_undo_push_layer_mask_show(GimpImage * image,const gchar * undo_desc,GimpLayer * layer)841 gimp_image_undo_push_layer_mask_show (GimpImage *image,
842 const gchar *undo_desc,
843 GimpLayer *layer)
844 {
845 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
846 g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
847 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL);
848
849 return gimp_image_undo_push (image, GIMP_TYPE_LAYER_MASK_PROP_UNDO,
850 GIMP_UNDO_LAYER_MASK_SHOW, undo_desc,
851 GIMP_DIRTY_ITEM_META,
852 "item", layer,
853 NULL);
854 }
855
856
857 /*******************/
858 /* Channel Undos */
859 /*******************/
860
861 GimpUndo *
gimp_image_undo_push_channel_add(GimpImage * image,const gchar * undo_desc,GimpChannel * channel,GimpChannel * prev_channel)862 gimp_image_undo_push_channel_add (GimpImage *image,
863 const gchar *undo_desc,
864 GimpChannel *channel,
865 GimpChannel *prev_channel)
866 {
867 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
868 g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);
869 g_return_val_if_fail (! gimp_item_is_attached (GIMP_ITEM (channel)), NULL);
870 g_return_val_if_fail (prev_channel == NULL || GIMP_IS_CHANNEL (prev_channel),
871 NULL);
872
873 return gimp_image_undo_push (image, GIMP_TYPE_CHANNEL_UNDO,
874 GIMP_UNDO_CHANNEL_ADD, undo_desc,
875 GIMP_DIRTY_IMAGE_STRUCTURE,
876 "item", channel,
877 "prev-channel", prev_channel,
878 NULL);
879 }
880
881 GimpUndo *
gimp_image_undo_push_channel_remove(GimpImage * image,const gchar * undo_desc,GimpChannel * channel,GimpChannel * prev_parent,gint prev_position,GimpChannel * prev_channel)882 gimp_image_undo_push_channel_remove (GimpImage *image,
883 const gchar *undo_desc,
884 GimpChannel *channel,
885 GimpChannel *prev_parent,
886 gint prev_position,
887 GimpChannel *prev_channel)
888 {
889 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
890 g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);
891 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)), NULL);
892 g_return_val_if_fail (prev_parent == NULL || GIMP_IS_CHANNEL (prev_parent),
893 NULL);
894 g_return_val_if_fail (prev_channel == NULL || GIMP_IS_CHANNEL (prev_channel),
895 NULL);
896
897 return gimp_image_undo_push (image, GIMP_TYPE_CHANNEL_UNDO,
898 GIMP_UNDO_CHANNEL_REMOVE, undo_desc,
899 GIMP_DIRTY_IMAGE_STRUCTURE,
900 "item", channel,
901 "prev-parent", prev_parent,
902 "prev-position", prev_position,
903 "prev-channel", prev_channel,
904 NULL);
905 }
906
907 GimpUndo *
gimp_image_undo_push_channel_color(GimpImage * image,const gchar * undo_desc,GimpChannel * channel)908 gimp_image_undo_push_channel_color (GimpImage *image,
909 const gchar *undo_desc,
910 GimpChannel *channel)
911 {
912 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
913 g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);
914 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)), NULL);
915
916 return gimp_image_undo_push (image, GIMP_TYPE_CHANNEL_PROP_UNDO,
917 GIMP_UNDO_CHANNEL_COLOR, undo_desc,
918 GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
919 "item", channel,
920 NULL);
921 }
922
923
924 /*******************/
925 /* Vectors Undos */
926 /*******************/
927
928 GimpUndo *
gimp_image_undo_push_vectors_add(GimpImage * image,const gchar * undo_desc,GimpVectors * vectors,GimpVectors * prev_vectors)929 gimp_image_undo_push_vectors_add (GimpImage *image,
930 const gchar *undo_desc,
931 GimpVectors *vectors,
932 GimpVectors *prev_vectors)
933 {
934 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
935 g_return_val_if_fail (GIMP_IS_VECTORS (vectors), NULL);
936 g_return_val_if_fail (! gimp_item_is_attached (GIMP_ITEM (vectors)), NULL);
937 g_return_val_if_fail (prev_vectors == NULL || GIMP_IS_VECTORS (prev_vectors),
938 NULL);
939
940 return gimp_image_undo_push (image, GIMP_TYPE_VECTORS_UNDO,
941 GIMP_UNDO_VECTORS_ADD, undo_desc,
942 GIMP_DIRTY_IMAGE_STRUCTURE,
943 "item", vectors,
944 "prev-vectors", prev_vectors,
945 NULL);
946 }
947
948 GimpUndo *
gimp_image_undo_push_vectors_remove(GimpImage * image,const gchar * undo_desc,GimpVectors * vectors,GimpVectors * prev_parent,gint prev_position,GimpVectors * prev_vectors)949 gimp_image_undo_push_vectors_remove (GimpImage *image,
950 const gchar *undo_desc,
951 GimpVectors *vectors,
952 GimpVectors *prev_parent,
953 gint prev_position,
954 GimpVectors *prev_vectors)
955 {
956 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
957 g_return_val_if_fail (GIMP_IS_VECTORS (vectors), NULL);
958 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (vectors)), NULL);
959 g_return_val_if_fail (prev_parent == NULL || GIMP_IS_VECTORS (prev_parent),
960 NULL);
961 g_return_val_if_fail (prev_vectors == NULL || GIMP_IS_VECTORS (prev_vectors),
962 NULL);
963
964 return gimp_image_undo_push (image, GIMP_TYPE_VECTORS_UNDO,
965 GIMP_UNDO_VECTORS_REMOVE, undo_desc,
966 GIMP_DIRTY_IMAGE_STRUCTURE,
967 "item", vectors,
968 "prev-parent", prev_parent,
969 "prev-position", prev_position,
970 "prev-vectors", prev_vectors,
971 NULL);
972 }
973
974 GimpUndo *
gimp_image_undo_push_vectors_mod(GimpImage * image,const gchar * undo_desc,GimpVectors * vectors)975 gimp_image_undo_push_vectors_mod (GimpImage *image,
976 const gchar *undo_desc,
977 GimpVectors *vectors)
978 {
979 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
980 g_return_val_if_fail (GIMP_IS_VECTORS (vectors), NULL);
981 g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (vectors)), NULL);
982
983 return gimp_image_undo_push (image, GIMP_TYPE_VECTORS_MOD_UNDO,
984 GIMP_UNDO_VECTORS_MOD, undo_desc,
985 GIMP_DIRTY_ITEM | GIMP_DIRTY_VECTORS,
986 "item", vectors,
987 NULL);
988 }
989
990
991 /******************************/
992 /* Floating Selection Undos */
993 /******************************/
994
995 GimpUndo *
gimp_image_undo_push_fs_to_layer(GimpImage * image,const gchar * undo_desc,GimpLayer * floating_layer)996 gimp_image_undo_push_fs_to_layer (GimpImage *image,
997 const gchar *undo_desc,
998 GimpLayer *floating_layer)
999 {
1000 GimpUndo *undo;
1001
1002 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
1003 g_return_val_if_fail (GIMP_IS_LAYER (floating_layer), NULL);
1004
1005 undo = gimp_image_undo_push (image, GIMP_TYPE_FLOATING_SELECTION_UNDO,
1006 GIMP_UNDO_FS_TO_LAYER, undo_desc,
1007 GIMP_DIRTY_IMAGE_STRUCTURE,
1008 "item", floating_layer,
1009 NULL);
1010
1011 return undo;
1012 }
1013
1014
1015 /******************************************************************************/
1016 /* Something for which programmer is too lazy to write an undo function for */
1017 /******************************************************************************/
1018
1019 static void
undo_pop_cantundo(GimpUndo * undo,GimpUndoMode undo_mode,GimpUndoAccumulator * accum)1020 undo_pop_cantundo (GimpUndo *undo,
1021 GimpUndoMode undo_mode,
1022 GimpUndoAccumulator *accum)
1023 {
1024 switch (undo_mode)
1025 {
1026 case GIMP_UNDO_MODE_UNDO:
1027 gimp_message (undo->image->gimp, NULL, GIMP_MESSAGE_WARNING,
1028 _("Can't undo %s"), gimp_object_get_name (undo));
1029 break;
1030
1031 case GIMP_UNDO_MODE_REDO:
1032 break;
1033 }
1034 }
1035
1036 GimpUndo *
gimp_image_undo_push_cantundo(GimpImage * image,const gchar * undo_desc)1037 gimp_image_undo_push_cantundo (GimpImage *image,
1038 const gchar *undo_desc)
1039 {
1040 GimpUndo *undo;
1041
1042 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
1043
1044 /* This is the sole purpose of this type of undo: the ability to
1045 * mark an image as having been mutated, without really providing
1046 * any adequate undo facility.
1047 */
1048
1049 undo = gimp_image_undo_push (image, GIMP_TYPE_UNDO,
1050 GIMP_UNDO_CANT, undo_desc,
1051 GIMP_DIRTY_ALL,
1052 NULL);
1053
1054 if (undo)
1055 g_signal_connect (undo, "pop",
1056 G_CALLBACK (undo_pop_cantundo),
1057 NULL);
1058
1059 return undo;
1060 }
1061