Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show dual batteries properly in Power Management / Cinnamon Settings #11790

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 10 additions & 36 deletions files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -417,10 +411,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:
Expand All @@ -435,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]
Expand Down
Loading