[Xfce4-commits] [apps/xfdashboard] 08/09: XfdashboardActor: update for g_type_class_add_private() deprecation and silence compiler warning at libxfdashboard/actor.c

noreply at xfce.org noreply at xfce.org
Wed Aug 21 15:20:44 CEST 2019


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

n   o   m   a   d       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfdashboard.

commit 8c90fcdbc048a8a692ab89db75fde8deea8c2325
Author: Stephan Haller <nomad at froevel.de>
Date:   Wed Aug 21 15:11:11 2019 +0200

    XfdashboardActor: update for g_type_class_add_private() deprecation and silence compiler warning at libxfdashboard/actor.c
---
 libxfdashboard/actor.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/libxfdashboard/actor.c b/libxfdashboard/actor.c
index 6f8c31f..89531c1 100644
--- a/libxfdashboard/actor.c
+++ b/libxfdashboard/actor.c
@@ -39,15 +39,13 @@
 
 /* Define this class in GObject system */
 static gpointer				xfdashboard_actor_parent_class=NULL;
+static gint					xfdashboard_actor_private_offset=0;
 
+static gpointer xfdashboard_actor_get_instance_private(XfdashboardActor *self);
 void xfdashboard_actor_class_init(XfdashboardActorClass *klass);
 void xfdashboard_actor_init(XfdashboardActor *self);
 void xfdashboard_actor_base_class_finalize(XfdashboardActorClass *klass);
 
-/* Private structure - access only by public API if needed */
-#define XFDASHBOARD_ACTOR_GET_PRIVATE(obj) \
-	(G_TYPE_INSTANCE_GET_PRIVATE((obj), XFDASHBOARD_TYPE_ACTOR, XfdashboardActorPrivate))
-
 struct _XfdashboardActorPrivate
 {
 	/* Properties related */
@@ -971,6 +969,12 @@ static void _xfdashboard_actor_get_property(GObject *inObject,
 	}
 }
 
+/* Access instance's private structure */
+static inline gpointer xfdashboard_actor_get_instance_private(XfdashboardActor *self)
+{
+	return(G_STRUCT_MEMBER_P(self, xfdashboard_actor_private_offset));
+}
+ 
 /* Class initialization
  * Override functions in parent classes and define properties
  * and signals
@@ -983,6 +987,12 @@ void xfdashboard_actor_class_init(XfdashboardActorClass *klass)
 	/* Get parent class */
 	xfdashboard_actor_parent_class=g_type_class_peek_parent(klass);
 
+	/* Adjust offset to instance private structure */
+	if(xfdashboard_actor_private_offset!=0)
+	{
+		g_type_class_adjust_private_offset(klass, &xfdashboard_actor_private_offset);
+	}
+
 	/* Override functions */
 	gobjectClass->dispose=_xfdashboard_actor_dispose;
 	gobjectClass->set_property=_xfdashboard_actor_set_property;
@@ -994,9 +1004,6 @@ void xfdashboard_actor_class_init(XfdashboardActorClass *klass)
 	clutterActorClass->show=_xfdashboard_actor_show;
 	clutterActorClass->hide=_xfdashboard_actor_hide;
 
-	/* Set up private structure */
-	g_type_class_add_private(klass, sizeof(XfdashboardActorPrivate));
-
 	/* Create param-spec pool for themable properties */
 	g_assert(_xfdashboard_actor_stylable_properties_pool==NULL);
 	_xfdashboard_actor_stylable_properties_pool=g_param_spec_pool_new(FALSE);
@@ -1040,7 +1047,7 @@ void xfdashboard_actor_init(XfdashboardActor *self)
 {
 	XfdashboardActorPrivate		*priv;
 
-	priv=self->priv=XFDASHBOARD_ACTOR_GET_PRIVATE(self);
+	priv=self->priv=xfdashboard_actor_get_instance_private(self);
 
 	/* Set up default values */
 	priv->canFocus=FALSE;
@@ -1094,27 +1101,27 @@ GType xfdashboard_actor_get_type(void)
 		{
 			sizeof(XfdashboardActorClass),
 			NULL,
-			(GBaseFinalizeFunc)xfdashboard_actor_base_class_finalize,
-			(GClassInitFunc)xfdashboard_actor_class_init,
+			(GBaseFinalizeFunc)(void*)xfdashboard_actor_base_class_finalize,
+			(GClassInitFunc)(void*)xfdashboard_actor_class_init,
 			NULL, /* class_finalize */
 			NULL, /* class_data */
 			sizeof(XfdashboardActor),
 			0,    /* n_preallocs */
-			(GInstanceInitFunc)xfdashboard_actor_init,
+			(GInstanceInitFunc)(void*)xfdashboard_actor_init,
 			NULL, /* value_table */
 		};
 
 		/* Implemented interfaces info */
 		const GInterfaceInfo	actorStylableInterfaceInfo=
 		{
-			(GInterfaceInitFunc)_xfdashboard_actor_stylable_iface_init,
+			(GInterfaceInitFunc)(void*)_xfdashboard_actor_stylable_iface_init,
 			NULL,
 			NULL
 		};
 
 		const GInterfaceInfo	actorFocusableInterfaceInfo=
 		{
-			(GInterfaceInitFunc)_xfdashboard_actor_focusable_iface_init,
+			(GInterfaceInitFunc)(void*)_xfdashboard_actor_focusable_iface_init,
 			NULL,
 			NULL
 		};
@@ -1125,6 +1132,9 @@ GType xfdashboard_actor_get_type(void)
 											&actorInfo,
 											0);
 
+		/* Add private structure */
+		xfdashboard_actor_private_offset=g_type_add_instance_private(actorType, sizeof(XfdashboardActorPrivate));
+
 		/* Add implemented interfaces */
 		g_type_add_interface_static(actorType,
 									XFDASHBOARD_TYPE_STYLABLE,

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


More information about the Xfce4-commits mailing list