static void gimp_layer_mask_undo_constructed (GObject *object) { GimpLayerMaskUndo *layer_mask_undo = GIMP_LAYER_MASK_UNDO (object); G_OBJECT_CLASS (parent_class)->constructed (object); g_assert (GIMP_IS_LAYER (GIMP_ITEM_UNDO (object)->item)); g_assert (GIMP_IS_LAYER_MASK (layer_mask_undo->layer_mask)); }
static void gimp_drawable_undo_constructed (GObject *object) { GimpDrawableUndo *drawable_undo = GIMP_DRAWABLE_UNDO (object); G_OBJECT_CLASS (parent_class)->constructed (object); g_assert (GIMP_IS_DRAWABLE (GIMP_ITEM_UNDO (object)->item)); g_assert (drawable_undo->buffer != NULL); }
static void gimp_text_undo_constructed (GObject *object) { GimpTextUndo *text_undo = GIMP_TEXT_UNDO (object); GimpTextLayer *layer; G_OBJECT_CLASS (parent_class)->constructed (object); g_assert (GIMP_IS_TEXT_LAYER (GIMP_ITEM_UNDO (text_undo)->item)); layer = GIMP_TEXT_LAYER (GIMP_ITEM_UNDO (text_undo)->item); switch (GIMP_UNDO (object)->undo_type) { case GIMP_UNDO_TEXT_LAYER: if (text_undo->pspec) { g_assert (text_undo->pspec->owner_type == GIMP_TYPE_TEXT); text_undo->value = g_slice_new0 (GValue); g_value_init (text_undo->value, text_undo->pspec->value_type); g_object_get_property (G_OBJECT (layer->text), text_undo->pspec->name, text_undo->value); } else if (layer->text) { text_undo->text = gimp_config_duplicate (GIMP_CONFIG (layer->text)); } break; case GIMP_UNDO_TEXT_LAYER_MODIFIED: text_undo->modified = layer->modified; break; case GIMP_UNDO_TEXT_LAYER_CONVERT: text_undo->format = gimp_drawable_get_format (GIMP_DRAWABLE (layer)); break; default: g_assert_not_reached (); } }
static GObject * gimp_layer_prop_undo_constructor (GType type, guint n_params, GObjectConstructParam *params) { GObject *object; GimpLayerPropUndo *layer_prop_undo; GimpImage *image; GimpLayer *layer; object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params); layer_prop_undo = GIMP_LAYER_PROP_UNDO (object); g_assert (GIMP_IS_LAYER (GIMP_ITEM_UNDO (object)->item)); image = GIMP_UNDO (object)->image; layer = GIMP_LAYER (GIMP_ITEM_UNDO (object)->item); switch (GIMP_UNDO (object)->undo_type) { case GIMP_UNDO_LAYER_REPOSITION: layer_prop_undo->position = gimp_image_get_layer_index (image, layer); break; case GIMP_UNDO_LAYER_MODE: layer_prop_undo->mode = gimp_layer_get_mode (layer); break; case GIMP_UNDO_LAYER_OPACITY: layer_prop_undo->opacity = gimp_layer_get_opacity (layer); break; case GIMP_UNDO_LAYER_LOCK_ALPHA: layer_prop_undo->lock_alpha = gimp_layer_get_lock_alpha (layer); break; default: g_assert_not_reached (); } return object; }
static void gimp_item_prop_undo_constructed (GObject *object) { GimpItemPropUndo *item_prop_undo = GIMP_ITEM_PROP_UNDO (object); GimpItem *item; G_OBJECT_CLASS (parent_class)->constructed (object); item = GIMP_ITEM_UNDO (object)->item; switch (GIMP_UNDO (object)->undo_type) { case GIMP_UNDO_ITEM_REORDER: item_prop_undo->parent = gimp_item_get_parent (item); item_prop_undo->position = gimp_item_get_index (item); break; case GIMP_UNDO_ITEM_RENAME: item_prop_undo->name = g_strdup (gimp_object_get_name (item)); break; case GIMP_UNDO_ITEM_DISPLACE: gimp_item_get_offset (item, &item_prop_undo->offset_x, &item_prop_undo->offset_y); break; case GIMP_UNDO_ITEM_VISIBILITY: item_prop_undo->visible = gimp_item_get_visible (item); break; case GIMP_UNDO_ITEM_LINKED: item_prop_undo->linked = gimp_item_get_linked (item); break; case GIMP_UNDO_ITEM_LOCK_CONTENT: item_prop_undo->lock_content = gimp_item_get_lock_content (item); break; case GIMP_UNDO_ITEM_LOCK_POSITION: item_prop_undo->lock_position = gimp_item_get_lock_position (item); break; case GIMP_UNDO_PARASITE_ATTACH: case GIMP_UNDO_PARASITE_REMOVE: g_assert (item_prop_undo->parasite_name != NULL); item_prop_undo->parasite = gimp_parasite_copy (gimp_item_parasite_find (item, item_prop_undo->parasite_name)); break; default: g_assert_not_reached (); } }
static void gimp_floating_sel_undo_constructed (GObject *object) { GimpFloatingSelUndo *floating_sel_undo = GIMP_FLOATING_SEL_UNDO (object); GimpLayer *layer; G_OBJECT_CLASS (parent_class)->constructed (object); g_assert (GIMP_IS_LAYER (GIMP_ITEM_UNDO (object)->item)); layer = GIMP_LAYER (GIMP_ITEM_UNDO (object)->item); switch (GIMP_UNDO (object)->undo_type) { case GIMP_UNDO_FS_TO_LAYER: floating_sel_undo->drawable = gimp_layer_get_floating_sel_drawable (layer); break; default: g_assert_not_reached (); } }
static void gimp_item_undo_free (GimpUndo *undo, GimpUndoMode undo_mode) { GimpItemUndo *item_undo = GIMP_ITEM_UNDO (undo); if (item_undo->item) { g_object_unref (item_undo->item); item_undo->item = NULL; } GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode); }
static void gimp_drawable_undo_pop (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { GimpDrawableUndo *drawable_undo = GIMP_DRAWABLE_UNDO (undo); GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum); gimp_drawable_swap_pixels (GIMP_DRAWABLE (GIMP_ITEM_UNDO (undo)->item), drawable_undo->buffer, drawable_undo->x, drawable_undo->y); }
static gint64 gimp_channel_undo_get_memsize (GimpObject *object, gint64 *gui_size) { GimpItemUndo *item_undo = GIMP_ITEM_UNDO (object); gint64 memsize = 0; if (! gimp_item_is_attached (item_undo->item)) memsize += gimp_object_get_memsize (GIMP_OBJECT (item_undo->item), gui_size); return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, gui_size); }
static GObject * gimp_item_prop_undo_constructor (GType type, guint n_params, GObjectConstructParam *params) { GObject *object; GimpItemPropUndo *item_prop_undo; GimpItem *item; object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params); item_prop_undo = GIMP_ITEM_PROP_UNDO (object); item = GIMP_ITEM_UNDO (object)->item; switch (GIMP_UNDO (object)->undo_type) { case GIMP_UNDO_ITEM_RENAME: item_prop_undo->name = g_strdup (gimp_object_get_name (GIMP_OBJECT (item))); break; case GIMP_UNDO_ITEM_DISPLACE: gimp_item_offsets (item, &item_prop_undo->offset_x, &item_prop_undo->offset_y); break; case GIMP_UNDO_ITEM_VISIBILITY: item_prop_undo->visible = gimp_item_get_visible (item); break; case GIMP_UNDO_ITEM_LINKED: item_prop_undo->linked = gimp_item_get_linked (item); break; case GIMP_UNDO_PARASITE_ATTACH: case GIMP_UNDO_PARASITE_REMOVE: g_assert (item_prop_undo->parasite_name != NULL); item_prop_undo->parasite = gimp_parasite_copy (gimp_item_parasite_find (item, item_prop_undo->parasite_name)); break; default: g_assert_not_reached (); } return object; }
static GObject * gimp_vectors_mod_undo_constructor (GType type, guint n_params, GObjectConstructParam *params) { GObject *object; GimpVectorsModUndo *vectors_mod_undo; GimpVectors *vectors; object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params); vectors_mod_undo = GIMP_VECTORS_MOD_UNDO (object); g_assert (GIMP_IS_VECTORS (GIMP_ITEM_UNDO (object)->item)); vectors = GIMP_VECTORS (GIMP_ITEM_UNDO (object)->item); vectors_mod_undo->vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors), G_TYPE_FROM_INSTANCE (vectors), FALSE)); return object; }
static gint64 gimp_layer_mask_undo_get_memsize (GimpObject *object, gint64 *gui_size) { GimpLayerMaskUndo *layer_mask_undo = GIMP_LAYER_MASK_UNDO (object); GimpLayer *layer = GIMP_LAYER (GIMP_ITEM_UNDO (object)->item); gint64 memsize = 0; /* don't use !gimp_item_is_attached() here */ if (gimp_layer_get_mask (layer) != layer_mask_undo->layer_mask) memsize += gimp_object_get_memsize (GIMP_OBJECT (layer_mask_undo->layer_mask), gui_size); return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, gui_size); }
static void gimp_floating_sel_undo_pop (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { GimpFloatingSelUndo *floating_sel_undo = GIMP_FLOATING_SEL_UNDO (undo); GimpLayer *floating_layer = GIMP_LAYER (GIMP_ITEM_UNDO (undo)->item); GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum); switch (undo->undo_type) { case GIMP_UNDO_FS_TO_LAYER: if (undo_mode == GIMP_UNDO_MODE_UNDO) { /* Update the preview for the floating sel */ gimp_viewable_invalidate_preview (GIMP_VIEWABLE (floating_layer)); gimp_layer_set_floating_sel_drawable (floating_layer, floating_sel_undo->drawable); gimp_image_set_active_layer (undo->image, floating_layer); gimp_drawable_attach_floating_sel (gimp_layer_get_floating_sel_drawable (floating_layer), floating_layer); } else { gimp_drawable_detach_floating_sel (gimp_layer_get_floating_sel_drawable (floating_layer)); gimp_layer_set_floating_sel_drawable (floating_layer, NULL); } /* When the floating selection is converted to/from a normal * layer it does something resembling a name change, so emit the * "name-changed" signal */ gimp_object_name_changed (GIMP_OBJECT (floating_layer)); gimp_drawable_update (GIMP_DRAWABLE (floating_layer), 0, 0, gimp_item_get_width (GIMP_ITEM (floating_layer)), gimp_item_get_height (GIMP_ITEM (floating_layer))); break; default: g_assert_not_reached (); } }
static void gimp_layer_prop_undo_pop (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { GimpLayerPropUndo *layer_prop_undo = GIMP_LAYER_PROP_UNDO (undo); GimpLayer *layer = GIMP_LAYER (GIMP_ITEM_UNDO (undo)->item); GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum); switch (undo->undo_type) { case GIMP_UNDO_LAYER_MODE: { GimpLayerModeEffects mode; mode = gimp_layer_get_mode (layer); gimp_layer_set_mode (layer, layer_prop_undo->mode, FALSE); layer_prop_undo->mode = mode; } break; case GIMP_UNDO_LAYER_OPACITY: { gdouble opacity; opacity = gimp_layer_get_opacity (layer); gimp_layer_set_opacity (layer, layer_prop_undo->opacity, FALSE); layer_prop_undo->opacity = opacity; } break; case GIMP_UNDO_LAYER_LOCK_ALPHA: { gboolean lock_alpha; lock_alpha = gimp_layer_get_lock_alpha (layer); gimp_layer_set_lock_alpha (layer, layer_prop_undo->lock_alpha, FALSE); layer_prop_undo->lock_alpha = lock_alpha; } break; default: g_assert_not_reached (); } }
static void gimp_vectors_prop_undo_constructed (GObject *object) { /* GimpVectors *vectors; */ G_OBJECT_CLASS (parent_class)->constructed (object); gimp_assert (GIMP_IS_VECTORS (GIMP_ITEM_UNDO (object)->item)); /* vectors = GIMP_VECTORS (GIMP_ITEM_UNDO (object)->item); */ switch (GIMP_UNDO (object)->undo_type) { default: gimp_assert_not_reached (); } }
static void gimp_vectors_prop_undo_pop (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { #if 0 GimpVectorsPropUndo *vectors_prop_undo = GIMP_VECTORS_PROP_UNDO (undo); GimpVectors *vectors = GIMP_VECTORS (GIMP_ITEM_UNDO (undo)->item); #endif GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum); switch (undo->undo_type) { default: gimp_assert_not_reached (); } }
gboolean gimp_edit_fade (GimpImage *image, GimpContext *context) { GimpDrawableUndo *undo; g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE); g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE); undo = GIMP_DRAWABLE_UNDO (gimp_image_undo_get_fadeable (image)); if (undo && undo->applied_buffer) { GimpDrawable *drawable; GeglBuffer *buffer; drawable = GIMP_DRAWABLE (GIMP_ITEM_UNDO (undo)->item); g_object_ref (undo); buffer = g_object_ref (undo->applied_buffer); gimp_image_undo (image); gimp_drawable_apply_buffer (drawable, buffer, GEGL_RECTANGLE (0, 0, gegl_buffer_get_width (undo->buffer), gegl_buffer_get_height (undo->buffer)), TRUE, gimp_object_get_name (undo), gimp_context_get_opacity (context), gimp_context_get_paint_mode (context), GIMP_LAYER_COLOR_SPACE_AUTO, GIMP_LAYER_COLOR_SPACE_AUTO, GIMP_LAYER_COMPOSITE_AUTO, NULL, undo->x, undo->y); g_object_unref (buffer); g_object_unref (undo); return TRUE; } return FALSE; }
static void gimp_item_undo_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GimpItemUndo *item_undo = GIMP_ITEM_UNDO (object); switch (property_id) { case PROP_ITEM: item_undo->item = g_value_dup_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static void gimp_layer_mask_prop_undo_pop (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { GimpLayerMaskPropUndo *layer_mask_prop_undo = GIMP_LAYER_MASK_PROP_UNDO (undo); GimpLayer *layer = GIMP_LAYER (GIMP_ITEM_UNDO (undo)->item); GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum); switch (undo->undo_type) { case GIMP_UNDO_LAYER_MASK_APPLY: { gboolean apply; apply = gimp_layer_get_apply_mask (layer); gimp_layer_set_apply_mask (layer, layer_mask_prop_undo->apply, FALSE); layer_mask_prop_undo->apply = apply; } break; case GIMP_UNDO_LAYER_MASK_SHOW: { gboolean show; show = gimp_layer_get_show_mask (layer); gimp_layer_set_show_mask (layer, layer_mask_prop_undo->show, FALSE); layer_mask_prop_undo->show = show; } break; default: g_assert_not_reached (); } }
static void gimp_channel_undo_pop (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { GimpChannelUndo *channel_undo = GIMP_CHANNEL_UNDO (undo); GimpChannel *channel = GIMP_CHANNEL (GIMP_ITEM_UNDO (undo)->item); GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum); if ((undo_mode == GIMP_UNDO_MODE_UNDO && undo->undo_type == GIMP_UNDO_CHANNEL_ADD) || (undo_mode == GIMP_UNDO_MODE_REDO && undo->undo_type == GIMP_UNDO_CHANNEL_REMOVE)) { /* remove channel */ /* record the current parent and position */ channel_undo->prev_parent = gimp_channel_get_parent (channel); channel_undo->prev_position = gimp_item_get_index (GIMP_ITEM (channel)); gimp_image_remove_channel (undo->image, channel, FALSE, channel_undo->prev_channel); } else { /* restore channel */ /* record the active channel */ channel_undo->prev_channel = gimp_image_get_active_channel (undo->image); gimp_image_add_channel (undo->image, channel, channel_undo->prev_parent, channel_undo->prev_position, FALSE); } }
static void gimp_item_prop_undo_pop (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { GimpItemPropUndo *item_prop_undo = GIMP_ITEM_PROP_UNDO (undo); GimpItem *item = GIMP_ITEM_UNDO (undo)->item; GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum); switch (undo->undo_type) { case GIMP_UNDO_ITEM_REORDER: { GimpItem *parent; gint position; parent = gimp_item_get_parent (item); position = gimp_item_get_index (item); gimp_item_tree_reorder_item (gimp_item_get_tree (item), item, item_prop_undo->parent, item_prop_undo->position, FALSE, NULL); item_prop_undo->parent = parent; item_prop_undo->position = position; } break; case GIMP_UNDO_ITEM_RENAME: { gchar *name; name = g_strdup (gimp_object_get_name (item)); gimp_item_tree_rename_item (gimp_item_get_tree (item), item, item_prop_undo->name, FALSE, NULL); g_free (item_prop_undo->name); item_prop_undo->name = name; } break; case GIMP_UNDO_ITEM_DISPLACE: { gint offset_x; gint offset_y; gimp_item_get_offset (item, &offset_x, &offset_y); gimp_item_translate (item, item_prop_undo->offset_x - offset_x, item_prop_undo->offset_y - offset_y, FALSE); item_prop_undo->offset_x = offset_x; item_prop_undo->offset_y = offset_y; } break; case GIMP_UNDO_ITEM_VISIBILITY: { gboolean visible; visible = gimp_item_get_visible (item); gimp_item_set_visible (item, item_prop_undo->visible, FALSE); item_prop_undo->visible = visible; } break; case GIMP_UNDO_ITEM_LINKED: { gboolean linked; linked = gimp_item_get_linked (item); gimp_item_set_linked (item, item_prop_undo->linked, FALSE); item_prop_undo->linked = linked; } break; case GIMP_UNDO_ITEM_COLOR_TAG: { GimpColorTag color_tag; color_tag = gimp_item_get_color_tag (item); gimp_item_set_color_tag (item, item_prop_undo->color_tag, FALSE); item_prop_undo->color_tag = color_tag; } break; case GIMP_UNDO_ITEM_LOCK_CONTENT: { gboolean lock_content; lock_content = gimp_item_get_lock_content (item); gimp_item_set_lock_content (item, item_prop_undo->lock_content, FALSE); item_prop_undo->lock_content = lock_content; } break; case GIMP_UNDO_ITEM_LOCK_POSITION: { gboolean lock_position; lock_position = gimp_item_get_lock_position (item); gimp_item_set_lock_position (item, item_prop_undo->lock_position, FALSE); item_prop_undo->lock_position = lock_position; } break; case GIMP_UNDO_PARASITE_ATTACH: case GIMP_UNDO_PARASITE_REMOVE: { GimpParasite *parasite; parasite = item_prop_undo->parasite; item_prop_undo->parasite = gimp_parasite_copy (gimp_item_parasite_find (item, item_prop_undo->parasite_name)); if (parasite) gimp_item_parasite_attach (item, parasite, FALSE); else gimp_item_parasite_detach (item, item_prop_undo->parasite_name, FALSE); if (parasite) gimp_parasite_free (parasite); } break; default: g_assert_not_reached (); } }
static void gimp_text_undo_pop (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { GimpTextUndo *text_undo = GIMP_TEXT_UNDO (undo); GimpTextLayer *layer = GIMP_TEXT_LAYER (GIMP_ITEM_UNDO (undo)->item); GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum); switch (undo->undo_type) { case GIMP_UNDO_TEXT_LAYER: if (text_undo->pspec) { GValue *value; g_return_if_fail (layer->text != NULL); value = g_slice_new0 (GValue); g_value_init (value, text_undo->pspec->value_type); g_object_get_property (G_OBJECT (layer->text), text_undo->pspec->name, value); g_object_set_property (G_OBJECT (layer->text), text_undo->pspec->name, text_undo->value); g_value_unset (text_undo->value); g_slice_free (GValue, text_undo->value); text_undo->value = value; } else { GimpText *text; text = (layer->text ? gimp_config_duplicate (GIMP_CONFIG (layer->text)) : NULL); if (layer->text && text_undo->text) gimp_config_sync (G_OBJECT (text_undo->text), G_OBJECT (layer->text), 0); else gimp_text_layer_set_text (layer, text_undo->text); if (text_undo->text) g_object_unref (text_undo->text); text_undo->text = text; } break; case GIMP_UNDO_TEXT_LAYER_MODIFIED: { gboolean modified; #if 0 g_print ("setting layer->modified from %s to %s\n", layer->modified ? "TRUE" : "FALSE", text_undo->modified ? "TRUE" : "FALSE"); #endif modified = layer->modified; g_object_set (layer, "modified", text_undo->modified, NULL); text_undo->modified = modified; gimp_viewable_invalidate_preview (GIMP_VIEWABLE (layer)); } break; case GIMP_UNDO_TEXT_LAYER_CONVERT: { const Babl *format; format = gimp_drawable_get_format (GIMP_DRAWABLE (layer)); gimp_drawable_convert_type (GIMP_DRAWABLE (layer), gimp_item_get_image (GIMP_ITEM (layer)), gimp_babl_format_get_base_type (text_undo->format), gimp_babl_format_get_precision (text_undo->format), 0, 0, FALSE); text_undo->format = format; } break; default: g_assert_not_reached (); } }
static void gimp_item_prop_undo_pop (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { GimpItemPropUndo *item_prop_undo = GIMP_ITEM_PROP_UNDO (undo); GimpItem *item = GIMP_ITEM_UNDO (undo)->item; GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum); switch (undo->undo_type) { case GIMP_UNDO_ITEM_RENAME: { gchar *name; name = g_strdup (gimp_object_get_name (GIMP_OBJECT (item))); gimp_object_take_name (GIMP_OBJECT (item), item_prop_undo->name); item_prop_undo->name = name; } break; case GIMP_UNDO_ITEM_DISPLACE: { gint offset_x; gint offset_y; gimp_item_offsets (item, &offset_x, &offset_y); gimp_item_translate (item, item_prop_undo->offset_x - offset_x, item_prop_undo->offset_y - offset_y, FALSE); item_prop_undo->offset_x = offset_x; item_prop_undo->offset_y = offset_y; } break; case GIMP_UNDO_ITEM_VISIBILITY: { gboolean visible; visible = gimp_item_get_visible (item); gimp_item_set_visible (item, item_prop_undo->visible, FALSE); item_prop_undo->visible = visible; } break; case GIMP_UNDO_ITEM_LINKED: { gboolean linked; linked = gimp_item_get_linked (item); gimp_item_set_linked (item, item_prop_undo->linked, FALSE); item_prop_undo->linked = linked; } break; case GIMP_UNDO_PARASITE_ATTACH: case GIMP_UNDO_PARASITE_REMOVE: { GimpParasite *parasite; parasite = item_prop_undo->parasite; item_prop_undo->parasite = gimp_parasite_copy (gimp_item_parasite_find (item, item_prop_undo->parasite_name)); if (parasite) gimp_parasite_list_add (item->parasites, parasite); else gimp_parasite_list_remove (item->parasites, item_prop_undo->parasite_name); if (parasite) gimp_parasite_free (parasite); } break; default: g_assert_not_reached (); } }
static void gimp_mask_undo_pop (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { GimpMaskUndo *mask_undo = GIMP_MASK_UNDO (undo); GimpChannel *channel = GIMP_CHANNEL (GIMP_ITEM_UNDO (undo)->item); GimpDrawable *drawable = GIMP_DRAWABLE (channel); GeglBuffer *new_buffer; const Babl *format; gint x1, y1, x2, y2; gint width = 0; gint height = 0; GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum); if (gimp_channel_bounds (channel, &x1, &y1, &x2, &y2)) { new_buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, x2 - x1, y2 - y1), gimp_drawable_get_format (drawable)); gegl_buffer_copy (gimp_drawable_get_buffer (drawable), GEGL_RECTANGLE (x1, y1, x2 - x1, y2 - y1), new_buffer, GEGL_RECTANGLE (0, 0, 0, 0)); gegl_buffer_clear (gimp_drawable_get_buffer (drawable), GEGL_RECTANGLE (x1, y1, x2 - x1, y2 - y1)); } else { new_buffer = NULL; } format = gimp_drawable_get_format (drawable); if (mask_undo->convert_format) { GeglBuffer *buffer; gint width = gimp_item_get_width (GIMP_ITEM (channel)); gint height = gimp_item_get_height (GIMP_ITEM (channel)); buffer = gimp_gegl_buffer_new (GEGL_RECTANGLE (0, 0, width, height), mask_undo->format); gegl_buffer_clear (buffer, NULL); gimp_drawable_set_buffer (drawable, FALSE, NULL, buffer); g_object_unref (buffer); } if (mask_undo->buffer) { width = gegl_buffer_get_width (mask_undo->buffer); height = gegl_buffer_get_height (mask_undo->buffer); gegl_buffer_copy (mask_undo->buffer, NULL, gimp_drawable_get_buffer (drawable), GEGL_RECTANGLE (mask_undo->x, mask_undo->y, 0, 0)); g_object_unref (mask_undo->buffer); } /* invalidate the current bounds and boundary of the mask */ gimp_drawable_invalidate_boundary (drawable); if (mask_undo->buffer) { channel->empty = FALSE; channel->x1 = mask_undo->x; channel->y1 = mask_undo->y; channel->x2 = mask_undo->x + width; channel->y2 = mask_undo->y + height; } else { channel->empty = TRUE; channel->x1 = 0; channel->y1 = 0; channel->x2 = gimp_item_get_width (GIMP_ITEM (channel)); channel->y2 = gimp_item_get_height (GIMP_ITEM (channel)); } /* we know the bounds */ channel->bounds_known = TRUE; /* set the new mask undo parameters */ mask_undo->buffer = new_buffer; mask_undo->x = x1; mask_undo->y = y1; mask_undo->format = format; gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0, gimp_item_get_width (GIMP_ITEM (channel)), gimp_item_get_height (GIMP_ITEM (channel))); }