[container] Use a 1:1 mapping between child and ChildMeta

Since an actor can only be parented to one container we don't need
the extra complications of maintaining a list of ChildMeta objects
attached to an actor in the default implementation of the Container
interface.
This commit is contained in:
Emmanuele Bassi 2009-09-14 15:57:31 +01:00
parent 6e3afa4ebe
commit abbe2ebf8b

View File

@ -700,23 +700,14 @@ get_child_meta (ClutterContainer *container,
ClutterActor *actor) ClutterActor *actor)
{ {
ClutterContainerIface *iface = CLUTTER_CONTAINER_GET_IFACE (container); ClutterContainerIface *iface = CLUTTER_CONTAINER_GET_IFACE (container);
ClutterChildMeta *meta;
if (iface->child_meta_type == G_TYPE_INVALID) if (iface->child_meta_type == G_TYPE_INVALID)
return NULL; return NULL;
else
{
ClutterChildMeta *child_meta = NULL;
GSList *list, *iter;
list = g_object_get_qdata (G_OBJECT (container), quark_child_meta); meta = g_object_get_qdata (G_OBJECT (actor), quark_child_meta);
for (iter = list; iter; iter = g_slist_next (iter)) if (meta != NULL && meta->actor == actor)
{ return meta;
child_meta = iter->data;
if (child_meta->actor == actor)
return child_meta;
}
}
return NULL; return NULL;
} }
@ -727,7 +718,6 @@ create_child_meta (ClutterContainer *container,
{ {
ClutterContainerIface *iface = CLUTTER_CONTAINER_GET_IFACE (container); ClutterContainerIface *iface = CLUTTER_CONTAINER_GET_IFACE (container);
ClutterChildMeta *child_meta = NULL; ClutterChildMeta *child_meta = NULL;
GSList *data_list = NULL;
if (iface->child_meta_type == G_TYPE_INVALID) if (iface->child_meta_type == G_TYPE_INVALID)
return; return;
@ -744,9 +734,9 @@ create_child_meta (ClutterContainer *container,
"actor", actor, "actor", actor,
NULL); NULL);
data_list = g_object_get_qdata (G_OBJECT (container), quark_child_meta); g_object_set_qdata_full (G_OBJECT (container), quark_child_meta,
data_list = g_slist_prepend (data_list, child_meta); child_meta,
g_object_set_qdata (G_OBJECT (container), quark_child_meta, data_list); (GDestroyNotify) g_object_unref);
} }
static void static void
@ -758,30 +748,8 @@ destroy_child_meta (ClutterContainer *container,
if (iface->child_meta_type == G_TYPE_INVALID) if (iface->child_meta_type == G_TYPE_INVALID)
return; return;
else
{
ClutterChildMeta *child_meta = NULL;
GSList *list = g_object_get_qdata (object, quark_child_meta);
GSList *iter;
for (iter = list; iter; iter = g_slist_next (iter)) g_object_set_qdata (object, quark_child_meta, NULL);
{
child_meta = iter->data;
if (child_meta->actor == actor)
break;
else
child_meta = NULL;
}
if (child_meta)
{
list = g_slist_remove (list, child_meta);
g_object_set_qdata (object, quark_child_meta, list);
g_object_unref (child_meta);
}
}
} }
/** /**