Add get_parent() API for items, layers, channels and vectors

this is pretty pointless from an abstraction point of view, but using
these functions will make the code a lot more readable by getting rid
of tons of ugly casts to and from GimpViewable whenever getting an
item's parent.
This commit is contained in:
Michael Natterer 2010-02-07 12:03:07 +01:00
parent f2c56cb363
commit e0224cdbfb
8 changed files with 40 additions and 1 deletions

View File

@ -1684,6 +1684,14 @@ gimp_channel_new_from_component (GimpImage *image,
return channel;
}
GimpChannel *
gimp_channel_get_parent (GimpChannel *channel)
{
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);
return GIMP_CHANNEL (gimp_viewable_get_parent (GIMP_VIEWABLE (channel)));
}
void
gimp_channel_set_color (GimpChannel *channel,
const GimpRGB *color,

View File

@ -138,6 +138,8 @@ GimpChannel * gimp_channel_new_from_component (GimpImage *image,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_get_parent (GimpChannel *channel);
gdouble gimp_channel_get_opacity (const GimpChannel *channel);
void gimp_channel_set_opacity (GimpChannel *channel,
gdouble opacity,

View File

@ -689,6 +689,14 @@ gimp_item_is_attached (const GimpItem *item)
return GIMP_ITEM_GET_CLASS (item)->is_attached (item);
}
GimpItem *
gimp_item_get_parent (GimpItem *item)
{
g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
return GIMP_ITEM (gimp_viewable_get_parent (GIMP_VIEWABLE (item)));
}
GimpItemTree *
gimp_item_get_tree (GimpItem *item)
{

View File

@ -143,6 +143,8 @@ gboolean gimp_item_is_removed (const GimpItem *item);
gboolean gimp_item_is_attached (const GimpItem *item);
GimpItem * gimp_item_get_parent (GimpItem *item);
GimpItemTree * gimp_item_get_tree (GimpItem *item);
GimpContainer * gimp_item_get_container (GimpItem *item);
GList * gimp_item_get_container_iter (GimpItem *item);

View File

@ -1339,6 +1339,14 @@ gimp_layer_new_from_region (PixelRegion *region,
return new_layer;
}
GimpLayer *
gimp_layer_get_parent (GimpLayer *layer)
{
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
return GIMP_LAYER (gimp_viewable_get_parent (GIMP_VIEWABLE (layer)));
}
GimpLayerMask *
gimp_layer_get_mask (const GimpLayer *layer)
{

View File

@ -96,6 +96,8 @@ GimpLayer * gimp_layer_new_from_region (PixelRegion *region,
gdouble opacity,
GimpLayerModeEffects mode);
GimpLayer * gimp_layer_get_parent (GimpLayer *layer);
GimpLayerMask * gimp_layer_get_mask (const GimpLayer *layer);
GimpLayerMask * gimp_layer_create_mask (const GimpLayer *layer,
GimpAddMaskType mask_type,

View File

@ -587,6 +587,14 @@ gimp_vectors_new (GimpImage *image,
return vectors;
}
GimpVectors *
gimp_vectors_get_parent (GimpVectors *vectors)
{
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), NULL);
return GIMP_VECTORS (gimp_viewable_get_parent (GIMP_VIEWABLE (vectors)));
}
void
gimp_vectors_freeze (GimpVectors *vectors)
{

View File

@ -88,6 +88,8 @@ GType gimp_vectors_get_type (void) G_GNUC_CONST;
GimpVectors * gimp_vectors_new (GimpImage *image,
const gchar *name);
GimpVectors * gimp_vectors_get_parent (GimpVectors *vectors);
void gimp_vectors_freeze (GimpVectors *vectors);
void gimp_vectors_thaw (GimpVectors *vectors);
@ -97,7 +99,6 @@ void gimp_vectors_add_strokes (const GimpVectors *src_vectors,
GimpVectors *dest_vectors);
/* accessing / modifying the anchors */
GimpAnchor * gimp_vectors_anchor_get (const GimpVectors *vectors,