app: add gimp_item_unset_removed() and move item->removed to private

This commit is contained in:
Michael Natterer 2011-01-30 21:57:45 +01:00
parent fd655490e8
commit af160141db
5 changed files with 28 additions and 11 deletions

View File

@ -3475,9 +3475,11 @@ gimp_image_add_layer (GimpImage *image,
{
GimpLayerMask *mask = gimp_layer_get_mask (layer);
/* if the layer came from the undo stack, reset the mask's "removed" state */
/* if the layer came from the undo stack,
* reset the mask's "removed" state
*/
if (gimp_item_is_removed (GIMP_ITEM (mask)))
GIMP_ITEM (mask)->removed = FALSE;
gimp_item_unset_removed (GIMP_ITEM (mask));
}
return TRUE;

View File

@ -91,9 +91,7 @@ struct _GimpItemPrivate
guint linked : 1; /* control linkage */
guint lock_content : 1; /* content editability */
#if 0
guint removed : 1; /* removed from the image? */
#endif
GeglNode *node; /* the GEGL node to plug
into the graph */
@ -305,7 +303,7 @@ gimp_item_init (GimpItem *item)
private->visible = TRUE;
private->linked = FALSE;
private->lock_content = FALSE;
item->removed = FALSE;
private->removed = FALSE;
private->node = NULL;
private->offset_node = NULL;
}
@ -629,7 +627,7 @@ gimp_item_removed (GimpItem *item)
g_return_if_fail (GIMP_IS_ITEM (item));
item->removed = TRUE;
GET_PRIVATE (item)->removed = TRUE;
children = gimp_viewable_get_children (GIMP_VIEWABLE (item));
@ -650,7 +648,25 @@ gimp_item_is_removed (const GimpItem *item)
{
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
return item->removed;
return GET_PRIVATE (item)->removed;
}
/**
* gimp_item_unset_removed:
* @item: a #GimpItem which was on the undo stack
*
* Unsets an item's "removed" state. This function is called when an
* item was on the undo stack and is added back to its parent
* container during and undo or redo. It must never be called from
* anywhere else.
**/
void
gimp_item_unset_removed (GimpItem *item)
{
g_return_if_fail (GIMP_IS_ITEM (item));
g_return_if_fail (gimp_item_is_removed (item));
GET_PRIVATE (item)->removed = FALSE;
}
/**

View File

@ -39,8 +39,6 @@ struct _GimpItem
GimpParasiteList *parasites; /* Plug-in parasite data */
gint width, height; /* size in pixels */
guint removed : 1; /* removed from the image? */
};
struct _GimpItemClass
@ -142,6 +140,7 @@ GType gimp_item_get_type (void) G_GNUC_CONST;
void gimp_item_removed (GimpItem *item);
gboolean gimp_item_is_removed (const GimpItem *item);
void gimp_item_unset_removed (GimpItem *item);
gboolean gimp_item_is_attached (const GimpItem *item);

View File

@ -449,7 +449,7 @@ gimp_item_tree_add_item (GimpItemTree *tree,
/* if the item came from the undo stack, reset its "removed" state */
if (gimp_item_is_removed (item))
item->removed = FALSE;
gimp_item_unset_removed (item);
}
GimpItem *

View File

@ -1462,7 +1462,7 @@ gimp_layer_add_mask (GimpLayer *layer,
/* if the mask came from the undo stack, reset its "removed" state */
if (gimp_item_is_removed (GIMP_ITEM (mask)))
GIMP_ITEM (mask)->removed = FALSE;
gimp_item_unset_removed (GIMP_ITEM (mask));
return layer->mask;
}