From a3d4b4b4d3c59d7c13a28bfebd2a1799b1e69d49 Mon Sep 17 00:00:00 2001 From: Simon Steinbeiss Date: Fri, 12 Apr 2019 00:30:27 +0200 Subject: [PATCH] Show discharge level even in unknown state (Bug #15280) Also strip leading/trailing whitespace from vendor and model. --- common/xfpm-power-common.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common/xfpm-power-common.c b/common/xfpm-power-common.c index 95e64bd..fd525dd 100644 --- a/common/xfpm-power-common.c +++ b/common/xfpm-power-common.c @@ -260,8 +260,12 @@ get_device_description (UpClient *upower, UpDevice *device) if (vendor == NULL) vendor = g_strdup (""); + else + vendor = g_strstrip (vendor); if (model == NULL) model = g_strdup (""); + else + model = g_strstrip (model); /* If we get a vendor or model we can use it, otherwise translate the * device type into something readable (works for things like ac_power) @@ -354,6 +358,12 @@ get_device_description (UpClient *upower, UpDevice *device) tip = g_strdup_printf (_("%s %s\nis empty"), vendor, model); } + else if ( state == UP_DEVICE_STATE_UNKNOWN && percentage != 0.0 ) + { + tip = g_strdup_printf (_("%s %s\nCurrent charge: %0.0f%%"), + vendor, model, + percentage); + } else { if (type == UP_DEVICE_KIND_LINE_POWER) -- 2.19.1