From 2233124e53eeff0bb7c55d723ddbe406161f9316 Mon Sep 17 00:00:00 2001 From: Fabian Schillig Date: Tue, 25 Jul 2023 14:31:04 +0200 Subject: [PATCH 1/2] Show battery pending charge/discharge states in Power Management --- .../share/cinnamon/cinnamon-settings/modules/cs_power.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py index cf0d22e8b0..2ebe7c95b1 100755 --- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py +++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py @@ -417,10 +417,14 @@ def set_device_battery_primary(self, device): else: details = UPowerGlib.Device.state_to_string(state) else: - if state == UPowerGlib.DeviceState.CHARGING or state == UPowerGlib.DeviceState.PENDING_CHARGE: + if state == UPowerGlib.DeviceState.CHARGING: details = _("Charging") - elif state == UPowerGlib.DeviceState.DISCHARGING or state == UPowerGlib.DeviceState.PENDING_DISCHARGE: + elif state == UPowerGlib.DeviceState.PENDING_CHARGE: + details = _("Not charging") + elif state == UPowerGlib.DeviceState.DISCHARGING: details = _("Using battery power") + elif state == UPowerGlib.DeviceState.PENDING_DISCHARGE: + details = _("Not discharging") elif state == UPowerGlib.DeviceState.FULLY_CHARGED: details = _("Charging - fully charged") elif state == UPowerGlib.DeviceState.EMPTY: From 535a7e27f67246067d511bd75f43b5ed304015e6 Mon Sep 17 00:00:00 2001 From: Fabian Schillig Date: Tue, 25 Jul 2023 14:50:36 +0200 Subject: [PATCH 2/2] Show all batteries as "primary" batteries, removing set_device_battery_additional() --- .../cinnamon-settings/modules/cs_power.py | 38 ++----------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py index 2ebe7c95b1..1a9ee9105d 100755 --- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py +++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py @@ -320,16 +320,10 @@ def build_battery_page(self, *args): else: primary_settings.add_row(self.set_device_ups_primary(device)) elif device[UP_TYPE] == UPowerGlib.DeviceKind.BATTERY and not ups_as_primary: - if not have_primary: - if not primary_settings: - primary_settings = self.battery_page.add_section(_("Batteries")) - primary_settings.add_row(self.set_device_battery_primary(device)) - self.show_battery_page = True - have_primary = True - else: - widget = self.set_device_battery_additional(device) - if widget: - primary_settings.add_row(widget) + if not primary_settings: + primary_settings = self.battery_page.add_section(_("Batteries")) + primary_settings.add_row(self.set_device_battery_primary(device)) + self.show_battery_page = True else: if not secondary_settings: secondary_settings = self.battery_page.add_section(_("Devices")) @@ -439,30 +433,6 @@ def set_device_battery_primary(self, device): widget = self.create_battery_row(device_id, "battery", desc, percentage, battery_level, details) return widget - def set_device_battery_additional(self, device): - state = device[UP_STATE] - details = None - - if state == UPowerGlib.DeviceState.FULLY_CHARGED: - details = _("Fully charged") - elif state == UPowerGlib.DeviceState.EMPTY: - details = _("Empty") - - if details: - widget = SettingsWidget() - icon = Gtk.Image.new_from_icon_name("battery", Gtk.IconSize.DND) - widget.pack_start(icon, False, False, 0) - label = Gtk.Label(_("Secondary battery")) - widget.pack_start(label, False, False, 0) - label = Gtk.Label() - label.set_markup(details) - label.get_style_context().add_class("dim-label") - widget.pack_end(label, False, False, 0) - - return widget - else: - return None - def add_battery_device_secondary(self, device): device_id = device[UP_ID] kind = device[UP_TYPE]