[gnome-settings-daemon] power: Fix energy for the composite battery



commit 5506f182d200cecc6576b9646731e2df9d4ecafd
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Jun 17 18:08:15 2013 +0200

    power: Fix energy for the composite battery
    
    We were using the energy, energy_rate and energy_full from
    the last read battery when creating the composite device, instead
    of the aggregated value.

 plugins/power/gsd-power-manager.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 8122845..cf2f728 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -748,9 +748,6 @@ engine_update_composite_device (GsdPowerManager *manager,
 {
         guint i;
         gdouble percentage = 0.0;
-        gdouble energy = 0.0;
-        gdouble energy_full = 0.0;
-        gdouble energy_rate = 0.0;
         gdouble energy_total = 0.0;
         gdouble energy_full_total = 0.0;
         gdouble energy_rate_total = 0.0;
@@ -763,7 +760,6 @@ engine_update_composite_device (GsdPowerManager *manager,
         GPtrArray *array;
         UpDevice *device;
         UpDeviceState state;
-        UpDeviceKind kind;
         UpDeviceKind original_kind;
 
         /* get the type of the original device */
@@ -774,6 +770,11 @@ engine_update_composite_device (GsdPowerManager *manager,
         /* update the composite device */
         array = manager->priv->devices_array;
         for (i=0;i<array->len;i++) {
+                UpDeviceKind kind;
+                gdouble energy = 0.0;
+                gdouble energy_full = 0.0;
+                gdouble energy_rate = 0.0;
+
                 device = g_ptr_array_index (array, i);
                 g_object_get (device,
                               "kind", &kind,
@@ -834,9 +835,9 @@ engine_update_composite_device (GsdPowerManager *manager,
 
         g_debug ("printing composite device");
         g_object_set (device,
-                      "energy", energy,
-                      "energy-full", energy_full,
-                      "energy-rate", energy_rate,
+                      "energy", energy_total,
+                      "energy-full", energy_full_total,
+                      "energy-rate", energy_rate_total,
                       "time-to-empty", time_to_empty,
                       "time-to-full", time_to_full,
                       "percentage", percentage,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]