From 03914ea4099c9da04c7bfb8258c213ff8c95a2ac Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Tue, 29 Mar 2022 13:23:42 -0400 Subject: [PATCH 1/2] Make auto-resume of paused media optional Add a new Telephony preference, 'after-unpause', default true. (New UI in the preferences allows it to be switched on/off.) When it's set to false, exiting the ringing and talking states will still restore volume levels (if configured), but will leave the media player(s) paused so the user can resume manually. --- ...ome.Shell.Extensions.GSConnect.gschema.xml | 4 +- data/ui/preferences-device-panel.ui | 96 +++++++++++++++++++ src/preferences/device.js | 6 ++ src/service/components/mpris.js | 13 ++- src/service/plugins/telephony.js | 24 ++++- 5 files changed, 136 insertions(+), 7 deletions(-) diff --git a/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml b/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml index 05c8126ba..ffdb925f1 100644 --- a/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml +++ b/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml @@ -192,6 +192,8 @@ SPDX-License-Identifier: GPL-2.0-or-later true + + true + - diff --git a/data/ui/preferences-device-panel.ui b/data/ui/preferences-device-panel.ui index 8007a4bce..4bdabff5b 100644 --- a/data/ui/preferences-device-panel.ui +++ b/data/ui/preferences-device-panel.ui @@ -1572,6 +1572,7 @@ SPDX-License-Identifier: GPL-2.0-or-later True False 0 + 32 True @@ -1764,12 +1765,107 @@ SPDX-License-Identifier: GPL-2.0-or-later + + False + True + 4 + + + + + True + False + start + 12 + After Calls + + + + False True 5 + + + True + False + 0 + + + True + False + True + none + + + + + True + True + 56 + False + + + True + False + 12 + 12 + 12 + + + True + False + start + center + True + True + Resume Paused Media + + + + + + + 0 + 0 + + + + + True + True + center + settings.after-unpause + + + + + + + 1 + 0 + + + + + + + + + + + + + + + False + True + 7 + + diff --git a/src/preferences/device.js b/src/preferences/device.js index 002eb5833..cb6bca09e 100644 --- a/src/preferences/device.js +++ b/src/preferences/device.js @@ -286,6 +286,7 @@ var Panel = GObject.registerClass({ // Telephony 'telephony', 'telephony-page', 'ringing-list', 'ringing-volume', 'talking-list', 'talking-volume', + 'after-list', // Shortcuts 'shortcuts-page', @@ -484,6 +485,7 @@ var Panel = GObject.registerClass({ this.actions.add_action(settings.create_action('talking-volume')); this.actions.add_action(settings.create_action('talking-pause')); this.actions.add_action(settings.create_action('talking-microphone')); + this.actions.add_action(settings.create_action('after-unpause')); // Pair Actions const encryption_info = new Gio.SimpleAction({name: 'encryption-info'}); @@ -903,8 +905,12 @@ var Panel = GObject.registerClass({ this.ringing_list.next = this.talking_list; this.talking_list.prev = this.ringing_list; + this.talking_list.next = this.after_list; + this.after_list.prev = this.talking_list; + this.ringing_list.set_header_func(rowSeparators); this.talking_list.set_header_func(rowSeparators); + this.after_list.set_header_func(rowSeparators); } /** diff --git a/src/service/components/mpris.js b/src/service/components/mpris.js index 52f35d7f6..a764d56f9 100644 --- a/src/service/components/mpris.js +++ b/src/service/components/mpris.js @@ -996,6 +996,7 @@ var Manager = GObject.registerClass({ if (player.PlaybackStatus === 'Playing' && player.CanPause) { player.Pause(); this._paused.set(name, player); + debug(`Paused ${name}`); } } } @@ -1004,14 +1005,22 @@ var Manager = GObject.registerClass({ * A convenience function for restarting all players paused with pauseAll(). */ unpauseAll() { - for (const player of this._paused.values()) { - if (player.PlaybackStatus === 'Paused' && player.CanPlay) + for (const [name, player] of this._paused) { + if (player.PlaybackStatus === 'Paused' && player.CanPlay) { player.Play(); + debug(`Unpaused ${name}`); + } else { + debug(`Cannot unpause ${name}, skipping`); + } } this._paused.clear(); } + clearPaused() { + this._paused.clear(); + } + destroy() { if (this._cancellable.is_cancelled()) return; diff --git a/src/service/plugins/telephony.js b/src/service/plugins/telephony.js index 9fe683af1..c2433094f 100644 --- a/src/service/plugins/telephony.js +++ b/src/service/plugins/telephony.js @@ -96,16 +96,32 @@ var Plugin = GObject.registerClass({ } /** - * Restore volume, microphone and media player state (if changed), making - * sure to unpause before raising volume. + * Restore volume and microphone, plus media player state + * (if we changed it and restore is enabled). + * + * If we're going to auto-unpause, make sure to do that first + * before raising volume. + * Otherwise, still raise the volume (so the user can unpause). * * TODO: there's a possibility we might revert a media/mixer state set for * another device. */ _restoreMediaState() { // Media Playback - if (this._mpris) - this._mpris.unpauseAll(); + if (this._mpris) { + if (this.settings.get_boolean('after-unpause')) { + this._mpris.unpauseAll(); + } else { + /* Even if unpause is disabled, we still need to clear + * the list of which players we're holding paused + * + * TODO: This potentially worsens the multi-device + * problem, since we may be erasing the player + * list when another device still needs it. + */ + this._mpris.clearPaused(); + } + } // Mixer Volume if (this._mixer) From 86e4f50cd31a16825721ab8236a6bf17a595998f Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Thu, 7 Apr 2022 20:25:31 -0400 Subject: [PATCH 2/2] Rename unpause pref to 'ended-resume' --- ...ome.Shell.Extensions.GSConnect.gschema.xml | 2 +- data/ui/preferences-device-panel.ui | 22 +++++++++---------- src/preferences/device.js | 10 ++++----- src/service/plugins/telephony.js | 6 ++--- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml b/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml index ffdb925f1..f1a47caea 100644 --- a/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml +++ b/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml @@ -192,7 +192,7 @@ SPDX-License-Identifier: GPL-2.0-or-later true - + true diff --git a/data/ui/preferences-device-panel.ui b/data/ui/preferences-device-panel.ui index 4bdabff5b..8e4563443 100644 --- a/data/ui/preferences-device-panel.ui +++ b/data/ui/preferences-device-panel.ui @@ -1772,12 +1772,12 @@ SPDX-License-Identifier: GPL-2.0-or-later - + True False start 12 - After Calls + Call Ended @@ -1794,7 +1794,7 @@ SPDX-License-Identifier: GPL-2.0-or-later False 0 - + True False True @@ -1802,7 +1802,7 @@ SPDX-License-Identifier: GPL-2.0-or-later - + True True 56 @@ -1815,7 +1815,7 @@ SPDX-License-Identifier: GPL-2.0-or-later 12 12 - + True False start @@ -1824,8 +1824,8 @@ SPDX-License-Identifier: GPL-2.0-or-later True Resume Paused Media - - + + @@ -1834,14 +1834,14 @@ SPDX-License-Identifier: GPL-2.0-or-later - + True True center - settings.after-unpause + settings.ended-resume - - + + diff --git a/src/preferences/device.js b/src/preferences/device.js index cb6bca09e..aa65fe28a 100644 --- a/src/preferences/device.js +++ b/src/preferences/device.js @@ -286,7 +286,7 @@ var Panel = GObject.registerClass({ // Telephony 'telephony', 'telephony-page', 'ringing-list', 'ringing-volume', 'talking-list', 'talking-volume', - 'after-list', + 'ended-list', // Shortcuts 'shortcuts-page', @@ -485,7 +485,7 @@ var Panel = GObject.registerClass({ this.actions.add_action(settings.create_action('talking-volume')); this.actions.add_action(settings.create_action('talking-pause')); this.actions.add_action(settings.create_action('talking-microphone')); - this.actions.add_action(settings.create_action('after-unpause')); + this.actions.add_action(settings.create_action('ended-resume')); // Pair Actions const encryption_info = new Gio.SimpleAction({name: 'encryption-info'}); @@ -905,12 +905,12 @@ var Panel = GObject.registerClass({ this.ringing_list.next = this.talking_list; this.talking_list.prev = this.ringing_list; - this.talking_list.next = this.after_list; - this.after_list.prev = this.talking_list; + this.talking_list.next = this.ended_list; + this.ended_list.prev = this.talking_list; this.ringing_list.set_header_func(rowSeparators); this.talking_list.set_header_func(rowSeparators); - this.after_list.set_header_func(rowSeparators); + this.ended_list.set_header_func(rowSeparators); } /** diff --git a/src/service/plugins/telephony.js b/src/service/plugins/telephony.js index c2433094f..cffc40187 100644 --- a/src/service/plugins/telephony.js +++ b/src/service/plugins/telephony.js @@ -99,7 +99,7 @@ var Plugin = GObject.registerClass({ * Restore volume and microphone, plus media player state * (if we changed it and restore is enabled). * - * If we're going to auto-unpause, make sure to do that first + * If we're going to auto-resume, make sure to do that first * before raising volume. * Otherwise, still raise the volume (so the user can unpause). * @@ -109,10 +109,10 @@ var Plugin = GObject.registerClass({ _restoreMediaState() { // Media Playback if (this._mpris) { - if (this.settings.get_boolean('after-unpause')) { + if (this.settings.get_boolean('ended-resume')) { this._mpris.unpauseAll(); } else { - /* Even if unpause is disabled, we still need to clear + /* Even if resume is disabled, we still need to clear * the list of which players we're holding paused * * TODO: This potentially worsens the multi-device