diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2014-07-22 12:19:20 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2014-07-22 12:19:20 -0500 |
commit | 1f98321fa6139105a1b427a2dac2b4e2b0642dd6 (patch) | |
tree | 660b472ccbd9833627660c575aaeedf52426c63b /src | |
parent | dd322344959c31ebbda939bf74547ed85e3233f9 (diff) | |
download | ayatana-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')
-rw-r--r-- | src/notifier.c | 8 |
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); } |