[Xfce4-commits] <xfce4-power-manager:master> Creating the devkit-power branch, this brank is highly experimental a big part of xfpm and its configuration settings are broken.

Ali Abdallah noreply at xfce.org
Sat Jan 30 02:18:01 CET 2010


Updating branch refs/heads/master
         to c4bab4c1be603614ace33b914d155c12223e762e (commit)
       from 3742c86ef274cdb1c1493e16878d414c960c1ac5 (commit)

commit c4bab4c1be603614ace33b914d155c12223e762e
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Tue Nov 3 16:07:11 2009 +0100

    Creating the devkit-power branch, this brank is highly experimental
    a big part of xfpm and its configuration settings are broken.
    
    In this branch polkit is a new optional dependency, this is for
    getting if the user is permitted to use org.freedesktop.Devicekit.Power
    sleep interfaces, also by default the power manager will try to
    manipulate the lcd brightness using xrandr (doesn't work yet),
    HAL remains an optional dependency of fall back for the lcd
    brightness and in case of mapping failure of keyboard sleep keys.
    
    If HAL support is compiled but HAL is not running
    or stopped, xfpm should in future commits be able to handle this.

 Makefile.am                                       |    8 +-
 common/Makefile.am                                |   25 +
 common/xfpm-brightness.c                          |  424 ++++++++
 common/xfpm-brightness.h                          |   68 ++
 {libxfpm => common}/xfpm-common.c                 |   36 +-
 {libxfpm => common}/xfpm-common.h                 |    7 +
 {src => common}/xfpm-debug.c                      |    0
 {src => common}/xfpm-debug.h                      |    0
 {libxfpm => common}/xfpm-icons.h                  |    1 +
 configure.ac.in                                   |   48 +-
 data/interfaces/xfpm-settings.ui                  |    4 +-
 libdbus/Makefile.am                               |   36 +
 libdbus/xfpm-dbus-marshal.list                    |    2 +
 {src => libdbus}/xfpm-dbus-monitor.c              |   13 +-
 {src => libdbus}/xfpm-dbus-monitor.h              |    0
 libdbus/xfpm-dbus.c                               |  138 +++
 {libxfpm => libdbus}/xfpm-dbus.h                  |   22 +-
 libhal/Makefile.am                                |   35 +
 {libxfpm => libhal}/hal-device.c                  |    0
 {libxfpm => libhal}/hal-device.h                  |    0
 {libxfpm => libhal}/hal-manager.c                 |    0
 {libxfpm => libhal}/hal-manager.h                 |    0
 {libxfpm => libhal}/hal-marshal.list              |    0
 libxfpm/Makefile.am                               |   69 --
 libxfpm/hal-battery.c                             |  554 -----------
 libxfpm/hal-enum.h                                |   37 -
 libxfpm/hal-power.c                               |  386 --------
 libxfpm/hal-power.h                               |   67 --
 libxfpm/xfpm-dbus.c                               |   93 --
 libxfpm/xfpm-popups.c                             |   79 --
 libxfpm/xfpm-popups.h                             |   35 -
 libxfpm/xfpm-string.c                             |   47 -
 libxfpm/xfpm-string.h                             |   35 -
 panel-plugins/brightness/Makefile.am              |   21 +-
 panel-plugins/brightness/brightness-button.c      |   42 +-
 panel-plugins/brightness/brightness-plugin.c      |    2 -
 panel-plugins/brightness/brightness-proxy.c       |  237 -----
 panel-plugins/brightness/brightness-proxy.h       |   62 --
 settings/Makefile.am                              |   11 +-
 settings/xfpm-settings-main.c                     |   49 +-
 settings/xfpm-settings.c                          |   90 +-
 settings/xfpm-settings.h                          |    5 +-
 src/Makefile.am                                   |  165 ++--
 src/org.freedesktop.PowerManagement.Backlight.xml |   15 -
 src/org.freedesktop.PowerManagement.xml           |    4 +-
 src/xfpm-adapter.c                                |  214 ----
 src/xfpm-adapter.h                                |   61 --
 src/xfpm-backlight.c                              |  193 ----
 src/xfpm-backlight.h                              |   56 --
 src/xfpm-battery-info.c                           |  222 -----
 src/xfpm-battery-info.h                           |   35 -
 src/xfpm-battery.c                                |  953 +++++++++----------
 src/xfpm-battery.h                                |   36 +-
 src/xfpm-brightness-hal.c                         |  594 -----------
 src/xfpm-brightness-hal.h                         |   64 --
 src/xfpm-brightness-widget.c                      |  352 -------
 src/xfpm-brightness-widget.h                      |   60 --
 src/xfpm-button-hal.c                             |  327 -------
 src/xfpm-button-hal.h                             |   67 --
 src/xfpm-button-xf86.c                            |  271 -----
 src/xfpm-button-xf86.h                            |   59 --
 src/xfpm-button.c                                 |  251 ++++--
 src/xfpm-button.h                                 |   26 +-
 src/xfpm-cpu.c                                    |  427 --------
 src/xfpm-cpu.h                                    |   59 --
 src/xfpm-dkp.c                                    | 1087 +++++++++++++++++++++
 src/xfpm-dkp.h                                    |  100 ++
 src/xfpm-dpms.c                                   |   56 +-
 src/xfpm-engine.c                                 |  957 ------------------
 src/xfpm-engine.h                                 |   62 --
 src/xfpm-enum-glib.h                              |   13 -
 src/xfpm-idle.c                                   |  370 -------
 src/xfpm-idle.h                                   |   74 --
 src/xfpm-main.c                                   |  126 ++--
 src/xfpm-manager.c                                |  331 +++++--
 src/xfpm-manager.h                                |    3 +-
 {libxfpm => src}/xfpm-notify.c                    |    3 +-
 {libxfpm => src}/xfpm-notify.h                    |    0
 src/xfpm-polkit.c                                 |  191 ++++
 libxfpm/hal-battery.h => src/xfpm-polkit.h        |   39 +-
 src/xfpm-screen-saver.c                           |  157 ---
 src/xfpm-screen-saver.h                           |   62 --
 src/xfpm-session.c                                |  279 ------
 src/xfpm-session.h                                |   69 --
 src/xfpm-shutdown.c                               |  532 ----------
 src/xfpm-shutdown.h                               |   83 --
 src/xfpm-supply.c                                 |  631 ------------
 src/xfpm-supply.h                                 |   66 --
 src/xfpm-tray-icon.c                              |  553 -----------
 src/xfpm-tray-icon.h                              |   73 --
 src/xfpm-xfconf.c                                 |    5 +-
 91 files changed, 3380 insertions(+), 9841 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index fa225bb..dc3cd5c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,9 +4,15 @@ if BUILD_PANEL_PLUGINS
 plugins_dir = panel-plugins
 endif
 
+if ENABLE_HAL
+libhal_dir = libhal
+endif
+
 SUBDIRS =        	\
 	data		\
-	libxfpm		\
+	$(libhal_dir)	\
+	libdbus		\
+	common		\
 	src		\
 	settings	\
 	$(plugins_dir)	\
diff --git a/common/Makefile.am b/common/Makefile.am
new file mode 100644
index 0000000..5557b1d
--- /dev/null
+++ b/common/Makefile.am
@@ -0,0 +1,25 @@
+noinst_LTLIBRARIES =                    \
+        libxfpmcommon.la
+
+libxfpmcommon_la_SOURCES =              \
+	xfpm-common.c			\
+	xfpm-common.h			\
+	xfpm-brightness.c		\
+	xfpm-brightness.h		\
+	xfpm-debug.c			\
+	xfpm-debug.h			\
+	xfpm-icons.h
+
+libxfpmcommon_la_CFLAGS =               \
+	$(GTK_CFLAGS)                   \
+	$(GLIB_CFLAGS)                  \
+	$(LIBXFCE4UTIL_CFLAGS)
+
+if ENABLE_HAL
+
+libxfpmcommon_la_CFLAGS += 		\
+	$(DBUS_GLIB_CFLAGS)
+
+libxfpmcommon_la_LIBADD =		\
+	$(top_builddir)/libhal/libxfpmhal.la
+endif
\ No newline at end of file
diff --git a/common/xfpm-brightness.c b/common/xfpm-brightness.c
new file mode 100644
index 0000000..15bd984
--- /dev/null
+++ b/common/xfpm-brightness.c
@@ -0,0 +1,424 @@
+/*
+ * * 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 <gtk/gtk.h>
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/Xrandr.h>
+
+#include <libxfce4util/libxfce4util.h>
+
+#ifdef WITH_HAL
+#include <dbus/dbus-glib.h>
+#include "libhal/hal-manager.h"
+#include "libhal/hal-device.h"
+#endif
+
+#include "xfpm-brightness.h"
+#include "xfpm-debug.h"
+
+static void xfpm_brightness_finalize   (GObject *object);
+
+#define XFPM_BRIGHTNESS_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_BRIGHTNESS, XfpmBrightnessPrivate))
+
+struct XfpmBrightnessPrivate
+{
+    XRRScreenResources *resource;
+    Atom		backlight;
+    gint 		output;
+    gboolean		xrandr_has_hw;
+    
+#ifdef WITH_HAL
+    DBusGProxy         *hal_proxy;
+    gboolean		hal_brightness_in_hw;
+    gboolean		hal_hw_found;
+    guint		hal_max_level;
+    guint		hal_step;
+#endif
+};
+
+G_DEFINE_TYPE (XfpmBrightness, xfpm_brightness, G_TYPE_OBJECT)
+
+static gboolean
+xfpm_brightness_xrand_get_limit (XfpmBrightness *brightness, RROutput output, guint *min, guint *max)
+{
+    XRRPropertyInfo *info;
+    gboolean ret = TRUE;
+
+    info = XRRQueryOutputProperty (GDK_DISPLAY (), output, brightness->priv->backlight);
+    
+    if (info == NULL) 
+    {
+	g_warning ("could not get output property");
+	return FALSE;
+    }
+    
+    if (!info->range || info->num_values != 2) 
+    {
+	g_warning ("no range found");
+	ret = FALSE;
+	goto out;
+    }
+    
+    *min = info->values[0];
+    *max = info->values[1];
+    
+out:
+    XFree (info);
+    return ret;
+}
+
+static gboolean G_GNUC_UNUSED
+xfpm_brightness_xrandr_get_current (XfpmBrightness *brightness, RROutput output, guint *current)
+{
+    unsigned long nitems;
+    unsigned long bytes_after;
+    guint *prop;
+    Atom actual_type;
+    int actual_format;
+    gboolean ret = FALSE;
+
+    if (XRRGetOutputProperty (GDK_DISPLAY (), output, brightness->priv->backlight,
+			      0, 4, False, False, None,
+			      &actual_type, &actual_format,
+			      &nitems, &bytes_after, ((unsigned char **)&prop)) != Success) 
+    {
+	g_warning ("failed to get property");
+	return FALSE;
+    }
+    
+    if (actual_type == XA_INTEGER && nitems == 1 && actual_format == 32) 
+    {
+	memcpy (current, prop, sizeof (guint));
+	ret = TRUE;
+    }
+    
+    XFree (prop);
+    
+    return ret;
+}
+
+static gboolean
+xfpm_brightness_setup_xrandr (XfpmBrightness *brightness)
+{
+    GdkScreen *screen;
+    XRROutputInfo *info;
+    Window window;
+    gint major, minor, screen_num;
+    guint min, max;
+    gboolean ret = FALSE;
+    gint i;
+    
+    if ( !XRRQueryVersion (GDK_DISPLAY (), &major, &minor) )
+    {
+	TRACE ("No XRANDR extension found");
+	return FALSE;
+    }
+    
+    brightness->priv->backlight = XInternAtom (GDK_DISPLAY (), "BACKLIGHT", True);
+    
+    if (brightness->priv->backlight == None) 
+    {
+	TRACE ("No outputs have backlight property");
+	return FALSE;
+    }
+	
+    screen = gdk_display_get_default_screen (gdk_display_get_default ());
+    
+    screen_num = gdk_screen_get_number (screen);
+    
+    window = RootWindow (GDK_DISPLAY (), screen_num);
+    
+#if (RANDR_MAJOR == 1 && RANDR_MINOR >=3 )
+    brightness->priv->resource = XRRGetScreenResourcesCurrent (GDK_DISPLAY (), window);
+#else
+    brightness->priv->resource = XRRGetScreenResources (GDK_DISPLAY (), window);
+#endif
+    
+    for ( i = 0; i < brightness->priv->resource->noutput; i++)
+    {
+	info = XRRGetOutputInfo (GDK_DISPLAY (), brightness->priv->resource, brightness->priv->resource->outputs[i]);
+	
+	if ( !g_strcmp0 (info->name, "LVDS") )
+	{
+	    if ( xfpm_brightness_xrand_get_limit (brightness, brightness->priv->resource->outputs[i], &min, &max) &&
+		 min != max )
+	    {
+		ret = TRUE;
+		brightness->priv->output = brightness->priv->resource->outputs[i];
+	    }
+	    
+	}
+	XRRFreeOutputInfo (info);
+    }
+    
+    return ret;
+}
+
+
+/*
+ * Begin HAL optional brightness code. 
+ * 
+ */
+
+#ifdef WITH_HAL
+static gint 
+xfpm_brightness_hal_get_level (XfpmBrightness *brg)
+{
+    GError *error = NULL;
+    gint level = 0;
+    gboolean ret = FALSE;
+    
+    ret = dbus_g_proxy_call (brg->priv->hal_proxy, "GetBrightness", &error,
+	 		     G_TYPE_INVALID,
+			     G_TYPE_INT, &level,
+			     G_TYPE_INVALID);
+
+    if (error)
+    {
+	g_warning ("GetBrightness failed : %s\n", error->message);
+	g_error_free (error);
+    }
+    return level;
+}
+
+static gboolean
+xfpm_brightness_hal_set_level (XfpmBrightness *brg, gint level)
+{
+    GError *error = NULL;
+    gboolean ret = FALSE;
+    gint dummy;
+    
+    TRACE ("Setting level %d", level);
+    
+    ret = dbus_g_proxy_call (brg->priv->hal_proxy, "SetBrightness", &error,
+			     G_TYPE_INT, level,
+			     G_TYPE_INVALID,
+			     G_TYPE_INT, &dummy, /* Just to avoid a warning! */
+			     G_TYPE_INVALID );
+		       
+    if ( error )
+    {
+	g_critical ("Error setting brightness level: %s\n", error->message);
+	g_error_free (error);
+	return FALSE;
+    }
+    
+    if (!ret)
+    {
+	g_warning ("SetBrightness failed\n");
+    }
+    
+    return TRUE;
+}
+
+
+static void
+xfpm_brightness_hal_up (XfpmBrightness *brightness)
+{
+    gint hw_level;
+    
+    hw_level = xfpm_brightness_hal_get_level (brightness);
+    
+    if ( hw_level != 0 )
+    {
+	xfpm_brightness_hal_set_level (brightness, hw_level + brightness->priv->hal_step);
+    }
+}
+
+static void
+xfpm_brightness_hal_down (XfpmBrightness *brightness)
+{
+    gint hw_level;
+    
+    hw_level = xfpm_brightness_hal_get_level (brightness);
+    
+    if ( hw_level != 0 )
+    {
+	xfpm_brightness_hal_set_level (brightness, hw_level - brightness->priv->hal_step);
+    }
+    
+}
+
+static gboolean
+xfpm_brightness_setup_hal (XfpmBrightness *brightness)
+{
+    DBusGConnection *bus;
+    HalDevice *device;
+    gchar **udi = NULL;
+    HalManager *manager;
+    
+    manager = hal_manager_new ();
+    
+    udi = hal_manager_find_device_by_capability (manager, "laptop_panel");
+    g_object_unref ( manager);
+    
+    if ( !udi || !udi[0])
+    {
+    	return FALSE;
+    }
+    
+    device = hal_device_new ();
+    hal_device_set_udi (device, udi[0]);
+    
+    brightness->priv->hal_max_level = hal_device_get_property_int (device, "laptop_panel.num_levels") -1;
+    brightness->priv->hal_step = brightness->priv->hal_max_level <= 20 ? 1 : brightness->priv->hal_max_level / 20;
+    brightness->priv->hal_hw_found = TRUE;
+    
+    if ( hal_device_has_key (device, "laptop_panel.brightness_in_hardware") )
+	brightness->priv->hal_brightness_in_hw = hal_device_get_property_bool (device ,"laptop_panel.brightness_in_hardware");
+	
+    TRACE ("laptop_panel.num_levels=%d\n", brightness->priv->hal_max_level);
+    
+    g_object_unref (device);
+
+    /*FIXME, check for errors*/
+    bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
+    
+    brightness->priv->hal_proxy = dbus_g_proxy_new_for_name (bus,
+							     "org.freedesktop.Hal",
+							     udi[0],
+							     "org.freedesktop.Hal.Device.LaptopPanel");
+     
+    if ( !brightness->priv->hal_proxy )
+	g_warning ("Unable to get proxy for device %s\n", udi[0]);
+    
+    hal_manager_free_string_array (udi);
+    return FALSE;
+}
+#endif /* WITH_HAL*/
+
+static void
+xfpm_brightness_class_init (XfpmBrightnessClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = xfpm_brightness_finalize;
+
+    g_type_class_add_private (klass, sizeof (XfpmBrightnessPrivate));
+}
+
+static void
+xfpm_brightness_init (XfpmBrightness *brightness)
+{
+    brightness->priv = XFPM_BRIGHTNESS_GET_PRIVATE (brightness);
+    
+    brightness->priv->resource = NULL;
+    
+}
+
+static void
+xfpm_brightness_finalize (GObject *object)
+{
+    XfpmBrightness *brightness;
+
+    brightness = XFPM_BRIGHTNESS (object);
+
+    if ( brightness->priv->resource )
+	XRRFreeScreenResources (brightness->priv->resource);
+
+    G_OBJECT_CLASS (xfpm_brightness_parent_class)->finalize (object);
+}
+
+XfpmBrightness *
+xfpm_brightness_new (void)
+{
+    XfpmBrightness *brightness = NULL;
+    brightness = g_object_new (XFPM_TYPE_BRIGHTNESS, NULL);
+    return brightness;
+}
+
+gboolean
+xfpm_brightness_setup (XfpmBrightness *brightness)
+{
+    brightness->priv->xrandr_has_hw = xfpm_brightness_setup_xrandr (brightness);
+    
+    if ( !brightness->priv->xrandr_has_hw )
+    {
+	TRACE ("Unable to control brightness via xrandr, trying to use HAL");
+	if ( !xfpm_brightness_setup_hal (brightness) )
+	    return FALSE;
+    }
+    
+    return TRUE;
+}
+
+void xfpm_brightness_up	(XfpmBrightness *brightness)
+{
+#ifdef WITH_HAL
+    if ( brightness->priv->hal_hw_found )
+	xfpm_brightness_hal_up (brightness);
+#endif
+}
+
+void xfpm_brightness_down (XfpmBrightness *brightness)
+{
+#ifdef WITH_HAL
+    if ( brightness->priv->hal_hw_found )
+	xfpm_brightness_hal_down (brightness);
+#endif
+}
+
+gboolean xfpm_brightness_has_hw (XfpmBrightness *brightness)
+{
+#ifdef WITH_HAL
+    if ( !brightness->priv->xrandr_has_hw )
+	return brightness->priv->hal_hw_found;
+#endif
+    
+    return brightness->priv->xrandr_has_hw;
+}
+
+guint xfpm_brightness_get_max_level (XfpmBrightness *brightness)
+{
+#ifdef WITH_HAL
+    return brightness->priv->hal_max_level;
+#endif
+    return 0;
+}
+
+guint xfpm_brightness_get_level	(XfpmBrightness *brightness)
+{
+#ifdef WITH_HAL
+    return xfpm_brightness_hal_get_level (brightness);
+#endif
+    return 0;
+}
+
+gboolean xfpm_brightness_set_level (XfpmBrightness *brightness, guint level)
+{
+#ifdef WITH_HAL
+    return xfpm_brightness_hal_set_level (brightness, level);
+#endif
+    
+    return FALSE;
+}
diff --git a/common/xfpm-brightness.h b/common/xfpm-brightness.h
new file mode 100644
index 0000000..91ef694
--- /dev/null
+++ b/common/xfpm-brightness.h
@@ -0,0 +1,68 @@
+/*
+ * * 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_BRIGHTNESS_H
+#define __XFPM_BRIGHTNESS_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define XFPM_TYPE_BRIGHTNESS        (xfpm_brightness_get_type () )
+#define XFPM_BRIGHTNESS(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_BRIGHTNESS, XfpmBrightness))
+#define XFPM_IS_BRIGHTNESS(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_BRIGHTNESS))
+
+typedef struct XfpmBrightnessPrivate XfpmBrightnessPrivate;
+
+typedef struct
+{
+    GObject         		parent;
+    XfpmBrightnessPrivate      *priv;
+    
+} XfpmBrightness;
+
+typedef struct
+{
+    GObjectClass 		parent_class;
+    
+} XfpmBrightnessClass;
+
+GType        			xfpm_brightness_get_type        (void) G_GNUC_CONST;
+
+XfpmBrightness       	       *xfpm_brightness_new             (void);
+
+gboolean			xfpm_brightness_setup 		(XfpmBrightness *brightness);
+
+void				xfpm_brightness_up		(XfpmBrightness *brightness);
+
+void				xfpm_brightness_down		(XfpmBrightness *brightness);
+
+gboolean			xfpm_brightness_has_hw 		(XfpmBrightness *brightness);
+
+guint 				xfpm_brightness_get_max_level   (XfpmBrightness *brightness);
+
+guint 				xfpm_brightness_get_level	(XfpmBrightness *brightness);
+
+gboolean			xfpm_brightness_set_level	(XfpmBrightness *brightness,
+								 guint level);
+
+G_END_DECLS
+
+#endif /* __XFPM_BRIGHTNESS_H */
diff --git a/libxfpm/xfpm-common.c b/common/xfpm-common.c
similarity index 84%
rename from libxfpm/xfpm-common.c
rename to common/xfpm-common.c
index 77da56a..cde612a 100644
--- a/libxfpm/xfpm-common.c
+++ b/common/xfpm-common.c
@@ -23,7 +23,20 @@
 #include <libxfce4util/libxfce4util.h>
 
 #include "xfpm-common.h"
-#include "xfpm-string.h"
+
+const gchar *xfpm_bool_to_string (gboolean value)
+{
+    if ( value == TRUE ) return "TRUE";
+    else 		 return "FALSE";
+}
+
+gboolean xfpm_string_to_bool (const gchar *string)
+{
+    if ( !g_strcmp0 (string, "TRUE") ) return TRUE;
+    else if ( !g_strcmp0 (string, "FALSE") ) return FALSE;
+    
+    return FALSE;
+}
 
 GtkBuilder *xfpm_builder_new_from_string (const gchar *ui, GError **error)
 {
@@ -180,3 +193,24 @@ gboolean xfpm_is_multihead_connected (void)
     
     return FALSE;
 }
+
+GdkPixbuf *xfpm_icon_load (const gchar *icon_name, gint size)
+{
+    GdkPixbuf *pix = NULL;
+    GError *error = NULL;
+    
+    pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), 
+				    icon_name, 
+				    size,
+				    GTK_ICON_LOOKUP_USE_BUILTIN,
+				    &error);
+				    
+    if ( error )
+    {
+	g_warning ("Unable to load icon : %s : %s", icon_name, error->message);
+	g_error_free (error);
+    }
+    
+    return pix;
+}
+
diff --git a/libxfpm/xfpm-common.h b/common/xfpm-common.h
similarity index 86%
rename from libxfpm/xfpm-common.h
rename to common/xfpm-common.h
index dfd9faf..80f47cd 100644
--- a/libxfpm/xfpm-common.h
+++ b/common/xfpm-common.h
@@ -30,6 +30,13 @@
 
 G_BEGIN_DECLS
 
+GdkPixbuf      *xfpm_icon_load			(const gchar *icon_name,
+						 gint size);
+
+const gchar    *xfpm_bool_to_string     	(gboolean value) G_GNUC_PURE;
+
+gboolean        xfpm_string_to_bool     	(const gchar *string) G_GNUC_PURE;
+
 GtkBuilder     *xfpm_builder_new_from_string   	(const gchar *file,
 						 GError **error);
 
diff --git a/src/xfpm-debug.c b/common/xfpm-debug.c
similarity index 100%
rename from src/xfpm-debug.c
rename to common/xfpm-debug.c
diff --git a/src/xfpm-debug.h b/common/xfpm-debug.h
similarity index 100%
rename from src/xfpm-debug.h
rename to common/xfpm-debug.h
diff --git a/libxfpm/xfpm-icons.h b/common/xfpm-icons.h
similarity index 97%
rename from libxfpm/xfpm-icons.h
rename to common/xfpm-icons.h
index 3bc8f67..e00a96d 100644
--- a/libxfpm/xfpm-icons.h
+++ b/common/xfpm-icons.h
@@ -32,6 +32,7 @@ G_BEGIN_DECLS
 #define XFPM_KBD_ICON_PREFIX			"xfpm-keyboard-"
 #define XFPM_CAMERA_ICON_PREFIX			"xfpm-camera-"
 #define XFPM_PDA_ICON_PREFIX			"xfpm-pda-"
+#define XFPM_PHONE_ICON_PREFIX			"xfpm-phone-"
 #define XFPM_KBD_MOUSE_ICON_PREFIX		"xfpm-keyboard-mouse-"
 
 #define XFPM_DISPLAY_BRIGHTNESS_ICON	        "xfpm-brightness-lcd"
diff --git a/configure.ac.in b/configure.ac.in
index a2919d4..3e0c3ca 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -1,7 +1,7 @@
 m4_define([intltool_minimum_version], [0.31])
 m4_define([xfpm_version_major],  [0])
-m4_define([xfpm_version_minor],  [8])
-m4_define([xfpm_version_micro],  [4.1])
+m4_define([xfpm_version_minor],  [9])
+m4_define([xfpm_version_micro],  [90])
 m4_define([xfpm_version_build],  [@REVISION@])
 m4_define([xfpm_version_tag],[git])
 m4_define([xfpm_version], [xfpm_version_major().xfpm_version_minor().xfpm_version_micro()ifelse(xfpm_version_tag(), [git], [xfpm_version_tag().xfpm_version_build()], [xfpm_version_tag()])])
@@ -54,11 +54,13 @@ m4_define([dbus_minimum_version], [0.60])
 m4_define([dbus_glib_minimum_version], [0.70])
 
 m4_define([xfconf_minimum_version], [4.6.0])
-m4_define([libxfcegui4_minimum_version],[4.6.0])
+m4_define([libxfce4ui_minimum_version],[4.6.0])
 m4_define([libxfce4util_minimum_version],[4.6.0])
 m4_define([libxfce4panel_minimum_version],[4.6.0])
 
 m4_define([libnotify_minimum_version], [0.4.1])
+m4_define([xrandr_minimum_version], [1.2.0])
+m4_define([polkit_minimum_version], [0.91])
 
 XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [gtk_minimum_version])
 XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [glib_minimum_version])
@@ -68,9 +70,29 @@ XDT_CHECK_PACKAGE([GMODULE], [gmodule-2.0], [glib_minimum_version])
 XDT_CHECK_PACKAGE([DBUS], [dbus-1], [dbus_minimum_version])
 XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [dbus_glib_minimum_version])
 XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0],[xfconf_minimum_version])
-XDT_CHECK_PACKAGE([LIBXFCE4GUI], [libxfcegui4-1.0],[libxfcegui4_minimum_version])
+XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1],[libxfce4ui_minimum_version])
 XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0],[libxfce4util_minimum_version])
 XDT_CHECK_PACKAGE([LIBNOTIFY],[libnotify], [libnotify_minimum_version])
+XDT_CHECK_PACKAGE([XRANDR],[xrandr], [xrandr_minimum_version])
+
+POLKIT="no"
+XDT_CHECK_OPTIONAL_PACKAGE([POLKIT], [polkit-gobject-1], [polkit_minimum_version], [polkit], [Polkit support])
+
+#=======================================================#
+#              Use HAL?			                #
+#=======================================================#
+AC_ARG_ENABLE([hal],
+	[AC_HELP_STRING([--disable-hal],
+		[Do not enable HAL (default=enabled)])],
+	[ac_cv_enable_hal=$enableval],
+	[ac_cv_enable_hal=yes])
+if test "x$ac_cv_enable_hal" = "xno"; then
+	enable_hal="no"
+else
+	enable_hal="yes"
+	AC_DEFINE(WITH_HAL, 1 , [HAL support])
+fi
+AM_CONDITIONAL([ENABLE_HAL], [test "x$enable_hal" = "xyes"])
 
 #=======================================================#
 #           Check for DPMS support                      #
@@ -168,7 +190,9 @@ XDT_FEATURE_DEBUG
 
 AC_OUTPUT([
 Makefile
-libxfpm/Makefile
+libhal/Makefile
+libdbus/Makefile
+common/Makefile
 src/Makefile
 settings/Makefile
 panel-plugins/Makefile
@@ -191,12 +215,14 @@ echo "
  	    Xfce Power Manager $VERSION
 	======================================
  
-	prefix:			$prefix
-	xdg autostart:		$sysconfdir/xdg/autostart
-   	DPMS:   		$have_dpms
-	Network manager:	$ac_network_manager
-  	Build panel plugins:	$build_panel_plugins
-   	Debug:		   	$enable_debug
+	prefix:			${prefix}
+	xdg autostart:		${sysconfdir/xdg/autostart}
+	HAL:			${enable_hal}
+	POLKIT:			${POLKIT_FOUND}
+   	DPMS:   		${have_dpms}
+	Network manager:	${ac_network_manager}
+  	Build panel plugins:	${build_panel_plugins}
+   	Debug:		   	${enable_debug}
 --------------------------------------------------
 
 Configuration finished, type make to compile"
diff --git a/data/interfaces/xfpm-settings.ui b/data/interfaces/xfpm-settings.ui
index 1531e12..50c6f7c 100644
--- a/data/interfaces/xfpm-settings.ui
+++ b/data/interfaces/xfpm-settings.ui
@@ -54,7 +54,7 @@
   </object>
   <object class="GtkAdjustment" id="adjustment9">
     <property name="value">10</property>
-    <property name="lower">1</property>
+    <property name="lower">5</property>
     <property name="upper">20</property>
     <property name="step_increment">1</property>
   </object>
@@ -264,7 +264,7 @@
                                         <child>
                                           <object class="GtkLabel" id="hibernate-label">
                                             <property name="visible">True</property>
-                                            <property name="xalign">0</property>
+					    <property name="xalign">0</property>
                                             <property name="label" translatable="yes">When hibernate button is pressed:</property>
                                           </object>
                                           <packing>
diff --git a/libdbus/Makefile.am b/libdbus/Makefile.am
new file mode 100644
index 0000000..3ab62d2
--- /dev/null
+++ b/libdbus/Makefile.am
@@ -0,0 +1,36 @@
+noinst_LTLIBRARIES = 			\
+	libxfpmdbus.la
+
+libxfpmdbus_la_SOURCES =		\
+	xfpm-dbus.c			\
+	xfpm-dbus.h			\
+	xfpm-dbus-monitor.c		\
+	xfpm-dbus-monitor.h		\
+	xfpm-dbus-marshal.c		\
+	xfpm-dbus-marshal.h
+	
+libxfpmdbus_la_CFLAGS =			\
+	$(GLIB_CFLAGS)			\
+	$(LIBXFCE4UTIL_CFLAGS)		\
+	$(DBUS_GLIB_CFLAGS)
+
+if MAINTAINER_MODE
+
+BUILT_SOURCES =				\
+	xfpm-dbus-marshal.c		\
+	xfpm-dbus-marshal.h
+
+xfpm-dbus-marshal.c: xfpm-dbus-marshal.list
+	echo "#include \"xfpm-dbus-marshal.h\"" > $@ && \
+	glib-genmarshal $< --prefix=_xfpm_dbus_marshal --body >> $@
+
+xfpm-dbus-marshal.h: xfpm-dbus-marshal.list
+	glib-genmarshal $< --prefix=_xfpm_dbus_marshal --header > $@
+
+endif
+
+EXTRA_DIST =				\
+	xfpm-dbus-marshal.list
+
+DISTCLEANFILES =			\
+	$(BUILT_SOURCES)
\ No newline at end of file
diff --git a/libdbus/xfpm-dbus-marshal.list b/libdbus/xfpm-dbus-marshal.list
new file mode 100644
index 0000000..7803418
--- /dev/null
+++ b/libdbus/xfpm-dbus-marshal.list
@@ -0,0 +1,2 @@
+VOID:STRING,BOOLEAN
+VOID:STRING,BOOLEAN,BOOLEAN
diff --git a/src/xfpm-dbus-monitor.c b/libdbus/xfpm-dbus-monitor.c
similarity index 97%
rename from src/xfpm-dbus-monitor.c
rename to libdbus/xfpm-dbus-monitor.c
index b77b21d..16fa406 100644
--- a/src/xfpm-dbus-monitor.c
+++ b/libdbus/xfpm-dbus-monitor.c
@@ -33,11 +33,10 @@
 
 #include <libxfce4util/libxfce4util.h>
 
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-dbus.h"
+#include "xfpm-dbus.h"
 
 #include "xfpm-dbus-monitor.h"
-#include "xfpm-marshal.h"
+#include "xfpm-dbus-marshal.h"
 
 static void xfpm_dbus_monitor_finalize   (GObject *object);
 
@@ -112,7 +111,6 @@ xfpm_dbus_monitor_unique_connection_name_lost (XfpmDBusMonitor *monitor, DBusBus
 	
 	if ( !g_strcmp0 (watch->name, name) && bus_type == watch->bus_type )
 	{
-	    TRACE ("Unique name %s disconnected ", name);
 	    g_signal_emit (G_OBJECT(monitor), signals [UNIQUE_NAME_LOST], 0, 
 			   watch->name, bus_type == DBUS_BUS_SESSION ? TRUE : FALSE);
 	    g_ptr_array_remove (monitor->priv->names_array, watch);
@@ -142,7 +140,6 @@ xfpm_dbus_monitor_service_connection_changed (XfpmDBusMonitor *monitor, DBusBusT
 	
 	if ( !g_strcmp0 (watch->name, name) && watch->bus_type == bus_type)
 	{
-	    TRACE ("Service %s connection changed %s", name, xfpm_bool_to_string (connected));
 	    g_signal_emit (G_OBJECT (monitor), signals [SERVICE_CONNECTION_CHANGED], 0,
 			   name, connected, bus_type == DBUS_BUS_SESSION ? TRUE : FALSE);
 	}
@@ -287,7 +284,7 @@ xfpm_dbus_monitor_class_init (XfpmDBusMonitorClass *klass)
 		      G_SIGNAL_RUN_LAST,
 		      G_STRUCT_OFFSET (XfpmDBusMonitorClass, unique_name_lost),
 		      NULL, NULL,
-		      _xfpm_marshal_VOID__STRING_BOOLEAN,
+		      _xfpm_dbus_marshal_VOID__STRING_BOOLEAN,
 		      G_TYPE_NONE, 2, 
 		      G_TYPE_STRING, G_TYPE_BOOLEAN);
 		     
@@ -306,7 +303,7 @@ xfpm_dbus_monitor_class_init (XfpmDBusMonitorClass *klass)
 		      G_SIGNAL_RUN_LAST,
 		      G_STRUCT_OFFSET (XfpmDBusMonitorClass, service_connection_changed),
 		      NULL, NULL,
-		      _xfpm_marshal_VOID__STRING_BOOLEAN_BOOLEAN,
+		      _xfpm_dbus_marshal_VOID__STRING_BOOLEAN_BOOLEAN,
 		      G_TYPE_NONE, 3, G_TYPE_STRING,
 		      G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
 		      
@@ -421,8 +418,6 @@ gboolean xfpm_dbus_monitor_add_unique_name (XfpmDBusMonitor *monitor, DBusBusTyp
     if ( xfpm_dbus_monitor_get_watch_data (monitor->priv->names_array, unique_name, bus_type) )
 	return FALSE;
 	
-    TRACE ("Monitoring application with unique_name %s", unique_name);
-    
     watch = g_new0 (XfpmWatchData , 1);
     watch->name = g_strdup (unique_name);
     watch->bus_type = bus_type;
diff --git a/src/xfpm-dbus-monitor.h b/libdbus/xfpm-dbus-monitor.h
similarity index 100%
rename from src/xfpm-dbus-monitor.h
rename to libdbus/xfpm-dbus-monitor.h
diff --git a/libdbus/xfpm-dbus.c b/libdbus/xfpm-dbus.c
new file mode 100644
index 0000000..ccbe5dc
--- /dev/null
+++ b/libdbus/xfpm-dbus.c
@@ -0,0 +1,138 @@
+/*
+ * * Copyright (C) 2008-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
+ */
+
+#include "xfpm-dbus.h"
+
+gboolean
+xfpm_dbus_name_has_owner (DBusConnection *connection, const gchar *name)
+{
+    DBusError error;
+    gboolean ret;
+    
+    dbus_error_init (&error);
+    
+    ret = dbus_bus_name_has_owner(connection, name, &error);
+    
+    if ( dbus_error_is_set(&error) )
+    {
+        g_warning("Failed to get name owner: %s\n",error.message);
+        dbus_error_free(&error);
+        return FALSE;
+    }
+    
+    return ret;
+}
+
+gboolean xfpm_dbus_register_name(DBusConnection *connection, const gchar *name)
+{
+    DBusError error;
+    int ret;
+    
+    dbus_error_init(&error);
+    
+    ret =
+	dbus_bus_request_name(connection,
+			      name,
+			      DBUS_NAME_FLAG_DO_NOT_QUEUE,
+			      &error);
+	
+    if ( dbus_error_is_set(&error) )
+    {
+	g_warning("Error: %s\n",error.message);
+	dbus_error_free(&error);
+	return FALSE;
+    }
+    
+    if ( ret == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER )
+    {
+	return TRUE;
+    }
+    
+    return FALSE;
+}
+
+gboolean xfpm_dbus_release_name(DBusConnection *connection, const gchar *name)
+{
+    DBusError error;
+    int ret;
+    
+    dbus_error_init(&error);
+    
+    ret =
+	dbus_bus_release_name(connection,
+			      name,
+			      &error);
+    
+    if ( dbus_error_is_set(&error) )
+    {
+        g_warning("Error: %s\n",error.message);
+        dbus_error_free(&error);
+        return FALSE;
+    }
+    
+    if ( ret == -1 ) return FALSE;
+    
+    return TRUE;
+}
+
+
+GHashTable *xfpm_dbus_get_interface_properties (DBusGProxy *proxy_prop, const gchar *iface_name)
+{
+    gboolean ret;
+    GError *error = NULL;
+    GHashTable *props = NULL;
+
+    props = NULL;
+
+    ret = dbus_g_proxy_call (proxy_prop, "GetAll", &error,
+			     G_TYPE_STRING, iface_name,
+			     G_TYPE_INVALID,
+			     dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &props,
+			     G_TYPE_INVALID);
+			    
+    if (!ret) 
+    {
+	g_warning ("Unable to get interface properties for : %s : %s", iface_name, error->message);
+	g_error_free (error);
+    }
+    
+    return props;
+}
+
+GValue xfpm_dbus_get_interface_property (DBusGProxy *proxy, const gchar *iface_name, const gchar *prop_name)
+{
+    gboolean ret;
+    GError *error = NULL;
+    GValue value = { 0, };
+
+    ret = dbus_g_proxy_call (proxy, "Get", &error,
+			     G_TYPE_STRING, iface_name,
+			     G_TYPE_STRING, prop_name,
+			     G_TYPE_INVALID,
+			     G_TYPE_VALUE, &value, G_TYPE_INVALID);
+							
+    if (!ret) 
+    {
+	g_warning ("Unable to get property %s on interface  %s : %s", prop_name, iface_name, error->message);
+	g_error_free (error);
+    }
+    
+    return value;
+}
diff --git a/libxfpm/xfpm-dbus.h b/libdbus/xfpm-dbus.h
similarity index 62%
rename from libxfpm/xfpm-dbus.h
rename to libdbus/xfpm-dbus.h
index 11ca372..0f005f7 100644
--- a/libxfpm/xfpm-dbus.h
+++ b/libdbus/xfpm-dbus.h
@@ -23,12 +23,22 @@
 
 #include <glib.h>
 #include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
 
-gboolean	xfpm_dbus_name_has_owner (DBusConnection *bus,
-					  const gchar *name);
-gboolean        xfpm_dbus_register_name  (DBusConnection *bus,
-					  const gchar *name);
-gboolean        xfpm_dbus_release_name   (DBusConnection *bus,
-					  const gchar *name);
+gboolean	xfpm_dbus_name_has_owner 	   (DBusConnection *bus,
+						    const gchar *name);
+					  
+gboolean        xfpm_dbus_register_name  	   (DBusConnection *bus,
+						    const gchar *name);
+					  
+gboolean        xfpm_dbus_release_name   	   (DBusConnection *bus,
+						    const gchar *name);
+
+GHashTable     *xfpm_dbus_get_interface_properties (DBusGProxy *proxy_prop,
+						    const gchar *iface_name);
+
+GValue 		xfpm_dbus_get_interface_property   (DBusGProxy *proxy, 
+						    const gchar *iface_name, 
+						    const gchar *prop_name);
 
 #endif /* __XFPM_DBUS_H */
diff --git a/libhal/Makefile.am b/libhal/Makefile.am
new file mode 100644
index 0000000..d8e76b3
--- /dev/null
+++ b/libhal/Makefile.am
@@ -0,0 +1,35 @@
+noinst_LTLIBRARIES = 			\
+	libxfpmhal.la
+
+libxfpmhal_la_SOURCES =			\
+	hal-manager.c			\
+	hal-manager.h			\
+	hal-device.c			\
+	hal-device.h			\
+	hal-marshal.c			\
+	hal-marshal.h
+
+libxfpmhal_la_CFLAGS =			\
+	$(GLIB_CFLAGS)			\
+	$(DBUS_GLIB_CFLAGS)
+
+if MAINTAINER_MODE
+
+BUILT_SOURCES =				\
+	hal-marshal.c			\
+	hal-marshal.h
+
+hal-marshal.c: hal-marshal.list
+	echo "#include \"hal-marshal.h\"" > $@ && \
+	glib-genmarshal $< --prefix=_hal_marshal --body >> $@
+
+hal-marshal.h: hal-marshal.list
+	glib-genmarshal $< --prefix=_hal_marshal --header > $@
+
+endif
+
+EXTRA_DIST =				\
+	hal-marshal.list
+
+DISTCLEANFILES =			\
+	$(BUILT_SOURCES)
\ No newline at end of file
diff --git a/libxfpm/hal-device.c b/libhal/hal-device.c
similarity index 100%
rename from libxfpm/hal-device.c
rename to libhal/hal-device.c
diff --git a/libxfpm/hal-device.h b/libhal/hal-device.h
similarity index 100%
rename from libxfpm/hal-device.h
rename to libhal/hal-device.h
diff --git a/libxfpm/hal-manager.c b/libhal/hal-manager.c
similarity index 100%
rename from libxfpm/hal-manager.c
rename to libhal/hal-manager.c
diff --git a/libxfpm/hal-manager.h b/libhal/hal-manager.h
similarity index 100%
rename from libxfpm/hal-manager.h
rename to libhal/hal-manager.h
diff --git a/libxfpm/hal-marshal.list b/libhal/hal-marshal.list
similarity index 100%
rename from libxfpm/hal-marshal.list
rename to libhal/hal-marshal.list
diff --git a/libxfpm/Makefile.am b/libxfpm/Makefile.am
deleted file mode 100644
index ecdc403..0000000
--- a/libxfpm/Makefile.am
+++ /dev/null
@@ -1,69 +0,0 @@
-noinst_LTLIBRARIES = 			\
-	libxfpmhal.la			\
-	libxfpmhalpower.la		\
-	libxfpmcommon.la
-
-libxfpmhal_la_SOURCES =			\
-	hal-manager.c			\
-	hal-manager.h			\
-	hal-device.c			\
-	hal-device.h			\
-	hal-marshal.c			\
-	hal-marshal.h
-
-libxfpmhal_la_CFLAGS =			\
-	$(GLIB_CFLAGS)			\
-	$(DBUS_GLIB_CFLAGS)
-
-libxfpmhalpower_la_SOURCES =		\
-	hal-power.c			\
-	hal-power.h			\
-	hal-battery.c			\
-	hal-battery.h			\
-	hal-enum.h
-
-libxfpmhalpower_la_CFLAGS  =		\
-	$(GLIB_CFLAGS)			\
-	$(DBUS_GLIB_CFLAGS)
-
-libxfpmcommon_la_SOURCES =      	\
-        xfpm-string.c           	\
-        xfpm-string.h           	\
-        xfpm-dbus.c             	\
-        xfpm-dbus.h             	\
-        xfpm-popups.c           	\
-        xfpm-popups.h           	\
-        xfpm-common.c           	\
-        xfpm-common.h			\
-	xfpm-notify.c			\
-	xfpm-notify.h			\
-	xfpm-icons.h
-
-libxfpmcommon_la_CFLAGS =       	\
-        $(GTK_CFLAGS)           	\
-        $(GLIB_CFLAGS)          	\
-        $(DBUS_CFLAGS)			\
-	$(LIBXFCE4UTIL_CFLAGS)		\
-	$(LIBXFCEGUI4_CFLAGS)		\
-	$(LIBNOTIFY_CFLAGS)
-
-if MAINTAINER_MODE
-
-BUILT_SOURCES =				\
-	hal-marshal.c			\
-	hal-marshal.h
-
-hal-marshal.c: hal-marshal.list
-	echo "#include \"hal-marshal.h\"" > $@ && \
-	glib-genmarshal $< --prefix=_hal_marshal --body >> $@
-
-hal-marshal.h: hal-marshal.list
-	glib-genmarshal $< --prefix=_hal_marshal --header > $@
-
-endif
-
-EXTRA_DIST =				\
-	hal-marshal.list
-
-DISTCLEANFILES =			\
-	$(BUILT_SOURCES)
\ No newline at end of file
diff --git a/libxfpm/hal-battery.c b/libxfpm/hal-battery.c
deleted file mode 100644
index 5a3734b..0000000
--- a/libxfpm/hal-battery.c
+++ /dev/null
@@ -1,554 +0,0 @@
-/*
- * * Copyright (C) 2008-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 <glib/gi18n.h>
-
-#include "hal-battery.h"
-#include "hal-manager.h"
-#include "hal-enum.h"
-
-static void hal_battery_finalize   (GObject *object);
-
-static void hal_battery_get_property(GObject *object,
-				    guint prop_id,
-				    GValue *value,
-				    GParamSpec *pspec);
-
-#define HAL_BATTERY_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), HAL_TYPE_BATTERY, HalBatteryPrivate))
-
-#define FREE_STR_PROP(str)            		    \
-    if ( str )                                      \
-        g_free (str);                               \
-    str = NULL;
-
-struct HalBatteryPrivate
-{
-    /* Properties read-only */
-    HalDeviceType type;
-    
-    gboolean  is_present;
-    gboolean  is_charging;
-    gboolean  is_discharging;
-    
-    guint     percentage;
-
-    guint32   current_charge;
-    guint32   last_full;
-    
-    guint32   reporting_design;
-    guint32   reporting_last_full;
-    
-    guint      time;
-    
-};
-
-enum
-{
-    PROP_0,
-    PROP_TYPE,
-    PROP_IS_PRESENT,
-    PROP_IS_CHARGING,
-    PROP_IS_DISCHARGING,
-    PROP_CURRENT_CHARGE,
-    PROP_PERCENTAGE,
-    PROP_REPORTING_DESIGN,
-    PROP_LAST_FULL,
-    PROP_REPORTING_LAST_FULL,
-    PROP_TIME,
-    PROP_TECHNOLOGY,
-    PROP_VENDOR,
-    PROP_MODEL,
-    PROP_UNIT
-};
-
-enum
-{
-    BATTERY_CHANGED,
-    LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(HalBattery, hal_battery, HAL_TYPE_DEVICE)
-
-static gchar *
-hal_battery_get_info_string (HalBattery *battery, const gchar *key)
-{
-    gchar *val = NULL;
-    
-    if ( hal_device_has_key (HAL_DEVICE (battery), key) )
-    {
-	val = hal_device_get_property_string (HAL_DEVICE(battery), key);
-    }
-    
-    return val;
-}
-
-static void
-hal_battery_class_init(HalBatteryClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    object_class->get_property = hal_battery_get_property;
-    object_class->finalize = hal_battery_finalize;
-
-    signals[BATTERY_CHANGED] =
-    	g_signal_new("battery-changed",
-		     HAL_TYPE_BATTERY,
-		     G_SIGNAL_RUN_LAST,
-		     G_STRUCT_OFFSET(HalBatteryClass, battery_changed),
-		     NULL, NULL,
-		     g_cclosure_marshal_VOID__VOID,
-		     G_TYPE_NONE, 0, G_TYPE_NONE);
-    
-    g_object_class_install_property(object_class,
-				    PROP_IS_PRESENT,
-				    g_param_spec_boolean("is-present",
-				    			 NULL, NULL,
-							 FALSE,
-							 G_PARAM_READABLE));
-
-    g_object_class_install_property(object_class,
-				    PROP_IS_CHARGING,
-				    g_param_spec_boolean("is-charging",
-							 NULL, NULL,
-							 FALSE,
-							 G_PARAM_READABLE));
-							 
-    g_object_class_install_property(object_class,
-				    PROP_IS_DISCHARGING,
-				    g_param_spec_boolean("is-discharging",
-							 NULL, NULL,
-							 FALSE,
-							 G_PARAM_READABLE));
-    g_object_class_install_property(object_class,
-				    PROP_CURRENT_CHARGE,
-				    g_param_spec_uint("current-charge",
-						      NULL, NULL,
-						      0,
-						      G_MAXUINT32,
-						      0,
-						      G_PARAM_READABLE));
-						      
-    g_object_class_install_property(object_class,
-				    PROP_LAST_FULL,
-				    g_param_spec_uint("last-full",
-						      NULL, NULL,
-						      0,
-						      G_MAXUINT32,
-						      0,
-						      G_PARAM_READABLE));
-						      
-     g_object_class_install_property(object_class,
-				    PROP_REPORTING_DESIGN,
-				    g_param_spec_uint("reporting-design",
-						      NULL, NULL,
-						      0,
-						      G_MAXUINT32,
-						      0,
-						      G_PARAM_READABLE));
-    g_object_class_install_property(object_class,
-				    PROP_REPORTING_LAST_FULL,
-				    g_param_spec_uint("reporting-last-full",
-						      NULL, NULL,
-						      0,
-						      G_MAXUINT32,
-						      0,
-						      G_PARAM_READABLE));
-    g_object_class_install_property(object_class,
-				    PROP_TIME,
-				    g_param_spec_uint("time",
-						      NULL, NULL,
-						      0,
-						      G_MAXINT,
-						      0,
-						      G_PARAM_READABLE));
-    g_object_class_install_property(object_class,
-				    PROP_TYPE,
-				    g_param_spec_uint("type",
-						      NULL, NULL,
-						      0,
-						      HAL_DEVICE_TYPE_UNKNOWN,
-						      HAL_DEVICE_TYPE_UNKNOWN,
-						      G_PARAM_READABLE));
-    g_object_class_install_property(object_class,
-				    PROP_PERCENTAGE,
-				    g_param_spec_uint("percentage",
-						      NULL, NULL,
-						      0,
-						      G_MAXINT,
-						      0,
-						      G_PARAM_READABLE));
-						      
-    g_object_class_install_property(object_class,
-				    PROP_TECHNOLOGY,
-				    g_param_spec_string("technology",
-							NULL, NULL,
-						        NULL,
-						        G_PARAM_READABLE));
-     g_object_class_install_property(object_class,
-				    PROP_VENDOR,
-				    g_param_spec_string("vendor",
-							NULL, NULL,
-						        NULL,
-						        G_PARAM_READABLE));
-    g_object_class_install_property(object_class,
-				    PROP_MODEL,
-				    g_param_spec_string("model",
-							NULL, NULL,
-						        NULL,
-						        G_PARAM_READABLE));
-    g_object_class_install_property(object_class,
-				    PROP_UNIT,
-				    g_param_spec_string("unit",
-							 NULL, NULL,
-							 NULL,
-							 G_PARAM_READABLE));
-							 
-    g_type_class_add_private(klass,sizeof(HalBatteryPrivate));
-}
-
-static void
-hal_battery_init (HalBattery *battery)
-{
-
-    battery->priv = HAL_BATTERY_GET_PRIVATE(battery);
-    
-    battery->priv->is_present      = FALSE;
-    battery->priv->is_charging     = FALSE;
-    battery->priv->is_discharging  = FALSE;
-
-    battery->priv->type            = HAL_DEVICE_TYPE_UNKNOWN;
-    
-    battery->priv->percentage      = 0;
-    battery->priv->current_charge  = 0;
-    battery->priv->last_full       = 0;
-    battery->priv->time            = 0;
-    battery->priv->reporting_design = 0;
-    battery->priv->reporting_last_full = 0;
-}
-
-static const gchar * G_GNUC_PURE
-_translate_technology (const gchar *tech)
-{
-    if ( !g_strcmp0 (tech, "lithium-ion") )
-    {
-	return _("Lithium ion");
-    }
-    else if ( !g_strcmp0 (tech, "lead-acid") )
-    {
-	return _("Lead acid");
-    }
-    else if ( !g_strcmp0 (tech, "lithium-polymer") )
-    {
-	return _("Lithium polymer");
-    }
-    else if ( !g_strcmp0 (tech, "nickel-metal-hydride") )
-    {
-	return _("Nickel metal hydride");
-    }
-    
-    return _("Unknown");
-}
-
-static const gchar * G_GNUC_PURE
-_translate_unit (const gchar *unit)
-{
-    if ( !g_strcmp0 (unit, "mWh") )
-    {
-	return _("mWh");
-    }
-    else if ( !g_strcmp0 (unit, "mAh") )
-    {
-	return _("mAh");
-    }
-    
-    return _("Unknown unit");
-}
-
-static void hal_battery_get_property(GObject *object,
-				    guint prop_id,
-				    GValue *value,
-				    GParamSpec *pspec)
-{
-    HalBattery *battery;
-    battery = HAL_BATTERY(object);
-
-    switch (prop_id)
-    {
-	case PROP_TYPE:
-		g_value_set_uint (value, battery->priv->type);
-		break;
-	case PROP_IS_PRESENT:
-		g_value_set_boolean (value, battery->priv->is_present);
-		break;
-	case PROP_IS_CHARGING:
-		g_value_set_boolean (value, battery->priv->is_charging);
-		break;
-	case PROP_IS_DISCHARGING:
-		g_value_set_boolean (value, battery->priv->is_discharging);
-		break;
-		
-	case PROP_UNIT:
-	{
-		gchar *unit = NULL;
-		gchar *val;
-		val = hal_battery_get_info_string (battery, "battery.reporting.unit");
-		if ( val )
-		{
-		    unit = g_strdup(_translate_unit (val));
-		    g_free (val);
-		}
-		g_value_set_string (value, unit);
-		break;
-	}
-	case PROP_TECHNOLOGY:
-	{
-		gchar *val;
-		gchar *technology = NULL;
-		val = hal_battery_get_info_string (battery, "battery.technology");
-		if ( val )
-		{
-		    technology = g_strdup (_translate_technology (val));
-		    g_free (val);
-		}
-		
-		g_value_set_string (value, technology);
-		g_free (technology);
-		break;
-	}
-	case PROP_VENDOR:
-	{
-		gchar *vendor = NULL;
-		vendor = hal_battery_get_info_string (battery, "battery.vendor");
-		g_value_set_string (value, vendor);
-		g_free (vendor);
-		break;
-	}
-	case PROP_MODEL:
-	{
-		gchar *model = NULL;
-		model = hal_battery_get_info_string (battery, "battery.model");
-		g_value_set_string (value, model);
-		g_free (model);
-		break;
-	}
-	case PROP_PERCENTAGE:
-		g_value_set_uint (value, battery->priv->percentage);
-		break;
-	case PROP_CURRENT_CHARGE:
-		g_value_set_uint (value, battery->priv->current_charge);
-		break;
-	case PROP_LAST_FULL:
-		g_value_set_uint (value, battery->priv->last_full);
-		break;
-	case PROP_REPORTING_DESIGN:
-		g_value_set_uint (value, battery->priv->reporting_design);
-		break;
-	case PROP_REPORTING_LAST_FULL:
-		g_value_set_uint (value, battery->priv->reporting_last_full);
-		break;	
-	case PROP_TIME:
-		g_value_set_uint (value, battery->priv->time);
-		break;
-	default:
-            G_OBJECT_WARN_INVALID_PROPERTY_ID(object,prop_id,pspec);
-            break;
-    }
-}
-
-static void
-hal_battery_finalize(GObject *object)
-{
-    HalBattery *battery;
-
-    battery = HAL_BATTERY(object);
-    
-    G_OBJECT_CLASS(hal_battery_parent_class)->finalize(object);
-}
-
-static HalDeviceType G_GNUC_PURE
-hal_battery_type_enum_from_string(const gchar *string)
-{
-    if ( !g_strcmp0 (string, "primary") )
-    {
-	return HAL_DEVICE_TYPE_PRIMARY;
-    }
-    else if ( !g_strcmp0 (string, "ups") )
-    {
-	return HAL_DEVICE_TYPE_UPS;
-    }
-    else if ( !g_strcmp0 (string, "mouse") )
-    {
-	return HAL_DEVICE_TYPE_MOUSE;
-    }
-    else if ( !g_strcmp0 (string, "keyboard") )
-    {
-	return HAL_DEVICE_TYPE_KEYBOARD;
-    }
-    else if ( !g_strcmp0 (string, "camera") )
-    {
-	return HAL_DEVICE_TYPE_CAMERA;
-    }
-    else if ( !g_strcmp0 (string, "keyboard_mouse") )
-    {
-	return HAL_DEVICE_TYPE_KEYBOARD_MOUSE;
-    }
-    
-    return HAL_DEVICE_TYPE_UNKNOWN;
-}
-
-static HalDeviceType
-hal_battery_get_device_type (HalBattery *battery)
-{
-    const gchar *udi;
-    gchar *type = NULL;
-    
-    HalDeviceType type_enum = HAL_DEVICE_TYPE_UNKNOWN;
-    
-    udi = hal_device_get_udi (HAL_DEVICE(battery));
-    
-    g_return_val_if_fail (udi != NULL, HAL_DEVICE_TYPE_UNKNOWN);
-    
-    type = hal_device_get_property_string (HAL_DEVICE(battery), "battery.type");
-    
-    if ( type )
-    {
-	type_enum  = hal_battery_type_enum_from_string(type);
-	g_free(type);
-    }
-    return type_enum;
-}
-
-static guint G_GNUC_CONST
-_get_battery_percentage (guint32 last_full, guint32 current)
-{
-    guint val = 100;
-    float f;
-    
-    if ( G_UNLIKELY (last_full <= current) ) return val;
-    
-    /*
-     * Special case when we get 0 as last full
-     * this happens for me once i had the battery
-     * totally empty on my aspire one.
-     */
-    if ( G_UNLIKELY (last_full == 0 ) )
-	return 0;
-	
-    f = (float)current/last_full *100;
-	
-	val = (guint)f;
-	
-    return val;   
-}
-
-static void
-hal_battery_refresh_all (HalBattery *battery)
-{
-    
-    battery->priv->is_present = 
-    	hal_device_get_property_bool(HAL_DEVICE(battery), "battery.present");
-	
-    battery->priv->is_charging = 
-    	hal_device_get_property_bool(HAL_DEVICE(battery), "battery.rechargeable.is_charging");
-    
-    battery->priv->is_discharging = 
-    	hal_device_get_property_bool(HAL_DEVICE(battery), "battery.rechargeable.is_discharging");
-    
-    battery->priv->current_charge = 
-    	hal_device_get_property_int(HAL_DEVICE(battery), "battery.charge_level.current");
-	
-    battery->priv->last_full = 
-    	hal_device_get_property_int(HAL_DEVICE(battery), "battery.charge_level.last_full");
-    
-    if ( hal_device_has_key (HAL_DEVICE(battery), "battery.remaining_time") )
-    	battery->priv->time = 
-    		hal_device_get_property_int(HAL_DEVICE(battery), "battery.remaining_time");
-    else
-    	battery->priv->time = 0;
-    
-    if ( hal_device_has_key(HAL_DEVICE(battery), "battery.charge_level.percentage") )
-     	battery->priv->percentage = 
-    		hal_device_get_property_int(HAL_DEVICE(battery), "battery.charge_level.percentage");
-    else battery->priv->percentage = _get_battery_percentage(battery->priv->last_full, battery->priv->current_charge);
-    
-    if ( hal_device_has_key(HAL_DEVICE(battery), "battery.reporting.last_full") )
-     	battery->priv->reporting_last_full = 
-    		hal_device_get_property_int(HAL_DEVICE(battery), "battery.reporting.last_full");
-
-    battery->priv->reporting_design = hal_device_get_property_int (HAL_DEVICE(battery), 
-								   "battery.reporting.design");
-}
-
-static void
-hal_battery_battery_changed_cb (HalBattery *battery, const gchar *key)
-{
-    if ( !g_strcmp0 (key, "battery.present") ||
-    	 !g_strcmp0 (key, "battery.rechargeable.is_charging") ||
-	 !g_strcmp0 (key, "battery.rechargeable.is_discharging") ||
-	 !g_strcmp0 (key, "battery.charge_level.current")    ||
-	 !g_strcmp0 (key, "battery.remaining_time") ||
-	 !g_strcmp0 (key, "battery.charge_level.percentage") )
-    {
-	hal_battery_refresh_all (battery);
-    	g_signal_emit (G_OBJECT (battery), signals[BATTERY_CHANGED], 0);
-    }
-}
-
-static void
-hal_battery_property_modified_cb(HalBattery *battery, 
-			         const gchar *udi,
-				 const gchar *key, 
-			         gboolean is_removed,
-			         gboolean is_added,
-				 gpointer data)
-{
-    hal_battery_battery_changed_cb (battery, key);
-}
-
-HalBattery *
-hal_battery_new (const gchar *udi)
-{
-    HalBattery *battery = NULL;
-    
-    battery = g_object_new (HAL_TYPE_BATTERY, NULL);
-    hal_device_set_udi (HAL_DEVICE(battery), udi);
-    
-    battery->priv->type = hal_battery_get_device_type (battery);
-   
-    hal_battery_refresh_all (battery);
-	
-    hal_device_watch (HAL_DEVICE(battery));
-    
-    g_signal_connect (G_OBJECT(battery), "device-changed",
-		      G_CALLBACK(hal_battery_property_modified_cb), battery);
-    return battery;
-}
diff --git a/libxfpm/hal-enum.h b/libxfpm/hal-enum.h
deleted file mode 100644
index ddb8b20..0000000
--- a/libxfpm/hal-enum.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * * Copyright (C) 2008-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 __HAL_ENUM_H
-#define __HAL_ENUM_H
-
-typedef enum
-{
-    HAL_DEVICE_TYPE_PRIMARY,
-    HAL_DEVICE_TYPE_UPS,
-    HAL_DEVICE_TYPE_MOUSE,
-    HAL_DEVICE_TYPE_KEYBOARD,
-    HAL_DEVICE_TYPE_KEYBOARD_MOUSE,
-    HAL_DEVICE_TYPE_CAMERA,
-    HAL_DEVICE_TYPE_PDA,
-    HAL_DEVICE_TYPE_UNKNOWN
-    
-} HalDeviceType;
-
-#endif /*__HAL_ENUM_H */
diff --git a/libxfpm/hal-power.c b/libxfpm/hal-power.c
deleted file mode 100644
index d561694..0000000
--- a/libxfpm/hal-power.c
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * * Copyright (C) 2008-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 <dbus/dbus-glib.h>
-
-#include "hal-manager.h"
-#include "hal-power.h"
-
-static void hal_power_finalize   (GObject *object);
-
-#define HAL_POWER_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), HAL_TYPE_POWER, HalPowerPrivate))
-
-struct HalPowerPrivate
-{
-    GHashTable *hash  	;
-    HalManager *manager ;
-    
-    gulong      sig_1;
-    gulong      sig_2;
-};
-
-enum
-{
-    BATTERY_ADDED,
-    BATTERY_REMOVED,
-    LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(HalPower, hal_power, G_TYPE_OBJECT)
-
-/*
- * Sanity check of the keys present of a battery device
- */
-static gboolean
-hal_power_check_battery (HalPower *power, HalDevice *device)
-{
-    if ( hal_device_has_key(device, "battery.present") &&
-	 hal_device_has_key(device, "battery.rechargeable.is_charging") &&
-         hal_device_has_key(device, "battery.rechargeable.is_discharging") &&
-         hal_device_has_key(device, "battery.charge_level.current") &&
-	 hal_device_has_key(device, "battery.charge_level.last_full") )
-		 return TRUE;
-    
-    return FALSE;
-}
-
-/*
- * Check if the device added is actually a new non-moniotred device
- * Hald duplicates udi when running udevadm trigger
- */
-static gboolean
-hal_power_is_battery_new (HalPower *power, HalDevice *device)
-{
-    GList *list = NULL;
-    gboolean new_device = TRUE;
-    guint is_new = 0;
-    HalDevice *hash_device;
-    guint i;
-    
-    list = g_hash_table_get_values (power->priv->hash);
-    if ( !list )
-	return new_device;
-	
-    if ( g_list_length(list) == 0 )
-	return new_device;
-	
-    for ( i = 0; i < g_list_length(list); i++ )
-    {
-	hash_device = (HalDevice *) g_list_nth_data (list, i);
-	
-	if ( hal_device_get_property_int (hash_device, "battery.charge_level.current") !=
-	     hal_device_get_property_int (device, "battery.charge_level.current") && 
-	     hal_device_get_property_int (hash_device, "battery.charge_level.last_full") !=
-	     hal_device_get_property_int (device, "battery.charge_level.last_full") )
-	    is_new++;
-    }
-
-    /* Device doesn't match to any one in the hash*/
-    if ( is_new == g_list_length (list) )
-	new_device = TRUE;
-    else
-	new_device = FALSE;
-	
-    g_list_free (list);
-    return new_device;
-}
-
-static HalBattery *
-hal_power_add_battery (HalPower *power, const gchar *udi)
-{
-    HalBattery *battery;
-    battery  = hal_battery_new (udi);
-    
-    g_hash_table_insert (power->priv->hash, g_strdup(udi), battery );
-    
-    return battery ;
-}
-
-static void
-hal_power_remove_battery (HalPower *power, HalBattery *battery, const gchar *udi)
-{
-    g_signal_emit (power, signals[BATTERY_REMOVED], 0, battery);
-    
-    if (!g_hash_table_remove(power->priv->hash, udi))
-    	g_warning ("Unable to removed object from hash\n");
-}
-
-static HalBattery *
-hal_power_get_battery_from_hash (HalPower *power, const gchar *udi)
-{
-    HalBattery *battery = NULL;
-    
-    battery = g_hash_table_lookup(power->priv->hash, udi);
-    
-    return battery;
-}
-
-static void
-hal_power_device_added_cb (HalManager *manager, const gchar *udi, HalPower *power)
-{
-    HalDevice *device = hal_device_new ();
-    HalBattery *battery;
-    hal_device_set_udi (device, udi);
-    
-    if ( hal_device_has_capability (device, "battery") )
-    {
-	if ( !hal_power_check_battery (power, device) )
-	    goto out;
-	    
-	if ( !hal_power_is_battery_new (power, device) )
-	    goto out;
-	    
-	battery = hal_power_add_battery (power, udi);
-        g_signal_emit (G_OBJECT(power), signals[BATTERY_ADDED], 0, battery);
-    }
-out:
-    g_object_unref (device);
-}
-
-static void
-hal_power_device_removed_cb (HalManager *manager, const gchar *udi, HalPower *power)
-{
-    HalBattery *battery  = hal_power_get_battery_from_hash (power, udi);
-    
-    if (battery)
-    {
-	hal_power_remove_battery (power, battery , udi);
-    }
-}
-
-static void
-hal_power_class_init(HalPowerClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    signals[BATTERY_ADDED] =
-    	g_signal_new("battery-added",
-		     HAL_TYPE_POWER,
-		     G_SIGNAL_RUN_LAST,
-		     G_STRUCT_OFFSET(HalPowerClass, battery_added),
-		     NULL, NULL,
-		     g_cclosure_marshal_VOID__POINTER,
-		     G_TYPE_NONE, 1, G_TYPE_POINTER);
-		     
-    signals[BATTERY_REMOVED] =
-    	g_signal_new("battery-removed",
-		     HAL_TYPE_POWER,
-		     G_SIGNAL_RUN_LAST,
-		     G_STRUCT_OFFSET(HalPowerClass, battery_removed),
-		     NULL, NULL,
-		     g_cclosure_marshal_VOID__POINTER,
-		     G_TYPE_NONE, 1, G_TYPE_POINTER);
-		     
-    object_class->finalize = hal_power_finalize;
-
-    g_type_class_add_private(klass,sizeof(HalPowerPrivate));
-}
-
-static void
-hal_power_get_batteries_internal (HalPower *power)
-{
-    HalDevice *device = hal_device_new ();
-    gchar **batteries = NULL;
-    gint i;
-    
-    batteries = hal_manager_find_device_by_capability (power->priv->manager, "battery");
-    
-    if ( !batteries ) 
-    	goto out;
-    
-    for ( i = 0; batteries[i]; i++ )
-    {
-	hal_device_set_udi (device, batteries[i]);
-	
-	if (!hal_power_check_battery(power, device))
-	    continue;
-		
-	if ( !hal_power_is_battery_new (power, device) )
-	    continue;
-	    
-    	hal_power_add_battery (power, batteries[i]);
-    }
-    hal_manager_free_string_array (batteries);
-
-out:
-    g_object_unref (device);
-}
-
-static gboolean
-hal_power_is_power_save_set (void)
-{
-    HalDevice *device;
-    gboolean   val;
-    
-    device = hal_device_new ();
-
-    hal_device_set_udi (device, "/org/freedesktop/Hal/devices/computer");
-    
-    val = hal_device_get_property_bool (device, "power_management.is_powersave_set");
-    
-    g_object_unref (device);
-    
-    return val;
-}
-
-static gboolean 
-hal_power_set_power_save_internal (HalPower *power, gboolean set)
-{
-    DBusGConnection *bus;
-    DBusGProxy      *proxy;
-    GError          *error = NULL;
-    gint             ret = 0;
-    
-    if ( hal_power_is_power_save_set () == set )
-	return TRUE;
-    
-    bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
-    
-    proxy = dbus_g_proxy_new_for_name (bus, 
-				       "org.freedesktop.Hal",
-				       "/org/freedesktop/Hal/devices/computer",
-				       "org.freedesktop.Hal.Device.SystemPowerManagement");
-				       
-    if ( !proxy )
-    {
-	g_warning ("Unable to get proxy for /org/freedesktop/Hal/devices/computer");
-	dbus_g_connection_unref (bus);
-	return FALSE;
-    }
-    
-    dbus_g_proxy_call (proxy, "SetPowerSave", &error,
-		       G_TYPE_BOOLEAN, set,
-		       G_TYPE_INVALID,
-		       G_TYPE_INT, &ret,
-		       G_TYPE_INVALID);
-    
-    dbus_g_connection_unref (bus);
-    g_object_unref (proxy);
-    
-    if ( error )
-    {
-	g_warning ("%s: ", error->message);
-	g_error_free (error);
-	return FALSE;
-    }
-    return ret == 0 ? TRUE : FALSE;
-}
-
-static void
-hal_power_init(HalPower *power)
-{
-    power->priv = HAL_POWER_GET_PRIVATE(power);
-    
-    power->priv->manager = hal_manager_new ();
-    power->priv->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
-    
-    power->priv->sig_1 = g_signal_connect (power->priv->manager, "device-added", 
-					   G_CALLBACK(hal_power_device_added_cb), power);
-    
-    power->priv->sig_2 = g_signal_connect (power->priv->manager, "device-removed",
-					    G_CALLBACK(hal_power_device_removed_cb), power);
-   
-    hal_power_get_batteries_internal (power);
-}
-
-static void
-hal_power_finalize(GObject *object)
-{
-    HalPower *power;
-    
-    power = HAL_POWER(object);
-    
-    if ( g_signal_handler_is_connected (power->priv->manager, power->priv->sig_1 ) )
-	g_signal_handler_disconnect (power->priv->manager, power->priv->sig_1 );
-	
-    if ( g_signal_handler_is_connected (power->priv->manager, power->priv->sig_2 ) )
-	g_signal_handler_disconnect (power->priv->manager, power->priv->sig_2 );
-    
-    g_hash_table_destroy (power->priv->hash);
-    
-    g_object_unref (power->priv->manager);
-	
-    G_OBJECT_CLASS(hal_power_parent_class)->finalize(object);
-}
-
-HalPower *
-hal_power_new(void)
-{
-    HalPower *power = NULL;
-    power = g_object_new (HAL_TYPE_POWER,NULL);
-    return power;
-}
-
-/*
- * Return an array of power devices, the array should be freed by the caller
- */
-GPtrArray *
-hal_power_get_batteries (HalPower *power)
-{
-    guint i;
-    GPtrArray *array;
-    HalBattery *battery;
-    GList *list = NULL;
-    
-    g_return_val_if_fail (HAL_IS_POWER (power), NULL);
-    
-    array = g_ptr_array_new ();
-   
-    list = g_hash_table_get_values (power->priv->hash);
-   
-    if (!list)
-   	goto out;
-	
-    for ( i=0; i < g_list_length (list); i++)
-    {
-       battery = g_list_nth_data (list, i);
-       g_ptr_array_add (array, battery);
-    }
-   
-    g_list_free (list);
-out:
-   return array;
-}
-
-gboolean hal_power_set_power_save  (HalPower *power)
-{
-    g_return_val_if_fail (HAL_IS_POWER (power), FALSE);
-
-    return hal_power_set_power_save_internal (power, TRUE);
-}
-
-gboolean hal_power_unset_power_save (HalPower *power)
-{
-    g_return_val_if_fail (HAL_IS_POWER (power), FALSE);
-
-    return hal_power_set_power_save_internal (power, FALSE);
-}
diff --git a/libxfpm/hal-power.h b/libxfpm/hal-power.h
deleted file mode 100644
index a5f3590..0000000
--- a/libxfpm/hal-power.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * * Copyright (C) 2008-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 __HAL_POWER_H
-#define __HAL_POWER_H
-
-#include <glib-object.h>
-
-#include "hal-device.h"
-#include "hal-battery.h"
-
-G_BEGIN_DECLS
-
-#define HAL_TYPE_POWER        (hal_power_get_type () )
-#define HAL_POWER(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), HAL_TYPE_POWER, HalPower))
-#define HAL_IS_POWER(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), HAL_TYPE_POWER))
-
-typedef struct HalPowerPrivate HalPowerPrivate;
-
-typedef struct
-{
-    GObject		parent;
-    HalPowerPrivate    *priv;
-    
-} HalPower;
-
-typedef struct
-{
-    GObjectClass 	parent_class;
-    
-    void 		(*battery_added)	  (HalPower *power,
-						   const HalBattery *battery);
-					   
-    void        	(*battery_removed)        (HalPower *power,
-						   const HalBattery *battery);
-					   
-} HalPowerClass;
-
-GType        		hal_power_get_type        (void) G_GNUC_CONST;
-HalPower       	       *hal_power_new             (void);
-
-GPtrArray      	       *hal_power_get_batteries   (HalPower *power);
-
-gboolean                hal_power_set_power_save  (HalPower *power);
-
-gboolean                hal_power_unset_power_save(HalPower *power);
-
-G_END_DECLS
-
-#endif /* __HAL_POWER_H */
diff --git a/libxfpm/xfpm-dbus.c b/libxfpm/xfpm-dbus.c
deleted file mode 100644
index 1f0e623..0000000
--- a/libxfpm/xfpm-dbus.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * * Copyright (C) 2008-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
- */
-
-#include "xfpm-dbus.h"
-
-gboolean
-xfpm_dbus_name_has_owner (DBusConnection *connection, const gchar *name)
-{
-    DBusError error;
-    gboolean ret;
-    
-    dbus_error_init (&error);
-    
-    ret = dbus_bus_name_has_owner(connection, name, &error);
-    
-    if ( dbus_error_is_set(&error) )
-    {
-        g_warning("Failed to get name owner: %s\n",error.message);
-        dbus_error_free(&error);
-        return FALSE;
-    }
-    
-    return ret;
-}
-
-gboolean xfpm_dbus_register_name(DBusConnection *connection, const gchar *name)
-{
-    DBusError error;
-    int ret;
-    
-    dbus_error_init(&error);
-    
-    ret =
-	dbus_bus_request_name(connection,
-			      name,
-			      DBUS_NAME_FLAG_DO_NOT_QUEUE,
-			      &error);
-	
-    if ( dbus_error_is_set(&error) )
-    {
-	g_warning("Error: %s\n",error.message);
-	dbus_error_free(&error);
-	return FALSE;
-    }
-    
-    if ( ret == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER )
-    {
-	return TRUE;
-    }
-    
-    return FALSE;
-}
-
-gboolean xfpm_dbus_release_name(DBusConnection *connection, const gchar *name)
-{
-    DBusError error;
-    int ret;
-    
-    dbus_error_init(&error);
-    
-    ret =
-	dbus_bus_release_name(connection,
-			      name,
-			      &error);
-    
-    if ( dbus_error_is_set(&error) )
-    {
-        g_warning("Error: %s\n",error.message);
-        dbus_error_free(&error);
-        return FALSE;
-    }
-    
-    if ( ret == -1 ) return FALSE;
-    
-    return TRUE;
-}
diff --git a/libxfpm/xfpm-popups.c b/libxfpm/xfpm-popups.c
deleted file mode 100644
index d05463e..0000000
--- a/libxfpm/xfpm-popups.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * * Copyright (C) 2008-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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <gtk/gtk.h>
-#include <glib.h>
-
-#include "xfpm-popups.h"
-
-static GtkWidget *
-xfpm_message_dialog (const gchar *title, const gchar *message, GtkMessageType message_type)
-{
-    GtkWidget *dialog;
-    
-    dialog = gtk_message_dialog_new_with_markup(NULL,
-                                                GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                message_type,
-                                                GTK_BUTTONS_CLOSE,
-                                                "<span size='larger'><b>%s</b></span>",
-                                                title);
-                                                
-    gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog), "%s", message);
-    
-    return dialog;
-}
-
-void xfpm_popup_message(const gchar *title,
-                        const gchar *message,
-                        GtkMessageType message_type)
-{
-    
-    GtkWidget *dialog;
-    
-    dialog = xfpm_message_dialog (title, message, message_type);
-    
-    g_signal_connect(dialog,
-                     "response",
-                     G_CALLBACK(gtk_widget_destroy),
-                     NULL);
-                     
-    gtk_widget_show(dialog);                         
-}                 
-
-void xfpm_info (const gchar *title, const gchar *message )
-{
-    GtkWidget *dialog;
-    
-    dialog = xfpm_message_dialog (title, message, GTK_MESSAGE_INFO);
-    
-    gtk_dialog_run (GTK_DIALOG(dialog));
-    gtk_widget_destroy (dialog);
-}
-
-void    xfpm_error              (const gchar *title,
-				 const gchar *message)
-{
-    GtkWidget *dialog;
-    
-    dialog = xfpm_message_dialog (title, message, GTK_MESSAGE_ERROR);
-    
-    gtk_dialog_run (GTK_DIALOG(dialog));
-    gtk_widget_destroy (dialog);
-}
diff --git a/libxfpm/xfpm-popups.h b/libxfpm/xfpm-popups.h
deleted file mode 100644
index 6ab95db..0000000
--- a/libxfpm/xfpm-popups.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * * Copyright (C) 2008-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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __XFPM_POPUPS_H
-#define __XFPM_POPUPS_H
-
-void 	xfpm_popup_message	(const gchar *title,
-				 const gchar *message,
-				 GtkMessageType message_type);
-
-
-void 	xfpm_info 		(const gchar *title, 
-				 const gchar *message);
-				 
-void    xfpm_error              (const gchar *title,
-				 const gchar *message);
-
-#endif /* __XFPM_POPUPS_H */
diff --git a/libxfpm/xfpm-string.c b/libxfpm/xfpm-string.c
deleted file mode 100644
index 5919251..0000000
--- a/libxfpm/xfpm-string.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * * Copyright (C) 2008-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 <glib.h>
-
-#include "xfpm-string.h"
-
-gboolean xfpm_strequal (const gchar *str1, const gchar *str2)
-{
-    if ( g_strcmp0 (str1, str2) == 0 ) return TRUE;
-    return FALSE;
-}
-
-const gchar *xfpm_bool_to_string (gboolean value)
-{
-    if ( value == TRUE ) return "TRUE";
-    else 		 return "FALSE";
-}
-
-gboolean xfpm_string_to_bool (const gchar *string)
-{
-    if ( xfpm_strequal(string, "TRUE") ) return TRUE;
-    else if ( xfpm_strequal(string, "FALSE")) return FALSE;
-    
-    return FALSE;
-}
diff --git a/libxfpm/xfpm-string.h b/libxfpm/xfpm-string.h
deleted file mode 100644
index 2a7bd20..0000000
--- a/libxfpm/xfpm-string.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * * Copyright (C) 2008-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_STRING_H
-#define __XFPM_STRING_H
-
-#include <glib.h>
-#include <string.h>
-
-gboolean        xfpm_strequal		(const gchar *str1,
-					 const gchar *str2);
-
-const gchar    *xfpm_bool_to_string     (gboolean value) G_GNUC_PURE;
-
-gboolean        xfpm_string_to_bool     (const gchar *string) G_GNUC_PURE;
-
-
-#endif /* XFPM_STRING_H */
diff --git a/panel-plugins/brightness/Makefile.am b/panel-plugins/brightness/Makefile.am
index 5e78044..9d5c9ee 100644
--- a/panel-plugins/brightness/Makefile.am
+++ b/panel-plugins/brightness/Makefile.am
@@ -4,9 +4,7 @@ plugin_PROGRAMS = xfce4-brightness-plugin
 xfce4_brightness_plugin_SOURCES =		\
 	brightness-plugin.c			\
 	brightness-button.c			\
-	brightness-button.h			\
-	brightness-proxy.c			\
-	brightness-proxy.h
+	brightness-button.h
 
 xfce4_brightness_plugin_CFLAGS =		\
 	-I$(top_srcdir)				\
@@ -15,18 +13,25 @@ xfce4_brightness_plugin_CFLAGS =		\
 	$(LIBXFCE4PANEL_CFLAGS)       		\
 	$(LIBXFCE4UTIL_CFLAGS)        		\
 	$(GTK_CFLAGS)			      	\
-	$(GLIB_CFLAGS)				\
-	$(DBUS_GLIB_CFLAGS)
+	$(GLIB_CFLAGS)
 
 xfce4_brightness_plugin_LDADD =			\
-	$(top_builddir)/libxfpm/libxfpmhal.la	\
-	$(top_builddir)/libxfpm/libxfpmcommon.la\
+	$(top_builddir)/common/libxfpmcommon.la \
 	$(LIBXFCE4PANEL_LIBS)   		\
 	$(LIBXFCE4UTIL_LIBS)			\
 	$(GTK_LIBS)   				\
-	$(GLIB_LIBS)				\
+	$(GLIB_LIBS)
+
+if ENABLE_HAL
+
+xfce4_brightness_plugin_CFLAGS += 		\
+	$(DBUS_GLIB_CFLAGS)
+
+xfce4_brightness_plugin_LDADD += 		\
 	$(DBUS_GLIB_LIBS)
 
+endif
+
 #
 # Desktop file
 #
diff --git a/panel-plugins/brightness/brightness-button.c b/panel-plugins/brightness/brightness-button.c
index cf9577f..833a981 100644
--- a/panel-plugins/brightness/brightness-button.c
+++ b/panel-plugins/brightness/brightness-button.c
@@ -30,11 +30,11 @@
 #include <libxfce4util/libxfce4util.h>
 #include <libxfcegui4/libxfcegui4.h>
 
-#include "libxfpm/xfpm-common.h"
-#include "libxfpm/xfpm-icons.h"
+#include "common/xfpm-common.h"
+#include "common/xfpm-icons.h"
+#include "common/xfpm-brightness.h"
 
 #include "brightness-button.h"
-#include "brightness-proxy.h"
 
 static void brightness_button_finalize   (GObject *object);
 
@@ -44,7 +44,8 @@ static void brightness_button_finalize   (GObject *object);
 struct BrightnessButtonPrivate
 {
     XfcePanelPlugin *plugin;
-    BrightnessProxy *brightness;
+    
+    XfpmBrightness  *brightness;
     
     GtkWidget       *popup;
     GtkWidget       *range;
@@ -173,7 +174,7 @@ brightness_button_set_tooltip (BrightnessButton *button)
 {
     gboolean has_hw;
     
-    has_hw = brightness_proxy_has_hw (button->priv->brightness);
+    has_hw = xfpm_brightness_has_hw (button->priv->brightness);
     
     if ( has_hw )
 	gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Control your LCD brightness"));
@@ -194,7 +195,7 @@ brightness_button_popup_win (GtkWidget *widget, GdkEvent *ev, guint32 ev_time)
     
     button = BRIGHTNESS_BUTTON (widget);
     
-    has_hw = brightness_proxy_has_hw (button->priv->brightness);
+    has_hw = xfpm_brightness_has_hw (button->priv->brightness);
     
     if ( !has_hw ) 
 	return FALSE;
@@ -303,7 +304,7 @@ brightness_button_popup_win (GtkWidget *widget, GdkEvent *ev, guint32 ev_time)
    
     gtk_window_move (GTK_WINDOW(button->priv->popup), x, y);
     TRACE("Displaying window on x=%d y=%d", x, y);
-    current_level = brightness_proxy_get_level (button->priv->brightness);
+    current_level = xfpm_brightness_get_level (button->priv->brightness);
     
     gtk_range_set_value (GTK_RANGE(button->priv->range), current_level);
     button->priv->popup_open = TRUE;
@@ -321,7 +322,7 @@ minus_clicked (GtkWidget *widget, BrightnessButton *button)
 {
     guint level, max_level;
     
-    max_level = brightness_proxy_get_max_level (button->priv->brightness);
+    max_level = xfpm_brightness_get_max_level (button->priv->brightness);
     level = (guint ) gtk_range_get_value (GTK_RANGE (button->priv->range));
     
     if ( level != 0 )
@@ -333,7 +334,7 @@ plus_clicked (GtkWidget *widget, BrightnessButton *button)
 {
     guint level, max_level;
     
-    max_level = brightness_proxy_get_max_level (button->priv->brightness);
+    max_level = xfpm_brightness_get_max_level (button->priv->brightness);
     level = (guint ) gtk_range_get_value (GTK_RANGE (button->priv->range));
     
     if ( level != max_level )
@@ -347,11 +348,11 @@ range_value_changed (GtkWidget *widget, BrightnessButton *button)
     
     range_level = (guint) gtk_range_get_value (GTK_RANGE (button->priv->range));
     
-    hw_level = brightness_proxy_get_level (button->priv->brightness);
+    hw_level = xfpm_brightness_get_level (button->priv->brightness);
     
     if ( hw_level != range_level )
     {
-	brightness_proxy_set_level (button->priv->brightness, range_level);
+	xfpm_brightness_set_level (button->priv->brightness, range_level);
     }
 }
 
@@ -363,11 +364,12 @@ brightness_button_create_popup (BrightnessButton *button)
     guint max_level;
     gboolean has_hw;
     
-    has_hw = brightness_proxy_has_hw (button->priv->brightness);
+    has_hw = xfpm_brightness_has_hw (button->priv->brightness);
+    
     if ( !has_hw )
 	return;
 	
-    max_level = brightness_proxy_get_max_level (button->priv->brightness);
+    max_level = xfpm_brightness_get_max_level (button->priv->brightness);
      
     button->priv->popup = gtk_window_new (GTK_WINDOW_POPUP);
     gtk_window_set_decorated (GTK_WINDOW(button->priv->popup), FALSE);
@@ -431,8 +433,8 @@ brightness_button_up (BrightnessButton *button)
     guint level;
     guint max_level;
     
-    level = brightness_proxy_get_level (button->priv->brightness);
-    max_level = brightness_proxy_get_max_level (button->priv->brightness);
+    level = xfpm_brightness_get_level (button->priv->brightness);
+    max_level = xfpm_brightness_get_max_level (button->priv->brightness);
     
     if ( level != max_level )
     {
@@ -444,7 +446,7 @@ static void
 brightness_button_down (BrightnessButton *button)
 {
     guint level;
-    level = brightness_proxy_get_level (button->priv->brightness);
+    level = xfpm_brightness_get_level (button->priv->brightness);
     
     if ( level != 0 )
     {
@@ -460,7 +462,7 @@ brightness_button_scroll_event (GtkWidget *widget, GdkEventScroll *ev)
     
     button = BRIGHTNESS_BUTTON (widget);
     
-    hw_found = brightness_proxy_has_hw (button->priv->brightness);
+    hw_found = xfpm_brightness_has_hw (button->priv->brightness);
     
     if ( !hw_found )
 	return FALSE;
@@ -507,7 +509,8 @@ brightness_button_init (BrightnessButton *button)
 {
     button->priv = BRIGHTNESS_BUTTON_GET_PRIVATE (button);
     
-    button->priv->brightness = brightness_proxy_new ();
+    button->priv->brightness = xfpm_brightness_new ();
+    xfpm_brightness_setup (button->priv->brightness);
     
     gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
 }
@@ -556,7 +559,7 @@ brightness_button_set_icon (BrightnessButton *button, gint width)
     GdkPixbuf *pixbuf;
     const gchar *icon_name;
     
-    hw_found = brightness_proxy_has_hw (button->priv->brightness);
+    hw_found = xfpm_brightness_has_hw (button->priv->brightness);
     
     icon_name = hw_found ? XFPM_DISPLAY_BRIGHTNESS_ICON : XFPM_DISPLAY_BRIGHTNESS_INVALID_ICON;
     
@@ -586,7 +589,6 @@ reload_activated (GtkWidget *widget, BrightnessButton *button)
 {
     gint size;
     
-    brightness_proxy_reload (button->priv->brightness);
     destroy_popup (button);
     brightness_button_create_popup (button);
     brightness_button_set_tooltip (button);
diff --git a/panel-plugins/brightness/brightness-plugin.c b/panel-plugins/brightness/brightness-plugin.c
index e71afda..d0ffccd 100644
--- a/panel-plugins/brightness/brightness-plugin.c
+++ b/panel-plugins/brightness/brightness-plugin.c
@@ -31,8 +31,6 @@
 
 #include <libxfce4panel/xfce-panel-plugin.h>
 
-#include <dbus/dbus-glib.h>
-
 #include "brightness-button.h"
 
 static void
diff --git a/panel-plugins/brightness/brightness-proxy.c b/panel-plugins/brightness/brightness-proxy.c
deleted file mode 100644
index 3bc4993..0000000
--- a/panel-plugins/brightness/brightness-proxy.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * * 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 <dbus/dbus-glib.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "libxfpm/hal-manager.h"
-#include "libxfpm/hal-device.h"
-
-#include "brightness-proxy.h"
-
-static void brightness_proxy_finalize   (GObject *object);
-
-#define BRIGHTNESS_PROXY_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), BRIGHTNESS_TYPE_PROXY, BrightnessProxyPrivate))
-
-struct BrightnessProxyPrivate
-{
-    DBusGConnection *bus;
-    DBusGConnection *session;
-    DBusGProxy      *proxy;
-    guint            max_level;
-    gboolean         has_hw;
-};
-
-G_DEFINE_TYPE (BrightnessProxy, brightness_proxy, G_TYPE_OBJECT)
-
-static void
-brightness_proxy_get_device (BrightnessProxy *brightness)
-{
-    HalManager *manager;
-    HalDevice *device;
-    gchar **udis = NULL;
-    
-    manager = hal_manager_new ();
-    
-    udis = hal_manager_find_device_by_capability (manager, "laptop_panel");
-    
-    if (!udis || !udis[0] )
-    {
-	TRACE ("No laptop panel found on the system");
-	brightness->priv->has_hw = FALSE;
-	brightness->priv->proxy = NULL;
-	goto out;
-    }
-    
-    device = hal_device_new ();
-    hal_device_set_udi (device, udis[0]);
-    
-    brightness->priv->max_level =
-	hal_device_get_property_int (device, "laptop_panel.num_levels") -1;
-	
-    TRACE("Laptop panel %s with max level %d", udis[0], brightness->priv->max_level);
-    
-    brightness->priv->proxy = dbus_g_proxy_new_for_name (brightness->priv->bus,
-		   			                 "org.freedesktop.Hal",
-						         udis[0],
-						         "org.freedesktop.Hal.Device.LaptopPanel");
-    brightness->priv->has_hw = TRUE;
-    
-    g_object_unref (device);
-out:
-    g_object_unref (manager);
-}
-
-static void
-brightness_proxy_class_init (BrightnessProxyClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-    object_class->finalize = brightness_proxy_finalize;
-
-    g_type_class_add_private (klass, sizeof (BrightnessProxyPrivate));
-}
-
-static void
-brightness_proxy_init (BrightnessProxy *brightness_proxy)
-{
-    brightness_proxy->priv = BRIGHTNESS_PROXY_GET_PRIVATE (brightness_proxy);
-    
-    brightness_proxy->priv->max_level = 0;
-    
-    // FIXME, Don't connect blindly
-    brightness_proxy->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
-    brightness_proxy->priv->session = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
-    
-    brightness_proxy_get_device (brightness_proxy);
-}
-
-static void
-brightness_proxy_finalize (GObject *object)
-{
-    BrightnessProxy *brightness_proxy;
-
-    brightness_proxy = BRIGHTNESS_PROXY (object);
-    
-    dbus_g_connection_unref (brightness_proxy->priv->bus);
-    dbus_g_connection_unref (brightness_proxy->priv->session);
-    
-    if ( brightness_proxy->priv->proxy )
-	g_object_unref (brightness_proxy->priv->proxy);
-
-    G_OBJECT_CLASS (brightness_proxy_parent_class)->finalize (object);
-}
-
-static void
-brightness_proxy_update_xfpm_brightness_level (BrightnessProxy *brightness, guint level)
-{
-    DBusGProxy *proxy;
-    
-    proxy = dbus_g_proxy_new_for_name (brightness->priv->session,
-				       "org.freedesktop.PowerManagement",
-				       "/org/freedesktop/PowerManagement/Backlight",
-				       "org.freedesktop.PowerManagement.Backlight");
-					       
-    if ( !proxy )
-    {
-	g_warning ("Failed to create proxy to Xfpm");
-	return;
-    }
-
-    dbus_g_proxy_call_no_reply (proxy, "UpdateBrightness",
-			        G_TYPE_UINT, level,
-				G_TYPE_INVALID,
-				G_TYPE_INVALID);
-				
-    g_object_unref ( proxy );
-}
-
-BrightnessProxy *
-brightness_proxy_new (void)
-{
-    BrightnessProxy *brightness_proxy = NULL;
-    brightness_proxy = g_object_new (BRIGHTNESS_TYPE_PROXY, NULL);
-    return brightness_proxy;
-}
-
-gboolean
-brightness_proxy_set_level (BrightnessProxy *brightness, guint level)
-{
-    GError *error = NULL;
-    gboolean ret;
-    gint dummy;
-    
-    g_return_val_if_fail (BRIGHTNESS_IS_PROXY (brightness), FALSE);
-    
-    ret = dbus_g_proxy_call (brightness->priv->proxy, "SetBrightness", &error,
-			     G_TYPE_INT, level,
-			     G_TYPE_INVALID,
-			     G_TYPE_INT, &dummy,
-			     G_TYPE_INVALID );
-    if ( error )
-    {
-	g_critical ("Error setting brightness level: %s\n", error->message);
-	g_error_free (error);
-	return FALSE;
-    }
-	
-    brightness_proxy_update_xfpm_brightness_level (brightness, level);
-    
-    return ret;
-}
-
-guint
-brightness_proxy_get_level (BrightnessProxy *brightness)
-{
-    GError *error = NULL;
-    gint level = 0;
-    gboolean ret;
-    
-    g_return_val_if_fail (BRIGHTNESS_IS_PROXY (brightness), 0);
-    
-    ret = dbus_g_proxy_call (brightness->priv->proxy, "GetBrightness", &error,
-	 		     G_TYPE_INVALID,
-			     G_TYPE_INT, &level,
-			     G_TYPE_INVALID);
-
-    if ( error )
-    {
-	g_critical ("Error getting brightness level: %s\n", error->message);
-	g_error_free (error);
-    }
-    return level;
-}
-
-guint brightness_proxy_get_max_level (BrightnessProxy *brightness)
-{
-    g_return_val_if_fail (BRIGHTNESS_IS_PROXY (brightness), 0);
-    
-    return brightness->priv->max_level;
-}
-
-gboolean brightness_proxy_has_hw (BrightnessProxy *brightness)
-{
-    g_return_val_if_fail (BRIGHTNESS_IS_PROXY (brightness), FALSE);
-    
-    return brightness->priv->has_hw;
-}
-
-
-void brightness_proxy_reload (BrightnessProxy *brightness)
-{
-    g_return_if_fail (BRIGHTNESS_IS_PROXY (brightness));
-    
-    if ( brightness->priv->proxy )
-	g_object_unref (brightness->priv->proxy);
-	
-    brightness_proxy_get_device (brightness);
-}
diff --git a/panel-plugins/brightness/brightness-proxy.h b/panel-plugins/brightness/brightness-proxy.h
deleted file mode 100644
index 5c96035..0000000
--- a/panel-plugins/brightness/brightness-proxy.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * * 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 __BRIGHTNESS_PROXY_H
-#define __BRIGHTNESS_PROXY_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define BRIGHTNESS_TYPE_PROXY        (brightness_proxy_get_type () )
-#define BRIGHTNESS_PROXY(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), BRIGHTNESS_TYPE_PROXY, BrightnessProxy))
-#define BRIGHTNESS_IS_PROXY(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), BRIGHTNESS_TYPE_PROXY))
-
-typedef struct BrightnessProxyPrivate BrightnessProxyPrivate;
-
-typedef struct
-{
-    GObject         		parent;
-    BrightnessProxyPrivate     *priv;
-    
-} BrightnessProxy;
-
-typedef struct
-{
-    GObjectClass 		parent_class;
-} BrightnessProxyClass;
-
-GType        			brightness_proxy_get_type        (void) G_GNUC_CONST;
-BrightnessProxy       	       *brightness_proxy_new             (void);
-
-gboolean                        brightness_proxy_set_level       (BrightnessProxy *brightness,
-								  guint level);
-
-guint                           brightness_proxy_get_level       (BrightnessProxy *brightness);
-
-guint                           brightness_proxy_get_max_level   (BrightnessProxy *brightness) G_GNUC_PURE;
-
-gboolean                        brightness_proxy_has_hw          (BrightnessProxy *brightness) G_GNUC_PURE;
-
-void                            brightness_proxy_reload          (BrightnessProxy *brightness);
-
-G_END_DECLS
-
-#endif /* __BRIGHTNESS_PROXY_H */
diff --git a/settings/Makefile.am b/settings/Makefile.am
index dafbd3c..7d80680 100644
--- a/settings/Makefile.am
+++ b/settings/Makefile.am
@@ -11,8 +11,10 @@ xfce4_power_manager_settings_SOURCES = 				\
 
 xfce4_power_manager_settings_CFLAGS =				\
 	-I$(top_srcdir)						\
+	-I$(top_srcdir)/common					\
 	-I$(top_srcdir)/src					\
 	-I$(top_srcdir)/data					\
+	-I$(top_srcdir)/libdbus                 		\
 	-DLOCALEDIR=\"$(localedir)\"				\
 	-DG_LOG_DOMAIN=\"xfce4-power-manager-settings\" 	\
 	-export-dynamic						\
@@ -23,21 +25,22 @@ xfce4_power_manager_settings_CFLAGS =				\
 	$(GMODULE_CFLAGS)					\
 	$(DBUS_CFLAGS)						\
 	$(DBUS_GLIB_CFLAGS)					\
-	$(LIBXFCE4GUI_CFLAGS)					\
+	$(LIBXFCE4UI_CFLAGS)					\
 	$(LIBXFCE4UTIL_CFLAGS)					\
 	$(XFCONF_CFLAGS)
 
 xfce4_power_manager_settings_LDADD   =				\
+	$(top_builddir)/libdbus/libxfpmdbus.la  		\
+	$(top_builddir)/common/libxfpmcommon.la			\
 	$(GTK_LIBS)						\
 	$(GLIB_LIBS)						\
 	$(GTHREAD_LIBS)						\
 	$(GMODULE_LIBS)						\
 	$(DBUS_LIBS)						\
 	$(DBUS_GLIB_LIBS)					\
-	$(LIBXFCE4GUI_LIBS)					\
+	$(LIBXFCE4UI_LIBS)					\
 	$(LIBXFCE4UTIL_LIBS)					\
-	$(XFCONF_LIBS)						\
-	$(top_builddir)/libxfpm/libxfpmcommon.la
+	$(XFCONF_LIBS)
 
 
 manpagedir = $(mandir)/man1
diff --git a/settings/xfpm-settings-main.c b/settings/xfpm-settings-main.c
index f0ecedf..b4b8e19 100644
--- a/settings/xfpm-settings-main.c
+++ b/settings/xfpm-settings-main.c
@@ -30,36 +30,36 @@
 #include <glib.h>
 
 #include <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
+#include <libxfce4ui/libxfce4ui.h>
 
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 
 #include <xfconf/xfconf.h>
 
-#include "libxfpm/xfpm-popups.h"
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-common.h"
-#include "libxfpm/xfpm-dbus.h"
+#include "common/xfpm-common.h"
 
 #include "xfce-power-manager-dbus-client.h"
 #include "xfpm-settings.h"
 #include "xfpm-config.h"
+#include "xfpm-dbus.h"
 
-int main(int argc, char **argv)
+int main (int argc, char **argv)
 {
     GError *error = NULL;
     DBusGConnection *bus;
     GHashTable *config_hash;
     
-    gboolean system_laptop;
-    gboolean user_privilege;
+    gboolean has_battery;
+    gboolean auth_suspend;
+    gboolean auth_hibernate;
     gboolean can_suspend;
     gboolean can_hibernate;
     gboolean has_lcd_brightness;
     gboolean has_sleep_button;
     gboolean has_hibernate_button;
     gboolean has_power_button;
+    gboolean has_lid;
     gboolean start_xfpm_if_not_running;
     
     GdkNativeWindow socket_id = 0;
@@ -98,7 +98,7 @@ int main(int argc, char **argv)
 	g_error ("%s\n",error->message);
     }
 
-    if ( xfpm_dbus_name_has_owner(dbus_g_connection_get_connection(bus), "org.xfce.PowerManager") ) 
+    if ( xfpm_dbus_name_has_owner (dbus_g_connection_get_connection(bus), "org.xfce.PowerManager") ) 
     {
 	TRACE("Xfce power manager is running\n");
 	
@@ -114,10 +114,11 @@ int main(int argc, char **argv)
 	if ( !xfconf_init(&error) )
     	{
 	    g_critical("xfconf init failed: %s using default settings\n", error->message);
-	    
-	    xfpm_popup_message(_("Xfce Power Manager"),_("Failed to load power manager configuration, "\
-	    			"using defaults"), GTK_MESSAGE_WARNING);
-	    g_error_free(error);
+	    xfce_dialog_show_warning (NULL, 
+				      _("Xfce Power Manager"), 
+				      "%s",
+				      _("Failed to load power manager configuration, using defaults"));
+	    g_error_free (error);
 	    error = NULL;
 	    return EXIT_FAILURE;
     	}
@@ -141,24 +142,25 @@ int main(int argc, char **argv)
 	if ( error )
 	{
 	    g_critical ("Unable to get configuration information from xfce power manager: %s", error->message);
-	    xfpm_error (_("Xfce Power Manager Settings"),
-		       _("Unable to connect to Xfce Power Manager") );
+	    xfce_dialog_show_error (NULL, error, "%s", _("Unable to connect to Xfce Power Manager"));
 	    g_error_free (error);
 	    return EXIT_FAILURE;
 	}
 	
-	system_laptop = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "system-laptop"));
+	has_battery = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "has-battery"));
+	has_lid = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "has-lid"));
 	can_suspend = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-suspend"));
 	can_hibernate = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-hibernate"));
-	user_privilege = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "caller-privilege"));
+	auth_suspend = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "auth-suspend"));
+	auth_hibernate = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "auth-hibernate"));
 	has_lcd_brightness = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "has-brightness"));
 	has_sleep_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "sleep-button"));
 	has_power_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "power-button"));
 	has_hibernate_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "hibernate-button"));
 	
-	xfpm_settings_dialog_new (channel, system_laptop, user_privilege,
+	xfpm_settings_dialog_new (channel, has_battery, auth_hibernate, auth_suspend,
 				  can_suspend, can_hibernate, has_lcd_brightness,
-				  system_laptop, has_sleep_button, has_hibernate_button, has_power_button,
+				  has_lid, has_sleep_button, has_hibernate_button, has_power_button,
 				  socket_id);
 					   
 	gtk_main();
@@ -173,9 +175,12 @@ int main(int argc, char **argv)
 	g_print(_("Xfce power manager is not running"));
 	g_print("\n");
 	start_xfpm_if_not_running =
-	    xfce_confirm(_("Xfce4 Power Manager is not running, do you want to launch it now?"),
-			GTK_STOCK_YES,
-			_("Run"));
+	    xfce_dialog_confirm (NULL, 
+				 GTK_STOCK_YES, 
+				 _("Run"), 
+				 _("Xfce4 Power Manager is not running, do you want to launch it now?"),
+				 NULL);
+	
 	if ( start_xfpm_if_not_running ) 
 	{
 	    g_spawn_command_line_async("xfce4-power-manager",NULL);
diff --git a/settings/xfpm-settings.c b/settings/xfpm-settings.c
index fdfb94e..33277c8 100644
--- a/settings/xfpm-settings.c
+++ b/settings/xfpm-settings.c
@@ -32,11 +32,10 @@
 #include <xfconf/xfconf.h>
 
 #include <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
+#include <libxfce4ui/libxfce4ui.h>
 
-#include "libxfpm/xfpm-common.h"
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-icons.h"
+#include "xfpm-common.h"
+#include "xfpm-icons.h"
 
 #include "interfaces/xfpm-settings_ui.h"
 
@@ -717,7 +716,7 @@ cpu_freq_control_changed_cb (GtkWidget *w, XfconfChannel *channel)
 
 
 static void
-xfpm_settings_on_battery (XfconfChannel *channel, gboolean user_privilege, gboolean can_suspend, 
+xfpm_settings_on_battery (XfconfChannel *channel, gboolean auth_hibernate, gboolean auth_suspend, gboolean can_suspend, 
 			 gboolean can_hibernate, gboolean has_lcd_brightness, gboolean has_lid)
 {
     gboolean valid;
@@ -751,7 +750,7 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean user_privilege, gbool
     gtk_range_set_value (GTK_RANGE (inact), val);
     
     
-    if (!user_privilege )
+    if (!auth_suspend && auth_hibernate )
     {
 	gtk_widget_set_sensitive (battery_critical, FALSE);
 	gtk_widget_set_tooltip_text (battery_critical, _("Shutdown and hibernate operations not permitted"));
@@ -764,13 +763,13 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean user_privilege, gbool
     gtk_list_store_append(list_store, &iter);
     gtk_list_store_set (list_store, &iter, 0, _("Nothing"), 1, XFPM_DO_NOTHING, -1);
     
-    if ( can_suspend )
+    if ( can_suspend && auth_suspend )
     {
 	gtk_list_store_append(list_store, &iter);
 	gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, XFPM_DO_SUSPEND, -1);
     }
     
-    if ( can_hibernate )
+    if ( can_hibernate && auth_hibernate )
     {
 	gtk_list_store_append(list_store, &iter);
 	gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, XFPM_DO_HIBERNATE, -1);
@@ -822,7 +821,7 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean user_privilege, gbool
     lid = GTK_WIDGET (gtk_builder_get_object (xml, "on-battery-lid"));
     if ( has_lid )
     {
-	if (!user_privilege )
+	if (!auth_hibernate && !auth_suspend )
 	{
 	    gtk_widget_set_sensitive (lid, FALSE);
 	    gtk_widget_set_tooltip_text (lid, _("Shutdown and hibernate operations not permitted"));
@@ -835,13 +834,13 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean user_privilege, gbool
 	gtk_list_store_append(list_store, &iter);
 	gtk_list_store_set (list_store, &iter, 0, _("Nothing"), 1, LID_TRIGGER_NOTHING, -1);
 	
-	if ( can_suspend )
+	if ( can_suspend && auth_suspend )
 	{
 	    gtk_list_store_append(list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, LID_TRIGGER_SUSPEND, -1);
 	}
 	
-	if ( can_hibernate)
+	if ( can_hibernate && auth_hibernate)
 	{
 	    gtk_list_store_append(list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, LID_TRIGGER_HIBERNATE, -1);
@@ -898,8 +897,8 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean user_privilege, gbool
 }
 
 static void
-xfpm_settings_on_ac (XfconfChannel *channel, gboolean user_privilege, gboolean can_suspend, 
-		     gboolean can_hibernate, gboolean has_lcd_brightness, gboolean has_lid)
+xfpm_settings_on_ac (XfconfChannel *channel, gboolean auth_suspend, gboolean auth_hibernate, 
+		     gboolean can_suspend, gboolean can_hibernate, gboolean has_lcd_brightness, gboolean has_lid)
 {
     GtkWidget *inact;
     GtkWidget *lid;
@@ -948,7 +947,7 @@ xfpm_settings_on_ac (XfconfChannel *channel, gboolean user_privilege, gboolean c
     {
 	list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
 	
-	if ( !user_privilege )
+	if ( !auth_hibernate && !auth_suspend )
 	{
 	    gtk_widget_set_sensitive (lid, FALSE);
 	    gtk_widget_set_tooltip_text (lid, _("Hibernate and suspend operations not permitted"));
@@ -1020,7 +1019,7 @@ xfpm_settings_on_ac (XfconfChannel *channel, gboolean user_privilege, gboolean c
 }
 
 static void
-xfpm_settings_general (XfconfChannel *channel, gboolean user_privilege,
+xfpm_settings_general (XfconfChannel *channel, gboolean auth_hibernate, gboolean auth_suspend,
 		       gboolean can_suspend, gboolean can_hibernate,
 		       gboolean has_sleep_button, gboolean has_hibernate_button,
 		       gboolean has_power_button)
@@ -1103,7 +1102,7 @@ xfpm_settings_general (XfconfChannel *channel, gboolean user_privilege,
     
     if ( has_power_button )
     {
-	if (!user_privilege )
+	if (!auth_hibernate && !auth_suspend)
 	{
 	    gtk_widget_set_sensitive (power, FALSE);
 	    gtk_widget_set_tooltip_text (power, _("Hibernate and suspend operations not permitted"));
@@ -1114,13 +1113,13 @@ xfpm_settings_general (XfconfChannel *channel, gboolean user_privilege,
 	gtk_list_store_append (list_store, &iter);
 	gtk_list_store_set (list_store, &iter, 0, _("Nothing"), 1, XFPM_DO_NOTHING, -1);
 	
-	if ( can_suspend )
+	if ( can_suspend && auth_suspend)
 	{
 	    gtk_list_store_append (list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, XFPM_DO_SUSPEND, -1);
 	}
 	
-	if ( can_hibernate )
+	if ( can_hibernate && auth_hibernate )
 	{
 	    gtk_list_store_append (list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, XFPM_DO_HIBERNATE, -1);
@@ -1161,7 +1160,7 @@ xfpm_settings_general (XfconfChannel *channel, gboolean user_privilege,
     
     if (has_hibernate_button )
     {
-	if (!user_privilege )
+	if (!auth_hibernate && !auth_suspend )
 	{
 	    gtk_widget_set_sensitive (hibernate, FALSE);
 	    gtk_widget_set_tooltip_text (hibernate, _("Hibernate and suspend operations not permitted"));
@@ -1172,13 +1171,13 @@ xfpm_settings_general (XfconfChannel *channel, gboolean user_privilege,
 	gtk_list_store_append (list_store, &iter);
 	gtk_list_store_set (list_store, &iter, 0, _("Nothing"), 1, XFPM_DO_NOTHING, -1);
 	
-	if ( can_suspend )
+	if ( can_suspend && auth_suspend)
 	{
 	    gtk_list_store_append (list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, XFPM_DO_SUSPEND, -1);
 	}
 	
-	if ( can_hibernate )
+	if ( can_hibernate && auth_hibernate )
 	{
 	    gtk_list_store_append (list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, XFPM_DO_HIBERNATE, -1);
@@ -1216,7 +1215,7 @@ xfpm_settings_general (XfconfChannel *channel, gboolean user_privilege,
     
     if ( has_sleep_button )
     {
-	if (!user_privilege )
+	if (!auth_hibernate && !auth_suspend )
 	{
 	    gtk_widget_set_sensitive (sleep_w, FALSE);
 	    gtk_widget_set_tooltip_text (sleep_w, _("Hibernate and suspend operations not permitted"));
@@ -1227,13 +1226,13 @@ xfpm_settings_general (XfconfChannel *channel, gboolean user_privilege,
 	gtk_list_store_append (list_store, &iter);
 	gtk_list_store_set (list_store, &iter, 0, _("Nothing"), 1, XFPM_DO_NOTHING, -1);
 	
-	if ( can_suspend )
+	if ( can_suspend && auth_suspend )
 	{
 	    gtk_list_store_append (list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, XFPM_DO_SUSPEND, -1);
 	}
 	
-	if ( can_hibernate )
+	if ( can_hibernate && auth_hibernate)
 	{
 	    gtk_list_store_append (list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, XFPM_DO_HIBERNATE, -1);
@@ -1273,7 +1272,8 @@ xfpm_settings_general (XfconfChannel *channel, gboolean user_privilege,
 }
 
 static void
-xfpm_settings_advanced (XfconfChannel *channel, gboolean system_laptop, gboolean user_privilege,
+xfpm_settings_advanced (XfconfChannel *channel, gboolean system_laptop, 
+		        gboolean auth_hibernate, gboolean auth_suspend,
 			gboolean can_suspend, gboolean can_hibernate)
 {
     guint val;
@@ -1288,23 +1288,23 @@ xfpm_settings_advanced (XfconfChannel *channel, gboolean system_laptop, gboolean
     GtkWidget *inact_suspend = GTK_WIDGET (gtk_builder_get_object (xml, "inactivity-suspend"));
     GtkWidget *inact_hibernate = GTK_WIDGET (gtk_builder_get_object (xml, "inactivity-hibernate"));
     
-    if ( !can_suspend )
+    if ( !auth_suspend || !can_suspend)
     {
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (inact_hibernate), TRUE);
 	gtk_widget_set_sensitive (inact_suspend, FALSE);
 	gtk_widget_set_tooltip_text (inact_suspend, _("Suspend operation not permitted"));
     }
     
-    if ( !can_hibernate )
+    if ( !auth_hibernate || !can_hibernate )
     {
 	gtk_widget_set_sensitive (inact_hibernate, FALSE);
 	gtk_widget_set_tooltip_text (inact_hibernate, _("Hibernate operation not permitted"));
     }
    
     str = xfconf_channel_get_string (channel, PROPERTIES_PREFIX INACTIVITY_SLEEP_MODE, "Suspend");
-    if ( xfpm_strequal (str, "Suspend") )
+    if ( !g_strcmp0 (str, "Suspend") )
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (inact_suspend), TRUE);
-    else if ( xfpm_strequal (str, "Hibernate"))
+    else if ( !g_strcmp0 (str, "Hibernate"))
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (inact_hibernate), TRUE);
     else 
     {
@@ -1320,9 +1320,9 @@ xfpm_settings_advanced (XfconfChannel *channel, gboolean system_laptop, gboolean
 #ifdef HAVE_DPMS
     str = xfconf_channel_get_string (channel, PROPERTIES_PREFIX DPMS_SLEEP_MODE, "standby");
     
-    if ( xfpm_strequal (str, "standby" ) )
+    if ( !g_strcmp0 (str, "standby" ) )
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sleep_dpms_mode), TRUE);
-    else if ( xfpm_strequal (str, "suspend") )
+    else if ( !g_strcmp0 (str, "suspend") )
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (suspend_dpms_mode), TRUE);
     else 
     {
@@ -1349,7 +1349,7 @@ xfpm_settings_advanced (XfconfChannel *channel, gboolean system_laptop, gboolean
     
 	val = xfconf_channel_get_uint (channel, PROPERTIES_PREFIX CRITICAL_POWER_LEVEL, 10);
 
-	if ( G_UNLIKELY (val > 20) )
+	if ( val > 20 || val < 5)
 	{
 	    g_critical ("Value %d if out of range for property %s\n", val, CRITICAL_POWER_LEVEL);
 	    gtk_spin_button_set_value (GTK_SPIN_BUTTON(critical_level), 10);
@@ -1369,7 +1369,7 @@ xfpm_settings_advanced (XfconfChannel *channel, gboolean system_laptop, gboolean
      */
     lock = GTK_WIDGET (gtk_builder_get_object (xml, "lock-screen"));
     
-    if ( !user_privilege )
+    if ( (!auth_hibernate && !auth_suspend) || (!can_suspend && !can_hibernate) )
     {
 	gtk_widget_set_sensitive (lock, FALSE);
 	gtk_widget_set_tooltip_text (lock, _("Hibernate and suspend operations not permitted"));
@@ -1452,7 +1452,7 @@ xfpm_settings_tree_view (XfconfChannel *channel, gboolean system_laptop)
     gtk_tree_view_append_column(GTK_TREE_VIEW(view),col);
     
     /*General settings */
-    pix = xfce_themed_icon_load ("preferences-system", 48); 
+    pix = xfpm_icon_load ("preferences-system", 48); 
     
     gtk_list_store_append(list_store, &iter);
     
@@ -1468,7 +1468,7 @@ xfpm_settings_tree_view (XfconfChannel *channel, gboolean system_laptop)
     i++;
     
     /* ON ac power */
-    pix = xfce_themed_icon_load (XFPM_AC_ADAPTER_ICON, 48); 
+    pix = xfpm_icon_load (XFPM_AC_ADAPTER_ICON, 48); 
     gtk_list_store_append(list_store, &iter);
     if ( pix )
     {
@@ -1483,7 +1483,7 @@ xfpm_settings_tree_view (XfconfChannel *channel, gboolean system_laptop)
     
     if ( system_laptop )
     {
-	pix = xfce_themed_icon_load (XFPM_BATTERY_ICON, 48); 
+	pix = xfpm_icon_load (XFPM_BATTERY_ICON, 48); 
 	gtk_list_store_append(list_store, &iter);
 	if ( pix )
 	{
@@ -1497,7 +1497,7 @@ xfpm_settings_tree_view (XfconfChannel *channel, gboolean system_laptop)
     }
     i++;
     
-    pix = xfce_themed_icon_load ("applications-other", 48); 
+    pix = xfpm_icon_load ("applications-other", 48); 
     gtk_list_store_append(list_store, &iter);
     if ( pix )
     {
@@ -1548,7 +1548,7 @@ delete_event_cb (GtkWidget *plug, GdkEvent *ev, XfconfChannel *channel)
 
 void
 xfpm_settings_dialog_new (XfconfChannel *channel, gboolean system_laptop, 
-			  gboolean user_privilege, gboolean can_suspend, 
+			  gboolean auth_hibernate, gboolean auth_suspend, gboolean can_suspend, 
 			  gboolean can_hibernate, gboolean has_lcd_brightness, 
 			  gboolean has_lid, gboolean has_sleep_button, 
 			  gboolean has_hibernate_button, gboolean has_power_button,
@@ -1559,9 +1559,9 @@ xfpm_settings_dialog_new (XfconfChannel *channel, gboolean system_laptop,
     GtkWidget *allbox;
     GError *error = NULL;
 
-    TRACE("system_laptop=%s user_privilege=%s can_suspend=%s can_hibernate=%s has_lcd_brightness=%s has_lid=%s "\
+    g_debug("system_laptop=%s auth_hibernate=%s  auth_suspend=%s can_suspend=%s can_hibernate=%s has_lcd_brightness=%s has_lid=%s "\
           "has_sleep_button=%s has_hibernate_button=%s has_power_button=%s",
-	  xfpm_bool_to_string (system_laptop), xfpm_bool_to_string (user_privilege),
+	  xfpm_bool_to_string (system_laptop), xfpm_bool_to_string (auth_hibernate), xfpm_bool_to_string (auth_suspend),
 	  xfpm_bool_to_string (can_suspend), xfpm_bool_to_string (can_hibernate),
 	  xfpm_bool_to_string (has_lcd_brightness), xfpm_bool_to_string (has_lid),
 	  xfpm_bool_to_string (has_sleep_button), xfpm_bool_to_string (has_hibernate_button),
@@ -1571,7 +1571,7 @@ xfpm_settings_dialog_new (XfconfChannel *channel, gboolean system_laptop,
     
     if ( G_UNLIKELY (error) )
     {
-	xfce_err ("%s : %s", error->message, _("Check your power manager installation"));
+	xfce_dialog_show_error (NULL, error, "%s", _("Check your power manager installation"));
 	g_error ("%s", error->message);
     }
     
@@ -1587,17 +1587,17 @@ xfpm_settings_dialog_new (XfconfChannel *channel, gboolean system_laptop,
     dialog = GTK_WIDGET (gtk_builder_get_object (xml, "xfpm-settings-dialog"));
     nt = GTK_WIDGET (gtk_builder_get_object (xml, "main-notebook"));
     
-    xfpm_settings_on_ac (channel, user_privilege, can_suspend, can_hibernate, has_lcd_brightness, has_lid );
+    xfpm_settings_on_ac (channel, auth_hibernate, auth_suspend, can_suspend, can_hibernate, has_lcd_brightness, has_lid );
     
     if ( system_laptop )
-	xfpm_settings_on_battery (channel, user_privilege, can_suspend, can_hibernate, has_lcd_brightness, has_lid);
+	xfpm_settings_on_battery (channel, auth_hibernate, auth_suspend, can_suspend, can_hibernate, has_lcd_brightness, has_lid);
 	
     xfpm_settings_tree_view (channel, system_laptop);
     
-    xfpm_settings_general   (channel, user_privilege, can_suspend, can_hibernate,
+    xfpm_settings_general   (channel, auth_hibernate, auth_suspend, can_suspend, can_hibernate,
 			     has_sleep_button, has_hibernate_button, has_power_button );
 			     
-    xfpm_settings_advanced  (channel, system_laptop, user_privilege, can_suspend, can_hibernate);
+    xfpm_settings_advanced  (channel, system_laptop, auth_hibernate, auth_suspend, can_suspend, can_hibernate);
     
     if ( id != 0 )
     {
diff --git a/settings/xfpm-settings.h b/settings/xfpm-settings.h
index 2f269d0..dac16aa 100644
--- a/settings/xfpm-settings.h
+++ b/settings/xfpm-settings.h
@@ -23,8 +23,9 @@
 
 
 void	       xfpm_settings_dialog_new 	(XfconfChannel *channel,
-						 gboolean system_laptop,
-						 gboolean user_privilege,
+						 gboolean has_battery,
+						 gboolean auth_hibernate,
+						 gboolean auth_suspend,
 					         gboolean can_suspend,
 					         gboolean can_hibernate,
 					         gboolean has_lcd_brightness,
diff --git a/src/Makefile.am b/src/Makefile.am
index 68d6fb7..282e11d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,114 +1,80 @@
 bin_PROGRAMS = xfce4-power-manager
 
-xfce4_power_manager_SOURCES = 			\
-	xfpm-enum-types.c			\
-	xfpm-enum-types.h			\
-	xfpm-marshal.c				\
-	xfpm-marshal.h				\
-	org.freedesktop.PowerManagement.h	\
-	org.freedesktop.PowerManagement.Inhibit.h\
-	org.freedesktop.PowerManagement.Backlight.h\
-	xfce-power-manager-dbus-server.h	\
-	xfce-power-manager-dbus-client.h	\
+xfce4_power_manager_SOURCES =                   \
+	$(BUILT_SOURCES)			\
+	xfpm-enum.h				\
+	xfpm-enum-glib.h			\
 	xfpm-main.c				\
 	xfpm-manager.c				\
 	xfpm-manager.h				\
-	xfpm-engine.c				\
-	xfpm-engine.h				\
-	xfpm-session.c				\
-	xfpm-session.h				\
-	xfpm-xfconf.c				\
-	xfpm-xfconf.h				\
-	xfpm-supply.c				\
-	xfpm-supply.h				\
-	xfpm-adapter.c				\
-	xfpm-adapter.h				\
+	xfpm-dkp.c				\
+	xfpm-dkp.h				\
 	xfpm-battery.c				\
 	xfpm-battery.h				\
-	xfpm-battery-info.c			\
-	xfpm-battery-info.h			\
+	xfpm-xfconf.c				\
+	xfpm-xfconf.h				\
 	xfpm-dpms.c				\
 	xfpm-dpms.h				\
-	xfpm-cpu.c				\
-	xfpm-cpu.h				\
 	xfpm-button.c				\
 	xfpm-button.h				\
-	xfpm-button-xf86.c			\
-	xfpm-button-xf86.h			\
-	xfpm-button-hal.c			\
-	xfpm-button-hal.h			\
-	xfpm-backlight.c			\
-	xfpm-backlight.h			\
-	xfpm-brightness-hal.c			\
-	xfpm-brightness-hal.h			\
-	xfpm-brightness-widget.c		\
-	xfpm-brightness-widget.h		\
-	xfpm-idle.c				\
-	xfpm-idle.h				\
-	xfpm-inhibit.c				\
-	xfpm-inhibit.h				\
-	xfpm-screen-saver.c			\
-	xfpm-screen-saver.h			\
-	xfpm-dbus-monitor.c			\
-	xfpm-dbus-monitor.h			\
-	xfpm-tray-icon.c			\
-	xfpm-tray-icon.h			\
-	xfpm-shutdown.c				\
-	xfpm-shutdown.h				\
 	xfpm-network-manager.c			\
 	xfpm-network-manager.h			\
+	xfpm-inhibit.c				\
+	xfpm-inhibit.h				\
+	xfpm-notify.c				\
+	xfpm-notify.h				\
+	xfpm-polkit.c				\
+	xfpm-polkit.h				\
 	xfpm-errors.c				\
-	xfpm-errors.h				\
-	xfpm-config.h				\
-	xfpm-enum.h				\
-	xfpm-debug.c				\
-	xfpm-debug.h
-
-
-xfce4_power_manager_CFLAGS =			\
-	-I$(top_srcdir)				\
-	-I$(top_srcdir)/libxfpm			\
-	-DLOCALEDIR=\"$(localedir)\"		\
-	-DG_LOG_DOMAIN=\"xfce4-power-manager\" 	\
-	$(GOBJECT_CFLAGS)			\
-	$(GTHREAD_CFLAGS)			\
-	$(DBUS_GLIB_CFLAGS)			\
-	$(LIBXFCE4GUI_CFLAGS)			\
-	$(XFCONF_CFLAGS)			\
-	$(LIBNOTIFY_CFLAGS)			\
-	$(DPMS_CFLAGS)              	
-
-xfce4_power_manager_LDADD   =			\
-	$(top_builddir)/libxfpm/libxfpmhal.la	\
-	$(top_builddir)/libxfpm/libxfpmhalpower.la\
-	$(top_builddir)/libxfpm/libxfpmcommon.la\
-	$(GOBJECT_LIBS)				\
-	$(GTHREAD_LIBS)				\
-	$(DBUS_GLIB_LIBS)			\
-	$(LIBXFCE4GUI_LIBS)			\
-	$(XFCONF_LIBS)				\
-	$(LIBNOTIFY_LIBS)			\
-	$(DPMS_LIBS)		
+	xfpm-errors.h
+
+xfce4_power_manager_CFLAGS =                    \
+        -I$(top_srcdir)                         \
+	-I$(top_srcdir)/common                  \
+	-I$(top_srcdir)/libdbus                 \
+        -DLOCALEDIR=\"$(localedir)\"            \
+        -DG_LOG_DOMAIN=\"xfce4-power-manager\"  \
+        $(GOBJECT_CFLAGS)                       \
+        $(GTHREAD_CFLAGS)                       \
+        $(DBUS_GLIB_CFLAGS)                     \
+        $(LIBXFCE4UI_CFLAGS)                    \
+        $(XFCONF_CFLAGS)                        \
+        $(LIBNOTIFY_CFLAGS)                     \
+	$(XRANDR_CFLAGS)			\
+	$(POLKIT_CFLAGS)			\
+        $(DPMS_CFLAGS)                  
+
+xfce4_power_manager_LDADD =                     \
+	$(top_builddir)/common/libxfpmcommon.la \
+	$(top_builddir)/libdbus/libxfpmdbus.la  \
+        $(GOBJECT_LIBS)                         \
+        $(GTHREAD_LIBS)                         \
+        $(DBUS_GLIB_LIBS)                       \
+        $(LIBXFCE4UI_LIBS)                      \
+        $(XFCONF_LIBS)                          \
+        $(LIBNOTIFY_LIBS)                       \
+	$(XRANDR_LIBS)				\
+	$(POLKIT_LIBS)				\
+        $(DPMS_LIBS)
 
 manpagedir = $(mandir)/man1
 
 manpage_DATA = xfce4-power-manager.1
 
-xfpm_glib_headers = 				\
-	$(srcdir)/xfpm-enum-glib.h			
+xfpm_glib_headers =                             \
+        $(srcdir)/xfpm-enum-glib.h
 
-if MAINTAINER_MODE
+BUILT_SOURCES =					\
+	xfce-power-manager-dbus-server.h	\
+	xfce-power-manager-dbus-client.h	\
+	xfpm-enum-types.c                       \
+	xfpm-enum-types.h			\
+	xfpm-marshal.c                          \
+        xfpm-marshal.h				\
+	org.freedesktop.PowerManagement.h       \
+	org.freedesktop.PowerManagement.Inhibit.h
 
-BUILT_SOURCES = 					\
-	xfce-power-manager-dbus-server.h		\
-	xfce-power-manager-dbus-client.h		\
-	org.freedesktop.PowerManagement.h		\
-	org.freedesktop.PowerManagement.Inhibit.h	\
-	org.freedesktop.PowerManagement.Backlight.h	\
-	xfpm-marshal.c					\
-	xfpm-marshal.h					\
-	xfpm-enum-types.c				\
-	xfpm-enum-types.h
+if MAINTAINER_MODE
 
 xfpm-enum-types.h: $(xfpm_glib_headers)
 	( cd $(srcdir) && glib-mkenums \
@@ -146,14 +112,11 @@ xfce-power-manager-dbus-client.h: $(srcdir)/org.xfce.Power.Manager.xml
 	dbus-binding-tool --mode=glib-client --prefix=xfpm_manager $< >$@
 
 org.freedesktop.PowerManagement.h: $(srcdir)/org.freedesktop.PowerManagement.xml
-	dbus-binding-tool --mode=glib-server --prefix=xfpm_engine $< >$@
+	dbus-binding-tool --mode=glib-server --prefix=xfpm_dkp $< >$@
 
 org.freedesktop.PowerManagement.Inhibit.h: $(srcdir)/org.freedesktop.PowerManagement.Inhibit.xml
 	dbus-binding-tool --mode=glib-server --prefix=xfpm_inhibit $< >$@
 
-org.freedesktop.PowerManagement.Backlight.h: $(srcdir)/org.freedesktop.PowerManagement.Backlight.xml
-	dbus-binding-tool --mode=glib-server --prefix=xfpm_backlight $< >$@
-
 endif
 
 @INTLTOOL_DESKTOP_RULE@
@@ -161,13 +124,11 @@ autostartdir = $(sysconfdir)/xdg/autostart
 autostart_in_files = xfce4-power-manager.desktop.in
 autostart_DATA = $(autostart_in_files:.desktop.in=.desktop)
 
-EXTRA_DIST = 					\
+EXTRA_DIST =                                    \
 	xfpm-marshal.list			\
-	xfpm-enum-glib.h			\
-	$(autostart_in_files)			\
-	$(manpage_DATA)
-
-DISTCLEANFILES =				\
-	$(BUILT_SOURCES)			\
-	xfce4-power-manager.desktop
+        $(autostart_in_files)                   \
+        $(manpage_DATA)
 
+DISTCLEANFILES =                                \
+        $(BUILT_SOURCES)                        \
+        xfce4-power-manager.desktop
\ No newline at end of file
diff --git a/src/org.freedesktop.PowerManagement.Backlight.xml b/src/org.freedesktop.PowerManagement.Backlight.xml
deleted file mode 100644
index 8d96094..0000000
--- a/src/org.freedesktop.PowerManagement.Backlight.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<node name="/">
-    <interface name="org.freedesktop.PowerManagement.Backlight">
-        <annotation name="org.freedesktop.DBus.GLib.CSymbol"
-                    value="xfpm_backlight_dbus"/>
-        <annotation name="org.freedesktop.DBus.GLib.ClientCSymbol"
-                    value="xfpm_backlight_dbus_client"/>
-
-    <method name="UpdateBrightness">
-      <arg type="u" name="level" direction="in"/>
-    </method>
-
-    </interface>
-</node>
diff --git a/src/org.freedesktop.PowerManagement.xml b/src/org.freedesktop.PowerManagement.xml
index ad11a85..9d8a74e 100644
--- a/src/org.freedesktop.PowerManagement.xml
+++ b/src/org.freedesktop.PowerManagement.xml
@@ -3,9 +3,9 @@
 <node name="/org/freedesktop/PowerManagement">
     <interface name="org.freedesktop.PowerManagement">
         <annotation name="org.freedesktop.DBus.GLib.CSymbol"
-                    value="xfpm_engine_dbus"/>
+                    value="xfpm_dkp_dbus"/>
         <annotation name="org.freedesktop.DBus.GLib.ClientCSymbol"
-                    value="xfpm_engine_dbus_client"/>   
+                    value="xfpm_dkp_dbus_client"/>   
 
     <method name="Shutdown">
     </method>
diff --git a/src/xfpm-adapter.c b/src/xfpm-adapter.c
deleted file mode 100644
index c983aff..0000000
--- a/src/xfpm-adapter.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * * Copyright (C) 2008-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>
-
-#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 <glib.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "libxfpm/hal-manager.h"
-#include "libxfpm/hal-device.h"
-#include "libxfpm/xfpm-string.h"
-
-#include "xfpm-adapter.h"
-
-static void xfpm_adapter_finalize   (GObject *object);
-
-#define XFPM_ADAPTER_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_ADAPTER, XfpmAdapterPrivate))
-
-struct XfpmAdapterPrivate
-{
-    HalDevice 	 *device;
-    gboolean      present;
-    gboolean      hw_found;
-};
-
-enum
-{
-    ADAPTER_CHANGED,
-    LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmAdapter, xfpm_adapter, G_TYPE_OBJECT)
-
-static void
-xfpm_adapter_device_changed_cb (HalDevice *device, const gchar *udi, const gchar *key,
-			        gboolean is_added, gboolean is_removed, XfpmAdapter *adapter)
-{
-    //FIXME React correctly is device is removed
-    if ( xfpm_strequal(key, "ac_adapter.present") )
-    {
-	adapter->priv->present = hal_device_get_property_bool (adapter->priv->device, "ac_adapter.present");
-	g_signal_emit (G_OBJECT(adapter), signals[ADAPTER_CHANGED], 0, adapter->priv->present);
-    }
-}
-
-static void
-xfpm_adapter_set_device (XfpmAdapter *adapter, HalManager *manager)
-{
-    gchar **udi;
-    
-    manager = hal_manager_new ();
-    
-    udi = hal_manager_find_device_by_capability (manager, "ac_adapter");
-    
-    if (udi == NULL || udi[0] == NULL)//FIXME Adapter should be present on laptops
-	goto out;
-	
-    TRACE("Found AC Adapter with udi=%s\n", udi[0]);
-
-    adapter->priv->hw_found = TRUE;
-    
-    adapter->priv->device = hal_device_new ();
-    hal_device_set_udi (adapter->priv->device, udi[0]);
-    
-    hal_manager_free_string_array (udi);
-    
-    adapter->priv->present = hal_device_get_property_bool (adapter->priv->device, "ac_adapter.present");
-    
-    g_signal_connect (adapter->priv->device, "device-changed",
-		      G_CALLBACK(xfpm_adapter_device_changed_cb), adapter);
-		      
-    hal_device_watch (adapter->priv->device);
-out:
-    ;
-}
-
-static void
-xfpm_adapter_class_init(XfpmAdapterClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    signals[ADAPTER_CHANGED] = 
-    	g_signal_new("adapter-changed",
-                      XFPM_TYPE_ADAPTER,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmAdapterClass, adapter_changed),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__BOOLEAN,
-                      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-		      
-    object_class->finalize = xfpm_adapter_finalize;
-
-    g_type_class_add_private (klass, sizeof(XfpmAdapterPrivate));
-}
-
-static void
-xfpm_adapter_init(XfpmAdapter *adapter)
-{
-    HalManager *manager;
-    
-    adapter->priv = XFPM_ADAPTER_GET_PRIVATE(adapter);
-    
-    adapter->priv->device   = NULL;
-    adapter->priv->present  = TRUE;
-    adapter->priv->hw_found = FALSE;
-    
-    manager = hal_manager_new ();
-        
-    if ( hal_manager_get_is_laptop (manager) )
-    {
-	xfpm_adapter_set_device (adapter, manager);
-	TRACE("System is identified as a laptop");
-    }
-    else
-    {
-	TRACE("System is not identified as a laptop");
-    }
-    
-    g_object_unref (manager);
-}
-
-static void
-xfpm_adapter_finalize(GObject *object)
-{
-    XfpmAdapter *adapter;
-
-    adapter = XFPM_ADAPTER(object);
-    
-    if ( adapter->priv->device )
-	g_object_unref (adapter->priv->device);
-    
-    G_OBJECT_CLASS(xfpm_adapter_parent_class)->finalize(object);
-}
-
-XfpmAdapter *
-xfpm_adapter_new (void)
-{
-    static gpointer xfpm_adapter_object = NULL;
-    
-    if ( G_LIKELY (xfpm_adapter_object != NULL) )
-    {
-	g_object_ref (xfpm_adapter_object);
-    }
-    else
-    {
-	xfpm_adapter_object = g_object_new (XFPM_TYPE_ADAPTER, NULL);
-	g_object_add_weak_pointer (xfpm_adapter_object, &xfpm_adapter_object);
-    }
-    return XFPM_ADAPTER (xfpm_adapter_object);
-}
-
-gboolean xfpm_adapter_get_present (XfpmAdapter *adapter)
-{
-    g_return_val_if_fail (XFPM_IS_ADAPTER(adapter), FALSE);
-    
-    return adapter->priv->present;
-}
-
-gboolean xfpm_adapter_has_hw (XfpmAdapter *adapter)
-{
-    g_return_val_if_fail (XFPM_IS_ADAPTER(adapter), FALSE);
-    
-    return adapter->priv->hw_found;
-}
-
-void xfpm_adapter_reload (XfpmAdapter *adapter)
-{
-    HalManager *manager;
-    
-    g_return_if_fail (XFPM_IS_ADAPTER (adapter));
-    
-    g_object_unref (adapter->priv->device);
-    
-    manager = hal_manager_new ();
-    xfpm_adapter_set_device (adapter, manager);
-    g_object_unref (manager);
-}
diff --git a/src/xfpm-adapter.h b/src/xfpm-adapter.h
deleted file mode 100644
index 838ae13..0000000
--- a/src/xfpm-adapter.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * * Copyright (C) 2008-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_ADAPTER_H
-#define __XFPM_ADAPTER_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_ADAPTER        (xfpm_adapter_get_type () )
-#define XFPM_ADAPTER(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_ADAPTER, XfpmAdapter))
-#define XFPM_IS_ADAPTER(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_ADAPTER))
-
-typedef struct XfpmAdapterPrivate XfpmAdapterPrivate;
-
-typedef struct
-{
-    GObject		  parent;
-    XfpmAdapterPrivate	 *priv;
-    
-} XfpmAdapter;
-
-typedef struct
-{
-    GObjectClass 	  parent_class;
-    
-    void                 (*adapter_changed)    	      (XfpmAdapter *adapter,
-    						       gboolean present);
-    
-} XfpmAdapterClass;
-
-GType        	 	 xfpm_adapter_get_type        (void) G_GNUC_CONST;
-XfpmAdapter      	*xfpm_adapter_new             (void);
-
-gboolean 	  	 xfpm_adapter_get_present     (XfpmAdapter *adapter) G_GNUC_PURE;
-
-gboolean 		 xfpm_adapter_has_hw 	      (XfpmAdapter *adapter) G_GNUC_PURE;
-
-void                     xfpm_adapter_reload          (XfpmAdapter *adapter);
-
-G_END_DECLS
-
-#endif /* __XFPM_ADAPTER_H */
diff --git a/src/xfpm-backlight.c b/src/xfpm-backlight.c
deleted file mode 100644
index e138db0..0000000
--- a/src/xfpm-backlight.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * * 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 <libxfce4util/libxfce4util.h>
-
-#include "xfpm-backlight.h"
-#include "xfpm-brightness-hal.h"
-#include "xfpm-brightness-widget.h"
-
-static void xfpm_backlight_finalize   (GObject *object);
-
-static void xfpm_backlight_dbus_class_init (XfpmBacklightClass *klass);
-static void xfpm_backlight_dbus_init       (XfpmBacklight *bk);
-
-#define XFPM_BACKLIGHT_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_BACKLIGHT, XfpmBacklightPrivate))
-
-struct XfpmBacklightPrivate
-{
-    XfpmBrightnessHal    *br;
-    XfpmBrightnessWidget *widget;
-    
-    gboolean has_hw;
-};
-
-G_DEFINE_TYPE(XfpmBacklight, xfpm_backlight, G_TYPE_OBJECT)
-
-static void
-xfpm_backlight_brightness_up (XfpmBrightnessHal *brg, guint level, XfpmBacklight *bk)
-{
-    xfpm_brightness_widget_set_level (bk->priv->widget, level);
-}
-
-static void
-xfpm_backlight_brightness_down (XfpmBrightnessHal *brg, guint level, XfpmBacklight *bk)
-{
-    xfpm_brightness_widget_set_level (bk->priv->widget, level);
-}
-
-static void
-xfpm_backlight_get_device (XfpmBacklight *bk)
-{
-    guint max_level;
-    bk->priv->br     = xfpm_brightness_hal_new ();
-    bk->priv->has_hw = xfpm_brightness_hal_has_hw (bk->priv->br);
-    
-    if ( bk->priv->has_hw == FALSE )
-	g_object_unref (bk->priv->br);
-    else
-    {
-	bk->priv->widget = xfpm_brightness_widget_new ();
-	g_signal_connect (G_OBJECT(bk->priv->br), "brigthness-up",
-			  G_CALLBACK (xfpm_backlight_brightness_up), bk);
-			  
-	g_signal_connect (G_OBJECT(bk->priv->br), "brigthness-down",
-			  G_CALLBACK (xfpm_backlight_brightness_down), bk);
-	
-	max_level = xfpm_brightness_hal_get_max_level (bk->priv->br);
-	xfpm_brightness_widget_set_max_level (bk->priv->widget,
-					      max_level);
-    }
-    
-}
-
-static void
-xfpm_backlight_class_init(XfpmBacklightClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    object_class->finalize = xfpm_backlight_finalize;
-
-    g_type_class_add_private(klass,sizeof(XfpmBacklightPrivate));
-    
-    xfpm_backlight_dbus_class_init (klass);
-}
-
-static void
-xfpm_backlight_init(XfpmBacklight *bk)
-{
-    bk->priv = XFPM_BACKLIGHT_GET_PRIVATE(bk);
-    
-    xfpm_backlight_get_device (bk);
-    
-    xfpm_backlight_dbus_init (bk);
-}
-
-static void
-xfpm_backlight_finalize(GObject *object)
-{
-    XfpmBacklight *bk;
-
-    bk = XFPM_BACKLIGHT(object);
-    
-    if ( bk->priv->has_hw == TRUE )
-    {
-	g_object_unref (bk->priv->br);
-	g_object_unref (bk->priv->widget);
-    }
-    
-    G_OBJECT_CLASS(xfpm_backlight_parent_class)->finalize(object);
-}
-
-XfpmBacklight *
-xfpm_backlight_new(void)
-{
-    XfpmBacklight *bk = NULL;
-    bk = g_object_new (XFPM_TYPE_BACKLIGHT, NULL);
-    return bk;
-}
-
-/*
- * 
- * DBus server implementation for org.freedesktop.PowerManagement.Backlight (Not standard) 
- *
- */
-
-static gboolean xfpm_backlight_dbus_update_brightness (XfpmBacklight *bk,
-						       guint IN_level,
-						       GError **error);
-
-#include "org.freedesktop.PowerManagement.Backlight.h"
-
-static void xfpm_backlight_dbus_class_init  (XfpmBacklightClass *klass)
-{
-    dbus_g_object_type_install_info (G_TYPE_FROM_CLASS(klass),
-				     &dbus_glib_xfpm_backlight_object_info);
-}
-
-static void xfpm_backlight_dbus_init	  (XfpmBacklight *bk)
-{
-    DBusGConnection *bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
-    
-    dbus_g_connection_register_g_object (bus,
-					 "/org/freedesktop/PowerManagement/Backlight",
-					 G_OBJECT(bk));
-}
-
-
-static gboolean xfpm_backlight_dbus_update_brightness (XfpmBacklight *bk,
-						       guint IN_level,
-						       GError **error)
-{
-    TRACE("Update backlight message received");
-    if ( bk->priv->has_hw )
-	xfpm_brightness_hal_update_level (bk->priv->br, IN_level);
-    
-    return TRUE;
-}
-
-gboolean xfpm_backlight_has_hw (XfpmBacklight *bk)
-{
-    g_return_val_if_fail (XFPM_IS_BACKLIGHT (bk), FALSE);
-    
-    return bk->priv->has_hw;
-}
-
-void xfpm_backlight_reload (XfpmBacklight *bk)
-{
-    g_return_if_fail (XFPM_IS_BACKLIGHT (bk));
-    
-    if ( bk->priv->has_hw == TRUE )
-    {
-	g_object_unref (bk->priv->br);
-	g_object_unref (bk->priv->widget);
-    }
-    
-    xfpm_backlight_get_device (bk);
-}
diff --git a/src/xfpm-backlight.h b/src/xfpm-backlight.h
deleted file mode 100644
index 99171fd..0000000
--- a/src/xfpm-backlight.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * * 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_BACKLIGHT_H
-#define __XFPM_BACKLIGHT_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_BACKLIGHT        (xfpm_backlight_get_type () )
-#define XFPM_BACKLIGHT(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_BACKLIGHT, XfpmBacklight))
-#define XFPM_IS_BACKLIGHT(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_BACKLIGHT))
-
-typedef struct XfpmBacklightPrivate XfpmBacklightPrivate;
-
-typedef struct
-{
-    GObject		 	  parent;
-    XfpmBacklightPrivate	 *priv;
-	
-} XfpmBacklight;
-
-typedef struct
-{
-    GObjectClass parent_class;
-	
-} XfpmBacklightClass;
-
-GType			         xfpm_backlight_get_type        (void) G_GNUC_CONST;
-XfpmBacklight       		*xfpm_backlight_new             (void);
-
-gboolean                         xfpm_backlight_has_hw          (XfpmBacklight *bk) G_GNUC_PURE;
-
-void                             xfpm_backlight_reload          (XfpmBacklight *bk);
-
-G_END_DECLS
-
-#endif /* __XFPM_BACKLIGHT_H */
diff --git a/src/xfpm-battery-info.c b/src/xfpm-battery-info.c
deleted file mode 100644
index 6580116..0000000
--- a/src/xfpm-battery-info.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * * Copyright (C) 2008-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 <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
-
-#include "xfpm-battery-info.h"
-
-static GtkWidget *
-xfpm_battery_info (HalBattery *device)
-{
-    PangoFontDescription *pfd;
-    
-    GtkWidget *table;
-    GtkWidget *label;
-    GtkWidget *align;
-    
-    gint i = 0;
-
-    gchar   *unit = NULL;
-    gchar   *str;
-    guint32  last_full = 0;
-    guint32  design_capacity = 0;
-    gchar   *tech = NULL;
-    gchar   *vendor = NULL;
-    gchar   *model = NULL;
-
-    g_object_get (G_OBJECT(device), 
-    		  "unit", &unit,
-		  "reporting-last-full", &last_full, 
-		  "technology", &tech, 
-		  "vendor", &vendor,
-		  "model", &model,
-		  "reporting-design", &design_capacity,
-		  NULL);
-		  
-    pfd = pango_font_description_from_string("bold");
-    
-    table = gtk_table_new (4, 2, FALSE);
-    
-    if (!unit)
-    	unit = g_strdup (_("Unknown unit"));
-    
-    //Technology
-    if ( tech )
-    {
-    	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-    
-    	label = gtk_label_new (_("Technology:"));
-    	gtk_container_add (GTK_CONTAINER(align), label);
-    	gtk_widget_modify_font (label, pfd);
-    
-    	gtk_table_attach(GTK_TABLE(table), align,
-			 0, 1, i, i+1, 
-		     	 GTK_FILL, GTK_FILL,
-		     	 2, 8);
-
-	label = gtk_label_new (tech);
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	g_free (tech);
-	gtk_table_attach(GTK_TABLE(table), align,
-			 1, 2, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-		     	 2, 8);
-    	i++;
-    }
-
-    /// Capacity design
-    if ( design_capacity != 0 )
-    {
-	label = gtk_label_new (_("Design:"));
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	
-	gtk_widget_modify_font (label, pfd);
-	
-	gtk_table_attach(GTK_TABLE(table), align,
-			 0, 1, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-			 2, 8);
-			 
-	str = g_strdup_printf ("%d %s", design_capacity, unit);
-	
-	label = gtk_label_new (str);
-	g_free (str);
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	
-	gtk_table_attach(GTK_TABLE(table), align,
-			 1, 2, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-			 2, 8);
-	i++;
-    }
-    
-    
-    if ( last_full != 0 )
-    {
-    	label = gtk_label_new (_("Last full:"));
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-    	gtk_widget_modify_font (label, pfd);
-    
-    	gtk_table_attach(GTK_TABLE(table), align,
-			 0, 1, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-		     	 2, 8);
-			 
-	str = g_strdup_printf ("%d %s", last_full, unit);
-	label = gtk_label_new (str);
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	g_free (str);
-	gtk_table_attach(GTK_TABLE(table), align,
-			 1, 2, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-		     	 2, 8);
-    	i++;
-    }
-    
-    if ( vendor )
-    {
-    	label = gtk_label_new (_("Vendor:"));
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	gtk_widget_modify_font (label, pfd);
-	
-	gtk_table_attach(GTK_TABLE(table), align,
-			 0, 1, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-			 2, 8);
-	
-	label = gtk_label_new (vendor);
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	g_free (vendor);
-	gtk_table_attach(GTK_TABLE(table), align,
-			 1, 2, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-		     	 2, 8);
-	i++;
-    }
-    
-     
-    if ( model )
-    {
-    	label = gtk_label_new (_("Model:"));
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	gtk_widget_modify_font (label, pfd);
-	
-	gtk_table_attach(GTK_TABLE(table), align,
-			 0, 1, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-			 2, 8);
-	
-	label = gtk_label_new (model);
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	g_free (model);
-	gtk_table_attach(GTK_TABLE(table), align,
-			 1, 2, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-		     	 2, 8);
-	i++;
-    }
-    
-    if ( unit )
-    	g_free(unit);
-	
-    return table;
-}
-
-GtkWidget *xfpm_battery_info_new (HalBattery *device, const gchar *icon_name)
-{
-    GtkWidget *info;
-    GtkWidget *mainbox;
-    GtkWidget *allbox;
-    
-    info = xfce_titled_dialog_new_with_buttons(_("Battery information"),
-					       NULL,
-                                               GTK_DIALOG_DESTROY_WITH_PARENT,
-                                               GTK_STOCK_CLOSE,
-                                               GTK_RESPONSE_CANCEL,
-					       NULL);
-					       
-    gtk_window_set_icon_name (GTK_WINDOW(info), icon_name);
-    gtk_dialog_set_default_response (GTK_DIALOG(info), GTK_RESPONSE_CLOSE);
-    
-    mainbox = GTK_DIALOG (info)->vbox;
-    
-    allbox = gtk_vbox_new (FALSE, 0);
-    gtk_box_pack_start (GTK_BOX(mainbox), allbox, TRUE, TRUE, 0);
-    
-    gtk_box_pack_start (GTK_BOX (allbox), xfpm_battery_info(device), FALSE, FALSE, 8);
-    
-    g_signal_connect (info, "response", G_CALLBACK(gtk_widget_destroy), NULL);
-    
-    return info;
-}
diff --git a/src/xfpm-battery-info.h b/src/xfpm-battery-info.h
deleted file mode 100644
index 766a750..0000000
--- a/src/xfpm-battery-info.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * * Copyright (C) 2008-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_BATTERY_INFO_H
-#define __XFPM_BATTERY_INFO_H
-
-#include <gtk/gtk.h>
-#include <glib.h>
-
-#include "libxfpm/hal-battery.h"
-
-G_BEGIN_DECLS
-
-GtkWidget 	*xfpm_battery_info_new 		(HalBattery *device, const gchar *icon_name);
-
-G_END_DECLS
-
-#endif /*__XFPM_BATTERY_INFO_H */
diff --git a/src/xfpm-battery.c b/src/xfpm-battery.c
index a2315ec..e66d14c 100644
--- a/src/xfpm-battery.c
+++ b/src/xfpm-battery.c
@@ -1,5 +1,5 @@
 /*
- * * Copyright (C) 2008 Ali <aliov at xfce.org>
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -26,107 +26,73 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <glib.h>
 #include <gtk/gtk.h>
 
-#include <glib.h>
-
 #include <libxfce4util/libxfce4util.h>
 
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-notify.h"
-#include "libxfpm/xfpm-icons.h"
-
 #include "xfpm-battery.h"
-#include "xfpm-tray-icon.h"
-#include "xfpm-string.h"
-#include "xfpm-marshal.h"
-#include "xfpm-enum-types.h"
-#include "xfpm-enum.h"
-#include "xfpm-battery-info.h"
+#include "xfpm-dbus.h"
+#include "xfpm-icons.h"
 #include "xfpm-xfconf.h"
+#include "xfpm-notify.h"
 #include "xfpm-config.h"
-#include "xfpm-adapter.h"
+#include "xfpm-enum-glib.h"
+#include "xfpm-enum-types.h"
 #include "xfpm-debug.h"
+#include "xfpm-common.h"
 
 static void xfpm_battery_finalize   (GObject *object);
 
 #define XFPM_BATTERY_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_BATTERY, XfpmBatteryPrivate))
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_BATTERY, XfpmBatteryPrivate))
 
 struct XfpmBatteryPrivate
 {
-    XfpmTrayIcon    *icon;
-    XfpmAdapter     *adapter;
-    HalBattery      *device;
-    XfpmXfconf      *conf;
-    XfpmNotify      *notify;
-
-    HalDeviceType    type;
-    gchar 	    *icon_prefix;
-    
-    gboolean         adapter_present;
-    XfpmBatteryState state;
-    
-    gulong	     sig_1;
-    gulong           sig_2;
-    gulong           sig_3;
+    XfpmXfconf             *conf;
+    XfpmNotify		   *notify;
+    DBusGProxy             *proxy;
+    DBusGProxy 		   *proxy_prop;
+    
+    gchar		   *icon_prefix;
+    
+    XfpmDkpDeviceState      state;
+    XfpmDkpDeviceType       type;
+    gboolean		    ac_online;
+    gboolean                present;
+    gint 		    percentage;
+    gint64		    time_to_full;
+    gint64		    time_to_empty;
+    
+    gulong		    sig;
 };
 
 enum
 {
-    BATTERY_STATE_CHANGED,
-    LAST_SIGNAL
+    PROP_0,
+    PROP_AC_ONLINE
 };
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmBattery, xfpm_battery, G_TYPE_OBJECT)
+    
+G_DEFINE_TYPE (XfpmBattery, xfpm_battery, GTK_TYPE_STATUS_ICON)
 
 static const gchar * G_GNUC_CONST
-xfpm_battery_get_icon_index (HalDeviceType type, guint percent)
+xfpm_battery_get_icon_index (XfpmDkpDeviceType type, guint percent)
 {
     if (percent < 10) {
-	return "000";
+        return "000";
     } else if (percent < 30) {
-	return (type == HAL_DEVICE_TYPE_PRIMARY || type == HAL_DEVICE_TYPE_UPS ? "020" : "030");
+        return ( (type == XFPM_DKP_DEVICE_TYPE_BATTERY || type == XFPM_DKP_DEVICE_TYPE_UPS) ? "020" : "030");
     } else if (percent < 50) {
-	return (type == HAL_DEVICE_TYPE_PRIMARY || type == HAL_DEVICE_TYPE_UPS ? "040" : "030");
+        return ( (type == XFPM_DKP_DEVICE_TYPE_BATTERY || type == XFPM_DKP_DEVICE_TYPE_UPS ) ? "040" : "030");
     } else if (percent < 70) {
-	return "060";
+        return "060";
     } else if (percent < 90) {
-	return (type == HAL_DEVICE_TYPE_PRIMARY || type == HAL_DEVICE_TYPE_UPS ? "080" : "060");
+        return ((type == XFPM_DKP_DEVICE_TYPE_BATTERY || type == XFPM_DKP_DEVICE_TYPE_UPS) ? "080" : "060");
     }
     return "100";
 }
 
-static const gchar * G_GNUC_CONST
-xfpm_battery_get_message_from_battery_state (XfpmBatteryState state, gboolean adapter_present)
-{
-    switch (state)
-    {
-	case BATTERY_FULLY_CHARGED:
-	    return _("Your battery is fully charged");
-	    break;
-	case BATTERY_NOT_FULLY_CHARGED:
-	    return _("Your battery is charging");
-	    break;
-	case BATTERY_IS_CHARGING:
-	    return  _("Battery is charging");
-	    break;
-	case BATTERY_IS_DISCHARGING:
-	    return  adapter_present ? _("Your battery is discharging"): _("System is running on battery power");
-	    break;
-	case BATTERY_CHARGE_LOW:
-	    return adapter_present ? _("Your battery charge is low") : _("System is running on low power"); 
-	    break;
-	default:
-	    return NULL;
-    }
-}
-
 static void
-xfpm_battery_refresh_visible_icon (XfpmBattery *battery)
+xfpm_battery_refresh_visible (XfpmBattery *battery)
 {
     XfpmShowIcon show_icon;
     gboolean visible = TRUE;
@@ -141,96 +107,95 @@ xfpm_battery_refresh_visible_icon (XfpmBattery *battery)
 	visible = FALSE;
     else if ( show_icon == SHOW_ICON_WHEN_BATTERY_PRESENT )
     {
-	if ( battery->priv->state == BATTERY_NOT_PRESENT )
-	    visible = FALSE;
-	else visible = TRUE;
+	if ( battery->priv->present )
+	    visible = TRUE;
+	else visible = FALSE;
     }
     else if ( show_icon == SHOW_ICON_WHEN_BATTERY_CHARGING_DISCHARGING )
     {
-	if ( battery->priv->state == BATTERY_FULLY_CHARGED )
+	if ( battery->priv->state == XFPM_DKP_DEVICE_STATE_FULLY_CHARGED )
 	    visible = FALSE;
 	else visible = TRUE;
     }
 
     XFPM_DEBUG_ENUM ("Tray icon configuration: ", show_icon, XFPM_TYPE_SHOW_ICON);
-    XFPM_DEBUG_ENUM_FULL (battery->priv->state, XFPM_TYPE_BATTERY_STATE, " setting tray icon visible %s", 
-			  xfpm_bool_to_string (visible));
-    xfpm_tray_icon_set_visible (battery->priv->icon, visible);
+			  
+    gtk_status_icon_set_visible (GTK_STATUS_ICON (battery), visible);
 }
-    
-static void
-xfpm_battery_refresh_icon (XfpmBattery *battery, 
-			   XfpmBatteryState state,
-			   guint percentage)
-{
-    gchar *icon;
 
-    if ( state == BATTERY_NOT_PRESENT )
+
+static const gchar * G_GNUC_CONST
+xfpm_battery_get_message_from_battery_state (XfpmDkpDeviceState state, gboolean ac_online)
+{
+    switch (state)
     {
-	xfpm_tray_icon_set_icon (battery->priv->icon, 
-				 battery->priv->type == HAL_DEVICE_TYPE_UPS ? 
-				 XFPM_UPS_ICON_PREFIX "missing" : 
-				 XFPM_PRIMARY_ICON_PREFIX "missing");
-	return;
+	case XFPM_DKP_DEVICE_STATE_FULLY_CHARGED:
+	    return _("Your battery is fully charged");
+	    break;
+	case XFPM_DKP_DEVICE_STATE_CHARGING:
+	    return  _("Your battery is charging");
+	    break;
+	case XFPM_DKP_DEVICE_STATE_DISCHARGING:
+	    return  ac_online ? _("Your battery is discharging"): _("System is running on battery power");
+	    break;
+	default:
+	    return NULL;
     }
+}
+
+static void
+xfpm_battery_refresh_icon (XfpmBattery *battery)
+{
+    gchar icon_name[128];
     
-    /* Battery full */
-    if ( state == BATTERY_FULLY_CHARGED )
+    TRACE ("Battery state %d", battery->priv->state);
+    
+    if ( battery->priv->type == XFPM_DKP_DEVICE_TYPE_BATTERY || 
+	 battery->priv->type == XFPM_DKP_DEVICE_TYPE_UPS )
     {
-	if ( battery->priv->type == HAL_DEVICE_TYPE_PRIMARY)
-	    xfpm_tray_icon_set_icon (battery->priv->icon, 
-				     battery->priv->adapter_present ? 
-				     XFPM_PRIMARY_ICON_PREFIX "charged" : 
-				     XFPM_PRIMARY_ICON_PREFIX "100");
-	else
+	if (!battery->priv->present)
 	{
-	    icon = g_strdup_printf("%s%s", 
-	    		           battery->priv->icon_prefix, 
-	    			   xfpm_battery_get_icon_index (battery->priv->type, percentage));
-	    xfpm_tray_icon_set_icon (battery->priv->icon, icon);
-	    g_free(icon);
+	    g_snprintf (icon_name, 128, "%s%s", battery->priv->icon_prefix, "missing");
 	}
-    }
-    else if ( state == BATTERY_NOT_FULLY_CHARGED )
-    {
-	if ( battery->priv->adapter_present )
+	else if (battery->priv->state == XFPM_DKP_DEVICE_STATE_FULLY_CHARGED )
 	{
-	    icon = g_strdup_printf("%s%s-%s",
-			      battery->priv->icon_prefix, 
-			      xfpm_battery_get_icon_index (battery->priv->type, percentage),
-			      "charging");
+	    g_snprintf (icon_name, 128, "%s%s", battery->priv->icon_prefix, battery->priv->ac_online ? "charged" : "100");
 	}
-	else
+	else if ( battery->priv->state == XFPM_DKP_DEVICE_STATE_CHARGING || 
+		  battery->priv->state == XFPM_DKP_DEVICE_STATE_PENDING_CHARGING)
 	{
-	    icon = g_strdup_printf("%s%s",
-			      battery->priv->icon_prefix, 
-			      xfpm_battery_get_icon_index (battery->priv->type, percentage));
+	    g_snprintf (icon_name, 128, "%s%s-%s", 
+			battery->priv->icon_prefix, 
+			xfpm_battery_get_icon_index (battery->priv->type, battery->priv->percentage),
+			"charging");
+	}
+	else if ( battery->priv->state == XFPM_DKP_DEVICE_STATE_DISCHARGING ||
+		  battery->priv->state == XFPM_DKP_DEVICE_STATE_PENDING_DISCHARGING)
+	{
+	    g_snprintf (icon_name, 128, "%s%s", 
+			battery->priv->icon_prefix, 
+			xfpm_battery_get_icon_index (battery->priv->type, battery->priv->percentage));
 	}
-	xfpm_tray_icon_set_icon (battery->priv->icon, icon);
-	g_free(icon);
-	
-    }
-    else if ( state == BATTERY_IS_CHARGING )
-    {
-	icon = g_strdup_printf("%s%s-%s",
-			      battery->priv->icon_prefix, 
-			      xfpm_battery_get_icon_index (battery->priv->type, percentage),
-			      "charging");
-				      
-	xfpm_tray_icon_set_icon (battery->priv->icon, icon);
-	g_free(icon);
     }
-    else if ( state == BATTERY_IS_DISCHARGING || state == BATTERY_CHARGE_CRITICAL ||
-	      state == BATTERY_CHARGE_LOW )
+    else
     {
-	icon = g_strdup_printf("%s%s",
-			      battery->priv->icon_prefix, 
-			      xfpm_battery_get_icon_index (battery->priv->type, percentage));
-				      
-	xfpm_tray_icon_set_icon (battery->priv->icon, icon);
-	g_free(icon);
-	
+	if ( !battery->priv->present )
+	{
+	    g_snprintf (icon_name, 128, "%s-000", battery->priv->icon_prefix);
+	}
+	else if ( battery->priv->state == XFPM_DKP_DEVICE_STATE_FULLY_CHARGED )
+	{
+	    g_snprintf (icon_name, 128, "%s-100", battery->priv->icon_prefix);
+	}
+	else if ( battery->priv->state == XFPM_DKP_DEVICE_STATE_DISCHARGING )
+	{
+	    g_snprintf (icon_name, 128, "%s-%s", 
+			battery->priv->icon_prefix, 
+			xfpm_battery_get_icon_index (battery->priv->type, battery->priv->percentage));
+	}
     }
+    
+    gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (battery), icon_name);
 }
 
 static gboolean
@@ -241,496 +206,464 @@ xfpm_battery_notify_idle (gpointer data)
     
     battery = XFPM_BATTERY (data);
     
-    message = xfpm_battery_get_message_from_battery_state (battery->priv->state, battery->priv->adapter_present);
+    message = xfpm_battery_get_message_from_battery_state (battery->priv->state, battery->priv->ac_online);
+    
     if ( !message )
 	return FALSE;
 	
     xfpm_notify_show_notification (battery->priv->notify, 
-				    _("Xfce power manager"), 
-				    message, 
-				    xfpm_tray_icon_get_icon_name (battery->priv->icon),
-				    8000,
-				    battery->priv->type == HAL_DEVICE_TYPE_PRIMARY ? FALSE : TRUE,
-				    XFPM_NOTIFY_NORMAL,
-				    xfpm_tray_icon_get_tray_icon(battery->priv->icon));
+				   _("Xfce power manager"), 
+				   message, 
+				   gtk_status_icon_get_icon_name (GTK_STATUS_ICON (battery)),
+				   8000,
+				   FALSE,
+				   XFPM_NOTIFY_NORMAL,
+				   GTK_STATUS_ICON (battery));
     
     return FALSE;
 }
 
 static void
-xfpm_battery_notify (XfpmBattery *battery)
+xfpm_battery_notify_state (XfpmBattery *battery)
 {
     gboolean notify;
     static gboolean starting_up = TRUE;
-
-    if ( starting_up )
-    {
-	starting_up = FALSE;
+    
+    if ( !gtk_status_icon_get_visible (GTK_STATUS_ICON (battery)) )
 	return;
-    }
-
-    g_object_get (G_OBJECT (battery->priv->conf),
-		  GENERAL_NOTIFICATION_CFG, &notify,
-		  NULL);
-		  
-    if ( notify )
+    
+    if ( battery->priv->type == XFPM_DKP_DEVICE_TYPE_BATTERY ||
+	 battery->priv->type == XFPM_DKP_DEVICE_TYPE_UPS )
     {
-	g_idle_add ((GSourceFunc) xfpm_battery_notify_idle, battery);
+	if ( starting_up )
+	{
+	    starting_up = FALSE;
+	    return;
+	}
+    
+	g_object_get (G_OBJECT (battery->priv->conf),
+		      GENERAL_NOTIFICATION_CFG, &notify,
+		      NULL);
+		      
+	if ( notify )
+	{
+	    g_idle_add ((GSourceFunc) xfpm_battery_notify_idle, battery);
+	}
     }
 }
 
-static const gchar * G_GNUC_CONST
-_get_battery_name (HalDeviceType type)
+/*
+ * Taken from gpm
+ */
+static gchar *
+xfpm_battery_get_time_string (guint seconds)
 {
-    if ( type ==  HAL_DEVICE_TYPE_UPS)
-	return _("Your UPS");
-    else if ( type == HAL_DEVICE_TYPE_MOUSE )
-	return _("Your Mouse battery");
-    else if ( type == HAL_DEVICE_TYPE_KEYBOARD )
-	return _("Your Keyboard battery");
-    else if ( type ==  HAL_DEVICE_TYPE_CAMERA )
-	return _("Your Camera battery");
-    else if ( type == HAL_DEVICE_TYPE_PDA)
-	return _("Your PDA battery");
-	
-    return _("Your Battery");
-}
+    char* timestring = NULL;
+    gint  hours;
+    gint  minutes;
 
-static const gchar * G_GNUC_PURE
-xfpm_battery_get_battery_state (XfpmBatteryState *state, 
-				gboolean is_charging, 
-				gboolean is_discharging,
-				guint32 last_full, 
-				guint32 current_charge, 
-				guint percentage,
-				guint8 critical_level)
-{
-    if ( G_UNLIKELY (current_charge == 0 || percentage == 0) )
+    /* Add 0.5 to do rounding */
+    minutes = (int) ( ( seconds / 60.0 ) + 0.5 );
+
+    if (minutes == 0) 
     {
-	*state = BATTERY_CHARGE_CRITICAL;
-	return _("is empty");
+	timestring = g_strdup (_("Unknown time"));
+	return timestring;
     }
-    
-    if ( !is_charging && !is_discharging &&  current_charge >= last_full )
+
+    if (minutes < 60) 
     {
-	*state = BATTERY_FULLY_CHARGED;
-	return _("is fully charged");
+	timestring = g_strdup_printf (ngettext ("%i minute",
+			              "%i minutes",
+				      minutes), minutes);
+	return timestring;
     }
-    else if ( !is_charging && !is_discharging && last_full != current_charge )
+
+    hours = minutes / 60;
+    minutes = minutes % 60;
+
+    if (minutes == 0)
+	timestring = g_strdup_printf (ngettext (
+			    "%i hour",
+			    "%i hours",
+			    hours), hours);
+    else
+	/* TRANSLATOR: "%i %s %i %s" are "%i hours %i minutes"
+	 * Swap order with "%2$s %2$i %1$s %1$i if needed */
+	timestring = g_strdup_printf (_("%i %s %i %s"),
+			    hours, ngettext ("hour", "hours", hours),
+			    minutes, ngettext ("minute", "minutes", minutes));
+    return timestring;
+}
+
+/*
+ * Refresh tooltip function for UPS and battery device only.
+ */
+static void
+xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip)
+{
+    const gchar *battery_name;
+    gchar *tip = NULL;
+    gchar *est_time_str = NULL;
+    gchar *power_status = NULL;
+    
+    power_status = g_strdup_printf (battery->priv->ac_online ? _("Adaptor is online") : _("System is running on battery power"));
+    
+    battery_name = battery->priv->type == XFPM_DKP_DEVICE_TYPE_BATTERY ? _("Battery") : _("UPS");
+    
+    if ( battery->priv->state == XFPM_DKP_DEVICE_STATE_FULLY_CHARGED )
     {
-	*state = BATTERY_NOT_FULLY_CHARGED;
-	return _("charge level");
+	if ( battery->priv->time_to_empty > 0 )
+	{
+	    est_time_str = xfpm_battery_get_time_string (battery->priv->time_to_empty);
+	    tip = g_strdup_printf (_("%s.\n(%i%%), Your %s is fully charged.\nProvides %s runtime"), 
+				   power_status,
+				   battery->priv->percentage, battery_name, est_time_str);
+	    g_free (est_time_str);
+	}
+	else
+	{
+	    tip = g_strdup_printf (_("%s.\n(%i%%), Your %s is fully charged."), 
+				  power_status,
+				  battery->priv->percentage, battery_name);
+	}
     }
-    else if ( is_charging && !is_discharging )
+    else if ( battery->priv->state == XFPM_DKP_DEVICE_STATE_CHARGING )
     {
-	*state = BATTERY_IS_CHARGING;
-	return  _("is charging");
+	if ( battery->priv->time_to_full != 0 )
+	{
+	    est_time_str = xfpm_battery_get_time_string (battery->priv->time_to_full);
+	    tip = g_strdup_printf (_("%s.\n(%i%%), Your %s is charging.\n%s until is fully charged."), 
+				    power_status,
+				   battery->priv->percentage, battery_name, est_time_str);
+	    g_free (est_time_str);
+	}
+	else
+	{
+	    tip = g_strdup_printf (_("%s.\n(%i%%), Your %s is charging."),
+				   power_status,
+				   battery->priv->percentage, 
+				   battery_name);
+	}
     }
-    else if ( !is_charging && is_discharging )
+    else if ( battery->priv->state == XFPM_DKP_DEVICE_STATE_DISCHARGING )
     {
-	if ( percentage >= 30 )
+	if ( battery->priv->time_to_empty != 0 )
 	{
-	    *state = BATTERY_IS_DISCHARGING;
-	    return  _("is discharging");
+	    est_time_str = xfpm_battery_get_time_string (battery->priv->time_to_empty);
+	    tip = g_strdup_printf (_("%s.\n(%i%%), Your %s is discharging.\n%s left."), 
+				   power_status,
+				   battery->priv->percentage, battery_name, est_time_str);
+	    g_free (est_time_str);
 	}
-	else if ( percentage >= critical_level && percentage < 30)
+	else
 	{
-	    *state = BATTERY_CHARGE_LOW;
-	    return  _("charge is low");
+	    tip = g_strdup_printf (_("%s.\n(%i%%), Your %s is discharging."),
+				   power_status,
+				   battery->priv->percentage,
+				   battery_name);
 	}
-	else if ( percentage < critical_level )
-	{
-	    *state = BATTERY_CHARGE_CRITICAL;
-	    return _("is almost empty");
-    	}
+	
+    }
+    else if ( battery->priv->state == XFPM_DKP_DEVICE_STATE_PENDING_CHARGING )
+    {
+	tip = g_strdup_printf (_("%s.\n%s waiting to discharge (%i%%)"), power_status, battery_name, battery->priv->percentage);
+    }
+    else if ( battery->priv->state == XFPM_DKP_DEVICE_STATE_PENDING_DISCHARGING )
+    {
+	tip = g_strdup_printf (_("%s.\n%s waiting to charge (%i%%)"), power_status, battery_name, battery->priv->percentage);
+    }
+    else if ( battery->priv->state == XFPM_DKP_DEVICE_STATE_EMPTY )
+    {
+	tip = g_strdup_printf (_("%s.\nYour %s is empty"), power_status, battery_name);
     }
     
-    g_warn_if_reached ();
+    gtk_tooltip_set_text (tooltip, tip);
+    gtk_tooltip_set_icon_from_icon_name (tooltip, 
+					 gtk_status_icon_get_icon_name (GTK_STATUS_ICON (battery)),
+					 GTK_ICON_SIZE_BUTTON);
+					 
     
-    return "";
+    g_free (power_status);
+    g_free (tip);
 }
 
 static void
-xfpm_battery_refresh_common (XfpmBattery *battery, guint percentage, XfpmBatteryState state)
+xfpm_battery_refresh (XfpmBattery *battery, GHashTable *props)
 {
-    XfpmShowIcon show_icon;
+    GValue *value;
+    guint state;
     
-    g_object_get (G_OBJECT (battery->priv->conf),
-		  SHOW_TRAY_ICON_CFG, &show_icon,
-		  NULL);
-
-    if ( show_icon != NEVER_SHOW_ICON )
-	xfpm_battery_refresh_icon (battery, state, percentage);
+    value = g_hash_table_lookup (props, "IsPresent");
     
-    if ( battery->priv->state != state)
+    if ( value == NULL )
     {
-	battery->priv->state = state;
-	XFPM_DEBUG_ENUM ("battery state change", battery->priv->state, XFPM_TYPE_BATTERY_STATE);
-	TRACE("Emitting signal battery state changed");
-	g_signal_emit (G_OBJECT(battery), signals[BATTERY_STATE_CHANGED], 0, state);
-	
-	if ( battery->priv->state != BATTERY_NOT_FULLY_CHARGED && show_icon != NEVER_SHOW_ICON)
-	    xfpm_battery_notify (battery);
-	else
-	    xfpm_notify_close_normal (battery->priv->notify);
+	g_warning ("No 'IsPresent' property found");
+	goto out;
     }
-}
-
-static void
-xfpm_battery_refresh_misc (XfpmBattery *battery, gboolean is_present, 
-			   gboolean is_charging, gboolean is_discharging,
-			   guint32 last_full, guint32 current_charge,
-			   guint percentage, guint time_per)
-{
-    gchar *tip;
-    XfpmBatteryState state;
-    const gchar *str;
-    guint critical_level;
     
-    g_object_get (G_OBJECT (battery->priv->conf),
-		  CRITICAL_POWER_LEVEL, &critical_level,
-		  NULL);
+    battery->priv->present = g_value_get_boolean (value);
+    
+    value = g_hash_table_lookup (props, "State");
     
-    if ( !is_present )
+    if ( value == NULL )
     {
-	tip = g_strdup_printf ("%s %s", _get_battery_name(battery->priv->type), _("is not present"));
-	xfpm_tray_icon_set_tooltip (battery->priv->icon, tip);
-	g_free(tip);
-	battery->priv->state = BATTERY_NOT_PRESENT;
-	return;
+	g_warning ("No 'State' property found");
     }
     
-    state = battery->priv->state;
-    str = xfpm_battery_get_battery_state (&state, is_charging, is_discharging,
-    				          last_full, current_charge, percentage, 
-					  critical_level);
-    tip = g_strdup_printf("%i%% %s %s", percentage, _get_battery_name(battery->priv->type), str);
-    //FIXME: Time for misc batteries
-    xfpm_tray_icon_set_tooltip (battery->priv->icon, tip);
-    g_free (tip);
-    
-    xfpm_battery_refresh_common (battery, percentage, state);
-}
-
-static void
-xfpm_battery_refresh_primary (XfpmBattery *battery, gboolean is_present, 
-			      gboolean is_charging, gboolean is_discharging,
-			      guint32 last_full, guint32 current_charge,
-			      guint percentage, guint time_per)
-{
-    gchar *tip;
-    const gchar *str;
-    guint critical_level;
-
-    XfpmBatteryState state = battery->priv->state;
-    
-    g_object_get (G_OBJECT (battery->priv->conf),
-		  CRITICAL_POWER_LEVEL, &critical_level,
-		  NULL);
-    
-    TRACE ("Start");
-    
-    if ( !is_present )
+    state = g_value_get_uint (value);
+    if ( state != battery->priv->state )
     {
-	xfpm_tray_icon_set_tooltip(battery->priv->icon, _("Battery not present"));
-	battery->priv->state = BATTERY_NOT_PRESENT;
-	return;
+	battery->priv->state = state;
+	xfpm_battery_refresh_visible (battery);
+	xfpm_battery_notify_state (battery);
     }
-
-    str = xfpm_battery_get_battery_state (&state, is_charging, is_discharging,
-					  last_full, current_charge, percentage, critical_level);
     
-    XFPM_DEBUG_ENUM ("battery state", state, XFPM_TYPE_BATTERY_STATE);
+    value = g_hash_table_lookup (props, "Percentage");
     
-    if ( time_per != 0  && time_per <= 28800 /* 8 hours */ && 
-	 state != BATTERY_FULLY_CHARGED && state != BATTERY_NOT_FULLY_CHARGED )
+    if ( value == NULL )
     {
-	gchar *time_str;
-        gchar *tip_no_time;
-	const gchar *est_time;
-	        
-        gint minutes, hours, minutes_left;
-       	hours = time_per / 3600;
-		minutes = time_per / 60;
-		minutes_left = minutes % 60;
-
-	tip_no_time = g_strdup_printf ("%i%% %s %s\n%s", 
-			       percentage, 
-			       _("Battery"),
-			       str,
-			       battery->priv->adapter_present ? 
-			       _("System is running on AC power") :
-			       _("System is running on battery power"));
-
-	if ( state == BATTERY_IS_DISCHARGING || 
-	     state == BATTERY_CHARGE_LOW         || 
-	     state == BATTERY_CHARGE_CRITICAL )
-        {
-            est_time = _("Estimated time left");
-        }
-        else //* BATTERY_IS_CHARGING
-        {
-            est_time = _("Estimated time to be fully charged");
-        }
-
-        time_str = g_strdup_printf("%s: %d %s %d %s",est_time,
-                                   hours,hours > 1 ? _("hours") : _("hour") ,
-                                   minutes_left, minutes_left > 1 ? _("minutes") : _("minute"));
-
-	tip = (hours != 0 || minutes_left != 0 ) ? 
-	     g_strdup_printf ("%s\n%s", tip_no_time, time_str) :
-	     g_strdup (tip_no_time);
-	     
-	g_free (tip_no_time);
-	g_free (time_str);
+	g_warning ("No 'Percentage' property found on battery device");
+	goto out;
     }
-    else
+    
+    battery->priv->percentage = (gint) g_value_get_double (value);
+    
+    xfpm_battery_refresh_icon (battery);
+    
+    if ( battery->priv->type == XFPM_DKP_DEVICE_TYPE_BATTERY ||
+	 battery->priv->type == XFPM_DKP_DEVICE_TYPE_UPS )
     {
-	 tip = g_strdup_printf ("%i%% %s %s\n%s", 
-			   percentage, 
-			   _("Battery"),
-			   str, 
-			   battery->priv->adapter_present ? 
-			   _("System is running on AC power") :
-			   _("System is running on battery power"));
+	value = g_hash_table_lookup (props, "TimeToEmpty");
+	
+	if ( value == NULL )
+	{
+	    g_warning ("No 'TimeToEmpty' property found on battery device");
+	    goto out;
+	}
+	
+	battery->priv->time_to_empty = g_value_get_int64 (value);
+	
+	value = g_hash_table_lookup (props, "TimeToFull");
+	
+	if ( value == NULL )
+	{
+	    g_warning ("No 'TimeToFull' property found on battery device");
+	    goto out;
+	}
+	
+	battery->priv->time_to_full = g_value_get_int64 (value);
     }
-
-    xfpm_tray_icon_set_tooltip(battery->priv->icon, tip);
-    g_free(tip);
-
-    xfpm_battery_refresh_common (battery, percentage, state);
+    
+    out:
+	g_hash_table_destroy (props);
 }
 
 static void
-xfpm_battery_refresh (XfpmBattery *battery)
+xfpm_battery_changed_cb (DBusGProxy *proxy, XfpmBattery *battery)
 {
-    gboolean is_present, is_charging, is_discharging = FALSE;
-    guint percentage = 0;
-    guint32 last_full, current_charge = 0;
-    guint time_per = 0;
-    
-    g_object_get (G_OBJECT(battery->priv->device), 
-    		  "is-present", &is_present,
-		  "is-charging", &is_charging,
-		  "is-discharging", &is_discharging, 
-		  "percentage", &percentage,
-		  "last-full", &last_full,
-		  "current-charge", &current_charge,
-		  "time", &time_per,
-		  NULL);
-		  
-    TRACE ("Battery status is_present %s is_charging %s is_discharging %s", 
-	   xfpm_bool_to_string (is_present), 
-	   xfpm_bool_to_string (is_charging), 
-	   xfpm_bool_to_string (is_discharging));
-	   
-    TRACE ("Battery info precentage %i last_full %i current_charge %i time_per %i",
-	   percentage, last_full, current_charge, time_per);
-	   
-    battery->priv->type == HAL_DEVICE_TYPE_PRIMARY ?
-			   xfpm_battery_refresh_primary (battery, is_present, 
-							 is_charging, is_discharging, 
-							 last_full, current_charge,
-							 percentage, time_per)
-  					           :
-			    xfpm_battery_refresh_misc   (battery, is_present, 
-							 is_charging, is_discharging, 
-							 last_full, current_charge,
-							 percentage, time_per);
-							 
-    xfpm_battery_refresh_visible_icon (battery);
+    GHashTable *props;
+    
+    props = xfpm_dbus_get_interface_properties (battery->priv->proxy_prop, DKP_IFACE_DEVICE);
+    
+    if ( props )
+	xfpm_battery_refresh (battery, props);
 }
 
-static void
-xfpm_battery_device_changed_cb (HalBattery *device, XfpmBattery *battery)
+static gboolean
+xfpm_battery_query_tooltip (GtkStatusIcon *icon, 
+			    gint x,
+			    gint y,
+			    gboolean keyboard_mode,
+			    GtkTooltip *tooltip)
 {
-    TRACE("start");
-    xfpm_battery_refresh (battery);
-}
+    XfpmBattery *battery;
+    
+    battery = XFPM_BATTERY (icon);
 
-static gchar *
-_get_icon_prefix_from_enum_type (HalDeviceType type)
-{
-    if ( type == HAL_DEVICE_TYPE_PRIMARY )
-    {
-	return g_strdup (XFPM_PRIMARY_ICON_PREFIX);
-    }
-    else if ( type == HAL_DEVICE_TYPE_UPS ) 
-    {
-	return g_strdup (XFPM_UPS_ICON_PREFIX);
-    }
-    else if ( type == HAL_DEVICE_TYPE_MOUSE ) 
-    {
-	return g_strdup (XFPM_MOUSE_ICON_PREFIX);
-    }
-    else if ( type == HAL_DEVICE_TYPE_KEYBOARD ) 
-    {
-	return g_strdup (XFPM_KBD_ICON_PREFIX);
-    }
-    else if ( type == HAL_DEVICE_TYPE_CAMERA ) 
-    {
-	return g_strdup (XFPM_CAMERA_ICON_PREFIX);
-    }
-    else if ( type == HAL_DEVICE_TYPE_PDA ) 
+    if ( battery->priv->type == XFPM_DKP_DEVICE_TYPE_BATTERY ||
+	 battery->priv->type == XFPM_DKP_DEVICE_TYPE_UPS )
     {
-	return g_strdup (XFPM_PDA_ICON_PREFIX);
-    }
-    else if ( type == HAL_DEVICE_TYPE_KEYBOARD_MOUSE ) 
-    {
-	return g_strdup (XFPM_KBD_MOUSE_ICON_PREFIX);
+	xfpm_battery_set_tooltip_primary (battery, tooltip);
+	return TRUE;
     }
     
-    return g_strdup (XFPM_PRIMARY_ICON_PREFIX);
+    return FALSE;
 }
 
 static void
-xfpm_battery_adapter_changed_cb (XfpmAdapter *adapter, gboolean present, XfpmBattery *battery)
+xfpm_battery_tray_icon_settings_changed (GObject *obj, GParamSpec *spec, XfpmBattery *battery)
 {
-    battery->priv->adapter_present = present;
-    xfpm_battery_refresh (battery);
+    xfpm_battery_refresh_visible (battery);
 }
 
-static void
-xfpm_battery_tray_icon_settings_changed (GObject *obj, GParamSpec *spec, XfpmBattery *battery)
+static void xfpm_battery_get_property (GObject *object,
+				       guint prop_id,
+				       GValue *value,
+				       GParamSpec *pspec)
 {
-    xfpm_battery_refresh_visible_icon (battery);
+    XfpmBattery *battery;
+    
+    battery = XFPM_BATTERY (object);
+    
+    switch (prop_id)
+    {
+	case PROP_AC_ONLINE:
+	    g_value_set_boolean (value, battery->priv->ac_online);
+	    break;
+	default:
+	    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+    }
 }
 
-static void
-xfpm_battery_show_info (XfpmTrayIcon *tray, XfpmBattery *battery)
+static void xfpm_battery_set_property (GObject *object,
+				       guint prop_id,
+				       const GValue *value,
+				       GParamSpec *pspec)
 {
-    gchar *icon = g_strdup_printf("%s%s",
-				  battery->priv->icon_prefix, 
-	    			  xfpm_battery_get_icon_index(battery->priv->type, 100));
-				      
-    GtkWidget *info = xfpm_battery_info_new (battery->priv->device, icon);
+    XfpmBattery *battery;
     
-    g_free (icon);
+    battery = XFPM_BATTERY (object);
     
-    gtk_widget_show_all (info);
+    switch (prop_id)
+    {
+	case PROP_AC_ONLINE:
+	    battery->priv->ac_online = g_value_get_boolean (value);
+	    xfpm_battery_refresh_icon (battery);
+	    break;
+	default:
+	    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+    }
 }
 
+
 static void
-xfpm_battery_class_init(XfpmBatteryClass *klass)
+xfpm_battery_class_init (XfpmBatteryClass *klass)
 {
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    signals[BATTERY_STATE_CHANGED] = 
-    	g_signal_new("battery-state-changed",
-		      XFPM_TYPE_BATTERY,
-		      G_SIGNAL_RUN_LAST,
-		      G_STRUCT_OFFSET(XfpmBatteryClass, battery_state_changed),
-		      NULL, NULL,
-		      g_cclosure_marshal_VOID__ENUM,
-		      G_TYPE_NONE, 1, XFPM_TYPE_BATTERY_STATE);
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    GtkStatusIconClass *status_icon_class = GTK_STATUS_ICON_CLASS (klass);
 
     object_class->finalize = xfpm_battery_finalize;
+    object_class->get_property = xfpm_battery_get_property;
+    object_class->set_property = xfpm_battery_set_property;
+
+    status_icon_class->query_tooltip = xfpm_battery_query_tooltip;
     
-    g_type_class_add_private(klass,sizeof(XfpmBatteryPrivate));
+    g_object_class_install_property (object_class,
+                                     PROP_AC_ONLINE,
+                                     g_param_spec_boolean("ac-online",
+                                                          NULL, NULL,
+                                                          FALSE,
+                                                          G_PARAM_READWRITE));
+
+    g_type_class_add_private (klass, sizeof (XfpmBatteryPrivate));
 }
 
 static void
-xfpm_battery_init(XfpmBattery *battery)
+xfpm_battery_init (XfpmBattery *battery)
 {
-    battery->priv = XFPM_BATTERY_GET_PRIVATE(battery);
-    
-    battery->priv->icon      = xfpm_tray_icon_new ();
-    battery->priv->adapter   = xfpm_adapter_new ();
-    battery->priv->conf      = xfpm_xfconf_new ();
-    battery->priv->notify    = xfpm_notify_new ();
-    battery->priv->state = BATTERY_STATE_UNKNOWN;
-    battery->priv->icon_prefix = NULL;
-    
-    battery->priv->adapter_present = xfpm_adapter_get_present (battery->priv->adapter);
-    
-    battery->priv->sig_1 = g_signal_connect (battery->priv->adapter ,"adapter-changed",
-					     G_CALLBACK (xfpm_battery_adapter_changed_cb), battery);
-    
-    g_signal_connect (battery->priv->icon, "show-information", 
-		      G_CALLBACK (xfpm_battery_show_info), battery);
+    battery->priv = XFPM_BATTERY_GET_PRIVATE (battery);
+    
+    battery->priv->conf          = xfpm_xfconf_new ();
+    battery->priv->notify        = xfpm_notify_new ();
+    battery->priv->proxy_prop    = NULL;
+    battery->priv->state         = XFPM_DKP_DEVICE_STATE_UNKNOWN;
+    battery->priv->type          = XFPM_DKP_DEVICE_TYPE_UNKNOWN;
+    battery->priv->icon_prefix   = NULL;
+    battery->priv->time_to_full  = 0;
+    battery->priv->time_to_empty = 0;
+    battery->priv->ac_online     = TRUE;
+    
+    battery->priv->sig = g_signal_connect (G_OBJECT (battery->priv->conf), "notify::" SHOW_TRAY_ICON_CFG,
+					   G_CALLBACK (xfpm_battery_tray_icon_settings_changed), battery);
 }
 
 static void
-xfpm_battery_finalize(GObject *object)
+xfpm_battery_finalize (GObject *object)
 {
     XfpmBattery *battery;
-    battery = XFPM_BATTERY(object);
- 
-    if ( g_signal_handler_is_connected (battery->priv->adapter, battery->priv->sig_1 ) )
-	g_signal_handler_disconnect (G_OBJECT (battery->priv->adapter), battery->priv->sig_1);
-	
-    if ( g_signal_handler_is_connected (battery->priv->conf, battery->priv->sig_2 ) )
-	g_signal_handler_disconnect (G_OBJECT (battery->priv->conf), battery->priv->sig_2);
-	
-     if ( g_signal_handler_is_connected (battery->priv->device, battery->priv->sig_3 ) )
-	g_signal_handler_disconnect (G_OBJECT (battery->priv->device), battery->priv->sig_3);
 
-    g_object_unref (battery->priv->icon);
+    battery = XFPM_BATTERY (object);
     
-    g_object_unref (battery->priv->device);
-	
-    if ( battery->priv->icon_prefix )
-    	g_free(battery->priv->icon_prefix);
-	
-    g_object_unref (battery->priv->adapter);
+    g_free (battery->priv->icon_prefix);
     
+    dbus_g_proxy_disconnect_signal (battery->priv->proxy, "Changed",
+				    G_CALLBACK (xfpm_battery_changed_cb), battery);
+				    
+    if ( g_signal_handler_is_connected (battery->priv->conf, battery->priv->sig ) )
+	g_signal_handler_disconnect (G_OBJECT (battery->priv->conf), battery->priv->sig);
+				    
+    g_object_unref (battery->priv->proxy);
+    g_object_unref (battery->priv->proxy_prop);
     g_object_unref (battery->priv->conf);
-    
     g_object_unref (battery->priv->notify);
 
-    G_OBJECT_CLASS(xfpm_battery_parent_class)->finalize(object);
+    G_OBJECT_CLASS (xfpm_battery_parent_class)->finalize (object);
 }
 
-XfpmBattery *
-xfpm_battery_new(const HalBattery *device)
+static gchar *
+xfpm_battery_get_icon_prefix_device_enum_type (XfpmDkpDeviceType type)
 {
-    XfpmBattery *battery = NULL;
-    
-    battery = g_object_new(XFPM_TYPE_BATTERY, NULL);
-    
-    battery->priv->device = (HalBattery *)g_object_ref(G_OBJECT(device));
-    
-    g_object_get(G_OBJECT(battery->priv->device), "type", &battery->priv->type, NULL);
-    
-    battery->priv->icon_prefix = _get_icon_prefix_from_enum_type(battery->priv->type);
-    
-    xfpm_battery_refresh (battery);
-    
-    battery->priv->sig_3 = g_signal_connect (G_OBJECT(battery->priv->device), "battery-changed",
-					     G_CALLBACK(xfpm_battery_device_changed_cb), battery);
-		      
-    battery->priv->sig_2 = g_signal_connect (G_OBJECT(battery->priv->conf), "notify::" SHOW_TRAY_ICON_CFG,
-					     G_CALLBACK(xfpm_battery_tray_icon_settings_changed), battery);
+    if ( type == XFPM_DKP_DEVICE_TYPE_BATTERY )
+    {
+	return g_strdup (XFPM_PRIMARY_ICON_PREFIX);
+    }
+    else if ( type == XFPM_DKP_DEVICE_TYPE_UPS ) 
+    {
+	return g_strdup (XFPM_UPS_ICON_PREFIX);
+    }
+    else if ( type == XFPM_DKP_DEVICE_TYPE_MOUSE ) 
+    {
+	return g_strdup (XFPM_MOUSE_ICON_PREFIX);
+    }
+    else if ( type == XFPM_DKP_DEVICE_TYPE_KBD ) 
+    {
+	return g_strdup (XFPM_KBD_ICON_PREFIX);
+    }
+    else if ( type == XFPM_DKP_DEVICE_TYPE_PHONE ) 
+    {
+	return g_strdup (XFPM_PHONE_ICON_PREFIX);
+    }
     
-    return battery;
+    return g_strdup (XFPM_PRIMARY_ICON_PREFIX);
 }
 
-const HalBattery*
-xfpm_battery_get_device (XfpmBattery *battery)
+GtkStatusIcon *
+xfpm_battery_new (void)
 {
-    g_return_val_if_fail (XFPM_IS_BATTERY(battery), NULL);
+    XfpmBattery *battery = NULL;
     
-    return battery->priv->device;
-}
-
-XfpmBatteryState xfpm_battery_get_state (XfpmBattery *battery)
-{
-    g_return_val_if_fail (XFPM_IS_BATTERY(battery), BATTERY_NOT_PRESENT);
+    battery = g_object_new (XFPM_TYPE_BATTERY, NULL);
     
-    return battery->priv->state;
+    return GTK_STATUS_ICON (battery);
 }
 
-GtkStatusIcon  *xfpm_battery_get_status_icon    (XfpmBattery *battery)
+void xfpm_battery_monitor_device (XfpmBattery *battery,
+				  DBusGProxy *proxy,
+				  DBusGProxy *proxy_prop,
+				  XfpmDkpDeviceType device_type)
 {
-    g_return_val_if_fail (XFPM_IS_BATTERY(battery), NULL);
-    
-    return xfpm_tray_icon_get_tray_icon (battery->priv->icon);
+    battery->priv->type = device_type;
+    battery->priv->proxy_prop = proxy_prop;
+    battery->priv->proxy = proxy;
+    battery->priv->icon_prefix = xfpm_battery_get_icon_prefix_device_enum_type (device_type);
     
+    dbus_g_proxy_add_signal (proxy, "Changed", G_TYPE_INVALID);
+    dbus_g_proxy_connect_signal (proxy, "Changed",
+				 G_CALLBACK (xfpm_battery_changed_cb), battery, NULL);
+
+    g_object_set (G_OBJECT (battery),
+		  "has-tooltip", TRUE,
+		  NULL);
+
+    xfpm_battery_changed_cb (proxy, battery);
 }
 
-const gchar *xfpm_battery_get_icon_name (XfpmBattery *battery)
+XfpmDkpDeviceType	    xfpm_battery_get_device_type (XfpmBattery *battery)
 {
-    g_return_val_if_fail (XFPM_IS_BATTERY (battery), NULL);
+    g_return_val_if_fail (XFPM_IS_BATTERY (battery), XFPM_DKP_DEVICE_TYPE_UNKNOWN );
     
-    return xfpm_tray_icon_get_icon_name (battery->priv->icon);
+    return battery->priv->type;
 }
diff --git a/src/xfpm-battery.h b/src/xfpm-battery.h
index 02ab5a4..2cd4399 100644
--- a/src/xfpm-battery.h
+++ b/src/xfpm-battery.h
@@ -1,5 +1,5 @@
 /*
- * * Copyright (C) 2008 Ali <aliov at xfce.org>
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -23,46 +23,42 @@
 
 #include <glib-object.h>
 #include <gtk/gtk.h>
+#include <dbus/dbus-glib.h>
 
-#include "libxfpm/hal-battery.h"
-
-#include "xfpm-enum-glib.h"
-#include "xfpm-notify.h"
+#include "xfpm-dkp.h"
 
 G_BEGIN_DECLS
 
 #define XFPM_TYPE_BATTERY        (xfpm_battery_get_type () )
-#define XFPM_BATTERY(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_BATTERY, XfpmBattery))
-#define XFPM_IS_BATTERY(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_BATTERY))
+#define XFPM_BATTERY(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_BATTERY, XfpmBattery))
+#define XFPM_IS_BATTERY(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_BATTERY))
 
 typedef struct XfpmBatteryPrivate XfpmBatteryPrivate;
 
 typedef struct
 {
-    GObject		 parent;
-    XfpmBatteryPrivate	*priv;
+    GtkStatusIcon      	    parent;
+    
+    XfpmBatteryPrivate     *priv;
     
 } XfpmBattery;
 
 typedef struct
 {
-    GObjectClass         parent_class;
+    GtkStatusIconClass 	    parent_class;
     
-    void	        (*battery_state_changed)	(XfpmBattery *battery,
-    					            	 XfpmBatteryState state);
-       
 } XfpmBatteryClass;
 
-GType        		 xfpm_battery_get_type           (void) G_GNUC_CONST;
-XfpmBattery    		*xfpm_battery_new                (const HalBattery *device);
-
-const HalBattery	*xfpm_battery_get_device         (XfpmBattery *battery) G_GNUC_PURE;
+GType        		    xfpm_battery_get_type        (void) G_GNUC_CONST;
 
-XfpmBatteryState         xfpm_battery_get_state          (XfpmBattery *battery) G_GNUC_PURE;
+GtkStatusIcon              *xfpm_battery_new             (void);
 
-GtkStatusIcon  		*xfpm_battery_get_status_icon    (XfpmBattery *battery);
+void			    xfpm_battery_monitor_device  (XfpmBattery *battery,
+							  DBusGProxy *proxy,
+							  DBusGProxy *proxy_prop,
+							  XfpmDkpDeviceType device_type);
 
-const gchar    		*xfpm_battery_get_icon_name      (XfpmBattery *battery) G_GNUC_PURE;
+XfpmDkpDeviceType	    xfpm_battery_get_device_type (XfpmBattery *battery);
 
 G_END_DECLS
 
diff --git a/src/xfpm-brightness-hal.c b/src/xfpm-brightness-hal.c
deleted file mode 100644
index 0728428..0000000
--- a/src/xfpm-brightness-hal.c
+++ /dev/null
@@ -1,594 +0,0 @@
-/*
- * * Copyright (C) 2008-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 <dbus/dbus-glib.h>
-
-#include <libxfce4util/libxfce4util.h>
-#include <xfconf/xfconf.h>
-
-#include "libxfpm/hal-manager.h"
-#include "libxfpm/hal-device.h"
-#include "libxfpm/xfpm-string.h"
-
-#include "xfpm-brightness-hal.h"
-#include "xfpm-button.h"
-#include "xfpm-enum-glib.h"
-#include "xfpm-xfconf.h"
-#include "xfpm-idle.h"
-#include "xfpm-config.h"
-#include "xfpm-adapter.h"
-#include "xfpm-screen-saver.h"
-
-static void xfpm_brightness_hal_finalize   (GObject *object);
-
-#define XFPM_BRIGHTNESS_HAL_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_BRIGHTNESS_HAL, XfpmBrightnessHalPrivate))
-
-#define ALARM_DISABLED 9
-
-struct XfpmBrightnessHalPrivate
-{
-    DBusGProxy      *proxy;
-    
-    XfpmXfconf      *conf;
-    XfpmIdle        *idle;
-    XfpmButton      *button;
-    XfpmAdapter     *adapter;
-    XfpmScreenSaver *saver;
-    
-    guint           max_level;
-    guint           hw_level;
-    guint           step;
-    gboolean        brightness_in_hw;
-    gboolean        hw_found;
-    gboolean        block;
-    gboolean        inhibited;
-    
-    gboolean        on_battery;
-    
-    gulong	    sig[6];
-};
-
-enum
-{
-    BRIGHTNESS_UP,
-    BRIGHTNESS_DOWN,
-    LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmBrightnessHal, xfpm_brightness_hal, G_TYPE_OBJECT)
-
-static gint 
-xfpm_brightness_hal_get_level (XfpmBrightnessHal *brg, GError **error)
-{
-    gint level = 0;
-    gboolean ret = FALSE;
-    
-    ret = dbus_g_proxy_call (brg->priv->proxy, "GetBrightness", error,
-	 		     G_TYPE_INVALID,
-			     G_TYPE_INT, &level,
-			     G_TYPE_INVALID);
-
-    if (!ret)
-    {
-	g_warning("GetBrightness failed\n");
-    }
-    return level;
-}
-
-static gboolean
-xfpm_brightness_hal_set_level (XfpmBrightnessHal *brg, gint level)
-{
-    GError *error = NULL;
-    gboolean ret = FALSE;
-    gint dummy;
-    
-    TRACE ("Setting level %d", level);
-    
-    ret = dbus_g_proxy_call (brg->priv->proxy, "SetBrightness", &error,
-			     G_TYPE_INT, level,
-			     G_TYPE_INVALID,
-			     G_TYPE_INT, &dummy, /* Just to avoid a warning! */
-			     G_TYPE_INVALID );
-		       
-    if ( error )
-    {
-	g_critical ("Error setting brightness level: %s\n", error->message);
-	g_error_free (error);
-	return FALSE;
-    }
-    
-    if (!ret)
-    {
-	g_warning("SetBrightness failed\n");
-    }
-    
-    return TRUE;
-}
-
-static void
-xfpm_brightness_hal_set_proxy (XfpmBrightnessHal *brg, const gchar *udi)
-{
-    DBusGConnection *bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
-    
-    brg->priv->hw_found = TRUE;
-    
-    brg->priv->proxy = dbus_g_proxy_new_for_name (bus,
-		   			          "org.freedesktop.Hal",
-						  udi,
-					          "org.freedesktop.Hal.Device.LaptopPanel");
-     
-    if ( !brg->priv->proxy )
-	g_warning ("Unable to get proxy for device %s\n", udi);
-}
-
-static void
-xfpm_brightness_hal_get_device (XfpmBrightnessHal *brg, const gchar *udi)
-{
-    HalDevice *device = hal_device_new ();
-    hal_device_set_udi (device, udi);
-
-    brg->priv->max_level = 
-	hal_device_get_property_int (device, "laptop_panel.num_levels") -1;
-    
-    brg->priv->step = brg->priv->max_level <= 20 ? 1 : brg->priv->max_level / 20;
-    
-    if ( hal_device_has_key (device, "laptop_panel.brightness_in_hardware") )
-	brg->priv->brightness_in_hw = hal_device_get_property_bool (device ,"laptop_panel.brightness_in_hardware");
-	
-    TRACE ("laptop_panel.num_levels=%d\n", brg->priv->max_level);
-    
-    g_object_unref (device);
-}
-
-static void
-xfpm_brightness_hal_read_hal_level (XfpmBrightnessHal *brg)
-{
-    GError *error = NULL;
-    
-    brg->priv->hw_level = xfpm_brightness_hal_get_level (brg, &error);
-   
-    if ( error )
-    {
-	g_warning ("Error getting brightness level: %s\n", error->message);
-	g_error_free (error);
-    }
-}
-
-static gboolean
-xfpm_brightness_hal_setup (XfpmBrightnessHal *brg)
-{
-    gchar **udi = NULL;
-
-    HalManager *manager = hal_manager_new ();
-    
-    udi = hal_manager_find_device_by_capability (manager, "laptop_panel");
-    
-    if ( !udi || !udi[0])
-    {
-	g_object_unref ( manager);
-    	return FALSE;
-    }
-	
-    TRACE ("Found laptop_panel with udi=%s\n", udi[0]);
-    xfpm_brightness_hal_get_device (brg, udi[0]);
-    xfpm_brightness_hal_set_proxy (brg, udi[0]);
-
-    xfpm_brightness_hal_read_hal_level (brg);
-    
-    TRACE ("Current hw level =%d\n", brg->priv->hw_level);
-    
-    hal_manager_free_string_array (udi);
-    return TRUE;
-}
-
-static void
-xfpm_brightness_hal_up (XfpmBrightnessHal *brg)
-{
-    gboolean show_popup;
-    gboolean enable_brightness;
-    
-    g_object_get (G_OBJECT (brg->priv->conf),
-		  ENABLE_BRIGHTNESS_CONTROL, &enable_brightness,
-		  SHOW_BRIGHTNESS_POPUP, &show_popup,
-		  NULL);
-    
-    if ( enable_brightness == FALSE || brg->priv->brightness_in_hw)
-	goto signal;
-	
-    if ( brg->priv->hw_level <= brg->priv->max_level -1 )
-    {
-	TRACE ("Brightness key up");
-	xfpm_brightness_hal_set_level (brg, brg->priv->hw_level + brg->priv->step );
-    }
-    
-signal:
-    xfpm_brightness_hal_read_hal_level (brg);
-    
-    if ( show_popup )
-	g_signal_emit (G_OBJECT (brg), signals [BRIGHTNESS_UP], 0, brg->priv->hw_level);
-}
-
-static void
-xfpm_brightness_hal_down (XfpmBrightnessHal *brg)
-{
-    gboolean show_popup, enable_brightness;
-    
-    g_object_get (G_OBJECT (brg->priv->conf),
-		  ENABLE_BRIGHTNESS_CONTROL, &enable_brightness,
-		  SHOW_BRIGHTNESS_POPUP, &show_popup,
-		  NULL);
-    
-    if ( enable_brightness == FALSE || brg->priv->brightness_in_hw)
-	goto signal;
-	
-    if ( brg->priv->hw_level != 0)
-    {
-	TRACE("Brightness key down");
-	xfpm_brightness_hal_set_level (brg, brg->priv->hw_level - brg->priv->step );
-    }
-    
-signal:
-    xfpm_brightness_hal_read_hal_level (brg);
-    
-    if ( show_popup )
-	g_signal_emit (G_OBJECT (brg), signals [BRIGHTNESS_UP], 0, brg->priv->hw_level);
-}
-
-static void
-xfpm_brightness_hal_button_pressed_cb (XfpmButton *button, XfpmButtonKey type, XfpmBrightnessHal *brg)
-{
-    if ( type == BUTTON_MON_BRIGHTNESS_UP )
-    {
-	brg->priv->block = TRUE;
-	xfpm_brightness_hal_up (brg);
-    }
-    else if ( type == BUTTON_MON_BRIGHTNESS_DOWN )
-    {
-	brg->priv->block = TRUE;
-	xfpm_brightness_hal_down (brg);
-    }
-}
-
-static void
-xfpm_brightness_hal_reset_cb (XfpmIdle *idle, XfpmBrightnessHal *brg)
-{
-    GError *error = NULL;
-    guint level;
-    
-    if (brg->priv->block)
-	return;
-    
-    if ( brg->priv->inhibited )
-	return;
-    
-    level = xfpm_brightness_hal_get_level (brg, &error);
-     
-    if ( error )
-    {
-	g_warning ("Error getting brightness level: %s\n", error->message);
-	g_error_free (error);
-	return;
-    }
-     
-    if ( level != brg->priv->hw_level && level != 0)
-    {
-	TRACE("Resetting brightness level to %d", brg->priv->hw_level);
-	xfpm_brightness_hal_set_level(brg, brg->priv->hw_level);
-    }
-}
-
-static void
-xfpm_brightness_timeout_on_ac (XfpmBrightnessHal *brg)
-{
-    GError *error = NULL;
-    guint level;
-    
-    if ( brg->priv->on_battery )
-	    return;
-    
-    level = xfpm_brightness_hal_get_level (brg, &error);
-    
-    brg->priv->hw_level = level;
-    
-    if ( error )
-    {
-	g_warning ("Error getting brightness level: %s\n", error->message);
-	g_error_free (error);
-	return;
-    }
-    
-    if ( level != 0 && level != brg->priv->step )
-    {
-	TRACE ("Reducing brightness, on AC power\n");
-	xfpm_brightness_hal_set_level(brg, brg->priv->step);
-    }
-}
-
-static void
-xfpm_brightness_timeout_on_battery (XfpmBrightnessHal *brg)
-{
-    GError *error = NULL;
-    guint level;
-    
-    if ( !brg->priv->on_battery )
-	    return;
-    
-    level = xfpm_brightness_hal_get_level (brg, &error);
-    
-    brg->priv->hw_level = level;
-    
-    if ( error )
-    {
-	g_warning ("Error getting brightness level: %s\n", error->message);
-	g_error_free (error);
-	return;
-    }
-    
-    if ( level != 0 && level != brg->priv->step )
-    {
-	xfpm_brightness_hal_set_level(brg, brg->priv->step);
-	TRACE ("Reducing brightness, on battery power\n");
-    }
-}
-
-static void
-xfpm_brightness_hal_alarm_timeout_cb (XfpmIdle *idle, guint id, XfpmBrightnessHal *brg)
-{
-    if ( brg->priv->block )
-	brg->priv->block = FALSE;
-    
-    if ( brg->priv->inhibited )
-	return;
-    
-    id == TIMEOUT_BRIGHTNESS_ON_AC ? xfpm_brightness_timeout_on_ac (brg) :
-			     xfpm_brightness_timeout_on_battery (brg);
-}
-
-static void
-xfpm_brightness_hal_adapter_changed_cb (XfpmAdapter *adapter, gboolean present, XfpmBrightnessHal *brg)
-{
-    brg->priv->on_battery = !present;
-}
-
-static void
-xfpm_brightness_hal_inhibit_changed_cb (XfpmScreenSaver *saver, gboolean inhibited, XfpmBrightnessHal *brg)
-{
-    TRACE("Inhibit changed %s", xfpm_bool_to_string (inhibited));
-    brg->priv->inhibited = inhibited;
-}
-
-static void
-xfpm_brightness_get_user_timeouts (XfpmBrightnessHal *brg, guint *timeout_on_ac, guint *timeout_on_battery)
-{
-    g_object_get (G_OBJECT (brg->priv->conf),
-		  BRIGHTNESS_ON_AC, timeout_on_ac,
-		  BRIGHTNESS_ON_BATTERY, timeout_on_battery,
-		  NULL);
-}
-
-static void
-xfpm_brightness_hal_set_timeouts (XfpmBrightnessHal *brg )
-{
-    guint timeout_on_ac, timeout_on_battery ;
-    
-    xfpm_brightness_get_user_timeouts (brg, &timeout_on_ac, &timeout_on_battery);
-    
-    if ( timeout_on_ac == ALARM_DISABLED )
-    {
-	xfpm_idle_free_alarm (brg->priv->idle, TIMEOUT_BRIGHTNESS_ON_AC );
-    }
-    else
-    {
-	xfpm_idle_set_alarm (brg->priv->idle, TIMEOUT_BRIGHTNESS_ON_AC, timeout_on_ac * 1000);
-    }
-    
-    if ( timeout_on_battery == ALARM_DISABLED )
-    {
-	xfpm_idle_free_alarm (brg->priv->idle, TIMEOUT_BRIGHTNESS_ON_BATTERY );
-    }
-    else
-    {
-	xfpm_idle_set_alarm (brg->priv->idle, TIMEOUT_BRIGHTNESS_ON_BATTERY, timeout_on_battery * 1000);
-    }
-    
-    xfpm_idle_alarm_reset_all (brg->priv->idle);
-}
-
-static void
-xfpm_brightness_hal_settings_changed_cb (GObject *objm, GParamSpec *spec, XfpmBrightnessHal *brg)
-{
-    if ( g_str_has_prefix (spec->name, "brightness") )
-    {
-	TRACE ("User settings changed");
-	xfpm_brightness_hal_set_timeouts (brg);
-    }
-}
-
-static void
-xfpm_brightness_hal_class_init(XfpmBrightnessHalClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-     signals [BRIGHTNESS_UP] = 
-        g_signal_new("brigthness-up",
-                      XFPM_TYPE_BRIGHTNESS_HAL,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET (XfpmBrightnessHalClass, brightness_up),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__UINT,
-                      G_TYPE_NONE, 1, G_TYPE_UINT);
-
-    signals [BRIGHTNESS_DOWN] = 
-        g_signal_new("brigthness-down",
-                      XFPM_TYPE_BRIGHTNESS_HAL,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET (XfpmBrightnessHalClass, brightness_down),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__UINT,
-                      G_TYPE_NONE, 1, G_TYPE_UINT);
-
-    object_class->finalize = xfpm_brightness_hal_finalize;
-
-    g_type_class_add_private (klass, sizeof (XfpmBrightnessHalPrivate));
-}
-
-static void
-xfpm_brightness_hal_init(XfpmBrightnessHal *brg)
-{
-    brg->priv = XFPM_BRIGHTNESS_HAL_GET_PRIVATE(brg);
-    
-    brg->priv->proxy    	= NULL;
-    brg->priv->idle             = NULL;
-    brg->priv->hw_found 	= FALSE;
-    brg->priv->on_battery       = FALSE;
-    brg->priv->block            = FALSE;
-    brg->priv->brightness_in_hw = FALSE;
-    brg->priv->max_level        = 0;
-    brg->priv->inhibited        = FALSE;
-    
-    xfpm_brightness_hal_setup (brg);
-
-    if ( brg->priv->hw_found && brg->priv->max_level > 0 )
-    {
-	brg->priv->idle     = xfpm_idle_new ();
-	brg->priv->conf     = xfpm_xfconf_new ();
-	brg->priv->button   = xfpm_button_new ();
-	brg->priv->adapter  = xfpm_adapter_new ();
-	brg->priv->saver    = xfpm_screen_saver_new ();
-	
-	brg->priv->sig[0] =
-	g_signal_connect (brg->priv->saver, "screen-saver-inhibited",
-			  G_CALLBACK(xfpm_brightness_hal_inhibit_changed_cb), brg);
-	
-	brg->priv->on_battery = !xfpm_adapter_get_present (brg->priv->adapter);
-	
-	brg->priv->sig[1] =
-	g_signal_connect (brg->priv->adapter, "adapter-changed",
-			  G_CALLBACK(xfpm_brightness_hal_adapter_changed_cb), brg);
-	
-	brg->priv->sig[2] =
-	g_signal_connect (brg->priv->button, "button-pressed",	
-			  G_CALLBACK(xfpm_brightness_hal_button_pressed_cb), brg);
-	
-	brg->priv->sig[3] =
-	g_signal_connect (brg->priv->idle, "alarm-timeout",
-			  G_CALLBACK(xfpm_brightness_hal_alarm_timeout_cb), brg);
-	
-	brg->priv->sig[4] =
-	g_signal_connect (brg->priv->idle, "reset",
-			  G_CALLBACK(xfpm_brightness_hal_reset_cb), brg);
-			
-	brg->priv->sig[5] =
-	g_signal_connect (brg->priv->conf, "notify", 
-			  G_CALLBACK(xfpm_brightness_hal_settings_changed_cb), brg);
-			  
-	xfpm_brightness_hal_set_timeouts (brg);
-    }
-    else
-    {
-	TRACE("No lcd brightness control found in the system");
-    }
-}
-
-static void
-xfpm_brightness_hal_finalize (GObject *object)
-{
-    XfpmBrightnessHal *brg;
-
-    brg = XFPM_BRIGHTNESS_HAL(object);
-    
-    if ( brg->priv->saver && g_signal_handler_is_connected (brg->priv->saver, brg->priv->sig[0]) )
-	g_signal_handler_disconnect (G_OBJECT (brg->priv->saver), brg->priv->sig[0]);
-    
-    if ( brg->priv->adapter && g_signal_handler_is_connected (brg->priv->adapter, brg->priv->sig[1]) )
-	g_signal_handler_disconnect (G_OBJECT (brg->priv->adapter), brg->priv->sig[1]);
-    
-    if ( brg->priv->button && g_signal_handler_is_connected (brg->priv->button, brg->priv->sig[2]) )
-	g_signal_handler_disconnect (G_OBJECT (brg->priv->button), brg->priv->sig[2]);
-	
-    if ( brg->priv->idle && g_signal_handler_is_connected (brg->priv->idle, brg->priv->sig[3]) )
-	g_signal_handler_disconnect (G_OBJECT (brg->priv->idle), brg->priv->sig[3]);
-	
-    if ( brg->priv->idle && g_signal_handler_is_connected (brg->priv->idle, brg->priv->sig[4]) )
-	g_signal_handler_disconnect (G_OBJECT (brg->priv->idle), brg->priv->sig[4]);
-    
-    if ( brg->priv->conf && g_signal_handler_is_connected (brg->priv->conf, brg->priv->sig[5]) )
-	g_signal_handler_disconnect (G_OBJECT (brg->priv->conf), brg->priv->sig[5]);
-	
-    if ( brg->priv->proxy )
-	g_object_unref (brg->priv->proxy);
-
-    if ( brg->priv->conf )
-	g_object_unref (brg->priv->conf);
-	
-    if ( brg->priv->adapter)
-	g_object_unref (brg->priv->adapter);
-	
-    if ( brg->priv->saver )
-	g_object_unref (brg->priv->saver);
-    
-    if ( 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);
-}
-
-XfpmBrightnessHal *
-xfpm_brightness_hal_new (void)
-{
-    XfpmBrightnessHal *brg = NULL;
-    brg = g_object_new (XFPM_TYPE_BRIGHTNESS_HAL, NULL);
-    return brg;
-}
-
-gboolean xfpm_brightness_hal_has_hw (XfpmBrightnessHal *brg)
-{
-    g_return_val_if_fail (XFPM_IS_BRIGHTNESS_HAL (brg), FALSE);
-    
-    return brg->priv->hw_found;
-}
-
-void xfpm_brightness_hal_update_level (XfpmBrightnessHal *brg, guint level)
-{
-    g_return_if_fail (XFPM_IS_BRIGHTNESS_HAL (brg));
-    
-    brg->priv->hw_level = level;
-}
-
-guint xfpm_brightness_hal_get_max_level (XfpmBrightnessHal *brg)
-{
-    g_return_val_if_fail (XFPM_IS_BRIGHTNESS_HAL (brg), 0);
-    
-    return brg->priv->max_level;
-}
diff --git a/src/xfpm-brightness-hal.h b/src/xfpm-brightness-hal.h
deleted file mode 100644
index b574677..0000000
--- a/src/xfpm-brightness-hal.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * * Copyright (C) 2008-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_BRIGHTNESS_HAL_H
-#define __XFPM_BRIGHTNESS_HAL_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_BRIGHTNESS_HAL        (xfpm_brightness_hal_get_type () )
-#define XFPM_BRIGHTNESS_HAL(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_BRIGHTNESS_HAL, XfpmBrightnessHal))
-#define XFPM_IS_BRIGHTNESS_HAL(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_BRIGHTNESS_HAL))
-
-typedef struct XfpmBrightnessHalPrivate XfpmBrightnessHalPrivate;
-
-typedef struct
-{
-    GObject		 		parent;
-    XfpmBrightnessHalPrivate	       *priv;
-    
-} XfpmBrightnessHal;
-
-typedef struct
-{
-    GObjectClass 			parent_class;
-    
-    void                                (*brightness_up)		    (XfpmBrightnessHal *brg,
-									     guint level);
-									     
-    void                                (*brightness_down)		    (XfpmBrightnessHal *brg,
-									     guint level);
-    
-} XfpmBrightnessHalClass;
-
-GType        				xfpm_brightness_hal_get_type        (void) G_GNUC_CONST;
-XfpmBrightnessHal      		       *xfpm_brightness_hal_new             (void);
-
-gboolean                                xfpm_brightness_hal_has_hw          (XfpmBrightnessHal *brg) G_GNUC_PURE;
-
-void                                    xfpm_brightness_hal_update_level    (XfpmBrightnessHal *brg,
-									     guint level);
-
-guint                                   xfpm_brightness_hal_get_max_level   (XfpmBrightnessHal *brg) G_GNUC_PURE;									     
-G_END_DECLS
-
-#endif /* __XFPM_BRIGHTNESS_HAL_H */
diff --git a/src/xfpm-brightness-widget.c b/src/xfpm-brightness-widget.c
deleted file mode 100644
index 6f90240..0000000
--- a/src/xfpm-brightness-widget.c
+++ /dev/null
@@ -1,352 +0,0 @@
-/* * 
- *  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 <math.h>
-
-#include <gtk/gtk.h>
-#include <glib.h>
-#include <cairo.h>
-
-#include <libnotify/notify.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "libxfpm/xfpm-common.h"
-
-#include "xfpm-brightness-widget.h"
-#include "xfpm-dbus-monitor.h"
-
-static void xfpm_brightness_widget_finalize   (GObject *object);
-
-#define XFPM_BRIGHTNESS_WIDGET_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_BRIGHTNESS_WIDGET, XfpmBrightnessWidgetPrivate))
-
-#define BRIGHTNESS_POPUP_SIZE	180
-
-struct XfpmBrightnessWidgetPrivate
-{
-    XfpmDBusMonitor     *monitor;
-    GtkWidget 		*window;
-    GtkWidget           *progress_bar;
-    
-    guint      		 level;
-    guint      		 max_level;
-    gulong     		 timeout_id;
-    gulong		 destroy_id;
-    
-    gboolean		 check_server_caps;
-    gboolean		 notify_osd;
-    NotifyNotification	*n;
-    
-    gulong		 sig_1;
-};
-
-G_DEFINE_TYPE (XfpmBrightnessWidget, xfpm_brightness_widget, G_TYPE_OBJECT)
-
-static void
-xfpm_brightness_widget_service_connection_changed_cb (XfpmDBusMonitor *monitor, gchar *service_name, 
-						      gboolean connected, gboolean on_session,
-						      XfpmBrightnessWidget *widget)
-{
-    if ( !g_strcmp0 (service_name, "org.freedesktop.Notifications")  && on_session )
-    {
-	if ( connected )
-	    widget->priv->check_server_caps = TRUE;
-	else
-	    widget->priv->notify_osd = FALSE;
-    }
-}
-
-static gboolean
-xfpm_brightness_widget_server_is_notify_osd (void)
-{
-    gboolean supports_sync = FALSE;
-    GList *caps = NULL;
-
-    caps = notify_get_server_caps ();
-    if (caps != NULL) 
-    {
-	if (g_list_find_custom (caps, "x-canonical-private-synchronous", (GCompareFunc) g_strcmp0) != NULL)
-	    supports_sync = TRUE;
-
-	    g_list_foreach(caps, (GFunc)g_free, NULL);
-	    g_list_free(caps);
-    }
-
-    return supports_sync;
-}
-
-static void
-xfpm_brightness_widget_display_notification (XfpmBrightnessWidget *widget)
-{
-    guint i;
-    gfloat value = 0;
-    
-    static const char *display_icon_name[] = 
-    {
-	"notification-display-brightness-off",
-	"notification-display-brightness-low",
-	"notification-display-brightness-medium",
-	"notification-display-brightness-high",
-	"notification-display-brightness-full",
-	NULL
-    };
-    
-    value = (gfloat) 100 * widget->priv->level / widget->priv->max_level;
-    
-    i = (gint)value / 25;
-    
-    notify_notification_set_hint_int32 (widget->priv->n,
-					"value",
-					 value);
-    
-    notify_notification_set_hint_string (widget->priv->n,
-					 "x-canonical-private-synchronous",
-					 "brightness");
-					 
-    notify_notification_update (widget->priv->n,
-			        " ",
-				"",
-				display_icon_name[i]);
-				
-    notify_notification_show (widget->priv->n, NULL);
-}
-
-static gboolean
-xfpm_brightness_widget_timeout (XfpmBrightnessWidget *widget)
-{
-    gtk_widget_hide (widget->priv->window);
-    return FALSE;
-}
-
-static void
-xfpm_brightness_widget_create_popup (XfpmBrightnessWidget *widget)
-{
-    GtkWidget *vbox;
-    GtkWidget *img;
-    GtkWidget *align;
-    GtkObject *adj;
-    
-    if ( widget->priv->window != NULL )
-	return;
-	
-    widget->priv->window = gtk_window_new (GTK_WINDOW_POPUP);
-
-    g_object_set (G_OBJECT (widget->priv->window), 
-		  "window-position", GTK_WIN_POS_CENTER_ALWAYS,
-		  "decorated", FALSE,
-		  "resizable", FALSE,
-		  "type-hint", GDK_WINDOW_TYPE_HINT_UTILITY,
-		  "app-paintable", TRUE,
-		  NULL);
-
-    gtk_window_set_default_size (GTK_WINDOW (widget->priv->window), BRIGHTNESS_POPUP_SIZE, BRIGHTNESS_POPUP_SIZE);
-    
-    align = gtk_alignment_new (0., 0.5, 0, 0);
-    gtk_alignment_set_padding (GTK_ALIGNMENT (align), 5, 5, 5, 5);
-    
-    vbox = gtk_vbox_new (FALSE, 0);
-    
-    gtk_container_add (GTK_CONTAINER (widget->priv->window), align);
-    gtk_container_add (GTK_CONTAINER (align), vbox);
-    
-    img = gtk_image_new_from_icon_name ("xfpm-brightness-lcd", GTK_ICON_SIZE_DIALOG);
-    
-    gtk_box_pack_start (GTK_BOX (vbox), img, TRUE, TRUE, 0);
-    
-    widget->priv->progress_bar = gtk_progress_bar_new ();
-    
-    adj = gtk_adjustment_new (0., 0., widget->priv->max_level, 1., 0., 0.);
-
-    g_object_set (G_OBJECT (widget->priv->progress_bar),
-		  "adjustment", adj,
-		  NULL);
-    
-    gtk_box_pack_start (GTK_BOX (vbox), widget->priv->progress_bar, TRUE, TRUE, 0);
-    
-    gtk_widget_show_all (align);
-}
-
-static void
-xfpm_brightness_widget_create_notification (XfpmBrightnessWidget *widget)
-{
-    if ( widget->priv->n == NULL )
-    {
-	widget->priv->n = notify_notification_new (" ",
-						   "",
-					           NULL,
-					           NULL);
-    }
-}
-
-static gboolean
-xfpm_brightness_widget_destroy (gpointer data)
-{
-    XfpmBrightnessWidget *widget;
-    
-    widget = XFPM_BRIGHTNESS_WIDGET (data);
-    
-    if ( widget->priv->window )
-    {
-	gtk_widget_destroy (widget->priv->window);
-	widget->priv->window = NULL;
-    }
-    
-    
-    if ( widget->priv->n )
-    {
-	g_object_unref (widget->priv->n);
-	widget->priv->n = NULL;
-    }
-    
-    return FALSE;
-}
-
-static void
-xfpm_brightness_widget_class_init (XfpmBrightnessWidgetClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-    object_class->finalize = xfpm_brightness_widget_finalize;
-    
-    g_type_class_add_private (klass, sizeof (XfpmBrightnessWidgetPrivate));
-}
-
-static void
-xfpm_brightness_widget_init (XfpmBrightnessWidget *widget)
-{
-    widget->priv = XFPM_BRIGHTNESS_WIDGET_GET_PRIVATE (widget);
-    
-    widget->priv->monitor = xfpm_dbus_monitor_new ();
-    
-    widget->priv->level  = 0;
-    widget->priv->max_level = 0;
-    widget->priv->timeout_id = 0;
-    widget->priv->destroy_id = 0;
-    widget->priv->notify_osd = FALSE;
-    widget->priv->check_server_caps = TRUE;
-    widget->priv->window = NULL;
-    widget->priv->progress_bar = NULL;
-    widget->priv->n = NULL;
-    
-    xfpm_dbus_monitor_add_service (widget->priv->monitor, 
-				   DBUS_BUS_SESSION,
-				   "org.freedesktop.Notifications");
-    
-    widget->priv->sig_1 = g_signal_connect (widget->priv->monitor, "service-connection-changed",
-					    G_CALLBACK (xfpm_brightness_widget_service_connection_changed_cb),
-					    widget);
-}
-
-static void
-xfpm_brightness_widget_finalize (GObject *object)
-{
-    XfpmBrightnessWidget *widget;
-
-    widget = XFPM_BRIGHTNESS_WIDGET (object);
-    
-    if ( g_signal_handler_is_connected (G_OBJECT (widget->priv->monitor), widget->priv->sig_1) )
-	g_signal_handler_disconnect (G_OBJECT (widget->priv->monitor), widget->priv->sig_1);
-	
-    xfpm_brightness_widget_destroy (widget);
-    
-    g_object_unref (widget->priv->monitor);
-
-    G_OBJECT_CLASS (xfpm_brightness_widget_parent_class)->finalize (object);
-}
-
-static void
-xfpm_brightness_widget_show (XfpmBrightnessWidget *widget)
-{
-    if ( widget->priv->notify_osd )
-    {
-	xfpm_brightness_widget_create_notification (widget);
-	xfpm_brightness_widget_display_notification (widget);
-    }
-    else
-    {
-	GtkAdjustment *adj;
-	
-	xfpm_brightness_widget_create_popup (widget);
-	g_object_get (G_OBJECT (widget->priv->progress_bar),
-		      "adjustment", &adj,
-		      NULL);
-	
-	gtk_adjustment_set_value (adj, widget->priv->level);
-	
-	if ( !GTK_WIDGET_VISIBLE (widget->priv->window))
-	    gtk_window_present (GTK_WINDOW (widget->priv->window));
-	
-	if ( widget->priv->timeout_id != 0 )
-	    g_source_remove (widget->priv->timeout_id);
-	    
-	widget->priv->timeout_id = 
-	    g_timeout_add (900, (GSourceFunc) xfpm_brightness_widget_timeout, widget);
-    }
-    
-    if ( widget->priv->destroy_id != 0 )
-    {
-	g_source_remove (widget->priv->destroy_id);
-	widget->priv->destroy_id = 0;
-    }
-    
-    /* Release the memory after 60 seconds */
-    widget->priv->destroy_id = g_timeout_add_seconds (60, (GSourceFunc) xfpm_brightness_widget_destroy, widget);
-}
-    
-
-XfpmBrightnessWidget *
-xfpm_brightness_widget_new (void)
-{
-    XfpmBrightnessWidget *widget = NULL;
-    widget = g_object_new (XFPM_TYPE_BRIGHTNESS_WIDGET, NULL);
-
-    return widget;
-}
-
-void xfpm_brightness_widget_set_max_level (XfpmBrightnessWidget *widget, guint level)
-{
-    g_return_if_fail (XFPM_IS_BRIGHTNESS_WIDGET (widget));
-
-    widget->priv->max_level = level;
-}
-
-void xfpm_brightness_widget_set_level (XfpmBrightnessWidget *widget, guint level)
-{
-    g_return_if_fail (XFPM_IS_BRIGHTNESS_WIDGET (widget));
-    
-    widget->priv->level = level;
-
-    if ( widget->priv->check_server_caps )
-    {
-	widget->priv->notify_osd = xfpm_brightness_widget_server_is_notify_osd ();
-	widget->priv->check_server_caps = FALSE;
-    }
-    
-    xfpm_brightness_widget_show (widget);
-}
diff --git a/src/xfpm-brightness-widget.h b/src/xfpm-brightness-widget.h
deleted file mode 100644
index 8b861fe..0000000
--- a/src/xfpm-brightness-widget.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* * 
- *  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_BRIGHTNESS_WIDGET_H
-#define __XFPM_BRIGHTNESS_WIDGET_H
-
-#include <gtk/gtk.h>
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_BRIGHTNESS_WIDGET        (xfpm_brightness_widget_get_type () )
-#define XFPM_BRIGHTNESS_WIDGET(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_BRIGHTNESS_WIDGET, XfpmBrightnessWidget))
-#define XFPM_IS_BRIGHTNESS_WIDGET(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_BRIGHTNESS_WIDGET))
-
-typedef struct XfpmBrightnessWidgetPrivate XfpmBrightnessWidgetPrivate;
-
-typedef struct
-{
-    GObject         		     parent;
-    XfpmBrightnessWidgetPrivate     *priv;
-    
-} XfpmBrightnessWidget;
-
-typedef struct
-{
-    GObjectClass 		     parent_class;
-    
-} XfpmBrightnessWidgetClass;
-
-GType        		   	     xfpm_brightness_widget_get_type      (void) G_GNUC_CONST;
-
-XfpmBrightnessWidget   	            *xfpm_brightness_widget_new           (void);
-
-void				     xfpm_brightness_widget_set_max_level (XfpmBrightnessWidget *widget, 
-									   guint level);
-
-void                        	     xfpm_brightness_widget_set_level     (XfpmBrightnessWidget *widget,
-									   guint level);
-
-G_END_DECLS
-
-#endif /* __XFPM_BRIGHTNESS_WIDGET_H */
diff --git a/src/xfpm-button-hal.c b/src/xfpm-button-hal.c
deleted file mode 100644
index db6cbfb..0000000
--- a/src/xfpm-button-hal.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * * 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"
-
-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;
-    guint8 	keys;
-    guint8      mapped_keys;
-};
-
-enum
-{
-    HAL_BUTTON_PRESSED,
-    LID_EVENT,
-    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") )
-    {
-	if ( bt->priv->mapped_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")  || xfpm_strequal (detail, "suspend") ) && !(bt->priv->keys & SLEEP_KEY) )
-    {
-	if ( bt->priv->mapped_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, "hibernate") && !(bt->priv->keys & HIBERNATE_KEY) )
-    {
-	if ( bt->priv->mapped_keys & HIBERNATE_KEY )
-	{
-	    TRACE ("Emitting signal button press condition %s detail %s", condition, detail);
-	    g_signal_emit (G_OBJECT (bt), signals [HAL_BUTTON_PRESSED], 0, BUTTON_HIBERNATE);
-	}
-    }
-    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);
-    
-	    TRACE ("Emitting signal lid event : pressed %s", xfpm_bool_to_string (pressed));
-	    g_signal_emit (G_OBJECT (bt), signals [LID_EVENT], 0, pressed);
-	}
-	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") )
-	{
-	    bt->priv->mapped_keys |= LID_KEY;
-	    g_free (button_type);
-	    goto out;
-	}
-	else
-	{
-	    g_free (button_type);
-	    g_object_unref (device);
-	    return;
-	}
-    }
-    
-    if ( hal_device_has_key (device, "button.type") )
-    {
-	button_type = hal_device_get_property_string (device, "button.type");
-	if ( button_type == NULL ) goto out;
-	
-	if ( xfpm_strequal (button_type, "lid") )
-	    bt->priv->mapped_keys |= LID_KEY;
-	else if ( xfpm_strequal (button_type, "sleep") )
-	    bt->priv->mapped_keys |= SLEEP_KEY;
-	else if ( xfpm_strequal (button_type, "suspend") )
-	    bt->priv->mapped_keys |= SLEEP_KEY;
-	else if ( xfpm_strequal (button_type, "hibernate") )
-	    bt->priv->mapped_keys |= HIBERNATE_KEY;
-	else if ( xfpm_strequal (button_type, "power") )
-	    bt->priv->mapped_keys |= POWER_KEY;
-	    
-	g_free (button_type);
-    }
-    
-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");
-    
-    g_object_unref (manager);
-    
-    if ( udi == NULL || udi[0] == NULL )
-	return;
-	
-    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);
-
-    signals[LID_EVENT] = 
-        g_signal_new("lid-event",
-                      XFPM_TYPE_BUTTON_HAL,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmButtonHalClass, lid_event),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__BOOLEAN,
-                      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-
-    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;
-    button->priv->mapped_keys = 0;
-}
-
-static void
-xfpm_button_hal_free_device_array (XfpmButtonHal *button)
-{
-    HalDevice *device;
-    guint 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_get (void)
-{
-    static gpointer button = NULL;
-    
-    if ( G_LIKELY (button) )
-    {
-	g_object_ref (button);
-    }
-    else
-    {
-	button = g_object_new (XFPM_TYPE_BUTTON_HAL, NULL);
-	g_object_add_weak_pointer (button, &button);
-    }
-	
-    return XFPM_BUTTON_HAL (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);
-}
-
-guint8 xfpm_button_hal_get_mapped_keys (XfpmButtonHal *button)
-{
-    g_return_val_if_fail (XFPM_IS_BUTTON_HAL (button), 0);
-    
-    return button->priv->mapped_keys;
-}
diff --git a/src/xfpm-button-hal.h b/src/xfpm-button-hal.h
deleted file mode 100644
index 2d991f4..0000000
--- a/src/xfpm-button-hal.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * * 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);
-							       
-    void		      (*lid_event)		      (XfpmButtonHal *button,
-							       gboolean pressed);
-    
-} XfpmButtonHalClass;
-
-GType        		      xfpm_button_hal_get_type        (void) G_GNUC_CONST;
-
-XfpmButtonHal       	     *xfpm_button_hal_get             (void);
-
-void                          xfpm_button_hal_get_keys        (XfpmButtonHal *button,
-							       gboolean lid_only,
-							       guint8 buttons);
-							       
-guint8                        xfpm_button_hal_get_mapped_keys (XfpmButtonHal *button) G_GNUC_PURE;
-
-G_END_DECLS
-
-#endif /* __XFPM_BUTTON_HAL_H */
diff --git a/src/xfpm-button-xf86.c b/src/xfpm-button-xf86.c
deleted file mode 100644
index 04f8315..0000000
--- a/src/xfpm-button-xf86.c
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * * Copyright (C) 2008-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
- */
-
-
-/*
- * 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
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <X11/X.h>
-#include <X11/XF86keysym.h>
-
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-
-#include <glib.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "xfpm-button-xf86.h"
-#include "xfpm-enum.h"
-#include "xfpm-enum-types.h"
-#include "xfpm-debug.h"
-
-static void xfpm_button_xf86_finalize   (GObject *object);
-
-#define XFPM_BUTTON_XF86_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_BUTTON_XF86, XfpmButtonXf86Private))
-
-static struct
-{
-    XfpmButtonKey    key;
-    guint            key_code;
-} xfpm_key_map [NUMBER_OF_BUTTONS] = { {0, 0}, };
-
-struct XfpmButtonXf86Private
-{
-    GdkScreen	*screen;
-    GdkWindow   *window;
-    
-    guint8       mapped_buttons;
-};
-
-enum
-{
-    XF86_BUTTON_PRESSED,
-    LAST_SIGNAL
-};
-
-#define DUPLICATE_SHUTDOWN_TIMEOUT 4.0f
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmButtonXf86, xfpm_button_xf86, G_TYPE_OBJECT)
-
-static guint
-xfpm_button_get_key (unsigned int keycode)
-{
-    XfpmButtonKey key = BUTTON_UNKNOWN;
-    guint i;
-    
-    for ( i = 0; i < G_N_ELEMENTS (xfpm_key_map); i++)
-    {
-	if ( xfpm_key_map [i].key_code == keycode )
-	    key = xfpm_key_map [i].key;
-    }
-    
-    return key;
-}
-
-static GdkFilterReturn
-xfpm_button_xf86_filter_x_events (GdkXEvent *xevent, GdkEvent *ev, gpointer data)
-{
-    XfpmButtonKey key;
-    XfpmButtonXf86 *button;
-    
-    XEvent *xev = (XEvent *) xevent;
-    
-    if ( xev->type != KeyPress )
-    	return GDK_FILTER_CONTINUE;
-    
-    key = xfpm_button_get_key (xev->xkey.keycode);
-    
-    if ( key != BUTTON_UNKNOWN )
-    {
-	button = (XfpmButtonXf86 *) data;
-    
-	XFPM_DEBUG_ENUM ("Key press", key, XFPM_TYPE_BUTTON_KEY);
-    
-	g_signal_emit (G_OBJECT(button), signals[XF86_BUTTON_PRESSED], 0, key);
-	return GDK_FILTER_REMOVE;
-    }
-    
-    return GDK_FILTER_CONTINUE;
-}
-
-static gboolean
-xfpm_button_xf86_grab_keystring (XfpmButtonXf86 *button, guint keycode)
-{
-    Display *display;
-    guint ret;
-    guint modmask = 0;
-    
-    display = GDK_DISPLAY ();
-    
-    gdk_error_trap_push ();
-
-    ret = XGrabKey (display, keycode, modmask,
-		    GDK_WINDOW_XID (button->priv->window), True,
-		    GrabModeAsync, GrabModeAsync);
-		    
-    if ( ret == BadAccess )
-    {
-	g_warning ("Failed to grab modmask=%u, keycode=%li",
-		    modmask, (long int) keycode);
-	return FALSE;
-    }
-	
-    ret = XGrabKey (display, keycode, LockMask | modmask,
-		    GDK_WINDOW_XID (button->priv->window), True,
-		    GrabModeAsync, GrabModeAsync);
-			
-    if (ret == BadAccess)
-    {
-	g_warning ("Failed to grab modmask=%u, keycode=%li",
-		   LockMask | modmask, (long int) keycode);
-	return FALSE;
-    }
-
-    gdk_flush ();
-    gdk_error_trap_pop ();
-    return TRUE;
-}
-
-
-static gboolean
-xfpm_button_xf86_xevent_key (XfpmButtonXf86 *button, guint keysym , XfpmButtonKey key)
-{
-    guint keycode = XKeysymToKeycode (GDK_DISPLAY(), keysym);
-
-    if ( keycode == 0 )
-    {
-	g_warning ("could not map keysym %x to keycode\n", keysym);
-	return FALSE;
-    }
-    
-    if ( !xfpm_button_xf86_grab_keystring(button, keycode)) 
-    {
-    	g_warning ("Failed to grab %i\n", keycode);
-	return FALSE;
-    }
-    
-    XFPM_DEBUG_ENUM_FULL (key, XFPM_TYPE_BUTTON_KEY, "Grabbed key %li ", (long int) keycode);
-    
-    xfpm_key_map [key].key_code = keycode;
-    xfpm_key_map [key].key = key;
-    
-    return TRUE;
-}
-
-static void
-xfpm_button_xf86_setup (XfpmButtonXf86 *button)
-{
-    button->priv->screen = gdk_screen_get_default ();
-    button->priv->window = gdk_screen_get_root_window (button->priv->screen);
-    
-    if ( xfpm_button_xf86_xevent_key (button, XF86XK_PowerOff, BUTTON_POWER_OFF) )
-	button->priv->mapped_buttons |= POWER_KEY;
-    
-#ifdef HAVE_XF86XK_HIBERNATE
-    if ( xfpm_button_xf86_xevent_key (button, XF86XK_Hibernate, BUTTON_HIBERNATE) )
-	button->priv->mapped_buttons |= HIBERNATE_KEY;
-#endif 
-
-#ifdef HAVE_XF86XK_SUSPEND
-    if ( xfpm_button_xf86_xevent_key (button, XF86XK_Suspend, BUTTON_HIBERNATE) )
-	button->priv->mapped_buttons |= HIBERNATE_KEY;
-#endif 
-
-    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);
-}
-
-static void
-xfpm_button_xf86_class_init(XfpmButtonXf86Class *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    signals[XF86_BUTTON_PRESSED] = 
-        g_signal_new("xf86-button-pressed",
-                      XFPM_TYPE_BUTTON_XF86,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmButtonXf86Class, xf86_button_pressed),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__ENUM,
-                      G_TYPE_NONE, 1, XFPM_TYPE_BUTTON_KEY);
-
-    object_class->finalize = xfpm_button_xf86_finalize;
-
-    g_type_class_add_private(klass,sizeof(XfpmButtonXf86Private));
-}
-
-static void
-xfpm_button_xf86_init(XfpmButtonXf86 *button)
-{
-    button->priv = XFPM_BUTTON_XF86_GET_PRIVATE(button);
-    
-    button->priv->mapped_buttons = 0;
-    button->priv->screen = NULL;
-    button->priv->window = NULL;
-    
-    xfpm_button_xf86_setup (button);
-}
-
-static void
-xfpm_button_xf86_finalize(GObject *object)
-{
-    XfpmButtonXf86 *button;
-
-    button = XFPM_BUTTON_XF86 (object);
-    
-    G_OBJECT_CLASS(xfpm_button_xf86_parent_class)->finalize(object);
-}
-
-XfpmButtonXf86 *
-xfpm_button_xf86_new(void)
-{
-    XfpmButtonXf86 *button = NULL;
-    button = g_object_new (XFPM_TYPE_BUTTON_XF86, NULL);
-    return button;
-}
-
-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;
-}
diff --git a/src/xfpm-button-xf86.h b/src/xfpm-button-xf86.h
deleted file mode 100644
index f9bc962..0000000
--- a/src/xfpm-button-xf86.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * * Copyright (C) 2008-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_XF86_H
-#define __XFPM_BUTTON_XF86_H
-
-#include <glib-object.h>
-
-#include "xfpm-enum-glib.h"
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_BUTTON_XF86   (xfpm_button_xf86_get_type () )
-#define XFPM_BUTTON_XF86(o)     (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_BUTTON_XF86, XfpmButtonXf86))
-#define XFPM_IS_BUTTON_XF86(o)  (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_BUTTON_XF86))
-
-typedef struct XfpmButtonXf86Private XfpmButtonXf86Private;
-
-typedef struct
-{
-    GObject		  	parent;
-    XfpmButtonXf86Private      *priv;
-    
-} XfpmButtonXf86;
-
-typedef struct
-{
-    GObjectClass 		parent_class;
-     
-    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);
-
-guint8                		xfpm_button_xf86_get_mapped_buttons     (XfpmButtonXf86 *button) G_GNUC_PURE;
-
-G_END_DECLS
-
-#endif /* __XFPM_BUTTON_XF86_H */
diff --git a/src/xfpm-button.c b/src/xfpm-button.c
index 800e8ad..1b10d3d 100644
--- a/src/xfpm-button.c
+++ b/src/xfpm-button.c
@@ -1,5 +1,5 @@
 /*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -18,6 +18,13 @@
  * 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
@@ -26,28 +33,38 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <X11/X.h>
+#include <X11/XF86keysym.h>
+
+#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
+
 #include <glib.h>
 
+#include <libxfce4util/libxfce4util.h>
+
 #include "xfpm-button.h"
-#include "xfpm-button-xf86.h"
-#include "xfpm-button-hal.h"
-#include "xfpm-shutdown.h"
 #include "xfpm-enum.h"
 #include "xfpm-enum-types.h"
+#include "xfpm-debug.h"
 
 static void xfpm_button_finalize   (GObject *object);
 
 #define XFPM_BUTTON_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_BUTTON, XfpmButtonPrivate))
+(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_BUTTON, XfpmButtonPrivate))
 
-#define SLEEP_KEY_TIMEOUT 6.0f
+static struct
+{
+    XfpmButtonKey    key;
+    guint            key_code;
+} xfpm_key_map [NUMBER_OF_BUTTONS] = { {0, 0}, };
 
 struct XfpmButtonPrivate
 {
-    XfpmButtonXf86 *xf86;
-    XfpmButtonHal  *hal;
-    XfpmShutdown   *shutdown;
-    GTimer         *timer;
+    GdkScreen	*screen;
+    GdkWindow   *window;
+    
+    guint8       mapped_buttons;
 };
 
 enum
@@ -56,92 +73,176 @@ enum
     LAST_SIGNAL
 };
 
-static guint signals [LAST_SIGNAL] = { 0 };
+#define DUPLICATE_SHUTDOWN_TIMEOUT 4.0f
 
-G_DEFINE_TYPE (XfpmButton, xfpm_button, G_TYPE_OBJECT)
+static guint signals[LAST_SIGNAL] = { 0 };
 
-static void
-xfpm_button_xf86_emit_signal (XfpmButton *button, XfpmButtonKey key)
+G_DEFINE_TYPE(XfpmButton, xfpm_button, G_TYPE_OBJECT)
+
+static guint
+xfpm_button_get_key (unsigned int keycode)
 {
-    if ( key == BUTTON_POWER_OFF || key == BUTTON_SLEEP || key == BUTTON_HIBERNATE )
+    XfpmButtonKey key = BUTTON_UNKNOWN;
+    guint i;
+    
+    for ( i = 0; i < G_N_ELEMENTS (xfpm_key_map); i++)
     {
-	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);
-	}
+	if ( xfpm_key_map [i].key_code == keycode )
+	    key = xfpm_key_map [i].key;
     }
-    else
+    
+    return key;
+}
+
+static GdkFilterReturn
+xfpm_button_filter_x_events (GdkXEvent *xevent, GdkEvent *ev, gpointer data)
+{
+    XfpmButtonKey key;
+    XfpmButton *button;
+    
+    XEvent *xev = (XEvent *) xevent;
+    
+    if ( xev->type != KeyPress )
+    	return GDK_FILTER_CONTINUE;
+    
+    key = xfpm_button_get_key (xev->xkey.keycode);
+    
+    if ( key != BUTTON_UNKNOWN )
     {
-	g_signal_emit (G_OBJECT (button), signals [BUTTON_PRESSED], 0, key);
+	button = (XfpmButton *) data;
+    
+	XFPM_DEBUG_ENUM ("Key press", key, XFPM_TYPE_BUTTON_KEY);
+    
+	g_signal_emit (G_OBJECT(button), signals[BUTTON_PRESSED], 0, key);
+	return GDK_FILTER_REMOVE;
     }
+    
+    return GDK_FILTER_CONTINUE;
 }
 
-static void
-xfpm_button_xf86_button_pressed_cb (XfpmButtonXf86 *xf86, XfpmButtonKey key, XfpmButton *button)
+static gboolean
+xfpm_button_grab_keystring (XfpmButton *button, guint keycode)
 {
-    xfpm_button_xf86_emit_signal (button, key);
+    Display *display;
+    guint ret;
+    guint modmask = 0;
+    
+    display = GDK_DISPLAY ();
+    
+    gdk_error_trap_push ();
+
+    ret = XGrabKey (display, keycode, modmask,
+		    GDK_WINDOW_XID (button->priv->window), True,
+		    GrabModeAsync, GrabModeAsync);
+		    
+    if ( ret == BadAccess )
+    {
+	g_warning ("Failed to grab modmask=%u, keycode=%li",
+		    modmask, (long int) keycode);
+	return FALSE;
+    }
+	
+    ret = XGrabKey (display, keycode, LockMask | modmask,
+		    GDK_WINDOW_XID (button->priv->window), True,
+		    GrabModeAsync, GrabModeAsync);
+			
+    if (ret == BadAccess)
+    {
+	g_warning ("Failed to grab modmask=%u, keycode=%li",
+		   LockMask | modmask, (long int) keycode);
+	return FALSE;
+    }
+
+    gdk_flush ();
+    gdk_error_trap_pop ();
+    return TRUE;
 }
 
-static void
-xfpm_button_hal_button_pressed_cb (XfpmButtonHal *hal, XfpmButtonKey key, XfpmButton *button)
+
+static gboolean
+xfpm_button_xevent_key (XfpmButton *button, guint keysym , XfpmButtonKey key)
 {
-    xfpm_button_xf86_emit_signal (button, key);
+    guint keycode = XKeysymToKeycode (GDK_DISPLAY(), keysym);
+
+    if ( keycode == 0 )
+    {
+	g_warning ("could not map keysym %x to keycode\n", keysym);
+	return FALSE;
+    }
+    
+    if ( !xfpm_button_grab_keystring(button, keycode)) 
+    {
+    	g_warning ("Failed to grab %i\n", keycode);
+	return FALSE;
+    }
+    
+    XFPM_DEBUG_ENUM_FULL (key, XFPM_TYPE_BUTTON_KEY, "Grabbed key %li ", (long int) keycode);
+    
+    xfpm_key_map [key].key_code = keycode;
+    xfpm_key_map [key].key = key;
+    
+    return TRUE;
 }
 
 static void
-xfpm_button_waking_up_cb (XfpmShutdown *shutdown, XfpmButton *button)
+xfpm_button_setup (XfpmButton *button)
 {
-    g_timer_reset (button->priv->timer);
+    button->priv->screen = gdk_screen_get_default ();
+    button->priv->window = gdk_screen_get_root_window (button->priv->screen);
+    
+    if ( xfpm_button_xevent_key (button, XF86XK_PowerOff, BUTTON_POWER_OFF) )
+	button->priv->mapped_buttons |= POWER_KEY;
+    
+#ifdef HAVE_XF86XK_HIBERNATE
+    if ( xfpm_button_xevent_key (button, XF86XK_Hibernate, BUTTON_HIBERNATE) )
+	button->priv->mapped_buttons |= HIBERNATE_KEY;
+#endif 
+
+#ifdef HAVE_XF86XK_SUSPEND
+    if ( xfpm_button_xevent_key (button, XF86XK_Suspend, BUTTON_HIBERNATE) )
+	button->priv->mapped_buttons |= HIBERNATE_KEY;
+#endif 
+
+    if ( xfpm_button_xevent_key (button, XF86XK_Sleep, BUTTON_SLEEP) )
+	button->priv->mapped_buttons |= SLEEP_KEY;
+	
+    if ( xfpm_button_xevent_key (button, XF86XK_MonBrightnessUp, BUTTON_MON_BRIGHTNESS_UP) &&
+	 xfpm_button_xevent_key (button, XF86XK_MonBrightnessDown, BUTTON_MON_BRIGHTNESS_DOWN) )
+	button->priv->mapped_buttons |= BRIGHTNESS_KEY;
+
+    gdk_window_add_filter (button->priv->window, 
+			   xfpm_button_filter_x_events, button);
 }
 
 static void
-xfpm_button_class_init (XfpmButtonClass *klass)
+xfpm_button_class_init(XfpmButtonClass *klass)
 {
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
-    signals[BUTTON_PRESSED] = 
-        g_signal_new("button-pressed",
+    signals [BUTTON_PRESSED] = 
+        g_signal_new ("button-pressed",
                       XFPM_TYPE_BUTTON,
                       G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmButtonClass, button_pressed),
+                      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;
-    gboolean only_lid = FALSE;
-    
     button->priv = XFPM_BUTTON_GET_PRIVATE (button);
-    button->priv->xf86 = xfpm_button_xf86_new ();
-    button->priv->timer = g_timer_new ();
-    button->priv->shutdown = xfpm_shutdown_new ();
-    
-    xf86_mapped = xfpm_button_xf86_get_mapped_buttons (button->priv->xf86);
-
-    button->priv->hal = xfpm_button_hal_get ();
     
-    if ( xf86_mapped & SLEEP_KEY && xf86_mapped & POWER_KEY && 
-	 xf86_mapped & BRIGHTNESS_KEY && xf86_mapped & HIBERNATE_KEY )
-	only_lid = TRUE;
-
-    xfpm_button_hal_get_keys (button->priv->hal, only_lid, xf86_mapped);
+    button->priv->mapped_buttons = 0;
+    button->priv->screen = NULL;
+    button->priv->window = NULL;
     
-    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);
-		      
-    g_signal_connect (button->priv->shutdown, "waking-up",
-		      G_CALLBACK (xfpm_button_waking_up_cb), button);
+    xfpm_button_setup (button);
 }
 
 static void
@@ -151,44 +252,20 @@ xfpm_button_finalize (GObject *object)
 
     button = XFPM_BUTTON (object);
     
-    g_object_unref (button->priv->hal);
-    g_object_unref (button->priv->xf86);
-    g_object_unref (button->priv->shutdown);
-    
-    g_timer_destroy (button->priv->timer);
-
-    G_OBJECT_CLASS (xfpm_button_parent_class)->finalize (object);
+    G_OBJECT_CLASS(xfpm_button_parent_class)->finalize(object);
 }
 
 XfpmButton *
 xfpm_button_new (void)
 {
-    static gpointer xfpm_button_object = NULL;
-    
-    if ( G_LIKELY (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);
+    XfpmButton *button = NULL;
+    button = g_object_new (XFPM_TYPE_BUTTON, NULL);
+    return button;
 }
 
 guint8 xfpm_button_get_mapped (XfpmButton *button)
 {
-    guint8 mapped_keys = 0;
-    guint8 hal_mapped;
-    guint8 xf86_mapped;
-    
     g_return_val_if_fail (XFPM_IS_BUTTON (button), 0);
     
-    hal_mapped  = xfpm_button_hal_get_mapped_keys (button->priv->hal);
-    xf86_mapped = xfpm_button_xf86_get_mapped_buttons (button->priv->xf86);
-    
-    mapped_keys = hal_mapped | xf86_mapped;
-    
-    return mapped_keys;
+    return button->priv->mapped_buttons;
 }
diff --git a/src/xfpm-button.h b/src/xfpm-button.h
index 7243c20..6ce5309 100644
--- a/src/xfpm-button.h
+++ b/src/xfpm-button.h
@@ -1,5 +1,5 @@
 /*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -27,31 +27,33 @@
 
 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))
+#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;
+    GObject		  	parent;
+    XfpmButtonPrivate          *priv;
     
 } XfpmButton;
 
 typedef struct
 {
-    GObjectClass 		 parent_class;
-    void                         (*button_pressed)	     (XfpmButton *button,
-							      XfpmButtonKey key);
+    GObjectClass 		parent_class;
+     
+    void                 	(*button_pressed)		        (XfpmButton *button,
+								         XfpmButtonKey type);
     
 } XfpmButtonClass;
 
-GType        			 xfpm_button_get_type        (void) G_GNUC_CONST;
-XfpmButton       		*xfpm_button_new             (void);
+GType                 		xfpm_button_get_type               	(void) G_GNUC_CONST;
 
-guint8                           xfpm_button_get_mapped      (XfpmButton *button);
+XfpmButton       	       *xfpm_button_new             		(void);
+
+guint8                		xfpm_button_get_mapped		     	(XfpmButton *button) G_GNUC_PURE;
 
 G_END_DECLS
 
diff --git a/src/xfpm-cpu.c b/src/xfpm-cpu.c
deleted file mode 100644
index 80d536e..0000000
--- a/src/xfpm-cpu.c
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * * Copyright (C) 2008-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 <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "libxfpm/hal-manager.h"
-#include "libxfpm/xfpm-string.h"
-
-#include "xfpm-cpu.h"
-#include "xfpm-adapter.h"
-#include "xfpm-xfconf.h"
-#include "xfpm-config.h"
-#include "xfpm-enum.h"
-
-#ifdef SYSTEM_IS_LINUX /* the end if at the end of the file */
-
-static void xfpm_cpu_finalize   (GObject *object);
-
-#define XFPM_CPU_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_CPU, XfpmCpuPrivate))
-
-struct XfpmCpuPrivate
-{
-    DBusGConnection *bus;
-    XfpmAdapter     *adapter;
-    XfpmXfconf      *conf;
-    
-    gboolean 	     on_battery;
-    guint8           cpu_governors;
-};
-
-G_DEFINE_TYPE(XfpmCpu, xfpm_cpu, G_TYPE_OBJECT)
-
-static gboolean
-xfpm_cpu_check_interface (XfpmCpu *cpu)
-{
-    DBusMessage *message;
-    DBusMessage *reply;
-    DBusError error ;
-    
-    message = dbus_message_new_method_call ("org.freedesktop.Hal",
-					    "/org/freedesktop/Hal",
-					    "org.freedesktop.Hal.Device.CPUFreq",
-					    "JustToCheck");
-    
-    if (!message)
-    	return FALSE;
-    
-    dbus_error_init (&error);
-    
-    reply = 
-    	dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection(cpu->priv->bus),
-						   message, 2000, &error);
-    dbus_message_unref (message);
-    
-    if ( reply ) dbus_message_unref (reply);
-    
-    if ( dbus_error_is_set(&error) )
-    {
-	if ( !g_strcmp0 (error.name, "org.freedesktop.DBus.Error.UnknownMethod") )
-        {
-            dbus_error_free(&error);
-	    return TRUE;
-        }
-    }
-    return FALSE;
-}
-
-static gchar **
-xfpm_cpu_get_hal_available_governors (XfpmCpu *cpu)
-{
-    gchar **governors = NULL;
-    GError *error = NULL;
-    DBusGProxy *proxy = dbus_g_proxy_new_for_name (cpu->priv->bus,
-						   "org.freedesktop.Hal",
-						   "/org/freedesktop/Hal/devices/computer",
-						   "org.freedesktop.Hal.Device.CPUFreq");
-    if ( !proxy )
-    {
-	g_critical ("Failed to create proxy");
-	goto out;
-    }
-    
-    dbus_g_proxy_call (proxy, "GetCPUFreqAvailableGovernors", &error,
-		       G_TYPE_INVALID,
-		       G_TYPE_STRV, &governors,
-		       G_TYPE_INVALID);
-		       
-    if ( error )
-    {
-	g_warning ("Failed to get cpu governors: %s", error->message);
-	g_error_free (error);
-    }
-    
-    g_object_unref (proxy);
-out:
-    return governors;
-}
-
-static gchar *
-xfpm_cpu_get_hal_current_governor (XfpmCpu *cpu)
-{
-    gchar *governor = NULL;
-    GError *error = NULL;
-    
-    DBusGProxy *proxy = dbus_g_proxy_new_for_name (cpu->priv->bus,
-						   "org.freedesktop.Hal",
-						   "/org/freedesktop/Hal/devices/computer",
-						   "org.freedesktop.Hal.Device.CPUFreq");
-    if ( !proxy )
-    {
-	g_critical ("Failed to create proxy");
-	goto out;
-    }
-    
-    dbus_g_proxy_call (proxy, "GetCPUFreqGovernor", &error,
-		       G_TYPE_INVALID,
-		       G_TYPE_STRING, &governor,
-		       G_TYPE_INVALID);
-    
-    if ( error )
-    {
-	g_warning ("Failed to get cpu governor: %s", error->message);
-	g_error_free (error);
-    }
-    
-    g_object_unref (proxy);
-out:
-    return governor;
-}
-
-static gboolean
-xfpm_cpu_set_hal_governor (XfpmCpu *cpu, const gchar *governor)
-{
-    gboolean ret = FALSE;
-    GError *error = NULL;
-    
-    DBusGProxy *proxy = dbus_g_proxy_new_for_name (cpu->priv->bus,
-						   "org.freedesktop.Hal",
-						   "/org/freedesktop/Hal/devices/computer",
-						   "org.freedesktop.Hal.Device.CPUFreq");
-    if ( !proxy )
-    {
-	g_critical ("Failed to create proxy");
-	goto out;
-    }
-    
-    ret = dbus_g_proxy_call (proxy, "SetCPUFreqGovernor", &error,
-	  		     G_TYPE_STRING, governor,
-			     G_TYPE_INVALID,
-			     G_TYPE_INVALID);
-			     
-    if ( error )
-    {
-	g_warning ("Failed to set cpu governor: %s", error->message);
-	g_error_free (error);
-    }
-    		     
-    g_object_unref (proxy);
-out:
-    return ret;
-}
-
-static void
-xfpm_cpu_set_governor (XfpmCpu *cpu, const gchar *governor)
-{
-    TRACE("Settings cpu governor to %s", governor);
-    
-    if (! xfpm_cpu_set_hal_governor(cpu, governor))
-    {
-    	g_critical ("Unable to set CPU governor to %s", governor);
-    }
-}
-
-static XfpmCpuGovernor 
-_governor_name_to_enum (const gchar *governor)
-{
-    if ( xfpm_strequal(governor, "ondemand") )
-    	return CPU_ONDEMAND;
-    else if ( xfpm_strequal(governor, "powersave") )
-    	return CPU_POWERSAVE;
-    else if ( xfpm_strequal (governor, "performance") )
-    	return CPU_PERFORMANCE;
-    
-    return CPU_UNKNOWN;
-}
-
-static XfpmCpuGovernor
-xfpm_cpu_get_current_governor (XfpmCpu *cpu)
-{
-    gchar *current_governor = NULL;
-    XfpmCpuGovernor governor_enum;
-    
-    current_governor = xfpm_cpu_get_hal_current_governor (cpu);
-    
-    if ( !current_governor )
-    {
-	g_warning ("Unable to get current governor");
-	return CPU_UNKNOWN;
-    }
-    governor_enum = _governor_name_to_enum (current_governor);
-    g_free (current_governor);
-    return governor_enum;
-}
-
-/*
- * Get the available CPU governors on the system
- */
-static void
-xfpm_cpu_get_available_governors (XfpmCpu *cpu)
-{
-    int i;
-    gchar **governors = NULL;
-    governors = xfpm_cpu_get_hal_available_governors (cpu);
-	
-    if ( !governors || !governors[0])
-    {
-    	g_critical ("Unable to get CPU governors\n");
-	return;
-    }
-    
-    for ( i = 0; governors[i]; i++)
-    {
-    	TRACE("found CPU governor %s", governors[i]);
-	if (xfpm_strequal(governors[i], "powersave") )
-	    cpu->priv->cpu_governors |= CPU_POWERSAVE;
-	else if ( xfpm_strequal(governors[i], "ondemand") )
-	    cpu->priv->cpu_governors |= CPU_ONDEMAND;
-	else if ( xfpm_strequal(governors[i], "performance") )
-	    cpu->priv->cpu_governors |= CPU_PERFORMANCE;
-    }
-    hal_manager_free_string_array (governors);
-}
-
-static gboolean
-xfpm_cpu_check_iface (XfpmCpu *cpu)
-{
-    gboolean cpu_freq_iface;
-    
-    cpu_freq_iface = xfpm_cpu_check_interface (cpu);
-		  
-    if (!cpu_freq_iface)
-    {
-	g_warning ("CPU FREQ interface cannot be used");
-	return FALSE;
-    }
-    
-    xfpm_cpu_get_available_governors (cpu);
-    
-    if ( (cpu->priv->cpu_governors & CPU_ONDEMAND || cpu->priv->cpu_governors & CPU_PERFORMANCE)
-	 && (cpu->priv->cpu_governors & CPU_POWERSAVE) )
-	return TRUE;
-    
-    g_warning ("No convenient cpu governors found on the system, cpu frequency control will be disabled");
-    return FALSE;
-}
-
-static void
-xfpm_cpu_set_power_save (XfpmCpu *cpu)
-{
-    if ( xfpm_cpu_get_current_governor (cpu) != CPU_POWERSAVE && cpu->priv->cpu_governors & CPU_POWERSAVE )
-	xfpm_cpu_set_governor (cpu, "powersave");
-}
-
-static void
-xfpm_cpu_set_performance_ondemand (XfpmCpu *cpu)
-{
-    XfpmCpuGovernor gov;
-    
-    gov = xfpm_cpu_get_current_governor (cpu);
-    
-    if ( gov == CPU_ONDEMAND )
-	return;
-	
-    if ( (gov != CPU_ONDEMAND) && (cpu->priv->cpu_governors & CPU_ONDEMAND) )
-	xfpm_cpu_set_governor (cpu, "ondemand");
-    else if ( (gov != CPU_PERFORMANCE) && (cpu->priv->cpu_governors & CPU_PERFORMANCE) )
-	xfpm_cpu_set_governor (cpu, "performance");
-}
-
-static void
-xfpm_cpu_refresh (XfpmCpu *cpu)
-{
-    gboolean power_save;
-    gboolean enable_cpu_freq;
-
-    TRACE ("start");
-    
-    g_object_get (G_OBJECT (cpu->priv->conf),
-		  POWER_SAVE_ON_BATTERY, &power_save,
-		  CPU_FREQ_CONTROL, &enable_cpu_freq,
-		  NULL);
-    
-    if ( enable_cpu_freq == FALSE )
-	return;
-    
-    if (power_save == FALSE)
-    {
-	xfpm_cpu_set_performance_ondemand (cpu);
-	return;
-    }
-	
-    if ( cpu->priv->on_battery )
-	xfpm_cpu_set_power_save (cpu);
-    else 
-	xfpm_cpu_set_performance_ondemand (cpu);
-}
-
-static void
-xfpm_cpu_adapter_changed_cb (XfpmAdapter *adapter, gboolean is_present, XfpmCpu *cpu)
-{
-    cpu->priv->on_battery = !is_present;
-    xfpm_cpu_refresh (cpu);
-}
-
-static void
-xfpm_cpu_settings_changed (GObject *obj, GParamSpec *spec, XfpmCpu *cpu)
-{
-    if ( !g_strcmp0 (spec->name, CPU_FREQ_CONTROL) || !g_strcmp0 (spec->name, POWER_SAVE_ON_BATTERY))
-	xfpm_cpu_refresh (cpu);
-}
-
-static void
-xfpm_cpu_class_init(XfpmCpuClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    object_class->finalize = xfpm_cpu_finalize;
-
-    g_type_class_add_private(klass,sizeof(XfpmCpuPrivate));
-}
-
-static void
-xfpm_cpu_init(XfpmCpu *cpu)
-{
-    cpu->priv = XFPM_CPU_GET_PRIVATE(cpu);
-    cpu->priv->cpu_governors = 0;
-    
-    cpu->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
-    
-    if (!cpu->priv->bus)
-	goto out;
-    
-    if ( xfpm_cpu_check_iface (cpu))
-    {
-	cpu->priv->adapter       = xfpm_adapter_new ();
-	cpu->priv->conf 	 = xfpm_xfconf_new ();
-	
-	g_signal_connect (cpu->priv->adapter, "adapter-changed",
-			  G_CALLBACK(xfpm_cpu_adapter_changed_cb), cpu);
-	
-	g_signal_connect (cpu->priv->conf, "notify",
-			  G_CALLBACK (xfpm_cpu_settings_changed), cpu);
-	
-	cpu->priv->on_battery = !xfpm_adapter_get_present (cpu->priv->adapter);
-	xfpm_cpu_refresh (cpu);
-    }
-    
-out:
-    ;
-}
-
-static void
-xfpm_cpu_finalize(GObject *object)
-{
-    XfpmCpu *cpu;
-
-    cpu = XFPM_CPU(object);
-
-    if ( cpu->priv->conf )
-	g_object_unref (cpu->priv->conf);
-    
-    if ( cpu->priv->conf )
-	g_object_unref (cpu->priv->adapter);
-	
-    if ( cpu->priv->bus )
-	dbus_g_connection_unref (cpu->priv->bus);
-
-    G_OBJECT_CLASS(xfpm_cpu_parent_class)->finalize(object);
-}
-
-XfpmCpu *
-xfpm_cpu_new (void)
-{
-    XfpmCpu *cpu = NULL;
-    cpu = g_object_new (XFPM_TYPE_CPU, NULL);
-    return cpu;
-}
-
-void xfpm_cpu_reload (XfpmCpu *cpu)
-{
-    g_return_if_fail (XFPM_IS_CPU (cpu));
-    
-    cpu->priv->cpu_governors = 0;
-    xfpm_cpu_check_iface (cpu);
-}
-
-#endif /*SYSTEM_IS_LINUX*/
diff --git a/src/xfpm-cpu.h b/src/xfpm-cpu.h
deleted file mode 100644
index 2eda193..0000000
--- a/src/xfpm-cpu.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * * Copyright (C) 2008-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_CPU_H
-#define __XFPM_CPU_H
-
-#include <glib-object.h>
-
-#include "xfpm-config.h"
-
-G_BEGIN_DECLS
-
-#ifdef SYSTEM_IS_LINUX
-
-#define XFPM_TYPE_CPU        (xfpm_cpu_get_type () )
-#define XFPM_CPU(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_CPU, XfpmCpu))
-#define XFPM_IS_CPU(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_CPU))
-
-typedef struct XfpmCpuPrivate XfpmCpuPrivate;
-
-typedef struct
-{
-    GObject		 parent;
-    XfpmCpuPrivate	 *priv;
-    
-} XfpmCpu;
-
-typedef struct
-{
-    GObjectClass parent_class;
-    
-} XfpmCpuClass;
-
-GType          xfpm_cpu_get_type        (void) G_GNUC_CONST;
-XfpmCpu       *xfpm_cpu_new             (void);
-void           xfpm_cpu_reload          (XfpmCpu *cpu);
-
-#endif /*SYSTEM_IS_LINUX*/
-
-G_END_DECLS
-
-#endif /* __XFPM_CPU_H */
diff --git a/src/xfpm-dkp.c b/src/xfpm-dkp.c
new file mode 100644
index 0000000..9d150e7
--- /dev/null
+++ b/src/xfpm-dkp.c
@@ -0,0 +1,1087 @@
+/*
+ * * 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 <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include <libxfce4util/libxfce4util.h>
+#include <libxfce4ui/libxfce4ui.h>
+
+#include "xfpm-dkp.h"
+#include "xfpm-dbus.h"
+#include "xfpm-battery.h"
+#include "xfpm-notify.h"
+#include "xfpm-inhibit.h"
+#include "xfpm-polkit.h"
+#include "xfpm-icons.h"
+#include "xfpm-common.h"
+
+static void xfpm_dkp_finalize     (GObject *object);
+
+static void xfpm_dkp_set_property (GObject *object,
+				   guint prop_id,
+				   const GValue *value,
+				   GParamSpec *pspec);
+				   
+static void xfpm_dkp_get_property (GObject *object,
+				   guint prop_id,
+				   GValue *value,
+				   GParamSpec *pspec);
+
+static void xfpm_dkp_dbus_class_init (XfpmDkpClass * klass);
+static void xfpm_dkp_dbus_init (XfpmDkp *dkp);
+
+#define XFPM_DKP_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_DKP, XfpmDkpPrivate))
+
+struct XfpmDkpPrivate
+{
+    DBusGConnection *bus;
+    
+    DBusGProxy      *proxy;
+    DBusGProxy      *proxy_prop;
+    
+    GHashTable      *hash;
+    
+    XfpmInhibit	    *inhibit;
+    gboolean	     inhibited;
+    
+    XfpmNotify	    *notify;
+#ifdef HAVE_POLKIT
+    XfpmPolkit 	    *polkit;
+#endif
+    gboolean	     auth_suspend;
+    gboolean	     auth_hibernate;
+    
+    /* Properties */
+    gboolean	     lid_is_present;
+    gboolean         lid_is_closed;
+    gboolean	     on_battery;
+    gchar           *daemon_version;
+    gboolean	     can_suspend;
+    gboolean         can_hibernate;
+};
+
+enum
+{
+    PROP_0,
+    PROP_ON_BATTERY,
+    PROP_AUTH_SUSPEND,
+    PROP_AUTH_HIBERNATE,
+    PROP_CAN_SUSPEND,
+    PROP_CAN_HIBERNATE,
+    PROP_HAS_LID
+};
+
+enum
+{
+    ON_BATTERY_CHANGED,
+    LOW_BATTERY_CHANGED,
+    LID_CHANGED,
+    LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+
+G_DEFINE_TYPE (XfpmDkp, xfpm_dkp, G_TYPE_OBJECT)
+
+#ifdef HAVE_POLKIT
+static void
+xfpm_dkp_check_polkit_auth (XfpmDkp *dkp)
+{
+    dkp->priv->auth_suspend = xfpm_polkit_check_auth (dkp->priv->polkit, 
+						      "org.freedesktop.devicekit.power.suspend");
+
+    dkp->priv->auth_hibernate = xfpm_polkit_check_auth (dkp->priv->polkit, 
+							"org.freedesktop.devicekit.power.hibernate");
+
+}
+#endif
+
+static void
+xfpm_dkp_check_pm (XfpmDkp *dkp, GHashTable *props)
+{
+    GValue *value;
+    gboolean ret;
+    
+    value = g_hash_table_lookup (props, "CanSuspend");
+    
+    if (value == NULL) 
+    {
+	g_warning ("No 'CanSuspend' property");
+    }
+    ret = g_value_get_boolean (value);
+    
+    if (ret != dkp->priv->can_suspend) 
+    {
+	dkp->priv->can_suspend = ret;
+    }
+
+    value = g_hash_table_lookup (props, "CanHibernate");
+    
+    if (value == NULL) 
+    {
+	g_warning ("No 'CanHibernate' property");
+    }
+    
+    ret = g_value_get_boolean (value);
+    
+    if (ret != dkp->priv->can_hibernate) 
+    {
+	dkp->priv->can_hibernate = ret;
+    }
+}
+
+static void
+xfpm_dkp_check_power (XfpmDkp *dkp, GHashTable *props)
+{
+    GValue *value;
+    gboolean on_battery;
+    
+    value = g_hash_table_lookup (props, "OnBattery");
+    
+    if (G_LIKELY (value)) 
+    {
+	on_battery = g_value_get_boolean (value);
+    
+	if (on_battery != dkp->priv->on_battery ) 
+	{
+	    GList *list;
+	    guint len, i;
+	    g_signal_emit (G_OBJECT (dkp), signals [ON_BATTERY_CHANGED], 0, on_battery);
+	    dkp->priv->on_battery = on_battery;
+	    list = g_hash_table_get_values (dkp->priv->hash);
+	    len = g_list_length (list);
+	    for ( i = 0; i < len; i++)
+	    {
+		g_object_set (G_OBJECT (g_list_nth_data (list, i)), 
+			      "ac-online", !on_battery,
+			      NULL);
+	    }
+	}
+    }
+    else
+    {
+	g_warning ("No 'OnBattery' property");
+    }
+}
+
+static void
+xfpm_dkp_check_lid (XfpmDkp *dkp, GHashTable *props)
+{
+    GValue *value;
+    
+    value = g_hash_table_lookup (props, "LidIsPresent");
+    
+    if (value == NULL) 
+    {
+	g_warning ("No 'LidIsPresent' property");
+	return;
+    }
+
+    dkp->priv->lid_is_present = g_value_get_boolean (value);
+
+    if (dkp->priv->lid_is_present) 
+    {
+	gboolean closed;
+	
+	value = g_hash_table_lookup (props, "LidIsClosed");
+    
+	if (value == NULL) 
+	{
+	    g_warning ("No 'LidIsClosed' property");
+	    return;
+	}
+	
+	closed = g_value_get_boolean (value);
+	
+	if (closed != dkp->priv->lid_is_closed ) 
+	{
+	    dkp->priv->lid_is_closed = closed;
+	    g_signal_emit (G_OBJECT (dkp), signals [LID_CHANGED], 0, dkp->priv->lid_is_closed);
+	}
+    }
+}
+
+/*
+ * Get the properties on org.freedesktop.DeviceKit.Power
+ * 
+ * DaemonVersion      's'
+ * CanSuspend'        'b'
+ * CanHibernate'      'b'
+ * OnBattery'         'b'
+ * OnLowBattery'      'b'
+ * LidIsClosed'       'b'
+ * LidIsPresent'      'b'
+ */
+static void
+xfpm_dkp_get_properties (XfpmDkp *dkp)
+{
+    GHashTable *props;
+    
+    props = xfpm_dbus_get_interface_properties (dkp->priv->proxy_prop, DKP_IFACE);
+    
+    xfpm_dkp_check_pm (dkp, props);
+    xfpm_dkp_check_lid (dkp, props);
+    xfpm_dkp_check_power (dkp, props);
+    /*
+    if ( dkp->priv->daemon_version == NULL )
+    {
+	value = g_hash_table_lookup (props, "DaemonVersion");
+    
+	if (value == NULL) 
+	{
+	    g_warning ("No 'DaemonVersion' property");
+	    goto out;
+	}
+	//FIXME: Check daemon version
+	client->priv->daemon_version = g_strdup (g_value_get_string (value));
+    }
+    */
+    g_hash_table_destroy (props);
+}
+
+static void
+xfpm_dkp_report_error (XfpmDkp *dkp, const gchar *error, const gchar *icon_name)
+{
+    GtkStatusIcon *battery = NULL;
+    guint i, len;
+    GList *list;
+    
+    list = g_hash_table_get_values (dkp->priv->hash);
+    len = g_list_length (list);
+    
+    for ( i = 0; i < len; i++)
+    {
+	XfpmDkpDeviceType type;
+	battery = g_list_nth_data (list, i);
+	type = xfpm_battery_get_device_type (XFPM_BATTERY (battery));
+	if ( type == XFPM_DKP_DEVICE_TYPE_BATTERY ||
+	     type == XFPM_DKP_DEVICE_TYPE_UPS )
+	     break;
+    }
+    
+    xfpm_notify_show_notification (dkp->priv->notify, 
+				   _("Xfce power manager"), 
+				   error, 
+				   icon_name,
+				   10000,
+				   FALSE,
+				   XFPM_NOTIFY_CRITICAL,
+				   battery);
+    
+}
+
+static void
+xfpm_dkp_sleep (XfpmDkp *dkp, const gchar *sleep)
+{
+    GError *error = NULL;
+    
+    dbus_g_proxy_call (dkp->priv->proxy, sleep, &error,
+		       G_TYPE_INVALID,
+		       G_TYPE_INVALID);
+    
+    if ( error )
+    {
+	const gchar *icon_name;
+	if ( !g_strcmp0 (sleep, "Hibernate") )
+	    icon_name = XFPM_HIBERNATE_ICON;
+	else
+	    icon_name = XFPM_SUSPEND_ICON;
+	    
+	xfpm_dkp_report_error (dkp, error->message, icon_name);
+	g_error_free (error);
+    }
+}
+
+static void
+xfpm_dkp_hibernate_cb (XfpmDkp *dkp, GtkStatusIcon *icon)
+{
+    xfpm_dkp_sleep (dkp, "Hibernate");
+}
+
+static void
+xfpm_dkp_suspend_cb (XfpmDkp *dkp, GtkStatusIcon *icon)
+{
+    xfpm_dkp_sleep (dkp, "Suspend");
+    
+}
+
+static void
+xfpm_dkp_battery_info_cb (GtkStatusIcon *icon)
+{
+    
+}
+
+static void
+xfpm_dkp_tray_exit_activated_cb (gpointer data)
+{
+    gboolean ret;
+    
+    ret = xfce_dialog_confirm (NULL, 
+			       GTK_STOCK_YES, 
+			       _("Quit"),
+			       _("All running instances of the power manager will exit"),
+			       "%s",
+			        _("Quit Xfce power manager?"));
+    if ( ret )
+    {
+	xfpm_quit ();
+    }
+}
+
+static void
+xfpm_dkp_show_tray_menu (XfpmDkp *dkp, 
+			 GtkStatusIcon *icon, 
+			 guint button, 
+			 guint activate_time,
+			 gboolean show_info_item)
+{
+    GtkWidget *menu, *mi, *img;
+
+    menu = gtk_menu_new();
+
+    // Hibernate menu option
+    mi = gtk_image_menu_item_new_with_label (_("Hibernate"));
+    img = gtk_image_new_from_icon_name (XFPM_HIBERNATE_ICON, GTK_ICON_SIZE_MENU);
+    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
+    gtk_widget_set_sensitive (mi, FALSE);
+    
+    if ( dkp->priv->can_hibernate && dkp->priv->auth_hibernate)
+    {
+	gtk_widget_set_sensitive (mi, TRUE);
+	g_signal_connect(G_OBJECT (mi), "activate",
+			G_CALLBACK (xfpm_dkp_hibernate_cb), icon);
+    }
+    gtk_widget_show (mi);
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+    
+    // Suspend menu option
+    mi = gtk_image_menu_item_new_with_label (_("Suspend"));
+    img = gtk_image_new_from_icon_name (XFPM_SUSPEND_ICON, GTK_ICON_SIZE_MENU);
+    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
+    
+    gtk_widget_set_sensitive (mi, FALSE);
+    
+    if ( dkp->priv->can_suspend && dkp->priv->auth_hibernate)
+    {
+	gtk_widget_set_sensitive (mi, TRUE);
+	g_signal_connect (mi, "activate",
+			  G_CALLBACK (xfpm_dkp_suspend_cb), icon);
+    }
+    
+    gtk_widget_show (mi);
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+/*
+    saver_inhibited = xfpm_screen_saver_get_inhibit (tray->priv->srv);
+    mi = gtk_check_menu_item_new_with_label (_("Monitor power control"));
+    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), !saver_inhibited);
+    gtk_widget_set_tooltip_text (mi, _("Disable or enable monitor power control, "\
+                                       "for example you could disable the screen power "\
+				       "control to avoid screen blanking when watching a movie."));
+    
+    g_signal_connect (G_OBJECT (mi), "activate",
+		      G_CALLBACK (xfpm_tray_icon_inhibit_active_cb), tray);
+    gtk_widget_set_sensitive (mi, TRUE);
+    gtk_widget_show(mi);
+    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
+*/
+    if ( show_info_item )
+    {
+	mi = gtk_separator_menu_item_new ();
+	gtk_widget_show (mi);
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+    
+	// Battery informations
+    
+	mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_INFO, NULL);
+	
+	gtk_widget_set_sensitive (mi,FALSE);
+	gtk_widget_set_sensitive (mi,TRUE);
+	
+	g_signal_connect_swapped (mi,"activate",
+				  G_CALLBACK (xfpm_dkp_battery_info_cb), icon);
+			 
+	gtk_widget_show (mi);
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+    
+    
+	// Separator
+	mi = gtk_separator_menu_item_new ();
+	gtk_widget_show (mi);
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+    }
+	
+    mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_HELP, NULL);
+    gtk_widget_set_sensitive (mi, TRUE);
+    gtk_widget_show (mi);
+    g_signal_connect (mi, "activate", G_CALLBACK (xfpm_help), NULL);
+	
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+    
+    mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
+    gtk_widget_set_sensitive (mi, TRUE);
+    gtk_widget_show (mi);
+    g_signal_connect (mi, "activate", G_CALLBACK (xfpm_about), _("Xfce Power Manager"));
+    
+    gtk_menu_shell_append (GTK_MENU_SHELL(menu), mi);
+    
+    mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_PREFERENCES, NULL);
+    gtk_widget_set_sensitive (mi, TRUE);
+    gtk_widget_show (mi);
+    g_signal_connect (mi, "activate",G_CALLBACK (xfpm_preferences), NULL);
+    
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
+    mi = gtk_separator_menu_item_new ();
+    gtk_widget_show (mi);
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
+    mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
+    gtk_widget_set_sensitive (mi, TRUE);
+    gtk_widget_show (mi);
+    g_signal_connect_swapped (mi, "activate", G_CALLBACK (xfpm_dkp_tray_exit_activated_cb), NULL);
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
+    g_signal_connect (menu, "selection-done",
+		      G_CALLBACK (gtk_widget_destroy), NULL);
+
+    // Popup the menu
+    gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
+		   gtk_status_icon_position_menu, 
+		   icon, button, activate_time);
+    
+}
+
+static void 
+xfpm_dkp_show_tray_menu_battery (GtkStatusIcon *icon, guint button, 
+			         guint activate_time, XfpmDkp *dkp)
+{
+    xfpm_dkp_show_tray_menu (dkp, icon, button, activate_time, TRUE);
+}
+
+static void
+xfpm_dkp_add_device (XfpmDkp *dkp, const gchar *object_path)
+{
+    DBusGProxy *proxy_prop;
+    guint device_type;
+    GValue value;
+    
+    proxy_prop = dbus_g_proxy_new_for_name (dkp->priv->bus, 
+					    DKP_NAME,
+					    object_path,
+					    DBUS_INTERFACE_PROPERTIES);
+				       
+    if ( !proxy_prop )
+    {
+	g_warning ("Unable to create proxy for : %s", object_path);
+	return;
+    }
+    
+    value = xfpm_dbus_get_interface_property (proxy_prop, DKP_IFACE_DEVICE, "Type");
+    
+    device_type = g_value_get_uint (&value);
+    
+    if ( device_type == XFPM_DKP_DEVICE_TYPE_LINE_POWER )
+    {
+	
+    }
+    else if ( device_type == XFPM_DKP_DEVICE_TYPE_BATTERY || 
+	      device_type == XFPM_DKP_DEVICE_TYPE_UPS     ||
+	      device_type == XFPM_DKP_DEVICE_TYPE_MOUSE   ||
+	      device_type == XFPM_DKP_DEVICE_TYPE_KBD     ||
+	      device_type == XFPM_DKP_DEVICE_TYPE_PHONE)
+    {
+	GtkStatusIcon *battery;
+	DBusGProxy *proxy;
+	TRACE ("Battery device detected at : %s", object_path);
+	proxy = dbus_g_proxy_new_for_name (dkp->priv->bus,
+					   DKP_NAME,
+					   object_path,
+					   DKP_IFACE_DEVICE);
+	battery = xfpm_battery_new ();
+	xfpm_battery_monitor_device (XFPM_BATTERY (battery), proxy, proxy_prop, device_type);
+	g_hash_table_insert (dkp->priv->hash, g_strdup (object_path), battery);
+	
+	g_signal_connect (battery, "popup-menu",
+			  G_CALLBACK (xfpm_dkp_show_tray_menu_battery), dkp);
+	
+    }
+    else 
+    {
+	g_warning ("Unable to monitor unkown power device with object_path : %s", object_path);
+	g_object_unref (proxy_prop);
+    }
+}
+
+/*
+ * Get the object path of all the power devices
+ * on dkp.
+ */
+static GPtrArray *
+xfpm_dkp_enumerate_devices (XfpmDkp *dkp)
+{
+    gboolean ret;
+    GError *error = NULL;
+    GPtrArray *array = NULL;
+    GType g_type_array;
+
+    g_type_array = dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH);
+    
+    ret = dbus_g_proxy_call (dkp->priv->proxy, "EnumerateDevices", &error,
+			     G_TYPE_INVALID,
+			     g_type_array, &array,
+			     G_TYPE_INVALID);
+    if (!ret) 
+    {
+	g_critical ("Couldn't enumerate power devices: %s", error->message);
+	g_error_free (error);
+    }
+    
+    return array;
+}
+
+static void
+xfpm_dkp_get_power_devices (XfpmDkp *dkp)
+{
+    GPtrArray *array = NULL;
+    guint i;
+    
+    array = xfpm_dkp_enumerate_devices (dkp);
+    
+    for ( i = 0; i < array->len; i++)
+    {
+	const gchar *object_path = ( const gchar *) g_ptr_array_index (array, i);
+	TRACE ("Power device detected at : %s", object_path);
+	xfpm_dkp_add_device (dkp, object_path);
+    }
+    
+    g_ptr_array_free (array, TRUE);
+}
+
+static void
+xfpm_dkp_remove_device (XfpmDkp *dkp, const gchar *object_path)
+{
+    g_hash_table_remove (dkp->priv->hash, object_path);
+}
+
+static void
+xfpm_dkp_inhibit_changed_cb (XfpmInhibit *inhibit, gboolean is_inhibit, XfpmDkp *dkp)
+{
+    dkp->priv->inhibited = is_inhibit;
+}
+
+static void
+xfpm_dkp_changed_cb (DBusGProxy *proxy, XfpmDkp *dkp)
+{
+    xfpm_dkp_get_properties (dkp);
+}
+
+static void
+xfpm_dkp_device_added_cb (DBusGProxy *proxy, const gchar *object_path, XfpmDkp *dkp)
+{
+    xfpm_dkp_add_device (dkp, object_path);
+}
+
+static void
+xfpm_dkp_device_removed_cb (DBusGProxy *proxy, const gchar *object_path, XfpmDkp *dkp)
+{
+    xfpm_dkp_remove_device (dkp, object_path);
+}
+
+static void
+xfpm_dkp_device_changed_cb (DBusGProxy *proxy, const gchar *object_path, XfpmDkp *dkp)
+{
+    XfpmBattery *battery;
+    
+    battery = g_hash_table_lookup (dkp->priv->hash, object_path);
+    
+    if ( battery )
+    {
+	
+    }
+}
+
+#ifdef HAVE_POLKIT
+static void
+xfpm_dkp_polkit_auth_changed_cb (XfpmDkp *dkp)
+{
+    xfpm_dkp_check_polkit_auth (dkp);
+}
+#endif
+
+static void
+xfpm_dkp_class_init (XfpmDkpClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = xfpm_dkp_finalize;
+
+    object_class->get_property = xfpm_dkp_get_property;
+    object_class->set_property = xfpm_dkp_set_property;
+
+    signals [ON_BATTERY_CHANGED] = 
+        g_signal_new ("on-battery-changed",
+                      XFPM_TYPE_DKP,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(XfpmDkpClass, on_battery_changed),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__BOOLEAN,
+                      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
+    signals [LOW_BATTERY_CHANGED] = 
+        g_signal_new ("low-battery-changed",
+                      XFPM_TYPE_DKP,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(XfpmDkpClass, low_battery_changed),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__BOOLEAN,
+                      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
+    signals [LID_CHANGED] = 
+        g_signal_new ("lid-changed",
+                      XFPM_TYPE_DKP,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(XfpmDkpClass, lid_changed),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__BOOLEAN,
+                      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
+    g_object_class_install_property (object_class,
+                                     PROP_ON_BATTERY,
+                                     g_param_spec_boolean ("on-battery",
+                                                          NULL, NULL,
+                                                          FALSE,
+                                                          G_PARAM_READABLE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_AUTH_SUSPEND,
+                                     g_param_spec_boolean ("auth-suspend",
+                                                          NULL, NULL,
+                                                          FALSE,
+                                                          G_PARAM_READABLE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_AUTH_HIBERNATE,
+                                     g_param_spec_boolean ("auth-hibernate",
+                                                          NULL, NULL,
+                                                          FALSE,
+                                                          G_PARAM_READABLE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_CAN_HIBERNATE,
+                                     g_param_spec_boolean ("can-hibernate",
+                                                          NULL, NULL,
+                                                          FALSE,
+                                                          G_PARAM_READABLE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_CAN_SUSPEND,
+                                     g_param_spec_boolean ("can-suspend",
+                                                          NULL, NULL,
+                                                          FALSE,
+                                                          G_PARAM_READABLE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_HAS_LID,
+                                     g_param_spec_boolean ("has-lid",
+                                                          NULL, NULL,
+                                                          FALSE,
+                                                          G_PARAM_READABLE));
+
+    g_type_class_add_private (klass, sizeof (XfpmDkpPrivate));
+    
+    xfpm_dkp_dbus_class_init (klass);
+}
+
+static void
+xfpm_dkp_init (XfpmDkp *dkp)
+{
+    GError *error = NULL;
+    
+    dkp->priv = XFPM_DKP_GET_PRIVATE (dkp);
+    
+    dkp->priv->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
+    dkp->priv->lid_is_present  = FALSE;
+    dkp->priv->lid_is_closed   = FALSE;
+    dkp->priv->on_battery      = FALSE;
+    dkp->priv->daemon_version  = NULL;
+    dkp->priv->can_suspend     = FALSE;
+    dkp->priv->can_hibernate   = FALSE;
+    dkp->priv->auth_hibernate  = TRUE;
+    dkp->priv->auth_suspend    = TRUE;
+    
+    dkp->priv->inhibit = xfpm_inhibit_new ();
+    dkp->priv->notify  = xfpm_notify_new ();
+#ifdef HAVE_POLKIT
+    dkp->priv->polkit  = xfpm_polkit_get ();
+    g_signal_connect_swapped (dkp->priv->polkit, "auth-changed",
+			      G_CALLBACK (xfpm_dkp_polkit_auth_changed_cb), dkp);
+#endif
+    
+    g_signal_connect (dkp->priv->inhibit, "has-inhibit-changed",
+		      G_CALLBACK (xfpm_dkp_inhibit_changed_cb), dkp);
+    
+    dkp->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+    
+    if ( error )
+    {
+	g_critical ("Unable to connect to the system bus : %s", error->message);
+	g_error_free (error);
+	goto out;
+    }
+    
+    dkp->priv->proxy = dbus_g_proxy_new_for_name (dkp->priv->bus,
+					          DKP_NAME,
+						  DKP_PATH,
+						  DKP_IFACE);
+    if (dkp->priv->proxy == NULL) 
+    {
+	g_critical ("Unable to create proxy for %s", DKP_NAME);
+	goto out;
+    }
+    
+    dkp->priv->proxy_prop = dbus_g_proxy_new_for_name (dkp->priv->bus,
+						       DKP_NAME,
+						       DKP_PATH,
+						       DBUS_INTERFACE_PROPERTIES);
+    if (dkp->priv->proxy_prop == NULL) 
+    {
+	g_critical ("Unable to create proxy for %s", DKP_NAME);
+	goto out;
+    }
+    
+    xfpm_dkp_get_power_devices (dkp);
+    xfpm_dkp_get_properties (dkp);
+#ifdef HAVE_POLKIT
+    xfpm_dkp_check_polkit_auth (dkp);
+#endif
+    
+    dbus_g_proxy_add_signal (dkp->priv->proxy, "Changed", G_TYPE_INVALID);
+    dbus_g_proxy_add_signal (dkp->priv->proxy, "DeviceAdded", G_TYPE_STRING, G_TYPE_INVALID);
+    dbus_g_proxy_add_signal (dkp->priv->proxy, "DeviceRemoved", G_TYPE_STRING, G_TYPE_INVALID);
+    dbus_g_proxy_add_signal (dkp->priv->proxy, "DeviceChanged", G_TYPE_STRING, G_TYPE_INVALID);
+    
+    dbus_g_proxy_connect_signal (dkp->priv->proxy, "Changed",
+				 G_CALLBACK (xfpm_dkp_changed_cb), dkp, NULL);
+    dbus_g_proxy_connect_signal (dkp->priv->proxy, "DeviceRemoved",
+				 G_CALLBACK (xfpm_dkp_device_removed_cb), dkp, NULL);
+    dbus_g_proxy_connect_signal (dkp->priv->proxy, "DeviceAdded",
+				 G_CALLBACK (xfpm_dkp_device_added_cb), dkp, NULL);
+   
+    dbus_g_proxy_connect_signal (dkp->priv->proxy, "DeviceChanged",
+				 G_CALLBACK (xfpm_dkp_device_changed_cb), dkp, NULL);
+
+    
+out:
+    xfpm_dkp_dbus_init (dkp);
+    
+    /*
+     * Emit org.freedesktop.PowerManagement session signals on startup
+     */
+    g_signal_emit (G_OBJECT (dkp), signals [ON_BATTERY_CHANGED], 0, dkp->priv->on_battery);
+}
+
+static void xfpm_dkp_set_property (GObject *object,
+				   guint prop_id,
+				   const GValue *value,
+				   GParamSpec *pspec)
+{
+    XfpmDkp *dkp;
+    dkp = XFPM_DKP (object);
+
+    switch (prop_id)
+    {
+         default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+    }
+}
+
+static void xfpm_dkp_get_property (GObject *object,
+				   guint prop_id,
+				   GValue *value,
+				   GParamSpec *pspec)
+{
+    XfpmDkp *dkp;
+    dkp = XFPM_DKP (object);
+
+    switch (prop_id)
+    {
+	case PROP_ON_BATTERY:
+	    g_value_set_boolean (value, dkp->priv->on_battery);
+	    break;
+	case PROP_AUTH_HIBERNATE:
+	    g_value_set_boolean (value, dkp->priv->auth_hibernate);
+	    break;
+	case PROP_AUTH_SUSPEND:
+	    g_value_set_boolean (value, dkp->priv->auth_suspend);
+	    break;
+	case PROP_CAN_SUSPEND:
+	    g_value_set_boolean (value, dkp->priv->can_suspend);
+	    break;
+	case PROP_CAN_HIBERNATE:
+	    g_value_set_boolean (value, dkp->priv->can_hibernate);
+	    break;
+	case PROP_HAS_LID:
+	    g_value_set_boolean (value, dkp->priv->lid_is_present);
+	    break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+    }
+}
+
+static void
+xfpm_dkp_finalize (GObject *object)
+{
+    XfpmDkp *dkp;
+
+    dkp = XFPM_DKP (object);
+    
+    g_object_unref (dkp->priv->inhibit);
+    g_object_unref (dkp->priv->notify);
+    
+    dbus_g_connection_unref (dkp->priv->bus);
+    
+    if ( dkp->priv->proxy )
+    {
+	dbus_g_proxy_disconnect_signal (dkp->priv->proxy, "Changed",
+					G_CALLBACK (xfpm_dkp_changed_cb), dkp);
+	dbus_g_proxy_disconnect_signal (dkp->priv->proxy, "DeviceRemoved",
+					G_CALLBACK (xfpm_dkp_device_removed_cb), dkp);
+	dbus_g_proxy_disconnect_signal (dkp->priv->proxy, "DeviceAdded",
+					G_CALLBACK (xfpm_dkp_device_added_cb), dkp);
+	dbus_g_proxy_disconnect_signal (dkp->priv->proxy, "DeviceChanged",
+					G_CALLBACK (xfpm_dkp_device_changed_cb), dkp);
+	g_object_unref (dkp->priv->proxy);
+    }
+    
+    if ( dkp->priv->proxy_prop )
+	g_object_unref (dkp->priv->proxy_prop);
+
+    g_hash_table_destroy (dkp->priv->hash);
+
+#ifdef HAVE_POLKIT
+    g_object_unref (dkp->priv->polkit);
+#endif
+
+    G_OBJECT_CLASS (xfpm_dkp_parent_class)->finalize (object);
+}
+
+XfpmDkp *
+xfpm_dkp_get (void)
+{
+    static gpointer xfpm_dkp_object = NULL;
+    
+    if ( G_LIKELY (xfpm_dkp_object != NULL ) )
+    {
+	g_object_ref (xfpm_dkp_object);
+    }
+    else
+    {
+	xfpm_dkp_object = g_object_new (XFPM_TYPE_DKP, NULL);
+	g_object_add_weak_pointer (xfpm_dkp_object, &xfpm_dkp_object);
+    }
+    
+    return XFPM_DKP (xfpm_dkp_object);
+}
+
+void xfpm_dkp_suspend (XfpmDkp *dkp)
+{
+}
+
+void xfpm_dkp_hibernate (XfpmDkp *dkp)
+{
+    
+}
+
+gboolean xfpm_dkp_has_battery (XfpmDkp *dkp)
+{
+    GtkStatusIcon *battery = NULL;
+    guint i, len;
+    GList *list;
+    
+    gboolean ret = FALSE;
+    
+    list = g_hash_table_get_values (dkp->priv->hash);
+    len = g_list_length (list);
+    
+    for ( i = 0; i < len; i++)
+    {
+	XfpmDkpDeviceType type;
+	battery = g_list_nth_data (list, i);
+	type = xfpm_battery_get_device_type (XFPM_BATTERY (battery));
+	if ( type == XFPM_DKP_DEVICE_TYPE_BATTERY ||
+	     type == XFPM_DKP_DEVICE_TYPE_UPS )
+	{
+	    ret = TRUE;
+	    break;
+	}
+    }
+    
+    return ret;
+}
+
+/*
+ * 
+ * DBus server implementation for org.freedesktop.PowerManagement
+ * 
+ */
+static gboolean xfpm_dkp_dbus_shutdown (XfpmDkp *dkp,
+				        GError **error);
+
+static gboolean xfpm_dkp_dbus_reboot   (XfpmDkp *dkp,
+					GError **error);
+					   
+static gboolean xfpm_dkp_dbus_hibernate (XfpmDkp * dkp,
+					 GError **error);
+
+static gboolean xfpm_dkp_dbus_suspend (XfpmDkp * dkp,
+				       GError ** error);
+
+static gboolean xfpm_dkp_dbus_can_reboot (XfpmDkp * dkp,
+					  gboolean * OUT_can_reboot, 
+					  GError ** error);
+
+static gboolean xfpm_dkp_dbus_can_shutdown (XfpmDkp * dkp,
+					    gboolean * OUT_can_reboot, 
+					    GError ** error);
+
+static gboolean xfpm_dkp_dbus_can_hibernate (XfpmDkp * dkp,
+					     gboolean * OUT_can_hibernate,
+					     GError ** error);
+
+static gboolean xfpm_dkp_dbus_can_suspend (XfpmDkp * dkp,
+					   gboolean * OUT_can_suspend,
+					   GError ** error);
+
+static gboolean xfpm_dkp_dbus_get_power_save_status (XfpmDkp * dkp,
+						     gboolean * OUT_save_power,
+						     GError ** error);
+
+static gboolean xfpm_dkp_dbus_get_on_battery (XfpmDkp * dkp,
+					      gboolean * OUT_on_battery,
+					      GError ** error);
+
+static gboolean xfpm_dkp_dbus_get_low_battery (XfpmDkp * dkp,
+					       gboolean * OUT_low_battery,
+					       GError ** error);
+
+#include "org.freedesktop.PowerManagement.h"
+
+static void
+xfpm_dkp_dbus_class_init (XfpmDkpClass * klass)
+{
+    dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
+                                     &dbus_glib_xfpm_dkp_object_info);
+}
+
+static void
+xfpm_dkp_dbus_init (XfpmDkp *dkp)
+{
+    DBusGConnection *bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+
+    dbus_g_connection_register_g_object (bus,
+                                         "/org/freedesktop/PowerManagement",
+                                         G_OBJECT (dkp));
+}
+
+static gboolean xfpm_dkp_dbus_shutdown (XfpmDkp *dkp,
+				        GError **error)
+{
+    return TRUE;
+}
+
+static gboolean xfpm_dkp_dbus_reboot   (XfpmDkp *dkp,
+					GError **error)
+{
+    return TRUE;
+}
+					   
+static gboolean xfpm_dkp_dbus_hibernate (XfpmDkp * dkp,
+					 GError **error)
+{
+    return TRUE;
+}
+
+static gboolean xfpm_dkp_dbus_suspend (XfpmDkp * dkp,
+				       GError ** error)
+{
+    return TRUE;
+}
+
+static gboolean xfpm_dkp_dbus_can_reboot (XfpmDkp * dkp,
+					  gboolean * OUT_can_reboot, 
+					  GError ** error)
+{
+    return TRUE;
+}
+
+static gboolean xfpm_dkp_dbus_can_shutdown (XfpmDkp * dkp,
+					    gboolean * OUT_can_reboot, 
+					    GError ** error)
+{
+    return TRUE;
+}
+
+static gboolean xfpm_dkp_dbus_can_hibernate (XfpmDkp * dkp,
+					     gboolean * OUT_can_hibernate,
+					     GError ** error)
+{
+    return TRUE;
+}
+
+static gboolean xfpm_dkp_dbus_can_suspend (XfpmDkp * dkp,
+					   gboolean * OUT_can_suspend,
+					   GError ** error)
+{
+    return TRUE;
+}
+
+static gboolean xfpm_dkp_dbus_get_power_save_status (XfpmDkp * dkp,
+						     gboolean * OUT_save_power,
+						     GError ** error)
+{
+    return TRUE;
+}
+
+static gboolean xfpm_dkp_dbus_get_on_battery (XfpmDkp * dkp,
+					      gboolean * OUT_on_battery,
+					      GError ** error)
+{
+    return TRUE;
+}
+
+static gboolean xfpm_dkp_dbus_get_low_battery (XfpmDkp * dkp,
+					       gboolean * OUT_low_battery,
+					       GError ** error)
+{
+    return TRUE;
+}
diff --git a/src/xfpm-dkp.h b/src/xfpm-dkp.h
new file mode 100644
index 0000000..5f3173e
--- /dev/null
+++ b/src/xfpm-dkp.h
@@ -0,0 +1,100 @@
+/*
+ * * 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_DKP_H
+#define __XFPM_DKP_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define XFPM_TYPE_DKP        (xfpm_dkp_get_type () )
+#define XFPM_DKP(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_DKP, XfpmDkp))
+#define XFPM_IS_DKP(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_DKP))
+
+#define DKP_NAME 	     "org.freedesktop.DeviceKit.Power"
+#define DKP_PATH 	     "/org/freedesktop/DeviceKit/Power"
+#define DKP_IFACE 	     "org.freedesktop.DeviceKit.Power"
+#define DKP_IFACE_DEVICE     "org.freedesktop.DeviceKit.Power.Device"
+
+typedef enum
+{
+    XFPM_DKP_DEVICE_TYPE_UNKNOWN,
+    XFPM_DKP_DEVICE_TYPE_LINE_POWER,
+    XFPM_DKP_DEVICE_TYPE_BATTERY,
+    XFPM_DKP_DEVICE_TYPE_UPS,
+    XFPM_DKP_DEVICE_TYPE_MONITOR,
+    XFPM_DKP_DEVICE_TYPE_MOUSE,
+    XFPM_DKP_DEVICE_TYPE_KBD,
+    XFPM_DKP_DEVICE_TYPE_PDA,
+    XFPM_DKP_DEVICE_TYPE_PHONE
+    
+} XfpmDkpDeviceType;
+  
+typedef enum
+{
+    XFPM_DKP_DEVICE_STATE_UNKNOWN,
+    XFPM_DKP_DEVICE_STATE_CHARGING,
+    XFPM_DKP_DEVICE_STATE_DISCHARGING,
+    XFPM_DKP_DEVICE_STATE_EMPTY,
+    XFPM_DKP_DEVICE_STATE_FULLY_CHARGED,
+    XFPM_DKP_DEVICE_STATE_PENDING_CHARGING,
+    XFPM_DKP_DEVICE_STATE_PENDING_DISCHARGING
+    
+} XfpmDkpDeviceState;
+
+typedef struct XfpmDkpPrivate XfpmDkpPrivate;
+
+typedef struct
+{
+    GObject         	parent;
+    
+    XfpmDkpPrivate     *priv;
+    
+} XfpmDkp;
+
+typedef struct
+{
+    GObjectClass 	parent_class;
+    
+    void                (*on_battery_changed)         	(XfpmDkp *dkp,
+						         gboolean on_battery);
+    
+    void                (*low_battery_changed)        	(XfpmDkp *dkp,
+							 gboolean low_battery);
+    
+    void		(*lid_changed)			(XfpmDkp *dkp,
+							 gboolean lid_is_closed);
+    
+} XfpmDkpClass;
+
+GType        		xfpm_dkp_get_type        	(void) G_GNUC_CONST;
+
+XfpmDkp       	       *xfpm_dkp_get             	(void);
+
+void			xfpm_dkp_suspend         	(XfpmDkp *dkp);
+
+void			xfpm_dkp_hibernate       	(XfpmDkp *dkp);
+
+gboolean		xfpm_dkp_has_battery		(XfpmDkp *dkp);
+
+G_END_DECLS
+
+#endif /* __XFPM_DKP_H */
diff --git a/src/xfpm-dpms.c b/src/xfpm-dpms.c
index 762860f..3c7992c 100644
--- a/src/xfpm-dpms.c
+++ b/src/xfpm-dpms.c
@@ -31,13 +31,11 @@
 
 #include <libxfce4util/libxfce4util.h>
 
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-common.h"
+#include "xfpm-common.h"
 
 #include "xfpm-dpms.h"
-#include "xfpm-adapter.h"
+#include "xfpm-dkp.h"
 #include "xfpm-xfconf.h"
-#include "xfpm-screen-saver.h"
 #include "xfpm-config.h"
 
 #ifdef HAVE_DPMS
@@ -50,18 +48,18 @@ static void xfpm_dpms_finalize   (GObject *object);
 struct XfpmDpmsPrivate
 {
     XfpmXfconf      *conf;
-    XfpmAdapter     *adapter;
-    XfpmScreenSaver *saver;
+    XfpmDkp         *dkp;
     
-    gboolean       dpms_capable;
-    gboolean       inhibited;
-    gboolean       on_battery;
+    gboolean         dpms_capable;
+    gboolean         inhibited;
     
-    gulong	   switch_off_timeout_id;
-    gulong	   switch_on_timeout_id;
+    gboolean         on_battery;
+    
+    gulong	     switch_off_timeout_id;
+    gulong	     switch_on_timeout_id;
 };
 
-G_DEFINE_TYPE(XfpmDpms, xfpm_dpms, G_TYPE_OBJECT)
+G_DEFINE_TYPE (XfpmDpms, xfpm_dpms, G_TYPE_OBJECT)
 
 static void
 xfpm_dpms_set_timeouts (XfpmDpms *dpms, guint16 standby, guint16 suspend, guint off)
@@ -92,10 +90,7 @@ xfpm_dpms_disable (XfpmDpms *dpms)
 	g_warning ("Cannot get DPMSInfo");
 	
     if ( state )
-    {
-	xfpm_dpms_set_timeouts (dpms, 0, 0, 0);
 	DPMSDisable (GDK_DISPLAY());
-    }
 }
 
 /*
@@ -206,18 +201,9 @@ xfpm_dpms_settings_changed_cb (GObject *obj, GParamSpec *spec, XfpmDpms *dpms)
 }
 
 static void
-xfpm_dpms_adapter_changed_cb (XfpmAdapter *adapter, gboolean present, XfpmDpms *dpms)
+xfpm_dpms_on_battery_changed_cb (XfpmDkp *dkp, gboolean on_battery, XfpmDpms *dpms)
 {
-    dpms->priv->on_battery = !present;
-    xfpm_dpms_refresh (dpms);
-}
-
-static void
-xfpm_dpms_inhibit_changed_cb (XfpmScreenSaver *saver, gboolean inhibited, XfpmDpms *dpms)
-{
-    dpms->priv->inhibited = inhibited;
-    TRACE ("Inhibit changed %s", xfpm_bool_to_string (inhibited));
-    
+    dpms->priv->on_battery = on_battery;
     xfpm_dpms_refresh (dpms);
 }
 
@@ -245,20 +231,19 @@ xfpm_dpms_init(XfpmDpms *dpms)
 
     if ( dpms->priv->dpms_capable )
     {
-	dpms->priv->adapter = xfpm_adapter_new ();
-	dpms->priv->saver   = xfpm_screen_saver_new ();
+	dpms->priv->dkp     = xfpm_dkp_get ();
 	dpms->priv->conf    = xfpm_xfconf_new  ();
     
-	g_signal_connect (dpms->priv->saver, "screen-saver-inhibited",
-			  G_CALLBACK(xfpm_dpms_inhibit_changed_cb), dpms);
-    
-	g_signal_connect (dpms->priv->adapter, "adapter-changed",
-			  G_CALLBACK(xfpm_dpms_adapter_changed_cb), dpms);
+	g_signal_connect (dpms->priv->dkp, "on-battery-changed",
+			  G_CALLBACK(xfpm_dpms_on_battery_changed_cb), dpms);
 			  
 	g_signal_connect (dpms->priv->conf, "notify",
 			  G_CALLBACK (xfpm_dpms_settings_changed_cb), dpms);
 			  
-	dpms->priv->on_battery = !xfpm_adapter_get_present (dpms->priv->adapter);
+	g_object_get (G_OBJECT (dpms->priv->dkp),
+		      "on-battery", &dpms->priv->on_battery,
+		      NULL);
+	
 	xfpm_dpms_refresh (dpms);
     }
     else
@@ -275,8 +260,7 @@ xfpm_dpms_finalize(GObject *object)
     dpms = XFPM_DPMS (object);
     
     g_object_unref (dpms->priv->conf);
-    g_object_unref (dpms->priv->adapter);
-    g_object_unref ( dpms->priv->saver);
+    g_object_unref (dpms->priv->dkp);
 
     G_OBJECT_CLASS(xfpm_dpms_parent_class)->finalize(object);
 }
diff --git a/src/xfpm-engine.c b/src/xfpm-engine.c
deleted file mode 100644
index ef3b2b2..0000000
--- a/src/xfpm-engine.c
+++ /dev/null
@@ -1,957 +0,0 @@
-/*
- * * Copyright (C) 2008-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/xfpm-string.h"
-#include "libxfpm/xfpm-common.h"
-#include "libxfpm/xfpm-notify.h"
-
-#ifdef HAVE_DPMS
-#include "xfpm-dpms.h"
-#endif
-
-#include "xfpm-engine.h"
-#include "xfpm-supply.h"
-#include "xfpm-adapter.h"
-#include "xfpm-xfconf.h"
-#include "xfpm-cpu.h"
-#include "xfpm-button.h"
-#include "xfpm-inhibit.h"
-#include "xfpm-backlight.h"
-#include "xfpm-screen-saver.h"
-#include "xfpm-shutdown.h"
-#include "xfpm-button-hal.h"
-#include "xfpm-idle.h"
-#include "xfpm-errors.h"
-#include "xfpm-config.h"
-#include "xfpm-enum-types.h"
-#include "xfpm-debug.h"
-
-static void xfpm_engine_finalize (GObject * object);
-
-static void xfpm_engine_dbus_class_init (XfpmEngineClass * klass);
-static void xfpm_engine_dbus_init (XfpmEngine * engine);
-
-#define XFPM_ENGINE_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_ENGINE, XfpmEnginePrivate))
-
-struct XfpmEnginePrivate
-{
-    XfpmXfconf 		*conf;
-    XfpmSupply 		*supply;
-    XfpmNotify 		*notify;
-#ifdef SYSTEM_IS_LINUX
-    XfpmCpu 		*cpu;
-#endif
-    XfpmBacklight 	*bk;
-    XfpmAdapter 	*adapter;
-    XfpmInhibit 	*inhibit;
-    XfpmShutdown        *shutdown;
-    XfpmButton          *button;
-    XfpmButtonHal       *bt_hal;
-    XfpmIdle            *idle;
-    XfpmScreenSaver     *srv;
-#ifdef HAVE_DPMS
-    XfpmDpms *dpms;
-#endif
-    gboolean inhibited;
-
-    guint8 power_management;
-    gboolean on_battery;
-    gboolean is_laptop;
-
-    gboolean has_lcd_brightness;
-    
-};
-
-enum
-{
-    ON_BATTERY_CHANGED,
-    LOW_BATTERY_CHANGED,
-    LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (XfpmEngine, xfpm_engine, G_TYPE_OBJECT)
-
-static gboolean xfpm_engine_do_suspend (XfpmEngine * engine)
-{
-    GError *error = NULL;
-
-    xfpm_suspend (engine->priv->shutdown, &error);
-
-    if (error)
-    {
-	g_warning ("%s", error->message);
-	g_error_free (error);
-    }
-    return FALSE;
-}
-
-static gboolean
-xfpm_engine_do_hibernate (XfpmEngine * engine)
-{
-    GError *error = NULL;
-
-    xfpm_hibernate (engine->priv->shutdown, &error);
-
-    if (error)
-    {
-	g_warning ("%s", error->message);
-	g_error_free (error);
-    }
-    return FALSE;
-}
-
-static gboolean
-xfpm_engine_do_shutdown (XfpmEngine * engine)
-{
-    GError *error = NULL;
-
-    xfpm_shutdown (engine->priv->shutdown, &error);
-
-    if (error)
-    {
-	g_warning ("%s", error->message);
-	g_error_free (error);
-    }
-    return FALSE;
-}
-
-/*
- * Map of int to strings shutdown values
- */
-static const gchar * G_GNUC_PURE
-xfpm_int_to_shutdown_string (gint val)
-{
-    if ( val == XFPM_DO_NOTHING )
-	return "Nothing";
-    else if ( val == XFPM_DO_SUSPEND)
-	return "Suspend";
-    else if ( val == XFPM_DO_HIBERNATE)
-	return "Hibernate";
-    else if ( val == XFPM_DO_SHUTDOWN)
-	return "Shutdown";
-    else if ( val == XFPM_ASK)
-	return "Ask";
-    
-    return "Invalid";
-}
-
-static void
-xfpm_engine_shutdown_request (XfpmEngine * engine,
-			      XfpmShutdownRequest shutdown, gboolean critical)
-{
-    gboolean lock_screen;
-    const gchar *action = xfpm_int_to_shutdown_string (shutdown);
-
-    g_object_get (G_OBJECT (engine->priv->conf),
-		  LOCK_SCREEN_ON_SLEEP, &lock_screen,
-		  NULL);
-
-    if (xfpm_strequal (action, "Nothing"))
-    {
-	TRACE ("Button is disabled in configuration");
-	return;
-    }
-    else if ( xfpm_strequal (action, "Ask") && xfpm_strequal (action, "Invalid"))
-    {
-	g_warning ("Invalid configuration action %s", action);
-	return;
-    }
-    else if ( engine->priv->inhibited == TRUE && critical == FALSE )
-    {
-	return;
-    }
-    else
-    {
-	TRACE ("Going to do %s\n", action);
-
-	if (shutdown == XFPM_DO_SHUTDOWN)
-	{
-	    xfpm_engine_do_shutdown (engine);
-	}
-	else if (shutdown == XFPM_DO_HIBERNATE)
-	{
-	    xfpm_shutdown_add_callback (engine->priv->shutdown, 
-					(GSourceFunc) xfpm_engine_do_hibernate,
-					lock_screen,
-					engine);
-	}
-	else if (shutdown == XFPM_DO_SUSPEND)
-	{
-	    xfpm_shutdown_add_callback (engine->priv->shutdown, 
-					(GSourceFunc) xfpm_engine_do_suspend,
-					lock_screen,
-					engine);
-	}
-
-    }
-}
-
-static void
-xfpm_engine_shutdown_request_battery_cb (XfpmSupply * supply,
-					 gboolean critical,
-					 XfpmShutdownRequest action,
-					 XfpmEngine * engine)
-{
-    if ( engine->priv->inhibited && critical == FALSE ) /* We can ignore the request here */
-	return;
-	
-    xfpm_engine_shutdown_request (engine, action, critical);
-}
-
-static void
-xfpm_engine_lid_event (XfpmButtonHal *bt_hal, gboolean pressed, XfpmEngine *engine)
-{
-    XfpmLidTriggerAction action;
-    
-    g_object_get (G_OBJECT (engine->priv->conf),
-		      engine->priv->on_battery ? LID_SWITCH_ON_BATTERY_CFG : LID_SWITCH_ON_AC_CFG, &action,
-		      NULL);
-
-    if ( pressed )
-    {
-	XFPM_DEBUG_ENUM ("LID close event", action, XFPM_TYPE_LID_TRIGGER_ACTION);
-	
-	if ( action == LID_TRIGGER_NOTHING )
-	{
-	    if ( !xfpm_is_multihead_connected () )
-		xfpm_dpms_force_level (engine->priv->dpms, DPMSModeOff);
-	}
-	else if ( action == LID_TRIGGER_LOCK_SCREEN )
-	{
-	    if ( !xfpm_is_multihead_connected () )
-		xfpm_lock_screen ();
-	}
-	else 
-	    xfpm_engine_shutdown_request (engine, action, FALSE);
-    }
-    else
-    {
-	XFPM_DEBUG_ENUM ("LID opened", action, XFPM_TYPE_LID_TRIGGER_ACTION);
-	xfpm_dpms_force_level (engine->priv->dpms, DPMSModeOn);
-    }
-}
-
-static void
-xfpm_engine_button_pressed_cb (XfpmButton *button,
-			       XfpmButtonKey type, XfpmEngine * engine)
-{
-    XfpmShutdownRequest req = XFPM_DO_NOTHING;
-    
-    XFPM_DEBUG_ENUM ("Received button press event", type, XFPM_TYPE_BUTTON_KEY);
-  
-    if ( engine->priv->inhibited )
-    {
-	TRACE("Power manager automatic sleep is currently disabled");
-	return;
-    }
-    
-    if ( type == BUTTON_MON_BRIGHTNESS_DOWN || type == BUTTON_MON_BRIGHTNESS_UP )
-	return;
-    
-    if ( type == BUTTON_POWER_OFF )
-    {
-	g_object_get (G_OBJECT (engine->priv->conf),
-		      POWER_SWITCH_CFG, &req,
-		      NULL);
-    }
-    else if ( type == BUTTON_SLEEP )
-    {
-	g_object_get (G_OBJECT (engine->priv->conf),
-		      SLEEP_SWITCH_CFG, &req,
-		      NULL);
-    }
-    else if ( type == BUTTON_HIBERNATE )
-    {
-	g_object_get (G_OBJECT (engine->priv->conf),
-		      HIBERNATE_SWITCH_CFG, &req,
-		      NULL);
-    }
-    else
-    {
-	g_return_if_reached ();
-    }
-
-    XFPM_DEBUG_ENUM ("Shutdown request : ", req, XFPM_TYPE_SHUTDOWN_REQUEST);
-	
-    if ( req == XFPM_ASK )
-	xfpm_shutdown_ask (engine->priv->shutdown);
-    else
-	xfpm_engine_shutdown_request (engine, req, FALSE);
-}
-
-static void
-xfpm_engine_check_hal_iface (XfpmEngine * engine)
-{
-    gboolean can_suspend, can_hibernate, caller;
-
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", &caller,
-		  "can-suspend", &can_suspend,
-		  "can-hibernate", &can_hibernate,
-		  NULL);
-
-    if ( caller )
-    {
-	if (can_hibernate)
-	    engine->priv->power_management |= SYSTEM_CAN_HIBERNATE;
-	if (can_suspend)
-	    engine->priv->power_management |= SYSTEM_CAN_SUSPEND;
-    }
-
-  //FIXME: Show errors here
-}
-
-static void
-xfpm_engine_supply_notify_cb (GObject *object, GParamSpec *spec, XfpmEngine *engine)
-{
-    gboolean low_power;
-    
-    if ( xfpm_strequal (spec->name, "on-low-battery") )
-    {
-	g_object_get (object, "on-low-battery", &low_power, NULL);
-	TRACE ("On low battery changed %s", xfpm_bool_to_string (low_power));
-	g_signal_emit (G_OBJECT (engine), signals [LOW_BATTERY_CHANGED], 0, low_power);
-    }
-}
-
-static gboolean
-xfpm_engine_load_all (gpointer data)
-{
-    XfpmEngine *engine;
-    HalManager *manager;
-
-    engine = XFPM_ENGINE (data);
-
-    xfpm_engine_check_hal_iface (engine);
-    
-    manager = hal_manager_new ();
-
-    if ( hal_manager_get_is_laptop (manager))
-	engine->priv->is_laptop = TRUE;
-    else
-	engine->priv->is_laptop = FALSE;
-
-    g_object_unref (manager);
-
-#ifdef HAVE_DPMS
-    engine->priv->dpms = xfpm_dpms_new ();
-#endif
-
-#ifdef SYSTEM_IS_LINUX
-    if (engine->priv->is_laptop)
-	engine->priv->cpu = xfpm_cpu_new ();
-#endif
-
-    engine->priv->supply = xfpm_supply_new (engine->priv->power_management);
-    g_signal_connect (G_OBJECT (engine->priv->supply), "shutdown-request",
-		      G_CALLBACK (xfpm_engine_shutdown_request_battery_cb),
-		      engine);
-		      
-    g_signal_connect (G_OBJECT (engine->priv->supply), "notify",
-		      G_CALLBACK (xfpm_engine_supply_notify_cb), engine);
-		      
-    xfpm_supply_monitor (engine->priv->supply);
-
-    engine->priv->button = xfpm_button_new ();
-
-    g_signal_connect (engine->priv->button, "button-pressed",
-		      G_CALLBACK (xfpm_engine_button_pressed_cb), engine);
-
-    engine->priv->bt_hal = xfpm_button_hal_get ();
-    g_signal_connect (engine->priv->bt_hal, "lid_event",
-		      G_CALLBACK (xfpm_engine_lid_event), engine);
-  /*
-   * Brightness HAL
-   */
-    if (engine->priv->is_laptop)
-    {
-	engine->priv->bk = xfpm_backlight_new ();
-	engine->priv->has_lcd_brightness =
-	xfpm_backlight_has_hw (engine->priv->bk);
-    }
-    return FALSE;
-}
-
-static void
-xfpm_engine_adapter_changed_cb (XfpmAdapter * adapter, gboolean present,
-				XfpmEngine * engine)
-{
-    engine->priv->on_battery = !present;
-    g_signal_emit (G_OBJECT (engine), signals [ON_BATTERY_CHANGED], 0, engine->priv->on_battery);
-    xfpm_idle_alarm_reset_all (engine->priv->idle);
-}
-
-static void
-xfpm_engine_inhibit_changed_cb (XfpmInhibit * inhibit, gboolean inhibited,
-				XfpmEngine * engine)
-{
-    engine->priv->inhibited = inhibited;
-}
-
-static void
-xfpm_engine_set_inactivity_timeouts (XfpmEngine *engine)
-{
-    guint on_ac, on_battery;
-    
-    g_object_get (G_OBJECT (engine->priv->conf),
-		  ON_AC_INACTIVITY_TIMEOUT, &on_ac,
-		  ON_BATTERY_INACTIVITY_TIMEOUT, &on_battery,
-		  NULL);
-    
-#ifdef DEBUG
-    if ( on_ac == 14 )
-	TRACE ("setting inactivity sleep timeout on ac to never");
-    else
-	TRACE ("setting inactivity sleep timeout on ac to %d", on_ac);
-    if ( on_battery == 14 )
-	TRACE ("setting inactivity sleep timeout on battery to never");
-    else
-	TRACE ("setting inactivity sleep timeout on battery to %d", on_battery);
-#endif
-    
-    if ( on_ac == 14 )
-    {
-	xfpm_idle_free_alarm (engine->priv->idle, TIMEOUT_INACTIVITY_ON_AC );
-    }
-    else
-    {
-	xfpm_idle_set_alarm (engine->priv->idle, TIMEOUT_INACTIVITY_ON_AC, on_ac * 1000 * 60);
-    }
-    
-    if ( on_battery == 14 )
-    {
-	xfpm_idle_free_alarm (engine->priv->idle, TIMEOUT_INACTIVITY_ON_BATTERY );
-    }
-    else
-    {
-	xfpm_idle_set_alarm (engine->priv->idle, TIMEOUT_INACTIVITY_ON_BATTERY, on_battery * 1000 * 60);
-    }
-}
-
-static void
-xfpm_engine_alarm_timeout_cb (XfpmIdle *idle, guint id, XfpmEngine *engine)
-{
-    XfpmShutdownRequest req = XFPM_DO_NOTHING;
-    gchar *sleep_mode;
-    gboolean saver;
-    
-    TRACE ("Alarm inactivity timeout id %d", id);
-    
-    if ( engine->priv->inhibited )
-    {
-	TRACE ("Power manager is currently inhibited");
-	return;
-    }
-    
-    saver = xfpm_screen_saver_get_inhibit (engine->priv->srv);
-    
-    if ( saver )
-    {
-	TRACE ("User disabled sleep on the context menu");
-	return;
-    }
-    
-    g_object_get (G_OBJECT (engine->priv->conf),
-		  INACTIVITY_SLEEP_MODE, &sleep_mode,
-		  NULL);
-		  
-    if ( !g_strcmp0 (sleep_mode, "Suspend") )
-	req = XFPM_DO_SUSPEND;
-    else
-	req = XFPM_DO_HIBERNATE;
-	
-    g_free (sleep_mode);
-
-    if ( id == TIMEOUT_INACTIVITY_ON_AC && engine->priv->on_battery == FALSE )
-	xfpm_engine_shutdown_request (engine, req, FALSE);
-    else if ( id ==  TIMEOUT_INACTIVITY_ON_BATTERY && engine->priv->is_laptop && engine->priv->on_battery  )
-	xfpm_engine_shutdown_request (engine, req, FALSE);
-    
-}
-
-static void
-xfpm_engine_settings_changed_cb (GObject *obj, GParamSpec *spec, XfpmEngine *engine)
-{
-    if ( g_str_has_prefix (spec->name, "inactivity") )
-	xfpm_engine_set_inactivity_timeouts (engine);
-}
-
-static void
-xfpm_engine_class_init (XfpmEngineClass * klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-    signals [ON_BATTERY_CHANGED] = 
-        g_signal_new("on-battery-changed",
-                      XFPM_TYPE_ENGINE,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmEngineClass, on_battery_changed),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__BOOLEAN,
-                      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-
-    signals [LOW_BATTERY_CHANGED] = 
-        g_signal_new("low-battery-changed",
-                      XFPM_TYPE_ENGINE,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmEngineClass, low_battery_changed),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__BOOLEAN,
-                      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-
-    object_class->finalize = xfpm_engine_finalize;
-
-    g_type_class_add_private (klass, sizeof (XfpmEnginePrivate));
-
-    xfpm_engine_dbus_class_init (klass);
-}
-
-static void
-xfpm_engine_init (XfpmEngine * engine)
-{
-    engine->priv = XFPM_ENGINE_GET_PRIVATE (engine);
-
-    engine->priv->shutdown = xfpm_shutdown_new ();
-    engine->priv->adapter = xfpm_adapter_new ();
-    engine->priv->notify = xfpm_notify_new ();
-    engine->priv->srv    = xfpm_screen_saver_new ();
-    engine->priv->inhibit = xfpm_inhibit_new ();
-    engine->priv->inhibited = FALSE;
-
-    g_signal_connect (engine->priv->inhibit, "has-inhibit-changed",
-		      G_CALLBACK (xfpm_engine_inhibit_changed_cb), engine);
-
-    engine->priv->conf = NULL;
-    engine->priv->supply = NULL;
-#ifdef HAVE_DPMS
-    engine->priv->dpms = NULL;
-#endif
-
-#ifdef SYSTEM_IS_LINUX
-    engine->priv->cpu = NULL;
-#endif
-
-    engine->priv->button = NULL;
-    engine->priv->bk = NULL;
-
-    engine->priv->power_management = 0;
-
-    xfpm_engine_dbus_init (engine);
-
-    engine->priv->conf = xfpm_xfconf_new ();
-
-    engine->priv->on_battery =
-	!xfpm_adapter_get_present (engine->priv->adapter);
-
-    g_signal_connect (engine->priv->adapter, "adapter-changed",
-		      G_CALLBACK (xfpm_engine_adapter_changed_cb), engine);
-
-    engine->priv->idle    = xfpm_idle_new ();
-
-    g_signal_connect (engine->priv->idle, "alarm-timeout",
-		      G_CALLBACK (xfpm_engine_alarm_timeout_cb), engine);
-		      
-    g_signal_connect (engine->priv->conf, "notify",
-		      G_CALLBACK (xfpm_engine_settings_changed_cb), engine);
-		    
-    xfpm_engine_set_inactivity_timeouts (engine);
-    
-    g_idle_add ((GSourceFunc)xfpm_engine_load_all, engine);
-}
-
-static void
-xfpm_engine_finalize (GObject * object)
-{
-    XfpmEngine *engine;
-
-    engine = XFPM_ENGINE (object);
-
-    g_object_unref (engine->priv->conf);
-
-    g_object_unref (engine->priv->supply);
-    
-    g_object_unref (engine->priv->button);
-    
-    g_object_unref (engine->priv->idle);
-    g_object_unref (engine->priv->bt_hal);
-
-#ifdef HAVE_DPMS
-    if (engine->priv->dpms)
-	g_object_unref (engine->priv->dpms);
-#endif
-
-#ifdef SYSTEM_IS_LINUX
-    if (engine->priv->cpu)
-	g_object_unref (engine->priv->cpu);
-#endif
-
-    g_object_unref (engine->priv->shutdown);
-
-    g_object_unref (engine->priv->adapter);
-    
-    g_object_unref (engine->priv->srv);
-
-    if (engine->priv->bk)
-	g_object_unref (engine->priv->bk);
-
-    g_object_unref (engine->priv->notify);
-
-    G_OBJECT_CLASS (xfpm_engine_parent_class)->finalize (object);
-}
-
-XfpmEngine *
-xfpm_engine_new (void)
-{
-    XfpmEngine *engine = NULL;
-    engine = g_object_new (XFPM_TYPE_ENGINE, NULL);
-
-    return engine;
-}
-
-void
-xfpm_engine_get_info (XfpmEngine * engine, GHashTable *hash)
-{
-    guint8 mapped_buttons;
-    gboolean user_privilege = FALSE;
-    gboolean can_suspend = FALSE;
-    gboolean can_hibernate = FALSE;
-    gboolean has_sleep_button = FALSE;
-    gboolean has_hibernate_button = FALSE;
-    gboolean has_power_button = FALSE;
-    
-    g_return_if_fail (XFPM_IS_ENGINE (engine));
-
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", &user_privilege,
-		  "can-suspend", &can_suspend,
-		  "can-hibernate", &can_hibernate, NULL);
-		  
-   
-    mapped_buttons = xfpm_button_get_mapped (engine->priv->button);
-    
-    if ( mapped_buttons & SLEEP_KEY )
-	has_sleep_button = TRUE;
-    if ( mapped_buttons & HIBERNATE_KEY )
-	has_hibernate_button = TRUE;
-    if ( mapped_buttons & POWER_KEY )
-	has_power_button = TRUE;
-	
-    g_hash_table_insert (hash, g_strdup ("caller-privilege"), g_strdup (xfpm_bool_to_string (user_privilege)));
-    g_hash_table_insert (hash, g_strdup ("can-suspend"), g_strdup (xfpm_bool_to_string (can_suspend)));
-    g_hash_table_insert (hash, g_strdup ("can-hibernate"), g_strdup (xfpm_bool_to_string (can_hibernate)));
-    g_hash_table_insert (hash, g_strdup ("system-laptop"), g_strdup (xfpm_bool_to_string (engine->priv->is_laptop)));
-    g_hash_table_insert (hash, g_strdup ("has-brightness"), g_strdup (xfpm_bool_to_string (engine->priv->has_lcd_brightness)));
-    g_hash_table_insert (hash, g_strdup ("sleep-button"), g_strdup (xfpm_bool_to_string (has_sleep_button)));
-    g_hash_table_insert (hash, g_strdup ("power-button"), g_strdup (xfpm_bool_to_string (has_power_button)));
-    g_hash_table_insert (hash, g_strdup ("hibernate-button"), g_strdup (xfpm_bool_to_string (has_hibernate_button)));
-}
-
-void xfpm_engine_reload_hal_objects (XfpmEngine *engine)
-{
-    g_return_if_fail (XFPM_IS_ENGINE (engine));
-    
-    xfpm_adapter_reload (engine->priv->adapter);
-    xfpm_supply_reload  (engine->priv->supply);
-    
-    
-    xfpm_shutdown_reload (engine->priv->shutdown);
-    
-    if ( engine->priv->is_laptop )
-    {
-	xfpm_backlight_reload (engine->priv->bk);
-#ifdef SYSTEM_IS_LINUX
-	xfpm_cpu_reload       (engine->priv->cpu);
-#endif
-    }
-}
-
-/*
- * 
- * DBus server implementation for org.freedesktop.PowerManagement
- * 
- */
-static gboolean xfpm_engine_dbus_shutdown (XfpmEngine *engine,
-					   GError **error);
-
-static gboolean xfpm_engine_dbus_reboot   (XfpmEngine *engine,
-					   GError **error);
-					   
-static gboolean xfpm_engine_dbus_hibernate (XfpmEngine * engine,
-					    GError **error);
-
-static gboolean xfpm_engine_dbus_suspend (XfpmEngine * engine,
-					  GError ** error);
-
-static gboolean xfpm_engine_dbus_can_reboot (XfpmEngine * engine,
-					     gboolean * OUT_can_reboot, 
-					     GError ** error);
-
-static gboolean xfpm_engine_dbus_can_shutdown (XfpmEngine * engine,
-					       gboolean * OUT_can_reboot, 
-					       GError ** error);
-
-static gboolean xfpm_engine_dbus_can_hibernate (XfpmEngine * engine,
-						gboolean * OUT_can_hibernate,
-						GError ** error);
-
-static gboolean xfpm_engine_dbus_can_suspend (XfpmEngine * engine,
-					      gboolean * OUT_can_suspend,
-					      GError ** error);
-
-static gboolean xfpm_engine_dbus_get_power_save_status (XfpmEngine * engine,
-						        gboolean * OUT_save_power,
-						        GError ** error);
-
-static gboolean xfpm_engine_dbus_get_on_battery (XfpmEngine * engine,
-						 gboolean * OUT_on_battery,
-						 GError ** error);
-
-static gboolean xfpm_engine_dbus_get_low_battery (XfpmEngine * engine,
-						  gboolean * OUT_low_battery,
-						  GError ** error);
-
-#include "org.freedesktop.PowerManagement.h"
-
-static void
-xfpm_engine_dbus_class_init (XfpmEngineClass * klass)
-{
-    dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
-				     &dbus_glib_xfpm_engine_object_info);
-}
-
-static void
-xfpm_engine_dbus_init (XfpmEngine * engine)
-{
-    DBusGConnection *bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
-
-    dbus_g_connection_register_g_object (bus,
-				         "/org/freedesktop/PowerManagement",
-				         G_OBJECT (engine));
-}
-
-static gboolean xfpm_engine_dbus_shutdown (XfpmEngine *engine,
-					   GError **error)
-{
-    gboolean caller_privilege, can_hibernate;
-    
-    TRACE ("Hibernate message received");
-
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", &caller_privilege,
-		  "can-hibernate", &can_hibernate, NULL);
-
-    if (!caller_privilege)
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
-		    _("Permission denied"));
-	return FALSE;
-    }
-
-    if ( engine->priv->inhibited )
-	return TRUE;
-
-    xfpm_shutdown (engine->priv->shutdown, NULL);
-    
-    return TRUE;
-}
-
-static gboolean xfpm_engine_dbus_reboot   (XfpmEngine *engine,
-					   GError **error)
-{
-    gboolean caller_privilege;
-    
-    TRACE ("Reboot message received");
-
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", &caller_privilege,
-		  NULL);
-
-    if (!caller_privilege)
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
-		    _("Permission denied"));
-	return FALSE;
-    }
-
-    if ( engine->priv->inhibited )
-	return TRUE;
-
-    xfpm_reboot (engine->priv->shutdown, NULL);
-    
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_hibernate (XfpmEngine * engine, GError ** error)
-{
-    gboolean caller_privilege, can_hibernate;
-    
-    TRACE ("Hibernate message received");
-
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", &caller_privilege,
-		  "can-hibernate", &can_hibernate, NULL);
-
-    if (!caller_privilege)
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
-		    _("Permission denied"));
-	return FALSE;
-    }
-
-    if (!can_hibernate)
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_NO_HARDWARE_SUPPORT,
-		    _("Hibernate not supported"));
-	return FALSE;
-    }
-
-    xfpm_engine_shutdown_request (engine, XFPM_DO_HIBERNATE, FALSE);
-
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_suspend (XfpmEngine * engine, GError ** error)
-{
-    gboolean caller_privilege, can_suspend;
-    TRACE ("Suspend message received");
-
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", &caller_privilege,
-		  "can-suspend", &can_suspend, NULL);
-
-    if (!caller_privilege)
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
-		    _("Permission denied"));
-	return FALSE;
-    }
-
-    if (!can_suspend)
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_NO_HARDWARE_SUPPORT,
-		    _("Suspend not supported"));
-	return FALSE;
-    }
-
-    xfpm_engine_shutdown_request (engine, XFPM_DO_SUSPEND, FALSE);
-
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_can_shutdown (XfpmEngine * engine,
-			       gboolean * OUT_can_shutdown, GError ** error)
-{
-    TRACE ("Can shutdown message received");
-    
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", OUT_can_shutdown, NULL);
-
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_can_reboot (XfpmEngine * engine,
-			     gboolean * OUT_can_reboot, GError ** error)
-{
-    TRACE ("Can reboot message received");
-    
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", OUT_can_reboot, NULL);
-
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_can_hibernate (XfpmEngine * engine,
-				gboolean * OUT_can_hibernate, GError ** error)
-{
-    TRACE ("Can hibernate message received");
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		    "can-hibernate", OUT_can_hibernate, NULL);
-
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_can_suspend (XfpmEngine * engine,
-			      gboolean * OUT_can_suspend, GError ** error)
-{
-    TRACE ("Can suspend message received");
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "can-suspend", OUT_can_suspend, NULL);
-
-    return TRUE;
-}
-
-static gboolean xfpm_engine_dbus_get_power_save_status (XfpmEngine * engine,
-						        gboolean * OUT_save_power,
-						        GError ** error)
-{
-    gboolean save_power;
-    
-    TRACE ("Can power save message received");
-    
-    g_object_get (G_OBJECT (engine->priv->conf),
-		  POWER_SAVE_ON_BATTERY, &save_power,
-		  NULL);
-		  
-    *OUT_save_power = save_power && engine->priv->on_battery;
-    
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_get_on_battery (XfpmEngine * engine,
-				 gboolean * OUT_on_battery, GError ** error)
-{
-    TRACE ("On battery message received");
-    *OUT_on_battery = engine->priv->on_battery;
-
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_get_low_battery (XfpmEngine * engine,
-				  gboolean * OUT_low_battery, GError ** error)
-{
-    TRACE ("On low battery message received");
-    *OUT_low_battery = xfpm_supply_on_low_battery (engine->priv->supply);
-
-    return TRUE;
-}
diff --git a/src/xfpm-engine.h b/src/xfpm-engine.h
deleted file mode 100644
index 3c98c16..0000000
--- a/src/xfpm-engine.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * * Copyright (C) 2008-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_ENGINE_H
-#define __XFPM_ENGINE_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_ENGINE        (xfpm_engine_get_type () )
-#define XFPM_ENGINE(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_ENGINE, XfpmEngine))
-#define XFPM_IS_ENGINE(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_ENGINE))
-
-typedef struct XfpmEnginePrivate XfpmEnginePrivate;
-
-typedef struct
-{
-    GObject		  parent;
-    XfpmEnginePrivate	 *priv;
-    
-} XfpmEngine;
-
-typedef struct
-{
-    GObjectClass 	  parent_class;
-    
-    void                  (*on_battery_changed)       	(XfpmEngine *engine,
-							 gboolean    on_battery);
-    
-    void                  (*low_battery_changed)       	(XfpmEngine *engine,
-							 gboolean    low_battery);
-							 
-} XfpmEngineClass;
-
-GType        	  	  xfpm_engine_get_type        	(void) G_GNUC_CONST;
-XfpmEngine       	 *xfpm_engine_new             	(void);
-
-void              	  xfpm_engine_get_info        	(XfpmEngine *engine,
-							 GHashTable *hash);
-							 						       
-void                     xfpm_engine_reload_hal_objects (XfpmEngine *engine);
-G_END_DECLS
-
-#endif /* __XFPM_ENGINE_H */
diff --git a/src/xfpm-enum-glib.h b/src/xfpm-enum-glib.h
index 41989c6..263a7e1 100644
--- a/src/xfpm-enum-glib.h
+++ b/src/xfpm-enum-glib.h
@@ -48,19 +48,6 @@ typedef enum
 
 typedef enum
 {
-    BATTERY_FULLY_CHARGED,
-    BATTERY_NOT_FULLY_CHARGED,
-    BATTERY_IS_CHARGING,
-    BATTERY_IS_DISCHARGING,
-    BATTERY_CHARGE_LOW,
-    BATTERY_CHARGE_CRITICAL,
-    BATTERY_NOT_PRESENT,
-    BATTERY_STATE_UNKNOWN
-    
-} XfpmBatteryState;
-
-typedef enum
-{
     BUTTON_UNKNOWN = 0,
     BUTTON_POWER_OFF,
     BUTTON_HIBERNATE,
diff --git a/src/xfpm-idle.c b/src/xfpm-idle.c
deleted file mode 100644
index 5eeb917..0000000
--- a/src/xfpm-idle.c
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * * Copyright (C) 2008-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
- */
-
-/*
- * Modified version of libidletime from gpm version 2.24.2
- * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-#include <X11/Xlib.h>
-#include <X11/extensions/sync.h>
-#include <gdk/gdkx.h>
-#include <gdk/gdk.h>
-
-#include "xfpm-idle.h"
-
-static void xfpm_idle_finalize   (GObject *object);
-
-#define XFPM_IDLE_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_IDLE, XfpmIdlePrivate))
-
-/*
- * Undef and use the function instead of the macro
- * as the macro is buggy.
- */
-#ifdef XSyncValueAdd
-#undef XSyncValueAdd
-#endif
-
-struct XfpmIdlePrivate
-{
-    int 		sync_event;
-    XSyncCounter	idle_counter;
-    GPtrArray          *array;
-};
-
-typedef struct
-{
-    guint	id;
-    XSyncValue  timeout;
-    XSyncAlarm  xalarm;
-    
-} IdleAlarm;
-
-enum
-{
-    RESET,
-    ALARM_TIMEOUT,
-    LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmIdle, xfpm_idle, G_TYPE_OBJECT)
-
-static void
-xfpm_idle_class_init(XfpmIdleClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-     signals[RESET] =
-	    g_signal_new("reset",
-			 XFPM_TYPE_IDLE,
-			 G_SIGNAL_RUN_LAST,
-			 G_STRUCT_OFFSET(XfpmIdleClass, reset),
-			 NULL, NULL,
-			 g_cclosure_marshal_VOID__VOID,
-			 G_TYPE_NONE, 0, G_TYPE_NONE);
-
-    signals[ALARM_TIMEOUT] =
-	    g_signal_new("alarm-timeout",
-			 XFPM_TYPE_IDLE,
-			 G_SIGNAL_RUN_LAST,
-			 G_STRUCT_OFFSET(XfpmIdleClass, alarm_timeout),
-			 NULL, NULL,
-			 g_cclosure_marshal_VOID__INT,
-			 G_TYPE_NONE, 1, G_TYPE_INT);
-			 
-    object_class->finalize = xfpm_idle_finalize;
-
-    g_type_class_add_private(klass,sizeof(XfpmIdlePrivate));
-}
-
-static IdleAlarm *
-xfpm_idle_find_alarm (XfpmIdle *idle, guint id)
-{
-    guint i;
-    IdleAlarm *alarm;
-    for (i = 0; i<idle->priv->array->len; i++) 
-    {
-	alarm = g_ptr_array_index (idle->priv->array, i);
-	if (alarm->id == id)
-	{
-	    return alarm;
-	}
-    }
-    return NULL;
-}
-
-static void
-xfpm_idle_xsync_alarm_set (XfpmIdle *idle, IdleAlarm *alarm, gboolean positive)
-{
-    XSyncAlarmAttributes attr;
-    XSyncValue delta;
-    unsigned int flags;
-    XSyncTestType test;
-
-    if (positive) 
-	test = XSyncPositiveComparison;
-    else 
-	test = XSyncNegativeComparison;
-
-    XSyncIntToValue (&delta, 0);
-
-    attr.trigger.counter = idle->priv->idle_counter;
-    attr.trigger.value_type = XSyncAbsolute;
-    attr.trigger.test_type = test;
-    attr.trigger.wait_value = alarm->timeout;
-    attr.delta = delta;
-
-    flags = XSyncCACounter | XSyncCAValueType | XSyncCATestType | XSyncCAValue | XSyncCADelta;
-
-    if ( alarm->xalarm ) 
-	XSyncChangeAlarm ( GDK_DISPLAY (), alarm->xalarm, flags, &attr);
-    else 
-	alarm->xalarm = XSyncCreateAlarm (GDK_DISPLAY (), flags, &attr);
-}
-
-static void
-xfpm_idle_xsync_value_add_one (XSyncValue *from, XSyncValue *to)
-{
-    int overflow;
-    XSyncValue add;
-    XSyncIntToValue (&add, -1);
-    XSyncValueAdd (to, *from, add, &overflow);
-}
-
-static void
-xfpm_idle_x_set_reset (XfpmIdle *idle, XSyncAlarmNotifyEvent *alarm_event)
-{
-    IdleAlarm *alarm;
-    
-    alarm = xfpm_idle_find_alarm (idle, 0);
-    xfpm_idle_xsync_value_add_one (&alarm_event->counter_value, &alarm->timeout);
-    xfpm_idle_xsync_alarm_set (idle, alarm, FALSE);
-}
-
-static IdleAlarm *
-xfpm_idle_alarm_find_event (XfpmIdle *idle, XSyncAlarmNotifyEvent *alarm_event)
-{
-    guint i;
-    IdleAlarm *alarm;
-    
-    for (i=0; i<idle->priv->array->len; i++) 
-    {
-	alarm = g_ptr_array_index (idle->priv->array, i);
-	if (alarm_event->alarm == alarm->xalarm) 
-	{
-	    return alarm;
-	}
-    }
-    return NULL;
-}
-
-void
-xfpm_idle_alarm_reset_all (XfpmIdle *idle)
-{
-    guint i;
-    IdleAlarm *alarm;
-
-    for ( i=1; i<idle->priv->array->len; i++) 
-    {
-	alarm = g_ptr_array_index (idle->priv->array, i);
-	xfpm_idle_xsync_alarm_set (idle, alarm, TRUE);
-    }
-	
-    g_signal_emit (G_OBJECT(idle), signals[RESET], 0 );
-}
-
-static GdkFilterReturn
-xfpm_idle_x_event_filter (GdkXEvent *gdkxevent, GdkEvent *event, gpointer data)
-{
-    IdleAlarm *alarm;
-    XfpmIdle *idle = (XfpmIdle *) data;
-    XEvent *xevent = ( XEvent *) gdkxevent;
-    XSyncAlarmNotifyEvent *alarm_event;
-    
-    if ( xevent->type != idle->priv->sync_event + XSyncAlarmNotify )
-        return GDK_FILTER_CONTINUE;
-    
-    alarm_event = (XSyncAlarmNotifyEvent *) xevent;
-    
-    alarm = xfpm_idle_alarm_find_event (idle, alarm_event);
-    
-    if ( alarm )
-    {
-	if (alarm->id != 0 )
-	{
-	    g_signal_emit (G_OBJECT(idle), signals[ALARM_TIMEOUT], 0, alarm->id );
-	    xfpm_idle_x_set_reset (idle, alarm_event);
-	    return GDK_FILTER_CONTINUE;
-	}
-	xfpm_idle_alarm_reset_all (idle);
-    }
-    
-    return GDK_FILTER_CONTINUE;
-}
-
-static IdleAlarm *
-xfpm_idle_new_alarm_internal (XfpmIdle *idle, guint id)
-{
-    IdleAlarm *alarm;
-    alarm = g_new0 (IdleAlarm, 1);
-    alarm->id = id;
-    g_ptr_array_add (idle->priv->array, alarm);
-    
-    return alarm;
-}
-
-static void
-xfpm_idle_init (XfpmIdle *idle)
-{
-    IdleAlarm *alarm;
-    int sync_error = 0;
-    int ncounters;
-    XSyncSystemCounter *counters;
-    int i;
-    
-    idle->priv = XFPM_IDLE_GET_PRIVATE(idle);
-    
-    idle->priv->array = g_ptr_array_new ();
-    idle->priv->sync_event = 0;
-    
-    if (!XSyncQueryExtension (GDK_DISPLAY (), &idle->priv->sync_event, &sync_error) )
-    {
-	g_warning ("No Sync extension.");
-	return;
-    }
-    
-    counters = XSyncListSystemCounters (GDK_DISPLAY (), &ncounters);
-    
-    for ( i = 0; i < ncounters && !idle->priv->idle_counter; i++)
-    {
-	if (!strcmp(counters[i].name, "IDLETIME"))
-	    idle->priv->idle_counter = counters[i].counter;
-    }
-    
-    XSyncFreeSystemCounterList (counters);
-    
-    if ( !idle->priv->idle_counter )
-    {
-	g_warning ("No idle counter.");
-	return;
-    }
-    
-    gdk_window_add_filter (NULL, xfpm_idle_x_event_filter, idle);
-    
-    alarm = xfpm_idle_new_alarm_internal (idle, 0);
-}
-
-static void
-xfpm_idle_free_alarm_internal (XfpmIdle *idle, IdleAlarm *alarm)
-{
-    gdk_error_trap_push ();
-    XSyncDestroyAlarm (GDK_DISPLAY(), alarm->xalarm);
-    gdk_flush ();
-    gdk_error_trap_pop ();
-    g_free(alarm);
-    g_ptr_array_remove (idle->priv->array, alarm);
-}
-
-static void
-xfpm_idle_finalize(GObject *object)
-{
-    guint i;
-    XfpmIdle *idle;
-    IdleAlarm *alarm;
-    
-    idle = XFPM_IDLE(object);
-
-    for ( i = 0; i<idle->priv->array->len; i++) 
-    {
-	alarm = g_ptr_array_index (idle->priv->array, i);
-	xfpm_idle_free_alarm_internal (idle, alarm);
-    }
-    g_ptr_array_free (idle->priv->array, TRUE);
-    
-    gdk_window_remove_filter (NULL, xfpm_idle_x_event_filter, idle);
-
-    G_OBJECT_CLASS(xfpm_idle_parent_class)->finalize(object);
-}
-
-XfpmIdle *
-xfpm_idle_new(void)
-{
-    XfpmIdle *idle = NULL;
-    idle = g_object_new (XFPM_TYPE_IDLE,NULL);
-    return idle;
-}
-
-gboolean 
-xfpm_idle_set_alarm (XfpmIdle *idle, guint id, gint timeout)
-{
-    IdleAlarm *alarm;
-    
-    g_return_val_if_fail (XFPM_IS_IDLE (idle), FALSE);
-    
-    if ( id == 0 )
-	return FALSE;
-	
-    if ( timeout == 0 )
-	return FALSE;
-    
-    alarm = xfpm_idle_find_alarm (idle, id);
-    
-    if ( !alarm )
-    {
-	alarm = xfpm_idle_new_alarm_internal (idle, id);
-    }
-    
-    XSyncIntToValue (&alarm->timeout, timeout);
-    xfpm_idle_xsync_alarm_set (idle, alarm, TRUE);
-    return TRUE;
-}
-
-gboolean xfpm_idle_free_alarm (XfpmIdle *idle, guint id)
-{
-    IdleAlarm *alarm;
-    
-    g_return_val_if_fail (XFPM_IS_IDLE (idle), FALSE);
-    
-    if ( id == 0 )
-	return FALSE;
-	
-    alarm = xfpm_idle_find_alarm (idle, id);
-    
-    if ( alarm )
-    {
-	xfpm_idle_free_alarm_internal (idle, alarm);
-	return TRUE;
-    }
-    
-    return FALSE;
-}
diff --git a/src/xfpm-idle.h b/src/xfpm-idle.h
deleted file mode 100644
index 84e9596..0000000
--- a/src/xfpm-idle.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * * Copyright (C) 2008-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_IDLE_H
-#define __XFPM_IDLE_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_IDLE        (xfpm_idle_get_type () )
-#define XFPM_IDLE(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_IDLE, XfpmIdle))
-#define XFPM_IS_IDLE(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_IDLE))
-
-enum
-{
-    TIMEOUT_INPUT = 0,
-    TIMEOUT_BRIGHTNESS_ON_AC,
-    TIMEOUT_BRIGHTNESS_ON_BATTERY,
-    TIMEOUT_INACTIVITY_ON_AC,
-    TIMEOUT_INACTIVITY_ON_BATTERY
-};
-
-typedef struct XfpmIdlePrivate XfpmIdlePrivate;
-
-typedef struct
-{
-    GObject		  parent;
-    XfpmIdlePrivate	 *priv;
-    
-} XfpmIdle;
-
-typedef struct
-{
-    GObjectClass 	  parent_class;
-    
-    void                 (*alarm_timeout)	    (XfpmIdle *idle,
-						     guint id);
-						     
-    void		 (*reset)		    (XfpmIdle *idle);
-    
-} XfpmIdleClass;
-
-GType        		  xfpm_idle_get_type        (void) G_GNUC_CONST;
-XfpmIdle       		 *xfpm_idle_new             (void);
-
-gboolean                  xfpm_idle_set_alarm       (XfpmIdle *idle,
-						     guint id,
-						     gint timeout);
-						     
-void                      xfpm_idle_alarm_reset_all (XfpmIdle *idle);
-
-gboolean                  xfpm_idle_free_alarm      (XfpmIdle *idle,
-						     guint id);
-G_END_DECLS
-
-#endif /* __XFPM_IDLE_H */
diff --git a/src/xfpm-main.c b/src/xfpm-main.c
index 3004567..80c2f42 100644
--- a/src/xfpm-main.c
+++ b/src/xfpm-main.c
@@ -33,19 +33,15 @@
 #include <glib.h>
 
 #include <libxfce4util/libxfce4util.h>
+#include <libxfce4ui/libxfce4ui.h>
 
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 
-#include "libxfpm/xfpm-dbus.h"
-#include "libxfpm/xfpm-popups.h"
+#include "xfpm-dbus.h"
 
 #include "xfce-power-manager-dbus-client.h"
 #include "xfpm-manager.h"
-#include "xfpm-session.h"
-
-static gchar    *client_id = NULL;
-static gboolean no_daemon  = FALSE;
 
 static void G_GNUC_NORETURN
 show_version (void)
@@ -71,51 +67,44 @@ xfpm_quit_signal (gint sig, gpointer data)
 }
 
 static void G_GNUC_NORETURN
-xfpm_start (DBusGConnection *bus)
+xfpm_start (DBusGConnection *bus, const gchar *client_id)
 {
     XfpmManager *manager;
-    XfpmSession *session;
     GError *error = NULL;
     
     TRACE ("Starting the power manager");
-    session = xfpm_session_new ();
-    
-    if ( client_id != NULL )
-	xfpm_session_set_client_id (session, client_id);
-	
-    xfpm_session_real_init (session);
     
-    manager = xfpm_manager_new (bus);
+    manager = xfpm_manager_new (bus, client_id);
     
     if ( xfce_posix_signal_handler_init (&error)) 
     {
-        xfce_posix_signal_handler_set_handler(SIGHUP,
-                                              xfpm_quit_signal,
-                                              manager, NULL);
+        xfce_posix_signal_handler_set_handler (SIGHUP,
+                                               xfpm_quit_signal,
+                                               manager, NULL);
 
-        xfce_posix_signal_handler_set_handler(SIGINT,
-                                              xfpm_quit_signal,
-					      manager, NULL);
+        xfce_posix_signal_handler_set_handler (SIGINT,
+                                               xfpm_quit_signal,
+					       manager, NULL);
 
-        xfce_posix_signal_handler_set_handler(SIGTERM,
-                                              xfpm_quit_signal,
-                                              manager, NULL);
+        xfce_posix_signal_handler_set_handler (SIGTERM,
+                                               xfpm_quit_signal,
+                                               manager, NULL);
     } 
     else 
     {
         g_warning ("Unable to set up POSIX signal handlers: %s", error->message);
-        g_error_free(error);
+        g_error_free (error);
     }
 
     xfpm_manager_start (manager);
     gtk_main ();
     
-    g_object_unref (session);
+    g_object_unref (manager);
     
     exit (EXIT_SUCCESS);
 }
 
-int main(int argc, char **argv)
+int main (int argc, char **argv)
 {
     DBusGConnection *bus;
     GError *error = NULL;
@@ -126,6 +115,8 @@ int main(int argc, char **argv)
     gboolean config     = FALSE;
     gboolean version    = FALSE;
     gboolean reload     = FALSE;
+    gboolean no_daemon  = FALSE;
+    gchar   *client_id  = NULL;
     
     GOptionEntry option_entries[] = 
     {
@@ -145,19 +136,19 @@ int main(int argc, char **argv)
     dbus_g_thread_init ();
 
     xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
-
+    
     if (!gtk_init_with_args (&argc, &argv, (gchar *)"", option_entries, (gchar *)PACKAGE, &error)) 
     {
-        if(G_LIKELY(error)) 
+        if (G_LIKELY (error)) 
         {
-            g_printerr("%s: %s.\n", G_LOG_DOMAIN, error->message);
-            g_printerr(_("Type '%s --help' for usage."), G_LOG_DOMAIN);
-            g_printerr("\n");
-            g_error_free(error);
+            g_printerr ("%s: %s.\n", G_LOG_DOMAIN, error->message);
+            g_printerr (_("Type '%s --help' for usage."), G_LOG_DOMAIN);
+            g_printerr ("\n");
+            g_error_free (error);
         }
         else
         {
-            g_error("Unable to open display.");
+            g_error ("Unable to open display.");
 	}
 
         return EXIT_FAILURE;
@@ -165,15 +156,15 @@ int main(int argc, char **argv)
     
     if ( version )    
     {
-	show_version();
+	show_version ();
     }
     
     if ( run + quit + config + version > 1 )
     {
-	g_printerr(_("Too many arguments"));
-	g_printerr("\n");
-	g_printerr(_("Type '%s --help' for usage."), G_LOG_DOMAIN);
-	g_printerr("\n");
+	g_printerr (_("Too many arguments"));
+	g_printerr ("\n");
+	g_printerr (_("Type '%s --help' for usage."), G_LOG_DOMAIN);
+	g_printerr ("\n");
 	return EXIT_FAILURE;
     }
 
@@ -182,41 +173,39 @@ int main(int argc, char **argv)
 	g_critical ("Could not daemonize");
     }
     
-    bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+    bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
             
     if ( error )
     {
-	gchar *message = g_strdup(_("Unable to get connection to the message bus session"));
-	message = g_strdup_printf("%s: ",error->message);
-	
-	xfpm_error (_("Xfce Power Manager"),
-		    message );
-			   
-	g_error ("%s: \n", message);
+	xfce_dialog_show_error (NULL, 
+				error, 
+				"%s",
+				_("Unable to get connection to the message bus session"));
+	g_error ("%s: \n", error->message);
     }
     
     if ( quit )
     {
-	if (!xfpm_dbus_name_has_owner(dbus_g_connection_get_connection(bus), 
-				      "org.xfce.PowerManager") )
+	if (!xfpm_dbus_name_has_owner (dbus_g_connection_get_connection(bus), 
+				       "org.xfce.PowerManager") )
         {
-            g_print(_("Xfce power manager is not running"));
-	    g_print("\n");
+            g_print (_("Xfce power manager is not running"));
+	    g_print ("\n");
             return EXIT_SUCCESS;
         }
 	else
 	{
-	    proxy = dbus_g_proxy_new_for_name(bus, 
-			                      "org.xfce.PowerManager",
-					      "/org/xfce/PowerManager",
-					      "org.xfce.Power.Manager");
+	    proxy = dbus_g_proxy_new_for_name (bus, 
+			                       "org.xfce.PowerManager",
+					       "/org/xfce/PowerManager",
+					       "org.xfce.Power.Manager");
 	    if ( !proxy ) 
 	    {
 		g_critical ("Failed to get proxy");
 		dbus_g_connection_unref(bus);
             	return EXIT_FAILURE;
 	    }
-	    xfpm_manager_dbus_client_quit(proxy , &error);
+	    xfpm_manager_dbus_client_quit (proxy , &error);
 	    g_object_unref (proxy);
 	    
 	    if ( error)
@@ -243,20 +232,21 @@ int main(int argc, char **argv)
     
     if ( reload )
     {
-	if (!xfpm_dbus_name_has_owner(dbus_g_connection_get_connection (bus), "org.xfce.PowerManager") &&
-	    !xfpm_dbus_name_has_owner (dbus_g_connection_get_connection(bus), "org.freedesktop.PowerManagement"))
+	if (!xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (bus), "org.xfce.PowerManager") &&
+	    !xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (bus), "org.freedesktop.PowerManagement"))
 	{
 	    g_print ("Xfce power manager is not running\n");
-	    xfpm_start (bus);
+	    xfpm_start (bus, client_id);
 	}
-	proxy = dbus_g_proxy_new_for_name(bus, 
-			                      "org.xfce.PowerManager",
-					      "/org/xfce/PowerManager",
-					      "org.xfce.Power.Manager");
+	
+	proxy = dbus_g_proxy_new_for_name (bus, 
+			                   "org.xfce.PowerManager",
+					   "/org/xfce/PowerManager",
+					   "org.xfce.Power.Manager");
 	if ( !proxy ) 
 	{
 	    g_critical ("Failed to get proxy");
-	    dbus_g_connection_unref(bus);
+	    dbus_g_connection_unref (bus);
 	    return EXIT_FAILURE;
 	}
 	    
@@ -270,15 +260,15 @@ int main(int argc, char **argv)
 	return EXIT_SUCCESS;
     }
     
-    if (xfpm_dbus_name_has_owner (dbus_g_connection_get_connection(bus), "org.freedesktop.PowerManagement") )
+    if (xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (bus), "org.freedesktop.PowerManagement") )
     {
 	g_print ("%s: %s\n", 
 		 _("Xfce Power Manager"),
 		 _("Another power manager is already running"));
 		  
     }
-    else if (xfpm_dbus_name_has_owner(dbus_g_connection_get_connection(bus), 
-				      "org.xfce.PowerManager"))
+    else if (xfpm_dbus_name_has_owner (dbus_g_connection_get_connection(bus), 
+				       "org.xfce.PowerManager"))
     {
 	g_print (_("Xfce power manager is already running"));
 	g_print ("\n");
@@ -286,7 +276,7 @@ int main(int argc, char **argv)
     }
     else
     {	
-	xfpm_start (bus);
+	xfpm_start (bus, client_id);
     }
     
     return EXIT_SUCCESS;
diff --git a/src/xfpm-manager.c b/src/xfpm-manager.c
index 5c65221..068c4b7 100644
--- a/src/xfpm-manager.c
+++ b/src/xfpm-manager.c
@@ -30,6 +30,7 @@
 #include <glib.h>
 
 #include <libxfce4util/libxfce4util.h>
+#include <libxfce4ui/libxfce4ui.h>
 #include <xfconf/xfconf.h>
 
 #include <dbus/dbus-glib.h>
@@ -37,15 +38,21 @@
 
 #include <libnotify/notify.h>
 
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-dbus.h"
-#include "libxfpm/xfpm-popups.h"
-
+#include "xfpm-dkp.h"
+#include "xfpm-dbus.h"
+#include "xfpm-dpms.h"
 #include "xfpm-manager.h"
-#include "xfpm-engine.h"
-#include "xfpm-session.h"
-#include "xfpm-dbus-monitor.h"
+#include "xfpm-button.h"
+#include "xfpm-inhibit.h"
+#include "xfpm-brightness.h"
+#include "xfpm-config.h"
+#include "xfpm-debug.h"
+#include "xfpm-xfconf.h"
 #include "xfpm-errors.h"
+#include "xfpm-common.h"
+#include "xfpm-enum.h"
+#include "xfpm-enum-glib.h"
+#include "xfpm-enum-types.h"
 
 static void xfpm_manager_finalize   (GObject *object);
 
@@ -59,51 +66,24 @@ static gboolean xfpm_manager_quit (XfpmManager *manager);
 
 struct XfpmManagerPrivate
 {
-    XfpmSession     *session;
-    XfpmEngine 	    *engine;
+    DBusGConnection *session_bus;
     
-    XfpmDBusMonitor *monitor;
+    XfceSMClient    *client;
     
-    DBusGConnection *session_bus;
-};
-
-G_DEFINE_TYPE(XfpmManager, xfpm_manager, G_TYPE_OBJECT)
-
-static void
-xfpm_manager_hal_connection_changed_cb (XfpmDBusMonitor *monitor, gboolean connected, XfpmManager *manager)
-{
-    TRACE("connected = %s", xfpm_bool_to_string (connected));
+    XfpmDkp         *dkp;
+    XfpmButton      *button;
+    XfpmInhibit     *inhibit;
+    XfpmXfconf      *conf;
+    XfpmBrightness  *brightness;
+#ifdef HAVE_DPMS
+    XfpmDpms        *dpms;
+#endif
     
-    if ( connected  == TRUE )
-    {
-	if ( manager->priv->engine == NULL)
-	{
-	    manager->priv->engine = xfpm_engine_new ();
-	}
-	else
-	{
-	    xfpm_engine_reload_hal_objects (manager->priv->engine);
-	}
-    }
-}
-
-static void
-xfpm_manager_system_bus_connection_changed_cb (XfpmDBusMonitor *monitor, gboolean connected, XfpmManager *manager)
-{
-    if ( connected == TRUE )
-    {
-	TRACE ("System bus connection changed to TRUE, restarting the power manager");
-	xfpm_manager_quit (manager);
-	g_spawn_command_line_async ("xfce4-power-manager", NULL);
-    }
-}
+    gboolean	     inhibited;
+    gboolean	     session_managed;
+};
 
-static void
-xfpm_manager_session_die_cb (XfpmSession *session, XfpmManager *manager)
-{
-    TRACE ("Session die signal, exiting");
-    xfpm_manager_quit (manager);
-}
+G_DEFINE_TYPE (XfpmManager, xfpm_manager, G_TYPE_OBJECT)
 
 static void
 xfpm_manager_class_init (XfpmManagerClass *klass)
@@ -112,33 +92,21 @@ xfpm_manager_class_init (XfpmManagerClass *klass)
 
     object_class->finalize = xfpm_manager_finalize;
 
-    g_type_class_add_private(klass,sizeof(XfpmManagerPrivate));
+    g_type_class_add_private (klass, sizeof (XfpmManagerPrivate));
 }
 
 static void
-xfpm_manager_init(XfpmManager *manager)
+xfpm_manager_init (XfpmManager *manager)
 {
     manager->priv = XFPM_MANAGER_GET_PRIVATE(manager);
-
-    manager->priv->engine        = NULL;
-    
-    manager->priv->session = xfpm_session_new ();
-    manager->priv->monitor = xfpm_dbus_monitor_new ();
     
-    g_signal_connect (manager->priv->monitor, "hal-connection-changed",
-		      G_CALLBACK(xfpm_manager_hal_connection_changed_cb), manager);
-		      
-    g_signal_connect (G_OBJECT (manager->priv->monitor), "system_bus_connection_changed",
-		      G_CALLBACK (xfpm_manager_system_bus_connection_changed_cb), manager);
+    manager->priv->inhibited = FALSE;
 
-    g_signal_connect (manager->priv->session, "session-die",
-		      G_CALLBACK (xfpm_manager_session_die_cb), manager);
-		      
     notify_init ("xfce4-power-manager");
 }
 
 static void
-xfpm_manager_finalize(GObject *object)
+xfpm_manager_finalize (GObject *object)
 {
     XfpmManager *manager;
 
@@ -147,13 +115,19 @@ xfpm_manager_finalize(GObject *object)
     if ( manager->priv->session_bus )
 	dbus_g_connection_unref (manager->priv->session_bus);
 	
-    if ( manager->priv->engine )
-    	g_object_unref (manager->priv->engine);
-	
-    g_object_unref (manager->priv->session);
-
-    g_object_unref (manager->priv->monitor);
+    g_object_unref (manager->priv->dkp);
+    g_object_unref (manager->priv->button);
+    g_object_unref (manager->priv->inhibit);
+    g_object_unref (manager->priv->conf);
+    g_object_unref (manager->priv->client);
     
+#ifdef HAVE_DPMS
+    g_object_unref (manager->priv->dpms);
+#endif
+    
+    if ( manager->priv->brightness )
+	g_object_unref (manager->priv->brightness);
+	
     G_OBJECT_CLASS (xfpm_manager_parent_class)->finalize (object);
 }
 
@@ -173,10 +147,6 @@ xfpm_manager_quit (XfpmManager *manager)
     TRACE ("Exiting");
     
     xfpm_manager_release_names (manager);
-    xfpm_session_quit (manager->priv->session);
-    
-    g_object_unref (G_OBJECT (manager));
-    
     gtk_main_quit ();
     return TRUE;
 }
@@ -190,32 +160,158 @@ xfpm_manager_reserve_names (XfpmManager *manager)
 				  "org.freedesktop.PowerManagement") )
     {
 	g_warning ("Unable to reserve bus name: Maybe any already running instance?\n");
-	xfpm_session_quit (manager->priv->session);
+	
 	g_object_unref (G_OBJECT (manager));
 	gtk_main_quit ();
+	
 	return FALSE;
     }
     return TRUE;
 }
 
+static void
+xfpm_manager_button_pressed_cb (XfpmButton *bt, XfpmButtonKey type, XfpmManager *manager)
+{
+    XfpmShutdownRequest req = XFPM_DO_NOTHING;
+    
+    XFPM_DEBUG_ENUM ("Received button press event", type, XFPM_TYPE_BUTTON_KEY);
+  
+    if ( manager->priv->inhibited )
+    {
+        TRACE("Power manager automatic sleep is currently disabled");
+        return;
+    }
+    
+    if ( type == BUTTON_MON_BRIGHTNESS_DOWN || type == BUTTON_MON_BRIGHTNESS_UP )
+        return;
+    
+    if ( type == BUTTON_POWER_OFF )
+    {
+        g_object_get (G_OBJECT (manager->priv->conf),
+                      POWER_SWITCH_CFG, &req,
+                      NULL);
+    }
+    else if ( type == BUTTON_SLEEP )
+    {
+        g_object_get (G_OBJECT (manager->priv->conf),
+                      SLEEP_SWITCH_CFG, &req,
+                      NULL);
+    }
+    else if ( type == BUTTON_HIBERNATE )
+    {
+        g_object_get (G_OBJECT (manager->priv->conf),
+                      HIBERNATE_SWITCH_CFG, &req,
+                      NULL);
+    }
+    else
+    {
+        g_return_if_reached ();
+    }
+
+    XFPM_DEBUG_ENUM ("Shutdown request : ", req, XFPM_TYPE_SHUTDOWN_REQUEST);
+        
+    if ( req == XFPM_ASK && manager->priv->session_managed )
+        xfce_sm_client_request_shutdown (manager->priv->client, XFCE_SM_CLIENT_SHUTDOWN_HINT_ASK);
+    /*
+    else
+        xfpm_engine_shutdown_request (engine, req, FALSE);
+    */
+}
+
+static void
+xfpm_manager_inhibit_changed_cb (XfpmInhibit *inhibit, gboolean is_inhibit, XfpmManager *manager)
+{
+    manager->priv->inhibited = is_inhibit;
+}
+
+static void
+xfpm_manager_lid_changed_cb (XfpmDkp *dkp, gboolean lid_is_closed, XfpmManager *manager)
+{
+    XfpmLidTriggerAction action;
+    gboolean on_battery;
+    
+    g_object_get (G_OBJECT (dkp),
+		  "on-battery", &on_battery,
+		  NULL);
+    
+    g_object_get (G_OBJECT (manager->priv->conf),
+		  on_battery ? LID_SWITCH_ON_BATTERY_CFG : LID_SWITCH_ON_AC_CFG, &action,
+		  NULL);
+
+    if ( lid_is_closed )
+    {
+	XFPM_DEBUG_ENUM ("LID close event", action, XFPM_TYPE_LID_TRIGGER_ACTION);
+	
+	if ( action == LID_TRIGGER_NOTHING )
+	{
+	    if ( !xfpm_is_multihead_connected () )
+		xfpm_dpms_force_level (manager->priv->dpms, DPMSModeOff);
+	}
+	else if ( action == LID_TRIGGER_LOCK_SCREEN )
+	{
+	    if ( !xfpm_is_multihead_connected () )
+		xfpm_lock_screen ();
+	}
+	/*
+	else 
+	    xfpm_engine_shutdown_request (engine, action, FALSE);
+	*/
+    }
+    else
+    {
+	XFPM_DEBUG_ENUM ("LID opened", action, XFPM_TYPE_LID_TRIGGER_ACTION);
+	xfpm_dpms_force_level (manager->priv->dpms, DPMSModeOn);
+    }
+}
+
 XfpmManager *
-xfpm_manager_new (DBusGConnection *bus)
+xfpm_manager_new (DBusGConnection *bus, const gchar *client_id)
 {
     XfpmManager *manager = NULL;
-    manager = g_object_new(XFPM_TYPE_MANAGER,NULL);
+    GError *error = NULL;
+    gchar *current_dir;
+    
+    const gchar *restart_command[] =
+    {
+	"xfce4-power-manager",
+	"--restart",
+	NULL
+    };
+	
+    manager = g_object_new (XFPM_TYPE_MANAGER, NULL);
 
     manager->priv->session_bus = bus;
     
-    xfpm_manager_dbus_class_init (XFPM_MANAGER_GET_CLASS(manager));
-    xfpm_manager_dbus_init (manager);
+    current_dir = g_get_current_dir ();
+    manager->priv->client = xfce_sm_client_get_full (XFCE_SM_CLIENT_RESTART_NORMAL,
+						     XFCE_SM_CLIENT_PRIORITY_DEFAULT,
+						     client_id,
+						     current_dir,
+						     restart_command,
+						     NULL);
+    
+    g_free (current_dir);
+    
+    manager->priv->session_managed = xfce_sm_client_connect (manager->priv->client, &error);
     
+    if ( error )
+    {
+	g_warning ("Unable to connect to session managet : %s", error->message);
+	g_error_free (error);
+    }
+    else
+    {
+	g_signal_connect_swapped (manager->priv->client, "quit",
+				  G_CALLBACK (xfpm_manager_quit), manager);
+    }
+    
+    xfpm_manager_dbus_class_init (XFPM_MANAGER_GET_CLASS (manager));
+    xfpm_manager_dbus_init (manager);
     return manager;
 }
 
 void xfpm_manager_start (XfpmManager *manager)
 {
-    gboolean hal_running;
-    
     if ( !xfpm_manager_reserve_names (manager) )
 	goto out;
 	
@@ -223,14 +319,31 @@ void xfpm_manager_start (XfpmManager *manager)
 				  NULL,
 				  XFPM_TYPE_ERROR);
     
-    hal_running = xfpm_dbus_monitor_hal_connected (manager->priv->monitor);
+    manager->priv->dkp = xfpm_dkp_get ();
+    manager->priv->button = xfpm_button_new ();
+    manager->priv->inhibit = xfpm_inhibit_new ();
+    manager->priv->conf = xfpm_xfconf_new ();
+   
+    manager->priv->brightness = xfpm_brightness_new ();
+    
+#ifdef HAVE_DPMS
+    manager->priv->dpms = xfpm_dpms_new ();
+#endif
     
-    if (!hal_running )
+    if ( !xfpm_brightness_setup (manager->priv->brightness) )
     {
-	xfpm_error (_("Xfce power manager"), _("HAL daemon is not running"));
-	goto out;
+	g_object_unref (manager->priv->brightness);
+	manager->priv->brightness = NULL;
     }
-    manager->priv->engine = xfpm_engine_new ();
+     
+    g_signal_connect (manager->priv->button, "button_pressed",
+		      G_CALLBACK (xfpm_manager_button_pressed_cb), manager);
+    
+    g_signal_connect (manager->priv->inhibit, "has-inhibit-changed",
+		      G_CALLBACK (xfpm_manager_inhibit_changed_cb), manager);
+    
+    g_signal_connect (manager->priv->dkp, "lid-changed",
+		      G_CALLBACK (xfpm_manager_lid_changed_cb), manager);
     
 out:
 	;
@@ -308,10 +421,54 @@ static gboolean xfpm_manager_dbus_get_config (XfpmManager *manager,
 					      GError **error)
 {
     
+    guint8 mapped_buttons;
+    gboolean auth_hibernate = FALSE;
+    gboolean auth_suspend = FALSE;
+    gboolean can_suspend = FALSE;
+    gboolean can_hibernate = FALSE;
+    gboolean has_sleep_button = FALSE;
+    gboolean has_hibernate_button = FALSE;
+    gboolean has_power_button = FALSE;
+    gboolean has_battery = TRUE;
+    gboolean has_lcd_brightness = TRUE;
+    gboolean has_lid = FALSE;
+    
     *OUT_config = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
     
-    xfpm_engine_get_info (manager->priv->engine, *OUT_config);
+
+    g_object_get (G_OBJECT (manager->priv->dkp),
+                  "auth-suspend", &auth_suspend,
+		  "auth-hibernate", &auth_hibernate,
+                  "can-suspend", &can_suspend,
+                  "can-hibernate", &can_hibernate, 
+		  "has-lid", &has_lid,
+		  NULL);
+    
+    has_battery = xfpm_dkp_has_battery (manager->priv->dkp);
+    
+    mapped_buttons = xfpm_button_get_mapped (manager->priv->button);
+    
+    if ( mapped_buttons & SLEEP_KEY )
+        has_sleep_button = TRUE;
+    if ( mapped_buttons & HIBERNATE_KEY )
+        has_hibernate_button = TRUE;
+    if ( mapped_buttons & POWER_KEY )
+        has_power_button = TRUE;
+
+    g_hash_table_insert (*OUT_config, g_strdup ("sleep-button"), g_strdup (xfpm_bool_to_string (has_sleep_button)));
+    g_hash_table_insert (*OUT_config, g_strdup ("power-button"), g_strdup (xfpm_bool_to_string (has_power_button)));
+    g_hash_table_insert (*OUT_config, g_strdup ("hibernate-button"), g_strdup (xfpm_bool_to_string (has_hibernate_button)));
+    g_hash_table_insert (*OUT_config, g_strdup ("auth-suspend"), g_strdup (xfpm_bool_to_string (auth_suspend)));
+    g_hash_table_insert (*OUT_config, g_strdup ("auth-hibernate"), g_strdup (xfpm_bool_to_string (auth_hibernate)));
+    g_hash_table_insert (*OUT_config, g_strdup ("can-suspend"), g_strdup (xfpm_bool_to_string (can_suspend)));
+    g_hash_table_insert (*OUT_config, g_strdup ("can-hibernate"), g_strdup (xfpm_bool_to_string (can_hibernate)));
+    
+    g_hash_table_insert (*OUT_config, g_strdup ("has-battery"), g_strdup (xfpm_bool_to_string (has_battery)));
+    g_hash_table_insert (*OUT_config, g_strdup ("has-lid"), g_strdup (xfpm_bool_to_string (has_lid)));
     
+    /*
+    g_hash_table_insert (*OUT_config, g_strdup ("has-brightness"), g_strdup (xfpm_bool_to_string (has_lcd_brightness)));
+    */
     return TRUE;
 }
 					      
diff --git a/src/xfpm-manager.h b/src/xfpm-manager.h
index 54a37ef..66153cd 100644
--- a/src/xfpm-manager.h
+++ b/src/xfpm-manager.h
@@ -48,7 +48,8 @@ typedef struct
 
 GType        		  xfpm_manager_get_type        (void) G_GNUC_CONST;
 
-XfpmManager    		 *xfpm_manager_new             (DBusGConnection *bus);
+XfpmManager    		 *xfpm_manager_new             (DBusGConnection *bus,
+							const gchar *client_id);
 
 void            	  xfpm_manager_start           (XfpmManager *manager);
 
diff --git a/libxfpm/xfpm-notify.c b/src/xfpm-notify.c
similarity index 98%
rename from libxfpm/xfpm-notify.c
rename to src/xfpm-notify.c
index e983087..89a78bb 100644
--- a/libxfpm/xfpm-notify.c
+++ b/src/xfpm-notify.c
@@ -39,7 +39,6 @@
 #include <gtk/gtk.h>
 
 #include <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
 
 #include <libnotify/notify.h>
 
@@ -104,7 +103,7 @@ xfpm_notify_finalize(GObject *object)
 static void
 xfpm_notify_set_notification_icon (NotifyNotification *n, const gchar *icon_name )
 {
-    GdkPixbuf *pix = xfce_themed_icon_load (icon_name, 48);
+    GdkPixbuf *pix = xfpm_icon_load (icon_name, 48);
     
     if ( pix )
     {
diff --git a/libxfpm/xfpm-notify.h b/src/xfpm-notify.h
similarity index 100%
rename from libxfpm/xfpm-notify.h
rename to src/xfpm-notify.h
diff --git a/src/xfpm-polkit.c b/src/xfpm-polkit.c
new file mode 100644
index 0000000..a63e7a9
--- /dev/null
+++ b/src/xfpm-polkit.c
@@ -0,0 +1,191 @@
+/*
+ * * 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 <dbus/dbus-glib.h>
+
+#ifdef HAVE_POLKIT
+#include <polkit/polkit.h>
+#endif
+
+#include "xfpm-polkit.h"
+
+static void xfpm_polkit_finalize   (GObject *object);
+
+#define XFPM_POLKIT_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_POLKIT, XfpmPolkitPrivate))
+
+struct XfpmPolkitPrivate
+{
+    DBusGConnection   *bus;
+#ifdef HAVE_POLKIT
+    PolkitAuthority   *authority;
+#endif
+};
+
+enum
+{
+    AUTH_CHANGED,
+    LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (XfpmPolkit, xfpm_polkit, G_TYPE_OBJECT)
+
+static gboolean 
+xfpm_polkit_check_auth_intern (XfpmPolkit *polkit, const gchar *action_id)
+{
+#ifdef HAVE_POLKIT
+    PolkitSubject *subj;
+    PolkitAuthorizationResult *res;
+    GError *error = NULL;
+    gboolean ret = FALSE;
+    
+    subj = polkit_unix_process_new (getpid ());
+    
+    res = polkit_authority_check_authorization_sync (polkit->priv->authority, 
+						     subj, 
+						     action_id,
+						     NULL,
+						     POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE,
+						     NULL,
+						     &error);
+    
+    if ( error )
+    {
+	g_warning ("Unable to get authorization result for action :%s : %s", action_id, error->message);
+	g_error_free (error);
+	goto out;
+    }
+    
+    if (polkit_authorization_result_get_is_authorized (res))
+    {
+	ret = TRUE;
+    }
+    
+out:
+    if (res)
+	g_object_unref (res);
+	
+    return ret;
+    
+#endif
+    return TRUE;
+}
+
+#ifdef HAVE_POLKIT
+static void
+xfpm_polkit_auth_changed_cb (PolkitAuthority *authority, XfpmPolkit *polkit)
+{
+}
+#endif
+
+static void
+xfpm_polkit_class_init (XfpmPolkitClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = xfpm_polkit_finalize;
+
+    signals [AUTH_CHANGED] = 
+        g_signal_new ("auth-changed",
+                      XFPM_TYPE_POLKIT,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(XfpmPolkitClass, auth_changed),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE, 0, G_TYPE_NONE);
+
+    g_type_class_add_private (klass, sizeof (XfpmPolkitPrivate));
+}
+
+static void
+xfpm_polkit_init (XfpmPolkit *polkit)
+{
+    GError *error = NULL;
+    
+    polkit->priv = XFPM_POLKIT_GET_PRIVATE (polkit);
+    
+    polkit->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+    
+    if ( error )
+    {
+	g_critical ("Error getting system bus connection : %s", error->message);
+	g_error_free (error);
+	goto out;
+    }
+#ifdef HAVE_POLKIT
+    polkit->priv->authority = polkit_authority_get ();
+    g_signal_connect (polkit->priv->authority, "changed",
+		      G_CALLBACK (xfpm_polkit_auth_changed_cb), polkit);
+#endif
+    
+    
+out:
+    ;
+    
+}
+
+static void
+xfpm_polkit_finalize (GObject *object)
+{
+    XfpmPolkit *polkit;
+
+    polkit = XFPM_POLKIT (object);
+#ifdef HAVE_POLKIT
+    if (polkit->priv->authority )
+	g_object_unref (polkit->priv->authority);
+#endif
+
+    if ( polkit->priv->bus )
+	dbus_g_connection_unref (polkit->priv->bus);
+
+    G_OBJECT_CLASS (xfpm_polkit_parent_class)->finalize (object);
+}
+
+XfpmPolkit *
+xfpm_polkit_get (void)
+{
+    static gpointer xfpm_polkit_obj = NULL;
+    
+    if ( G_LIKELY (xfpm_polkit_obj) )
+    {
+	g_object_ref (xfpm_polkit_obj);
+    }
+    else
+    {
+	xfpm_polkit_obj = g_object_new (XFPM_TYPE_POLKIT, NULL);
+    }
+    
+    return XFPM_POLKIT (xfpm_polkit_obj);
+}
+
+gboolean xfpm_polkit_check_auth	(XfpmPolkit *polkit, const gchar *action_id)
+{
+    return xfpm_polkit_check_auth_intern (polkit, action_id);
+}
diff --git a/libxfpm/hal-battery.h b/src/xfpm-polkit.h
similarity index 52%
rename from libxfpm/hal-battery.h
rename to src/xfpm-polkit.h
index c751fca..69225e5 100644
--- a/libxfpm/hal-battery.h
+++ b/src/xfpm-polkit.h
@@ -1,5 +1,5 @@
 /*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -18,40 +18,41 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef __HAL_BATTERY_H
-#define __HAL_BATTERY_H
+#ifndef __XFPM_POLKIT_H
+#define __XFPM_POLKIT_H
 
 #include <glib-object.h>
 
-#include "hal-device.h"
-#include "hal-enum.h"
-
 G_BEGIN_DECLS
 
-#define HAL_TYPE_BATTERY        (hal_battery_get_type () )
-#define HAL_BATTERY(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), HAL_TYPE_BATTERY, HalBattery))
-#define HAL_IS_BATTERY(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), HAL_TYPE_BATTERY))
+#define XFPM_TYPE_POLKIT        (xfpm_polkit_get_type () )
+#define XFPM_POLKIT(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_POLKIT, XfpmPolkit))
+#define XFPM_IS_POLKIT(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_POLKIT))
 
-typedef struct HalBatteryPrivate HalBatteryPrivate;
+typedef struct XfpmPolkitPrivate XfpmPolkitPrivate;
 
 typedef struct
 {
-    HalDevice		   parent;
-    HalBatteryPrivate	  *priv;
+    GObject         	   parent;
+    XfpmPolkitPrivate     *priv;
     
-} HalBattery;
+} XfpmPolkit;
 
 typedef struct
 {
-    HalDeviceClass         parent_class;
+    GObjectClass 	   parent_class;
     
-    void                  (*battery_changed) (HalBattery *device);
+    void		  (*auth_changed)		(XfpmPolkit *polkit);
     
-} HalBatteryClass;
+} XfpmPolkitClass;
+
+GType        		   xfpm_polkit_get_type        	(void) G_GNUC_CONST;
+
+XfpmPolkit                *xfpm_polkit_get             	(void);
 
-GType        	  hal_battery_get_type        (void) G_GNUC_CONST;
-HalBattery       *hal_battery_new             (const gchar *udi);
+gboolean		   xfpm_polkit_check_auth	(XfpmPolkit *polkit,
+							 const gchar *action_id);
 
 G_END_DECLS
 
-#endif /* __HAL_BATTERY_H */
+#endif /* __XFPM_POLKIT_H */
diff --git a/src/xfpm-screen-saver.c b/src/xfpm-screen-saver.c
deleted file mode 100644
index 983e9d9..0000000
--- a/src/xfpm-screen-saver.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * * 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 <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "libxfpm/xfpm-dbus.h"
-
-#include "xfpm-screen-saver.h"
-#include "xfpm-inhibit.h"
-#include "xfpm-dbus-monitor.h"
-
-static void xfpm_screen_saver_finalize   (GObject *object);
-
-#define XFPM_SCREEN_SAVER_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_SCREEN_SAVER, XfpmScreenSaverPrivate))
-
-struct XfpmScreenSaverPrivate
-{
-    DBusGConnection *bus;
-    XfpmInhibit     *inhibit;
-    
-    gboolean         inhibited;
-};
-
-enum
-{
-    SCREEN_SAVER_INHIBITED,
-    LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmScreenSaver, xfpm_screen_saver, G_TYPE_OBJECT)
-
-static void
-xfpm_screen_saver_inhibit_changed_cb (XfpmInhibit *inhbit, gboolean inhibited, XfpmScreenSaver *srv)
-{
-    g_signal_emit (G_OBJECT (srv), signals [SCREEN_SAVER_INHIBITED], 0, inhibited);
-}
-
-static void
-xfpm_screen_saver_class_init(XfpmScreenSaverClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-     signals[SCREEN_SAVER_INHIBITED] =
-	    g_signal_new("screen-saver-inhibited",
-			 XFPM_TYPE_SCREEN_SAVER,
-			 G_SIGNAL_RUN_LAST,
-			 G_STRUCT_OFFSET(XfpmScreenSaverClass, screen_saver_inhibited),
-			 NULL, NULL,
-			 g_cclosure_marshal_VOID__BOOLEAN,
-			 G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-
-    object_class->finalize = xfpm_screen_saver_finalize;
-    
-    g_type_class_add_private(klass,sizeof(XfpmScreenSaverPrivate));
-}
-
-static void
-xfpm_screen_saver_init(XfpmScreenSaver *srv)
-{
-    srv->priv = XFPM_SCREEN_SAVER_GET_PRIVATE(srv);
-    
-    srv->priv->inhibit = xfpm_inhibit_new ();
-    g_signal_connect (srv->priv->inhibit, "has-inhibit-changed",
-		      G_CALLBACK (xfpm_screen_saver_inhibit_changed_cb), srv);
-}
-
-static void
-xfpm_screen_saver_finalize(GObject *object)
-{
-    XfpmScreenSaver *srv;
-
-    srv = XFPM_SCREEN_SAVER(object);
-    
-    g_object_unref (srv->priv->inhibit);
-    
-    G_OBJECT_CLASS(xfpm_screen_saver_parent_class)->finalize(object);
-}
-
-XfpmScreenSaver *
-xfpm_screen_saver_new(void)
-{
-    static gpointer xfpm_screen_saver_object = NULL;
-    
-    if ( G_LIKELY (xfpm_screen_saver_object != NULL) )
-    {
-	g_object_ref (xfpm_screen_saver_object);
-    }
-    else
-    {
-	xfpm_screen_saver_object = g_object_new (XFPM_TYPE_SCREEN_SAVER, NULL);
-	g_object_add_weak_pointer (xfpm_screen_saver_object, &xfpm_screen_saver_object);
-    }
-    return XFPM_SCREEN_SAVER (xfpm_screen_saver_object);
-}
-
-void xfpm_screen_saver_inhibit (XfpmScreenSaver *srv)
-{
-    g_return_if_fail (XFPM_IS_SCREEN_SAVER (srv));
-    
-    if ( srv->priv->inhibited == FALSE )
-    {
-	srv->priv->inhibited = TRUE;
-	g_signal_emit (G_OBJECT (srv), signals[SCREEN_SAVER_INHIBITED], 0, srv->priv->inhibited);
-    }
-}
-
-void xfpm_screen_saver_uninhibit (XfpmScreenSaver *srv)
-{
-    g_return_if_fail (XFPM_IS_SCREEN_SAVER (srv));
-    
-    if ( srv->priv->inhibited == TRUE )
-    {
-	srv->priv->inhibited = FALSE;
-	g_signal_emit (G_OBJECT (srv), signals[SCREEN_SAVER_INHIBITED], 0, srv->priv->inhibited);
-    }
-}
-
-gboolean xfpm_screen_saver_get_inhibit (XfpmScreenSaver *srv)
-{
-    g_return_val_if_fail (XFPM_IS_SCREEN_SAVER (srv), FALSE);
-    
-    return srv->priv->inhibited;
-}
diff --git a/src/xfpm-screen-saver.h b/src/xfpm-screen-saver.h
deleted file mode 100644
index 021f228..0000000
--- a/src/xfpm-screen-saver.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * * 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_SCREEN_SAVER_H
-#define __XFPM_SCREEN_SAVER_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_SCREEN_SAVER        (xfpm_screen_saver_get_type () )
-#define XFPM_SCREEN_SAVER(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_SCREEN_SAVER, XfpmScreenSaver))
-#define XFPM_IS_SCREEN_SAVER(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_SCREEN_SAVER))
-
-typedef struct XfpmScreenSaverPrivate XfpmScreenSaverPrivate;
-
-typedef struct
-{
-    GObject		 	  parent;
-    XfpmScreenSaverPrivate	 *priv;
-	
-} XfpmScreenSaver;
-
-typedef struct
-{
-    GObjectClass 		  parent_class;
-    
-    void                          (*screen_saver_inhibited)	    (XfpmScreenSaver *srv,
-								     gboolean is_inhibited);
-	
-} XfpmScreenSaverClass;
-
-GType        			  xfpm_screen_saver_get_type        (void) G_GNUC_CONST;
-
-XfpmScreenSaver       	 	 *xfpm_screen_saver_new             (void);
-
-void				  xfpm_screen_saver_inhibit         (XfpmScreenSaver *srv);
-
-void 				  xfpm_screen_saver_uninhibit       (XfpmScreenSaver *srv);
-
-gboolean                          xfpm_screen_saver_get_inhibit     (XfpmScreenSaver *srv);
-
-G_END_DECLS
-
-#endif /* __XFPM_SCREEN_SAVER_H */
diff --git a/src/xfpm-session.c b/src/xfpm-session.c
deleted file mode 100644
index 1daed15..0000000
--- a/src/xfpm-session.c
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * * 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 <gtk/gtk.h>
-
-#include <dbus/dbus-glib.h>
-
-#include <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
-
-#include "xfpm-session.h"
-
-static void xfpm_session_finalize   (GObject *object);
-
-#define XFPM_SESSION_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_SESSION, XfpmSessionPrivate))
-
-/* copied from xfce4-session/shutdown.h -- ORDER MATTERS.  The numbers
- * correspond to the 'type' parameter of org.xfce.Session.Manager.Shutdown
- */
-typedef enum
-{
-    XFSM_SHUTDOWN_ASK = 0,
-    XFSM_SHUTDOWN_LOGOUT,
-    XFSM_SHUTDOWN_HALT,
-    XFSM_SHUTDOWN_REBOOT,
-    XFSM_SHUTDOWN_SUSPEND,
-    XFSM_SHUTDOWN_HIBERNATE,
-  
-} XfsmShutdownType;
-
-struct XfpmSessionPrivate
-{
-    SessionClient *client;
-    gboolean       managed;
-    gboolean	   initted;
-};
-
-enum
-{
-    SESSION_DIE,
-    LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-static gpointer xfpm_session_object = NULL;
-
-G_DEFINE_TYPE (XfpmSession, xfpm_session, G_TYPE_OBJECT)
-
-static void
-xfpm_session_die (gpointer client_data)
-{
-    XfpmSession *session;
-    
-    if ( G_UNLIKELY (xfpm_session_object == NULL ) )
-	return;
-	
-    session = XFPM_SESSION (xfpm_session_object);
-    if ( G_UNLIKELY (session->priv->managed == FALSE) )
-	return;
-	
-    TRACE ("Session disconnected signal\n");
-    g_signal_emit (G_OBJECT (session), signals [SESSION_DIE], 0);
-}
-
-static void
-xfpm_session_class_init (XfpmSessionClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-    signals[SESSION_DIE] = 
-        g_signal_new("session-die",
-                      XFPM_TYPE_SESSION,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmSessionClass, session_die),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__VOID,
-                      G_TYPE_NONE, 0, G_TYPE_NONE);
-
-    object_class->finalize = xfpm_session_finalize;
-
-    g_type_class_add_private (klass, sizeof (XfpmSessionPrivate));
-}
-
-static void
-xfpm_session_init (XfpmSession *session)
-{
-    gchar **restart_command;
-    
-    session->priv = XFPM_SESSION_GET_PRIVATE (session);
-    
-    session->priv->client = NULL;
-    session->priv->managed = FALSE;
-    session->priv->initted = FALSE;
-    
-    restart_command    = g_new (gchar *, 3);
-    restart_command[0] = g_strdup ("xfce4-power-manager");
-    restart_command[1] = g_strdup ("--restart");
-    restart_command[2] = NULL;
-    
-    session->priv->client = client_session_new_full (NULL,
-						     SESSION_RESTART_IF_RUNNING,
-						     40,
-						     NULL,
-						     (gchar *) PACKAGE_NAME,
-						     NULL,
-						     restart_command,
-						     g_strdupv (restart_command),
-						     NULL,
-						     NULL,
-						     NULL);
-    if ( G_UNLIKELY (session->priv->client == NULL ) )
-    {
-	g_warning ("Failed to connect to session manager");
-	return;
-    }
-    
-    session->priv->client->die     = xfpm_session_die;
-}
-
-static void
-xfpm_session_finalize (GObject *object)
-{
-    XfpmSession *session;
-
-    session = XFPM_SESSION (object);
-
-    if ( session->priv->client != NULL )
-    {
-	client_session_free (session->priv->client);
-    }
-
-    G_OBJECT_CLASS (xfpm_session_parent_class)->finalize (object);
-}
-
-static gboolean 
-xfpm_session_shutdown_internal (XfpmSession *session, XfsmShutdownType type, gboolean allow_save)
-{
-    DBusGConnection *bus;
-    DBusGProxy *proxy;
-    GError *error = NULL;
-    
-    bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
-    
-    if ( error )
-    {
-	g_print ("Unable to get DBUS session connection, %s", error->message);
-	g_error_free (error);
-	return FALSE;
-    }
-    
-    proxy = dbus_g_proxy_new_for_name (bus,
-				       "org.xfce.SessionManager",
-                                       "/org/xfce/SessionManager",
-                                       "org.xfce.Session.Manager");
-				       
-    if ( !proxy )
-    {
-	g_critical ("Unable to create proxy for xfce session manager");
-	dbus_g_connection_unref (bus);
-	return FALSE;
-    }
-	
-    dbus_g_proxy_call (proxy, "Shutdown", &error,
-		       G_TYPE_UINT, type,
-		       G_TYPE_BOOLEAN, allow_save,
-		       G_TYPE_INVALID,
-		       G_TYPE_INVALID);
-		       
-    if ( error )
-    {
-	g_warning ("%s", error->message);
-	g_error_free (error);
-    }
-    
-    g_object_unref (proxy);
-    dbus_g_connection_unref (bus);
-    return TRUE;
-}
-
-XfpmSession *
-xfpm_session_new (void)
-{
-    if ( xfpm_session_object != NULL )
-    {
-	g_object_ref (xfpm_session_object);
-    }
-    else
-    {
-	xfpm_session_object = g_object_new (XFPM_TYPE_SESSION, NULL);
-	g_object_add_weak_pointer (xfpm_session_object, &xfpm_session_object);
-    }
-    return XFPM_SESSION (xfpm_session_object);
-}
-
-void xfpm_session_real_init (XfpmSession *session)
-{
-    session->priv->managed = session_init (session->priv->client);
-    session->priv->initted = TRUE;
-}
-
-void xfpm_session_set_client_id (XfpmSession *session, const gchar *client_id)
-{
-    g_return_if_fail (XFPM_IS_SESSION (session));
-    g_return_if_fail (session->priv->initted == FALSE);
-    
-    if ( G_UNLIKELY (session->priv->client == NULL || session->priv->managed == FALSE) )
-	return;
-    
-    TRACE ("Setting client id : %s\n", client_id);
-    client_session_set_client_id (session->priv->client, client_id);
-}
-
-void xfpm_session_quit (XfpmSession *session)
-{
-    g_return_if_fail (XFPM_IS_SESSION (session));
-    
-    if ( G_UNLIKELY (session->priv->client == NULL || session->priv->managed == FALSE) )
-	return;
-    
-    client_session_set_restart_style (session->priv->client, SESSION_RESTART_NEVER);
-}
-
-gboolean xfpm_session_shutdown (XfpmSession *session)
-{
-    gboolean allow_save   = TRUE;
-    XfsmShutdownType type = XFSM_SHUTDOWN_HALT;
-    
-    g_return_val_if_fail (XFPM_IS_SESSION (session), FALSE);
-    
-    return xfpm_session_shutdown_internal (session, type, allow_save);
-}
-
-gboolean xfpm_session_reboot (XfpmSession *session)
-{
-    gboolean allow_save   = TRUE;
-    XfsmShutdownType type = XFSM_SHUTDOWN_REBOOT;
-    
-    g_return_val_if_fail (XFPM_IS_SESSION (session), FALSE);
-    
-    return xfpm_session_shutdown_internal (session, type, allow_save);
-}
-
-gboolean xfpm_session_ask_shutdown (XfpmSession *session)
-{
-    gboolean allow_save   = TRUE;
-    XfsmShutdownType type = XFSM_SHUTDOWN_ASK;
-    
-    g_return_val_if_fail (XFPM_IS_SESSION (session), FALSE);
-    
-    return xfpm_session_shutdown_internal (session, type, allow_save);
-}
diff --git a/src/xfpm-session.h b/src/xfpm-session.h
deleted file mode 100644
index e40b13a..0000000
--- a/src/xfpm-session.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * * 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_SESSION_H
-#define __XFPM_SESSION_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_SESSION        (xfpm_session_get_type () )
-#define XFPM_SESSION(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_SESSION, XfpmSession))
-#define XFPM_IS_SESSION(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_SESSION))
-
-typedef struct XfpmSessionPrivate XfpmSessionPrivate;
-
-typedef struct
-{
-    GObject         		 parent;
-    XfpmSessionPrivate     	*priv;
-    
-} XfpmSession;
-
-typedef struct
-{
-    GObjectClass 		 parent_class;
-    
-    void                        (*session_die)		      (XfpmSession *session);
-    
-} XfpmSessionClass;
-
-GType  		      		 xfpm_session_get_type        (void) G_GNUC_CONST;
-
-XfpmSession       		*xfpm_session_new             (void);
-
-void				 xfpm_session_real_init	      (XfpmSession *session);
-
-void			         xfpm_session_set_client_id   (XfpmSession *session,
-							       const gchar *client_id);
-							    
-/* This is used to change the restart Style */
-void				 xfpm_session_quit	      (XfpmSession *session);
-
-gboolean                         xfpm_session_shutdown        (XfpmSession *session);
-
-gboolean 			 xfpm_session_reboot 	      (XfpmSession *session);
-
-gboolean			 xfpm_session_ask_shutdown    (XfpmSession *session);
-
-G_END_DECLS
-
-#endif /* __XFPM_SESSION_H */
diff --git a/src/xfpm-shutdown.c b/src/xfpm-shutdown.c
deleted file mode 100644
index 5479543..0000000
--- a/src/xfpm-shutdown.c
+++ /dev/null
@@ -1,532 +0,0 @@
-/*
- * * 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 <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include <glib.h>
-
-#include "libxfpm/hal-device.h"
-
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-common.h"
-
-#include "xfpm-shutdown.h"
-#include "xfpm-session.h"
-#include "xfpm-network-manager.h"
-#include "xfpm-dbus-monitor.h"
-#include "xfpm-errors.h"
-
-#define DUPLICATE_SHUTDOWN_REQUEST 8.0f
-
-static void xfpm_shutdown_finalize   (GObject *object);
-
-static void xfpm_shutdown_get_property (GObject *object,
-				        guint prop_id,
-				        GValue *value,
-				        GParamSpec *pspec);
-
-#define XFPM_SHUTDOWN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_SHUTDOWN, XfpmShutdownPrivate))
-
-struct XfpmShutdownPrivate
-{
-    DBusGConnection *bus;
-    XfpmDBusMonitor *monitor;
-
-    XfpmSession     *session;
-    gboolean         connected;
-    gboolean         can_suspend;
-    gboolean         can_hibernate;
-    gboolean         caller_privilege;
-    
-    gboolean         block_shutdown;
-};
-
-enum
-{
-    PROP_0,
-    PROP_CALLER_PRIVILEGE,
-    PROP_CAN_SUSPEND,
-    PROP_CAN_HIBERNATE,
-};
-
-enum
-{
-    WAKING_UP,
-    LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmShutdown, xfpm_shutdown, G_TYPE_OBJECT)
-
-static gboolean
-xfpm_shutdown_check_interface (XfpmShutdown *shutdown, const gchar *interface)
-{
-    DBusMessage *message;
-    DBusMessage *reply;
-    DBusError error ;
-    
-    message = dbus_message_new_method_call ("org.freedesktop.Hal",
-					    "/org/freedesktop/Hal",
-					    interface,
-					    "JustToCheck");
-    
-    if (!message)
-    	return FALSE;
-    
-    dbus_error_init (&error);
-    
-    reply = 
-    	dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection(shutdown->priv->bus),
-						   message, 2000, &error);
-    dbus_message_unref (message);
-    
-    if ( reply ) dbus_message_unref (reply);
-    
-    if ( dbus_error_is_set(&error) )
-    {
-	if ( !g_strcmp0 (error.name, "org.freedesktop.DBus.Error.UnknownMethod") )
-        {
-            dbus_error_free(&error);
-	    return TRUE;
-        }
-    }
-    return FALSE;
-}
-
-static void
-xfpm_shutdown_power_management_check (XfpmShutdown *shutdown)
-{
-    HalDevice *device;
-    device = hal_device_new ();
-    hal_device_set_udi (device,  "/org/freedesktop/Hal/devices/computer");
-    
-    shutdown->priv->caller_privilege =
-	xfpm_shutdown_check_interface (shutdown,  "org.freedesktop.Hal.Device.SystemPowerManagement");
-    
-    shutdown->priv->can_suspend   = hal_device_get_property_bool (device, "power_management.can_suspend");
-    shutdown->priv->can_hibernate = hal_device_get_property_bool (device, "power_management.can_hibernate");
-    g_object_unref (device);
-}
-
-static void
-xfpm_shutdown_connection_changed_cb (XfpmDBusMonitor *monitor, gboolean connected, XfpmShutdown *shutdown)
-{
-    TRACE ("Hal connection changed=%s", xfpm_bool_to_string (connected));
-    shutdown->priv->connected = connected;
-}
-
-static void
-xfpm_shutdown_class_init(XfpmShutdownClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    signals[WAKING_UP] = 
-        g_signal_new("waking-up",
-                      XFPM_TYPE_SHUTDOWN,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmShutdownClass, waking_up),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__VOID,
-                      G_TYPE_NONE, 0, G_TYPE_NONE);
-
-    object_class->get_property = xfpm_shutdown_get_property;
-    g_object_class_install_property(object_class,
-				    PROP_CALLER_PRIVILEGE,
-				    g_param_spec_boolean("caller-privilege",
-							 NULL, NULL,
-							 FALSE,
-							 G_PARAM_READABLE));
-							 
-    g_object_class_install_property(object_class,
-				    PROP_CAN_SUSPEND,
-				    g_param_spec_boolean("can-suspend",
-							 NULL, NULL,
-							 FALSE,
-							 G_PARAM_READABLE));
-							 
-    g_object_class_install_property(object_class,
-				    PROP_CAN_HIBERNATE,
-				    g_param_spec_boolean("can-hibernate",
-							 NULL, NULL,
-							 FALSE,
-							 G_PARAM_READABLE));
-							 
-    object_class->finalize = xfpm_shutdown_finalize;
-    g_type_class_add_private(klass,sizeof(XfpmShutdownPrivate));
-}
-
-static void
-xfpm_shutdown_init (XfpmShutdown *shutdown)
-{
-    GError *error = NULL;
-    shutdown->priv = XFPM_SHUTDOWN_GET_PRIVATE(shutdown);
-    
-    shutdown->priv->bus 			= NULL;
-    shutdown->priv->connected			= FALSE;
-    shutdown->priv->can_suspend    		= FALSE;
-    shutdown->priv->can_hibernate  		= FALSE;
-    shutdown->priv->caller_privilege        	= FALSE;
-    
-    shutdown->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-    
-    shutdown->priv->session = xfpm_session_new ();
-    
-    if ( error )
-    {
-	g_critical ("Unable to get system bus %s.", error->message);
-	g_error_free (error);
-	return;
-    }
-    
-    shutdown->priv->monitor = xfpm_dbus_monitor_new ();
-    
-    g_signal_connect (shutdown->priv->monitor, "hal-connection-changed",
-		      G_CALLBACK (xfpm_shutdown_connection_changed_cb), shutdown);
-		      
-    shutdown->priv->connected = xfpm_dbus_monitor_hal_connected (shutdown->priv->monitor);
-    
-    xfpm_shutdown_power_management_check (shutdown);
-}
-
-static void xfpm_shutdown_get_property (GObject *object,
-				        guint prop_id,
-				        GValue *value,
-				        GParamSpec *pspec)
-{
-    XfpmShutdown *shutdown;
-    shutdown = XFPM_SHUTDOWN (object);
-
-    switch(prop_id)
-    {
-	case PROP_CALLER_PRIVILEGE:
-	    g_value_set_boolean (value, shutdown->priv->caller_privilege );
-	    break;
-	case PROP_CAN_SUSPEND:
-	    g_value_set_boolean (value, shutdown->priv->can_suspend );
-	    break;
-	case PROP_CAN_HIBERNATE:
-	    g_value_set_boolean (value, shutdown->priv->can_hibernate);
-	    break;
-	default:
-	    G_OBJECT_WARN_INVALID_PROPERTY_ID(object,prop_id,pspec);
-	    break;
-    }
-}
-
-static void
-xfpm_shutdown_finalize(GObject *object)
-{
-    XfpmShutdown *shutdown;
-
-    shutdown = XFPM_SHUTDOWN(object);
-    
-    if ( shutdown->priv->bus )
-	dbus_g_connection_unref (shutdown->priv->bus);	
-
-    g_object_unref (shutdown->priv->monitor);
-	
-    g_object_unref (shutdown->priv->session);
-	
-    G_OBJECT_CLASS(xfpm_shutdown_parent_class)->finalize(object);
-}
-
-static gboolean 
-xfpm_shutdown_internal (DBusConnection *bus, const gchar *shutdown, GError **gerror)
-{
-    DBusMessage *message, *reply = NULL;
-    DBusError error;
-    gint exit_code = 0;
-    
-    message = dbus_message_new_method_call ("org.freedesktop.Hal",
-					    "/org/freedesktop/Hal/devices/computer",
-					    "org.freedesktop.Hal.Device.SystemPowerManagement",
-					    shutdown);
-    if ( !message )
-    {
-	g_set_error ( gerror, 0, 0, "Out of memory");
-	return FALSE;
-    }
-    
-    if ( !g_strcmp0 ("Suspend", shutdown ) )
-    {
-	gint seconds = 0;
-    	dbus_message_append_args (message, DBUS_TYPE_INT32, &seconds, DBUS_TYPE_INVALID);
-    }
-    
-    dbus_error_init (&error);
-    
-    reply = dbus_connection_send_with_reply_and_block (bus,
-						       message,
-						       -1,
-						       &error);
-    dbus_message_unref (message);
-
-    if ( dbus_error_is_set(&error) )
-    {
-	dbus_set_g_error (gerror, &error);
-	return FALSE;
-    }
-    
-    switch (dbus_message_get_type(reply) )
-    {
-	case DBUS_MESSAGE_TYPE_METHOD_RETURN:
-		dbus_message_get_args (reply, NULL,
-				       DBUS_TYPE_INT32,
-				       &exit_code,
-				       DBUS_TYPE_INVALID);
-		dbus_message_unref (reply);
-		if ( exit_code == 0) return TRUE;
-		else
-		{
-		    g_warning ("Sleep program exited with exit code %d", exit_code);
-		    g_set_error (gerror, 0, 0, "System failed to sleep");
-		    return FALSE;
-		}
-		break;
-	case DBUS_MESSAGE_TYPE_ERROR:
-		dbus_message_unref (reply);
-		g_set_error ( gerror, 0, 0, "Failed to sleep");
-		return FALSE;
-		break;
-	default:
-		dbus_message_unref ( reply );
-		g_set_error ( gerror, 0, 0, "Failed to sleep");
-		return FALSE;
-    }
-    return TRUE;
-}
-
-static const gchar * G_GNUC_PURE
-_filter_error_message(const gchar *error)
-{
-    if( xfpm_strequal ("No back-end for your operating system", error))
-    {
-        return _("No back-end for your operating system");
-    }
-    else if ( xfpm_strequal ("No hibernate script found", error) )
-    {
-        return _("No hibernate script found");
-    }
-    else if ( xfpm_strequal ("No suspend script found", error) )
-    {
-	return _("No suspend script found");
-    }
-    else if ( xfpm_strequal ("No suspend method found", error) )
-    {
-        return _("No suspend method found");
-    }
-    else if ( xfpm_strequal ("No hibernate method found", error))
-    {
-        return _("No hibernate method found");
-    }
-    else if ( xfpm_strequal ("Out of memory", error) )
-    {
-	return _("Out of memory");
-    }
-    else if ( xfpm_strequal ("System failed to sleep", error ) )
-    {
-	return _("System failed to sleep");
-    }
-    return NULL;
-}
-
-XfpmShutdown *
-xfpm_shutdown_new(void)
-{
-    static gpointer xfpm_shutdown_object = NULL;
-    
-    if ( G_LIKELY (xfpm_shutdown_object != NULL) )
-    {
-	g_object_ref (xfpm_shutdown_object);
-    }
-    else
-    {
-	xfpm_shutdown_object = g_object_new (XFPM_TYPE_SHUTDOWN, NULL);
-	g_object_add_weak_pointer (xfpm_shutdown_object, &xfpm_shutdown_object);
-    }
-    return XFPM_SHUTDOWN (xfpm_shutdown_object);
-}
-
-gboolean                  xfpm_shutdown_add_callback    (XfpmShutdown *shutdown,
-							 GSourceFunc func,
-							 gboolean lock_screen,
-							 gpointer data)
-{
-    g_return_val_if_fail (XFPM_IS_SHUTDOWN (shutdown), FALSE);
-    
-    if (shutdown->priv->block_shutdown)
-	return FALSE;
-    
-    xfpm_send_message_to_network_manager ("sleep");
-    if ( lock_screen )
-	xfpm_lock_screen ();
-	
-    if ( lock_screen )
-	g_timeout_add_seconds (2 , func, data);
-    else
-	g_timeout_add (100, func, data);
-	
-    shutdown->priv->block_shutdown = TRUE;
-    return TRUE;
-}
-
-void xfpm_shutdown	(XfpmShutdown *shutdown, GError **error)
-{
-    g_return_if_fail (XFPM_IS_SHUTDOWN(shutdown));
-    
-    TRACE ("Start");
-    
-    if ( G_UNLIKELY (shutdown->priv->connected == FALSE) )
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_HAL_DISCONNECTED, _("HAL daemon is currently not connected"));
-	shutdown->priv->block_shutdown = FALSE;
-	return;
-    }
-    
-    xfpm_send_message_to_network_manager ("sleep");
-    
-    if ( !xfpm_shutdown_internal (dbus_g_connection_get_connection(shutdown->priv->bus), "Shutdown", NULL))
-    {
-	xfpm_send_message_to_network_manager ("wake");
-	shutdown->priv->block_shutdown = FALSE;
-    }
-}
-
-void xfpm_reboot (XfpmShutdown *shutdown, GError **error)
-{
-    g_return_if_fail (XFPM_IS_SHUTDOWN(shutdown));
-    
-    TRACE ("Start");
-    
-    if ( G_UNLIKELY (shutdown->priv->connected == FALSE) )
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_HAL_DISCONNECTED, _("HAL daemon is currently not connected"));
-	shutdown->priv->block_shutdown = FALSE;
-	return;
-    }
-    
-    xfpm_send_message_to_network_manager ("sleep");
-    if ( !xfpm_shutdown_internal (dbus_g_connection_get_connection(shutdown->priv->bus), "Reboot", NULL))
-    {
-	xfpm_send_message_to_network_manager ("wake");
-	shutdown->priv->block_shutdown = FALSE;
-    }
-}    
-
-void xfpm_hibernate (XfpmShutdown *shutdown, GError **error)
-{
-    GError *error_internal = NULL;
-    const gchar *error_message;
-    
-    g_return_if_fail (XFPM_IS_SHUTDOWN(shutdown));
-    
-    TRACE ("Start");
-    
-    if ( G_UNLIKELY (shutdown->priv->connected == FALSE) )
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_HAL_DISCONNECTED, _("HAL daemon is currently not connected"));
-	shutdown->priv->block_shutdown = FALSE;
-	return;
-    }
-
-    xfpm_send_message_to_network_manager ("sleep");
-
-    xfpm_shutdown_internal (dbus_g_connection_get_connection(shutdown->priv->bus), "Hibernate", &error_internal);
-    shutdown->priv->block_shutdown = FALSE;
-    
-    if ( error_internal )
-    {
-	g_warning ("%s", error_internal->message);
-	error_message = _filter_error_message (error_internal->message);
-	if ( error_message )
-	{
-	    g_set_error (error, XFPM_ERROR, XFPM_ERROR_SLEEP_FAILED, "%s", error_message);
-	}
-	g_error_free (error_internal);
-    }
-    g_signal_emit (G_OBJECT (shutdown), signals [WAKING_UP], 0);
-    
-    xfpm_send_message_to_network_manager ("wake");
-}
-
-void xfpm_suspend (XfpmShutdown *shutdown, GError **error)
-{
-    GError *error_internal = NULL;
-    const gchar *error_message;
-    
-    g_return_if_fail (XFPM_IS_SHUTDOWN(shutdown));
-    
-    TRACE ("Start");
-    
-    if ( G_UNLIKELY (shutdown->priv->connected == FALSE) )
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_HAL_DISCONNECTED, _("HAL daemon is currently not connected"));
-	shutdown->priv->block_shutdown = FALSE;
-	return;
-    }
-    
-    xfpm_send_message_to_network_manager ("sleep");
-    xfpm_shutdown_internal (dbus_g_connection_get_connection(shutdown->priv->bus), "Suspend", &error_internal);
-    shutdown->priv->block_shutdown = FALSE;
-     
-    if ( error_internal )
-    {
-	g_warning ("%s", error_internal->message);
-	error_message = _filter_error_message (error_internal->message);
-	if ( error_message )
-	{
-	    g_set_error ( error, XFPM_ERROR, XFPM_ERROR_SLEEP_FAILED, "%s", error_message);
-	}
-	g_error_free (error_internal);
-    }
-    g_signal_emit (G_OBJECT (shutdown), signals [WAKING_UP], 0);
-    xfpm_send_message_to_network_manager ("wake");
-}
-
-void xfpm_shutdown_ask (XfpmShutdown *shutdown)
-{
-    g_return_if_fail (XFPM_IS_SHUTDOWN (shutdown));
-    
-    TRACE ("Start");
-    
-    xfpm_session_ask_shutdown (shutdown->priv->session);
-}
-
-void xfpm_shutdown_reload (XfpmShutdown *shutdown)
-{
-    g_return_if_fail (XFPM_IS_SHUTDOWN (shutdown));
-    
-    TRACE ("Start");
-    
-    xfpm_shutdown_power_management_check (shutdown);
-}
diff --git a/src/xfpm-shutdown.h b/src/xfpm-shutdown.h
deleted file mode 100644
index f230558..0000000
--- a/src/xfpm-shutdown.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * * 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_SHUTDOWN_H
-#define __XFPM_SHUTDOWN_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_SHUTDOWN        (xfpm_shutdown_get_type () )
-#define XFPM_SHUTDOWN(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_SHUTDOWN, XfpmShutdown))
-#define XFPM_IS_SHUTDOWN(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_SHUTDOWN))
-
-typedef enum
-{
-    SYSTEM_CAN_HIBERNATE         =  (1<<0),
-    SYSTEM_CAN_SUSPEND           =  (1<<1),
-    
-} SystemPowerManagement;
-
-typedef struct XfpmShutdownPrivate XfpmShutdownPrivate;
-
-typedef struct
-{
-    GObject		  parent;
-    XfpmShutdownPrivate	 *priv;
-	
-} XfpmShutdown;
-
-typedef struct
-{
-    GObjectClass 	  parent_class;
-    
-    void		  (*waking_up)			(XfpmShutdown *shutdown);
-	
-} XfpmShutdownClass;
-
-GType        		  xfpm_shutdown_get_type        (void) G_GNUC_CONST;
-XfpmShutdown       	 *xfpm_shutdown_new             (void);
-
-gboolean                  xfpm_shutdown_add_callback    (XfpmShutdown *shutdown,
-							 GSourceFunc func,
-							 gboolean lock_screen,
-							 gpointer data);
-							 
-
-void                      xfpm_shutdown			(XfpmShutdown *shutdown,
-							 GError **error);
-
-void                      xfpm_reboot			(XfpmShutdown *shutdown,
-							 GError **error);
-
-void                      xfpm_hibernate                (XfpmShutdown *shutdown,
-							 GError **error);
-
-void                      xfpm_suspend                  (XfpmShutdown *shutdown,
-							 GError **error);
-
-void                      xfpm_shutdown_ask             (XfpmShutdown *shutdown);
-
-void			  xfpm_shutdown_reload          (XfpmShutdown *shutdown);
-
-G_END_DECLS
-
-#endif /* __XFPM_SHUTDOWN_H */
diff --git a/src/xfpm-supply.c b/src/xfpm-supply.c
deleted file mode 100644
index 5fbdc16..0000000
--- a/src/xfpm-supply.c
+++ /dev/null
@@ -1,631 +0,0 @@
-/*
- * * Copyright (C) 2008-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 <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
-
-#include "libxfpm/hal-power.h"
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-common.h"
-#include "libxfpm/xfpm-notify.h"
-#include "libxfpm/xfpm-icons.h"
-
-#include "xfpm-supply.h"
-#include "xfpm-adapter.h"
-#include "xfpm-battery.h"
-#include "xfpm-enum.h"
-#include "xfpm-enum-types.h"
-#include "xfpm-xfconf.h"
-#include "xfpm-tray-icon.h"
-#include "xfpm-config.h"
-#include "xfpm-shutdown.h"
-#include "xfpm-inhibit.h"
-#include "xfpm-debug.h"
-#include "xfpm-marshal.h"
-
-static void xfpm_supply_finalize   (GObject *object);
-static void xfpm_supply_refresh_tray_icon (XfpmSupply *supply);
-static void xfpm_supply_hide_adapter_icon (XfpmSupply *supply);
-
-#define XFPM_SUPPLY_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_SUPPLY, XfpmSupplyPrivate))
-
-struct XfpmSupplyPrivate
-{
-    XfpmNotify    *notify;
-    XfpmAdapter   *adapter;
-    XfpmXfconf    *conf;
-    XfpmTrayIcon  *tray;
-    XfpmInhibit   *inhibit;
-    
-    HalPower      *power;
-    GHashTable    *hash;
-    
-    gboolean       low_power;
-    gboolean       adapter_present;
-    gboolean       inhibited;
-    guint8         power_management;
-};
-
-enum
-{
-    PROP_O,
-    PROP_ON_BATTERY,
-    PROP_ON_LOW_BATTERY
-};    
-
-enum
-{
-    SHUTDOWN_REQUEST,
-    LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmSupply, xfpm_supply, G_TYPE_OBJECT)
-
-static void
-xfpm_supply_get_property (GObject *object,
-			  guint prop_id,
-			  GValue *value,
-			  GParamSpec *pspec)
-{
-    XfpmSupply *supply;
-    
-    supply = XFPM_SUPPLY (object);
-    
-    switch ( prop_id )
-    {
-	case PROP_ON_BATTERY:
-	    g_value_set_boolean (value, !supply->priv->adapter_present);
-	    break;
-	case PROP_ON_LOW_BATTERY:
-	    g_value_set_boolean (value, supply->priv->low_power);
-	    break;
-	default:
-	    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-	    break;
-    }
-    
-}
-
-static void
-xfpm_supply_has_inhibit_changed_cb (XfpmInhibit *inhibit, gboolean inhibited, XfpmSupply *supply)
-{
-    supply->priv->inhibited = inhibited;
-}
-
-static void 
-xfpm_supply_tray_settings_changed (GObject *obj, GParamSpec *spec, XfpmSupply *supply)
-{
-    xfpm_supply_refresh_tray_icon (supply);
-}
-
-static void
-xfpm_supply_class_init(XfpmSupplyClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    object_class->get_property = xfpm_supply_get_property;
-
-    signals[SHUTDOWN_REQUEST] = 
-    	g_signal_new("shutdown-request",
-                      XFPM_TYPE_SUPPLY,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmSupplyClass, shutdown_request),
-                      NULL, NULL,
-                      _xfpm_marshal_VOID__BOOLEAN_ENUM,
-                      G_TYPE_NONE, 2, 
-		      G_TYPE_BOOLEAN,
-		      XFPM_TYPE_SHUTDOWN_REQUEST);
-		      
-    g_object_class_install_property(object_class,
-                                    PROP_ON_BATTERY,
-                                    g_param_spec_boolean("on-battery",
-                                                         NULL, NULL,
-                                                         FALSE,
-                                                         G_PARAM_READABLE));
-							 
-    g_object_class_install_property(object_class,
-                                    PROP_ON_LOW_BATTERY,
-                                    g_param_spec_boolean("on-low-battery",
-                                                         NULL, NULL,
-                                                         FALSE,
-                                                         G_PARAM_READABLE));
-
-    object_class->finalize = xfpm_supply_finalize;
-
-    g_type_class_add_private (klass, sizeof (XfpmSupplyPrivate));
-}
-
-static void
-xfpm_supply_init (XfpmSupply *supply)
-{
-    supply->priv = XFPM_SUPPLY_GET_PRIVATE (supply);
-  
-    supply->priv->hash    = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
-     
-    supply->priv->power   = hal_power_new      ();
-    supply->priv->notify  = xfpm_notify_new    ();
-    supply->priv->conf    = xfpm_xfconf_new    ();
-    supply->priv->tray    = NULL;
-    supply->priv->inhibit = xfpm_inhibit_new   ();
-    supply->priv->inhibited = FALSE;
-    supply->priv->low_power = FALSE;
-    
-    g_signal_connect (supply->priv->inhibit, "has-inhibit-changed",
-		      G_CALLBACK (xfpm_supply_has_inhibit_changed_cb), supply);
-			  
-    g_signal_connect (supply->priv->conf, "notify::" SHOW_TRAY_ICON_CFG,
-		      G_CALLBACK (xfpm_supply_tray_settings_changed), supply);
-}
-
-static void
-xfpm_supply_finalize (GObject *object)
-{
-    XfpmSupply *supply;
-    supply = XFPM_SUPPLY(object);
-    
-    g_object_unref(supply->priv->power);
-	
-    g_hash_table_destroy (supply->priv->hash);
-	
-    g_object_unref (supply->priv->notify);
-	
-    g_object_unref (supply->priv->conf);
-	
-    g_object_unref (supply->priv->adapter);
-    
-    g_object_unref (supply->priv->inhibit);
-    xfpm_supply_hide_adapter_icon (supply);
-	
-    G_OBJECT_CLASS(xfpm_supply_parent_class)->finalize(object);
-}
-
-static void
-xfpm_supply_hide_adapter_icon (XfpmSupply *supply)
-{
-    if ( supply->priv->tray )
-    {
-	g_object_unref (supply->priv->tray);
-	supply->priv->tray = NULL;
-    }
-}
-
-static void
-xfpm_supply_show_tray_icon (XfpmSupply *supply)
-{
-#ifdef DEBUG 
-    /* This shouldn't happen at all*/
-    if ( supply->priv->tray )
-    {
-	g_critical ("Already have tray icon for adapter!");
-	xfpm_supply_hide_adapter_icon (supply);
-    }
-#endif    
-
-    supply->priv->tray = xfpm_tray_icon_new ();
-    
-    xfpm_tray_icon_set_visible (supply->priv->tray, FALSE);
-    xfpm_tray_icon_set_icon (supply->priv->tray, XFPM_AC_ADAPTER_ICON);
-    xfpm_tray_icon_set_show_info_menu (supply->priv->tray, FALSE);
-}
-
-static void
-xfpm_supply_refresh_tray_icon (XfpmSupply *supply)
-{
-    XfpmShowIcon show_icon;
-    
-    g_object_get (G_OBJECT (supply->priv->conf),
-		  SHOW_TRAY_ICON_CFG, &show_icon,
-		  NULL);
-		  
-    XFPM_DEBUG_ENUM ("Tray icon configuration: ", show_icon, XFPM_TYPE_SHOW_ICON);
-    
-    if ( show_icon == SHOW_ICON_ALWAYS )
-    {
-	if ( g_hash_table_size (supply->priv->hash) == 0 )
-	{
-	    xfpm_supply_show_tray_icon (supply);
-	    xfpm_tray_icon_set_tooltip (supply->priv->tray,
-					supply->priv->adapter_present ? 
-					(_("Adapter present")) :
-					(_("Adapter not present")) );
-	}
-	else
-	{
-	    xfpm_supply_hide_adapter_icon (supply);
-	}
-    }
-    else
-    {
-	xfpm_supply_hide_adapter_icon (supply);
-    }
-}
-
-static gboolean 
-xfpm_supply_on_low_power (XfpmSupply *supply)
-{
-    const HalBattery *device;
-    guint low_power_level;
-    
-    GList *list = NULL;
-    guint i;
-    gboolean low_power = FALSE;
-    
-    if (supply->priv->adapter_present )
-	return FALSE;
-    
-    list = g_hash_table_get_values (supply->priv->hash);
-    
-    if ( !list)
-	return FALSE;
-	
-    g_object_get (G_OBJECT (supply->priv->conf),
-		  CRITICAL_POWER_LEVEL, &low_power_level,
-		  NULL);
-		  
-    for ( i=0; i< g_list_length(list); i++)
-    {
-	XfpmBattery *battery = NULL;
-	HalDeviceType type;
-	guint percentage;
-	battery = g_list_nth_data(list, i);
-	
-	if ( !battery )
-	    continue;
-	    
-	device = xfpm_battery_get_device (battery);
-	g_object_get (G_OBJECT(device), "type", &type, "percentage", &percentage, NULL);
-	if ( type != HAL_DEVICE_TYPE_PRIMARY )
-	    continue;
-	    
-	if ( percentage < low_power_level ) 
-	    low_power = TRUE;
-	else 
-	    low_power = FALSE;
-    }
-    return low_power;
-}
-
-static void
-_notify_action_callback (NotifyNotification *n, gchar *action, XfpmSupply *supply)
-{
-    if ( xfpm_strequal(action, "shutdown") )
-	g_signal_emit (G_OBJECT(supply ), signals[SHUTDOWN_REQUEST], 0, TRUE, XFPM_DO_SHUTDOWN);
-    else if ( xfpm_strequal(action, "hibernate") )
-	g_signal_emit (G_OBJECT(supply ), signals[SHUTDOWN_REQUEST], 0, TRUE, XFPM_DO_HIBERNATE);
-}
-
-static void
-xfpm_supply_add_actions_to_notification (XfpmSupply *supply, XfpmBattery *battery, NotifyNotification *n)
-{
-    if (supply->priv->power_management != 0 )
-    {
-        xfpm_notify_add_action_to_notification(
-			       supply->priv->notify,
-			       n,
-                               "shutdown",
-                               _("Shutdown the system"),
-                               (NotifyActionCallback)_notify_action_callback,
-                               supply);   
-    }
-    
-    if ( supply->priv->power_management & SYSTEM_CAN_HIBERNATE )
-    {
-        xfpm_notify_add_action_to_notification(
-			       supply->priv->notify,
-			       n,
-                               "hibernate",
-                               _("Hibernate the system"),
-                               (NotifyActionCallback)_notify_action_callback,
-                               supply);      
-    }
-}
-
-static void
-xfpm_supply_show_critical_action_inhibited (XfpmSupply *supply, XfpmBattery *battery)
-{
-    NotifyNotification *n;
-    const gchar *message;
-    
-    message = _("System is running on low power, "\
-               "but an application is currently disabling the automatic sleep, "\
-	       "this means that doing a sleep now may damage the data of this application. "\
-	       "Close this application before putting the computer on sleep mode or plug "\
-	       "in your AC adapter");
-    
-     n = 
-	xfpm_notify_new_notification (supply->priv->notify, 
-				      _("Xfce power manager"), 
-				      message, 
-				      xfpm_battery_get_icon_name (battery),
-				      30000,
-				      XFPM_NOTIFY_CRITICAL,
-				      xfpm_battery_get_status_icon (battery));
-				      
-    xfpm_supply_add_actions_to_notification (supply, battery, n);
-    
-    xfpm_notify_critical (supply->priv->notify, n);
-}
-
-static void
-xfpm_supply_show_critical_action (XfpmSupply *supply, XfpmBattery *battery)
-{
-    const gchar *message;
-    NotifyNotification *n;
-    
-    message = _("System is running on low power. "\
-              "Save your work to avoid losing data");
-	      
-    n = 
-	xfpm_notify_new_notification (supply->priv->notify, 
-				      _("Xfce power manager"), 
-				      message, 
-				      xfpm_battery_get_icon_name (battery),
-				      20000,
-				      XFPM_NOTIFY_CRITICAL,
-				      xfpm_battery_get_status_icon (battery));
-    
-    xfpm_supply_add_actions_to_notification (supply, battery, n);
-    xfpm_notify_critical (supply->priv->notify, n);
-}
-
-static void
-xfpm_supply_process_critical_action (XfpmSupply *supply, XfpmBattery *battery, XfpmShutdownRequest critical_action)
-{
-    if ( critical_action == XFPM_ASK )
-    {
-	if ( supply->priv->inhibited )
-	    xfpm_supply_show_critical_action_inhibited (supply, battery);
-	else
-	    xfpm_supply_show_critical_action (supply, battery);
-	    
-	return;
-    }
-	
-    g_signal_emit (G_OBJECT(supply ), signals[SHUTDOWN_REQUEST], 0, TRUE, critical_action);
-}
-
-static void
-xfpm_supply_handle_primary_critical (XfpmSupply *supply, XfpmBattery *battery)
-{
-    XfpmShutdownRequest critical_action;
-    
-    g_object_get (G_OBJECT (supply->priv->conf),
-	          CRITICAL_BATT_ACTION_CFG, &critical_action,
-		  NULL);
-
-    TRACE ("System is running on low power");
-    XFPM_DEBUG_ENUM ("Critical battery action", critical_action, XFPM_TYPE_SHUTDOWN_REQUEST);
-    
-    if ( supply->priv->inhibited )
-    {
-	xfpm_supply_show_critical_action_inhibited (supply, battery);
-    }
-    else if ( critical_action == XFPM_DO_NOTHING )
-    {
-	xfpm_supply_show_critical_action (supply, battery);
-    }
-    else
-    {
-	xfpm_supply_process_critical_action (supply, battery, critical_action);
-    }
-}
-
-static void
-xfpm_supply_battery_state_changed_cb (XfpmBattery *battery, XfpmBatteryState state, XfpmSupply *supply)
-{
-    gboolean low_power;
-    
-    low_power = xfpm_supply_on_low_power (supply);
-    
-    if ( state == BATTERY_CHARGE_CRITICAL && low_power )
-    {
-	supply->priv->low_power = TRUE;
-	g_object_notify (G_OBJECT (supply), "on-low-battery");
-	xfpm_supply_handle_primary_critical (supply, battery);
-    }
-    else if ( !low_power && supply->priv->low_power )
-    {
-	supply->priv->low_power = FALSE;
-	g_object_notify (G_OBJECT (supply), "on-low-battery");
-	xfpm_notify_close_critical (supply->priv->notify);
-    }
-}
-
-static XfpmBattery *
-xfpm_supply_get_battery (XfpmSupply *supply, const gchar *udi)
-{
-    XfpmBattery *battery;
-    battery = (XfpmBattery *)g_hash_table_lookup (supply->priv->hash, udi);
-    return battery;
-}
-
-static void
-xfpm_supply_add_battery (XfpmSupply *supply, const HalBattery *device)
-{
-    XfpmBattery *battery;
-    const gchar *udi;
-    
-    udi = hal_device_get_udi (HAL_DEVICE(device));
-
-    TRACE("New battery found %s", udi);
-
-    battery = xfpm_battery_new (device);
-    
-    g_hash_table_insert (supply->priv->hash, g_strdup(udi), battery);
-    
-    g_signal_connect (G_OBJECT(battery), "battery-state-changed",
-		      G_CALLBACK(xfpm_supply_battery_state_changed_cb), supply);
-		      
-    xfpm_supply_refresh_tray_icon (supply);
-}
-
-static void
-xfpm_supply_remove_battery (XfpmSupply *supply,  const HalBattery *device)
-{
-    const gchar *udi = hal_device_get_udi (HAL_DEVICE(device));
-    
-    XfpmBattery *battery = xfpm_supply_get_battery(supply, udi);
-	
-    if ( battery )
-    {
-	TRACE("Removing battery %s", udi);
-	if (!g_hash_table_remove (supply->priv->hash, udi))
-		g_critical ("Unable to remove battery object from hash");
-    }
-    xfpm_supply_refresh_tray_icon (supply);
-}
-
-static void
-xfpm_supply_battery_added_cb (HalPower *power, const HalBattery *device, XfpmSupply *supply)
-{
-    xfpm_supply_add_battery (supply, device);
-}
-
-static void
-xfpm_supply_battery_removed_cb (HalPower *power, const HalBattery *device, XfpmSupply *supply)
-{
-    xfpm_supply_remove_battery (supply, device);
-}
-
-static gboolean
-xfpm_supply_monitor_start (XfpmSupply *supply)
-{
-    GPtrArray *array;
-    guint i = 0;
-    
-    supply->priv->adapter_present = xfpm_adapter_get_present (supply->priv->adapter);
-    
-    array = hal_power_get_batteries (supply->priv->power);
-    
-    for ( i = 0; i<array->len; i++ )
-    {
-	HalBattery *device;
-	device = (HalBattery *)g_ptr_array_index(array, i);
-	xfpm_supply_add_battery (supply, device);
-    }
-    
-    g_ptr_array_free(array, TRUE);
-    
-    g_signal_connect(supply->priv->power, "battery-added",
-		     G_CALLBACK(xfpm_supply_battery_added_cb), supply);
-		     
-    g_signal_connect(supply->priv->power, "battery-removed",
-		     G_CALLBACK(xfpm_supply_battery_removed_cb), supply);
-    
-    return FALSE;
-}
-
-static void
-xfpm_supply_save_power (XfpmSupply *supply)
-{
-    gboolean save_power;
-
-    g_object_get (G_OBJECT (supply->priv->conf),
-		  POWER_SAVE_ON_BATTERY, &save_power,
-		  NULL);
-    
-    if ( save_power == FALSE )
-	hal_power_unset_power_save (supply->priv->power);
-    else if ( supply->priv->adapter_present )
-	hal_power_unset_power_save (supply->priv->power);
-    else 
-	hal_power_set_power_save (supply->priv->power);
-}
-
-static void
-xfpm_supply_adapter_changed_cb (XfpmAdapter *adapter, gboolean present, XfpmSupply *supply)
-{
-    supply->priv->adapter_present = present;
-    
-    g_object_notify (G_OBJECT (supply), "on-battery");
-    
-    if ( supply->priv->adapter_present && supply->priv->low_power )
-    {
-	supply->priv->low_power = FALSE;
-	g_object_notify (G_OBJECT (supply), "on-low-battery");
-	xfpm_notify_close_critical (supply->priv->notify);
-    }
-    
-    xfpm_supply_save_power (supply);
-}
-
-/*
- * Public functions
- */ 
-XfpmSupply *
-xfpm_supply_new (guint8 power_management_info)
-{
-    XfpmSupply *supply = NULL;
-    supply = g_object_new(XFPM_TYPE_SUPPLY,NULL);
-    
-    supply->priv->power_management = power_management_info;
-    
-    return supply;
-}
-
-void xfpm_supply_monitor (XfpmSupply *supply)
-{
-    supply->priv->adapter = xfpm_adapter_new ();
-    
-    g_signal_connect (supply->priv->adapter, "adapter-changed",
-		      G_CALLBACK(xfpm_supply_adapter_changed_cb), supply);
-      
-    xfpm_supply_monitor_start (supply);
-    
-    xfpm_supply_refresh_tray_icon (supply);
-    
-    supply->priv->low_power = xfpm_supply_on_low_power (supply);
-    
-    if ( supply->priv->low_power )
-	g_object_notify (G_OBJECT (supply), "on-low-battery");
-}
-
-gboolean xfpm_supply_on_low_battery (XfpmSupply *supply)
-{
-    g_return_val_if_fail (XFPM_IS_SUPPLY(supply), FALSE);
-    
-    return supply->priv->low_power;
-}
-
-void xfpm_supply_reload (XfpmSupply *supply)
-{
-    g_return_if_fail (XFPM_IS_SUPPLY (supply));
-    
-    g_object_unref (supply->priv->power);
-    
-    g_hash_table_destroy (supply->priv->hash);
-    
-    supply->priv->power = hal_power_new ();
-    supply->priv->hash  = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
-    
-    xfpm_supply_monitor_start (supply);
-}
diff --git a/src/xfpm-supply.h b/src/xfpm-supply.h
deleted file mode 100644
index 982060b..0000000
--- a/src/xfpm-supply.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * * Copyright (C) 2008-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_SUPPLY_H
-#define __XFPM_SUPPLY_H
-
-#include <glib-object.h>
-
-#include "xfpm-enum.h"
-#include "xfpm-enum-glib.h"
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_SUPPLY       (xfpm_supply_get_type () )
-#define XFPM_SUPPLY(o)         (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_SUPPLY, XfpmSupply))
-#define XFPM_IS_SUPPLY(o)      (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_SUPPLY))
-
-typedef struct XfpmSupplyPrivate XfpmSupplyPrivate;
-
-typedef struct
-{
-    GObject		 parent;
-    XfpmSupplyPrivate   *priv;
-	
-} XfpmSupply;
-
-typedef struct
-{
-    GObjectClass         parent_class;
-    
-    void                (*shutdown_request)	    (XfpmSupply *supply,
-						     gboolean critical,
-						     XfpmShutdownRequest action);
-	
-} XfpmSupplyClass;
-
-GType   	         xfpm_supply_get_type       (void) G_GNUC_CONST;
-
-XfpmSupply     	        *xfpm_supply_new            (guint8 power_management_info);
-
-void                     xfpm_supply_monitor        (XfpmSupply *supply);
-
-gboolean                 xfpm_supply_on_low_battery (XfpmSupply *supply) G_GNUC_PURE;
-
-void                     xfpm_supply_reload         (XfpmSupply *supply);
-
-G_END_DECLS
-
-#endif /* __XFPM_SUPPLY_H */
diff --git a/src/xfpm-tray-icon.c b/src/xfpm-tray-icon.c
deleted file mode 100644
index 15713d3..0000000
--- a/src/xfpm-tray-icon.c
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * * Copyright (C) 2008-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 <gtk/gtk.h>
-
-#include <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
-
-#include "libxfpm/xfpm-common.h"
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-notify.h"
-#include "libxfpm/xfpm-icons.h"
-
-#include "xfpm-tray-icon.h"
-#include "xfpm-shutdown.h"
-#include "xfpm-dbus-monitor.h"
-#include "xfpm-inhibit.h"
-#include "xfpm-screen-saver.h"
-#include "xfpm-xfconf.h"
-#include "xfpm-config.h"
-
-static void xfpm_tray_icon_finalize   (GObject *object);
-
-#define XFPM_TRAY_ICON_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_TRAY_ICON, XfpmTrayIconPrivate))
-
-struct XfpmTrayIconPrivate
-{
-    XfpmShutdown    *shutdown;
-    XfpmXfconf      *conf;
-    XfpmNotify      *notify;
-    XfpmInhibit     *inhibit;
-    XfpmScreenSaver *srv;
-    XfpmDBusMonitor *monitor;
-    
-    GtkStatusIcon   *icon;
-    GQuark           icon_quark;
-    gboolean         info_menu;
-    gboolean         inhibited;
-    gboolean	     data_available;
-    
-    gulong           sig;
-    gulong	     sig_1;
-};
-
-enum
-{
-    SHOW_INFORMATION,
-    LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmTrayIcon, xfpm_tray_icon, G_TYPE_OBJECT)
-
-static gboolean
-xfpm_tray_icon_size_changed_cb (GtkStatusIcon *icon, gint size, XfpmTrayIcon *tray)
-{
-    GdkPixbuf *pix;
-    
-    g_return_val_if_fail (size > 0, FALSE);
-
-    if ( tray->priv->icon_quark == 0 )
-	return FALSE;
-    
-    pix = xfce_themed_icon_load (g_quark_to_string (tray->priv->icon_quark), size);
-    
-    if ( pix )
-    {
-	gtk_status_icon_set_from_pixbuf (GTK_STATUS_ICON(tray->priv->icon), pix);
-	g_object_unref (pix);
-	return TRUE;
-    }
-    return FALSE;
-}
-
-static void
-xfpm_tray_info (GtkWidget *w, XfpmTrayIcon *tray)
-{
-    g_signal_emit (G_OBJECT (tray), signals[SHOW_INFORMATION], 0);
-}
-
-static gboolean
-xfpm_tray_icon_do_suspend (XfpmTrayIcon *tray)
-{
-    GError *error = NULL;
-
-    xfpm_suspend (tray->priv->shutdown, &error);
-
-    if (error)
-    {
-	g_warning ("%s", error->message);
-	xfpm_notify_show_notification (tray->priv->notify, 
-				      _("Xfce power manager"), 
-				       error->message, 
-				       xfpm_tray_icon_get_icon_name (tray),
-				       10000,
-				       FALSE,
-				       XFPM_NOTIFY_CRITICAL,
-				       tray->priv->icon);
-	g_error_free (error);
-    }
-    return FALSE;
-}
-
-static gboolean
-xfpm_tray_icon_do_hibernate (XfpmTrayIcon *tray)
-{
-    GError *error = NULL;
-
-    xfpm_hibernate (tray->priv->shutdown, &error);
-    
-    if (error)
-    {
-	g_warning ("%s", error->message);
-	xfpm_notify_show_notification (tray->priv->notify, 
-				      _("Xfce power manager"), 
-				       error->message, 
-				       xfpm_tray_icon_get_icon_name (tray),
-				       10000,
-				       FALSE,
-				       XFPM_NOTIFY_CRITICAL,
-				       tray->priv->icon);
-	g_error_free (error);
-    }
-    return FALSE;
-}
-
-static void
-xfpm_tray_icon_hibernate_cb (GtkWidget *w, XfpmTrayIcon *tray)
-{
-    const gchar *message;
-    gboolean lock_screen;
-    gboolean ret;
-
-    g_object_get (G_OBJECT (tray->priv->conf),
-		  LOCK_SCREEN_ON_SLEEP, &lock_screen,
-		  NULL);
-    
-    message = tray->priv->inhibited ? 
-	     _("An application is currently disabling the automatic sleep,"
-	      " doing this action now may damage the working state of this application,"
-	      " are you sure you want to hibernate the system?") :
-	      _("Are you sure you want to proceed?") ;
-    
-    ret = 
-	xfce_confirm (message,
-		      GTK_STOCK_YES,
-		      _("Hibernate"));
-    
-    if ( ret ) 
-    {
-	xfpm_shutdown_add_callback (tray->priv->shutdown, 
-				    (GSourceFunc) xfpm_tray_icon_do_hibernate, 
-				    lock_screen,
-				    tray);
-    }
-}
-
-static void
-xfpm_tray_icon_suspend_cb (GtkWidget *w, XfpmTrayIcon *tray)
-{
-    const gchar *message;
-    gboolean lock_screen;
-    gboolean ret;
-    
-    g_object_get (G_OBJECT (tray->priv->conf),
-		  LOCK_SCREEN_ON_SLEEP, &lock_screen,
-		  NULL);
-    
-    message = tray->priv->inhibited ? 
-	     _("An application is currently disabling the automatic sleep,"
-	      " doing this action now may damage the working state of this application,"
-	      " are you sure you want to suspend the system?") :
-	      _("Are you sure you want to proceed?") ;
-    
-    ret = 
-	xfce_confirm  (message,
-		       GTK_STOCK_YES,
-		       _("Suspend"));
-    
-    if ( ret ) 
-    {
-	xfpm_shutdown_add_callback (tray->priv->shutdown, 
-				    (GSourceFunc) xfpm_tray_icon_do_suspend, 
-				    lock_screen,
-				    tray);
-    }
-}
-
-static void
-xfpm_tray_icon_exit_activated_cb (GtkWidget *w, gpointer data)
-{
-    gboolean ret;
-    
-    ret = xfce_confirm (_("Quit the Xfce power manager"),
-	                GTK_STOCK_YES,
-			_("Quit"));
-    if ( ret )
-    {
-	xfpm_quit ();
-    }
-}
-
-static void
-xfpm_tray_icon_menu_selection_done (GtkMenuShell *menu, gpointer data)
-{
-    gtk_widget_destroy (GTK_WIDGET (menu));
-}
-
-static void
-xfpm_tray_icon_inhibit_active_cb (GtkWidget *mi, XfpmTrayIcon *tray)
-{
-    gboolean active;
-    active = xfpm_screen_saver_get_inhibit (tray->priv->srv);
-    
-    active == FALSE ? xfpm_screen_saver_inhibit   (tray->priv->srv) :
-		      xfpm_screen_saver_uninhibit (tray->priv->srv);
-}
-
-static void
-xfpm_tray_icon_popup_menu_cb (GtkStatusIcon *icon, guint button, 
-			      guint activate_time, XfpmTrayIcon *tray)
-{
-    GtkWidget *menu, *mi, *img;
-    gboolean can_suspend = FALSE;
-    gboolean can_hibernate = FALSE ;
-    gboolean caller = FALSE;
-
-    gboolean saver_inhibited;
-
-    menu = gtk_menu_new();
-
-    g_object_get (G_OBJECT (tray->priv->shutdown),
-		  "caller-privilege", &caller,
-		  "can-suspend", &can_suspend,
-		  "can-hibernate", &can_hibernate,
-		  NULL);
-    
-    // Hibernate menu option
-    mi = gtk_image_menu_item_new_with_label (_("Hibernate"));
-    img = gtk_image_new_from_icon_name (XFPM_HIBERNATE_ICON, GTK_ICON_SIZE_MENU);
-    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(mi), img);
-    gtk_widget_set_sensitive (mi,FALSE);
-    
-    if ( caller && can_hibernate && tray->priv->data_available )
-    {
-	gtk_widget_set_sensitive (mi, TRUE);
-	g_signal_connect (G_OBJECT (mi), "activate",
-			  G_CALLBACK (xfpm_tray_icon_hibernate_cb), tray);
-    }
-    gtk_widget_show(mi);
-    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-    
-    // Suspend menu option
-    mi = gtk_image_menu_item_new_with_label(_("Suspend"));
-    img = gtk_image_new_from_icon_name (XFPM_SUSPEND_ICON, GTK_ICON_SIZE_MENU);
-    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(mi),img);
-    
-    gtk_widget_set_sensitive(mi,FALSE);
-    if ( caller && can_suspend && tray->priv->data_available )
-    {
-	gtk_widget_set_sensitive (mi,TRUE);
-	g_signal_connect (mi, "activate",
-			  G_CALLBACK (xfpm_tray_icon_suspend_cb), tray);
-    }
-    gtk_widget_show(mi);
-    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-
-    saver_inhibited = xfpm_screen_saver_get_inhibit (tray->priv->srv);
-    mi = gtk_check_menu_item_new_with_label (_("Monitor power control"));
-    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), !saver_inhibited);
-    gtk_widget_set_tooltip_text (mi, _("Disable or enable monitor power control, "\
-                                       "for example you could disable the screen power "\
-				       "control to avoid screen blanking when watching a movie."));
-    
-    g_signal_connect (G_OBJECT (mi), "activate",
-		      G_CALLBACK (xfpm_tray_icon_inhibit_active_cb), tray);
-    gtk_widget_set_sensitive (mi, TRUE);
-    gtk_widget_show(mi);
-    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-    
-    if ( tray->priv->info_menu )
-    {
-	mi = gtk_separator_menu_item_new();
-	gtk_widget_show(mi);
-	gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-    
-	// Battery informations
-    
-	mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_INFO, NULL);
-	
-	gtk_widget_set_sensitive(mi,FALSE);
-	gtk_widget_set_sensitive (mi,TRUE);
-	
-	g_signal_connect(mi,"activate",
-			 G_CALLBACK(xfpm_tray_info), tray);
-			 
-	gtk_widget_show(mi);
-	gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-    
-    
-	// Separator
-	mi = gtk_separator_menu_item_new();
-	gtk_widget_show(mi);
-	gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-    }
-	
-    mi = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP,NULL);
-    gtk_widget_set_sensitive(mi,TRUE);
-    gtk_widget_show(mi);
-    g_signal_connect(mi,"activate",G_CALLBACK(xfpm_help),NULL);
-	
-    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-    
-    
-    mi = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT,NULL);
-    gtk_widget_set_sensitive(mi,TRUE);
-    gtk_widget_show(mi);
-    g_signal_connect(mi,"activate",G_CALLBACK(xfpm_about), _("Xfce Power Manager"));
-    
-    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-    
-    mi = gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES,NULL);
-    gtk_widget_set_sensitive(mi,TRUE);
-    gtk_widget_show(mi);
-    g_signal_connect(mi,"activate",G_CALLBACK(xfpm_preferences),NULL);
-    
-    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-
-    mi = gtk_separator_menu_item_new ();
-    gtk_widget_show (mi);
-    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
-
-    mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
-    gtk_widget_set_sensitive (mi, TRUE);
-    gtk_widget_show (mi);
-    g_signal_connect (mi, "activate", G_CALLBACK (xfpm_tray_icon_exit_activated_cb), NULL);
-    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
-
-    g_signal_connect (menu, "selection-done",
-		      G_CALLBACK (xfpm_tray_icon_menu_selection_done), NULL);
-
-    // Popup the menu
-    gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
-		   gtk_status_icon_position_menu, 
-		   icon, button, activate_time);
-}
-
-static void
-xfpm_tray_icon_inhibit_changed_cb (XfpmInhibit *inhibit, gboolean inhibited, XfpmTrayIcon *tray)
-{
-    tray->priv->inhibited = inhibited;
-}
-
-static void
-xfpm_tray_icon_hal_connection_changed_cb (XfpmDBusMonitor *monitor, gboolean connected, XfpmTrayIcon *tray)
-{
-    if ( connected == FALSE )
-	xfpm_tray_icon_set_tooltip (tray, _("No data available"));
-	
-    /*
-     * We set this variable after since xfpm_tray_icon_set_tooltip will return 
-     * if data_available is set to FALSE
-     */
-    tray->priv->data_available = connected;
-}
-
-static void
-xfpm_tray_icon_activated_cb (XfpmTrayIcon *tray)
-{
-    xfpm_preferences ();
-}
-
-static void
-xfpm_tray_icon_class_init(XfpmTrayIconClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    signals[SHOW_INFORMATION] =
-            g_signal_new("show-information",
-                         XFPM_TYPE_TRAY_ICON,
-                         G_SIGNAL_RUN_LAST,
-                         G_STRUCT_OFFSET(XfpmTrayIconClass, show_info),
-                         NULL, NULL,
-                         g_cclosure_marshal_VOID__VOID,
-                         G_TYPE_NONE, 0, G_TYPE_NONE);
-
-    object_class->finalize = xfpm_tray_icon_finalize;
-
-    g_type_class_add_private(klass,sizeof(XfpmTrayIconPrivate));
-}
-
-static void
-xfpm_tray_icon_init(XfpmTrayIcon *tray)
-{
-    tray->priv = XFPM_TRAY_ICON_GET_PRIVATE(tray);
-    
-    tray->priv->icon  = gtk_status_icon_new();
-    tray->priv->shutdown = xfpm_shutdown_new ();
-    tray->priv->conf  = xfpm_xfconf_new ();
-    tray->priv->notify = xfpm_notify_new ();
-    tray->priv->inhibited = FALSE;
-    tray->priv->inhibit = xfpm_inhibit_new ();
-    tray->priv->srv     = xfpm_screen_saver_new ();
-    tray->priv->monitor = xfpm_dbus_monitor_new ();
-    
-    tray->priv->info_menu = TRUE;
-    tray->priv->icon_quark = 0;
-    
-    g_signal_connect (tray->priv->icon, "size-changed",
-		      G_CALLBACK (xfpm_tray_icon_size_changed_cb), tray);
-		      
-    g_signal_connect (tray->priv->icon, "popup-menu",
-		      G_CALLBACK (xfpm_tray_icon_popup_menu_cb), tray);
-		      
-    g_signal_connect_swapped (tray->priv->icon, "activate",
-			      G_CALLBACK (xfpm_tray_icon_activated_cb), tray);
-			      
-    tray->priv->sig = g_signal_connect (tray->priv->inhibit, "has-inhibit-changed",
-					G_CALLBACK (xfpm_tray_icon_inhibit_changed_cb), tray);
-					
-    tray->priv->sig_1 = g_signal_connect (tray->priv->monitor, "hal-connection-changed",
-					 G_CALLBACK (xfpm_tray_icon_hal_connection_changed_cb), tray);
-					 
-    tray->priv->data_available = xfpm_dbus_monitor_hal_connected (tray->priv->monitor);
-}
-
-static void
-xfpm_tray_icon_finalize(GObject *object)
-{
-    XfpmTrayIcon *tray;
-
-    tray = XFPM_TRAY_ICON(object);
-    
-    if ( g_signal_handler_is_connected (tray->priv->inhibit, tray->priv->sig ) )
-	g_signal_handler_disconnect (G_OBJECT (tray->priv->inhibit), tray->priv->sig);
-    
-    if ( g_signal_handler_is_connected (tray->priv->monitor, tray->priv->sig_1) )
-	g_signal_handler_disconnect (G_OBJECT (tray->priv->monitor), tray->priv->sig_1);
-	
-    g_object_unref (tray->priv->monitor);
-    
-    g_object_unref (tray->priv->icon);
-	
-    g_object_unref (tray->priv->shutdown);
-    
-    g_object_unref (tray->priv->conf);
-    
-    g_object_unref (tray->priv->notify);
-    
-    g_object_unref (tray->priv->inhibit);
-    
-    g_object_unref (tray->priv->srv);
-
-    G_OBJECT_CLASS(xfpm_tray_icon_parent_class)->finalize(object);
-}
-
-XfpmTrayIcon *
-xfpm_tray_icon_new(void)
-{
-    XfpmTrayIcon *tray = NULL;
-    tray = g_object_new (XFPM_TYPE_TRAY_ICON, NULL);
-    return tray;
-}
-
-void xfpm_tray_icon_set_show_info_menu (XfpmTrayIcon *icon, gboolean value)
-{
-    g_return_if_fail (XFPM_IS_TRAY_ICON (icon));
-    icon->priv->info_menu = value;
-}
-
-void xfpm_tray_icon_set_icon (XfpmTrayIcon *icon, const gchar *icon_name)
-{
-    g_return_if_fail(XFPM_IS_TRAY_ICON(icon));
-    
-    icon->priv->icon_quark = g_quark_from_string(icon_name);
-    
-    xfpm_tray_icon_size_changed_cb (icon->priv->icon,
-				    gtk_status_icon_get_size(icon->priv->icon),
-				    icon);
-}
-
-void xfpm_tray_icon_set_tooltip (XfpmTrayIcon *icon, const gchar *tooltip)
-{
-    g_return_if_fail (XFPM_IS_TRAY_ICON (icon));
-    /*
-     * Hal is disconnected we have the tooltips set to "no data available"
-     */
-    g_return_if_fail (icon->priv->data_available);
-
-#if GTK_CHECK_VERSION (2, 16, 0)
-    gtk_status_icon_set_tooltip_text (GTK_STATUS_ICON(icon->priv->icon), tooltip);
-#else
-    gtk_status_icon_set_tooltip (GTK_STATUS_ICON(icon->priv->icon), tooltip);
-#endif
-}
-
-void xfpm_tray_icon_set_visible (XfpmTrayIcon *icon, gboolean visible)
-{
-    g_return_if_fail(XFPM_IS_TRAY_ICON(icon));
-    
-    gtk_status_icon_set_visible(GTK_STATUS_ICON(icon->priv->icon), visible);
-}
-
-gboolean xfpm_tray_icon_get_visible (XfpmTrayIcon *icon)
-{
-    g_return_val_if_fail (XFPM_IS_TRAY_ICON(icon), FALSE);
-    
-    return gtk_status_icon_get_visible (GTK_STATUS_ICON(icon->priv->icon));
-}
-
-GtkStatusIcon *xfpm_tray_icon_get_tray_icon (XfpmTrayIcon *icon)
-{
-    g_return_val_if_fail(XFPM_IS_TRAY_ICON(icon), NULL);
-    
-    return icon->priv->icon;
-}
-
-const gchar *xfpm_tray_icon_get_icon_name   (XfpmTrayIcon *icon)
-{
-    g_return_val_if_fail(XFPM_IS_TRAY_ICON(icon), NULL);
-    
-    if ( icon->priv->icon_quark == 0 ) return NULL;
-    
-    return  g_quark_to_string (icon->priv->icon_quark);
-}
diff --git a/src/xfpm-tray-icon.h b/src/xfpm-tray-icon.h
deleted file mode 100644
index 31944e7..0000000
--- a/src/xfpm-tray-icon.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * * Copyright (C) 2008-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_TRAY_ICON_H
-#define __XFPM_TRAY_ICON_H
-
-#include <glib-object.h>
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_TRAY_ICON        (xfpm_tray_icon_get_type () )
-#define XFPM_TRAY_ICON(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_TRAY_ICON, XfpmTrayIcon))
-#define XFPM_IS_TRAY_ICON(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_TRAY_ICON))
-
-typedef struct XfpmTrayIconPrivate XfpmTrayIconPrivate;
-
-typedef struct
-{
-    GObject		    parent;
-    XfpmTrayIconPrivate    *priv;
-	
-} XfpmTrayIcon;
-
-typedef struct
-{
-    GObjectClass            parent_class;
-    
-    void                    (*show_info)	   (XfpmTrayIcon *icon);
-	
-} XfpmTrayIconClass;
-
-GType        	    xfpm_tray_icon_get_type        	(void) G_GNUC_CONST;
-XfpmTrayIcon       *xfpm_tray_icon_new             	(void);
-
-void                xfpm_tray_icon_set_show_info_menu 	(XfpmTrayIcon *icon,
-						         gboolean value);
-
-void                xfpm_tray_icon_set_icon        	(XfpmTrayIcon *icon,
-							 const gchar *icon_name);
-						    
-void                xfpm_tray_icon_set_tooltip     	(XfpmTrayIcon *icon,
-							 const gchar *tooltip);
-						    
-void                xfpm_tray_icon_set_visible    	(XfpmTrayIcon *icon,
-							 gboolean visible);
-						    
-gboolean            xfpm_tray_icon_get_visible     	(XfpmTrayIcon *icon);
-
-GtkStatusIcon      *xfpm_tray_icon_get_tray_icon   	(XfpmTrayIcon *icon) G_GNUC_PURE;
-
-const gchar        *xfpm_tray_icon_get_icon_name   	(XfpmTrayIcon *icon) G_GNUC_PURE;  
-
-G_END_DECLS
-
-#endif /* __XFPM_TRAY_ICON_H */
diff --git a/src/xfpm-xfconf.c b/src/xfpm-xfconf.c
index 2152b84..700988d 100644
--- a/src/xfpm-xfconf.c
+++ b/src/xfpm-xfconf.c
@@ -31,9 +31,6 @@
 
 #include <xfconf/xfconf.h>
 
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-common.h"
-
 #include "xfpm-xfconf.h"
 #include "xfpm-config.h"
 #include "xfpm-enum-glib.h"
@@ -237,7 +234,7 @@ xfpm_xfconf_class_init (XfpmXfconfClass *klass)
                                      PROP_CRITICAL_LEVEL,
                                      g_param_spec_uint (CRITICAL_POWER_LEVEL,
                                                         NULL, NULL,
-							1,
+							5,
 							20,
 							10,
                                                         G_PARAM_READWRITE));



More information about the Xfce4-commits mailing list