From 3e3fa04ffbf101d517a2826542f68538c4c58556 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 18 Oct 2019 17:40:36 +0200 Subject: [PATCH] lib: Add up_client_new_session() To create a UpClient that will listen on the session bus. --- libupower-glib/up-client.c | 17 +++++++++++++++++ libupower-glib/up-client.h | 1 + 2 files changed, 18 insertions(+) diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c index 0e4112d..1369216 100644 --- a/libupower-glib/up-client.c +++ b/libupower-glib/up-client.c @@ -611,3 +611,20 @@ up_client_new (void) return client; } +/** + * up_client_new_session: + * + * Creates a new #UpClient object that will listen to UPower data on the session + * bus rather than on the system bus. + * + * Return value: a new UpClient object, or %NULL on failure. + * + * Since: 0.9.11 + **/ +UpClient * +up_client_new_session (GCancellable *cancellable, GError **error) +{ + return g_initable_new (UP_TYPE_CLIENT, cancellable, error, + "bus-type", G_BUS_TYPE_SESSION, + NULL); +} diff --git a/libupower-glib/up-client.h b/libupower-glib/up-client.h index 0180dd4..ac5171e 100644 --- a/libupower-glib/up-client.h +++ b/libupower-glib/up-client.h @@ -73,6 +73,7 @@ typedef struct { GType up_client_get_type (void); UpClient *up_client_new (void); UpClient *up_client_new_full (GCancellable *cancellable, GError **error); +UpClient *up_client_new_session (GCancellable *cancellable, GError **error); /* sync versions */ UpDevice * up_client_get_display_device (UpClient *client);