status/volume: Use (dis)connectObject

It makes sense to use this for all MixerControl handlers, not just
some of them.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2380>
This commit is contained in:
Florian Müllner 2022-07-15 14:30:49 +02:00
parent af5bc30dff
commit cf404f76c0

View File

@ -81,8 +81,7 @@ var StreamSlider = class extends Signals.EventEmitter {
} }
set stream(stream) { set stream(stream) {
if (this._stream) this._stream?.disconnectObject(this);
this._disconnectStream(this._stream);
this._stream = stream; this._stream = stream;
@ -96,10 +95,6 @@ var StreamSlider = class extends Signals.EventEmitter {
this._updateVisibility(); this._updateVisibility();
} }
_disconnectStream(stream) {
stream.disconnectObject(this);
}
_connectStream(stream) { _connectStream(stream) {
stream.connectObject( stream.connectObject(
'notify::is-muted', this._updateVolume.bind(this), 'notify::is-muted', this._updateVolume.bind(this),
@ -269,8 +264,12 @@ var InputStreamSlider = class extends StreamSlider {
constructor(control) { constructor(control) {
super(control); super(control);
this._slider.accessible_name = _("Microphone"); this._slider.accessible_name = _("Microphone");
this._control.connect('stream-added', this._maybeShowInput.bind(this));
this._control.connect('stream-removed', this._maybeShowInput.bind(this)); this._control.connectObject(
'stream-added', () => this._maybeShowInput(),
'stream-removed', () => this._maybeShowInput(),
this);
this._icon.icon_name = 'audio-input-microphone-symbolic'; this._icon.icon_name = 'audio-input-microphone-symbolic';
this._icons = [ this._icons = [
'microphone-sensitivity-muted-symbolic', 'microphone-sensitivity-muted-symbolic',
@ -316,9 +315,11 @@ var VolumeMenu = class extends PopupMenu.PopupMenuSection {
this.hasHeadphones = false; this.hasHeadphones = false;
this._control = control; this._control = control;
this._control.connect('state-changed', this._onControlStateChanged.bind(this)); this._control.connectObject(
this._control.connect('default-sink-changed', this._readOutput.bind(this)); 'state-changed', () => this._onControlStateChanged(),
this._control.connect('default-source-changed', this._readInput.bind(this)); 'default-sink-changed', () => this._readOutput(),
'default-source-changed', () => this._readInput(),
this);
this._output = new OutputStreamSlider(this._control); this._output = new OutputStreamSlider(this._control);
this._output.connect('stream-updated', this._output.connect('stream-updated',