A simple method for removing all children of an actor in one fell swoop.
* This function will take into consideration the #ClutterActor:depth
* of @child, and will keep the list of children sorted.
*
- * This function will emit the #ClutterContainer::actor-added signal.
+ * This function will emit the #ClutterContainer::actor-added signal
+ * on @self.
*
* Since: 1.10
*/
* This function will not take into consideration the #ClutterActor:depth
* of @child.
*
- * This function will emit the #ClutterContainer::actor-added signal.
+ * This function will emit the #ClutterContainer::actor-added signal
+ * on @self.
*
* Since: 1.10
*/
* This function will not take into consideration the #ClutterActor:depth
* of @child.
*
- * This function will emit the #ClutterContainer::actor-added signal.
+ * This function will emit the #ClutterContainer::actor-added signal
+ * on @self.
*
* Since: 1.10
*/
* This function will not take into consideration the #ClutterActor:depth
* of @child.
*
- * This function will emit the #ClutterContainer::actor-added signal.
+ * This function will emit the #ClutterContainer::actor-added signal
+ * on @self.
*
* Since: 1.10
*/
* function.
*
* This function will emit the #ClutterContainer::actor-removed
- * signal.
+ * signal on @self.
*
* Since: 1.10
*/
clutter_actor_remove_child_internal (self, child, TRUE, TRUE);
}
+/**
+ * clutter_actor_remove_all_children:
+ * @self: a #ClutterActor
+ *
+ * Removes all children of @self.
+ *
+ * This function releases the reference added by inserting a child actor
+ * in the list of children of @self.
+ *
+ * Since: 1.10
+ */
+void
+clutter_actor_remove_all_children (ClutterActor *self)
+{
+ ClutterActor *iter;
+
+ g_return_if_fail (CLUTTER_IS_ACTOR (self));
+
+ if (self->priv->n_children == 0)
+ return;
+
+ iter = self->priv->first_child;
+ while (iter != NULL)
+ {
+ ClutterActor *next = iter->priv->next_sibling;
+
+ clutter_actor_remove_child_internal (self, iter, TRUE, TRUE);
+
+ iter = next;
+ }
+
+ g_assert (self->priv->first_child == NULL);
+ g_assert (self->priv->last_child == NULL);
+ g_assert (self->priv->n_children == 0);
+}
+
typedef struct _InsertBetweenData {
ClutterActor *prev_sibling;
ClutterActor *next_sibling;
ClutterActor *new_child);
void clutter_actor_remove_child (ClutterActor *self,
ClutterActor *child);
+void clutter_actor_remove_all_children (ClutterActor *self);
GList * clutter_actor_get_children (ClutterActor *self);
gint clutter_actor_get_n_children (ClutterActor *self);
ClutterActor * clutter_actor_get_child_at_index (ClutterActor *self,
clutter_actor_destroy (actor);
g_object_unref (actor);
}
+
+void
+actor_remove_all (TestConformSimpleFixture *fixture,
+ gconstpointer dummy)
+{
+ ClutterActor *actor = clutter_actor_new ();
+
+ g_object_ref_sink (actor);
+
+ clutter_actor_add_child (actor, g_object_new (CLUTTER_TYPE_ACTOR,
+ "name", "foo",
+ NULL));
+ clutter_actor_add_child (actor, g_object_new (CLUTTER_TYPE_ACTOR,
+ "name", "bar",
+ NULL));
+ clutter_actor_add_child (actor, g_object_new (CLUTTER_TYPE_ACTOR,
+ "name", "baz",
+ NULL));
+
+ g_assert_cmpint (clutter_actor_get_n_children (actor), ==, 3);
+
+ clutter_actor_remove_all_children (actor);
+
+ g_assert_cmpint (clutter_actor_get_n_children (actor), ==, 0);
+
+ clutter_actor_destroy (actor);
+ g_object_unref (actor);
+}
TEST_CONFORM_SIMPLE ("/actor", actor_add_child);
TEST_CONFORM_SIMPLE ("/actor", actor_insert_child);
- TEST_CONFORM_SIMPLE ("/actor", actor_remove_child);
TEST_CONFORM_SIMPLE ("/actor", actor_raise_child);
TEST_CONFORM_SIMPLE ("/actor", actor_lower_child);
TEST_CONFORM_SIMPLE ("/actor", actor_replace_child);
+ TEST_CONFORM_SIMPLE ("/actor", actor_remove_child);
+ TEST_CONFORM_SIMPLE ("/actor", actor_remove_all);
TEST_CONFORM_SIMPLE ("/actor", actor_destruction);
TEST_CONFORM_SIMPLE ("/actor", actor_anchors);
TEST_CONFORM_SIMPLE ("/actor", actor_picking);