power: Make sure we fall back to the correct icon

Commit bd18313d12 changed to a new naming scheme for battery icons,
and used to old icon names as fallback-icon-name for compatibility
with older/other icon themes.

However that fallback code isn't working correctly, as GThemedIcon's
default fallbacks will transform a name of `battery-level-90-symbolic`
to a list of names:
 - `battery-level-90-symbolic`
 - `battery-level-symbolic`
 - `battery-symbolic`

The last one frequently exists, so instead of the intended fallback,
we end up with a generic battery icon.

Address this by specifying the icon as GIcon instead of an icon-name,
where we have more control over how the icon is resolved.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1442
This commit is contained in:
Florian Müllner 2019-07-16 00:37:13 +02:00 committed by Georges Basile Stavracas Neto
parent 208c5e9562
commit bd5162105e

View File

@ -114,8 +114,15 @@ var Indicator = class extends PanelMenu.SystemIndicator {
? 'battery-level-100-charged-symbolic'
: `battery-level-${fillLevel}${chargingState}-symbolic`;
this._indicator.icon_name = icon;
this._item.icon.icon_name = icon;
// Make sure we fall back to fallback-icon-name and not GThemedIcon's
// default fallbacks
let gicon = new Gio.ThemedIcon({
name: icon,
use_default_fallbacks: false
});
this._indicator.gicon = gicon;
this._item.icon.gicon = gicon;
let fallbackIcon = this._proxy.IconName;
this._indicator.fallback_icon_name = fallbackIcon;