[gnome-power-manager] Add support for the DeviceKit-power property lid-is-closed so we can now run without --enable-legacy
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-power-manager] Add support for the DeviceKit-power property lid-is-closed so we can now run without --enable-legacy
- Date: Tue, 5 May 2009 10:42:04 -0400 (EDT)
commit 90000eb88dbc4ef404f6be0940a0b64572c588ff
Author: Richard Hughes <richard hughsie com>
Date: Tue May 5 15:41:02 2009 +0100
Add support for the DeviceKit-power property lid-is-closed so we can now run without --enable-legacy-buttons
---
src/gpm-button.c | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/src/gpm-button.c b/src/gpm-button.c
index bb31443..e42390f 100644
--- a/src/gpm-button.c
+++ b/src/gpm-button.c
@@ -29,6 +29,7 @@
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <X11/XF86keysym.h>
+#include <devkit-power-gobject/devicekit-power.h>
#ifdef HAVE_LEGACY_BUTTONS
#include <hal-manager.h>
@@ -53,6 +54,7 @@ struct GpmButtonPrivate
gchar *last_button;
GTimer *timer;
gboolean lid_is_closed;
+ DkpClient *client;
#ifdef HAVE_LEGACY_BUTTONS
HalManager *hal_manager; /* remove when input events is in the kernel */
HalDeviceStore *hal_device_store;
@@ -516,6 +518,31 @@ hal_daemon_new_device_cb (HalManager *hal_manager, const gchar *udi, GpmButton *
#endif
/**
+ * gpm_button_client_changed_cb
+ **/
+static void
+gpm_button_client_changed_cb (DkpClient *client, GpmButton *button)
+{
+ gboolean lid_is_closed;
+
+ /* get new state */
+ lid_is_closed = dkp_client_lid_is_closed (client);
+
+ /* same state */
+ if (button->priv->lid_is_closed == lid_is_closed)
+ return;
+
+ /* save state */
+ button->priv->lid_is_closed = lid_is_closed;
+
+ /* sent correct event */
+ if (lid_is_closed)
+ gpm_button_emit_type (button, GPM_BUTTON_LID_CLOSED);
+ else
+ gpm_button_emit_type (button, GPM_BUTTON_LID_OPEN);
+}
+
+/**
* gpm_button_init:
* @button: This class instance
**/
@@ -532,6 +559,9 @@ gpm_button_init (GpmButton *button)
button->priv->timer = g_timer_new ();
button->priv->lid_is_closed = FALSE;
+ button->priv->client = dkp_client_new ();
+ g_signal_connect (button->priv->client, "changed",
+ G_CALLBACK (gpm_button_client_changed_cb), button);
/* register the brightness keys */
gpm_button_xevent_key (button, XF86XK_PowerOff, GPM_BUTTON_POWER);
@@ -585,6 +615,7 @@ gpm_button_finalize (GObject *object)
button = GPM_BUTTON (object);
button->priv = GPM_BUTTON_GET_PRIVATE (button);
+ g_object_unref (button->priv->client);
#ifdef HAVE_LEGACY_BUTTONS
g_object_unref (button->priv->hal_manager);
g_object_unref (button->priv->hal_device_store);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]