aboutsummaryrefslogtreecommitdiff
path: root/src/notifier.c
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-07-22 12:19:20 -0500
committerCharles Kerr <charles.kerr@canonical.com>2014-07-22 12:19:20 -0500
commit1f98321fa6139105a1b427a2dac2b4e2b0642dd6 (patch)
tree660b472ccbd9833627660c575aaeedf52426c63b /src/notifier.c
parentdd322344959c31ebbda939bf74547ed85e3233f9 (diff)
downloadayatana-indicator-power-1f98321fa6139105a1b427a2dac2b4e2b0642dd6.tar.gz
ayatana-indicator-power-1f98321fa6139105a1b427a2dac2b4e2b0642dd6.tar.bz2
ayatana-indicator-power-1f98321fa6139105a1b427a2dac2b4e2b0642dd6.zip
make the notification popup decision logic simpler & easier to read
Diffstat (limited to 'src/notifier.c')
-rw-r--r--src/notifier.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/notifier.c b/src/notifier.c
index 326f5a1..81662ca 100644
--- a/src/notifier.c
+++ b/src/notifier.c
@@ -167,9 +167,11 @@ on_battery_property_changed (IndicatorPowerNotifier * self)
old_discharging = p->discharging;
new_discharging = indicator_power_device_get_state(p->battery) == UP_DEVICE_STATE_DISCHARGING;
- if (new_discharging &&
- (new_power_level != POWER_LEVEL_OK) &&
- ((new_power_level != old_power_level) || (new_discharging != old_discharging)))
+ /* pop up a notification for a battery whenever either:
+ a) it's already discharging, and its PowerLevel worsens, OR
+ b) it's already got a bad PowerLevel and its state becomes 'discharging */
+ if ((new_discharging && (new_power_level > old_power_level)) ||
+ ((new_power_level != POWER_LEVEL_OK) && new_discharging && !old_discharging))
{
notification_show (self);
}