From 581e498d5bba0ee60a99d53d84f19358ba644370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 13 Nov 2009 15:39:30 +0000 Subject: [PATCH] * 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 --- src/apps/powerstatus/PowerStatusView.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/apps/powerstatus/PowerStatusView.cpp b/src/apps/powerstatus/PowerStatusView.cpp index ed67e34eb4..b8e69d5929 100644 --- a/src/apps/powerstatus/PowerStatusView.cpp +++ b/src/apps/powerstatus/PowerStatusView.cpp @@ -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);