Add utility function gimp_layer_get_container()

The new function returns a layer's container, which is either its
parent viewable's children, or image->layers. Scheduled for being
moved to a virtual function on GimpItem.
This commit is contained in:
Michael Natterer 2009-08-01 19:27:45 +02:00
parent ad66250f90
commit f4f5fc5f55
2 changed files with 24 additions and 0 deletions

View File

@ -2039,3 +2039,25 @@ gimp_layer_get_lock_alpha (const GimpLayer *layer)
return layer->lock_alpha;
}
GimpContainer *
gimp_layer_get_container (const GimpLayer *layer)
{
GimpViewable *parent;
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
parent = gimp_viewable_get_parent (GIMP_VIEWABLE (layer));
if (parent)
return gimp_viewable_get_children (parent);
if (gimp_item_is_attached (GIMP_ITEM (layer)))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
return gimp_image_get_layers (image);
}
return NULL;
}

View File

@ -137,5 +137,7 @@ void gimp_layer_set_lock_alpha (GimpLayer *layer,
gboolean push_undo);
gboolean gimp_layer_get_lock_alpha (const GimpLayer *layer);
GimpContainer * gimp_layer_get_container (const GimpLayer *layer);
#endif /* __GIMP_LAYER_H__ */