[haiku-commits] r34022 - haiku/trunk/src/apps/powerstatus

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 13 Nov 2009 16:39:30 +0100 (CET)

Author: axeld
Date: 2009-11-13 16:39:30 +0100 (Fri, 13 Nov 2009)
New Revision: 34022
Changeset: http://dev.haiku-os.org/changeset/34022/haiku

Modified:
   haiku/trunk/src/apps/powerstatus/PowerStatusView.cpp
Log:
* Now it should work correctly, but apparently, the battery info is not updated
  in the way it should be.


Modified: haiku/trunk/src/apps/powerstatus/PowerStatusView.cpp
===================================================================
--- haiku/trunk/src/apps/powerstatus/PowerStatusView.cpp        2009-11-13 
15:04:26 UTC (rev 34021)
+++ haiku/trunk/src/apps/powerstatus/PowerStatusView.cpp        2009-11-13 
15:39:30 UTC (rev 34022)
@@ -359,19 +359,28 @@
                        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);
                                }
-                               length += snprintf(text + length, sizeof(text) 
- length, "%s",
-                                       !fOnline ? "charging" : "discharging");
+
+                               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);
+                               }
                        } else
                                strcpy(text, "no battery");
                        SetToolTip(text);


Other related posts: