summaryrefslogtreecommitdiff
path: root/mate-session/gsm-client.c
diff options
context:
space:
mode:
authorWu Xiaotian <[email protected]>2018-11-19 14:12:59 +0800
committerraveit65 <[email protected]>2018-11-26 13:02:53 +0100
commit6b7875b9714d5872f80b6b4012f24fb8f548aca2 (patch)
treebf3ba2f47a359ecad1281604cb869fbfe1200a05 /mate-session/gsm-client.c
parentbdec713320b7487c429bd4415fdde55cf48cb44b (diff)
downloadmate-session-manager-6b7875b9714d5872f80b6b4012f24fb8f548aca2.tar.bz2
mate-session-manager-6b7875b9714d5872f80b6b4012f24fb8f548aca2.tar.xz
Avoid compile warning for g_type_class_add_private
- capplet/gsm-app-dialog.c - capplet/gsm-app-dialog.h - capplet/gsm-properties-dialog.c - capplet/gsm-properties-dialog.h - capplet/gsp-app-manager.c - capplet/gsp-app-manager.h - capplet/gsp-app.c - capplet/gsp-app.h - mate-session/gsm-app.c - mate-session/gsm-app.h - mate-session/gsm-autostart-app.c - mate-session/gsm-autostart-app.h - mate-session/gsm-client.c - mate-session/gsm-client.h - mate-session/gsm-consolekit.c - mate-session/gsm-consolekit.h - mate-session/gsm-dbus-client.c - mate-session/gsm-dbus-client.h - mate-session/gsm-inhibit-dialog.c - mate-session/gsm-inhibit-dialog.h - mate-session/gsm-inhibitor.c - mate-session/gsm-inhibitor.h - mate-session/gsm-logout-dialog.c - mate-session/gsm-logout-dialog.h - mate-session/gsm-store.c - mate-session/gsm-store.h - mate-session/gsm-systemd.c - mate-session/gsm-systemd.h - mate-session/gsm-xsmp-client.c - mate-session/gsm-xsmp-client.h - mate-session/gsm-xsmp-server.c - mate-session/gsm-xsmp-server.h
Diffstat (limited to 'mate-session/gsm-client.c')
-rw-r--r--mate-session/gsm-client.c110
1 files changed, 72 insertions, 38 deletions
diff --git a/mate-session/gsm-client.c b/mate-session/gsm-client.c
index 2909d99..13c6169 100644
--- a/mate-session/gsm-client.c
+++ b/mate-session/gsm-client.c
@@ -31,16 +31,14 @@
static guint32 client_serial = 1;
-#define GSM_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_CLIENT, GsmClientPrivate))
-
-struct GsmClientPrivate
-{
+typedef struct {
+ GObject parent;
char *id;
char *startup_id;
char *app_id;
guint status;
DBusGConnection *connection;
-};
+} GsmClientPrivate;
enum {
PROP_0,
@@ -58,7 +56,7 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-G_DEFINE_ABSTRACT_TYPE (GsmClient, gsm_client, G_TYPE_OBJECT)
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GsmClient, gsm_client, G_TYPE_OBJECT)
GQuark
gsm_client_error_quark (void)
@@ -111,10 +109,12 @@ static gboolean
register_client (GsmClient *client)
{
GError *error;
+ GsmClientPrivate *priv;
error = NULL;
- client->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (client->priv->connection == NULL) {
+ priv = gsm_client_get_instance_private (client);
+ priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (priv->connection == NULL) {
if (error != NULL) {
g_critical ("error getting session bus: %s", error->message);
g_error_free (error);
@@ -122,7 +122,7 @@ register_client (GsmClient *client)
return FALSE;
}
- dbus_g_connection_register_g_object (client->priv->connection, client->priv->id, G_OBJECT (client));
+ dbus_g_connection_register_g_object (priv->connection, priv->id, G_OBJECT (client));
return TRUE;
}
@@ -134,13 +134,14 @@ gsm_client_constructor (GType type,
{
GsmClient *client;
gboolean res;
+ GsmClientPrivate *priv;
client = GSM_CLIENT (G_OBJECT_CLASS (gsm_client_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
-
- g_free (client->priv->id);
- client->priv->id = g_strdup_printf ("/org/gnome/SessionManager/Client%u", get_next_client_serial ());
+ priv = gsm_client_get_instance_private (client);
+ g_free (priv->id);
+ priv->id = g_strdup_printf ("/org/gnome/SessionManager/Client%u", get_next_client_serial ());
res = register_client (client);
if (! res) {
@@ -153,24 +154,25 @@ gsm_client_constructor (GType type,
static void
gsm_client_init (GsmClient *client)
{
- client->priv = GSM_CLIENT_GET_PRIVATE (client);
}
static void
gsm_client_finalize (GObject *object)
{
GsmClient *client;
+ GsmClientPrivate *priv;
g_return_if_fail (object != NULL);
g_return_if_fail (GSM_IS_CLIENT (object));
client = GSM_CLIENT (object);
+ priv = gsm_client_get_instance_private (client);
- g_return_if_fail (client->priv != NULL);
+ g_return_if_fail (priv != NULL);
- g_free (client->priv->id);
- g_free (client->priv->startup_id);
- g_free (client->priv->app_id);
+ g_free (priv->id);
+ g_free (priv->startup_id);
+ g_free (priv->app_id);
G_OBJECT_CLASS (gsm_client_parent_class)->finalize (object);
}
@@ -179,9 +181,12 @@ void
gsm_client_set_status (GsmClient *client,
guint status)
{
+ GsmClientPrivate *priv;
g_return_if_fail (GSM_IS_CLIENT (client));
- if (client->priv->status != status) {
- client->priv->status = status;
+
+ priv = gsm_client_get_instance_private (client);
+ if (priv->status != status) {
+ priv->status = status;
g_object_notify (G_OBJECT (client), "status");
}
}
@@ -190,14 +195,17 @@ static void
gsm_client_set_startup_id (GsmClient *client,
const char *startup_id)
{
+ GsmClientPrivate *priv;
g_return_if_fail (GSM_IS_CLIENT (client));
- g_free (client->priv->startup_id);
+ priv = gsm_client_get_instance_private (client);
+
+ g_free (priv->startup_id);
if (startup_id != NULL) {
- client->priv->startup_id = g_strdup (startup_id);
+ priv->startup_id = g_strdup (startup_id);
} else {
- client->priv->startup_id = g_strdup ("");
+ priv->startup_id = g_strdup ("");
}
g_object_notify (G_OBJECT (client), "startup-id");
}
@@ -206,14 +214,17 @@ void
gsm_client_set_app_id (GsmClient *client,
const char *app_id)
{
+ GsmClientPrivate *priv;
g_return_if_fail (GSM_IS_CLIENT (client));
- g_free (client->priv->app_id);
+ priv = gsm_client_get_instance_private (client);
+
+ g_free (priv->app_id);
if (app_id != NULL) {
- client->priv->app_id = g_strdup (app_id);
+ priv->app_id = g_strdup (app_id);
} else {
- client->priv->app_id = g_strdup ("");
+ priv->app_id = g_strdup ("");
}
g_object_notify (G_OBJECT (client), "app-id");
}
@@ -251,18 +262,20 @@ gsm_client_get_property (GObject *object,
GParamSpec *pspec)
{
GsmClient *self;
+ GsmClientPrivate *priv;
self = GSM_CLIENT (object);
+ priv = gsm_client_get_instance_private (self);
switch (prop_id) {
case PROP_STARTUP_ID:
- g_value_set_string (value, self->priv->startup_id);
+ g_value_set_string (value, priv->startup_id);
break;
case PROP_APP_ID:
- g_value_set_string (value, self->priv->app_id);
+ g_value_set_string (value, priv->app_id);
break;
case PROP_STATUS:
- g_value_set_uint (value, self->priv->status);
+ g_value_set_uint (value, priv->status);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -285,13 +298,15 @@ static void
gsm_client_dispose (GObject *object)
{
GsmClient *client;
+ GsmClientPrivate *priv;
g_return_if_fail (object != NULL);
g_return_if_fail (GSM_IS_CLIENT (object));
client = GSM_CLIENT (object);
+ priv = gsm_client_get_instance_private (client);
- g_debug ("GsmClient: disposing %s", client->priv->id);
+ g_debug ("GsmClient: disposing %s", priv->id);
G_OBJECT_CLASS (gsm_client_parent_class)->dispose (object);
}
@@ -352,17 +367,18 @@ gsm_client_class_init (GsmClientClass *klass)
GSM_CLIENT_UNREGISTERED,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_type_class_add_private (klass, sizeof (GsmClientPrivate));
-
dbus_g_object_type_install_info (GSM_TYPE_CLIENT, &dbus_glib_gsm_client_object_info);
}
const char *
gsm_client_peek_id (GsmClient *client)
{
+ GsmClientPrivate *priv;
g_return_val_if_fail (GSM_IS_CLIENT (client), NULL);
- return client->priv->id;
+ priv = gsm_client_get_instance_private (client);
+
+ return priv->id;
}
/**
@@ -378,25 +394,34 @@ gsm_client_peek_id (GsmClient *client)
const char *
gsm_client_peek_app_id (GsmClient *client)
{
+ GsmClientPrivate *priv;
g_return_val_if_fail (GSM_IS_CLIENT (client), NULL);
- return client->priv->app_id;
+ priv = gsm_client_get_instance_private (client);
+
+ return priv->app_id;
}
const char *
gsm_client_peek_startup_id (GsmClient *client)
{
+ GsmClientPrivate *priv;
g_return_val_if_fail (GSM_IS_CLIENT (client), NULL);
- return client->priv->startup_id;
+ priv = gsm_client_get_instance_private (client);
+
+ return priv->startup_id;
}
guint
gsm_client_peek_status (GsmClient *client)
{
+ GsmClientPrivate *priv;
g_return_val_if_fail (GSM_IS_CLIENT (client), GSM_CLIENT_UNREGISTERED);
- return client->priv->status;
+ priv = gsm_client_get_instance_private (client);
+
+ return priv->status;
}
guint
@@ -412,9 +437,12 @@ gsm_client_get_startup_id (GsmClient *client,
char **id,
GError **error)
{
+ GsmClientPrivate *priv;
g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
- *id = g_strdup (client->priv->startup_id);
+ priv = gsm_client_get_instance_private (client);
+
+ *id = g_strdup (priv->startup_id);
return TRUE;
}
@@ -424,9 +452,12 @@ gsm_client_get_app_id (GsmClient *client,
char **id,
GError **error)
{
+ GsmClientPrivate *priv;
g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
- *id = g_strdup (client->priv->app_id);
+ priv = gsm_client_get_instance_private (client);
+
+ *id = g_strdup (priv->app_id);
return TRUE;
}
@@ -448,9 +479,12 @@ gsm_client_get_status (GsmClient *client,
guint *status,
GError **error)
{
+ GsmClientPrivate *priv;
g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
- *status = client->priv->status;
+ priv = gsm_client_get_instance_private (client);
+
+ *status = priv->status;
return TRUE;
}