[gnome-shell] windowMenu: Add an entry to take a screenshot



commit 84cfab21192dd2c3fa131ed57f788df12f0842bf
Author: Ivan Molodetskikh <yalterz gmail com>
Date:   Fri Aug 27 19:17:46 2021 +0300

    windowMenu: Add an entry to take a screenshot
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2105>

 js/ui/windowMenu.js | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/js/ui/windowMenu.js b/js/ui/windowMenu.js
index 27cecdac23..081645f042 100644
--- a/js/ui/windowMenu.js
+++ b/js/ui/windowMenu.js
@@ -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();
         });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]