GType clutter_action_get_type (void) G_GNUC_CONST;
/* ClutterActor API */
-void clutter_actor_add_action (ClutterActor *self,
- ClutterAction *action);
-void clutter_actor_remove_action (ClutterActor *self,
- ClutterAction *action);
-GList *clutter_actor_get_actions (ClutterActor *self);
-void clutter_actor_clear_actions (ClutterActor *self);
+void clutter_actor_add_action (ClutterActor *self,
+ ClutterAction *action);
+void clutter_actor_add_action_with_name (ClutterActor *self,
+ const gchar *name,
+ ClutterAction *action);
+void clutter_actor_remove_action (ClutterActor *self,
+ ClutterAction *action);
+void clutter_actor_remove_action_by_name (ClutterActor *self,
+ const gchar *name);
+ClutterAction *clutter_actor_get_action (ClutterActor *self,
+ const gchar *name);
+GList * clutter_actor_get_actions (ClutterActor *self);
+void clutter_actor_clear_actions (ClutterActor *self);
G_END_DECLS
}
/**
+ * clutter_actor_add_action_with_name:
+ * @self: a #ClutterActor
+ * @name: the name to set on the action
+ * @constraint: a #ClutterAction
+ *
+ * A convenience function for setting the name of a #ClutterAction
+ * while adding it to the list of actions applied to @self
+ *
+ * This function is the logical equivalent of:
+ *
+ * |[
+ * clutter_actor_meta_set_name (CLUTTER_ACTOR_META (action), name);
+ * clutter_actor_add_action (self, action);
+ * ]|
+ *
+ * Since: 1.4
+ */
+void
+clutter_actor_add_action_with_name (ClutterActor *self,
+ const gchar *name,
+ ClutterAction *action)
+{
+ g_return_if_fail (CLUTTER_IS_ACTOR (self));
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (CLUTTER_IS_ACTION (self));
+
+ clutter_actor_meta_set_name (CLUTTER_ACTOR_META (action), name);
+ clutter_actor_add_action (self, action);
+}
+
+/**
* clutter_actor_remove_action:
* @self: a #ClutterActor
* @action: a #ClutterAction
}
/**
+ * clutter_actor_remove_action_by_name:
+ * @self: a #ClutterActor
+ * @name: the name of the action to remove
+ *
+ * Removes the #ClutterAction with the given name from the list
+ * of actions applied to @self
+ *
+ * Since: 1.4
+ */
+void
+clutter_actor_remove_action_by_name (ClutterActor *self,
+ const gchar *name)
+{
+ ClutterActorPrivate *priv;
+ ClutterActorMeta *meta;
+
+ g_return_if_fail (CLUTTER_IS_ACTOR (self));
+ g_return_if_fail (name != NULL);
+
+ priv = self->priv;
+
+ if (priv->actions == NULL)
+ return;
+
+ meta = _clutter_meta_group_get_meta (priv->actions, name);
+ if (meta == NULL)
+ return;
+
+ _clutter_meta_group_remove_meta (priv->actions, meta);
+
+ g_object_notify (G_OBJECT (self), "actions");
+}
+
+/**
* clutter_actor_get_actions:
* @self: a #ClutterActor
*
}
/**
+ * clutter_actor_get_action:
+ * @self: a #ClutterActor
+ * @name: the name of the action to retrieve
+ *
+ * Retrieves the #ClutterAction with the given name in the list
+ * of actions applied to @self
+ *
+ * Return value: (transfer none): a #ClutterAction for the given
+ * name, or %NULL. The returned #ClutterAction is owned by the
+ * actor and it should not be unreferenced directly
+ *
+ * Since: 1.4
+ */
+ClutterAction *
+clutter_actor_get_action (ClutterActor *self,
+ const gchar *name)
+{
+ g_return_val_if_fail (CLUTTER_IS_ACTOR (self), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ if (self->priv->actions == NULL)
+ return NULL;
+
+ return CLUTTER_ACTION (_clutter_meta_group_get_meta (self->priv->actions, name));
+}
+
+/**
* clutter_actor_clear_actions:
* @self: a #ClutterActor
*
}
/**
+ * clutter_actor_add_constraint_with_name:
+ * @self: a #ClutterActor
+ * @name: the name to set on the constraint
+ * @constraint: a #ClutterConstraint
+ *
+ * A convenience function for setting the name of a #ClutterConstraint
+ * while adding it to the list of constraints applied to @self
+ *
+ * This function is the logical equivalent of:
+ *
+ * |[
+ * clutter_actor_meta_set_name (CLUTTER_ACTOR_META (constraint), name);
+ * clutter_actor_add_constraint (self, constraint);
+ * ]|
+ *
+ * Since: 1.4
+ */
+void
+clutter_actor_add_constraint_with_name (ClutterActor *self,
+ const gchar *name,
+ ClutterConstraint *constraint)
+{
+ g_return_if_fail (CLUTTER_IS_ACTOR (self));
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (CLUTTER_IS_CONSTRAINT (constraint));
+
+ clutter_actor_meta_set_name (CLUTTER_ACTOR_META (constraint), name);
+ clutter_actor_add_constraint (self, constraint);
+}
+
+/**
* clutter_actor_remove_constraint:
* @self: a #ClutterActor
* @constraint: a #ClutterConstraint
}
/**
+ * clutter_actor_remove_constraint_by_name:
+ * @self: a #ClutterActor
+ * @name: the name of the constraint to remove
+ *
+ * Removes the #ClutterConstraint with the given name from the list
+ * of constraints applied to @self
+ *
+ * Since: 1.4
+ */
+void
+clutter_actor_remove_constraint_by_name (ClutterActor *self,
+ const gchar *name)
+{
+ ClutterActorPrivate *priv;
+ ClutterActorMeta *meta;
+
+ g_return_if_fail (CLUTTER_IS_ACTOR (self));
+ g_return_if_fail (name != NULL);
+
+ priv = self->priv;
+
+ if (priv->constraints == NULL)
+ return;
+
+ meta = _clutter_meta_group_get_meta (priv->constraints, name);
+ if (meta == NULL)
+ return;
+
+ _clutter_meta_group_remove_meta (priv->constraints, meta);
+}
+
+/**
* clutter_actor_get_constraints:
* @self: a #ClutterActor
*
}
/**
+ * clutter_actor_get_constraint:
+ * @self: a #ClutterActor
+ * @name: the name of the constraint to retrieve
+ *
+ * Retrieves the #ClutterConstraint with the given name in the list
+ * of constraints applied to @self
+ *
+ * Return value: (transfer none): a #ClutterConstraint for the given
+ * name, or %NULL. The returned #ClutterConstraint is owned by the
+ * actor and it should not be unreferenced directly
+ *
+ * Since: 1.4
+ */
+ClutterConstraint *
+clutter_actor_get_constraint (ClutterActor *self,
+ const gchar *name)
+{
+ g_return_val_if_fail (CLUTTER_IS_ACTOR (self), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ if (self->priv->constraints == NULL)
+ return NULL;
+
+ return CLUTTER_CONSTRAINT (_clutter_meta_group_get_meta (self->priv->constraints, name));
+}
+
+/**
* clutter_actor_clear_constraints:
* @self: a #ClutterActor
*
GType clutter_constraint_get_type (void) G_GNUC_CONST;
/* ClutterActor API */
-void clutter_actor_add_constraint (ClutterActor *self,
- ClutterConstraint *constraint);
-void clutter_actor_remove_constraint (ClutterActor *self,
- ClutterConstraint *constraint);
-GList *clutter_actor_get_constraints (ClutterActor *self);
-void clutter_actor_clear_constraints (ClutterActor *self);
+void clutter_actor_add_constraint (ClutterActor *self,
+ ClutterConstraint *constraint);
+void clutter_actor_add_constraint_with_name (ClutterActor *self,
+ const gchar *name,
+ ClutterConstraint *constraint);
+void clutter_actor_remove_constraint (ClutterActor *self,
+ ClutterConstraint *constraint);
+void clutter_actor_remove_constraint_by_name (ClutterActor *self,
+ const gchar *name);
+GList * clutter_actor_get_constraints (ClutterActor *self);
+ClutterConstraint *clutter_actor_get_constraint (ClutterActor *self,
+ const gchar *name);
+void clutter_actor_clear_constraints (ClutterActor *self);
G_END_DECLS
clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect);
constraint = clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5);
- clutter_actor_meta_set_name (CLUTTER_ACTOR_META (constraint), "x-align");
- clutter_actor_add_constraint (rect, constraint);
+ clutter_actor_add_constraint_with_name (rect, "x-align", constraint);
constraint = clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.5);
- clutter_actor_meta_set_name (CLUTTER_ACTOR_META (constraint), "y-align");
- clutter_actor_add_constraint (rect, constraint);
+ clutter_actor_add_constraint_with_name (rect, "y-align", constraint);
rects[Center] = rect;
clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect);
constraint = clutter_bind_constraint_new (rects[Center], CLUTTER_BIND_X, 0.0);
- clutter_actor_meta_set_name (CLUTTER_ACTOR_META (constraint), "x-bind");
- clutter_actor_add_constraint (rect, constraint);
+ clutter_actor_add_constraint_with_name (rect, "x-bind", constraint);
constraint = clutter_bind_constraint_new (rects[Center], CLUTTER_BIND_Y, 0.0);
- clutter_actor_meta_set_name (CLUTTER_ACTOR_META (constraint), "y-bind");
- clutter_actor_add_constraint (rect, constraint);
+ clutter_actor_add_constraint_with_name (rect, "y-bind", constraint);
rects[i] = rect;
}