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.
This commit is contained in:
Emmanuele Bassi 2010-06-07 21:34:36 +01:00
parent 8583986e16
commit ab76584965
7 changed files with 41 additions and 0 deletions

6
README
View File

@ -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
-------------------------------------------------------------------------------

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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 */