[Xfce4-commits] [apps/xfdashboard] 01/02: Emit signal 'actor-created' at stage where a newly created actor was placed on.

noreply at xfce.org noreply at xfce.org
Fri Jun 10 11:57:31 CEST 2016


This is an automated email from the git hooks/post-receive script.

nomad pushed a commit to branch master
in repository apps/xfdashboard.

commit 1c70ab8cf29930b8ca91ea94460a56ee0810df87
Author: Stephan Haller <nomad at froevel.de>
Date:   Fri Jun 10 11:52:23 2016 +0200

    Emit signal 'actor-created' at stage where a newly created actor was placed on.
    
    This signal is emitted for the very first time a new actor gets its parent set and so it is the first time the actor belongs to UI and - from point of view of application - it exists now / was created. The main purpose of this signal is for plugins to react on newly created actor to filter and/or modify them and/or to connect signals. E.g. a plugin wants to connect a signal to each XfdashboardButton in XfdashboardQuicklaunch, so it has to listen for 'actor-created' signals at stage, t [...]
---
 libxfdashboard/actor.c | 28 ++++++++++++++++++++++++++--
 libxfdashboard/stage.c | 14 ++++++++++++++
 libxfdashboard/stage.h |  2 ++
 3 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/libxfdashboard/actor.c b/libxfdashboard/actor.c
index fe7869f..dd91fb6 100644
--- a/libxfdashboard/actor.c
+++ b/libxfdashboard/actor.c
@@ -59,6 +59,7 @@ struct _XfdashboardActorPrivate
 	/* Instance related */
 	GHashTable		*lastThemeStyleSet;
 	gboolean		forceStyleRevalidation;
+	gboolean		isFirstParent;
 };
 
 /* Properties */
@@ -746,12 +747,14 @@ static gboolean _xfdashboard_actor_enter_event(ClutterActor *inActor, ClutterCro
 /* Actor was (re)parented */
 static void _xfdashboard_actor_parent_set(ClutterActor *inActor, ClutterActor *inOldParent)
 {
-	XfdashboardActor		*self;
-	ClutterActorClass		*parentClass;
+	XfdashboardActor			*self;
+	XfdashboardActorPrivate		*priv;
+	ClutterActorClass			*parentClass;
 
 	g_return_if_fail(XFDASHBOARD_IS_ACTOR(inActor));
 
 	self=XFDASHBOARD_ACTOR(inActor);
+	priv=self->priv;
 
 	/* Call parent's virtual function */
 	parentClass=CLUTTER_ACTOR_CLASS(xfdashboard_actor_parent_class);
@@ -760,6 +763,26 @@ static void _xfdashboard_actor_parent_set(ClutterActor *inActor, ClutterActor *i
 		parentClass->parent_set(inActor, inOldParent);
 	}
 
+	/* Check if it is a newly created actor which is parented for the first time.
+	 * Then emit 'actor-created' signal on stage.
+	 */
+	if(priv->isFirstParent &&
+		!inOldParent &&
+		clutter_actor_get_parent(inActor))
+	{
+		ClutterActor			*stage;
+
+		/* Get stage where this actor belongs to and emit signal at stage */
+		stage=clutter_actor_get_stage(inActor);
+		if(XFDASHBOARD_IS_STAGE(stage))
+		{
+			g_signal_emit_by_name(stage, "actor-created", inActor, NULL);
+		}
+
+		/* Set flag that a parent set and signal was emitted */
+		priv->isFirstParent=FALSE;
+	}
+
 	/* Invalide styling to get it recomputed because its ID (from point
 	 * of view of css) has changed. Also invalidate children as they might
 	 * reference the old, invalid parent or the new, valid one.
@@ -992,6 +1015,7 @@ void xfdashboard_actor_init(XfdashboardActor *self)
 	priv->styleClasses=NULL;
 	priv->stylePseudoClasses=NULL;
 	priv->lastThemeStyleSet=NULL;
+	priv->isFirstParent=TRUE;
 
 	/* Connect signals */
 	g_signal_connect(self, "notify::mapped", G_CALLBACK(_xfdashboard_actor_on_mapped_changed), NULL);
diff --git a/libxfdashboard/stage.c b/libxfdashboard/stage.c
index ca21845..e973c2b 100644
--- a/libxfdashboard/stage.c
+++ b/libxfdashboard/stage.c
@@ -117,6 +117,8 @@ static GParamSpec* XfdashboardStageProperties[PROP_LAST]={ 0, };
 /* Signals */
 enum
 {
+	SIGNAL_ACTOR_CREATED,
+
 	SIGNAL_SEARCH_STARTED,
 	SIGNAL_SEARCH_CHANGED,
 	SIGNAL_SEARCH_ENDED,
@@ -1614,6 +1616,18 @@ static void xfdashboard_stage_class_init(XfdashboardStageClass *klass)
 	g_object_class_install_properties(gobjectClass, PROP_LAST, XfdashboardStageProperties);
 
 	/* Define signals */
+	XfdashboardStageSignals[SIGNAL_ACTOR_CREATED]=
+		g_signal_new("actor-created",
+						G_TYPE_FROM_CLASS(klass),
+						G_SIGNAL_RUN_LAST,
+						G_STRUCT_OFFSET(XfdashboardStageClass, actor_created),
+						NULL,
+						NULL,
+						g_cclosure_marshal_VOID__VOID,
+						G_TYPE_NONE,
+						1,
+						CLUTTER_TYPE_ACTOR);
+
 	XfdashboardStageSignals[SIGNAL_SEARCH_STARTED]=
 		g_signal_new("search-started",
 						G_TYPE_FROM_CLASS(klass),
diff --git a/libxfdashboard/stage.h b/libxfdashboard/stage.h
index a26828e..dea12fc 100644
--- a/libxfdashboard/stage.h
+++ b/libxfdashboard/stage.h
@@ -62,6 +62,8 @@ struct _XfdashboardStageClass
 
 	/*< public >*/
 	/* Virtual functions */
+	void (*actor_created)(XfdashboardStage *self, ClutterActor *inActor);
+
 	void (*search_started)(XfdashboardStage *self);
 	void (*search_changed)(XfdashboardStage *self, gchar *inText);
 	void (*search_ended)(XfdashboardStage *self);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list