示例#1
0
/* composite actors should implement destroy(), and inside their
 * implementation destroy any actors they are composed from;
 * in this case, we just destroy the child ClutterBox
 */
void clarity_cover_destroy(ClutterActor *self) {
    ClarityCoverPrivate *priv = CLARITY_COVER_GET_PRIVATE(self);

    if (priv) {
        if (CLUTTER_IS_ACTOR(priv->texture)) {
            clutter_actor_destroy(priv->texture);
            priv->texture = NULL;
        }

        if (CLUTTER_IS_ACTOR(priv->reflection)) {
            clutter_actor_destroy(priv->reflection);
            priv->reflection = NULL;
        }

        if (G_IS_OBJECT(priv->rotateBehaviour))
            priv->rotateBehaviour = NULL;
    }

    /* chain up to destroy() on the parent ClutterActorClass;
     * note that we check the parent class has a destroy() implementation
     * before calling it
     */
    if (CLUTTER_ACTOR_CLASS(clarity_cover_parent_class)->destroy)
        CLUTTER_ACTOR_CLASS(clarity_cover_parent_class)->destroy(self);
}
ClutterBox2DJoint *
clutter_box2d_add_weld_joint (ClutterBox2D        *box2d,
                              ClutterActor        *actor1,
                              ClutterActor        *actor2,
                              const ClutterVertex *anchor1,
                              const ClutterVertex *anchor2)
{
    ClutterBox2DPrivate *priv;
    b2WeldJointDef jd;

    g_return_val_if_fail (CLUTTER_IS_BOX2D (box2d), NULL);
    g_return_val_if_fail (CLUTTER_IS_ACTOR (actor1), NULL);
    g_return_val_if_fail (CLUTTER_IS_ACTOR (actor2), NULL);
    g_return_val_if_fail (anchor1 != NULL, NULL);
    g_return_val_if_fail (anchor2 != NULL, NULL);

    priv = box2d->priv;

    clutter_box2d_joint_ensure_bodies (box2d, actor1, actor2);

    jd.collideConnected = false;
    jd.bodyA = clutter_box2d_get_child (box2d, actor1)->priv->body;
    jd.bodyB = clutter_box2d_get_child (box2d, actor2)->priv->body;

    if (!jd.bodyA || !jd.bodyB)
        return NULL;

    jd.localAnchorA = b2Vec2 (anchor1->x * priv->scale_factor,
                              anchor1->y * priv->scale_factor);
    jd.localAnchorB = b2Vec2 (anchor2->x * priv->scale_factor,
                              anchor2->y * priv->scale_factor);
    jd.referenceAngle = jd.bodyB->GetAngle() - jd.bodyA->GetAngle();

    return joint_new (box2d, priv->world->CreateJoint (&jd), CLUTTER_BOX2D_JOINT_WELD);
}
ClutterBox2DJoint *
clutter_box2d_add_weld_joint2 (ClutterBox2D        *box2d,
                               ClutterActor        *actor1,
                               ClutterActor        *actor2,
                               const ClutterVertex *anchor)
{
    ClutterBox2DPrivate *priv;
    b2Body *bodyA, *bodyB;
    b2WeldJointDef jd;

    g_return_val_if_fail (CLUTTER_IS_BOX2D (box2d), NULL);
    g_return_val_if_fail (CLUTTER_IS_ACTOR (actor1), NULL);
    g_return_val_if_fail (CLUTTER_IS_ACTOR (actor2), NULL);
    g_return_val_if_fail (anchor != NULL, NULL);

    priv = box2d->priv;

    clutter_box2d_joint_ensure_bodies (box2d, actor1, actor2);

    jd.collideConnected = false;

    bodyA = clutter_box2d_get_child (box2d, actor1)->priv->body;
    bodyB = clutter_box2d_get_child (box2d, actor2)->priv->body;
    if (!bodyA || !bodyB)
        return NULL;

    jd.Initialize (bodyA, bodyB,
                   b2Vec2 (anchor->x * priv->scale_factor,
                           anchor->y * priv->scale_factor));

    return joint_new (box2d, priv->world->CreateJoint (&jd), CLUTTER_BOX2D_JOINT_WELD);
}
ClutterBox2DJoint *
clutter_box2d_add_pulley_joint (ClutterBox2D        *box2d,
                                ClutterActor        *actor1,
                                ClutterActor        *actor2,
                                const ClutterVertex *anchor1,
                                const ClutterVertex *anchor2,
                                const ClutterVertex *ground_anchor1,
                                const ClutterVertex *ground_anchor2,
                                gdouble              length1,
                                gdouble              length2,
                                gdouble              max_length1,
                                gdouble              max_length2,
                                gdouble              ratio)
{
    ClutterBox2DPrivate *priv;
    b2PulleyJointDef jd;

    g_return_val_if_fail (CLUTTER_IS_BOX2D (box2d), NULL);
    g_return_val_if_fail (CLUTTER_IS_ACTOR (actor1), NULL);
    g_return_val_if_fail (CLUTTER_IS_ACTOR (actor2), NULL);
    g_return_val_if_fail (anchor1 != NULL, NULL);
    g_return_val_if_fail (anchor2 != NULL, NULL);
    g_return_val_if_fail (ground_anchor1 != NULL, NULL);
    g_return_val_if_fail (ground_anchor2 != NULL, NULL);

    priv = box2d->priv;

    clutter_box2d_joint_ensure_bodies (box2d, actor1, actor2);

    jd.collideConnected = false;
    jd.bodyA = clutter_box2d_get_child (box2d, actor1)->priv->body;
    jd.bodyB = clutter_box2d_get_child (box2d, actor2)->priv->body;

    if (!jd.bodyA || !jd.bodyB)
        return NULL;

    jd.groundAnchorA = b2Vec2 (ground_anchor1->x * priv->scale_factor,
                               ground_anchor1->y * priv->scale_factor);
    jd.groundAnchorB = b2Vec2 (ground_anchor2->x * priv->scale_factor,
                               ground_anchor2->y * priv->scale_factor);
    jd.localAnchorA = b2Vec2 (anchor1->x * priv->scale_factor,
                              anchor1->y * priv->scale_factor);
    jd.localAnchorB = b2Vec2 (anchor2->x * priv->scale_factor,
                              anchor2->y * priv->scale_factor);
    jd.ratio = ratio;
    jd.lengthA = length1 * priv->scale_factor;
    jd.lengthB = length2 * priv->scale_factor;
    jd.maxLengthA = max_length1 * priv->scale_factor;
    jd.maxLengthB = max_length2 * priv->scale_factor;

    return joint_new (box2d, priv->world->CreateJoint (&jd), CLUTTER_BOX2D_JOINT_PULLEY);
}
示例#5
0
/**
 * clutter_container_lower_child: (virtual lower)
 * @container: a #ClutterContainer
 * @actor: the actor to raise
 * @sibling: (allow-none): the sibling to lower to, or %NULL to lower
 *   to the bottom
 *
 * Lowers @actor to @sibling level, in the depth ordering.
 *
 * This function calls the #ClutterContainerIface.lower() virtual function,
 * which has been deprecated. The default implementation will call
 * clutter_actor_set_child_below_sibling().
 *
 * Since: 0.6
 *
 * Deprecated: 1.10: Use clutter_actor_set_child_below_sibling() instead.
 */
void
clutter_container_lower_child (ClutterContainer *container,
                               ClutterActor     *actor,
                               ClutterActor     *sibling)
{
  ClutterContainerIface *iface;
  ClutterActor *self;

  g_return_if_fail (CLUTTER_IS_CONTAINER (container));
  g_return_if_fail (CLUTTER_IS_ACTOR (actor));
  g_return_if_fail (sibling == NULL || CLUTTER_IS_ACTOR (sibling));

  if (actor == sibling)
    return;

  self = CLUTTER_ACTOR (container);

  if (clutter_actor_get_parent (actor) != self)
    {
      g_warning ("Actor of type '%s' is not a child of the container "
                 "of type '%s'",
                 g_type_name (G_OBJECT_TYPE (actor)),
                 g_type_name (G_OBJECT_TYPE (container)));
      return;
    }

  if (sibling != NULL&&
      clutter_actor_get_parent (sibling) != self)
    {
      g_warning ("Actor of type '%s' is not a child of the container "
                 "of type '%s'",
                 g_type_name (G_OBJECT_TYPE (sibling)),
                 g_type_name (G_OBJECT_TYPE (container)));
      return;
    }

  iface = CLUTTER_CONTAINER_GET_IFACE (container);

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

  iface->lower (container, actor, sibling);
}
ClutterBox2DJoint *
clutter_box2d_add_pulley_joint2 (ClutterBox2D        *box2d,
                                 ClutterActor        *actor1,
                                 ClutterActor        *actor2,
                                 const ClutterVertex *anchor1,
                                 const ClutterVertex *anchor2,
                                 const ClutterVertex *ground_anchor1,
                                 const ClutterVertex *ground_anchor2,
                                 gdouble              max_length1,
                                 gdouble              max_length2,
                                 gdouble              ratio)
{
    ClutterBox2DPrivate *priv;
    b2Body *bodyA, *bodyB;
    b2PulleyJointDef jd;

    g_return_val_if_fail (CLUTTER_IS_BOX2D (box2d), NULL);
    g_return_val_if_fail (CLUTTER_IS_ACTOR (actor1), NULL);
    g_return_val_if_fail (CLUTTER_IS_ACTOR (actor2), NULL);
    g_return_val_if_fail (anchor1 != NULL, NULL);
    g_return_val_if_fail (anchor2 != NULL, NULL);
    g_return_val_if_fail (ground_anchor1 != NULL, NULL);
    g_return_val_if_fail (ground_anchor2 != NULL, NULL);

    priv = box2d->priv;

    clutter_box2d_joint_ensure_bodies (box2d, actor1, actor2);

    jd.collideConnected = false;

    bodyA = clutter_box2d_get_child (box2d, actor1)->priv->body;
    bodyB = clutter_box2d_get_child (box2d, actor2)->priv->body;
    if (!bodyA || !bodyB)
        return NULL;

    jd.Initialize (bodyA, bodyB,
                   b2Vec2 (ground_anchor1->x * priv->scale_factor,
                           ground_anchor1->y * priv->scale_factor),
                   b2Vec2 (ground_anchor2->x * priv->scale_factor,
                           ground_anchor2->y * priv->scale_factor),
                   b2Vec2 (anchor1->x * priv->scale_factor,
                           anchor1->y * priv->scale_factor),
                   b2Vec2 (anchor2->x * priv->scale_factor,
                           anchor2->y * priv->scale_factor),
                   ratio);

    return joint_new (box2d, priv->world->CreateJoint (&jd), CLUTTER_BOX2D_JOINT_PULLEY);
}
示例#7
0
/* Pointer left actor with tooltip */
static gboolean _xfdashboard_tooltip_action_on_leave_event(XfdashboardTooltipAction *self,
															ClutterEvent *inEvent,
															gpointer inUserData)
{
	XfdashboardTooltipActionPrivate		*priv;
	ClutterActor						*actor;
	ClutterActor						*stage;
	ClutterActor						*actorMeta;

	g_return_val_if_fail(XFDASHBOARD_IS_TOOLTIP_ACTION(self), CLUTTER_EVENT_PROPAGATE);
	g_return_val_if_fail(CLUTTER_IS_ACTOR(inUserData), CLUTTER_EVENT_PROPAGATE);

	priv=self->priv;
	actor=CLUTTER_ACTOR(inUserData);

	/* Get current actor this action belongs to */
	actorMeta=clutter_actor_meta_get_actor(CLUTTER_ACTOR_META(self));

	/* Release all sources and signal handler (except for enter event) */
	if(priv->motionSignalID!=0)
	{
		if(actorMeta) g_signal_handler_disconnect(actorMeta, priv->motionSignalID);
		priv->motionSignalID=0;
	}

	if(priv->leaveSignalID!=0)
	{
		if(actorMeta) g_signal_handler_disconnect(actorMeta, priv->leaveSignalID);
		priv->leaveSignalID=0;
	}

	if(priv->captureSignalID)
	{
		if(priv->captureSignalActor) g_signal_handler_disconnect(priv->captureSignalActor, priv->captureSignalID);
		priv->captureSignalActor=NULL;
		priv->captureSignalID=0;
	}

	if(priv->timeoutSourceID!=0)
	{
		g_source_remove(priv->timeoutSourceID);
		priv->timeoutSourceID=0;
	}

	/* Clear last actor we remembered if it is pointing to this actor */
	if(_xfdashboard_tooltip_last_event_actor==actor)
	{
		_xfdashboard_tooltip_last_event_actor=NULL;
	}

	/* Hide tooltip now */
	stage=clutter_actor_get_stage(actor);
	if(stage && XFDASHBOARD_IS_STAGE(stage))
	{
		g_signal_emit_by_name(stage, "hide-tooltip", self, NULL);
		priv->isVisible=FALSE;
	}

	return(CLUTTER_EVENT_PROPAGATE);
}
示例#8
0
/* Pointer entered an actor with tooltip */
static gboolean _xfdashboard_tooltip_action_on_enter_event(XfdashboardTooltipAction *self,
															ClutterEvent *inEvent,
															gpointer inUserData)
{
	XfdashboardTooltipActionPrivate		*priv;
	ClutterActor						*actor;

	g_return_val_if_fail(XFDASHBOARD_IS_TOOLTIP_ACTION(self), CLUTTER_EVENT_PROPAGATE);
	g_return_val_if_fail(CLUTTER_IS_ACTOR(inUserData), CLUTTER_EVENT_PROPAGATE);

	priv=self->priv;
	actor=CLUTTER_ACTOR(inUserData);

	/* Remove any timeout source we have added for this actor */
	if(priv->timeoutSourceID!=0)
	{
		g_source_remove(priv->timeoutSourceID);
		priv->timeoutSourceID=0;
	}

	/* Connect signals */
	g_warn_if_fail(priv->motionSignalID==0);
	priv->motionSignalID=g_signal_connect_swapped(actor,
													"motion-event",
													G_CALLBACK(_xfdashboard_tooltip_action_on_motion_event),
													self);

	g_warn_if_fail(priv->leaveSignalID==0);
	priv->leaveSignalID=g_signal_connect_swapped(actor,
													"leave-event",
													G_CALLBACK(_xfdashboard_tooltip_action_on_leave_event),
													self);

	return(CLUTTER_EVENT_PROPAGATE);
}
示例#9
0
/**
 * clutter_bin_layout_add:
 * @self: a #ClutterBinLayout
 * @child: a #ClutterActor
 * @x_align: horizontal alignment policy for @child
 * @y_align: vertical alignment policy for @child
 *
 * Adds a #ClutterActor to the container using @self and
 * sets the alignment policies for it
 *
 * This function is equivalent to clutter_container_add_actor()
 * and clutter_layout_manager_child_set_property() but it does not
 * require a pointer to the #ClutterContainer associated to the
 * #ClutterBinLayout
 *
 * Since: 1.2
 */
void
clutter_bin_layout_add (ClutterBinLayout    *self,
                        ClutterActor        *child,
                        ClutterBinAlignment  x_align,
                        ClutterBinAlignment  y_align)
{
  ClutterBinLayoutPrivate *priv;
  ClutterLayoutManager *manager;
  ClutterLayoutMeta *meta;

  g_return_if_fail (CLUTTER_IS_BIN_LAYOUT (self));
  g_return_if_fail (CLUTTER_IS_ACTOR (child));

  priv = self->priv;

  if (priv->container == NULL)
    {
      g_warning ("The layout of type '%s' must be associated to "
                 "a ClutterContainer before adding children",
                 G_OBJECT_TYPE_NAME (self));
      return;
    }

  clutter_container_add_actor (priv->container, child);

  manager = CLUTTER_LAYOUT_MANAGER (self);
  meta = clutter_layout_manager_get_child_meta (manager,
                                                priv->container,
                                                child);
  g_assert (CLUTTER_IS_BIN_LAYER (meta));

  set_layer_x_align (CLUTTER_BIN_LAYER (meta), x_align);
  set_layer_y_align (CLUTTER_BIN_LAYER (meta), y_align);
}
示例#10
0
static void meta_switcher_dispose(GObject *object)
{
    MetaSwitcher *switcher = META_SWITCHER(object);
    MetaSwitcherPrivate* priv = switcher->priv;

    if (priv->disposed) return;
    priv->disposed = TRUE;

    MetaScreen* screen = meta_plugin_get_screen(priv->plugin);
    ClutterActor* stage = meta_get_stage_for_screen(screen);
    clutter_actor_remove_child(stage, priv->top);

    if (priv->modaled) {
        meta_plugin_end_modal(priv->plugin, clutter_get_current_event_time());
        meta_enable_unredirect_for_screen(screen);

        if (priv->selected_id < 0 && priv->previous_focused)
            clutter_stage_set_key_focus(CLUTTER_STAGE(stage), priv->previous_focused);
    }

    if (CLUTTER_IS_ACTOR(priv->top)) {
        g_clear_pointer(&priv->top, clutter_actor_destroy);
    } else priv->top = NULL;

    if (priv->autoclose_id) {
        g_source_remove(priv->autoclose_id);
        priv->autoclose_id = 0;
    }

    GList* ws_list = meta_screen_get_workspaces(screen);
    g_list_foreach(ws_list, (GFunc)unhook_ws_event, switcher);

    G_OBJECT_CLASS(meta_switcher_parent_class)->dispose(object);
}
示例#11
0
/**
 * 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);
}
示例#12
0
static void
pkg_graph_place_child (PkgGraph     *graph,
                       ClutterActor *child)
{
	PkgGraphPrivate *priv;
	gfloat w, h, x = 0, y = 0;

	g_return_if_fail(PKG_IS_GRAPH(graph));
	g_return_if_fail(CLUTTER_IS_ACTOR(child));

	priv = graph->priv;

	clutter_actor_get_size(CLUTTER_ACTOR(graph), &w, &h);

	if (priv->xpad) {
		x = priv->xpad;
	}

	if (priv->ypad) {
		y = priv->ypad;
	}

	w -= 2 * priv->xpad;
	h -= 2 * priv->ypad;

	clutter_actor_set_size(child, w, h);
	clutter_actor_set_position(child, x, y);
	clutter_actor_queue_redraw(child);
}
示例#13
0
static AstroWindow *
get_window (AstroApplication *app)
{
  AstroExamplePrivate *priv;
  ClutterColor color = { 0xff, 0xff, 0x22, 0x22 };
  ClutterActor *window = NULL, *rect;

  g_return_val_if_fail (ASTRO_IS_EXAMPLE (app), NULL);
  priv = ASTRO_EXAMPLE (app)->priv;

  if (CLUTTER_IS_ACTOR (priv->window))
    window = priv->window;
  else
    {
      window = astro_window_new ();
      
      rect = clutter_rectangle_new_with_color (&color);
      clutter_container_add_actor (CLUTTER_CONTAINER (window), rect);
      clutter_actor_set_size (rect, CSW (), CSH()-ASTRO_PANEL_HEIGHT());
      clutter_actor_show (rect);
    }

  ASTRO_EXAMPLE (app)->priv->window = window;

  return ASTRO_WINDOW (window);
}
示例#14
0
/**
 * xfdashboard_traverse_actor:
 * @inRootActor: The root #ClutterActor where to begin traversing
 * @inSelector: A #XfdashboardCssSelector to filter actors while traversing or
 *   %NULL to disable filterting
 * @inCallback: Function to call on matching children
 * @inUserData: Data to pass to callback function
 *
 * Iterates through all children of @inRootActor recursively beginning at
 * @inRootActor and for each child matching the selector @inSelector it calls the
 * callback function @inCallback with the matching child and the user-data at
 * @inUserData.
 *
 * If @inRootActor is %NULL it begins at the global stage.
 *
 * If the selector @inSelector is %NULL all children will match and the callback
 * function @inCallback is called for all children.
 */
void xfdashboard_traverse_actor(ClutterActor *inRootActor,
								XfdashboardCssSelector *inSelector,
								XfdashboardTraversalCallback inCallback,
								gpointer inUserData)
{
	g_return_if_fail(!inRootActor || CLUTTER_IS_ACTOR(inRootActor));
	g_return_if_fail(!inSelector || XFDASHBOARD_IS_CSS_SELECTOR(inSelector));
	g_return_if_fail(inCallback);

	/* If root actor where begin traversal is NULL then begin at stage */
	if(!inRootActor)
	{
		inRootActor=CLUTTER_ACTOR(xfdashboard_application_get_stage(NULL));
	}

	/* If no selector is provider create a seletor matching all actors.
	 * Otherwise take an extra ref on provided selector to prevent
	 * destruction when we unref it later.
	 */
	if(!inSelector) inSelector=xfdashboard_css_selector_new_from_string("*");
		else g_object_ref(inSelector);

	/* Do traversal */
	_xfdashboard_traverse_actor_internal(inRootActor, inSelector, inCallback, inUserData);

	/* Release reference on selector */
	g_object_unref(inSelector);
}
示例#15
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);
}
示例#16
0
/**
 * clutter_container_remove_actor:
 * @container: a #ClutterContainer
 * @actor: a #ClutterActor
 *
 * Removes @actor from @container. The actor should be unparented, so
 * if you want to keep it around you must hold a reference to it
 * yourself, using g_object_ref(). When the actor has been removed,
 * the "actor-removed" signal is emitted by @container.
 *
 * Since: 0.4
 */
void
clutter_container_remove_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->remove)
    {
      CLUTTER_CONTAINER_WARN_NOT_IMPLEMENTED (container, "remove");
      return;
    }

  parent = clutter_actor_get_parent (actor);
  if (parent != CLUTTER_ACTOR (container))
    {
      g_warning ("Attempting to remove actor of type '%s' from "
		 "group of class '%s', but the container is not "
                 "the actor's parent.",
		 g_type_name (G_OBJECT_TYPE (actor)),
		 g_type_name (G_OBJECT_TYPE (container)));
      return;
    }

  clutter_container_destroy_child_meta (container, actor);

  iface->remove (container, actor);
}
示例#17
0
/* Default implementation of virtual function "get_parent" */
static XfdashboardStylable* _xfdashboard_stylable_real_get_parent(XfdashboardStylable *self)
{
	XfdashboardStylable		*parent;

	g_return_val_if_fail(XFDASHBOARD_IS_STYLABLE(self), NULL);

	parent=NULL;

	/* If object implementing this interface is derived from ClutterActor
	 * get actor's parent actor.
	 */
	if(CLUTTER_IS_ACTOR(self))
	{
		ClutterActor		*parentActor;

		/* Get parent and if parent stylable set parent as result */
		parentActor=clutter_actor_get_parent(CLUTTER_ACTOR(self));
		if(parentActor &&
			XFDASHBOARD_IS_STYLABLE(parentActor))
		{
			parent=XFDASHBOARD_STYLABLE(parentActor);
		}
	}

	/* Return stylable parent */
	return(parent);
}
示例#18
0
void
mex_tile_set_secondary_icon (MexTile      *tile,
                             ClutterActor *icon)
{
  MexTilePrivate *priv;

  g_return_if_fail (MEX_IS_TILE (tile));
  g_return_if_fail (!icon || CLUTTER_IS_ACTOR (icon));

  priv = tile->priv;
  if (priv->icon2 != icon)
    {
      if (priv->icon2)
        clutter_actor_destroy (priv->icon2);

      if (icon)
        {
          clutter_actor_push_internal (CLUTTER_ACTOR (tile));
          clutter_actor_set_parent (icon, CLUTTER_ACTOR (tile));
          clutter_actor_pop_internal (CLUTTER_ACTOR (tile));
        }

      priv->icon2 = icon;

      g_object_notify (G_OBJECT (tile), "secondary-icon");
    }
}
示例#19
0
/* Dump actors */
static void _xfdashboard_dump_actor_internal(ClutterActor *inActor, gint inLevel)
{
	ClutterActorIter	iter;
	ClutterActor		*child;
	gint				i;

	g_return_if_fail(CLUTTER_IS_ACTOR(inActor));
	g_return_if_fail(inLevel>=0);

	clutter_actor_iter_init(&iter, CLUTTER_ACTOR(inActor));
	while(clutter_actor_iter_next(&iter, &child))
	{
		for(i=0; i<inLevel; i++) g_print("  ");
		g_print("+- %s@%p - name: %s - geometry: %.2f,%.2f [%.2fx%.2f], mapped: %s, visible: %s, children: %d\n",
					G_OBJECT_TYPE_NAME(child), child,
					clutter_actor_get_name(child),
					clutter_actor_get_x(child),
					clutter_actor_get_y(child),
					clutter_actor_get_width(child),
					clutter_actor_get_height(child),
					clutter_actor_is_mapped(child) ? "yes" : "no",
					clutter_actor_is_visible(child) ? "yes" : "no",
					clutter_actor_get_n_children(child));
		if(clutter_actor_get_n_children(child)>0) _xfdashboard_dump_actor_internal(child, inLevel+1);
	}
}
示例#20
0
/* Callback function for xfdashboard_traverse_actor() to find stage interface
 * used in xfdashboard_notify().
 */
static gboolean _xfdashboard_notify_traverse_callback(ClutterActor *inActor, gpointer inUserData)
{
	XfdashboardStage					**outStageInterface;
	XfdashboardWindowTrackerMonitor		*stageMonitor;

	g_return_val_if_fail(CLUTTER_IS_ACTOR(inActor), XFDASHBOARD_TRAVERSAL_CONTINUE);
	g_return_val_if_fail(inUserData, XFDASHBOARD_TRAVERSAL_CONTINUE);

	outStageInterface=(XfdashboardStage**)inUserData;

	/* If actor currently traverse is a stage interface then store
	 * the actor in user-data and stop further traversal.
	 */
	if(XFDASHBOARD_IS_STAGE_INTERFACE(inActor))
	{
		stageMonitor=xfdashboard_stage_interface_get_monitor(XFDASHBOARD_STAGE_INTERFACE(inActor));
		if(xfdashboard_window_tracker_monitor_is_primary(stageMonitor))
		{
			*outStageInterface=XFDASHBOARD_STAGE(clutter_actor_get_stage(inActor));
			return(XFDASHBOARD_TRAVERSAL_STOP);
		}
	}

	/* If we get here a stage interface was not found so continue traversal */
	return(XFDASHBOARD_TRAVERSAL_CONTINUE);
}
示例#21
0
void
mex_column_view_set_placeholder_actor (MexColumnView *column,
                                       ClutterActor  *actor)
{
  MexColumnViewPrivate *priv;

  g_return_if_fail (MEX_IS_COLUMN_VIEW (column));
  g_return_if_fail (actor == NULL || CLUTTER_IS_ACTOR (actor));

  priv = column->priv;

  /* placeholder label */
  if (priv->placeholder_actor)
    clutter_actor_unparent (priv->placeholder_actor);

  priv->placeholder_actor = actor;

  if (actor)
    {
      clutter_actor_push_internal (CLUTTER_ACTOR (column));
      clutter_actor_set_parent (priv->placeholder_actor, CLUTTER_ACTOR (column));
      clutter_actor_pop_internal (CLUTTER_ACTOR (column));
    }

  clutter_actor_queue_relayout (CLUTTER_ACTOR (column));
}
示例#22
0
/**
 * clutter_container_child_get_property:
 * @container: a #ClutterContainer
 * @child: a #ClutterActor that is a child of @container.
 * @property: the name of the property to set.
 * @value: the value.
 *
 * Gets a container specific property of a child of @container, In general,
 * a copy is made of the property contents and the caller is responsible for
 * freeing the memory by calling g_value_unset().
 *
 * Note that clutter_container_child_set_property() is really intended for
 * language bindings, clutter_container_child_set() is much more convenient
 * for C programming.
 *
 * Since: 0.8
 */
void
clutter_container_child_get_property (ClutterContainer *container,
                                      ClutterActor     *child,
                                      const gchar      *property,
                                      GValue           *value)
{
  GObjectClass *klass;
  GParamSpec   *pspec;

  g_return_if_fail (CLUTTER_IS_CONTAINER (container));
  g_return_if_fail (CLUTTER_IS_ACTOR (child));
  g_return_if_fail (property != NULL);
  g_return_if_fail (value != NULL);

  klass = G_OBJECT_GET_CLASS (container);

  pspec = clutter_container_class_find_child_property (klass, property);
  if (!pspec)
    {
      g_warning ("%s: Containers of type '%s' have no child "
                 "property named '%s'",
                 G_STRLOC, G_OBJECT_TYPE_NAME (container), property);
      return;
    }

  if (!(pspec->flags & G_PARAM_READABLE))
    {
      g_warning ("%s: Child property '%s' of the container '%s' "
                 "is not writable",
                 G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (container));
      return;
    }

  container_get_child_property (container, child, value, pspec);
}
示例#23
0
/* Invalidate all stylable children recursively beginning at given actor */
static void _xfdashboard_actor_invalidate_recursive(ClutterActor *inActor)
{
	ClutterActor			*child;
	ClutterActorIter		actorIter;

	g_return_if_fail(CLUTTER_IS_ACTOR(inActor));

	/* If actor is stylable invalidate it to get its style recomputed */
	if(XFDASHBOARD_IS_STYLABLE(inActor))
	{
		xfdashboard_stylable_invalidate(XFDASHBOARD_STYLABLE(inActor));
	}

	/* Recompute styles for all children recursively */
	clutter_actor_iter_init(&actorIter, inActor);
	while(clutter_actor_iter_next(&actorIter, &child))
	{
		/* Call ourselve recursive with child as top-level actor.
		 * We return immediately if it has no children but invalidate child
		 * before. If it has children it will first invalidated and will be
		 * iterated over its children then. In both cases the child will
		 * be invalidated.
		 */
		_xfdashboard_actor_invalidate_recursive(child);
	}
}
示例#24
0
文件: mx-table.c 项目: ManMower/mx
/**
 * mx_table_insert_actor:
 * @table: a #MxTable
 * @actor: the child to insert
 * @row: the row to place the child into
 * @column: the column to place the child into
 *
 * Insert an actor at the specified row and column
 *
 * Note, column and rows numbers start from zero
 */
void
mx_table_insert_actor (MxTable      *table,
                       ClutterActor *actor,
                       gint          row,
                       gint          column)
{
  MxTableChild *meta;

  g_return_if_fail (MX_IS_TABLE (table));
  g_return_if_fail (CLUTTER_IS_ACTOR (actor));
  g_return_if_fail (row >= -1);
  g_return_if_fail (column >= -1);

  if (row < 0)
    row = table->priv->n_rows + 1;

  if (column < 0)
    column = table->priv->n_cols + 1;

  clutter_actor_add_child (CLUTTER_ACTOR (table), actor);

  meta =
    (MxTableChild *) clutter_container_get_child_meta (CLUTTER_CONTAINER (table),
                                                       actor);
  meta->row = row;
  meta->col = column;
  _mx_table_update_row_col (table, meta);

  clutter_actor_queue_relayout (CLUTTER_ACTOR (table));
}
示例#25
0
/**
 * xfdashboard_get_stage_of_actor:
 * @inActor: The #ClutterActor for which to find the stage
 *
 * Gets the #XfdashboardStageInterface of the monitor where
 * @inActor belongs to.
 *
 * Return value: (transfer none): The #XfdashboardStageInterface
 *   found or %NULL if none was found.
 */
XfdashboardStageInterface* xfdashboard_get_stage_of_actor(ClutterActor *inActor)
{
	ClutterActor		*parent;

	g_return_val_if_fail(CLUTTER_IS_ACTOR(inActor), NULL);

	/* Iterate through parents and return first XfdashboardStageInterface
	 * found. That's the stage of the monitor where the requested actor
	 * belongs to.
	 */
	parent=clutter_actor_get_parent(inActor);
	while(parent)
	{
		/* Check if current iterated parent is a XfdashboardStageInterface.
		 * If it is return it.
		 */
		if(XFDASHBOARD_IS_STAGE_INTERFACE(parent)) return(XFDASHBOARD_STAGE_INTERFACE(parent));

		/* Continue with next parent */
		parent=clutter_actor_get_parent(parent);
	}

	/* If we get here we did not find the stage the actor belongs to,
	 * so return NULL.
	 */
	return(NULL);
}
示例#26
0
ClutterBox2DJoint *
clutter_box2d_add_mouse_joint (ClutterBox2D        *box2d,
                               ClutterActor        *actor,
                               const ClutterVertex *target)
{
    ClutterBox2DPrivate *priv;
    b2MouseJointDef md;

    g_return_val_if_fail (CLUTTER_IS_BOX2D (box2d), NULL);
    g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), NULL);
    g_return_val_if_fail (target != NULL, NULL);

    priv = box2d->priv;

    clutter_box2d_joint_ensure_body (box2d, actor);

    md.bodyA = priv->ground_body;
    md.bodyB = clutter_box2d_get_child (box2d, actor)->priv->body;

    if (!md.bodyB)
        return NULL;

    md.target = b2Vec2( (target->x) * priv->scale_factor,
                        (target->y) * priv->scale_factor);
    md.bodyA->SetAwake (false);
    md.maxForce = 5100.0f * md.bodyB->GetMass ();

    return joint_new (box2d, priv->world->CreateJoint(&md), CLUTTER_BOX2D_JOINT_MOUSE);
}
示例#27
0
/* Dump actors */
static void _xfdashboard_dump_actor_print(ClutterActor *inActor, gint inLevel)
{
	XfdashboardStylable		*stylable;
	ClutterActorBox			allocation;
	gint					i;

	g_return_if_fail(CLUTTER_IS_ACTOR(inActor));
	g_return_if_fail(inLevel>=0);

	/* Check if actor is stylable to retrieve style configuration */
	stylable=NULL;
	if(XFDASHBOARD_IS_STYLABLE(inActor)) stylable=XFDASHBOARD_STYLABLE(inActor);

	/* Dump actor */
	for(i=0; i<inLevel; i++) g_print("  ");
	clutter_actor_get_allocation_box(inActor, &allocation);
	g_print("+- %s@%p [%s%s%s%s%s%s] - geometry: %.2f,%.2f [%.2fx%.2f], mapped: %s, visible: %s, layout: %s, children: %d\n",
				G_OBJECT_TYPE_NAME(inActor), inActor,
				clutter_actor_get_name(inActor) ? " #" : "",
				clutter_actor_get_name(inActor) ? clutter_actor_get_name(inActor) : "",
				stylable && xfdashboard_stylable_get_classes(stylable) ? "." : "",
				stylable && xfdashboard_stylable_get_classes(stylable) ? xfdashboard_stylable_get_classes(stylable) : "",
				stylable && xfdashboard_stylable_get_pseudo_classes(stylable) ? ":" : "",
				stylable && xfdashboard_stylable_get_pseudo_classes(stylable) ? xfdashboard_stylable_get_pseudo_classes(stylable) : "",
				allocation.x1,
				allocation.y1,
				allocation.x2-allocation.x1,
				allocation.y2-allocation.y1,
				clutter_actor_is_mapped(inActor) ? "yes" : "no",
				clutter_actor_is_visible(inActor) ? "yes" : "no",
				clutter_actor_get_layout_manager(inActor) ? G_OBJECT_TYPE_NAME(clutter_actor_get_layout_manager(inActor)) : "none",
				clutter_actor_get_n_children(inActor));

}
示例#28
0
文件: mx-bin.c 项目: ebassi/mx
/**
 * mx_bin_set_child:
 * @bin: a #MxBin
 * @child: a #ClutterActor, or %NULL
 *
 * Sets @child as the child of @bin.
 *
 * If @bin already has a child, the previous child is removed.
 */
void
mx_bin_set_child (MxBin        *bin,
                  ClutterActor *child)
{
  MxBinPrivate *priv;

  g_return_if_fail (MX_IS_BIN (bin));
  g_return_if_fail (child == NULL || CLUTTER_IS_ACTOR (child));

  priv = bin->priv;

  if (priv->child == child)
    return;

  if (priv->child)
    {
      ClutterActor *old_child = priv->child;

      priv->child = NULL;
      clutter_actor_remove_child (CLUTTER_ACTOR (bin), old_child);
    }

  if (child)
    {
      priv->child = child;
      clutter_actor_add_child (CLUTTER_ACTOR (bin), child);
    }

  clutter_actor_queue_relayout (CLUTTER_ACTOR (bin));

  g_object_notify (G_OBJECT (bin), "child");
}
示例#29
0
static VALUE
rbclt_media_set_position (int argc, VALUE *argv, VALUE self)
{
  ClutterMedia *media = CLUTTER_MEDIA (RVAL2GOBJ (self));
  VALUE pos, y;

  /* The 'set_position' setter for the 'position' property overrides
     the 'set_position(x,y)' method in Clutter::Actor, so to work
     around this we will fake a special set_position method, but only
     if the object is actually a ClutterActor */
  if (CLUTTER_IS_ACTOR (media))
    rb_scan_args (argc, argv, "11", &pos, &y);
  else
    {
      rb_scan_args (argc, argv, "10", &pos);
      y = Qnil;
    }

  if (y != Qnil)
    clutter_actor_set_position (CLUTTER_ACTOR (media),
                                NUM2INT (pos), NUM2INT (y));
  else
    clutter_media_set_position (media, NUM2INT (pos));

  return self;
}
示例#30
0
/**
 * 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);
}