diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index 44259fed6..41a80e894 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -24,8 +24,8 @@ /** * ClutterActor: - * - * The basic element of the scene graph + * + * The basic element of the scene graph * * The ClutterActor class is the basic element of the scene graph in Clutter, * and it encapsulates the position, size, and transformations of a node in @@ -104,8 +104,8 @@ * given index by using clutter_actor_get_child_at_index(). * * If you need to track additions of children to a #ClutterActor, use - * the #ClutterContainer::actor-added signal; similarly, to track removals - * of children from a ClutterActor, use the #ClutterContainer::actor-removed + * the #ClutterActor::actor-added signal; similarly, to track removals + * of children from a ClutterActor, use the #ClutterActor::actor-removed * signal. * * See [basic-actor.c](https://git.gnome.org/browse/clutter/tree/examples/basic-actor.c?h=clutter-1.18). @@ -537,7 +537,7 @@ #include "clutter/clutter-color-static.h" #include "clutter/clutter-color.h" #include "clutter/clutter-constraint-private.h" -#include "clutter/clutter-container-private.h" +#include "clutter/clutter-container.h" #include "clutter/clutter-content-private.h" #include "clutter/clutter-debug.h" #include "clutter/clutter-easing.h" @@ -926,6 +926,8 @@ enum TRANSITION_STOPPED, STAGE_VIEWS_CHANGED, RESOURCE_SCALE_CHANGED, + ACTOR_ADDED, + ACTOR_REMOVED, CLONED, DECLONED, @@ -4197,7 +4199,7 @@ clutter_actor_remove_child_internal (ClutterActor *self, /* we need to emit the signal before dropping the reference */ if (emit_actor_removed) - _clutter_container_emit_actor_removed (CLUTTER_CONTAINER (self), child); + g_signal_emit (self, actor_signals[ACTOR_REMOVED], 0, child); if (notify_first_last) { @@ -7423,6 +7425,39 @@ clutter_actor_class_init (ClutterActorClass *klass) NULL, NULL, NULL, G_TYPE_NONE, 0); + /** + * ClutterActor::actor-added: + * @actor: the actor which received the signal + * @child: the new child that has been added to @actor + * + * The signal is emitted each time an actor + * has been added to @actor. + */ + actor_signals[ACTOR_ADDED] = + g_signal_new (I_("actor-added"), + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (ClutterActorClass, actor_added), + NULL, NULL, NULL, + G_TYPE_NONE, 1, + CLUTTER_TYPE_ACTOR); + /** + * ClutterActor::actor-removed: + * @actor: the actor which received the signal + * @child: the child that has been removed from @actor + * + * The signal is emitted each time an actor + * is removed from @actor. + */ + actor_signals[ACTOR_REMOVED] = + g_signal_new (I_("actor-removed"), + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (ClutterActorClass, actor_removed), + NULL, NULL, NULL, + G_TYPE_NONE, 1, + CLUTTER_TYPE_ACTOR); + /*< private > */ actor_signals[CLONED] = g_signal_new ("cloned", @@ -11176,7 +11211,7 @@ clutter_actor_add_child_internal (ClutterActor *self, } if (emit_actor_added) - _clutter_container_emit_actor_added (CLUTTER_CONTAINER (self), child); + g_signal_emit (self, actor_signals[ACTOR_ADDED], 0, child); if (notify_first_last) { @@ -11203,7 +11238,7 @@ clutter_actor_add_child_internal (ClutterActor *self, * 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 #ClutterActor::actor-added signal * on @self. */ void @@ -11237,7 +11272,7 @@ clutter_actor_add_child (ClutterActor *self, * 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 #ClutterActor::actor-added signal * on @self. */ void @@ -11272,7 +11307,7 @@ clutter_actor_insert_child_at_index (ClutterActor *self, * 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 #ClutterActor::actor-added signal * on @self. */ void @@ -11311,7 +11346,7 @@ clutter_actor_insert_child_above (ClutterActor *self, * 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 #ClutterActor::actor-added signal * on @self. */ void @@ -11382,7 +11417,7 @@ clutter_actor_get_paint_visibility (ClutterActor *actor) * you will have to acquire a referenced on it before calling this * function. * - * This function will emit the #ClutterContainer::actor-removed + * This function will emit the #ClutterActor::actor-removed * signal on @self. */ void diff --git a/clutter/clutter/clutter-actor.h b/clutter/clutter/clutter-actor.h index 0df54be9a..2cfe5d3ca 100644 --- a/clutter/clutter/clutter-actor.h +++ b/clutter/clutter/clutter-actor.h @@ -246,6 +246,11 @@ struct _ClutterActorClass void (* resource_scale_changed) (ClutterActor *self); float (* calculate_resource_scale) (ClutterActor *self, int phase); + + void (* actor_added) (ClutterActor *self, + ClutterActor *child); + void (* actor_removed) (ClutterActor *self, + ClutterActor *child); }; /** diff --git a/clutter/clutter/clutter-container-private.h b/clutter/clutter/clutter-container-private.h deleted file mode 100644 index 04a3f86b1..000000000 --- a/clutter/clutter/clutter-container-private.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Clutter. - * - * An OpenGL based 'interactive canvas' library. - * - * Copyright 2020 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#pragma once - -#include "clutter/clutter-container.h" - -G_BEGIN_DECLS - -void _clutter_container_emit_actor_added (ClutterContainer *container, - ClutterActor *actor); -void _clutter_container_emit_actor_removed (ClutterContainer *container, - ClutterActor *actor); - -G_END_DECLS diff --git a/clutter/clutter/clutter-container.c b/clutter/clutter/clutter-container.c index 138d15dc2..f8c97e15e 100644 --- a/clutter/clutter/clutter-container.c +++ b/clutter/clutter/clutter-container.c @@ -37,7 +37,6 @@ #include "clutter/clutter-actor-private.h" #include "clutter/clutter-child-meta.h" -#include "clutter/clutter-container-private.h" #include "clutter/clutter-debug.h" #include "clutter/clutter-main.h" #include "clutter/clutter-marshal.h" @@ -64,7 +63,7 @@ /** * ClutterContainer: - * + * * An interface for container actors * * #ClutterContainer is an interface implemented by [class@Actor], and @@ -75,8 +74,6 @@ enum { - ACTOR_ADDED, - ACTOR_REMOVED, CHILD_NOTIFY, LAST_SIGNAL @@ -121,39 +118,6 @@ clutter_container_default_init (ClutterContainerInterface *iface) quark_child_meta = g_quark_from_static_string ("clutter-container-child-data"); - /** - * ClutterContainer::actor-added: - * @container: the actor which received the signal - * @actor: the new child that has been added to @container - * - * The signal is emitted each time an actor - * has been added to @container. - */ - container_signals[ACTOR_ADDED] = - g_signal_new (I_("actor-added"), - iface_type, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (ClutterContainerIface, actor_added), - NULL, NULL, NULL, - G_TYPE_NONE, 1, - CLUTTER_TYPE_ACTOR); - /** - * ClutterContainer::actor-removed: - * @container: the actor which received the signal - * @actor: the child that has been removed from @container - * - * The signal is emitted each time an actor - * is removed from @container. - */ - container_signals[ACTOR_REMOVED] = - g_signal_new (I_("actor-removed"), - iface_type, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (ClutterContainerIface, actor_removed), - NULL, NULL, NULL, - G_TYPE_NONE, 1, - CLUTTER_TYPE_ACTOR); - /** * ClutterContainer::child-notify: * @container: the container which received the signal @@ -765,7 +729,7 @@ clutter_container_child_set (ClutterContainer *container, GObjectClass *klass; const gchar *name; va_list var_args; - + g_return_if_fail (CLUTTER_IS_CONTAINER (container)); g_return_if_fail (CLUTTER_IS_ACTOR (actor)); @@ -779,7 +743,7 @@ clutter_container_child_set (ClutterContainer *container, GValue value = G_VALUE_INIT; gchar *error = NULL; GParamSpec *pspec; - + pspec = clutter_container_class_find_child_property (klass, name); if (!pspec) { @@ -898,7 +862,7 @@ clutter_container_child_get_property (ClutterContainer *container, * * In general, a copy is made of the property contents and the caller is * responsible for freeing the memory in the appropriate manner for the type, for - * instance by calling g_free() or g_object_unref(). + * instance by calling g_free() or g_object_unref(). */ void clutter_container_child_get (ClutterContainer *container, @@ -909,7 +873,7 @@ clutter_container_child_get (ClutterContainer *container, GObjectClass *klass; const gchar *name; va_list var_args; - + g_return_if_fail (CLUTTER_IS_CONTAINER (container)); g_return_if_fail (CLUTTER_IS_ACTOR (actor)); @@ -923,7 +887,7 @@ clutter_container_child_get (ClutterContainer *container, GValue value = G_VALUE_INIT; gchar *error = NULL; GParamSpec *pspec; - + pspec = clutter_container_class_find_child_property (klass, name); if (!pspec) { @@ -985,23 +949,3 @@ clutter_container_child_notify (ClutterContainer *container, child, pspec); } - -void -_clutter_container_emit_actor_added (ClutterContainer *container, - ClutterActor *actor) -{ - g_return_if_fail (CLUTTER_IS_CONTAINER (container)); - g_return_if_fail (CLUTTER_IS_ACTOR (actor)); - - g_signal_emit (container, container_signals[ACTOR_ADDED], 0, actor); -} - -void -_clutter_container_emit_actor_removed (ClutterContainer *container, - ClutterActor *actor) -{ - g_return_if_fail (CLUTTER_IS_CONTAINER (container)); - g_return_if_fail (CLUTTER_IS_ACTOR (actor)); - - g_signal_emit (container, container_signals[ACTOR_REMOVED], 0, actor); -} diff --git a/src/tests/clutter/conform/actor-graph.c b/src/tests/clutter/conform/actor-graph.c index 06255ebe8..5110c303f 100644 --- a/src/tests/clutter/conform/actor-graph.c +++ b/src/tests/clutter/conform/actor-graph.c @@ -400,9 +400,9 @@ actor_remove_all (void) } static void -actor_added (ClutterContainer *container, - ClutterActor *child, - gpointer data) +actor_added (ClutterActor *container, + ClutterActor *child, + gpointer data) { ClutterActor *actor = CLUTTER_ACTOR (container); int *counter = data; @@ -419,9 +419,9 @@ actor_added (ClutterContainer *container, } static void -actor_removed (ClutterContainer *container, - ClutterActor *child, - gpointer data) +actor_removed (ClutterActor *container, + ClutterActor *child, + gpointer data) { int *counter = data;