From ab76584965ce342017052183e3d70553065ff094 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 7 Jun 2010 21:34:36 +0100 Subject: [PATCH] layout-manager: Implement set_container() Store a back pointer of the layout manager inside the container using the GObject instance data. This introduces a change in the implementation of ClutterLayoutManager, though it's still binary compatible. --- README | 6 ++++++ clutter/clutter-bin-layout.c | 4 ++++ clutter/clutter-box-layout.c | 4 ++++ clutter/clutter-fixed-layout.c | 5 +++++ clutter/clutter-flow-layout.c | 4 ++++ clutter/clutter-layout-manager.c | 15 +++++++++++++++ clutter/clutter-private.h | 3 +++ 7 files changed, 41 insertions(+) diff --git a/README b/README index 4d7e949d1..e40ab4f00 100644 --- a/README +++ b/README @@ -296,6 +296,12 @@ Relevant information for developers with existing Clutter applications wanting to port to newer releases (see NEWS for general information on new features). +Release Notes for Clutter 1.4 +------------------------------------------------------------------------------- + +* ClutterLayoutManager sub-classes should chain up to the parent class's + implementation. + Release Notes for Clutter 1.2 ------------------------------------------------------------------------------- diff --git a/clutter/clutter-bin-layout.c b/clutter/clutter-bin-layout.c index 94a5fd5fb..9135b78df 100644 --- a/clutter/clutter-bin-layout.c +++ b/clutter/clutter-bin-layout.c @@ -559,9 +559,13 @@ clutter_bin_layout_set_container (ClutterLayoutManager *manager, ClutterContainer *container) { ClutterBinLayoutPrivate *priv; + ClutterLayoutManagerClass *parent_class; priv = CLUTTER_BIN_LAYOUT (manager)->priv; priv->container = container; + + parent_class = CLUTTER_LAYOUT_MANAGER_CLASS (clutter_bin_layout_parent_class); + parent_class->set_container (manager, container); } static void diff --git a/clutter/clutter-box-layout.c b/clutter/clutter-box-layout.c index 28730bb5b..4e49b0b98 100644 --- a/clutter/clutter-box-layout.c +++ b/clutter/clutter-box-layout.c @@ -550,6 +550,7 @@ clutter_box_layout_set_container (ClutterLayoutManager *layout, ClutterContainer *container) { ClutterBoxLayoutPrivate *priv = CLUTTER_BOX_LAYOUT (layout)->priv; + ClutterLayoutManagerClass *parent_class; priv->container = container; @@ -566,6 +567,9 @@ clutter_box_layout_set_container (ClutterLayoutManager *layout, clutter_actor_set_request_mode (CLUTTER_ACTOR (priv->container), request_mode); } + + parent_class = CLUTTER_LAYOUT_MANAGER_CLASS (clutter_box_layout_parent_class); + parent_class->set_container (layout, container); } static void diff --git a/clutter/clutter-fixed-layout.c b/clutter/clutter-fixed-layout.c index 2df24ebae..919a856cc 100644 --- a/clutter/clutter-fixed-layout.c +++ b/clutter/clutter-fixed-layout.c @@ -156,6 +156,8 @@ void clutter_fixed_layout_set_container (ClutterLayoutManager *manager, ClutterContainer *container) { + ClutterLayoutManagerClass *parent_class; + if (container != NULL) { g_object_set_data (G_OBJECT (manager), "fixed-container", container); @@ -176,6 +178,9 @@ clutter_fixed_layout_set_container (ClutterLayoutManager *manager, g_object_set_data (G_OBJECT (manager), "fixed-container", NULL); } + + parent_class = CLUTTER_LAYOUT_MANAGER_CLASS (clutter_fixed_layout_parent_class); + parent_class->set_container (manager, container); } static void diff --git a/clutter/clutter-flow-layout.c b/clutter/clutter-flow-layout.c index 937b1ac89..f885a250d 100644 --- a/clutter/clutter-flow-layout.c +++ b/clutter/clutter-flow-layout.c @@ -684,6 +684,7 @@ clutter_flow_layout_set_container (ClutterLayoutManager *manager, ClutterContainer *container) { ClutterFlowLayoutPrivate *priv = CLUTTER_FLOW_LAYOUT (manager)->priv; + ClutterLayoutManagerClass *parent_class; priv->container = container; @@ -700,6 +701,9 @@ clutter_flow_layout_set_container (ClutterLayoutManager *manager, clutter_actor_set_request_mode (CLUTTER_ACTOR (priv->container), request_mode); } + + parent_class = CLUTTER_LAYOUT_MANAGER_CLASS (clutter_flow_layout_parent_class); + parent_class->set_container (manager, container); } static void diff --git a/clutter/clutter-layout-manager.c b/clutter/clutter-layout-manager.c index 5dee44eff..6a28929a4 100644 --- a/clutter/clutter-layout-manager.c +++ b/clutter/clutter-layout-manager.c @@ -361,6 +361,14 @@ layout_manager_real_allocate (ClutterLayoutManager *manager, LAYOUT_MANAGER_WARN_NOT_IMPLEMENTED (manager, "allocate"); } +static void +layout_manager_real_set_container (ClutterLayoutManager *manager, + ClutterContainer *container) +{ + if (container != NULL) + g_object_set_data (G_OBJECT (container), "clutter-layout-manager", manager); +} + static ClutterLayoutMeta * layout_manager_real_create_child_meta (ClutterLayoutManager *manager, ClutterContainer *container, @@ -492,6 +500,7 @@ clutter_layout_manager_class_init (ClutterLayoutManagerClass *klass) klass->begin_animation = layout_manager_real_begin_animation; klass->get_animation_progress = layout_manager_real_get_animation_progress; klass->end_animation = layout_manager_real_end_animation; + klass->set_container = layout_manager_real_set_container; /** * ClutterLayoutManager::layout-changed: @@ -685,6 +694,12 @@ clutter_layout_manager_set_container (ClutterLayoutManager *manager, klass->set_container (manager, container); } +GType +_clutter_layout_manager_get_child_meta_type (ClutterLayoutManager *manager) +{ + return CLUTTER_LAYOUT_MANAGER_GET_CLASS (manager)->get_child_meta_type (manager); +} + static inline ClutterLayoutMeta * create_child_meta (ClutterLayoutManager *manager, ClutterContainer *container, diff --git a/clutter/clutter-private.h b/clutter/clutter-private.h index 88a29a912..5014133f7 100644 --- a/clutter/clutter-private.h +++ b/clutter/clutter-private.h @@ -42,6 +42,7 @@ #include "clutter-event.h" #include "clutter-feature.h" #include "clutter-id-pool.h" +#include "clutter-layout-manager.h" #include "clutter-master-clock.h" #include "clutter-stage-manager.h" #include "clutter-stage-window.h" @@ -335,6 +336,8 @@ gint32 _clutter_backend_get_units_serial (ClutterBackend *backend); gboolean _clutter_effect_pre_paint (ClutterEffect *effect); void _clutter_effect_post_paint (ClutterEffect *effect); +GType _clutter_layout_manager_get_child_meta_type (ClutterLayoutManager *manager); + G_END_DECLS #endif /* _HAVE_CLUTTER_PRIVATE_H */