summaryrefslogtreecommitdiff
path: root/src/dkp-device-supply.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2009-07-20 15:56:11 +0100
committerRichard Hughes <richard@hughsie.com>2009-07-20 15:56:35 +0100
commite44e8b0b790f5b29b91e74788c03095b71fe725b (patch)
tree81ebeb43823032ce498f211a21d0cf8e5e194d07 /src/dkp-device-supply.c
parenta9ccd95de3498983321beeaac467647b0fc936b6 (diff)
Use the global battery state as a metric when single battery machines are not charging or discharging
Diffstat (limited to 'src/dkp-device-supply.c')
-rw-r--r--src/dkp-device-supply.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/dkp-device-supply.c b/src/dkp-device-supply.c
index 48671aa..fb091a3 100644
--- a/src/dkp-device-supply.c
+++ b/src/dkp-device-supply.c
@@ -41,7 +41,7 @@
#define DKP_DEVICE_SUPPLY_REFRESH_TIMEOUT 30 /* seconds */
#define DKP_DEVICE_SUPPLY_UNKNOWN_TIMEOUT 2 /* seconds */
#define DKP_DEVICE_SUPPLY_UNKNOWN_RETRIES 30
-#define DKP_DEVICE_SUPPLY_CHARGED_THRESHOLD 95.0f /* % */
+#define DKP_DEVICE_SUPPLY_CHARGED_THRESHOLD 90.0f /* % */
struct DkpDeviceSupplyPrivate
{
@@ -335,7 +335,7 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply)
const gchar *recall_url = NULL;
DkpDaemon *daemon;
gboolean on_battery;
- guint count;
+ guint battery_count;
d = dkp_device_get_d (device);
if (d == NULL) {
@@ -533,25 +533,27 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply)
/* get global battery status */
daemon = dkp_device_get_daemon (device);
+ g_object_get (daemon,
+ "on-battery", &on_battery,
+ NULL);
+
+ /* only guess when we have more than one battery devices */
+ battery_count = dkp_daemon_get_number_devices_of_type (daemon, DKP_DEVICE_TYPE_BATTERY);
+
+ /* try to find a suitable icon depending on AC state */
+ if (on_battery && battery_count > 1)
+ state = DKP_DEVICE_STATE_PENDING_DISCHARGE;
+ else if (battery_count > 1)
+ state = DKP_DEVICE_STATE_PENDING_CHARGE;
+ else if (on_battery)
+ state = DKP_DEVICE_STATE_DISCHARGING;
+ else
+ state = DKP_DEVICE_STATE_FULLY_CHARGED;
+
+ /* print what we did */
+ egg_debug ("guessing battery state '%s' using global on-battery:%i",
+ dkp_device_state_to_text (state), on_battery);
- /* only guess wen we have more than one battery devices */
- count = dkp_daemon_get_number_devices_of_type (daemon, DKP_DEVICE_TYPE_BATTERY);
- if (count > 1) {
- g_object_get (daemon,
- "on-battery", &on_battery,
- NULL);
-
- /* try to find a suitable icon depending on AC state */
- if (on_battery) {
- state = DKP_DEVICE_STATE_PENDING_DISCHARGE;
- } else {
- state = DKP_DEVICE_STATE_PENDING_CHARGE;
- }
-
- /* print what we did */
- egg_debug ("guessing battery state '%s' using global on-battery:%i",
- dkp_device_state_to_text (state), on_battery);
- }
g_object_unref (daemon);
}