[gnome-settings-daemon] power: generalize laptop battery notifications
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] power: generalize laptop battery notifications
- Date: Thu, 19 Aug 2021 08:48:01 +0000 (UTC)
commit 0522bc46be433407d40d97e4fd44618ae4e82755
Author: Pablo Correa Gómez <ablocorrea hotmail com>
Date: Sat Jul 10 23:54:22 2021 +0200
power: generalize laptop battery notifications
With newer device types (such as phones and tablets) being used
in GNOME, assuming that a device with more than two power sources,
e.g: battery and current, is a laptop might not be accurate.
Fix that by using a more general and already tranlated string
in all cases.
plugins/power/gsd-power-manager.c | 28 +++++++---------------------
plugins/power/test.py | 4 ++--
2 files changed, 9 insertions(+), 23 deletions(-)
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 41823b2c..8f12c4ca 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -166,7 +166,7 @@ struct _GsdPowerManager
NotifyNotification *notification_sleep_warning;
GsdPowerActionType sleep_action_type;
GHashTable *devices_notified_ht; /* key = serial str, value = UpDeviceLevel */
- gboolean battery_is_low; /* laptop battery low, or UPS discharging */
+ gboolean battery_is_low; /* battery low, or UPS discharging */
/* Brightness */
GsdBacklight *backlight;
@@ -520,15 +520,8 @@ engine_charge_low (GsdPowerManager *manager, UpDevice *device)
if (kind == UP_DEVICE_KIND_BATTERY) {
- /* if the user has no other batteries, drop the "Laptop" wording */
- ret = (manager->devices_array->len > 0);
- if (ret) {
- /* TRANSLATORS: laptop battery low, and we only have one battery */
- title = _("Battery low");
- } else {
- /* TRANSLATORS: laptop battery low, and we have more than one kind of battery */
- title = _("Laptop battery low");
- }
+ /* TRANSLATORS: device battery low */
+ title = _("Battery low");
tmp = gpm_get_timestring (time_to_empty);
remaining_text = g_strconcat ("<b>", tmp, "</b>", NULL);
g_free (tmp);
@@ -670,15 +663,8 @@ engine_charge_critical (GsdPowerManager *manager, UpDevice *device)
if (kind == UP_DEVICE_KIND_BATTERY) {
- /* if the user has no other batteries, drop the "Laptop" wording */
- ret = (manager->devices_array->len > 0);
- if (ret) {
- /* TRANSLATORS: laptop battery critically low, and only have one kind of battery */
- title = _("Battery critically low");
- } else {
- /* TRANSLATORS: laptop battery critically low, and we have more than one type of
battery */
- title = _("Laptop battery critically low");
- }
+ /* TRANSLATORS: Device battery critically low */
+ title = _("Battery critically low");
/* we have to do different warnings depending on the policy */
policy = manager_critical_action_get (manager);
@@ -857,8 +843,8 @@ engine_charge_action (GsdPowerManager *manager, UpDevice *device)
if (kind == UP_DEVICE_KIND_BATTERY) {
- /* TRANSLATORS: laptop battery is really, really, low */
- title = _("Laptop battery critically low");
+ /* TRANSLATORS: device battery is really, really, low */
+ title = _("Battery critically low");
/* we have to do different warnings depending on the policy */
policy = manager_critical_action_get (manager);
diff --git a/plugins/power/test.py b/plugins/power/test.py
index 530ab698..93f8bab2 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -744,7 +744,7 @@ class PowerPluginTest6(PowerPluginBase):
# Check that it was picked up
self.check_plugin_log('EMIT: charge-critical', 2)
- self.p_notify_log.check_line_re(b'[0-9.]+ Notify "Power" .* "battery-caution-symbolic" ".*battery
critical.*"', timeout=0.5)
+ self.p_notify_log.check_line_re(b'[0-9.]+ Notify "Power" .* "battery-caution-symbolic" ".*[Bb]attery
critical.*"', timeout=0.5)
def test_notify_critical_battery_on_start(self):
'''action on critical battery on startup'''
@@ -754,7 +754,7 @@ class PowerPluginTest6(PowerPluginBase):
# Check that it was picked up
self.check_plugin_log('EMIT: charge-critical', 2)
- self.p_notify_log.check_line_re(b'[0-9.]+ Notify "Power" .* "battery-caution-symbolic" ".*battery
critical.*"', timeout=0.5)
+ self.p_notify_log.check_line_re(b'[0-9.]+ Notify "Power" .* "battery-caution-symbolic" ".*[Bb]attery
critical.*"', timeout=0.5)
def test_notify_device_battery(self):
'''critical power level notification for device batteries'''
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]