[Goodies-commits] r7152 - in xfce4-power-manager/trunk: . libxfpm po settings src
Ali Abdallah
aliov at xfce.org
Fri Apr 10 12:00:36 CEST 2009
Author: aliov
Date: 2009-04-10 10:00:36 +0000 (Fri, 10 Apr 2009)
New Revision: 7152
Added:
xfce4-power-manager/trunk/src/xfpm-button-hal.c
xfce4-power-manager/trunk/src/xfpm-button-hal.h
xfce4-power-manager/trunk/src/xfpm-button.c
xfce4-power-manager/trunk/src/xfpm-button.h
Removed:
xfce4-power-manager/trunk/src/xfpm-lid-hal.c
xfce4-power-manager/trunk/src/xfpm-lid-hal.h
Modified:
xfce4-power-manager/trunk/ChangeLog
xfce4-power-manager/trunk/libxfpm/hal-device.c
xfce4-power-manager/trunk/libxfpm/hal-device.h
xfce4-power-manager/trunk/libxfpm/hal-marshal.c
xfce4-power-manager/trunk/libxfpm/hal-marshal.h
xfce4-power-manager/trunk/libxfpm/hal-marshal.list
xfce4-power-manager/trunk/po/POTFILES.in
xfce4-power-manager/trunk/settings/xfpm-settings-main.c
xfce4-power-manager/trunk/src/Makefile.am
xfce4-power-manager/trunk/src/org.xfce.Power.Manager.xml
xfce4-power-manager/trunk/src/xfpm-brightness-hal.c
xfce4-power-manager/trunk/src/xfpm-button-xf86.c
xfce4-power-manager/trunk/src/xfpm-button-xf86.h
xfce4-power-manager/trunk/src/xfpm-engine.c
xfce4-power-manager/trunk/src/xfpm-engine.h
xfce4-power-manager/trunk/src/xfpm-enum-glib.h
xfce4-power-manager/trunk/src/xfpm-enum.h
xfce4-power-manager/trunk/src/xfpm-manager.c
Log:
Fall back to HAL in case we fail to map X11 keys
Modified: xfce4-power-manager/trunk/ChangeLog
===================================================================
--- xfce4-power-manager/trunk/ChangeLog 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/ChangeLog 2009-04-10 10:00:36 UTC (rev 7152)
@@ -1,4 +1,7 @@
+2009-04-10 12:00 Ali aliov at xfce.org
+ * : Fall back to HAL in case we fail to map X11 keys
+
2009-04-08 17:45 Ali aliov at xfce.org
* : Fix some Glib warnings
Modified: xfce4-power-manager/trunk/libxfpm/hal-device.c
===================================================================
--- xfce4-power-manager/trunk/libxfpm/hal-device.c 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/libxfpm/hal-device.c 2009-04-10 10:00:36 UTC (rev 7152)
@@ -18,6 +18,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+/*
+ * Based on code from gpm-button (gnome power manager)
+ * Copyright (C) 2006-2007 Richard Hughes <richard at hughsie.com>
+ *
+ */
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -46,11 +52,13 @@
gchar *udi;
gboolean watch_added;
+ gboolean watch_condition_added;
};
enum
{
DEVICE_CHANGED,
+ DEVICE_CONDITION,
LAST_SIGNAL
};
@@ -63,7 +71,6 @@
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
signals[DEVICE_CHANGED] =
g_signal_new("device-changed",
HAL_TYPE_DEVICE,
@@ -75,6 +82,16 @@
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
+ signals[DEVICE_CONDITION] =
+ g_signal_new("device-condition",
+ HAL_TYPE_DEVICE,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(HalDeviceClass, device_condition),
+ NULL, NULL,
+ _hal_marshal_VOID__STRING_STRING,
+ G_TYPE_NONE, 2,
+ G_TYPE_STRING, G_TYPE_STRING);
+
object_class->finalize = hal_device_finalize;
g_type_class_add_private (klass, sizeof(HalDevicePrivate));
@@ -141,6 +158,33 @@
}
static void
+hal_device_condition_cb (DBusGProxy *proxy,
+ const gchar *condition,
+ const gchar *details,
+ HalDevice *device)
+{
+ g_signal_emit (device, signals [DEVICE_CONDITION], 0, condition, details);
+}
+
+static void
+hal_device_add_watch_condition (HalDevice *device)
+{
+ g_return_if_fail ( DBUS_IS_G_PROXY (device->priv->proxy) );
+
+ dbus_g_object_register_marshaller (_hal_marshal_VOID__STRING_STRING,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_INVALID);
+
+ dbus_g_proxy_add_signal (device->priv->proxy, "Condition",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+
+ dbus_g_proxy_connect_signal (device->priv->proxy, "Condition",
+ G_CALLBACK (hal_device_condition_cb), device, NULL);
+
+ device->priv->watch_condition_added = TRUE;
+}
+
+static void
hal_device_init (HalDevice *device)
{
device->priv = HAL_DEVICE_GET_PRIVATE(device);
@@ -148,6 +192,7 @@
device->priv->proxy = NULL;
device->priv->udi = NULL;
device->priv->watch_added = FALSE;
+ device->priv->watch_condition_added = FALSE;
GError *error = NULL;
@@ -177,6 +222,10 @@
if ( device->priv->watch_added )
dbus_g_proxy_disconnect_signal (device->priv->proxy, "PropertyModified",
G_CALLBACK(hal_device_property_modified_cb), device);
+
+ if ( device->priv->watch_condition_added )
+ dbus_g_proxy_disconnect_signal (device->priv->proxy, "Condition",
+ G_CALLBACK(hal_device_condition_cb), device);
if ( device->priv->proxy )
g_object_unref (device->priv->proxy);
@@ -227,7 +276,17 @@
return device->priv->watch_added;
}
-
+
+gboolean
+hal_device_watch_condition (HalDevice *device)
+{
+ g_return_val_if_fail (device->priv->udi != NULL, FALSE);
+
+ hal_device_add_watch_condition (device);
+
+ return device->priv->watch_condition_added;
+}
+
gboolean hal_device_get_property_bool (HalDevice *device, const gchar *property)
{
g_return_val_if_fail (HAL_IS_DEVICE(device), FALSE);
Modified: xfce4-power-manager/trunk/libxfpm/hal-device.h
===================================================================
--- xfce4-power-manager/trunk/libxfpm/hal-device.h 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/libxfpm/hal-device.h 2009-04-10 10:00:36 UTC (rev 7152)
@@ -48,6 +48,10 @@
gboolean is_added,
gboolean is_removed);
+ void (*device_condition) (HalDevice *device,
+ const gchar *condition,
+ const gchar *detail);
+
} HalDeviceClass;
GType hal_device_get_type (void) G_GNUC_CONST;
@@ -61,6 +65,8 @@
gboolean hal_device_watch (HalDevice *device);
+gboolean hal_device_watch_condition (HalDevice *device);
+
gboolean hal_device_get_property_bool (HalDevice *device,
const gchar *property);
Modified: xfce4-power-manager/trunk/libxfpm/hal-marshal.c
===================================================================
--- xfce4-power-manager/trunk/libxfpm/hal-marshal.c 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/libxfpm/hal-marshal.c 2009-04-10 10:00:36 UTC (rev 7152)
@@ -125,3 +125,40 @@
data2);
}
+/* NONE:STRING,STRING (hal-marshal.list:3) */
+void
+_hal_marshal_VOID__STRING_STRING (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__STRING_STRING) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__STRING_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__STRING_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ data2);
+}
+
Modified: xfce4-power-manager/trunk/libxfpm/hal-marshal.h
===================================================================
--- xfce4-power-manager/trunk/libxfpm/hal-marshal.h 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/libxfpm/hal-marshal.h 2009-04-10 10:00:36 UTC (rev 7152)
@@ -24,6 +24,15 @@
gpointer marshal_data);
#define _hal_marshal_NONE__STRING_STRING_BOOLEAN_BOOLEAN _hal_marshal_VOID__STRING_STRING_BOOLEAN_BOOLEAN
+/* NONE:STRING,STRING (hal-marshal.list:3) */
+extern void _hal_marshal_VOID__STRING_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+#define _hal_marshal_NONE__STRING_STRING _hal_marshal_VOID__STRING_STRING
+
G_END_DECLS
#endif /* ___hal_marshal_MARSHAL_H__ */
Modified: xfce4-power-manager/trunk/libxfpm/hal-marshal.list
===================================================================
--- xfce4-power-manager/trunk/libxfpm/hal-marshal.list 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/libxfpm/hal-marshal.list 2009-04-10 10:00:36 UTC (rev 7152)
@@ -1,2 +1,3 @@
NONE:INT,BOXED
NONE:STRING,STRING,BOOLEAN,BOOLEAN
+NONE:STRING,STRING
Modified: xfce4-power-manager/trunk/po/POTFILES.in
===================================================================
--- xfce4-power-manager/trunk/po/POTFILES.in 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/po/POTFILES.in 2009-04-10 10:00:36 UTC (rev 7152)
@@ -5,7 +5,6 @@
src/xfpm-battery.c
src/xfpm-battery-info.c
src/xfpm-button-xf86.c
-src/xfpm-lid-hal.c
src/xfpm-brightness-hal.c
src/xfpm-battery.c
src/xfpm-idle.c
Modified: xfce4-power-manager/trunk/settings/xfpm-settings-main.c
===================================================================
--- xfce4-power-manager/trunk/settings/xfpm-settings-main.c 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/settings/xfpm-settings-main.c 2009-04-10 10:00:36 UTC (rev 7152)
@@ -78,7 +78,6 @@
gboolean user_privilege;
gboolean can_suspend;
gboolean can_hibernate;
- gboolean has_lid;
gboolean has_lcd_brightness;
XfconfChannel *channel;
@@ -130,7 +129,7 @@
xfpm_manager_dbus_client_get_config (proxy, &system_laptop, &user_privilege,
&can_suspend, &can_hibernate, &has_lcd_brightness,
- &has_lid, &error);
+ &error);
if ( error )
{
@@ -143,7 +142,7 @@
dialog = xfpm_settings_dialog_new (channel, system_laptop, user_privilege,
can_suspend, can_hibernate, has_lcd_brightness,
- has_lid);
+ system_laptop);
g_signal_connect(dialog, "response", G_CALLBACK(dialog_response_cb), bus);
Modified: xfce4-power-manager/trunk/src/Makefile.am
===================================================================
--- xfce4-power-manager/trunk/src/Makefile.am 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/src/Makefile.am 2009-04-10 10:00:36 UTC (rev 7152)
@@ -29,10 +29,12 @@
xfpm-dpms.h \
xfpm-cpu.c \
xfpm-cpu.h \
+ xfpm-button.c \
+ xfpm-button.h \
xfpm-button-xf86.c \
xfpm-button-xf86.h \
- xfpm-lid-hal.c \
- xfpm-lid-hal.h \
+ xfpm-button-hal.c \
+ xfpm-button-hal.h \
xfpm-backlight.c \
xfpm-backlight.h \
xfpm-brightness-hal.c \
Modified: xfce4-power-manager/trunk/src/org.xfce.Power.Manager.xml
===================================================================
--- xfce4-power-manager/trunk/src/org.xfce.Power.Manager.xml 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/src/org.xfce.Power.Manager.xml 2009-04-10 10:00:36 UTC (rev 7152)
@@ -19,7 +19,6 @@
<arg direction="out" name="can_suspend" type="b"/>
<arg direction="out" name="can_hibernate" type="b"/>
<arg direction="out" name="has_lcd_brightness" type="b"/>
- <arg direction="out" name="has_lid" type="b"/>
</method>
<method name="GetInfo">
Modified: xfce4-power-manager/trunk/src/xfpm-brightness-hal.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-brightness-hal.c 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/src/xfpm-brightness-hal.c 2009-04-10 10:00:36 UTC (rev 7152)
@@ -36,7 +36,7 @@
#include "libxfpm/xfpm-string.h"
#include "xfpm-brightness-hal.h"
-#include "xfpm-button-xf86.h"
+#include "xfpm-button.h"
#include "xfpm-enum-glib.h"
#include "xfpm-xfconf.h"
#include "xfpm-idle.h"
@@ -60,7 +60,7 @@
XfpmXfconf *conf;
XfpmIdle *idle;
- XfpmButtonXf86 *button;
+ XfpmButton *button;
XfpmAdapter *adapter;
XfpmScreenSaver *saver;
@@ -239,7 +239,7 @@
}
static void
-xfpm_brightness_hal_button_pressed_cb (XfpmButtonXf86 *button, XfpmXF86Button type, XfpmBrightnessHal *brg)
+xfpm_brightness_hal_button_pressed_cb (XfpmButton *button, XfpmButtonKey type, XfpmBrightnessHal *brg)
{
if ( type == BUTTON_MON_BRIGHTNESS_UP )
{
@@ -423,7 +423,7 @@
{
brg->priv->idle = xfpm_idle_new ();
brg->priv->conf = xfpm_xfconf_new ();
- brg->priv->button = xfpm_button_xf86_new ();
+ brg->priv->button = xfpm_button_new ();
brg->priv->adapter = xfpm_adapter_new ();
brg->priv->saver = xfpm_screen_saver_new ();
@@ -435,7 +435,7 @@
g_signal_connect (brg->priv->adapter, "adapter-changed",
G_CALLBACK(xfpm_brightness_hal_adapter_changed_cb), brg);
- g_signal_connect (brg->priv->button, "xf86-button-pressed",
+ g_signal_connect (brg->priv->button, "button-pressed",
G_CALLBACK(xfpm_brightness_hal_button_pressed_cb), brg);
g_signal_connect (brg->priv->idle, "alarm-timeout",
@@ -475,8 +475,11 @@
g_object_unref (brg->priv->saver);
if ( brg->priv->idle )
- g_object_unref (brg->priv->idle);
+ g_object_unref (brg->priv->idle);
+ if ( brg->priv->button)
+ g_object_unref (brg->priv->button);
+
G_OBJECT_CLASS(xfpm_brightness_hal_parent_class)->finalize(object);
}
Added: xfce4-power-manager/trunk/src/xfpm-button-hal.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-button-hal.c (rev 0)
+++ xfce4-power-manager/trunk/src/xfpm-button-hal.c 2009-04-10 10:00:36 UTC (rev 7152)
@@ -0,0 +1,270 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include <libxfce4util/libxfce4util.h>
+
+#include "libxfpm/hal-manager.h"
+#include "libxfpm/hal-device.h"
+
+#include "libxfpm/xfpm-string.h"
+
+#include "xfpm-button-hal.h"
+#include "xfpm-enum.h"
+#include "xfpm-enum-types.h"
+
+/* Init */
+static void xfpm_button_hal_class_init (XfpmButtonHalClass *klass);
+static void xfpm_button_hal_init (XfpmButtonHal *button);
+static void xfpm_button_hal_finalize (GObject *object);
+
+#define XFPM_BUTTON_HAL_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_BUTTON_HAL, XfpmButtonHalPrivate))
+
+struct XfpmButtonHalPrivate
+{
+ GPtrArray *array;
+ guint keys;
+};
+
+enum
+{
+ HAL_BUTTON_PRESSED,
+ LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (XfpmButtonHal, xfpm_button_hal, G_TYPE_OBJECT)
+
+static void
+xfpm_button_hal_emit_signals (XfpmButtonHal *bt, const gchar *condition, const gchar *detail)
+{
+ if ( !xfpm_strequal (condition, "ButtonPressed") )
+ return;
+
+ if ( xfpm_strequal (detail, "power") && bt->priv->keys & POWER_KEY )
+ {
+ TRACE ("Emitting signal button press condition %s detail %s", condition, detail);
+ g_signal_emit (G_OBJECT (bt), signals [HAL_BUTTON_PRESSED], 0, BUTTON_POWER_OFF);
+ }
+ else if ( xfpm_strequal (detail, "sleep") && bt->priv->keys & SLEEP_KEY )
+ {
+ TRACE ("Emitting signal button press condition %s detail %s", condition, detail);
+ g_signal_emit (G_OBJECT (bt), signals [HAL_BUTTON_PRESSED], 0, BUTTON_SLEEP);
+ }
+ else if ( xfpm_strequal (detail, "brightness-up") && bt->priv->keys & BRIGHTNESS_KEY )
+ {
+ TRACE ("Emitting signal button press condition %s detail %s", condition, detail);
+ g_signal_emit (G_OBJECT (bt), signals [HAL_BUTTON_PRESSED], 0, BUTTON_MON_BRIGHTNESS_UP);
+ }
+ else if ( xfpm_strequal (detail, "brightness-down") && bt->priv->keys & BRIGHTNESS_KEY )
+ {
+ TRACE ("Emitting signal button press condition %s detail %s", condition, detail);
+ g_signal_emit (G_OBJECT (bt), signals [HAL_BUTTON_PRESSED], 0, BUTTON_MON_BRIGHTNESS_DOWN);
+ }
+}
+
+static void
+xfpm_button_hal_device_changed_cb (HalDevice *device, const gchar *udi, const gchar *key,
+ gboolean is_added, gboolean is_removed, XfpmButtonHal *bt)
+{
+ gboolean pressed;
+ gchar *button_type;
+
+ if ( !xfpm_strequal (key, "button.state.value") )
+ return;
+
+ if ( hal_device_has_key (device, "button.type") )
+ {
+ button_type = hal_device_get_property_string (device, "button.type");
+
+ if ( button_type == NULL )
+ return;
+
+ if ( xfpm_strequal (button_type, "lid") )
+ {
+ pressed = hal_device_get_property_bool (device, key);
+
+ if ( pressed )
+ {
+ TRACE ("Emitting signal lid closed");
+ g_signal_emit (G_OBJECT (bt), signals [HAL_BUTTON_PRESSED], 0, BUTTON_LID_CLOSED );
+ }
+ }
+ g_free (button_type);
+ }
+}
+
+static void
+xfpm_button_hal_condition_cb (HalDevice *device, const gchar *condition,
+ const gchar *detail, XfpmButtonHal *bt)
+{
+ xfpm_button_hal_emit_signals (bt, condition, detail);
+}
+
+static void
+xfpm_button_hal_add_button (XfpmButtonHal *bt, const gchar *udi, gboolean lid_only)
+{
+ HalDevice *device;
+ gchar *button_type;
+
+ device = hal_device_new ();
+
+ hal_device_set_udi (device, udi);
+
+ if ( lid_only == TRUE )
+ {
+ if ( hal_device_has_key (device, "button.type") == FALSE )
+ {
+ g_object_unref (device);
+ return;
+ }
+
+ button_type = hal_device_get_property_string (device, "button.type");
+ if ( button_type == NULL ) return;
+
+ if ( xfpm_strequal (button_type, "lid") )
+ {
+ g_free (button_type);
+ goto out;
+ }
+ else
+ {
+ g_free (button_type);
+ g_object_unref (device);
+ return;
+ }
+ }
+
+out:
+ g_signal_connect (device, "device-changed",
+ G_CALLBACK (xfpm_button_hal_device_changed_cb), bt);
+
+ g_signal_connect (device, "device-condition",
+ G_CALLBACK (xfpm_button_hal_condition_cb), bt);
+
+ hal_device_watch (device);
+ hal_device_watch_condition (device);
+
+ g_ptr_array_add (bt->priv->array, device);
+}
+
+static void
+xfpm_button_hal_get_buttons (XfpmButtonHal *bt, gboolean lid_only)
+{
+ HalManager *manager;
+ gchar **udi;
+ int i;
+
+ manager = hal_manager_new ();
+
+ udi = hal_manager_find_device_by_capability (manager, "button");
+
+ if ( udi == NULL || udi[0] == NULL )
+ return;
+
+ g_object_unref (manager);
+
+ for ( i = 0; udi[i]; i++)
+ {
+ xfpm_button_hal_add_button (bt, udi[i], lid_only);
+ }
+ hal_manager_free_string_array (udi);
+}
+
+static void
+xfpm_button_hal_class_init (XfpmButtonHalClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ signals[HAL_BUTTON_PRESSED] =
+ g_signal_new("hal-button-pressed",
+ XFPM_TYPE_BUTTON_HAL,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(XfpmButtonHalClass, hal_button_pressed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__ENUM,
+ G_TYPE_NONE, 1, XFPM_TYPE_BUTTON_KEY);
+
+ object_class->finalize = xfpm_button_hal_finalize;
+
+ g_type_class_add_private (klass, sizeof (XfpmButtonHalPrivate));
+}
+
+static void
+xfpm_button_hal_init (XfpmButtonHal *button)
+{
+ button->priv = XFPM_BUTTON_HAL_GET_PRIVATE (button);
+ button->priv->array = g_ptr_array_new ();
+ button->priv->keys = 0;
+}
+
+static void
+xfpm_button_hal_free_device_array (XfpmButtonHal *button)
+{
+ HalDevice *device;
+ int i;
+
+ for ( i = 0 ; i<button->priv->array->len; i++)
+ {
+ device = g_ptr_array_index (button->priv->array, i);
+ g_object_unref (device);
+ }
+}
+
+static void
+xfpm_button_hal_finalize (GObject *object)
+{
+ XfpmButtonHal *button;
+
+ button = XFPM_BUTTON_HAL (object);
+
+ xfpm_button_hal_free_device_array (button);
+
+ g_ptr_array_free (button->priv->array, TRUE);
+
+ G_OBJECT_CLASS (xfpm_button_hal_parent_class)->finalize (object);
+}
+
+XfpmButtonHal *
+xfpm_button_hal_new (void)
+{
+ XfpmButtonHal *button = NULL;
+ button = g_object_new (XFPM_TYPE_BUTTON_HAL, NULL);
+ return button;
+}
+
+void xfpm_button_hal_get_keys (XfpmButtonHal *button, gboolean lid_only, guint8 keys)
+{
+ g_return_if_fail (XFPM_IS_BUTTON_HAL (button));
+
+ button->priv->keys = keys;
+ xfpm_button_hal_get_buttons (button, lid_only);
+}
Added: xfce4-power-manager/trunk/src/xfpm-button-hal.h
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-button-hal.h (rev 0)
+++ xfce4-power-manager/trunk/src/xfpm-button-hal.h 2009-04-10 10:00:36 UTC (rev 7152)
@@ -0,0 +1,60 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __XFPM_BUTTON_HAL_H
+#define __XFPM_BUTTON_HAL_H
+
+#include <glib-object.h>
+
+#include "xfpm-enum-glib.h"
+
+G_BEGIN_DECLS
+
+#define XFPM_TYPE_BUTTON_HAL (xfpm_button_hal_get_type () )
+#define XFPM_BUTTON_HAL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_BUTTON_HAL, XfpmButtonHal))
+#define XFPM_IS_BUTTON_HAL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_BUTTON_HAL))
+
+typedef struct XfpmButtonHalPrivate XfpmButtonHalPrivate;
+
+typedef struct
+{
+ GObject parent;
+ XfpmButtonHalPrivate *priv;
+
+} XfpmButtonHal;
+
+typedef struct
+{
+ GObjectClass parent_class;
+
+ void (*hal_button_pressed) (XfpmButtonHal *button,
+ XfpmButtonKey type);
+
+} XfpmButtonHalClass;
+
+GType xfpm_button_hal_get_type (void) G_GNUC_CONST;
+XfpmButtonHal *xfpm_button_hal_new (void);
+
+void xfpm_button_hal_get_keys (XfpmButtonHal *button,
+ gboolean lid_only,
+ guint8 buttons);
+G_END_DECLS
+
+#endif /* __XFPM_BUTTON_HAL_H */
Modified: xfce4-power-manager/trunk/src/xfpm-button-xf86.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-button-xf86.c 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/src/xfpm-button-xf86.c 2009-04-10 10:00:36 UTC (rev 7152)
@@ -30,19 +30,9 @@
#endif
#include <stdio.h>
-
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-
#include <X11/X.h>
#include <X11/XF86keysym.h>
@@ -54,6 +44,7 @@
#include <libxfce4util/libxfce4util.h>
#include "xfpm-button-xf86.h"
+#include "xfpm-enum.h"
#include "xfpm-enum-types.h"
/* Init */
@@ -72,7 +63,7 @@
GdkWindow *window;
GHashTable *hash;
- GTimer *timer;
+ guint8 mapped_buttons;
};
enum
@@ -105,25 +96,12 @@
return GDK_FILTER_CONTINUE;
}
- XfpmXF86Button type = GPOINTER_TO_INT (key_hash);
+ XfpmButtonKey type = GPOINTER_TO_INT (key_hash);
TRACE("Found key in hash %d", type);
- if ( (type == BUTTON_POWER_OFF || type == BUTTON_SLEEP) )
-
- {
- if ( g_timer_elapsed (button->priv->timer, NULL ) < DUPLICATE_SHUTDOWN_TIMEOUT )
- {
- TRACE("Button %d duplicated", type);
- goto out;
- }
- else
- g_timer_reset (button->priv->timer);
- }
-
g_signal_emit (G_OBJECT(button), signals[XF86_BUTTON_PRESSED], 0, type);
-out:
return GDK_FILTER_REMOVE;
}
@@ -165,8 +143,9 @@
return TRUE;
}
+
static gboolean
-xfpm_button_xf86_xevent_key (XfpmButtonXf86 *button, guint keysym , XfpmXF86Button type)
+xfpm_button_xf86_xevent_key (XfpmButtonXf86 *button, guint keysym , XfpmButtonKey type)
{
guint keycode = XKeysymToKeycode (GDK_DISPLAY(), keysym);
@@ -185,12 +164,12 @@
#ifdef DEBUG
gchar *content;
GValue value = { 0, };
- g_value_init (&value, XFPM_TYPE_XF86_BUTTON);
+ g_value_init (&value, XFPM_TYPE_BUTTON_KEY);
g_value_set_enum (&value, type);
content = g_strdup_value_contents (&value);
TRACE("Grabbed key=%s, keycode=%li", content, (long int) keycode);
g_free (content);
-#endif /* DEBUG */
+#endif /*DEBUG */
g_hash_table_insert (button->priv->hash, GINT_TO_POINTER(keycode), GINT_TO_POINTER(type));
@@ -203,10 +182,15 @@
button->priv->screen = gdk_screen_get_default ();
button->priv->window = gdk_screen_get_root_window (button->priv->screen);
- xfpm_button_xf86_xevent_key (button, XF86XK_PowerOff, BUTTON_POWER_OFF);
- xfpm_button_xf86_xevent_key (button, XF86XK_Sleep, BUTTON_SLEEP);
- xfpm_button_xf86_xevent_key (button, XF86XK_MonBrightnessUp, BUTTON_MON_BRIGHTNESS_UP);
- xfpm_button_xf86_xevent_key (button, XF86XK_MonBrightnessDown, BUTTON_MON_BRIGHTNESS_DOWN);
+ if ( xfpm_button_xf86_xevent_key (button, XF86XK_PowerOff, BUTTON_POWER_OFF) )
+ button->priv->mapped_buttons |= POWER_KEY;
+
+ if ( xfpm_button_xf86_xevent_key (button, XF86XK_Sleep, BUTTON_SLEEP) )
+ button->priv->mapped_buttons |= SLEEP_KEY;
+
+ if ( xfpm_button_xf86_xevent_key (button, XF86XK_MonBrightnessUp, BUTTON_MON_BRIGHTNESS_UP) &&
+ xfpm_button_xf86_xevent_key (button, XF86XK_MonBrightnessDown, BUTTON_MON_BRIGHTNESS_DOWN) )
+ button->priv->mapped_buttons |= BRIGHTNESS_KEY;
gdk_window_add_filter (button->priv->window,
xfpm_button_xf86_filter_x_events, button);
@@ -224,7 +208,7 @@
G_STRUCT_OFFSET(XfpmButtonXf86Class, xf86_button_pressed),
NULL, NULL,
g_cclosure_marshal_VOID__ENUM,
- G_TYPE_NONE, 1, XFPM_TYPE_XF86_BUTTON);
+ G_TYPE_NONE, 1, XFPM_TYPE_BUTTON_KEY);
object_class->finalize = xfpm_button_xf86_finalize;
@@ -236,9 +220,9 @@
{
button->priv = XFPM_BUTTON_XF86_GET_PRIVATE(button);
+ button->priv->mapped_buttons = 0;
button->priv->screen = NULL;
button->priv->window = NULL;
- button->priv->timer = g_timer_new ();
button->priv->hash = g_hash_table_new (NULL, NULL);
@@ -253,7 +237,6 @@
button = XFPM_BUTTON_XF86 (object);
g_hash_table_destroy (button->priv->hash);
- g_timer_destroy (button->priv->timer);
G_OBJECT_CLASS(xfpm_button_xf86_parent_class)->finalize(object);
}
@@ -272,3 +255,10 @@
}
return XFPM_BUTTON_XF86 (xfpm_button_xf86_object);
}
+
+guint8 xfpm_button_xf86_get_mapped_buttons (XfpmButtonXf86 *button)
+{
+ g_return_val_if_fail (XFPM_IS_BUTTON_XF86 (button), 0);
+
+ return button->priv->mapped_buttons;
+}
Modified: xfce4-power-manager/trunk/src/xfpm-button-xf86.h
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-button-xf86.h 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/src/xfpm-button-xf86.h 2009-04-10 10:00:36 UTC (rev 7152)
@@ -42,16 +42,18 @@
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (*xf86_button_pressed) (XfpmButtonXf86 *button,
- XfpmXF86Button type);
+ void (*xf86_button_pressed) (XfpmButtonXf86 *button,
+ XfpmButtonKey type);
} XfpmButtonXf86Class;
-GType xfpm_button_xf86_get_type (void) G_GNUC_CONST;
-XfpmButtonXf86 *xfpm_button_xf86_new (void);
+GType xfpm_button_xf86_get_type (void) G_GNUC_CONST;
+XfpmButtonXf86 *xfpm_button_xf86_new (void);
+guint8 xfpm_button_xf86_get_mapped_buttons (XfpmButtonXf86 *button) G_GNUC_PURE;
+
G_END_DECLS
#endif /* __XFPM_BUTTON_XF86_H */
Added: xfce4-power-manager/trunk/src/xfpm-button.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-button.c (rev 0)
+++ xfce4-power-manager/trunk/src/xfpm-button.c 2009-04-10 10:00:36 UTC (rev 7152)
@@ -0,0 +1,170 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include "xfpm-button.h"
+#include "xfpm-button-xf86.h"
+#include "xfpm-button-hal.h"
+#include "xfpm-enum.h"
+#include "xfpm-enum-types.h"
+
+/* Init */
+static void xfpm_button_class_init (XfpmButtonClass *klass);
+static void xfpm_button_init (XfpmButton *button);
+static void xfpm_button_finalize (GObject *object);
+
+#define XFPM_BUTTON_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_BUTTON, XfpmButtonPrivate))
+
+#define SLEEP_KEY_TIMEOUT 5.0f
+
+struct XfpmButtonPrivate
+{
+ XfpmButtonXf86 *xf86;
+ XfpmButtonHal *hal;
+ GTimer *timer;
+};
+
+enum
+{
+ BUTTON_PRESSED,
+ LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+static gpointer xfpm_button_object = NULL;
+
+G_DEFINE_TYPE (XfpmButton, xfpm_button, G_TYPE_OBJECT)
+
+static void
+xfpm_button_xf86_emit_signal (XfpmButton *button, XfpmButtonKey key)
+{
+ if ( key == BUTTON_LID_CLOSED || key == BUTTON_POWER_OFF || key == BUTTON_SLEEP )
+ {
+ if ( g_timer_elapsed (button->priv->timer, NULL) > SLEEP_KEY_TIMEOUT )
+ {
+ g_signal_emit (G_OBJECT (button), signals [BUTTON_PRESSED], 0, key);
+ g_timer_reset (button->priv->timer);
+ }
+ }
+ else
+ {
+ g_signal_emit (G_OBJECT (button), signals [BUTTON_PRESSED], 0, key);
+ }
+}
+
+static void
+xfpm_button_xf86_button_pressed_cb (XfpmButtonXf86 *xf86, XfpmButtonKey key, XfpmButton *button)
+{
+ xfpm_button_xf86_emit_signal (button, key);
+}
+
+static void
+xfpm_button_hal_button_pressed_cb (XfpmButtonHal *hal, XfpmButtonKey key, XfpmButton *button)
+{
+ xfpm_button_xf86_emit_signal (button, key);
+}
+
+static void
+xfpm_button_class_init (XfpmButtonClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ signals[BUTTON_PRESSED] =
+ g_signal_new("button-pressed",
+ XFPM_TYPE_BUTTON,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(XfpmButtonClass, button_pressed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__ENUM,
+ G_TYPE_NONE, 1, XFPM_TYPE_BUTTON_KEY);
+
+ object_class->finalize = xfpm_button_finalize;
+ g_type_class_add_private (klass, sizeof (XfpmButtonPrivate));
+}
+
+static void
+xfpm_button_init (XfpmButton *button)
+{
+ guint8 xf86_mapped;
+ guint8 hal_keys = 0;
+ gboolean only_lid = FALSE;
+
+ button->priv = XFPM_BUTTON_GET_PRIVATE (button);
+ button->priv->xf86 = xfpm_button_xf86_new ();
+ button->priv->timer = g_timer_new ();
+
+ xf86_mapped = xfpm_button_xf86_get_mapped_buttons (button->priv->xf86);
+
+ button->priv->hal = xfpm_button_hal_new ();
+
+ if ( xf86_mapped & SLEEP_KEY && xf86_mapped & POWER_KEY && xf86_mapped & BRIGHTNESS_KEY )
+ only_lid = TRUE;
+
+ hal_keys = ~xf86_mapped;
+
+ xfpm_button_hal_get_keys (button->priv->hal, only_lid, hal_keys);
+
+ g_signal_connect (button->priv->xf86, "xf86-button-pressed",
+ G_CALLBACK (xfpm_button_xf86_button_pressed_cb), button);
+
+ g_signal_connect (button->priv->hal, "hal-button-pressed",
+ G_CALLBACK (xfpm_button_hal_button_pressed_cb), button);
+}
+
+static void
+xfpm_button_finalize (GObject *object)
+{
+ XfpmButton *button;
+
+ button = XFPM_BUTTON (object);
+
+ g_object_unref (button->priv->hal);
+ g_object_unref (button->priv->xf86);
+
+ g_timer_destroy (button->priv->timer);
+
+ G_OBJECT_CLASS (xfpm_button_parent_class)->finalize (object);
+}
+
+XfpmButton *
+xfpm_button_new (void)
+{
+ if ( xfpm_button_object != NULL )
+ {
+ g_object_ref (xfpm_button_object);
+ }
+ else
+ {
+ xfpm_button_object = g_object_new (XFPM_TYPE_BUTTON, NULL);
+ g_object_add_weak_pointer (xfpm_button_object, &xfpm_button_object);
+ }
+ return XFPM_BUTTON (xfpm_button_object);
+}
Added: xfce4-power-manager/trunk/src/xfpm-button.h
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-button.h (rev 0)
+++ xfce4-power-manager/trunk/src/xfpm-button.h 2009-04-10 10:00:36 UTC (rev 7152)
@@ -0,0 +1,56 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __XFPM_BUTTON_H
+#define __XFPM_BUTTON_H
+
+#include <glib-object.h>
+
+#include "xfpm-enum-glib.h"
+
+G_BEGIN_DECLS
+
+#define XFPM_TYPE_BUTTON (xfpm_button_get_type () )
+#define XFPM_BUTTON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_BUTTON, XfpmButton))
+#define XFPM_IS_BUTTON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_BUTTON))
+
+typedef struct XfpmButtonPrivate XfpmButtonPrivate;
+
+typedef struct
+{
+ GObject parent;
+ XfpmButtonPrivate *priv;
+
+} XfpmButton;
+
+typedef struct
+{
+ GObjectClass parent_class;
+ void (*button_pressed) (XfpmButton *button,
+ XfpmButtonKey key);
+
+} XfpmButtonClass;
+
+GType xfpm_button_get_type (void) G_GNUC_CONST;
+XfpmButton *xfpm_button_new (void);
+
+G_END_DECLS
+
+#endif /* __XFPM_BUTTON_H */
Modified: xfce4-power-manager/trunk/src/xfpm-engine.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-engine.c 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/src/xfpm-engine.c 2009-04-10 10:00:36 UTC (rev 7152)
@@ -45,8 +45,7 @@
#include "xfpm-xfconf.h"
#include "xfpm-cpu.h"
#include "xfpm-network-manager.h"
-#include "xfpm-button-xf86.h"
-#include "xfpm-lid-hal.h"
+#include "xfpm-button.h"
#include "xfpm-inhibit.h"
#include "xfpm-backlight.h"
#include "xfpm-shutdown.h"
@@ -71,12 +70,11 @@
XfpmNotify *notify;
XfpmCpu *cpu;
- XfpmButtonXf86 *xf86_button;
- XfpmLidHal *lid;
XfpmBacklight *bk;
XfpmAdapter *adapter;
XfpmInhibit *inhibit;
XfpmShutdown *shutdown;
+ XfpmButton *button;
#ifdef HAVE_DPMS
XfpmDpms *dpms;
#endif
@@ -87,7 +85,6 @@
gboolean is_laptop;
gboolean has_lcd_brightness;
- gboolean has_lid;
gboolean block;
};
@@ -209,8 +206,8 @@
}
static void
-xfpm_engine_xf86_button_pressed_cb (XfpmButtonXf86 * button,
- XfpmXF86Button type, XfpmEngine * engine)
+xfpm_engine_button_pressed_cb (XfpmButton *button,
+ XfpmButtonKey type, XfpmEngine * engine)
{
TRACE ("Received button press event type %d", type);
XfpmShutdownRequest shutdown;
@@ -220,37 +217,21 @@
TRACE("Power manager automatic sleep is currently disabled");
return;
}
-
- if ( type != BUTTON_POWER_OFF && type != BUTTON_SLEEP )
- return;
-
- shutdown = xfpm_xfconf_get_property_enum (engine->priv->conf,
- type == BUTTON_POWER_OFF ? POWER_SWITCH_CFG :
- SLEEP_SWITCH_CFG );
- TRACE ("Accepting shutdown request");
+
+ if ( type == BUTTON_POWER_OFF || type == BUTTON_SLEEP )
+ shutdown = xfpm_xfconf_get_property_enum (engine->priv->conf,
+ type == BUTTON_POWER_OFF ? POWER_SWITCH_CFG :
+ SLEEP_SWITCH_CFG );
+ else
+ shutdown = xfpm_xfconf_get_property_enum (engine->priv->conf,
+ engine->priv->on_battery ?
+ LID_SWITCH_ON_BATTERY_CFG :
+ LID_SWITCH_ON_AC_CFG);
+
xfpm_engine_shutdown_request (engine, shutdown, FALSE);
}
static void
-xfpm_engine_lid_closed_cb (XfpmLidHal * lid, XfpmEngine * engine)
-{
- XfpmShutdownRequest shutdown;
-
- shutdown = xfpm_xfconf_get_property_enum (engine->priv->conf,
- engine->priv->
- on_battery ?
- LID_SWITCH_ON_BATTERY_CFG :
- LID_SWITCH_ON_AC_CFG);
-
- if ( engine->priv->inhibited )
- {
- TRACE("Power manager automatic sleep is currently disabled");
- return;
- }
- xfpm_engine_shutdown_request (engine, shutdown, FALSE);
-}
-
-static void
xfpm_engine_check_hal_iface (XfpmEngine * engine)
{
gboolean can_suspend, can_hibernate, caller;
@@ -300,29 +281,12 @@
engine);
xfpm_supply_monitor (engine->priv->supply);
- /*
- * Keys from XF86
- */
- engine->priv->xf86_button = xfpm_button_xf86_new ();
+ engine->priv->button = xfpm_button_new ();
- g_signal_connect (engine->priv->xf86_button, "xf86-button-pressed",
- G_CALLBACK (xfpm_engine_xf86_button_pressed_cb), engine);
+ g_signal_connect (engine->priv->button, "button-pressed",
+ G_CALLBACK (xfpm_engine_button_pressed_cb), engine);
/*
- * Lid from HAL
- */
- if (engine->priv->is_laptop)
- {
- engine->priv->lid = xfpm_lid_hal_new ();
- engine->priv->has_lid = xfpm_lid_hw_found (engine->priv->lid);
- if (engine->priv->has_lid)
- g_signal_connect (engine->priv->lid, "lid-closed",
- G_CALLBACK (xfpm_engine_lid_closed_cb), engine);
- else
- g_object_unref (engine->priv->lid);
- }
-
- /*
* Brightness HAL
*/
if (engine->priv->is_laptop)
@@ -390,8 +354,7 @@
engine->priv->dpms = NULL;
#endif
engine->priv->cpu = NULL;
- engine->priv->xf86_button = NULL;
- engine->priv->lid = NULL;
+ engine->priv->button = NULL;
engine->priv->bk = NULL;
engine->priv->power_management = 0;
@@ -419,6 +382,8 @@
g_object_unref (engine->priv->conf);
g_object_unref (engine->priv->supply);
+
+ g_object_unref (engine->priv->button);
#ifdef HAVE_DPMS
if (engine->priv->dpms)
@@ -428,9 +393,6 @@
if (engine->priv->cpu)
g_object_unref (engine->priv->cpu);
- if (engine->priv->lid)
- g_object_unref (engine->priv->lid);
-
g_object_unref (engine->priv->shutdown);
g_object_unref (engine->priv->adapter);
@@ -458,7 +420,7 @@
gboolean * user_privilege,
gboolean * can_suspend,
gboolean * can_hibernate,
- gboolean * has_lcd_brightness, gboolean * has_lid)
+ gboolean * has_lcd_brightness)
{
g_return_if_fail (XFPM_IS_ENGINE (engine));
@@ -469,7 +431,6 @@
*system_laptop = engine->priv->is_laptop;
*has_lcd_brightness = engine->priv->has_lcd_brightness;
- *has_lid = engine->priv->has_lid;
}
void xfpm_engine_reload_hal_objects (XfpmEngine *engine)
@@ -486,9 +447,7 @@
{
xfpm_backlight_reload (engine->priv->bk);
xfpm_cpu_reload (engine->priv->cpu);
- xfpm_lid_hal_reload (engine->priv->lid);
}
-
}
/*
Modified: xfce4-power-manager/trunk/src/xfpm-engine.h
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-engine.h 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/src/xfpm-engine.h 2009-04-10 10:00:36 UTC (rev 7152)
@@ -55,9 +55,8 @@
gboolean *user_privilege,
gboolean *can_suspend,
gboolean *can_hibernate,
- gboolean *has_lcd_brightness,
- gboolean *has_lid);
-
+ gboolean *has_lcd_brightness);
+
void xfpm_engine_reload_hal_objects (XfpmEngine *engine);
G_END_DECLS
Modified: xfce4-power-manager/trunk/src/xfpm-enum-glib.h
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-enum-glib.h 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/src/xfpm-enum-glib.h 2009-04-10 10:00:36 UTC (rev 7152)
@@ -53,9 +53,10 @@
BUTTON_POWER_OFF,
BUTTON_SLEEP,
BUTTON_MON_BRIGHTNESS_UP,
- BUTTON_MON_BRIGHTNESS_DOWN
+ BUTTON_MON_BRIGHTNESS_DOWN,
+ BUTTON_LID_CLOSED
-} XfpmXF86Button;
+} XfpmButtonKey;
G_END_DECLS
Modified: xfce4-power-manager/trunk/src/xfpm-enum.h
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-enum.h 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/src/xfpm-enum.h 2009-04-10 10:00:36 UTC (rev 7152)
@@ -48,11 +48,12 @@
typedef enum
{
- LID_SWITCH = (1<<0),
- SLEEP_SWITCH = (1<<1),
- POWER_SWITCH = (1<<2)
+ LID_KEY = (1 << 0),
+ BRIGHTNESS_KEY = (1 << 1),
+ SLEEP_KEY = (1 << 2),
+ POWER_KEY = (1 << 3)
-} XfpmSwitchButton;
+} XfpmKeys;
typedef enum
{
@@ -63,5 +64,6 @@
} XfpmCpuGovernor;
+G_END_DECLS
#endif /*__XFPM_ENUM_H */
Modified: xfce4-power-manager/trunk/src/xfpm-manager.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-manager.c 2009-04-10 09:29:21 UTC (rev 7151)
+++ xfce4-power-manager/trunk/src/xfpm-manager.c 2009-04-10 10:00:36 UTC (rev 7152)
@@ -284,8 +284,7 @@
OUT_user_privilege,
OUT_can_suspend,
OUT_can_hibernate,
- OUT_has_lcd_brightness,
- OUT_has_lid);
+ OUT_has_lcd_brightness);
return TRUE;
}
More information about the Goodies-commits
mailing list