示例#1
0
static inline void
container_add_actor (ClutterContainer *container,
                     ClutterActor     *actor)
{
  ClutterActor *parent;

  parent = clutter_actor_get_parent (actor);
  if (G_UNLIKELY (parent != NULL))
    {
      g_warning ("Attempting to add actor of type '%s' to a "
		 "container of type '%s', but the actor has "
                 "already a parent of type '%s'.",
		 g_type_name (G_OBJECT_TYPE (actor)),
		 g_type_name (G_OBJECT_TYPE (container)),
		 g_type_name (G_OBJECT_TYPE (parent)));
      return;
    }

  clutter_container_create_child_meta (container, actor);

#ifdef CLUTTER_ENABLE_DEBUG
  if (G_UNLIKELY (_clutter_diagnostic_enabled ()))
    {
      ClutterContainerIface *iface = CLUTTER_CONTAINER_GET_IFACE (container);

      if (iface->add != container_real_add)
        _clutter_diagnostic_message ("The ClutterContainer::add() virtual "
                                     "function has been deprecated and it "
                                     "should not be overridden by newly "
                                     "written code");
    }
#endif /* CLUTTER_ENABLE_DEBUG */

  CLUTTER_CONTAINER_GET_IFACE (container)->add (container, actor);
}
示例#2
0
/**
 * clutter_container_add_actor:
 * @container: a #ClutterContainer
 * @actor: the first #ClutterActor to add
 *
 * Adds a #ClutterActor to @container. This function will emit the
 * "actor-added" signal. The actor should be parented to
 * @container. You cannot add a #ClutterActor to more than one
 * #ClutterContainer.
 *
 * Since: 0.4
 */
void
clutter_container_add_actor (ClutterContainer *container,
                             ClutterActor     *actor)
{
  ClutterContainerIface *iface;
  ClutterActor *parent;

  g_return_if_fail (CLUTTER_IS_CONTAINER (container));
  g_return_if_fail (CLUTTER_IS_ACTOR (actor));

  iface = CLUTTER_CONTAINER_GET_IFACE (container);
  if (!iface->add)
    {
      CLUTTER_CONTAINER_WARN_NOT_IMPLEMENTED (container, "add");
      return;
    }

  parent = clutter_actor_get_parent (actor);
  if (parent)
    {
      g_warning ("Attempting to add actor of type '%s' to a "
		 "container of type '%s', but the actor has "
                 "already a parent of type '%s'.",
		 g_type_name (G_OBJECT_TYPE (actor)),
		 g_type_name (G_OBJECT_TYPE (container)),
		 g_type_name (G_OBJECT_TYPE (parent)));
      return;
    }

  clutter_container_create_child_meta (container, actor);

  iface->add (container, actor);
}
示例#3
0
/**
 * clutter_box_pack_at:
 * @box: a #ClutterBox
 * @actor: a #ClutterActor
 * @position: the position to insert the @actor at
 * @first_property: the name of the first property to set, or %NULL
 * @Varargs: a list of property name and value pairs, terminated by %NULL
 *
 * Adds @actor to @box, placing it at @position, and sets layout
 * properties at the same time, if the #ClutterLayoutManager used by
 * @box supports them
 *
 * If @position is a negative number, or is larger than the number of
 * children of @box, the new child is added at the end of the list of
 * children
 *
 * Since: 1.2
 */
void
clutter_box_pack_at (ClutterBox   *box,
                     ClutterActor *actor,
                     gint          position,
                     const gchar  *first_property,
                     ...)
{
  ClutterBoxPrivate *priv;
  va_list var_args;

  g_return_if_fail (CLUTTER_IS_BOX (box));
  g_return_if_fail (CLUTTER_IS_ACTOR (actor));

  priv = box->priv;

  /* this is really clutter_box_add() with a different insert() */
  priv->children = g_list_insert (priv->children,
                                  actor,
                                  position);

  clutter_actor_set_parent (actor, CLUTTER_ACTOR (box));
  clutter_actor_queue_relayout (actor);

  /* we need to explicitly call this, because we're not going through
   * the default code paths provided by clutter_container_add()
   */
  clutter_container_create_child_meta (CLUTTER_CONTAINER (box), actor);

  g_signal_emit_by_name (box, "actor-added", actor);

  if (first_property == NULL || *first_property == '\0')
    return;

  va_start (var_args, first_property);
  clutter_box_set_property_valist (box, actor, first_property, var_args);
  va_end (var_args);
}