app: add new virtual function GimpItem::unset_removed()
and implement it in GimpLayer to unset the removed flag on the layer mask. Remove layer mask special casing from gimp_image_add_layer(). Make sure that all an item's children get their removed flag unset in gimp_item_unset_removed().
This commit is contained in:
@ -3471,17 +3471,6 @@ gimp_image_add_layer (GimpImage *image,
|
||||
if (old_has_alpha != gimp_image_has_alpha (image))
|
||||
private->flush_accum.alpha_changed = TRUE;
|
||||
|
||||
if (gimp_layer_get_mask (layer))
|
||||
{
|
||||
GimpLayerMask *mask = gimp_layer_get_mask (layer);
|
||||
|
||||
/* if the layer came from the undo stack,
|
||||
* reset the mask's "removed" state
|
||||
*/
|
||||
if (gimp_item_is_removed (GIMP_ITEM (mask)))
|
||||
gimp_item_unset_removed (GIMP_ITEM (mask));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -215,6 +215,7 @@ gimp_item_class_init (GimpItemClass *klass)
|
||||
klass->linked_changed = NULL;
|
||||
klass->lock_content_changed = NULL;
|
||||
|
||||
klass->unset_removed = NULL;
|
||||
klass->is_attached = NULL;
|
||||
klass->is_content_locked = gimp_item_real_is_content_locked;
|
||||
klass->get_tree = NULL;
|
||||
@ -738,10 +739,20 @@ gimp_item_is_removed (const GimpItem *item)
|
||||
void
|
||||
gimp_item_unset_removed (GimpItem *item)
|
||||
{
|
||||
GimpContainer *children;
|
||||
|
||||
g_return_if_fail (GIMP_IS_ITEM (item));
|
||||
g_return_if_fail (gimp_item_is_removed (item));
|
||||
|
||||
GET_PRIVATE (item)->removed = FALSE;
|
||||
|
||||
children = gimp_viewable_get_children (GIMP_VIEWABLE (item));
|
||||
|
||||
if (children)
|
||||
gimp_container_foreach (children, (GFunc) gimp_item_unset_removed, NULL);
|
||||
|
||||
if (GIMP_ITEM_GET_CLASS (item)->unset_removed)
|
||||
GIMP_ITEM_GET_CLASS (item)->unset_removed (item);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,6 +50,7 @@ struct _GimpItemClass
|
||||
void (* lock_content_changed) (GimpItem *item);
|
||||
|
||||
/* virtual functions */
|
||||
void (* unset_removed) (GimpItem *item);
|
||||
gboolean (* is_attached) (const GimpItem *item);
|
||||
gboolean (* is_content_locked) (const GimpItem *item);
|
||||
GimpItemTree * (* get_tree) (GimpItem *item);
|
||||
|
@ -97,6 +97,7 @@ static gchar * gimp_layer_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
static void gimp_layer_removed (GimpItem *item);
|
||||
static void gimp_layer_unset_removed (GimpItem *item);
|
||||
static gboolean gimp_layer_is_attached (const GimpItem *item);
|
||||
static GimpItemTree * gimp_layer_get_tree (GimpItem *item);
|
||||
static GimpItem * gimp_layer_duplicate (GimpItem *item,
|
||||
@ -249,6 +250,7 @@ gimp_layer_class_init (GimpLayerClass *klass)
|
||||
viewable_class->get_description = gimp_layer_get_description;
|
||||
|
||||
item_class->removed = gimp_layer_removed;
|
||||
item_class->unset_removed = gimp_layer_unset_removed;
|
||||
item_class->is_attached = gimp_layer_is_attached;
|
||||
item_class->get_tree = gimp_layer_get_tree;
|
||||
item_class->duplicate = gimp_layer_duplicate;
|
||||
@ -493,6 +495,18 @@ gimp_layer_removed (GimpItem *item)
|
||||
GIMP_ITEM_CLASS (parent_class)->removed (item);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_layer_unset_removed (GimpItem *item)
|
||||
{
|
||||
GimpLayer *layer = GIMP_LAYER (item);
|
||||
|
||||
if (layer->mask)
|
||||
gimp_item_unset_removed (GIMP_ITEM (layer->mask));
|
||||
|
||||
if (GIMP_ITEM_CLASS (parent_class)->unset_removed)
|
||||
GIMP_ITEM_CLASS (parent_class)->unset_removed (item);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_layer_is_attached (const GimpItem *item)
|
||||
{
|
||||
|
Reference in New Issue
Block a user