[Xfce4-commits] <xfce4-power-manager:nick/upower-session> More upower poerting.

Nick Schermer noreply at xfce.org
Tue Mar 6 23:36:01 CET 2012


Updating branch refs/heads/nick/upower-session
         to 761ce4d2e78facafbf907759869eb9421a213154 (commit)
       from 7ee6d2c47b41338219b9a64722be8020df5b4a8f (commit)

commit 761ce4d2e78facafbf907759869eb9421a213154
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Mar 6 23:34:56 2012 +0100

    More upower poerting.

 configure.ac.in         |    4 +-
 src/Makefile.am         |    2 +
 src/xfpm-battery.c      |  585 +++++++++++--------------
 src/xfpm-battery.h      |   40 +--
 src/xfpm-manager.c      |    2 +-
 src/xfpm-power-common.c |  201 +++------
 src/xfpm-power-common.h |   30 +--
 src/xfpm-power-info.c   | 1128 +++++++++++++++++++++--------------------------
 src/xfpm-power.c        |  121 ++----
 src/xfpm-power.h        |    2 +-
 10 files changed, 909 insertions(+), 1206 deletions(-)

diff --git a/configure.ac.in b/configure.ac.in
index eb7ba40..52313f1 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -53,8 +53,8 @@ XDT_I18N([@LINGUAS@])
 #==================================================== #
 #          Check for required packages 		      #
 #=====================================================#
-m4_define([gtk_minimum_version], [2.12.0])
-m4_define([glib_minimum_version], [2.16.0]) 
+m4_define([gtk_minimum_version], [2.20.0])
+m4_define([glib_minimum_version], [2.24.0]) 
 m4_define([dbus_minimum_version], [0.60])
 m4_define([dbus_glib_minimum_version], [0.70])
 
diff --git a/src/Makefile.am b/src/Makefile.am
index e6ce147..e4e2cea 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -91,6 +91,7 @@ xfce4_power_information_CFLAGS =		\
 	$(GOBJECT_CFLAGS)                       \
 	$(DBUS_GLIB_CFLAGS)                     \
 	$(LIBXFCE4UI_CFLAGS)			\
+	$(UPOWER_GLIB_CFLAGS)			\
 	$(PLATFORM_CPPFLAGS)			\
 	$(PLATFORM_CFLAGS)
 
@@ -102,6 +103,7 @@ xfce4_power_information_LDADD =			\
 	$(GOBJECT_LIBS)                         \
 	$(DBUS_GLIB_LIBS)                       \
 	$(LIBXFCE4UI_LIBS)			\
+	$(UPOWER_GLIB_LIBS)			\
 	$(top_builddir)/libdbus/libxfpmdbus.la
 
 if ENABLE_POLKIT
diff --git a/src/xfpm-battery.c b/src/xfpm-battery.c
index bd3a0db..026fb55 100644
--- a/src/xfpm-battery.c
+++ b/src/xfpm-battery.c
@@ -1,5 +1,6 @@
 /*
- * * Copyright (C) 2009-2011 Ali <aliov at xfce.org>
+ * Copyright (C) 2009-2011 Ali <aliov at xfce.org>
+ * Copyright (C) 2012      Nick Schermer <nick at xfce.org>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -29,6 +30,7 @@
 #include <gtk/gtk.h>
 
 #include <libxfce4util/libxfce4util.h>
+#include <libupower-glib/upower.h>
 
 #include "xfpm-battery.h"
 #include "xfpm-dbus.h"
@@ -43,29 +45,39 @@
 #include "xfpm-power-common.h"
 #include "xfpm-common.h"
 
+#define KIND_IS_BATTERY_OR_UPS(kind) ((kind) == UP_DEVICE_KIND_BATTERY || (kind) == UP_DEVICE_KIND_UPS)
+
+
+
 static void xfpm_battery_finalize   (GObject *object);
 
-#define XFPM_BATTERY_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_BATTERY, XfpmBatteryPrivate))
 
-struct XfpmBatteryPrivate
+
+struct _XfpmBatteryClass
 {
+    GtkStatusIconClass __parent__;
+};
+
+struct _XfpmBattery
+{
+    GtkStatusIcon __parent__;
+
     UpDevice               *device;
+    UpDeviceKind            device_kind;
+    UpDeviceState           device_state;
 
-    XfpmXfconf             *conf;
-    XfpmNotify             *notify;
-    XfpmButton             *button;
+    /* translated device name */
+    const gchar            *device_name;
 
-    gchar                  *icon_prefix;
+    /* icon prefix for this device kind */
+    const gchar            *icon_prefix;
 
-    XfpmBatteryCharge       charge;
-    XfpmDeviceType          type;
     gboolean                ac_online;
-    guint                   percentage;
-    gint64                  time_to_full;
-    gint64                  time_to_empty;
+    XfpmBatteryCharge       charge;
 
-    const gchar            *battery_name;
+    XfpmXfconf             *conf;
+    XfpmNotify             *notify;
+    XfpmButton             *button;
 
     gulong                  sig;
     gulong                  sig_bt;
@@ -75,8 +87,7 @@ enum
 {
     PROP_0,
     PROP_AC_ONLINE,
-    PROP_CHARGE_STATUS,
-    PROP_DEVICE_TYPE
+    PROP_CHARGE_STATUS
 };
 
 enum
@@ -96,20 +107,20 @@ G_DEFINE_TYPE (XfpmBattery, xfpm_battery, GTK_TYPE_STATUS_ICON)
 
 
 static const gchar *
-xfpm_battery_get_icon_index (UpDeviceKind kind;, gdouble percentage)
+xfpm_battery_get_icon_index (UpDeviceKind kind, gdouble percentage)
 {
-    if (kind == UP_DEVICE_KIND_BATTERY || kind == UP_DEVICE_KIND_UPS)
+    if (KIND_IS_BATTERY_OR_UPS (kind))
     {
         if (percentage < 20)
             return "000";
         else if (percentage < 40)
             return "020";
         else if (percentage < 60)
-            return "040");
+            return "040";
         else if (percentage < 80)
             return "060";
         else if (percentage < 100)
-            return "080");
+            return "080";
         else
             return "100";
     }
@@ -120,7 +131,7 @@ xfpm_battery_get_icon_index (UpDeviceKind kind;, gdouble percentage)
         else if (percentage < 60)
             return "030";
         else if (percentage < 100)
-            return "060");
+            return "060";
         else
             return "100";
     }
@@ -132,14 +143,12 @@ xfpm_battery_refresh_visible (XfpmBattery *battery)
     XfpmShowIcon show_icon;
     gboolean visible;
     gboolean is_present;
-    UpDeviceState state;
 
     g_object_get (battery->device,
                   "is-present", &is_present,
-                  "state", state.
                   NULL);
 
-    g_object_get (G_OBJECT (battery->priv->conf),
+    g_object_get (G_OBJECT (battery->conf),
                   SHOW_TRAY_ICON_CFG, &show_icon,
                   NULL);
 
@@ -150,7 +159,7 @@ xfpm_battery_refresh_visible (XfpmBattery *battery)
     else if ( show_icon == SHOW_ICON_WHEN_BATTERY_PRESENT )
         visible = is_present;
     else if ( show_icon == SHOW_ICON_WHEN_BATTERY_CHARGING_DISCHARGING )
-        visible = state != UP_DEVICE_STATE_FULLY_CHARGED;
+        visible = battery->device_state != UP_DEVICE_STATE_FULLY_CHARGED;
     else
         visible = FALSE;
 
@@ -179,7 +188,7 @@ xfpm_battery_get_time_string (gint64 seconds)
 
     if (minutes < 60)
     {
-        return g_strdup_printf (ngettext ("%i minute", 
+        return g_strdup_printf (ngettext ("%i minute",
                                           "%i minutes",
                                           minutes), minutes);
     }
@@ -189,7 +198,7 @@ xfpm_battery_get_time_string (gint64 seconds)
 
     if (minutes == 0)
     {
-        return = g_strdup_printf (ngettext ("%i hour", "%i hours", hours), hours);
+        return g_strdup_printf (ngettext ("%i hour", "%i hours", hours), hours);
     }
     else
     {
@@ -204,75 +213,96 @@ xfpm_battery_get_time_string (gint64 seconds)
 static gchar *
 xfpm_battery_get_message_from_battery_state (XfpmBattery *battery)
 {
-    gchar *msg  = NULL;
+    gchar *msg = NULL;
+    guint64 time_to_full;
+    gchar *tmp;
+    gint64 time_to_empty;
+    gdouble percentage;
+    gchar *est_time_str;
 
-    if (battery->priv->type == XFPM_DEVICE_TYPE_BATTERY || battery->priv->type == XFPM_DEVICE_TYPE_UPS)
+    if (KIND_IS_BATTERY_OR_UPS (battery->device_kind))
     {
-        switch (battery->priv->state)
+        switch (battery->device_state)
         {
-            case XFPM_DEVICE_STATE_FULLY_CHARGED:
-                msg = g_strdup_printf (_("Your %s is fully charged"), battery->priv->battery_name);
+            case UP_DEVICE_STATE_FULLY_CHARGED:
+                msg = g_strdup_printf (_("Your %s is fully charged"), battery->device_name);
                 break;
-            case XFPM_DEVICE_STATE_CHARGING:
-                msg = g_strdup_printf (_("Your %s is charging"), battery->priv->battery_name);
 
-                if ( battery->priv->time_to_full != 0 )
+            case UP_DEVICE_STATE_CHARGING:
+                msg = g_strdup_printf (_("Your %s is charging"), battery->device_name);
+
+                g_object_get (battery->device,
+                              "time-to-full", &time_to_full,
+                              "percentage", &percentage,
+                              NULL);
+                
+                if ( time_to_full > 0 )
                 {
-                    gchar *tmp, *est_time_str;
-                    tmp = g_strdup (msg);
-                    g_free (msg);
+                    est_time_str = xfpm_battery_get_time_string (time_to_full);
+                    tmp = msg;
 
-                    est_time_str = xfpm_battery_get_time_string (battery->priv->time_to_full);
+                    msg = g_strdup_printf (_("%s (%i%%)\n%s until is fully charged."),
+                                           tmp, (gint) percentage, est_time_str);
 
-                    msg = g_strdup_printf (_("%s (%i%%)\n%s until is fully charged."), tmp, battery->priv->percentage, est_time_str);
                     g_free (est_time_str);
                     g_free (tmp);
                 }
 
                 break;
-            case XFPM_DEVICE_STATE_DISCHARGING:
-                if (battery->priv->ac_online)
-                    msg =  g_strdup_printf (_("Your %s is discharging"), battery->priv->battery_name);
+
+            case UP_DEVICE_STATE_DISCHARGING:
+                if (battery->ac_online)
+                    msg =  g_strdup_printf (_("Your %s is discharging"), battery->device_name);
                 else
-                    msg =  g_strdup_printf (_("System is running on %s power"), battery->priv->battery_name);
+                    msg =  g_strdup_printf (_("System is running on %s power"), battery->device_name);
+
+                g_object_get (battery->device,
+                              "time-to-empty", &time_to_empty,
+                              "percentage", &percentage,
+                              NULL);
 
-                    if ( battery->priv->time_to_empty != 0 )
-                    {
-                        gchar *tmp, *est_time_str;
-                        tmp = g_strdup (msg);
-                        g_free (msg);
+                if ( time_to_empty > 0 )
+                {
+                    est_time_str = xfpm_battery_get_time_string (time_to_empty);
+                    tmp = msg;
 
-                        est_time_str = xfpm_battery_get_time_string (battery->priv->time_to_empty);
+                    msg = g_strdup_printf (_("%s (%i%%)\nEstimated time left is %s."),
+                                           tmp, (gint) percentage, est_time_str);
 
-                        msg = g_strdup_printf (_("%s (%i%%)\nEstimated time left is %s."), tmp, battery->priv->percentage, est_time_str);
-                        g_free (tmp);
-                        g_free (est_time_str);
-                    }
+                    g_free (tmp);
+                    g_free (est_time_str);
+                }
                 break;
-            case XFPM_DEVICE_STATE_EMPTY:
-                msg = g_strdup_printf (_("Your %s is empty"), battery->priv->battery_name);
+
+            case UP_DEVICE_STATE_EMPTY:
+                msg = g_strdup_printf (_("Your %s is empty"), battery->device_name);
                 break;
+
             default:
                 break;
         }
 
     }
-    else if (battery->priv->type >= XFPM_DEVICE_TYPE_MONITOR)
+    else if (battery->device_kind == UP_DEVICE_KIND_MONITOR)
     {
-        switch (battery->priv->state)
+        switch (battery->device_state)
         {
-            case XFPM_DEVICE_STATE_FULLY_CHARGED:
-                msg = g_strdup_printf (_("Your %s is fully charged"), battery->priv->battery_name);
+            case UP_DEVICE_STATE_FULLY_CHARGED:
+                msg = g_strdup_printf (_("Your %s is fully charged"), battery->device_name);
                 break;
-            case XFPM_DEVICE_STATE_CHARGING:
-                msg = g_strdup_printf (_("Your %s is charging"), battery->priv->battery_name);
+                
+            case UP_DEVICE_STATE_CHARGING:
+                msg = g_strdup_printf (_("Your %s is charging"), battery->device_name);
                 break;
-            case XFPM_DEVICE_STATE_DISCHARGING:
-                msg =  g_strdup_printf (_("Your %s is discharging"), battery->priv->battery_name);
+                
+            case UP_DEVICE_STATE_DISCHARGING:
+                msg =  g_strdup_printf (_("Your %s is discharging"), battery->device_name);
                 break;
-            case XFPM_DEVICE_STATE_EMPTY:
-                msg = g_strdup_printf (_("Your %s is empty"), battery->priv->battery_name);
+                
+            case UP_DEVICE_STATE_EMPTY:
+                msg = g_strdup_printf (_("Your %s is empty"), battery->device_name);
                 break;
+                
             default:
                 break;
         }
@@ -286,59 +316,55 @@ xfpm_battery_refresh_icon (XfpmBattery *battery)
 {
     gchar icon_name[128];
     gboolean is_present;
-    UpDeviceState state;
-    UpDeviceKind kind;
     gdouble percentage;
 
-    XFPM_DEBUG ("Battery state %d", battery->priv->state);
+    XFPM_DEBUG ("Battery state %d", battery->device_state);
 
     g_snprintf (icon_name, sizeof (icon_name), GTK_STOCK_MISSING_IMAGE);
 
     g_object_get (battery->device,
                   "is-present", &is_present,
-                  "state", &state,
-                  "kind", &kind,
                   "percentage", &percentage,
                   NULL);
 
-    if ( kind == UP_DEVICE_KIND_BATTERY || kind == UP_DEVICE_KIND_UPS )
+    if (KIND_IS_BATTERY_OR_UPS (battery->device_kind))
     {
         if (!is_present)
         {
             g_snprintf (icon_name, sizeof (icon_name), "%s%s",
-                        battery->priv->icon_prefix, "missing");
+                        battery->icon_prefix, "missing");
         }
         else
         {
-            switch (state)
+            switch (battery->device_state)
             {
                 case UP_DEVICE_STATE_FULLY_CHARGED:
                     g_snprintf (icon_name, sizeof (icon_name), "%s%s",
-                                battery->priv->icon_prefix,
-                                battery->priv->ac_online ? "charged" : "100");
+                                battery->icon_prefix,
+                                battery->ac_online ? "charged" : "100");
                     break;
 
                 case UP_DEVICE_STATE_CHARGING:
                 case UP_DEVICE_STATE_PENDING_CHARGE:
                     g_snprintf (icon_name, sizeof (icon_name), "%s%s-%s",
-                                battery->priv->icon_prefix,
-                                xfpm_battery_get_icon_index (kind, percentage),
+                                battery->icon_prefix,
+                                xfpm_battery_get_icon_index (battery->device_kind, percentage),
                                 "charging");
                     break;
 
                 case UP_DEVICE_STATE_DISCHARGING:
                 case UP_DEVICE_STATE_PENDING_DISCHARGE:
                     g_snprintf (icon_name, sizeof (icon_name), "%s%s",
-                                battery->priv->icon_prefix,
-                                xfpm_battery_get_icon_index (kind, percentage));
+                                battery->icon_prefix,
+                                xfpm_battery_get_icon_index (battery->device_kind, percentage));
                     break;
 
                 case UP_DEVICE_STATE_EMPTY:
                     g_snprintf (icon_name, sizeof (icon_name), "%s%s",
-                                battery->priv->icon_prefix,
-                                battery->priv->ac_online ? "000-charging" : "000");
+                                battery->icon_prefix,
+                                battery->ac_online ? "000-charging" : "000");
                     break;
-                
+
                 default:
                     g_assert_not_reached ();
                     break;
@@ -347,21 +373,21 @@ xfpm_battery_refresh_icon (XfpmBattery *battery)
     }
     else
     {
-        if (!present || state == UP_DEVICE_STATE_EMPTY)
+        if (!is_present || battery->device_state == UP_DEVICE_STATE_EMPTY)
         {
             g_snprintf (icon_name, sizeof (icon_name), "%s-000",
-                        battery->priv->icon_prefix);
+                        battery->icon_prefix);
         }
-        else if (state == XFPM_DEVICE_STATE_FULLY_CHARGED)
+        else if (battery->device_state == UP_DEVICE_STATE_FULLY_CHARGED)
         {
-            g_snprintf (icon_name, sizeof (icon_name), "%s-100", 
-                        battery->priv->icon_prefix);
+            g_snprintf (icon_name, sizeof (icon_name), "%s-100",
+                        battery->icon_prefix);
         }
-        else if (state == XFPM_DEVICE_STATE_DISCHARGING)
+        else if (battery->device_state == UP_DEVICE_STATE_DISCHARGING)
         {
             g_snprintf (icon_name, sizeof (icon_name), "%s-%s",
-                        battery->priv->icon_prefix,
-                        xfpm_battery_get_icon_index (kind, percentage));
+                        battery->icon_prefix,
+                        xfpm_battery_get_icon_index (battery->device_kind, percentage));
         }
     }
 
@@ -378,7 +404,7 @@ xfpm_battery_notify (XfpmBattery *battery)
     if ( !message )
         return;
 
-    xfpm_notify_show_notification (battery->priv->notify,
+    xfpm_notify_show_notification (battery->notify,
                                    _("Power Manager"),
                                    message,
                                    gtk_status_icon_get_icon_name (GTK_STATUS_ICON (battery)),
@@ -394,9 +420,9 @@ static gboolean
 xfpm_battery_notify_idle (gpointer data)
 {
     XfpmBattery *battery = XFPM_BATTERY (data);
-    
+
     xfpm_battery_notify (battery);
-    
+
     return FALSE;
 }
 
@@ -405,23 +431,19 @@ xfpm_battery_notify_state (XfpmBattery *battery)
 {
     gboolean notify;
     static gboolean starting_up = TRUE;
-    UpDeviceKind kind;
 
     if ( !gtk_status_icon_get_visible (GTK_STATUS_ICON (battery)) )
         return;
-    
+
     if ( starting_up )
     {
         starting_up = FALSE;
         return;
     }
-    
-    g_object_get (battery->device, "kind", &kind, NULL);
 
-    if ( kind == XFPM_DEVICE_TYPE_BATTERY || kind == XFPM_DEVICE_TYPE_UPS )
+    if (KIND_IS_BATTERY_OR_UPS (battery->device_kind))
     {
-
-        g_object_get (G_OBJECT (battery->priv->conf),
+        g_object_get (G_OBJECT (battery->conf),
                       GENERAL_NOTIFICATION_CFG, &notify,
                       NULL);
 
@@ -441,32 +463,30 @@ xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip)
     gchar *tip;
     gchar *est_time_str;
     const gchar *power_status;
-    UpDeviceState state;
     gdouble percentage;
     gint64 time_to_empty;
     gint64 time_to_full;
 
     g_object_get (battery->device,
-                  "state", &state,
                   "percentage", &percentage,
                   "time-to-empty", &time_to_empty,
                   "time-to-full", &time_to_full,
                   NULL);
 
-    if ( battery->priv->ac_online )
+    if ( battery->ac_online )
         power_status = _("Adaptor is online");
     else
         power_status = _("System is running on battery power");
 
-    if ( state == UP_DEVICE_STATE_FULLY_CHARGED )
+    if ( battery->device_state == UP_DEVICE_STATE_FULLY_CHARGED )
     {
         if ( time_to_empty > 0 )
         {
             est_time_str = xfpm_battery_get_time_string (time_to_empty);
             tip = g_strdup_printf (_("%s\nYour %s is fully charged (%i%%).\nProvides %s runtime"),
                                    power_status,
-                                   battery->priv->battery_name,
-                                   percentage,
+                                   battery->device_name,
+                                   (gint) percentage,
                                    est_time_str);
             g_free (est_time_str);
         }
@@ -474,19 +494,19 @@ xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip)
         {
             tip = g_strdup_printf (_("%s\nYour %s is fully charged (%i%%)."),
                                    power_status,
-                                   battery->priv->battery_name,
-                                   percentage);
+                                   battery->device_name,
+                                   (gint) percentage);
         }
     }
-    else if ( state == UP_DEVICE_STATE_CHARGING )
+    else if ( battery->device_state == UP_DEVICE_STATE_CHARGING )
     {
         if ( time_to_full > 0 )
         {
             est_time_str = xfpm_battery_get_time_string (time_to_full);
             tip = g_strdup_printf (_("%s\nYour %s is charging (%i%%)\n%s until is fully charged."),
                                    power_status,
-                                   battery->priv->battery_name,
-                                   percentage,
+                                   battery->device_name,
+                                   (gint) percentage,
                                    est_time_str);
             g_free (est_time_str);
         }
@@ -494,19 +514,19 @@ xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip)
         {
             tip = g_strdup_printf (_("%s\nYour %s is charging (%i%%)."),
                                    power_status,
-                                   battery->priv->battery_name,
-                                   percentage);
+                                   battery->device_name,
+                                   (gint) percentage);
         }
     }
-    else if ( state == UP_DEVICE_STATE_DISCHARGING )
+    else if ( battery->device_state == UP_DEVICE_STATE_DISCHARGING )
     {
         if ( time_to_empty > 0 )
         {
             est_time_str = xfpm_battery_get_time_string (time_to_empty);
             tip = g_strdup_printf (_("%s\nYour %s is discharging (%i%%)\nEstimated time left is %s."),
                                    power_status,
-                                   battery->priv->battery_name,
-                                   percentage,
+                                   battery->device_name,
+                                   (gint) percentage,
                                    est_time_str);
             g_free (est_time_str);
         }
@@ -514,33 +534,32 @@ xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip)
         {
             tip = g_strdup_printf (_("%s\nYour %s is discharging (%i%%)."),
                                    power_status,
-                                   battery->priv->battery_name,
-                                   percentage);
+                                   battery->device_name,
+                                   (gint) percentage);
         }
 
     }
-    else if ( state == UP_DEVICE_STATE_PENDING_CHARGING )
+    else if ( battery->device_state == UP_DEVICE_STATE_PENDING_CHARGE )
     {
-        tip = g_strdup_printf (_("%s\n%s waiting to discharge (%i%%)."), 
-                               power_status, battery->priv->battery_name, 
-                               percentage);
+        tip = g_strdup_printf (_("%s\n%s waiting to discharge (%i%%)."),
+                               power_status, battery->device_name,
+                               (gint) percentage);
     }
-    else if ( state == UP_DEVICE_STATE_PENDING_DISCHARGING )
+    else if ( battery->device_state == UP_DEVICE_STATE_PENDING_DISCHARGE )
     {
-        tip = g_strdup_printf (_("%s\n%s waiting to charge (%i%%)."), 
-                               power_status, 
-                               battery->priv->battery_name, 
-                               percentage);
+        tip = g_strdup_printf (_("%s\n%s waiting to charge (%i%%)."),
+                               power_status,
+                               battery->device_name,
+                               (gint) percentage);
     }
     else
     {
         tip = g_strdup_printf (_("%s\nYour %s is empty"),
-                               power_status, 
-                               battery->priv->battery_name);
+                               power_status,
+                               battery->device_name);
     }
 
     gtk_tooltip_set_text (tooltip, tip);
-    
     g_free (tip);
 }
 
@@ -549,28 +568,34 @@ xfpm_battery_check_charge (XfpmBattery *battery)
 {
     XfpmBatteryCharge charge;
     guint critical_level, low_level;
+    gdouble percentage;
+    
 
-    g_object_get (G_OBJECT (battery->priv->conf),
+    g_object_get (G_OBJECT (battery->conf),
                   CRITICAL_POWER_LEVEL, &critical_level,
                   NULL);
 
     low_level = critical_level + 10;
+    
+    g_object_get (battery->device,
+                  "percentage", &percentage,
+                  NULL);
 
-    if ( battery->priv->percentage > low_level )
+    if ( percentage > low_level )
         charge = XFPM_BATTERY_CHARGE_OK;
-    else if ( battery->priv->percentage <= low_level && battery->priv->percentage > critical_level )
+    else if ( percentage <= low_level && percentage > critical_level )
         charge = XFPM_BATTERY_CHARGE_LOW;
-    else if ( battery->priv->percentage <= critical_level )
+    else if ( percentage <= critical_level )
         charge = XFPM_BATTERY_CHARGE_CRITICAL;
 
-    if ( charge != battery->priv->charge)
+    if ( charge != battery->charge)
     {
-        battery->priv->charge = charge;
+        battery->charge = charge;
         /*
          * only emit signal when when battery charge changes from ok->low->critical
          * and not the other way round.
          */
-        if ( battery->priv->charge != XFPM_BATTERY_CHARGE_CRITICAL || charge != XFPM_BATTERY_CHARGE_LOW )
+        if ( battery->charge != XFPM_BATTERY_CHARGE_CRITICAL || charge != XFPM_BATTERY_CHARGE_LOW )
             g_signal_emit (G_OBJECT (battery), signals [BATTERY_CHARGE_CHANGED], 0);
     }
 }
@@ -585,77 +610,22 @@ xfpm_battery_button_pressed_cb (XfpmButton *button, XfpmButtonKey type, XfpmBatt
 static void
 xfpm_battery_changed_cb (UpDevice *device, XfpmBattery *battery)
 {
-    gboolean is_present;
-
+    UpDeviceState state;
 
     g_return_if_fail (battery->device == device);
 
-    g_object_get (battery->device,
-                  "is-present", &is_present,
-                  NULL);
+    g_object_get (battery->device, "state", &state, NULL);
 
-    value = g_hash_table_lookup (props, "IsPresent");
-
-    if ( value == NULL )
+    if ( state != battery->device_state )
     {
-        g_warning ("No 'IsPresent' property found");
-        goto out;
-    }
-
-    battery->priv->present = is_present;
-
-    value = g_hash_table_lookup (props, "State");
-
-    if ( value == NULL )
-    {
-        g_warning ("No 'State' property found");
-    }
-
-    state = g_value_get_uint (value);
-    if ( state != battery->priv->state )
-    {
-        battery->priv->state = state;
+        battery->device_state = state;
         xfpm_battery_refresh_visible (battery);
         xfpm_battery_notify_state (battery);
     }
 
-    value = g_hash_table_lookup (props, "Percentage");
-
-    if ( value == NULL )
-    {
-        g_warning ("No 'Percentage' property found on battery device");
-        goto out;
-    }
-
-    battery->priv->percentage = (guint) g_value_get_double (value);
-
     xfpm_battery_check_charge (battery);
 
     xfpm_battery_refresh_icon (battery);
-
-    if ( battery->priv->type == XFPM_DEVICE_TYPE_BATTERY ||
-         battery->priv->type == XFPM_DEVICE_TYPE_UPS )
-    {
-        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);
-    }
 }
 
 static gboolean
@@ -669,8 +639,7 @@ xfpm_battery_query_tooltip (GtkStatusIcon *icon,
 
     battery = XFPM_BATTERY (icon);
 
-    if ( battery->priv->type == XFPM_DEVICE_TYPE_BATTERY ||
-         battery->priv->type == XFPM_DEVICE_TYPE_UPS )
+    if ( KIND_IS_BATTERY_OR_UPS (battery->device_kind) )
     {
         xfpm_battery_set_tooltip_primary (battery, tooltip);
         return TRUE;
@@ -697,13 +666,10 @@ static void xfpm_battery_get_property (GObject *object,
     switch (prop_id)
     {
         case PROP_AC_ONLINE:
-            g_value_set_boolean (value, battery->priv->ac_online);
-            break;
-        case PROP_DEVICE_TYPE:
-            g_value_set_enum (value, battery->priv->type);
+            g_value_set_boolean (value, battery->ac_online);
             break;
         case PROP_CHARGE_STATUS:
-            g_value_set_enum (value, battery->priv->charge);
+            g_value_set_enum (value, battery->charge);
             break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -723,7 +689,7 @@ static void xfpm_battery_set_property (GObject *object,
     switch (prop_id)
     {
         case PROP_AC_ONLINE:
-            battery->priv->ac_online = g_value_get_boolean (value);
+            battery->ac_online = g_value_get_boolean (value);
             xfpm_battery_refresh_icon (battery);
             break;
         default:
@@ -749,8 +715,7 @@ xfpm_battery_class_init (XfpmBatteryClass *klass)
         g_signal_new ("battery-charge-changed",
                       XFPM_TYPE_BATTERY,
                       G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmBatteryClass, battery_charge_changed),
-                      NULL, NULL,
+                      0, NULL, NULL,
                       g_cclosure_marshal_VOID__VOID,
                       G_TYPE_NONE, 0, G_TYPE_NONE);
 
@@ -762,46 +727,31 @@ xfpm_battery_class_init (XfpmBatteryClass *klass)
                                                           G_PARAM_READWRITE));
 
     g_object_class_install_property (object_class,
-                                     PROP_DEVICE_TYPE,
-                                     g_param_spec_enum ("device-type",
-                                                        NULL, NULL,
-                                                        XFPM_TYPE_DEVICE_TYPE,
-                                                        XFPM_DEVICE_TYPE_UNKNOWN,
-                                                        G_PARAM_READABLE));
-
-    g_object_class_install_property (object_class,
                                      PROP_CHARGE_STATUS,
                                      g_param_spec_enum ("charge-status",
                                                         NULL, NULL,
                                                         XFPM_TYPE_BATTERY_CHARGE,
                                                         XFPM_BATTERY_CHARGE_UNKNOWN,
                                                         G_PARAM_READABLE));
-
-    g_type_class_add_private (klass, sizeof (XfpmBatteryPrivate));
 }
 
 static void
 xfpm_battery_init (XfpmBattery *battery)
 {
-    battery->priv = XFPM_BATTERY_GET_PRIVATE (battery);
-
-    battery->priv->conf          = xfpm_xfconf_new ();
-    battery->priv->notify        = xfpm_notify_new ();
-    battery->priv->state         = XFPM_DEVICE_STATE_UNKNOWN;
-    battery->priv->type          = XFPM_DEVICE_TYPE_UNKNOWN;
-    battery->priv->charge        = XFPM_BATTERY_CHARGE_UNKNOWN;
-    battery->priv->icon_prefix   = NULL;
-    battery->priv->time_to_full  = 0;
-    battery->priv->time_to_empty = 0;
-    battery->priv->button        = xfpm_button_new ();
-    battery->priv->ac_online     = TRUE;
+    battery->conf = xfpm_xfconf_new ();
+    battery->notify = xfpm_notify_new ();
+    battery->device_state = UP_DEVICE_STATE_UNKNOWN;
+    battery->device_kind = UP_DEVICE_KIND_UNKNOWN;
+    battery->charge = XFPM_BATTERY_CHARGE_UNKNOWN;
+    battery->button = xfpm_button_new ();
+    battery->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);
+    battery->sig = g_signal_connect (G_OBJECT (battery->conf), "notify::" SHOW_TRAY_ICON_CFG,
+                                     G_CALLBACK (xfpm_battery_tray_icon_settings_changed), battery);
 
 
-    battery->priv->sig_bt = g_signal_connect (G_OBJECT (battery->priv->button), "button-pressed",
-                                           G_CALLBACK (xfpm_battery_button_pressed_cb), battery);
+    battery->sig_bt = g_signal_connect (G_OBJECT (battery->button), "button-pressed",
+                                        G_CALLBACK (xfpm_battery_button_pressed_cb), battery);
 }
 
 static void
@@ -809,143 +759,134 @@ xfpm_battery_finalize (GObject *object)
 {
     XfpmBattery *battery = XFPM_BATTERY (object);
 
-    g_signal_handlers_disconnect_by_func (battery->priv->device,
+    g_signal_handlers_disconnect_by_func (battery->device,
         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);
+    if ( g_signal_handler_is_connected (battery->conf, battery->sig ) )
+        g_signal_handler_disconnect (G_OBJECT (battery->conf), battery->sig);
 
-     if ( g_signal_handler_is_connected (battery->priv->button, battery->priv->sig_bt ) )
-        g_signal_handler_disconnect (G_OBJECT (battery->priv->button), battery->priv->sig_bt);
+     if ( g_signal_handler_is_connected (battery->button, battery->sig_bt ) )
+        g_signal_handler_disconnect (G_OBJECT (battery->button), battery->sig_bt);
 
-    g_object_unref (battery->priv->conf);
-    g_object_unref (battery->priv->notify);
-    g_object_unref (battery->priv->button);
-    g_object_unref (battery->priv->device);
+    g_object_unref (battery->conf);
+    g_object_unref (battery->notify);
+    g_object_unref (battery->button);
+    g_object_unref (battery->device);
 
     G_OBJECT_CLASS (xfpm_battery_parent_class)->finalize (object);
 }
 
-static gchar *
-xfpm_battery_get_icon_prefix_device_enum_type (XfpmDeviceType type)
+static const gchar *
+xfpm_battery_get_icon_prefix (UpDeviceKind kind)
 {
-    if ( type == XFPM_DEVICE_TYPE_BATTERY )
-    {
-        return g_strdup (XFPM_PRIMARY_ICON_PREFIX);
-    }
-    else if ( type == XFPM_DEVICE_TYPE_UPS )
+    switch (kind)
     {
-        return g_strdup (XFPM_UPS_ICON_PREFIX);
-    }
-    else if ( type == XFPM_DEVICE_TYPE_MOUSE )
-    {
-        return g_strdup (XFPM_MOUSE_ICON_PREFIX);
-    }
-    else if ( type == XFPM_DEVICE_TYPE_KBD )
-    {
-        return g_strdup (XFPM_KBD_ICON_PREFIX);
-    }
-    else if ( type == XFPM_DEVICE_TYPE_PHONE )
-    {
-        return g_strdup (XFPM_PHONE_ICON_PREFIX);
-    }
+        case UP_DEVICE_KIND_BATTERY:
+            return XFPM_PRIMARY_ICON_PREFIX;
+
+        case UP_DEVICE_KIND_UPS:
+            return XFPM_UPS_ICON_PREFIX;
 
-    return g_strdup (XFPM_PRIMARY_ICON_PREFIX);
+        case UP_DEVICE_KIND_MOUSE:
+            return XFPM_MOUSE_ICON_PREFIX;
+
+        case UP_DEVICE_KIND_KEYBOARD:
+            return XFPM_KBD_ICON_PREFIX;
+
+        case UP_DEVICE_KIND_PHONE:
+            return XFPM_PHONE_ICON_PREFIX;
+
+        default:
+            return XFPM_PRIMARY_ICON_PREFIX;
+    }
 }
 
 static const gchar *
-xfpm_battery_get_name (XfpmDeviceType type)
+xfpm_battery_get_kind_name (UpDeviceKind kind)
 {
-    const gchar *name = NULL;
-
-    switch (type)
+    switch (kind)
     {
-        case XFPM_DEVICE_TYPE_BATTERY:
-            name = _("battery");
-            break;
-        case XFPM_DEVICE_TYPE_UPS:
-            name = _("UPS");
-            break;
-        case XFPM_DEVICE_TYPE_MONITOR:
-            name = _("monitor battery");
-            break;
-        case XFPM_DEVICE_TYPE_MOUSE:
-            name = _("mouse battery");
-            break;
-        case XFPM_DEVICE_TYPE_KBD:
-            name = _("keyboard battery");
-            break;
-        case XFPM_DEVICE_TYPE_PDA:
-            name = _("PDA battery");
-            break;
-        case XFPM_DEVICE_TYPE_PHONE:
-            name = _("Phone battery");
-            break;
+        case UP_DEVICE_KIND_BATTERY:
+            return _("battery");
+
+        case UP_DEVICE_KIND_UPS:
+            return _("UPS");
+
+        case UP_DEVICE_KIND_MONITOR:
+            return _("monitor battery");
+
+        case UP_DEVICE_KIND_MOUSE:
+            return _("mouse battery");
+
+        case UP_DEVICE_KIND_KEYBOARD:
+            return _("keyboard battery");
+
+        case UP_DEVICE_KIND_PDA:
+            return _("PDA battery");
+
+        case UP_DEVICE_KIND_PHONE:
+            return _("Phone battery");
+
         default:
-            name = _("Unknown");
-            break;
+            return _("Unknown");
     }
-
-    return name;
 }
 
 GtkStatusIcon *
 xfpm_battery_new (UpDevice *device)
 {
     XfpmBattery *battery = NULL;
+    UpDeviceKind device_kind;
 
-    battery = g_object_new (XFPM_TYPE_BATTERY, NULL);
+    battery = g_object_new (XFPM_TYPE_BATTERY,
+                            "has-tooltip", TRUE, NULL);
+
+    g_object_get (device, "kind", &device_kind, NULL);
 
     battery->device = g_object_ref (device);
+    battery->device_kind = device_kind;
+    battery->device_name = xfpm_battery_get_kind_name (device_kind);
+    battery->icon_prefix = xfpm_battery_get_icon_prefix (device_kind);
+
     g_signal_connect (device, "changed",
                       G_CALLBACK (xfpm_battery_changed_cb), battery);
+    xfpm_battery_changed_cb (device, battery);
 
     return GTK_STATUS_ICON (battery);
 }
 
-void xfpm_battery_monitor_device (XfpmBattery *battery,
-                                  DBusGProxy *proxy,
-                                  DBusGProxy *proxy_prop,
-                                  XfpmDeviceType device_type)
+UpDeviceKind
+xfpm_battery_get_kind (XfpmBattery *battery)
 {
-    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);
-    battery->priv->battery_name = xfpm_battery_get_name (device_type);
+    g_return_val_if_fail (XFPM_IS_BATTERY (battery), UP_DEVICE_KIND_UNKNOWN );
 
-
-    g_object_set (G_OBJECT (battery),
-                  "has-tooltip", TRUE,
-                  NULL);
-
-    xfpm_battery_changed_cb (proxy, battery);
-}
-
-XfpmDeviceType xfpm_battery_get_device_type (XfpmBattery *battery)
-{
-    g_return_val_if_fail (XFPM_IS_BATTERY (battery), XFPM_DEVICE_TYPE_UNKNOWN );
-
-    return battery->priv->type;
+    return battery->device_kind;
 }
 
-XfpmBatteryCharge xfpm_battery_get_charge (XfpmBattery *battery)
+XfpmBatteryCharge
+xfpm_battery_get_charge (XfpmBattery *battery)
 {
     g_return_val_if_fail (XFPM_IS_BATTERY (battery), XFPM_BATTERY_CHARGE_UNKNOWN);
 
-    return battery->priv->charge;
+    return battery->charge;
 }
 
-const gchar *xfpm_battery_get_battery_name (XfpmBattery *battery)
+const gchar *
+xfpm_battery_get_name (XfpmBattery *battery)
 {
     g_return_val_if_fail (XFPM_IS_BATTERY (battery), NULL);
 
-    return battery->priv->battery_name;
+    return battery->device_name;
 }
 
-gchar *xfpm_battery_get_time_left (XfpmBattery *battery)
+gchar *
+xfpm_battery_get_time_left (XfpmBattery *battery)
 {
+    gint64 time_to_empty;
+
     g_return_val_if_fail (XFPM_IS_BATTERY (battery), NULL);
 
-    return xfpm_battery_get_time_string (battery->priv->time_to_empty);
+    g_object_get (battery->device, "time-to-empty", &time_to_empty, NULL);
+
+    return xfpm_battery_get_time_string (time_to_empty);
 }
diff --git a/src/xfpm-battery.h b/src/xfpm-battery.h
index fdc5f04..882533b 100644
--- a/src/xfpm-battery.h
+++ b/src/xfpm-battery.h
@@ -29,41 +29,27 @@
 
 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))
+typedef struct _XfpmBatteryClass XfpmBatteryClass;
+typedef struct _XfpmBattery      XfpmBattery;
 
-typedef struct XfpmBatteryPrivate XfpmBatteryPrivate;
+#define XFPM_TYPE_BATTERY            (xfpm_battery_get_type ())
+#define XFPM_BATTERY(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFPM_TYPE_BATTERY, XfpmBattery))
+#define XFPM_BATTERY_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), XFPM_TYPE_BATTERY, XfpmBatteryClass))
+#define XFPM_IS_BATTERY(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFPM_TYPE_BATTERY))
+#define XFPM_IS_BATTERY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFPM_TYPE_BATTERY))
+#define XFPM_BATTERY_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), XFPM_TYPE_BATTERY, XfpmBatteryClass))
 
-typedef struct
-{
-    GtkStatusIcon      	    parent;
-    
-    XfpmBatteryPrivate     *priv;
-    
-} XfpmBattery;
-
-typedef struct
-{
-    GtkStatusIconClass 	    parent_class;
-    
-    void		    (*battery_charge_changed)	 (XfpmBattery *battery);
-    
-} XfpmBatteryClass;
-
-GType        		    xfpm_battery_get_type        (void) G_GNUC_CONST;
+GType                       xfpm_battery_get_type        (void) G_GNUC_CONST;
 
 GtkStatusIcon              *xfpm_battery_new             (UpDevice    *device);
 
-void			    xfpm_battery_monitor_device  (XfpmBattery *battery);
-
-XfpmDeviceType	   	    xfpm_battery_get_device_type (XfpmBattery *battery);
+UpDeviceKind                xfpm_battery_get_kind        (XfpmBattery *battery);
 
-XfpmBatteryCharge	    xfpm_battery_get_charge      (XfpmBattery *battery);
+XfpmBatteryCharge           xfpm_battery_get_charge      (XfpmBattery *battery);
 
-const gchar 		   *xfpm_battery_get_battery_name(XfpmBattery *battery);
+const gchar                *xfpm_battery_get_name        (XfpmBattery *battery);
 
-gchar 			   *xfpm_battery_get_time_left   (XfpmBattery *battery);
+gchar                      *xfpm_battery_get_time_left   (XfpmBattery *battery);
 
 G_END_DECLS
 
diff --git a/src/xfpm-manager.c b/src/xfpm-manager.c
index b13d49c..71c9c0d 100644
--- a/src/xfpm-manager.c
+++ b/src/xfpm-manager.c
@@ -312,7 +312,7 @@ xfpm_manager_alarm_timeout_cb (EggIdletime *idle, guint id, XfpmManager *manager
     {
 	XfpmShutdownRequest req = XFPM_DO_NOTHING;
 	gchar *sleep_mode;
-	gboolean on_battery;
+	gboolean on_battery = FALSE;
     
 	g_object_get (G_OBJECT (manager->priv->conf),
 		      INACTIVITY_SLEEP_MODE, &sleep_mode,
diff --git a/src/xfpm-power-common.c b/src/xfpm-power-common.c
index 39ecc18..cdfa30d 100644
--- a/src/xfpm-power-common.c
+++ b/src/xfpm-power-common.c
@@ -31,168 +31,113 @@
 #include "xfpm-icons.h"
 
 /**
- * xfpm_power_enumerate_devices:
- * 
- **/
-GPtrArray *
-xfpm_power_enumerate_devices (DBusGProxy *proxy)
-{
-    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 (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;
-}
-
-/**
- * xfpm_power_get_interface_properties:
- * 
- **/
-GHashTable *xfpm_power_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;
-}
-
-/**
- * xfpm_power_get_interface_property:
- * 
- **/
-GValue xfpm_power_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;
-}
-
-/**
- * xfpm_power_translate_device_type:
- * 
+ * xfpm_power_translate_kind:
+ *
  **/
 const gchar *
-xfpm_power_translate_device_type (guint type)
+xfpm_power_translate_kind (UpDeviceKind kind)
 {
-    switch (type)
+    switch (kind)
     {
-        case XFPM_DEVICE_TYPE_BATTERY:
+        case UP_DEVICE_KIND_BATTERY:
             return _("Battery");
-        case XFPM_DEVICE_TYPE_UPS:
+
+        case UP_DEVICE_KIND_UPS:
             return _("UPS");
-        case XFPM_DEVICE_TYPE_LINE_POWER:
+
+        case UP_DEVICE_KIND_LINE_POWER:
             return _("Line power");
-        case XFPM_DEVICE_TYPE_MOUSE:
+
+        case UP_DEVICE_KIND_MOUSE:
             return _("Mouse");
-        case XFPM_DEVICE_TYPE_KBD:
+
+        case UP_DEVICE_KIND_KEYBOARD:
             return _("Keyboard");
-	case XFPM_DEVICE_TYPE_MONITOR:
-	    return _("Monitor");
-	case XFPM_DEVICE_TYPE_PDA:
-	    return _("PDA");
-	case XFPM_DEVICE_TYPE_PHONE:
-	    return _("Phone");
-	case XFPM_DEVICE_TYPE_UNKNOWN:
-	    return _("Unknown");
+
+        case UP_DEVICE_KIND_MONITOR:
+            return _("Monitor");
+
+        case UP_DEVICE_KIND_PDA:
+            return _("PDA");
+
+        case UP_DEVICE_KIND_PHONE:
+            return _("Phone");
+
+        case UP_DEVICE_KIND_UNKNOWN:
+            return _("Unknown");
+
+        default:
+            return _("Battery");
     }
-    
-    return _("Battery");
 }
 
 /**
  * xfpm_power_translate_technology:
- * 
+ *
  **/
-const gchar *xfpm_power_translate_technology (guint value)
+const gchar *
+xfpm_power_translate_technology (UpDeviceTechnology technology)
 {
-    switch (value)
+    switch (technology)
     {
-        case 0:
-            return _("Unknown");
-        case 1:
+        case UP_DEVICE_TECHNOLOGY_LITHIUM_ION:
             return _("Lithium ion");
-        case 2:
+
+        case UP_DEVICE_TECHNOLOGY_LITHIUM_POLYMER:
             return _("Lithium polymer");
-        case 3:
+
+        case UP_DEVICE_TECHNOLOGY_LITHIUM_IRON_PHOSPHATE:
             return _("Lithium iron phosphate");
-        case 4:
+
+        case UP_DEVICE_TECHNOLOGY_LEAD_ACID:
             return _("Lead acid");
-        case 5:
+
+        case UP_DEVICE_TECHNOLOGY_NICKEL_CADMIUM:
             return _("Nickel cadmium");
-        case 6:
+
+        case UP_DEVICE_TECHNOLOGY_NICKEL_METAL_HYDRIDE:
             return _("Nickel metal hybride");
+
+        default:
+            return _("Unknown");
     }
-    
-    return _("Unknown");
 }
 
-const gchar *xfpm_power_get_icon_name (guint device_type)
+const gchar *
+xfpm_power_get_icon_name (UpDeviceKind kind)
 {
-    switch (device_type)
+    switch (kind)
     {
-        case XFPM_DEVICE_TYPE_BATTERY:
+        case UP_DEVICE_KIND_BATTERY:
             return XFPM_BATTERY_ICON;
-        case XFPM_DEVICE_TYPE_UPS:
+
+        case UP_DEVICE_KIND_UPS:
             return XFPM_UPS_ICON;
-        case XFPM_DEVICE_TYPE_LINE_POWER:
+
+        case UP_DEVICE_KIND_LINE_POWER:
             return XFPM_AC_ADAPTER_ICON;
-        case XFPM_DEVICE_TYPE_MOUSE:
+
+        case UP_DEVICE_KIND_MOUSE:
             return XFPM_MOUSE_ICON;
-        case XFPM_DEVICE_TYPE_KBD:
+
+        case UP_DEVICE_KIND_KEYBOARD:
             return XFPM_KBD_ICON;
-	case XFPM_DEVICE_TYPE_MONITOR:
-	    return "monitor";
-	case XFPM_DEVICE_TYPE_PDA:
-	    return XFPM_PDA_ICON;
-	case XFPM_DEVICE_TYPE_PHONE:
-	    return XFPM_PHONE_ICON;
-	case XFPM_DEVICE_TYPE_UNKNOWN:
-	    return XFPM_BATTERY_ICON;
+
+        case UP_DEVICE_KIND_MONITOR:
+            return "monitor";
+
+        case UP_DEVICE_KIND_PDA:
+            return XFPM_PDA_ICON;
+
+        case UP_DEVICE_KIND_PHONE:
+            return XFPM_PHONE_ICON;
+
+        case UP_DEVICE_KIND_UNKNOWN:
+            return XFPM_BATTERY_ICON;
+
+        default:
+            return XFPM_BATTERY_ICON;
     }
-    
-    return XFPM_BATTERY_ICON;
 }
 
 
diff --git a/src/xfpm-power-common.h b/src/xfpm-power-common.h
index 1040aed..20fd2fe 100644
--- a/src/xfpm-power-common.h
+++ b/src/xfpm-power-common.h
@@ -22,35 +22,13 @@
 #define XFPM_UPOWER_COMMON
 
 #include <dbus/dbus-glib.h>
+#include <libupower-glib/upower.h>
 
-#define UPOWER_NAME 	      "org.freedesktop.UPower"
-#define UPOWER_PATH 	      "/org/freedesktop/UPower"
+const gchar 	*xfpm_power_translate_kind      	(UpDeviceKind kind);
 
-#define UPOWER_IFACE 	      "org.freedesktop.UPower"
-#define UPOWER_IFACE_DEVICE   "org.freedesktop.UPower.Device"
-#define UPOWER_PATH_DEVICE    "/org/freedesktop/UPower/devices/"
+const gchar	*xfpm_power_translate_technology	(UpDeviceTechnology technology);
 
-#define UPOWER_PATH_WAKEUPS   "/org/freedesktop/UPower/Wakeups"
-#define UPOWER_IFACE_WAKEUPS  "org.freedesktop.UPower.Wakeups"
-
-#define POLKIT_AUTH_SUSPEND   "org.freedesktop.upower.suspend"
-#define	POLKIT_AUTH_HIBERNATE "org.freedesktop.upower.hibernate"
-
-
-GPtrArray 	*xfpm_power_enumerate_devices		(DBusGProxy *proxy);
-
-GHashTable	*xfpm_power_get_interface_properties 	(DBusGProxy *proxy_prop, 
-							 const gchar *iface_name);
-
-GValue 		 xfpm_power_get_interface_property   	(DBusGProxy *proxy, 
-							 const gchar *iface_name, 
-							 const gchar *prop_name);
-
-const gchar 	*xfpm_power_translate_device_type 	(guint type);
-
-const gchar	*xfpm_power_translate_technology	(guint value);
-
-const gchar	*xfpm_power_get_icon_name		(guint device_type);
+const gchar	*xfpm_power_get_icon_name		(UpDeviceKind kind);
 
 
 #endif /* XFPM_UPOWER_COMMON */
diff --git a/src/xfpm-power-info.c b/src/xfpm-power-info.c
index b29707b..62658bd 100644
--- a/src/xfpm-power-info.c
+++ b/src/xfpm-power-info.c
@@ -46,19 +46,18 @@
 
 #include "xfpm-unique.h"
 
-typedef struct 
+typedef struct
 {
-    DBusGConnection *bus;
-    
-    DBusGProxy 	    *power_proxy;
-    DBusGProxy      *wakeups_proxy;
-    
-    GtkWidget 	    *dialog;
-    GtkWidget       *notebook;
-    GtkWidget	    *sideview; /*Sidebar tree view*/
-    
-    GtkWidget	    *wakeups; /* Tree view processor wakeups*/
-    
+    UpWakeups *up_wakeups;
+
+    guint      timeout_id;
+
+    GtkWidget *dialog;
+    GtkWidget *notebook;
+    GtkWidget *sideview; /*Sidebar tree view*/
+
+    GtkWidget *wakeups; /* Tree view processor wakeups*/
+
 } XfpmInfo;
 
 enum
@@ -67,16 +66,16 @@ enum
     XFPM_DEVICE_INFO_VALUE,
     XFPM_DEVICE_INFO_LAST
 };
-    
+
 enum
 {
     COL_SIDEBAR_ICON,
     COL_SIDEBAR_NAME,
     COL_SIDEBAR_INT,
     NCOLS_SIDEBAR
-    
+
 };
-  
+
 enum
 {
     COL_WAKEUPS_TYPE,
@@ -107,71 +106,71 @@ show_version (void)
 static gchar *
 gpm_stats_format_cmdline (const gchar *command, gboolean is_userspace)
 {
-	gchar *found;
-	gchar *temp = NULL;
-	gchar *cmdline;
-	const gchar *temp_ptr;
-
-	/* nothing */
-	if (command == NULL) {
-		/* TRANSLATORS: the command line was not provided */
-		temp_ptr = _("No data");
-		goto out;
-	}
-
-	/* common kernel cmd names */
-	if (g_strcmp0 (command, "insmod") == 0) {
-		/* TRANSLATORS: kernel module, usually a device driver */
-		temp_ptr = _("Kernel module");
-		goto out;
-	}
-	if (g_strcmp0 (command, "modprobe") == 0) {
-		/* TRANSLATORS: kernel module, usually a device driver */
-		temp_ptr = _("Kernel module");
-		goto out;
-	}
-	if (g_strcmp0 (command, "swapper") == 0) {
-		/* TRANSLATORS: kernel housekeeping */
-		temp_ptr = _("Kernel core");
-		goto out;
-	}
-	if (g_strcmp0 (command, "kernel-ipi") == 0) {
-		/* TRANSLATORS: interrupt between processors */
-		temp_ptr = _("Interprocessor interrupt");
-		goto out;
-	}
-	if (g_strcmp0 (command, "interrupt") == 0) {
-		/* TRANSLATORS: unknown interrupt */
-		temp_ptr = _("Interrupt");
-		goto out;
-	}
-
-	/* truncate at first space or ':' */
-	temp = g_strdup (command);
-	found = strstr (temp, ":");
-	if (found != NULL)
-		*found = '\0';
-	found = strstr (temp, " ");
-	if (found != NULL)
-		*found = '\0';
-
-	/* remove path */
-	found = g_strrstr (temp, "/");
-	if (found != NULL && strncmp (temp, "event", 5) != 0)
-		temp_ptr = found + 1;
-	else
-		temp_ptr = temp;
+        gchar *found;
+        gchar *temp = NULL;
+        gchar *cmdline;
+        const gchar *temp_ptr;
+
+        /* nothing */
+        if (command == NULL) {
+                /* TRANSLATORS: the command line was not provided */
+                temp_ptr = _("No data");
+                goto out;
+        }
+
+        /* common kernel cmd names */
+        if (g_strcmp0 (command, "insmod") == 0) {
+                /* TRANSLATORS: kernel module, usually a device driver */
+                temp_ptr = _("Kernel module");
+                goto out;
+        }
+        if (g_strcmp0 (command, "modprobe") == 0) {
+                /* TRANSLATORS: kernel module, usually a device driver */
+                temp_ptr = _("Kernel module");
+                goto out;
+        }
+        if (g_strcmp0 (command, "swapper") == 0) {
+                /* TRANSLATORS: kernel housekeeping */
+                temp_ptr = _("Kernel core");
+                goto out;
+        }
+        if (g_strcmp0 (command, "kernel-ipi") == 0) {
+                /* TRANSLATORS: interrupt between processors */
+                temp_ptr = _("Interprocessor interrupt");
+                goto out;
+        }
+        if (g_strcmp0 (command, "interrupt") == 0) {
+                /* TRANSLATORS: unknown interrupt */
+                temp_ptr = _("Interrupt");
+                goto out;
+        }
+
+        /* truncate at first space or ':' */
+        temp = g_strdup (command);
+        found = strstr (temp, ":");
+        if (found != NULL)
+                *found = '\0';
+        found = strstr (temp, " ");
+        if (found != NULL)
+                *found = '\0';
+
+        /* remove path */
+        found = g_strrstr (temp, "/");
+        if (found != NULL && strncmp (temp, "event", 5) != 0)
+                temp_ptr = found + 1;
+        else
+                temp_ptr = temp;
 
 out:
-	/* format command line */
-	if (is_userspace)
-		cmdline = g_markup_escape_text (temp_ptr, -1);
-	else
-		cmdline = g_markup_printf_escaped ("<i>%s</i>", temp_ptr);
-	g_free (temp);
-
-	/* return */
-	return cmdline;
+        /* format command line */
+        if (is_userspace)
+                cmdline = g_markup_escape_text (temp_ptr, -1);
+        else
+                cmdline = g_markup_printf_escaped ("<i>%s</i>", temp_ptr);
+        g_free (temp);
+
+        /* return */
+        return cmdline;
 }
 
 /**
@@ -181,94 +180,84 @@ out:
 static gchar *
 gpm_stats_format_details (const gchar *command_details)
 {
-	gchar *details;
-
-	/* replace common driver names */
-	if (g_strcmp0 (command_details, "i8042") == 0) {
-		/* TRANSLATORS: the keyboard and mouse device event */
-		details = g_strdup (_("PS/2 keyboard/mouse/touchpad"));
-	} else if (g_strcmp0 (command_details, "acpi") == 0) {
-		/* TRANSLATORS: ACPI, the Intel power standard on laptops and desktops */
-		details = g_strdup (_("ACPI"));
-	} else if (g_strcmp0 (command_details, "ata_piix") == 0) {
-		/* TRANSLATORS: serial ATA is a new style of hard disk interface */
-		details = g_strdup (_("Serial ATA"));
-	} else if (g_strcmp0 (command_details, "libata") == 0) {
-		/* TRANSLATORS: this is the old-style ATA interface */
-		details = g_strdup (_("ATA host controller"));
-	} else if (g_strcmp0 (command_details, "iwl3945") == 0 || g_strcmp0 (command_details, "iwlagn") == 0) {
-		/* TRANSLATORS: 802.11 wireless adaptor */
-		details = g_strdup (_("Intel wireless adaptor"));
-
-	/* try to make the wakeup type nicer */
-	} else if (g_str_has_prefix (command_details, "__mod_timer")) {
-		/* TRANSLATORS: a timer is something that fires periodically */
-		details = g_strdup_printf (_("Timer %s"), command_details+12);
-	} else if (g_str_has_prefix (command_details, "mod_timer")) {
-		/* TRANSLATORS: a timer is something that fires periodically */
-		details = g_strdup_printf (_("Timer %s"), command_details+10);
-	} else if (g_str_has_prefix (command_details, "hrtimer_start_expires")) {
-		/* TRANSLATORS: a timer is something that fires periodically */
-		details = g_strdup_printf (_("Timer %s"), command_details+22);
-	} else if (g_str_has_prefix (command_details, "hrtimer_start")) {
-		/* TRANSLATORS: a timer is something that fires periodically */
-		details = g_strdup_printf (_("Timer %s"), command_details+14);
-	} else if (g_str_has_prefix (command_details, "do_setitimer")) {
-		/* TRANSLATORS: a timer is something that fires periodically */
-		details = g_strdup_printf (_("Timer %s"), command_details+10);
-	} else if (g_str_has_prefix (command_details, "do_nanosleep")) {
-		/* TRANSLATORS: this is a task that's woken up from sleeping */
-		details = g_strdup_printf (_("Sleep %s"), command_details+13);
-	} else if (g_str_has_prefix (command_details, "enqueue_task_rt")) {
-		/* TRANSLATORS: this is a new realtime task */
-		details = g_strdup_printf (_("New task %s"), command_details+16);
-	} else if (g_str_has_prefix (command_details, "futex_wait")) {
-		/* TRANSLATORS: this is a task thats woken to check state */
-		details = g_strdup_printf (_("Wait %s"), command_details+11);
-	} else if (g_str_has_prefix (command_details, "queue_delayed_work_on")) {
-		/* TRANSLATORS: a work queue is a list of work that has to be done */
-		details = g_strdup_printf (_("Work queue %s"), command_details+22);
-	} else if (g_str_has_prefix (command_details, "queue_delayed_work")) {
-		/* TRANSLATORS: a work queue is a list of work that has to be done */
-		details = g_strdup_printf (_("Work queue %s"), command_details+19);
-	} else if (g_str_has_prefix (command_details, "dst_run_gc")) {
-		/* TRANSLATORS: this is when the networking subsystem clears out old entries */
-		details = g_strdup_printf (_("Network route flush %s"), command_details+11);
-	} else if (g_str_has_prefix (command_details, "usb_hcd_poll_rh_status")) {
-		/* TRANSLATORS: activity on the USB bus */
-		details = g_strdup_printf (_("USB activity %s"), command_details+23);
-	} else if (g_str_has_prefix (command_details, "schedule_hrtimeout_range")) {
-		/* TRANSLATORS: we've timed out of an aligned timer */
-		details = g_strdup_printf (_("Wakeup %s"), command_details+25);
-	} else if (g_str_has_prefix (command_details, "Local timer interrupts")) {
-		/* TRANSLATORS: interupts on the system required for basic operation */
-		details = g_strdup (_("Local interrupts"));
-	} else if (g_str_has_prefix (command_details, "Rescheduling interrupts")) {
-		/* TRANSLATORS: interrupts when a task gets moved from one core to another */
-		details = g_strdup (_("Rescheduling interrupts"));
-	} else
-		details = g_markup_escape_text (command_details, -1);
-
-	return details;
+        gchar *details;
+
+        /* replace common driver names */
+        if (g_strcmp0 (command_details, "i8042") == 0) {
+                /* TRANSLATORS: the keyboard and mouse device event */
+                details = g_strdup (_("PS/2 keyboard/mouse/touchpad"));
+        } else if (g_strcmp0 (command_details, "acpi") == 0) {
+                /* TRANSLATORS: ACPI, the Intel power standard on laptops and desktops */
+                details = g_strdup (_("ACPI"));
+        } else if (g_strcmp0 (command_details, "ata_piix") == 0) {
+                /* TRANSLATORS: serial ATA is a new style of hard disk interface */
+                details = g_strdup (_("Serial ATA"));
+        } else if (g_strcmp0 (command_details, "libata") == 0) {
+                /* TRANSLATORS: this is the old-style ATA interface */
+                details = g_strdup (_("ATA host controller"));
+        } else if (g_strcmp0 (command_details, "iwl3945") == 0 || g_strcmp0 (command_details, "iwlagn") == 0) {
+                /* TRANSLATORS: 802.11 wireless adaptor */
+                details = g_strdup (_("Intel wireless adaptor"));
+
+        /* try to make the wakeup type nicer */
+        } else if (g_str_has_prefix (command_details, "__mod_timer")) {
+                /* TRANSLATORS: a timer is something that fires periodically */
+                details = g_strdup_printf (_("Timer %s"), command_details+12);
+        } else if (g_str_has_prefix (command_details, "mod_timer")) {
+                /* TRANSLATORS: a timer is something that fires periodically */
+                details = g_strdup_printf (_("Timer %s"), command_details+10);
+        } else if (g_str_has_prefix (command_details, "hrtimer_start_expires")) {
+                /* TRANSLATORS: a timer is something that fires periodically */
+                details = g_strdup_printf (_("Timer %s"), command_details+22);
+        } else if (g_str_has_prefix (command_details, "hrtimer_start")) {
+                /* TRANSLATORS: a timer is something that fires periodically */
+                details = g_strdup_printf (_("Timer %s"), command_details+14);
+        } else if (g_str_has_prefix (command_details, "do_setitimer")) {
+                /* TRANSLATORS: a timer is something that fires periodically */
+                details = g_strdup_printf (_("Timer %s"), command_details+10);
+        } else if (g_str_has_prefix (command_details, "do_nanosleep")) {
+                /* TRANSLATORS: this is a task that's woken up from sleeping */
+                details = g_strdup_printf (_("Sleep %s"), command_details+13);
+        } else if (g_str_has_prefix (command_details, "enqueue_task_rt")) {
+                /* TRANSLATORS: this is a new realtime task */
+                details = g_strdup_printf (_("New task %s"), command_details+16);
+        } else if (g_str_has_prefix (command_details, "futex_wait")) {
+                /* TRANSLATORS: this is a task thats woken to check state */
+                details = g_strdup_printf (_("Wait %s"), command_details+11);
+        } else if (g_str_has_prefix (command_details, "queue_delayed_work_on")) {
+                /* TRANSLATORS: a work queue is a list of work that has to be done */
+                details = g_strdup_printf (_("Work queue %s"), command_details+22);
+        } else if (g_str_has_prefix (command_details, "queue_delayed_work")) {
+                /* TRANSLATORS: a work queue is a list of work that has to be done */
+                details = g_strdup_printf (_("Work queue %s"), command_details+19);
+        } else if (g_str_has_prefix (command_details, "dst_run_gc")) {
+                /* TRANSLATORS: this is when the networking subsystem clears out old entries */
+                details = g_strdup_printf (_("Network route flush %s"), command_details+11);
+        } else if (g_str_has_prefix (command_details, "usb_hcd_poll_rh_status")) {
+                /* TRANSLATORS: activity on the USB bus */
+                details = g_strdup_printf (_("USB activity %s"), command_details+23);
+        } else if (g_str_has_prefix (command_details, "schedule_hrtimeout_range")) {
+                /* TRANSLATORS: we've timed out of an aligned timer */
+                details = g_strdup_printf (_("Wakeup %s"), command_details+25);
+        } else if (g_str_has_prefix (command_details, "Local timer interrupts")) {
+                /* TRANSLATORS: interupts on the system required for basic operation */
+                details = g_strdup (_("Local interrupts"));
+        } else if (g_str_has_prefix (command_details, "Rescheduling interrupts")) {
+                /* TRANSLATORS: interrupts when a task gets moved from one core to another */
+                details = g_strdup (_("Rescheduling interrupts"));
+        } else
+                details = g_markup_escape_text (command_details, -1);
+
+        return details;
 }
 
 static gchar *
-xfpm_info_get_energy_property (GHashTable *props, const gchar *prop, const gchar *unit)
+xfpm_info_get_energy_property (gdouble energy, const gchar *unit)
 {
-    GValue *value;
-    gchar *val = NULL;
-    gdouble energy;
-    
-    value = g_hash_table_lookup (props, prop);
-    
-    if ( !value )
-	return NULL;
-	
-    energy = g_value_get_double (value);
-    
-    val = g_strdup_printf ("%.1f %s", energy, unit);
-    
-    return val;
+    if (energy > 0)
+        return g_strdup_printf ("%.1f %s", energy, unit);
+    else
+        return NULL;
 }
 
 static void
@@ -280,295 +269,261 @@ xfpm_info_add_sidebar_icon (XfpmInfo *info, const gchar *name, const gchar *icon
     guint nt;
 
     list_store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (info->sideview)));
-    
+
     nt = gtk_notebook_get_n_pages (GTK_NOTEBOOK (info->notebook));
-    
+
     pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
-				    icon_name,
-				    48,
-				    GTK_ICON_LOOKUP_USE_BUILTIN,
-				    NULL);
-    
+                                    icon_name,
+                                    48,
+                                    GTK_ICON_LOOKUP_USE_BUILTIN,
+                                    NULL);
+
     gtk_list_store_append (list_store, &iter);
-    gtk_list_store_set (list_store, &iter, 
-			COL_SIDEBAR_ICON, pix,
-			COL_SIDEBAR_NAME, name,
-			COL_SIDEBAR_INT, nt,
-			-1);
-			
+    gtk_list_store_set (list_store, &iter,
+                        COL_SIDEBAR_ICON, pix,
+                        COL_SIDEBAR_NAME, name,
+                        COL_SIDEBAR_INT, nt,
+                        -1);
+
     if ( pix )
-	g_object_unref (pix);
+        g_object_unref (pix);
 }
 
 static void
-xfpm_info_add_device_view (XfpmInfo *info, GHashTable *props, const gchar *object_path)
+xfpm_info_add_device (XfpmInfo *info, UpDevice *device)
 {
     GtkWidget *view;
-
     GtkListStore *list_store;
     GtkTreeIter iter;
     GtkTreeViewColumn *col;
     GtkCellRenderer *renderer;
-    GValue *value;
-    const gchar *cstr;
+    UpDeviceKind kind;
+    gboolean power_supply;
+    gchar *model;
+    UpDeviceTechnology technology;
+    gdouble energy_full_design;
+    gdouble energy_empty;
+    gdouble energy_full;
+    gdouble voltage;
+    gchar *vendor;
+    gchar *serial;
     gchar *str;
-    gint i = 0;
-    guint type = 0;
-    const gchar *battery_type = NULL;
-    
+
+    g_return_if_fail (UP_IS_DEVICE (device));
+
     view = gtk_tree_view_new ();
-    
+
     list_store = gtk_list_store_new (XFPM_DEVICE_INFO_LAST, G_TYPE_STRING, G_TYPE_STRING);
 
     gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (list_store));
-    
+
     renderer = gtk_cell_renderer_text_new ();
-    
+
     /*Device Attribute*/
     col = gtk_tree_view_column_new();
     gtk_tree_view_column_pack_start (col, renderer, FALSE);
     gtk_tree_view_column_set_attributes (col, renderer, "text", XFPM_DEVICE_INFO_NAME, NULL);
     gtk_tree_view_column_set_title (col, _("Attribute"));
     gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
-    
+
     /*Device Attribute Value*/
     col = gtk_tree_view_column_new();
     gtk_tree_view_column_pack_start (col, renderer, FALSE);
     gtk_tree_view_column_set_attributes (col, renderer, "text", XFPM_DEVICE_INFO_VALUE, NULL);
     gtk_tree_view_column_set_title (col, _("Value"));
-    
+
     gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
-    
+
+    g_object_get (device,
+                  "kind", &kind,
+                  "power-supply", &power_supply,
+                  "model", &model,
+                  "technology", &technology,
+                  "energy-full-design", &energy_full_design,
+                  "energy-empty", &energy_empty,
+                  "energy-full", &energy_full,
+                  "voltage", &voltage,
+                  "vendor", &vendor,
+                  "serial", &serial,
+                  NULL);
+
     /**
      * Add Device information:
      **/
-    /*Device*/
+    /* Device */
     gtk_list_store_append (list_store, &iter);
-    gtk_list_store_set (list_store, &iter, 
-			XFPM_DEVICE_INFO_NAME, _("Device"), 
-			XFPM_DEVICE_INFO_VALUE, g_str_has_prefix (object_path, UPOWER_PATH_DEVICE) ? object_path + strlen (UPOWER_PATH_DEVICE) : object_path,
-			-1);
-    i++;
-    
-    
-    /*Type*/
-    value = g_hash_table_lookup (props, "Type");
-    
-    if ( value )
-    {
-	type = g_value_get_uint (value);
-	battery_type = xfpm_power_translate_device_type (type);
-	gtk_list_store_append (list_store, &iter);
-	gtk_list_store_set (list_store, &iter, 
-			    XFPM_DEVICE_INFO_NAME, _("Type"), 
-			    XFPM_DEVICE_INFO_VALUE, battery_type,
-			    -1);
-	i++;
-    }
-    
-    value = g_hash_table_lookup (props, "PowerSupply");
-    
-    if ( value )
-    {
-	gtk_list_store_append (list_store, &iter);
-	gtk_list_store_set (list_store, &iter, 
-			    XFPM_DEVICE_INFO_NAME, _("PowerSupply"), 
-			    XFPM_DEVICE_INFO_VALUE, g_value_get_boolean (value) == TRUE ? _("True") : _("False"),
-			    -1);
-	i++;
-    }
-    
-    if ( type != XFPM_DEVICE_TYPE_LINE_POWER )
+    gtk_list_store_set (list_store, &iter,
+                        XFPM_DEVICE_INFO_NAME, _("Device"),
+                        XFPM_DEVICE_INFO_VALUE, "TODO",
+                        -1);
+
+    /* Kind */
+    gtk_list_store_append (list_store, &iter);
+    gtk_list_store_set (list_store, &iter,
+                        XFPM_DEVICE_INFO_NAME, _("Kind"),
+                        XFPM_DEVICE_INFO_VALUE, xfpm_power_translate_kind (kind),
+                        -1);
+
+    /* PowerSupply */
+    gtk_list_store_append (list_store, &iter);
+    gtk_list_store_set (list_store, &iter,
+                        XFPM_DEVICE_INFO_NAME, _("PowerSupply"),
+                        XFPM_DEVICE_INFO_VALUE, power_supply ? _("True") : _("False"),
+                        -1);
+
+    if ( kind != UP_DEVICE_KIND_LINE_POWER)
     {
-	/*Model*/
-	value = g_hash_table_lookup (props, "Model");
-	
-	if ( value )
-	{
-	    cstr = g_value_get_string (value);
-	    if ( cstr && strlen (cstr) > 0)
-	    {
-		gtk_list_store_append (list_store, &iter);
-		gtk_list_store_set (list_store, &iter, 
-				    XFPM_DEVICE_INFO_NAME, _("Model"), 
-				    XFPM_DEVICE_INFO_VALUE, g_value_get_string (value),
-				    -1);
-		i++;
-	    }
-	}
-	
-	/*Technology*/
-	value = g_hash_table_lookup (props, "Technology");
-	
-	if ( value )
-	{
-	    gtk_list_store_append (list_store, &iter);
-	    gtk_list_store_set (list_store, &iter, 
-				XFPM_DEVICE_INFO_NAME, _("Technology"), 
-				XFPM_DEVICE_INFO_VALUE, xfpm_power_translate_technology (g_value_get_uint (value)),
-				-1);
-	    i++;
-	}
-	
-	/* TRANSLATORS: Unit here is What hour*/
-	str = xfpm_info_get_energy_property (props, "EnergyFullDesign", _("Wh"));
-	
-	if ( str )
-	{
-	    gtk_list_store_append (list_store, &iter);
-	    gtk_list_store_set (list_store, &iter, 
-				XFPM_DEVICE_INFO_NAME, _("Energy full design"), 
-				XFPM_DEVICE_INFO_VALUE, str,
-				-1);
-	    i++;
-	    g_free (str);
-	}
-	
-	/* TRANSLATORS: Unit here is What hour*/
-	str = xfpm_info_get_energy_property (props, "EnergyFull", _("Wh"));
-	
-	if ( str )
-	{
-	    gtk_list_store_append (list_store, &iter);
-	    gtk_list_store_set (list_store, &iter, 
-				XFPM_DEVICE_INFO_NAME, _("Energy full"), 
-				XFPM_DEVICE_INFO_VALUE, str,
-				-1);
-	    i++;
-	    g_free (str);
-	}
-	
-	/* TRANSLATORS: Unit here is What hour*/
-	str = xfpm_info_get_energy_property (props, "EnergyEmpty", _("Wh"));
-	
-	if ( str )
-	{
-	    gtk_list_store_append (list_store, &iter);
-	    gtk_list_store_set (list_store, &iter, 
-				XFPM_DEVICE_INFO_NAME, _("Energy empty"), 
-				XFPM_DEVICE_INFO_VALUE, str,
-				-1);
-	    i++;
-	    g_free (str);
-	}
-	
-	/* TRANSLATORS: Unit here is volt*/
-	str = xfpm_info_get_energy_property (props, "Voltage", _("V"));
-	if ( str )
-	{
-	    gtk_list_store_append (list_store, &iter);
-	    gtk_list_store_set (list_store, &iter, 
-				XFPM_DEVICE_INFO_NAME, _("Voltage"), 
-				XFPM_DEVICE_INFO_VALUE, str,
-				-1);
-	    i++;
-	    g_free (str);
-	}
-	
-	/*Vendor*/
-	value = g_hash_table_lookup (props, "Vendor");
-	
-	if ( value )
-	{
-	    cstr = g_value_get_string (value);
-	    if ( cstr && strlen (cstr) > 0)
-	    {
-		gtk_list_store_append (list_store, &iter);
-		gtk_list_store_set (list_store, &iter, 
-				    XFPM_DEVICE_INFO_NAME, _("Vendor"), 
-				    XFPM_DEVICE_INFO_VALUE, g_value_get_string (value),
-				    -1);
-		i++;
-	    }
-	}
-	
-	/*Serial*/
-	value = g_hash_table_lookup (props, "Serial");
-	
-	if ( value )
-	{
-	    cstr = g_value_get_string (value);
-	    if ( cstr && strlen (cstr) > 0)
-	    {
-		gtk_list_store_append (list_store, &iter);
-		gtk_list_store_set (list_store, &iter, 
-				    XFPM_DEVICE_INFO_NAME, _("Serial"), 
-				    XFPM_DEVICE_INFO_VALUE, g_value_get_string (value),
-				    -1);
-		i++;
-	    }
-	}
+        /* Model */
+        if ( model )
+        {
+            gtk_list_store_append (list_store, &iter);
+            gtk_list_store_set (list_store, &iter,
+                                XFPM_DEVICE_INFO_NAME, _("Model"),
+                                XFPM_DEVICE_INFO_VALUE, model,
+                                -1);
+        }
+
+        /* Technology */
+        if ( technology != UP_DEVICE_TECHNOLOGY_UNKNOWN )
+        {
+            gtk_list_store_append (list_store, &iter);
+            gtk_list_store_set (list_store, &iter,
+                                XFPM_DEVICE_INFO_NAME, _("Technology"),
+                                XFPM_DEVICE_INFO_VALUE, xfpm_power_translate_technology (technology),
+                                -1);
+        }
+
+        /* TRANSLATORS: Unit here is What hour */
+        str = xfpm_info_get_energy_property (energy_full_design, _("Wh"));
+        if ( str )
+        {
+            gtk_list_store_append (list_store, &iter);
+            gtk_list_store_set (list_store, &iter,
+                                XFPM_DEVICE_INFO_NAME, _("Energy full design"),
+                                XFPM_DEVICE_INFO_VALUE, str,
+                                -1);
+            g_free (str);
+        }
+
+        /* TRANSLATORS: Unit here is What hour */
+        str = xfpm_info_get_energy_property (energy_full, _("Wh"));
+        if ( str )
+        {
+            gtk_list_store_append (list_store, &iter);
+            gtk_list_store_set (list_store, &iter,
+                                XFPM_DEVICE_INFO_NAME, _("Energy full"),
+                                XFPM_DEVICE_INFO_VALUE, str,
+                                -1);
+            g_free (str);
+        }
+
+        /* TRANSLATORS: Unit here is What hour */
+        str = xfpm_info_get_energy_property (energy_empty, _("Wh"));
+        if ( str )
+        {
+            gtk_list_store_append (list_store, &iter);
+            gtk_list_store_set (list_store, &iter,
+                                XFPM_DEVICE_INFO_NAME, _("Energy empty"),
+                                XFPM_DEVICE_INFO_VALUE, str,
+                                -1);
+            g_free (str);
+        }
+
+        /* TRANSLATORS: Unit here is volt */
+        str = xfpm_info_get_energy_property (voltage, _("V"));
+        if ( str )
+        {
+            gtk_list_store_append (list_store, &iter);
+            gtk_list_store_set (list_store, &iter,
+                                XFPM_DEVICE_INFO_NAME, _("Voltage"),
+                                XFPM_DEVICE_INFO_VALUE, str,
+                                -1);
+            g_free (str);
+        }
+
+        /* Vendor */
+        if ( vendor )
+        {
+            gtk_list_store_append (list_store, &iter);
+            gtk_list_store_set (list_store, &iter,
+                                XFPM_DEVICE_INFO_NAME, _("Vendor"),
+                                XFPM_DEVICE_INFO_VALUE, vendor,
+                                -1);
+        }
+
+        /* Serial */
+        if ( serial )
+        {
+            gtk_list_store_append (list_store, &iter);
+            gtk_list_store_set (list_store, &iter,
+                                XFPM_DEVICE_INFO_NAME, _("Serial"),
+                                XFPM_DEVICE_INFO_VALUE, serial,
+                                -1);
+        }
     }
-    
-    xfpm_info_add_sidebar_icon (info, battery_type, xfpm_power_get_icon_name (type));
-    
+
+    g_free (model);
+    g_free (vendor);
+    g_free (serial);
+
+    xfpm_info_add_sidebar_icon (info,
+                                xfpm_power_translate_kind (kind),
+				xfpm_power_get_icon_name (kind));
+
     gtk_notebook_append_page (GTK_NOTEBOOK (info->notebook), view, NULL);
+
     gtk_widget_show (view);
 }
 
 static void
-xfpm_info_add_device (XfpmInfo *info, const gchar *object_path)
+xfpm_info_power_devices (XfpmInfo *info)
 {
-    DBusGProxy *proxy_prop;
-    GHashTable *props;
-    
-    proxy_prop = dbus_g_proxy_new_for_name (info->bus, 
-					    UPOWER_NAME,
-					    object_path,
-					    DBUS_INTERFACE_PROPERTIES);
-					    
-    if ( !proxy_prop )
+    UpClient *up_client;
+    GPtrArray *array;
+    guint i;
+    UpDevice *device;
+    GError *error = NULL;
+
+    up_client = up_client_new ();
+    if ( !up_client )
+        return;
+
+    if (!up_client_enumerate_devices_sync (up_client, NULL, &error))
     {
-	g_warning ("Unable to create proxy for : %s", object_path);
+	g_object_unref (up_client);
+	g_critical ("Failed to get devices: %s", error->message);
+	g_error_free (error);
+	
 	return;
     }
-    
-    props = xfpm_power_get_interface_properties (proxy_prop, UPOWER_IFACE_DEVICE);
-    
-    if ( props )
-    {
-	xfpm_info_add_device_view (info, props, object_path);
-	g_hash_table_destroy (props);
-    }
-}
 
-static void
-xfpm_info_power_devices (XfpmInfo *info)
-{
-    GPtrArray *array = NULL;
-    guint i;
-    
-    /*Check for upower/devkit power here*/
+    array = up_client_get_devices (up_client);
 
-    info->power_proxy = dbus_g_proxy_new_for_name (info->bus,
-						   UPOWER_NAME,
-						   UPOWER_PATH,
-						   UPOWER_IFACE);
-    
-    array = xfpm_power_enumerate_devices (info->power_proxy);
-    
     if ( array )
     {
-	for ( i = 0; i < array->len; i++)
-	{
-	    const gchar *object_path = ( const gchar *) g_ptr_array_index (array, i);
-	    xfpm_info_add_device (info, object_path);
-	}
-	g_ptr_array_free (array, TRUE);
+        for ( i = 0; i < array->len; i++)
+        {
+            device =  g_ptr_array_index (array, i);
+            xfpm_info_add_device (info, device);
+        }
+
+        g_ptr_array_unref (array);
     }
+
+    g_object_unref (up_client);
 }
 
 
 /**
- * 
+ *
  * Method GetData on /org/freedesktop/DeviceKit/Power/Wakeups
- * 
+ *
  * <method name="GetData">
  *     <arg name="data" type="a(budss)" direction="out"/> (1)
  * </method>
- *  (1): array | boolean	Wheter the proceess on userspace
- * 	       | uint           PID
- *             | double		Wakeups value            
+ *  (1): array | boolean        Wheter the proceess on userspace
+ *             | uint           PID
+ *             | double         Wakeups value
  *             | string         command line
  *             | string         details
  **/
@@ -576,126 +531,89 @@ static void
 xfpm_info_update_wakeups (XfpmInfo *info)
 {
     GtkListStore *store;
-    
     GError *error = NULL;
-    
-    static GType collection_type = G_TYPE_INVALID;
-    static GType struct_type = G_TYPE_INVALID;
-
-    GPtrArray *array = NULL;
-    
-    gboolean ret;
+    GPtrArray *array;
+    UpWakeupItem *item;
+    guint pid;
+    gboolean userspace;
     guint i;
-    
-    if ( G_UNLIKELY (collection_type == G_TYPE_INVALID ) )
-    {
-	struct_type = dbus_g_type_get_struct ("GValueArray",
-					      G_TYPE_BOOLEAN,
-					      G_TYPE_UINT,
-					      G_TYPE_DOUBLE,
-					      G_TYPE_STRING,
-					      G_TYPE_STRING,
-					      G_TYPE_INVALID);
-    
-	collection_type = dbus_g_type_get_collection ("GPtrArray", struct_type);
-    }
-    
-    ret = dbus_g_proxy_call (info->wakeups_proxy, "GetData", &error,
-			     G_TYPE_INVALID,
-			     collection_type, &array,
-			     NULL);
-		       
-    if ( !ret )
+    gchar *pid_str;
+    const gchar *icon;
+    gchar *value_str;
+    gchar *formatted_cmd;
+    gchar *formatted_details;
+    GtkTreeIter iter;
+
+    array = up_wakeups_get_data_sync (info->up_wakeups, NULL, &error);
+
+    if ( !array )
     {
-	g_warning ("GetData Failed on %s : %s", UPOWER_PATH_WAKEUPS, error->message);
-	g_error_free (error);
-	return;
+        g_warning ("Failed to get wakeups data: %s", error ? error->message : "No error");
+        g_clear_error (&error);
+        return;
     }
-		    
+
     store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (info->wakeups)));
-    
+
     gtk_list_store_clear (GTK_LIST_STORE (store));
-    
+
     for ( i = 0; i < array->len; i++ )
     {
-	GValue elem = { 0 };
-	GtkTreeIter iter;
-	
-	gboolean userspace;
-	guint pid;
-	gdouble value;
-	gchar *cmd;
-	gchar *formatted_cmd;
-	gchar *details;
-	gchar *formatted_details;
-	gchar *pid_str;
-	gchar *value_str;
-	const gchar *icon;
-	
-	g_value_init (&elem, struct_type);
-	g_value_set_static_boxed (&elem, g_ptr_array_index (array, i));
-	
-	dbus_g_type_struct_get (&elem,
-				0, &userspace,
-				1, &pid,
-				2, &value,
-				3, &cmd,
-				4, &details,
-				G_MAXUINT);
-	
-	if ( userspace )
-	{
-	    pid_str = g_strdup_printf ("%i", pid);
-	}
-	else
-	{
-	    if ( pid < 0xff0 )
-	    {
-		pid_str = g_strdup_printf ("IRQ%i", pid);
-	    }
-	    else
-	    {
-		pid_str = g_strdup("IRQx");
-	    }
-	}
-	value_str = g_strdup_printf ("%.1f", value);
-	
-	icon = userspace ? "application-x-executable" : "applications-system";
-	
-	formatted_cmd = gpm_stats_format_cmdline (cmd, userspace);
-	formatted_details = gpm_stats_format_details (details);
-	
-	gtk_list_store_append (store, &iter);
-	gtk_list_store_set (store, &iter, 
-			    COL_WAKEUPS_TYPE, icon,
-			    COL_WAKEUPS_PID, pid_str,
-			    COL_WAKEUPS_VALUE, value_str,
-			    COL_WAKEUPS_CMD, formatted_cmd,
-			    COL_WAKEUPS_DETAILS, formatted_details,
-			    -1);
-	
-	g_free (cmd);
-	g_free (details);
-	g_free (formatted_cmd);
-	g_free (formatted_details);
-	
-	g_value_unset (&elem);
+        item = g_ptr_array_index (array, i);
+        g_return_if_fail (UP_IS_WAKEUP_ITEM (item));
+
+        pid = up_wakeup_item_get_id (item);
+        userspace = up_wakeup_item_get_is_userspace (item);
+
+        if ( userspace )
+        {
+            pid_str = g_strdup_printf ("%i", pid);
+            icon = "application-x-executable";
+        }
+        else
+        {
+            if ( pid < 0xff0 )
+            {
+                pid_str = g_strdup_printf ("IRQ%i", pid);
+            }
+            else
+            {
+                pid_str = g_strdup("IRQx");
+            }
+
+            icon = "applications-system";
+        }
+
+        value_str = g_strdup_printf ("%.1f", up_wakeup_item_get_value (item));
+        formatted_cmd = gpm_stats_format_cmdline (up_wakeup_item_get_cmdline (item), userspace);
+        formatted_details = gpm_stats_format_details (up_wakeup_item_get_details (item));
+
+        gtk_list_store_append (store, &iter);
+        gtk_list_store_set (store, &iter,
+                            COL_WAKEUPS_TYPE, icon,
+                            COL_WAKEUPS_PID, pid_str,
+                            COL_WAKEUPS_VALUE, value_str,
+                            COL_WAKEUPS_CMD, formatted_cmd,
+                            COL_WAKEUPS_DETAILS, formatted_details,
+                            -1);
+
+        g_free (formatted_cmd);
+        g_free (formatted_details);
+        g_free (value_str);
+        g_free (pid_str);
     }
-	
-    g_ptr_array_free (array, TRUE);
-    
+
+    g_ptr_array_unref (array);
 }
 
 static gboolean
 xfpm_info_update_wakeups_idle (gpointer data)
 {
-    XfpmInfo *info;
-    
-    info = (XfpmInfo*)data;
-    
-    if ( GTK_WIDGET_VISIBLE (info->wakeups) ) 
+    XfpmInfo *info = data;
+
+    if ( GTK_WIDGET_VISIBLE (info->wakeups) )
         xfpm_info_update_wakeups (info);
-    
+
     return TRUE;
 }
 
@@ -708,28 +626,19 @@ xfpm_info_cpu_wakeups (XfpmInfo *info)
     GtkTreeViewColumn *col;
     GtkCellRenderer *renderer;
     
-    info->wakeups_proxy = dbus_g_proxy_new_for_name (info->bus,
-						     UPOWER_NAME,
-						     UPOWER_PATH_WAKEUPS,
-						     UPOWER_IFACE_WAKEUPS);
-							  
-    if ( !info->wakeups_proxy )
-    {
-	g_warning ("Unable to create proxy for %s", UPOWER_PATH_WAKEUPS);
-	return;
-    }
-    
-    list_store = gtk_list_store_new (NCOLS_WAKEUPS, 
-				     G_TYPE_STRING, /*type*/
-				     G_TYPE_STRING, /*pid*/
-				     G_TYPE_STRING, /*value*/
-				     G_TYPE_STRING, /*command*/
-				     G_TYPE_STRING); /*details*/
-				     
+    info->up_wakeups = up_wakeups_new ();
+
+    list_store = gtk_list_store_new (NCOLS_WAKEUPS,
+                                     G_TYPE_STRING, /*type*/
+                                     G_TYPE_STRING, /*pid*/
+                                     G_TYPE_STRING, /*value*/
+                                     G_TYPE_STRING, /*command*/
+                                     G_TYPE_STRING); /*details*/
+
     info->wakeups = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
-    
+
     xfpm_info_add_sidebar_icon (info, _("Processor"), XFPM_PROCESSOR_ICON);
-    
+
     col = gtk_tree_view_column_new ();
     renderer = gtk_cell_renderer_pixbuf_new ();
     g_object_set (G_OBJECT (renderer), "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
@@ -737,49 +646,49 @@ xfpm_info_cpu_wakeups (XfpmInfo *info)
     gtk_tree_view_column_set_attributes (col, renderer, "icon-name", COL_WAKEUPS_TYPE, NULL);
     gtk_tree_view_append_column (GTK_TREE_VIEW (info->wakeups), col);
     gtk_tree_view_column_set_title (col, _("Type"));
-    
+
     renderer = gtk_cell_renderer_text_new ();
-    
+
     col = gtk_tree_view_column_new ();
     gtk_tree_view_column_pack_start (col, renderer, FALSE);
     gtk_tree_view_column_set_attributes (col, renderer, "text", COL_WAKEUPS_PID, NULL);
     gtk_tree_view_append_column (GTK_TREE_VIEW (info->wakeups), col);
     /* TANSLATORS: PID, is the process id, e.g what ps x gives*/
     gtk_tree_view_column_set_title (col, _("PID"));
-    
+
     col = gtk_tree_view_column_new ();
     gtk_tree_view_column_pack_start (col, renderer, FALSE);
     gtk_tree_view_column_set_attributes (col, renderer, "markup", COL_WAKEUPS_VALUE, NULL);
     gtk_tree_view_append_column (GTK_TREE_VIEW (info->wakeups), col);
     gtk_tree_view_column_set_title (col, _("Wakeups"));
-    
+
     col = gtk_tree_view_column_new ();
     gtk_tree_view_column_pack_start (col, renderer, FALSE);
     gtk_tree_view_column_set_attributes (col, renderer, "markup", COL_WAKEUPS_CMD, NULL);
     gtk_tree_view_append_column (GTK_TREE_VIEW (info->wakeups), col);
     gtk_tree_view_column_set_title (col, _("Command"));
-    
+
     col = gtk_tree_view_column_new ();
     gtk_tree_view_column_pack_start (col, renderer, FALSE);
     gtk_tree_view_column_set_attributes (col, renderer, "markup", COL_WAKEUPS_DETAILS, NULL);
     gtk_tree_view_append_column (GTK_TREE_VIEW (info->wakeups), col);
     gtk_tree_view_column_set_title (col, _("Details"));
-    
+
     vbox = gtk_vbox_new (FALSE, 4);
     scrolled = gtk_scrolled_window_new (NULL, NULL);
     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
-				    GTK_POLICY_NEVER,
-				    GTK_POLICY_AUTOMATIC);
+                                    GTK_POLICY_NEVER,
+                                    GTK_POLICY_AUTOMATIC);
     gtk_container_add (GTK_CONTAINER (scrolled), info->wakeups);
-    
+
     gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE, 0);
     gtk_notebook_append_page (GTK_NOTEBOOK (info->notebook), vbox, NULL);
-    
-    xfpm_info_update_wakeups (info);
-    
+
     xfpm_info_update_wakeups (info);
-    g_timeout_add_seconds (4, (GSourceFunc) xfpm_info_update_wakeups_idle, info);
-    
+
+    /* TODO use data-changed and totals-changed signals? */
+    info->timeout_id = g_timeout_add_seconds (4, xfpm_info_update_wakeups_idle, info);
+
     gtk_widget_show (vbox);
 }
 
@@ -794,7 +703,7 @@ view_cursor_changed_cb (GtkTreeView *view, XfpmInfo *info)
     sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
 
     if ( !gtk_tree_selection_get_selected (sel, &model, &selected_row))
-	return;
+        return;
 
     gtk_tree_model_get(model,
                        &selected_row,
@@ -814,135 +723,107 @@ xfpm_info_create (XfpmInfo *info)
     GtkListStore *list_store;
     GtkTreeViewColumn *col;
     GtkCellRenderer *renderer;
-    
+
     info->dialog = xfce_titled_dialog_new_with_buttons (_("Power Information"),
-							NULL,
-							GTK_DIALOG_DESTROY_WITH_PARENT,
-							GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
-							NULL);
+                                                        NULL,
+                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+                                                        NULL);
     gtk_window_set_position (GTK_WINDOW (info->dialog), GTK_WIN_POS_CENTER_ALWAYS);
     gtk_window_set_default_size (GTK_WINDOW (info->dialog), -1, 400);
-				 
+
     gtk_window_set_icon_name (GTK_WINDOW (info->dialog), GTK_STOCK_INFO);
-			      
+
     content_area = gtk_dialog_get_content_area (GTK_DIALOG (info->dialog));
-    
+
     hbox = gtk_hbox_new (FALSE, 4);
-    
+
     gtk_container_add (GTK_CONTAINER (content_area), hbox);
-    
+
     viewport = gtk_viewport_new (NULL, NULL);
     info->sideview = gtk_tree_view_new ();
     list_store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
 
     gtk_tree_view_set_model (GTK_TREE_VIEW (info->sideview), GTK_TREE_MODEL (list_store));
-    
+
     gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (info->sideview),TRUE);
     col = gtk_tree_view_column_new ();
 
     renderer = gtk_cell_renderer_pixbuf_new ();
-    
+
     gtk_tree_view_column_pack_start (col, renderer, FALSE);
     gtk_tree_view_column_set_attributes (col, renderer, "pixbuf", 0, NULL);
 
     renderer = gtk_cell_renderer_text_new ();
     gtk_tree_view_column_pack_start (col, renderer, FALSE);
     gtk_tree_view_column_set_attributes (col, renderer, "markup", 1, NULL);
-    
+
     gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (info->sideview), FALSE);
     gtk_tree_view_append_column (GTK_TREE_VIEW (info->sideview), col);
-    
+
     g_signal_connect (info->sideview, "cursor-changed",
-		      G_CALLBACK (view_cursor_changed_cb), info);
-    
+                      G_CALLBACK (view_cursor_changed_cb), info);
+
     gtk_container_add (GTK_CONTAINER (viewport), info->sideview);
-    
+
     gtk_box_pack_start (GTK_BOX (hbox), viewport, FALSE, FALSE, 0);
-    
+
     info->notebook = gtk_notebook_new ();
     gtk_box_pack_start (GTK_BOX (hbox), info->notebook, TRUE, TRUE, 0);
     gtk_notebook_set_show_tabs (GTK_NOTEBOOK (info->notebook), FALSE);
-    
-    /*Show power devices information, AC adapter, batteries*/
+
+    /* Show power devices information, AC adapter, batteries */
     xfpm_info_power_devices (info);
-    
-    /*Sow CPU wakeups*/
+
+    /* Show CPU wakeups */
     xfpm_info_cpu_wakeups (info);
-    
+
     g_object_set (G_OBJECT (hbox),
-		  "border-width", 4,
-		  NULL);
-    
-    gtk_widget_show_all (hbox);
-}
+                  "border-width", 4,
+                  NULL);
 
-static void
-xfpm_info_connect (XfpmInfo *info)
-{
-    GError *error = NULL;
-    
-    info->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-    
-    if ( error )
-    {
-	xfce_dialog_show_error (NULL,
-				error,
-				NULL);
-	g_error ("Cannot connect to system bus : %s", error->message);
-    }
+    gtk_widget_show_all (hbox);
 }
 
 static XfpmInfo *
 xfpm_info_new (void)
 {
-    XfpmInfo *info;
-    
-    info = g_new0 (XfpmInfo, 1);
-    
-    info->bus           = NULL;
-    info->power_proxy   = NULL;
-    info->wakeups_proxy = NULL;
-    info->dialog        = NULL;
-    
-    return info;
+    return g_slice_new0 (XfpmInfo);
 }
 
 static void
 xfpm_info_free (XfpmInfo *info)
 {
-    if ( info->bus ) 
-	dbus_g_connection_unref (info->bus);
-	
-    if ( info->power_proxy )
-	g_object_unref (info->power_proxy);
-	
-    if ( info->wakeups_proxy )
-	g_object_unref (info->wakeups_proxy);
-	
-    g_free (info);
+    if ( info->timeout_id )
+        g_source_remove (info->timeout_id);
+
+    if ( info->up_wakeups )
+        g_object_unref (info->up_wakeups);
+
+    g_slice_free (XfpmInfo, info);
 }
 
 int main (int argc, char **argv)
 {
     XfpmInfo *info;
     XfpmUnique *unique;
-    
+
     GError *error = NULL;
     gboolean version = FALSE;
-    
-    GOptionEntry option_entries[] = 
+
+    GOptionEntry option_entries[] =
     {
-	{ "version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &version, N_("Version information"), NULL },
-	{ NULL, },
+        { "version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &version, N_("Version information"), NULL },
+        { NULL, },
     };
 
     xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
-    
+
     g_set_application_name (PACKAGE_NAME);
-    
-    if (!gtk_init_with_args (&argc, &argv, (gchar *)"", option_entries, (gchar *)PACKAGE, &error)) 
+
+    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);
@@ -952,36 +833,35 @@ int main (int argc, char **argv)
         else
         {
             g_error ("Unable to open display.");
-	}
+        }
 
         return EXIT_FAILURE;
     }
-    
-    if ( version )    
+
+    if ( version )
     {
-	show_version ();
+        show_version ();
     }
-    
-    
+
+
     unique = xfpm_unique_new ("org.Xfce.PowerManager.Info");
-    
+
     if ( !xfpm_unique_app_is_running (unique ) )
     {
-	info = xfpm_info_new ();
-	xfpm_info_connect (info);
-	xfpm_info_create (info);
-	
-	g_signal_connect_swapped (unique, "ping-received",
-				  G_CALLBACK (gtk_window_present), info->dialog);
-	
-	gtk_dialog_run (GTK_DIALOG (info->dialog));
-	
-	gtk_widget_destroy (info->dialog);
-	
-	xfpm_info_free (info);
+        info = xfpm_info_new ();
+        xfpm_info_create (info);
+
+        g_signal_connect_swapped (unique, "ping-received",
+                                  G_CALLBACK (gtk_window_present), info->dialog);
+
+        gtk_dialog_run (GTK_DIALOG (info->dialog));
+
+        gtk_widget_destroy (info->dialog);
+
+        xfpm_info_free (info);
     }
-    
+
     g_object_unref (unique);
-    
+
     return EXIT_SUCCESS;
 }
diff --git a/src/xfpm-power.c b/src/xfpm-power.c
index 9eca8e2..553e444 100644
--- a/src/xfpm-power.c
+++ b/src/xfpm-power.c
@@ -107,20 +107,18 @@ static void
 xfpm_power_report_error (XfpmPower *power, const gchar *error, const gchar *icon_name)
 {
     GtkStatusIcon *battery = NULL;
-    guint i, len;
-    GList *list;
+    UpDeviceKind kind;
+    GSList *li;
     
-    list = g_hash_table_get_values (power->hash);
-    len = g_list_length (list);
-    
-    for ( i = 0; i < len; i++)
+    for (li = power->devices; li != NULL; li = li->next)
     {
-        XfpmDeviceType type;
-        battery = g_list_nth_data (list, i);
-        type = xfpm_battery_get_device_type (XFPM_BATTERY (battery));
-        if ( type == XFPM_DEVICE_TYPE_BATTERY ||
-             type == XFPM_DEVICE_TYPE_UPS )
-             break;
+        kind = xfpm_battery_get_kind (XFPM_BATTERY (li->data));
+        if (kind == UP_DEVICE_KIND_BATTERY
+            || kind == UP_DEVICE_KIND_UPS)
+        {
+            battery = GTK_STATUS_ICON (li->data);
+            break;
+        }        
     }
     
     xfpm_notify_show_notification (power->notify, 
@@ -169,9 +167,9 @@ xfpm_power_sleep (XfpmPower *power, const gchar *sleep_time, gboolean force)
         xfpm_lock_screen ();
     }
     
-    dbus_g_proxy_call (power->proxy, sleep_time, &error,
+    /*TODO dbus_g_proxy_call (power->proxy, sleep_time, &error,
                        G_TYPE_INVALID,
-                       G_TYPE_INVALID);
+                       G_TYPE_INVALID);*/
     
     if ( error )
     {
@@ -452,7 +450,7 @@ xfpm_power_show_tray_menu_battery (GtkStatusIcon *icon, guint button,
 
 static void 
 xfpm_power_show_tray_menu_adaptor (GtkStatusIcon *icon, guint button, 
-                                 guint activate_time, XfpmPower *power)
+                                   guint activate_time, XfpmPower *power)
 {
     xfpm_power_show_tray_menu (power, icon, button, activate_time, FALSE);
 }
@@ -460,30 +458,25 @@ xfpm_power_show_tray_menu_adaptor (GtkStatusIcon *icon, guint button,
 static XfpmBatteryCharge
 xfpm_power_get_current_charge_state (XfpmPower *power)
 {
-    GList *list;
-    guint len, i;
-    XfpmBatteryCharge max_charge_status = XFPM_BATTERY_CHARGE_UNKNOWN;
+    XfpmBattery *battery;
+    UpDeviceKind kind;
+    GSList *li;
+    XfpmBatteryCharge max_charge, charge;
     
-    list = g_hash_table_get_values (power->hash);
-    len = g_list_length (list);
+    max_charge = XFPM_BATTERY_CHARGE_UNKNOWN;
     
-    for ( i = 0; i < len; i++)
+    for (li = power->devices; li != NULL; li = li->next)
     {
-        XfpmBatteryCharge battery_charge;
-        XfpmDeviceType type;
-        
-        g_object_get (G_OBJECT (g_list_nth_data (list, i)),
-                      "charge-status", &battery_charge,
-                      "device-type", &type,
-                      NULL);
-        if ( type != XFPM_DEVICE_TYPE_BATTERY && 
-             type != XFPM_DEVICE_TYPE_UPS )
-            continue;
-        
-        max_charge_status = MAX (max_charge_status, battery_charge);
+        battery = XFPM_BATTERY (li->data);
+        kind = xfpm_battery_get_kind (battery);
+        if (kind == UP_DEVICE_KIND_BATTERY || kind == UP_DEVICE_KIND_UPS)
+        {
+            charge = xfpm_battery_get_charge (battery);
+            max_charge = MAX (max_charge, charge);
+        }
     }
-    
-    return max_charge_status;
+
+    return max_charge;
 }
 
 static void
@@ -760,7 +753,7 @@ xfpm_power_battery_charge_changed_cb (XfpmBattery *battery, XfpmPower *power)
                 gchar *msg;
                 gchar *time_str;
                 
-                const gchar *battery_name = xfpm_battery_get_battery_name (battery);
+                const gchar *battery_name = xfpm_battery_get_name (battery);
                 
                 time_str = xfpm_battery_get_time_left (battery);
                 
@@ -792,12 +785,15 @@ xfpm_power_battery_charge_changed_cb (XfpmBattery *battery, XfpmPower *power)
 static void
 xfpm_power_add_device (XfpmPower *power, UpDevice *device)
 {
-    UpDeviceKind device_kind;
+    UpDeviceKind kind;
     GtkStatusIcon *battery;
     
+    g_return_if_fail (UP_IS_DEVICE (device));
+    g_return_if_fail (XFPM_IS_POWER (power));
+    
     g_object_get (device, "kind", &kind, NULL);
     
-    XFPM_DEBUG_ENUM (device_type, XFPM_TYPE_DEVICE_TYPE, " device added");
+    XFPM_DEBUG (" device added");
                                        
     switch (kind)
     {
@@ -820,7 +816,7 @@ xfpm_power_add_device (XfpmPower *power, UpDevice *device)
             break;
         
         case UP_DEVICE_KIND_LINE_POWER:
-            g_warning ("Unable to monitor unkown power device with object_path : %s", object_path);
+            g_warning ("Unable to monitor unkown power device: %s", "TODO");
             break;
         
         default:
@@ -832,22 +828,23 @@ xfpm_power_add_device (XfpmPower *power, UpDevice *device)
 static void
 xfpm_power_get_power_devices (XfpmPower *power)
 {
-    GPtrArray *array = NULL;
+    GPtrArray *array;
     guint i;
+    UpDevice *device;
     
-    array = xfpm_power_enumerate_devices (power->proxy);
+    array = up_client_get_devices (power->up_client);
     
     if ( array )
     {
         for ( i = 0; i < array->len; i++)
         {
-            const gchar *object_path = ( const gchar *) g_ptr_array_index (array, i);
-            XFPM_DEBUG ("Power device detected at : %s", object_path);
-            xfpm_power_add_device (power, object_path);
+            device = g_ptr_array_index (array, i);
+            g_return_if_fail (UP_IS_DEVICE (device));
+        
+            xfpm_power_add_device (power, device);
         }
-        g_ptr_array_free (array, TRUE);
+        g_ptr_array_unref (array);
     }
-    
 }
 
 static void
@@ -928,20 +925,14 @@ xfpm_power_refresh_adaptor_visible (XfpmPower *power)
     
     if ( show_icon == SHOW_ICON_ALWAYS )
     {
-        if ( g_hash_table_size (power->hash) == 0 )
+        
+        if (power->devices == NULL)
         {
             xfpm_power_show_adapter_icon (power);
-#if GTK_CHECK_VERSION (2, 16, 0)
             gtk_status_icon_set_tooltip_text (power->adapter_icon, 
                                               TRUE ? //power->on_battery ? 
                                               _("Adaptor is offline") :
                                               _("Adaptor is online") );
-#else
-            gtk_status_icon_set_tooltip (power->adapter_icon, 
-                                         TRUE ?//power->on_battery ? 
-                                         _("Adaptor is offline") :
-                                         _("Adaptor is online") );
-#endif
         }
         else
         {
@@ -1024,7 +1015,6 @@ xfpm_power_init (XfpmPower *power)
     GError *error = NULL;
     gboolean on_battery;
 
-    power->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
     power->dialog          = NULL;
     power->adapter_icon    = NULL;
     power->overall_state   = XFPM_BATTERY_CHARGE_OK;
@@ -1071,28 +1061,9 @@ xfpm_power_finalize (GObject *object)
     power = XFPM_POWER (object);
 
     g_object_unref (power->conf);
+    g_object_unref (power->up_client);
     
     xfpm_power_hide_adapter_icon (power);
-    
-    dbus_g_connection_unref (power->bus);
-    
-    if ( power->proxy )
-    {
-        dbus_g_proxy_disconnect_signal (power->proxy, "Changed",
-                                        G_CALLBACK (xfpm_power_changed_cb), power);
-        dbus_g_proxy_disconnect_signal (power->proxy, "DeviceRemoved",
-                                        G_CALLBACK (xfpm_power_device_removed_cb), power);
-        dbus_g_proxy_disconnect_signal (power->proxy, "DeviceAdded",
-                                        G_CALLBACK (xfpm_power_device_added_cb), power);
-        dbus_g_proxy_disconnect_signal (power->proxy, "DeviceChanged",
-                                        G_CALLBACK (xfpm_power_device_changed_cb), power);
-        g_object_unref (power->proxy);
-    }
-    
-    if ( power->proxy_prop )
-        g_object_unref (power->proxy_prop);
-
-    g_hash_table_destroy (power->hash);
 
     G_OBJECT_CLASS (xfpm_power_parent_class)->finalize (object);
 }
diff --git a/src/xfpm-power.h b/src/xfpm-power.h
index c138080..820f608 100644
--- a/src/xfpm-power.h
+++ b/src/xfpm-power.h
@@ -38,7 +38,7 @@ typedef struct _XfpmPower      XfpmPower;
 
 GType                   xfpm_power_get_type             (void) G_GNUC_CONST;
 
-XfpmPower               *xfpm_power_get                 (void);
+XfpmPower              *xfpm_power_get                  (void);
 
 void                    xfpm_power_suspend              (XfpmPower *power,
                                                          gboolean   force);


More information about the Xfce4-commits mailing list