mirror of https://github.com/GNOME/gimp.git
Add gimp_viewable_is_ancestor()
The new functions figures if one viewable is another's parent or grandparent or grandgrand... Note that unlike gtk_widget_is_ancestor(), this function has its parameters in the right order.
This commit is contained in:
parent
85148ea2b9
commit
8cda7dca56
|
@ -1127,3 +1127,23 @@ gimp_viewable_get_children (GimpViewable *viewable)
|
|||
|
||||
return GIMP_VIEWABLE_GET_CLASS (viewable)->get_children (viewable);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_viewable_is_ancestor (GimpViewable *ancestor,
|
||||
GimpViewable *descendant)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_VIEWABLE (ancestor), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_VIEWABLE (descendant), FALSE);
|
||||
|
||||
while (descendant)
|
||||
{
|
||||
GimpViewable *parent = gimp_viewable_get_parent (descendant);
|
||||
|
||||
if (parent == ancestor)
|
||||
return TRUE;
|
||||
|
||||
descendant = parent;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -182,5 +182,8 @@ void gimp_viewable_set_parent (GimpViewable *viewable,
|
|||
|
||||
GimpContainer * gimp_viewable_get_children (GimpViewable *viewable);
|
||||
|
||||
gboolean gimp_viewable_is_ancestor (GimpViewable *ancestor,
|
||||
GimpViewable *descendant);
|
||||
|
||||
|
||||
#endif /* __GIMP_VIEWABLE_H__ */
|
||||
|
|
Loading…
Reference in New Issue