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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2103>
This commit is contained in:
Ivan Molodetskikh 2021-11-27 10:41:24 +03:00 committed by Marge Bot
parent eb60fa2908
commit fc0bff5e48

View File

@ -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 ||