diff --git a/clutter/clutter-layout-manager.c b/clutter/clutter-layout-manager.c index 2a2db6878..b46641265 100644 --- a/clutter/clutter-layout-manager.c +++ b/clutter/clutter-layout-manager.c @@ -299,6 +299,34 @@ clutter_layout_manager_layout_changed (ClutterLayoutManager *manager) g_signal_emit (manager, manager_signals[LAYOUT_CHANGED], 0); } +/** + * clutter_layout_manager_set_container: + * @manager: a #ClutterLayoutManager + * @container: (allow-none): a #ClutterContainer using @manager + * + * If the #ClutterLayoutManager sub-class allows it, allow + * adding a weak reference of the @container using @manager + * from within the layout manager + * + * The layout manager should not increase the reference + * count of the @container + * + * Since: 1.2 + */ +void +clutter_layout_manager_set_container (ClutterLayoutManager *manager, + ClutterContainer *container) +{ + ClutterLayoutManagerClass *klass; + + g_return_if_fail (CLUTTER_IS_LAYOUT_MANAGER (manager)); + g_return_if_fail (container == NULL || CLUTTER_IS_CONTAINER (container)); + + klass = CLUTTER_LAYOUT_MANAGER_GET_CLASS (manager); + if (klass->set_container) + klass->set_container (manager, container); +} + static inline ClutterLayoutMeta * create_child_meta (ClutterLayoutManager *manager, ClutterContainer *container, diff --git a/clutter/clutter-layout-manager.h b/clutter/clutter-layout-manager.h index aabeabca9..d3333c7cb 100644 --- a/clutter/clutter-layout-manager.h +++ b/clutter/clutter-layout-manager.h @@ -57,6 +57,9 @@ struct _ClutterLayoutManager { /*< private >*/ GInitiallyUnowned parent_instance; + + /* padding for future expansion */ + gpointer dummy; }; /** @@ -70,6 +73,10 @@ struct _ClutterLayoutManager * @allocate: virtual function; override to allocate the children of the * layout manager. See also the allocate() virtual function in * #ClutterActor + * @set_container: virtual function; override to set a back pointer + * on the #ClutterContainer using the layout manager. The implementation + * should not take a reference on the container, but just take a weak + * reference, to avoid potential leaks due to reference cycles * @create_child_meta: virtual function; override to create a * #ClutterChildMeta instance associated to a #ClutterContainer and a * child #ClutterActor, used to maintain layout manager specific properties @@ -102,6 +109,9 @@ struct _ClutterLayoutManagerClass const ClutterActorBox *allocation, ClutterAllocationFlags flags); + void (* set_container) (ClutterLayoutManager *manager, + ClutterContainer *container); + ClutterLayoutMeta *(* create_child_meta) (ClutterLayoutManager *manager, ClutterContainer *container, ClutterActor *actor); @@ -137,6 +147,8 @@ void clutter_layout_manager_allocate (ClutterLayoutMan const ClutterActorBox *allocation, ClutterAllocationFlags flags); +void clutter_layout_manager_set_container (ClutterLayoutManager *manager, + ClutterContainer *container); void clutter_layout_manager_layout_changed (ClutterLayoutManager *manager); ClutterLayoutMeta *clutter_layout_manager_get_child_meta (ClutterLayoutManager *manager, diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 31864a961..21d9c51c3 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -1735,6 +1735,7 @@ clutter_layout_manager_get_preferred_width clutter_layout_manager_get_preferred_height clutter_layout_manager_allocate clutter_layout_manager_layout_changed +clutter_layout_manager_set_container clutter_layout_manager_add_child_meta