From 45c4b372775505e1e8f2f2bfa0c7395760bf52a4 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 17 Oct 2013 00:35:22 +0200 Subject: [PATCH] lib: Add up_client_get_display_device() Add a helper to get to the display device. --- libupower-glib/up-client.c | 24 ++++++++++++++++++++++++ libupower-glib/up-client.h | 1 + 2 files changed, 25 insertions(+) diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c index 7243c8f..ec9434d 100644 --- a/libupower-glib/up-client.c +++ b/libupower-glib/up-client.c @@ -121,6 +121,30 @@ up_client_get_devices (UpClient *client) return g_ptr_array_ref (client->priv->array); } +/** + * up_client_get_display_device: + * @client: a #UpClient instance. + * + * Get the composite display device. + * Return value: (transfer full) a #UpClient object, or %NULL on error. + * + * Since: 1.0 + **/ +UpDevice * +up_client_get_display_device (UpClient *client) +{ + gboolean ret; + UpDevice *device; + + device = up_device_new (); + ret = up_device_set_object_path_sync (device, "/org/freedesktop/UPower/devices/DisplayDevice", NULL, NULL); + if (!ret) { + g_object_unref (G_OBJECT (device)); + return NULL; + } + return device; +} + /** * up_client_get_daemon_version: * @client: a #UpClient instance. diff --git a/libupower-glib/up-client.h b/libupower-glib/up-client.h index 3c389d0..0c58a3d 100644 --- a/libupower-glib/up-client.h +++ b/libupower-glib/up-client.h @@ -80,6 +80,7 @@ UpClient *up_client_new (void); gboolean up_client_enumerate_devices_sync (UpClient *client, GCancellable *cancellable, GError **error); +UpDevice * up_client_get_display_device (UpClient *client); /* accessors */ GPtrArray *up_client_get_devices (UpClient *client);