panel: Show warning indicator when unsafe-mode is on

MetaContext added an unsafe-mode property, which we will use to restrict
a number of privileged operations unless it is enabled. It is meant to
only be enabled temporarily for development/debugging purposes, so add
a scary icon to the top bar as a reminder to turn it off again.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3943

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1970>
This commit is contained in:
Florian Müllner 2021-09-02 17:15:36 +02:00 committed by Marge Bot
parent fb177a1cae
commit 3bee7c7f4b

View File

@ -507,6 +507,20 @@ class PanelCorner extends St.DrawingArea {
}
});
const UnsafeModeIndicator = GObject.registerClass(
class UnsafeModeIndicator extends PanelMenu.SystemIndicator {
_init() {
super._init();
this._indicator = this._addIndicator();
this._indicator.icon_name = 'channel-insecure-symbolic';
global.context.bind_property('unsafe-mode',
this._indicator, 'visible',
GObject.BindingFlags.SYNC_CREATE);
}
});
var AggregateLayout = GObject.registerClass(
class AggregateLayout extends Clutter.BoxLayout {
_init(params = {}) {
@ -568,6 +582,7 @@ class AggregateMenu extends PanelMenu.Button {
this._location = new imports.ui.status.location.Indicator();
this._nightLight = new imports.ui.status.nightLight.Indicator();
this._thunderbolt = new imports.ui.status.thunderbolt.Indicator();
this._unsafeMode = new UnsafeModeIndicator();
this._indicators.add_child(this._remoteAccess);
this._indicators.add_child(this._thunderbolt);
@ -579,6 +594,7 @@ class AggregateMenu extends PanelMenu.Button {
this._indicators.add_child(this._bluetooth);
this._indicators.add_child(this._rfkill);
this._indicators.add_child(this._volume);
this._indicators.add_child(this._unsafeMode);
this._indicators.add_child(this._power);
this._indicators.add_child(this._powerProfiles);