* Now it should work correctly, but apparently, the battery info is not updated

in the way it should be.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34022 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-11-13 15:39:30 +00:00
parent c479106612
commit 581e498d5b
+14 -5
View File
@@ -359,19 +359,28 @@ PowerStatusView::Update(bool force)
char text[256];
const char* open = "";
const char* close = "";
if (!fOnline) {
if (fOnline) {
open = "(";
close = ")";
}
if (fHasBattery) {
size_t length = snprintf(text, sizeof(text), "%s%ld%%%s\n",
size_t length = snprintf(text, sizeof(text), "%s%ld%%%s",
open, fPercent, close);
if (fTimeLeft) {
length += snprintf(text + length, sizeof(text) - length,
"%ld:%02ld\n", fTimeLeft / 3600, (fTimeLeft / 60) % 60);
"\n%ld:%02ld", fTimeLeft / 3600, (fTimeLeft / 60) % 60);
}
const char* state = NULL;
if ((fBatteryInfo.state & BATTERY_CHARGING) != 0)
state = "charging";
else if ((fBatteryInfo.state & BATTERY_DISCHARGING) != 0)
state = "discharging";
if (state != NULL) {
snprintf(text + length, sizeof(text) - length, "\n%s",
state);
}
length += snprintf(text + length, sizeof(text) - length, "%s",
!fOnline ? "charging" : "discharging");
} else
strcpy(text, "no battery");
SetToolTip(text);