[clutter/wip/apocalypses/apocalypse-1: 29/44] actor: Cosmetic fixes to internal add/remove child
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/apocalypses/apocalypse-1: 29/44] actor: Cosmetic fixes to internal add/remove child
- Date: Fri, 9 Dec 2011 16:32:18 +0000 (UTC)
commit 49f375b6f819ee1c8f1b33cc7d9e4af041b1079e
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Fri Dec 2 16:16:26 2011 +0000
actor: Cosmetic fixes to internal add/remove child
Avoid code duplication all over the place.
clutter/clutter-actor.c | 63 ++++++++++++++++++++++++++++------------------
1 files changed, 38 insertions(+), 25 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index 1aeb71a..9140b31 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -9090,7 +9090,9 @@ static void
clutter_actor_add_child_internal (ClutterActor *self,
ClutterActor *child,
ClutterActorAddChildFunc add_func,
- gpointer data)
+ gpointer data,
+ gboolean create_meta,
+ gboolean emit_signal)
{
ClutterTextDirection text_dir;
@@ -9113,6 +9115,9 @@ clutter_actor_add_child_internal (ClutterActor *self,
return;
}
+ if (create_meta)
+ clutter_container_create_child_meta (CLUTTER_CONTAINER (self), child);
+
g_object_ref_sink (child);
child->priv->parent_actor = self;
@@ -9179,6 +9184,9 @@ clutter_actor_add_child_internal (ClutterActor *self,
{
clutter_actor_queue_compute_expand (self);
}
+
+ if (emit_signal)
+ g_signal_emit_by_name (self, "actor-added", child);
}
/**
@@ -9207,11 +9215,11 @@ clutter_actor_add_child (ClutterActor *self,
g_return_if_fail (self != child);
g_return_if_fail (child->priv->parent_actor == NULL);
- clutter_container_create_child_meta (CLUTTER_CONTAINER (self), child);
clutter_actor_add_child_internal (self, child,
insert_child_at_depth,
- NULL);
- g_signal_emit_by_name (self, "actor-added", child);
+ NULL,
+ TRUE, /* create_meta */
+ TRUE /* emit_signals */);
}
/**
@@ -9244,11 +9252,11 @@ clutter_actor_insert_child_at_index (ClutterActor *self,
g_return_if_fail (child->priv->parent_actor == NULL);
g_return_if_fail (index_ < self->priv->n_children);
- clutter_container_create_child_meta (CLUTTER_CONTAINER (self), child);
clutter_actor_add_child_internal (self, child,
insert_child_at_index,
- GINT_TO_POINTER (index_));
- g_signal_emit_by_name (self, "actor-added", child);
+ GINT_TO_POINTER (index_),
+ TRUE,
+ TRUE);
}
/**
@@ -9285,11 +9293,11 @@ clutter_actor_insert_child_above (ClutterActor *self,
(CLUTTER_IS_ACTOR (sibling) &&
sibling->priv->parent_actor == self));
- clutter_container_create_child_meta (CLUTTER_CONTAINER (self), child);
clutter_actor_add_child_internal (self, child,
insert_child_above,
- sibling);
- g_signal_emit_by_name (self, "actor-added", child);
+ sibling,
+ TRUE,
+ TRUE);
}
/**
@@ -9326,11 +9334,11 @@ clutter_actor_insert_child_below (ClutterActor *self,
(CLUTTER_IS_ACTOR (sibling) &&
sibling->priv->parent_actor == self));
- clutter_container_create_child_meta (CLUTTER_CONTAINER (self), child);
clutter_actor_add_child_internal (self, child,
insert_child_below,
- sibling);
- g_signal_emit_by_name (self, "actor-added", child);
+ sibling,
+ TRUE,
+ TRUE);
}
/**
@@ -9360,7 +9368,9 @@ clutter_actor_set_parent (ClutterActor *self,
clutter_actor_add_child_internal (parent, self,
insert_child_at_depth,
- NULL);
+ NULL,
+ FALSE,
+ FALSE);
}
/**
@@ -9419,10 +9429,15 @@ invalidate_queue_redraw_entry (ClutterActor *self,
static void
clutter_actor_remove_child_internal (ClutterActor *self,
- ClutterActor *child)
+ ClutterActor *child,
+ gboolean destroy_meta,
+ gboolean emit_signal)
{
gboolean was_mapped;
+ if (destroy_meta)
+ clutter_container_destroy_child_meta (CLUTTER_CONTAINER (self), child);
+
was_mapped = CLUTTER_ACTOR_IS_MAPPED (child);
/* we need to unrealize *before* we set parent_actor to NULL,
@@ -9478,6 +9493,10 @@ clutter_actor_remove_child_internal (ClutterActor *self,
clutter_actor_queue_compute_expand (self);
}
+ /* we need to emit the signal before dropping the reference */
+ if (emit_signal)
+ g_signal_emit_by_name (self, "actor-removed", child);
+
/* remove the reference we acquired in clutter_actor_add_child() */
g_object_unref (child);
}
@@ -9509,15 +9528,7 @@ clutter_actor_remove_child (ClutterActor *self,
g_return_if_fail (child->priv->parent_actor != NULL);
g_return_if_fail (child->priv->parent_actor == self);
- g_object_ref (child);
-
- clutter_container_destroy_child_meta (CLUTTER_CONTAINER (self), child);
-
- clutter_actor_remove_child_internal (self, child);
-
- g_signal_emit_by_name (self, "actor-removed", child);
-
- g_object_unref (child);
+ clutter_actor_remove_child_internal (self, child, TRUE, TRUE);
}
/**
@@ -9546,7 +9557,9 @@ clutter_actor_unparent (ClutterActor *self)
if (self->priv->parent_actor == NULL)
return;
- clutter_actor_remove_child_internal (self->priv->parent_actor, self);
+ clutter_actor_remove_child_internal (self->priv->parent_actor, self,
+ FALSE,
+ FALSE);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]