screenshot: Add signals to ScreenshotUI
These signals will let the yet to be introduced D-Bus method to be notified of when either a screenshot has been taken, or if the screenshot UI has been closed without taking a screenshot. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2999>
This commit is contained in:
parent
75dafd8d9c
commit
c80f3af79b
@ -1060,6 +1060,10 @@ export const ScreenshotUI = GObject.registerClass({
|
||||
GObject.ParamFlags.READABLE,
|
||||
false),
|
||||
},
|
||||
Signals: {
|
||||
'screenshot-taken': {param_types: [Gio.File.$gtype]},
|
||||
'closed': {},
|
||||
},
|
||||
}, class ScreenshotUI extends St.Widget {
|
||||
_init() {
|
||||
super._init({
|
||||
@ -1663,6 +1667,8 @@ export const ScreenshotUI = GObject.registerClass({
|
||||
this._areaSelector.reset();
|
||||
for (const selector of this._windowSelectors)
|
||||
selector.reset();
|
||||
|
||||
this.emit('closed');
|
||||
}
|
||||
|
||||
close(instantly = false) {
|
||||
@ -1845,7 +1851,7 @@ export const ScreenshotUI = GObject.registerClass({
|
||||
|
||||
_onCaptureButtonClicked() {
|
||||
if (this._shotButton.checked) {
|
||||
this._saveScreenshot();
|
||||
this._saveScreenshot().catch(logError);
|
||||
this.close();
|
||||
} else {
|
||||
// Screencast closes the UI on its own.
|
||||
@ -1853,7 +1859,9 @@ export const ScreenshotUI = GObject.registerClass({
|
||||
}
|
||||
}
|
||||
|
||||
_saveScreenshot() {
|
||||
async _saveScreenshot() {
|
||||
let file = null;
|
||||
|
||||
if (this._selectionButton.checked || this._screenButton.checked) {
|
||||
const content = this._stageScreenshot.get_content();
|
||||
if (!content)
|
||||
@ -1866,7 +1874,8 @@ export const ScreenshotUI = GObject.registerClass({
|
||||
if (!this._cursor.visible)
|
||||
cursorTexture = null;
|
||||
|
||||
captureScreenshot(
|
||||
try {
|
||||
file = await captureScreenshot(
|
||||
texture, geometry, this._scale,
|
||||
{
|
||||
texture: cursorTexture ?? null,
|
||||
@ -1874,7 +1883,10 @@ export const ScreenshotUI = GObject.registerClass({
|
||||
y: this._cursor.y * this._scale,
|
||||
scale: this._cursorScale,
|
||||
}
|
||||
).catch(e => logError(e, 'Error capturing screenshot'));
|
||||
);
|
||||
} catch (e) {
|
||||
logError(e, 'Error capturing screenshot');
|
||||
}
|
||||
} else if (this._windowButton.checked) {
|
||||
const window =
|
||||
this._windowSelectors.flatMap(selector => selector.windows())
|
||||
@ -1892,7 +1904,8 @@ export const ScreenshotUI = GObject.registerClass({
|
||||
if (!this._cursor.visible)
|
||||
cursorTexture = null;
|
||||
|
||||
captureScreenshot(
|
||||
try {
|
||||
file = await captureScreenshot(
|
||||
texture,
|
||||
null,
|
||||
window.bufferScale,
|
||||
@ -1902,10 +1915,16 @@ export const ScreenshotUI = GObject.registerClass({
|
||||
y: window.cursorPoint.y * window.bufferScale,
|
||||
scale: this._cursorScale,
|
||||
}
|
||||
).catch(e => logError(e, 'Error capturing screenshot'));
|
||||
);
|
||||
} catch (e) {
|
||||
logError(e, 'Error capturing screenshot');
|
||||
}
|
||||
}
|
||||
|
||||
if (file)
|
||||
this.emit('screenshot-taken', file);
|
||||
}
|
||||
|
||||
async _startScreencast() {
|
||||
if (this._windowButton.checked)
|
||||
return; // TODO
|
||||
|
Loading…
x
Reference in New Issue
Block a user