From f94ffac7f36831dd8a79f30d5b94de9758fcd3a6 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Thu, 1 Apr 2021 12:50:12 +0200 Subject: Fix percentage for mice and keyboards --- src/device.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/device.c b/src/device.c index 05eb15e..91d7cf1 100644 --- a/src/device.c +++ b/src/device.c @@ -773,6 +773,15 @@ get_menuitem_text (const IndicatorPowerDevice * device, time_str = get_expanded_time_remaining (device); } + if (p->percentage > 0.01 && time_str != NULL) + { + if (g_str_equal(time_str, _("estimating…")) || g_str_equal(time_str, _("unknown"))) + { + g_free(time_str); + time_str = NULL; + } + } + if (time_str && *time_str) { /* TRANSLATORS: example: "battery (time remaining)" */ @@ -780,7 +789,14 @@ get_menuitem_text (const IndicatorPowerDevice * device, } else { - str = g_strdup (kind_str); + if (p->percentage > 0.01) + { + str = g_strdup_printf("%s (%.0lf%%)", kind_str, p->percentage); + } + else + { + str = g_strdup (kind_str); + } } g_free (time_str); -- cgit v1.2.3 From 062e93c1468a2928e1afa45e25e8e500f97aa588 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Thu, 1 Apr 2021 12:51:40 +0200 Subject: Add us to the copyright headers --- src/device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/device.c b/src/device.c index 91d7cf1..f03d514 100644 --- a/src/device.c +++ b/src/device.c @@ -3,9 +3,11 @@ A simple Device structure used internally by indicator-power Copyright 2012 Canonical Ltd. +Copyright 2021 AyatanaIndicators Authors: Charles Kerr + Robert Tari This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License -- cgit v1.2.3