Change the battery icon to one in the adwaita icon theme

The previous one must've been from some leftover theme I had sitting around.
This commit is contained in:
Peter Hutterer 2019-07-15 15:43:49 +10:00
parent 5f5c49b6d0
commit de23da9a84
2 changed files with 11 additions and 5 deletions

View File

@ -72,7 +72,7 @@
<property name="can_focus">False</property>
<property name="margin_left">10</property>
<property name="margin_right">10</property>
<property name="icon_name">battery-empty-symbolic</property>
<property name="icon_name">battery-missing-symbolic</property>
</object>
<packing>
<property name="expand">False</property>

View File

@ -84,14 +84,20 @@ class DrawingPerspective(Gtk.Stack):
self.device.connect('notify::drawings-available',
self._update_drawings)
# icon name is something like battery-020-charging, or battery-040
# in 20-step increments
if device.battery_percent > 80:
percent = 'full'
elif device.battery_percent > 40:
percent = 'good'
elif device.battery_percent > 10:
percent = 'low'
else:
percent = 'caution'
if device.battery_state == 1:
state = '-charging'
else:
state = ''
percent = f'{int(device.battery_percent/20) * 20:03d}'
batt_icon_name = f'battery-{percent}{state}'
batt_icon_name = f'battery-{percent}{state}-symbolic'
_, isize = self.image_battery.get_icon_name()
self.image_battery.set_from_icon_name(batt_icon_name, isize)
self._update_drawings(self.device, None)