From 60894665c424ff487caf294b9cd5f72c753a4a4f Mon Sep 17 00:00:00 2001 From: Wu Xiaotian Date: Wed, 11 Sep 2019 21:42:09 +0800 Subject: clock: avoid deprecated g_type_class_add_private --- applets/clock/system-timezone.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'applets/clock/system-timezone.c') diff --git a/applets/clock/system-timezone.c b/applets/clock/system-timezone.c index 6aa1c5ae..bed4aaaf 100644 --- a/applets/clock/system-timezone.c +++ b/applets/clock/system-timezone.c @@ -76,8 +76,6 @@ static char *files_to_check[CHECK_NB] = { static GObject *systz_singleton = NULL; -G_DEFINE_TYPE (SystemTimezone, system_timezone, G_TYPE_OBJECT) - typedef struct { char *tz; char *env_tz; @@ -89,6 +87,8 @@ enum { LAST_SIGNAL }; +G_DEFINE_TYPE_WITH_PRIVATE (SystemTimezone, system_timezone, G_TYPE_OBJECT) + static guint system_timezone_signals[LAST_SIGNAL] = { 0 }; static GObject *system_timezone_constructor (GType type, @@ -103,8 +103,6 @@ static void system_timezone_monitor_changed (GFileMonitor *handle, gpointer user_data); static char *system_timezone_find (void); -#define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SYSTEM_TIMEZONE_TYPE, SystemTimezonePrivate)) - SystemTimezone * system_timezone_new (void) { @@ -118,7 +116,7 @@ system_timezone_get (SystemTimezone *systz) g_return_val_if_fail (IS_SYSTEM_TIMEZONE (systz), NULL); - priv = PRIVATE (systz); + priv = system_timezone_get_instance_private (systz); return priv->tz; } @@ -129,7 +127,7 @@ system_timezone_get_env (SystemTimezone *systz) g_return_val_if_fail (IS_SYSTEM_TIMEZONE (systz), NULL); - priv = PRIVATE (systz); + priv = system_timezone_get_instance_private (systz); return priv->env_tz; } @@ -149,15 +147,14 @@ system_timezone_class_init (SystemTimezoneClass *class) NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); - - g_type_class_add_private (class, sizeof (SystemTimezonePrivate)); } static void system_timezone_init (SystemTimezone *systz) { int i; - SystemTimezonePrivate *priv = PRIVATE (systz); + SystemTimezonePrivate *priv; + priv = system_timezone_get_instance_private (systz); priv->tz = NULL; priv->env_tz = NULL; @@ -171,6 +168,7 @@ system_timezone_constructor (GType type, GObjectConstructParam *construct_properties) { GObject *obj; + SystemTimezone *systz; SystemTimezonePrivate *priv; int i; @@ -183,7 +181,8 @@ system_timezone_constructor (GType type, n_construct_properties, construct_properties); - priv = PRIVATE (obj); + systz = SYSTEM_TIMEZONE (obj); + priv = system_timezone_get_instance_private (systz); priv->tz = system_timezone_find (); @@ -229,7 +228,11 @@ static void system_timezone_finalize (GObject *obj) { int i; - SystemTimezonePrivate *priv = PRIVATE (obj); + SystemTimezone *systz; + SystemTimezonePrivate *priv; + + systz = SYSTEM_TIMEZONE (obj); + priv = system_timezone_get_instance_private (systz); if (priv->tz) { g_free (priv->tz); @@ -261,7 +264,8 @@ system_timezone_monitor_changed (GFileMonitor *handle, GFileMonitorEvent event, gpointer user_data) { - SystemTimezonePrivate *priv = PRIVATE (user_data); + SystemTimezonePrivate *priv; + priv = system_timezone_get_instance_private (user_data); char *new_tz; if (event != G_FILE_MONITOR_EVENT_CHANGED && -- cgit v1.2.1