From fc0bff5e480068e0f309d8f660d8d0f3969f8cbf Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sat, 27 Nov 2021 10:41:24 +0300 Subject: [PATCH] screenshot-ui: Add a screencast in progress property The screen recording menu entry will use this to check if a screencast is currently active and to stop the screencast. Use a GObject property so we can bind to notify; specifically we'll bind the visibility of a screencast area indicator. Part-of: --- js/ui/screenshot.js | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js index ce6ff26a2..741737623 100644 --- a/js/ui/screenshot.js +++ b/js/ui/screenshot.js @@ -995,8 +995,16 @@ class UIWindowSelector extends St.Widget { } }); -var ScreenshotUI = GObject.registerClass( -class ScreenshotUI extends St.Widget { +var ScreenshotUI = GObject.registerClass({ + Properties: { + 'screencast-in-progress': GObject.ParamSpec.boolean( + 'screencast-in-progress', + 'screencast-in-progress', + 'screencast-in-progress', + GObject.ParamFlags.READABLE, + false), + }, +}, class ScreenshotUI extends St.Widget { _init() { super._init({ name: 'screenshot-ui', @@ -1010,6 +1018,8 @@ class ScreenshotUI extends St.Widget { reactive: true, }); + this._screencastInProgress = false; + this._lockdownSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.lockdown' }); // The full-screen screenshot has a separate container so that we can @@ -1820,6 +1830,30 @@ class ScreenshotUI extends St.Widget { } } + stopScreencast() { + if (!this._screencastInProgress) + return; + + // Set this before calling the method as the screen recording indicator + // will check it before the success callback fires. + this._setScreencastInProgress(false); + } + + get screencast_in_progress() { + if (!('_screencastInProgress' in this)) + return false; + + return this._screencastInProgress; + } + + _setScreencastInProgress(inProgress) { + if (this._screencastInProgress === inProgress) + return; + + this._screencastInProgress = inProgress; + this.notify('screencast-in-progress'); + } + vfunc_key_press_event(event) { const symbol = event.keyval; if (symbol === Clutter.KEY_Return || symbol === Clutter.KEY_space ||