/** * clutter_behaviour_get_n_actors: * @behave: a #ClutterBehaviour * * Gets the number of actors this behaviour is applied too. * * Return value: The number of applied actors * * Since: 0.2 */ gint clutter_behaviour_get_n_actors (ClutterBehaviour *behave) { g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR (behave), 0); return g_slist_length (behave->priv->actors); }
/** * clutter_behaviour_get_alpha: * @behave: a #ClutterBehaviour * * Retrieves the #ClutterAlpha object bound to @behave. * * Return value: (transfer none): a #ClutterAlpha object, or %NULL if no alpha * object has been bound to this behaviour. * * Since: 0.2 */ ClutterAlpha * clutter_behaviour_get_alpha (ClutterBehaviour *behave) { g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR (behave), NULL); return behave->priv->alpha; }
/** * clutter_behaviour_remove: * @behave: a #ClutterBehaviour * @actor: a #ClutterActor * * Removes @actor from the list of #ClutterActor<!-- -->s to which * @behave applies. This function removes a reference on the actor. * * Since: 0.2 */ void clutter_behaviour_remove (ClutterBehaviour *behave, ClutterActor *actor) { ClutterBehaviourPrivate *priv; g_return_if_fail (CLUTTER_IS_BEHAVIOUR (behave)); g_return_if_fail (CLUTTER_IS_ACTOR (actor)); priv = behave->priv; if (!g_slist_find (priv->actors, actor)) { g_warning ("The behaviour of type %s is not applied " "to the actor of type %s", g_type_name (G_OBJECT_TYPE (behave)), g_type_name (G_OBJECT_TYPE (actor))); return; } g_signal_handlers_disconnect_by_func (actor, G_CALLBACK (remove_actor_on_destroy), behave); priv->actors = g_slist_remove (priv->actors, actor); g_signal_emit (behave, behave_signals[REMOVED], 0, actor); g_object_unref (actor); }
/** * clutter_behaviour_apply: * @behave: a #ClutterBehaviour * @actor: a #ClutterActor * * Applies @behave to @actor. This function adds a reference on * the actor. * * Since: 0.2 */ void clutter_behaviour_apply (ClutterBehaviour *behave, ClutterActor *actor) { ClutterBehaviourPrivate *priv; g_return_if_fail (CLUTTER_IS_BEHAVIOUR (behave)); g_return_if_fail (CLUTTER_IS_ACTOR (actor)); priv = behave->priv; if (g_slist_find (priv->actors, actor)) { g_warning ("The behaviour of type %s already applies " "to the actor of type %s", g_type_name (G_OBJECT_TYPE (behave)), g_type_name (G_OBJECT_TYPE (actor))); return; } priv->actors = g_slist_append (priv->actors, g_object_ref (actor)); g_signal_connect (actor, "destroy", G_CALLBACK (remove_actor_on_destroy), behave); g_signal_emit (behave, behave_signals[APPLIED], 0, actor); }
/** * clutter_behaviour_get_nth_actor: * @behave: a #ClutterBehaviour * @index_: the index of an actor this behaviour is applied too. * * Gets an actor the behaviour was applied to referenced by index num. * * Return value: (transfer none): A Clutter actor or NULL if @index_ is invalid. * * Since: 0.2 */ ClutterActor* clutter_behaviour_get_nth_actor (ClutterBehaviour *behave, gint index_) { g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR (behave), NULL); return g_slist_nth_data (behave->priv->actors, index_); }
/** * clutter_behaviour_is_applied: * @behave: a #ClutterBehaviour * @actor: a #ClutterActor * * Check if @behave applied to @actor. * * Return value: TRUE if actor has behaviour. FALSE otherwise. * * Since: 0.4 */ gboolean clutter_behaviour_is_applied (ClutterBehaviour *behave, ClutterActor *actor) { g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR (behave), FALSE); g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), FALSE); return (g_slist_find (behave->priv->actors, actor) != NULL); }
void clarity_cover_clear_rotation_behaviour(ClarityCover *self) { g_return_if_fail(CLARITY_IS_COVER(self)); ClutterBehaviour *behaviour = self->priv->rotateBehaviour; if (CLUTTER_IS_BEHAVIOUR(behaviour) && clutter_behaviour_is_applied(behaviour, CLUTTER_ACTOR(self))) { clutter_behaviour_remove(behaviour, CLUTTER_ACTOR(self)); self->priv->rotateBehaviour = NULL; } }
/** * clutter_behaviour_set_alpha: * @behave: a #ClutterBehaviour * @alpha: a #ClutterAlpha or %NULL to unset a previously set alpha * * Binds @alpha to a #ClutterBehaviour. The #ClutterAlpha object * is what makes a behaviour work: for each tick of the timeline * used by #ClutterAlpha a new value of the alpha parameter is * computed by the alpha function; the value should be used by * the #ClutterBehaviour to update one or more properties of the * actors to which the behaviour applies. * * If @alpha is not %NULL, the #ClutterBehaviour will take ownership * of the #ClutterAlpha instance. * * Since: 0.2 */ void clutter_behaviour_set_alpha (ClutterBehaviour *behave, ClutterAlpha *alpha) { ClutterBehaviourPrivate *priv; g_return_if_fail (CLUTTER_IS_BEHAVIOUR (behave)); g_return_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha)); priv = behave->priv; if (priv->alpha == alpha) return; if (priv->notify_id) { CLUTTER_NOTE (BEHAVIOUR, "removing previous notify-id (%d)", priv->notify_id); g_signal_handler_disconnect (priv->alpha, priv->notify_id); priv->notify_id = 0; } if (priv->alpha != NULL) { CLUTTER_NOTE (BEHAVIOUR, "removing previous alpha object"); g_object_unref (priv->alpha); priv->alpha = NULL; } if (alpha != NULL) { priv->alpha = g_object_ref_sink (alpha); priv->notify_id = g_signal_connect (priv->alpha, "notify::alpha", G_CALLBACK(notify_cb), behave); CLUTTER_NOTE (BEHAVIOUR, "setting new alpha object (%p, notify:%d)", priv->alpha, priv->notify_id); } g_object_notify_by_pspec (G_OBJECT (behave), obj_props[PROP_ALPHA]); }
/** * clutter_behaviour_actors_foreach: * @behave: a #ClutterBehaviour * @func: (scope call): a function called for each actor * @data: optional data to be passed to the function, or %NULL * * Calls @func for every actor driven by @behave. * * Since: 0.2 */ void clutter_behaviour_actors_foreach (ClutterBehaviour *behave, ClutterBehaviourForeachFunc func, gpointer data) { GSList *l; g_return_if_fail (CLUTTER_IS_BEHAVIOUR (behave)); g_return_if_fail (func != NULL); for (l = behave->priv->actors; l != NULL; l = l->next) { ClutterActor *actor = l->data; g_assert (CLUTTER_IS_ACTOR (actor)); func (behave, actor, data); } }
/** * clutter_behaviour_remove_all: * @behave: a #ClutterBehaviour * * Removes every actor from the list that @behave holds. * * Since: 0.4 */ void clutter_behaviour_remove_all (ClutterBehaviour *behave) { ClutterBehaviourPrivate *priv; GSList *l; g_return_if_fail (CLUTTER_IS_BEHAVIOUR (behave)); priv = behave->priv; for (l = priv->actors; l != NULL; l = l->next) { ClutterActor *actor = l->data; g_signal_emit (behave, behave_signals[REMOVED], 0, actor); g_signal_handlers_disconnect_by_func (actor, G_CALLBACK (remove_actor_on_destroy), behave); g_object_unref (actor); } g_slist_free (priv->actors); priv->actors = NULL; }