volume: Show indicator when microphone is active

Devices like cameras and microphones are privacy sensitive, as they can
be used to spy on the user. We cannot prevent non-sandboxed apps from
doing that, but as we already track when the microphone is recording,
we can at least show an indicator to make sure it doesn't happen behind
the user's back.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/729
This commit is contained in:
Florian Müllner 2019-09-14 14:41:08 +02:00 committed by Florian Müllner
parent d7c569c692
commit 6cad251187

View File

@ -299,6 +299,9 @@ var VolumeMenu = class extends PopupMenu.PopupMenuSection {
this.addMenuItem(this._output.item); this.addMenuItem(this._output.item);
this._input = new InputStreamSlider(this._control); this._input = new InputStreamSlider(this._control);
this._input.item.connect('notify::visible', () => {
this.emit('input-visible-changed');
});
this.addMenuItem(this._input.item); this.addMenuItem(this._input.item);
this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
@ -338,6 +341,10 @@ var VolumeMenu = class extends PopupMenu.PopupMenuSection {
getMaxLevel() { getMaxLevel() {
return this._output.getMaxLevel(); return this._output.getMaxLevel();
} }
getInputVisible() {
return this._input.item.visible;
}
}; };
var Indicator = class extends PanelMenu.SystemIndicator { var Indicator = class extends PanelMenu.SystemIndicator {
@ -345,18 +352,24 @@ var Indicator = class extends PanelMenu.SystemIndicator {
super(); super();
this._primaryIndicator = this._addIndicator(); this._primaryIndicator = this._addIndicator();
this._inputIndicator = this._addIndicator();
this._control = getMixerControl(); this._control = getMixerControl();
this._volumeMenu = new VolumeMenu(this._control); this._volumeMenu = new VolumeMenu(this._control);
this._volumeMenu.connect('icon-changed', () => { this._volumeMenu.connect('icon-changed', () => {
let icon = this._volumeMenu.getIcon(); let icon = this._volumeMenu.getIcon();
if (icon != null) { if (icon != null)
this.indicators.show();
this._primaryIndicator.icon_name = icon; this._primaryIndicator.icon_name = icon;
} else { this._primaryIndicator.visible = icon !== null;
this.indicators.hide(); });
}
this._inputIndicator.set({
icon_name: 'audio-input-microphone-symbolic',
visible: this._volumeMenu.getInputVisible(),
});
this._volumeMenu.connect('input-visible-changed', () => {
this._inputIndicator.visible = this._volumeMenu.getInputVisible();
}); });
this.menu.addMenuItem(this._volumeMenu); this.menu.addMenuItem(this._volumeMenu);