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 <byron@theclarkfamily.name>
This commit is contained in:
Byron Clark 2009-11-25 13:05:58 -07:00 committed by Richard Hughes
parent a0cac7f1ca
commit 1dbe1c87c5

View file

@ -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;
}