From 35a251324cc5256c459ff4287855cd510b30a026 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 24 Jul 2014 23:40:28 -0500 Subject: in notify, reverse the numerical order of the now-private PowerLevel enum so that they have the more intuitive behavior of higher integer values meaning a better power level. --- src/notifier.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/notifier.c') diff --git a/src/notifier.c b/src/notifier.c index 7add139..6557246 100644 --- a/src/notifier.c +++ b/src/notifier.c @@ -29,10 +29,10 @@ typedef enum { - POWER_LEVEL_OK, - POWER_LEVEL_LOW, + POWER_LEVEL_CRITICAL, POWER_LEVEL_VERY_LOW, - POWER_LEVEL_CRITICAL + POWER_LEVEL_LOW, + POWER_LEVEL_OK } PowerLevel; @@ -92,10 +92,10 @@ power_level_to_dbus_string (const PowerLevel power_level) { switch (power_level) { - case POWER_LEVEL_LOW: return "low"; - case POWER_LEVEL_VERY_LOW: return "very_low"; - case POWER_LEVEL_CRITICAL: return "critical"; - default: return "ok"; + case POWER_LEVEL_LOW: return POWER_LEVEL_STR_LOW; + case POWER_LEVEL_VERY_LOW: return POWER_LEVEL_STR_VERY_LOW; + case POWER_LEVEL_CRITICAL: return POWER_LEVEL_STR_CRITICAL; + default: return POWER_LEVEL_STR_OK; } } @@ -223,7 +223,7 @@ on_battery_property_changed (IndicatorPowerNotifier * self) /* pop up a 'low battery' notification if 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)) || + if ((new_discharging && (old_power_level > new_power_level)) || ((new_power_level != POWER_LEVEL_OK) && new_discharging && !old_discharging)) { notification_show (self); @@ -317,6 +317,8 @@ indicator_power_notifier_init (IndicatorPowerNotifier * self) p->dbus_battery = dbus_battery_skeleton_new (); + p->power_level = POWER_LEVEL_OK; + if (!instance_count++) { if (!notify_init("indicator-power-service")) -- cgit v1.2.3