windowMenu: Add an entry to take a screenshot
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2105>
This commit is contained in:
parent
b2fd93f3da
commit
84cfab2119
@ -6,6 +6,7 @@ const { GLib, Meta, St } = imports.gi;
|
||||
const BoxPointer = imports.ui.boxpointer;
|
||||
const Main = imports.ui.main;
|
||||
const PopupMenu = imports.ui.popupMenu;
|
||||
const Screenshot = imports.ui.screenshot;
|
||||
|
||||
var WindowMenu = class extends PopupMenu.PopupMenu {
|
||||
constructor(window, sourceActor) {
|
||||
@ -24,6 +25,19 @@ var WindowMenu = class extends PopupMenu.PopupMenu {
|
||||
|
||||
let item;
|
||||
|
||||
// Translators: entry in the window right click menu.
|
||||
item = this.addAction(_('Take Screenshot'), async () => {
|
||||
try {
|
||||
const actor = window.get_compositor_private();
|
||||
const content = actor.paint_to_content(null);
|
||||
const texture = content.get_texture();
|
||||
|
||||
await Screenshot.captureScreenshot(texture, null, 1, null);
|
||||
} catch (e) {
|
||||
logError(e, 'Error capturing screenshot');
|
||||
}
|
||||
});
|
||||
|
||||
item = this.addAction(_('Hide'), () => {
|
||||
window.minimize();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user