[gnome-shell] volume: Show indicator when microphone is active



commit 6cad2511876e716ab26d94dccfa5c3de173c68ae
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Sep 14 14:41:08 2019 +0200

    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

 js/ui/status/volume.js | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js
index db8e5a1f1d..3d23044dac 100644
--- a/js/ui/status/volume.js
+++ b/js/ui/status/volume.js
@@ -299,6 +299,9 @@ var VolumeMenu = class extends PopupMenu.PopupMenuSection {
         this.addMenuItem(this._output.item);
 
         this._input = new InputStreamSlider(this._control);
+        this._input.item.connect('notify::visible', () => {
+            this.emit('input-visible-changed');
+        });
         this.addMenuItem(this._input.item);
 
         this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
@@ -338,6 +341,10 @@ var VolumeMenu = class extends PopupMenu.PopupMenuSection {
     getMaxLevel() {
         return this._output.getMaxLevel();
     }
+
+    getInputVisible() {
+        return this._input.item.visible;
+    }
 };
 
 var Indicator = class extends PanelMenu.SystemIndicator {
@@ -345,18 +352,24 @@ var Indicator = class extends PanelMenu.SystemIndicator {
         super();
 
         this._primaryIndicator = this._addIndicator();
+        this._inputIndicator = this._addIndicator();
 
         this._control = getMixerControl();
         this._volumeMenu = new VolumeMenu(this._control);
         this._volumeMenu.connect('icon-changed', () => {
             let icon = this._volumeMenu.getIcon();
 
-            if (icon != null) {
-                this.indicators.show();
+            if (icon != null)
                 this._primaryIndicator.icon_name = icon;
-            } else {
-                this.indicators.hide();
-            }
+            this._primaryIndicator.visible = icon !== null;
+        });
+
+        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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]