diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-05-03 23:00:56 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-05-03 23:00:56 +0200 |
commit | 94edbd376fc72406d592991916aa1e3e1ea70747 (patch) | |
tree | dc07064f3d9bb8464dce9cfb21dd5380119e6cea /src/device.c | |
parent | 773cf3e9005941241a8f4ee3caefd30650970967 (diff) | |
parent | 062e93c1468a2928e1afa45e25e8e500f97aa588 (diff) | |
download | ayatana-indicator-power-94edbd376fc72406d592991916aa1e3e1ea70747.tar.gz ayatana-indicator-power-94edbd376fc72406d592991916aa1e3e1ea70747.tar.bz2 ayatana-indicator-power-94edbd376fc72406d592991916aa1e3e1ea70747.zip |
Merge branch 'tari01-pr/peripherial-percentage'
Attributes GH PR #25: https://github.com/AyatanaIndicators/ayatana-indicator-power/pull/25
Diffstat (limited to 'src/device.c')
-rw-r--r-- | src/device.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/device.c b/src/device.c index 05eb15e..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 <charles.kerr@canonical.com> + Robert Tari <robert@tari.in> This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -773,6 +775,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 +791,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); |