From 1dbe1c87c5703014f46222c8fe555f81015b85a0 Mon Sep 17 00:00:00 2001 From: Byron Clark Date: Wed, 25 Nov 2009 13:05:58 -0700 Subject: [PATCH] Use a gdouble for percentage. The percentage field of the device object is a gdouble. Low battery calculations should read this field as a gdouble instead of a guint to get the correct value. This fixes the case where clients see on-low-battery possibly changing with every percentage of battery discharge. Signed-off-by: Byron Clark --- src/linux/dkp-device-supply.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/linux/dkp-device-supply.c b/src/linux/dkp-device-supply.c index 03ada40..e6880e4 100644 --- a/src/linux/dkp-device-supply.c +++ b/src/linux/dkp-device-supply.c @@ -161,7 +161,7 @@ dkp_device_supply_get_low_battery (DkpDevice *device, gboolean *low_battery) gboolean ret; gboolean on_battery; DkpDeviceSupply *supply = DKP_DEVICE_SUPPLY (device); - guint percentage; + gdouble percentage; g_return_val_if_fail (DKP_IS_SUPPLY (supply), FALSE); g_return_val_if_fail (low_battery != NULL, FALSE); @@ -178,7 +178,7 @@ dkp_device_supply_get_low_battery (DkpDevice *device, gboolean *low_battery) } g_object_get (device, "percentage", &percentage, NULL); - *low_battery = (percentage < 10); + *low_battery = (percentage < 10.0f); return TRUE; }