Battery format fixes

This commit is contained in:
o9000 2017-06-20 18:58:13 +02:00
parent b5578ff5bc
commit ea0e52c5a2

View file

@ -170,7 +170,9 @@ void battery_update_text(char *dest, char *format)
? "Charging" ? "Charging"
: (battery_state.state == BATTERY_DISCHARGING) : (battery_state.state == BATTERY_DISCHARGING)
? "Discharging" ? "Discharging"
: (battery_state.state == BATTERY_FULL) ? "Full" : "Unknown", : (battery_state.state == BATTERY_FULL || battery_state.percentage >= 100)
? "Full"
: "Unknown",
BATTERY_BUF_SIZE); BATTERY_BUF_SIZE);
break; break;
case 'm': case 'm':
@ -186,7 +188,8 @@ void battery_update_text(char *dest, char *format)
strnappend(dest, buf, BATTERY_BUF_SIZE); strnappend(dest, buf, BATTERY_BUF_SIZE);
break; break;
case 't': case 't':
if (battery_state.state == BATTERY_FULL) { if (battery_state.state == BATTERY_FULL ||
(battery_state.state == BATTERY_UNKNOWN && battery_state.percentage >= 100)) {
snprintf(buf, sizeof(buf), "Full"); snprintf(buf, sizeof(buf), "Full");
strnappend(dest, buf, BATTERY_BUF_SIZE); strnappend(dest, buf, BATTERY_BUF_SIZE);
} else { } else {
@ -386,11 +389,7 @@ int update_battery()
int battery_compute_desired_size(void *obj) int battery_compute_desired_size(void *obj)
{ {
Battery *battery = (Battery *)obj; Battery *battery = (Battery *)obj;
return text_area_compute_desired_size(&battery->area, return text_area_compute_desired_size(&battery->area, buf_bat_line1, buf_bat_line2, bat1_font_desc, bat2_font_desc);
buf_bat_line1,
buf_bat_line2,
bat1_font_desc,
bat2_font_desc);
} }
gboolean resize_battery(void *obj) gboolean resize_battery(void *obj)