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,
|
GObject.ParamFlags.READABLE,
|
||||||
false),
|
false),
|
||||||
},
|
},
|
||||||
|
Signals: {
|
||||||
|
'screenshot-taken': {param_types: [Gio.File.$gtype]},
|
||||||
|
'closed': {},
|
||||||
|
},
|
||||||
}, class ScreenshotUI extends St.Widget {
|
}, class ScreenshotUI extends St.Widget {
|
||||||
_init() {
|
_init() {
|
||||||
super._init({
|
super._init({
|
||||||
@ -1663,6 +1667,8 @@ export const ScreenshotUI = GObject.registerClass({
|
|||||||
this._areaSelector.reset();
|
this._areaSelector.reset();
|
||||||
for (const selector of this._windowSelectors)
|
for (const selector of this._windowSelectors)
|
||||||
selector.reset();
|
selector.reset();
|
||||||
|
|
||||||
|
this.emit('closed');
|
||||||
}
|
}
|
||||||
|
|
||||||
close(instantly = false) {
|
close(instantly = false) {
|
||||||
@ -1845,7 +1851,7 @@ export const ScreenshotUI = GObject.registerClass({
|
|||||||
|
|
||||||
_onCaptureButtonClicked() {
|
_onCaptureButtonClicked() {
|
||||||
if (this._shotButton.checked) {
|
if (this._shotButton.checked) {
|
||||||
this._saveScreenshot();
|
this._saveScreenshot().catch(logError);
|
||||||
this.close();
|
this.close();
|
||||||
} else {
|
} else {
|
||||||
// Screencast closes the UI on its own.
|
// 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) {
|
if (this._selectionButton.checked || this._screenButton.checked) {
|
||||||
const content = this._stageScreenshot.get_content();
|
const content = this._stageScreenshot.get_content();
|
||||||
if (!content)
|
if (!content)
|
||||||
@ -1866,15 +1874,19 @@ export const ScreenshotUI = GObject.registerClass({
|
|||||||
if (!this._cursor.visible)
|
if (!this._cursor.visible)
|
||||||
cursorTexture = null;
|
cursorTexture = null;
|
||||||
|
|
||||||
captureScreenshot(
|
try {
|
||||||
texture, geometry, this._scale,
|
file = await captureScreenshot(
|
||||||
{
|
texture, geometry, this._scale,
|
||||||
texture: cursorTexture ?? null,
|
{
|
||||||
x: this._cursor.x * this._scale,
|
texture: cursorTexture ?? null,
|
||||||
y: this._cursor.y * this._scale,
|
x: this._cursor.x * this._scale,
|
||||||
scale: this._cursorScale,
|
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) {
|
} else if (this._windowButton.checked) {
|
||||||
const window =
|
const window =
|
||||||
this._windowSelectors.flatMap(selector => selector.windows())
|
this._windowSelectors.flatMap(selector => selector.windows())
|
||||||
@ -1892,18 +1904,25 @@ export const ScreenshotUI = GObject.registerClass({
|
|||||||
if (!this._cursor.visible)
|
if (!this._cursor.visible)
|
||||||
cursorTexture = null;
|
cursorTexture = null;
|
||||||
|
|
||||||
captureScreenshot(
|
try {
|
||||||
texture,
|
file = await captureScreenshot(
|
||||||
null,
|
texture,
|
||||||
window.bufferScale,
|
null,
|
||||||
{
|
window.bufferScale,
|
||||||
texture: cursorTexture ?? null,
|
{
|
||||||
x: window.cursorPoint.x * window.bufferScale,
|
texture: cursorTexture ?? null,
|
||||||
y: window.cursorPoint.y * window.bufferScale,
|
x: window.cursorPoint.x * window.bufferScale,
|
||||||
scale: this._cursorScale,
|
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() {
|
async _startScreencast() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user