[gnome-shell] systemActions: Add a screenshot UI action



commit a0206dcc3ff114a048f789589868fa2869189045
Author: Ivan Molodetskikh <yalterz gmail com>
Date:   Fri Dec 17 11:40:43 2021 +0300

    systemActions: Add a screenshot UI action
    
    It waits for the overview to close because otherwise the screenshot UI
    would capture the overview.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2106>

 js/misc/systemActions.js | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
---
diff --git a/js/misc/systemActions.js b/js/misc/systemActions.js
index 10cab9a9e2..a45a21c165 100644
--- a/js/misc/systemActions.js
+++ b/js/misc/systemActions.js
@@ -4,6 +4,7 @@ const { AccountsService, Clutter, Gdm, Gio, GLib, GObject, Meta } = imports.gi;
 const GnomeSession = imports.misc.gnomeSession;
 const LoginManager = imports.misc.loginManager;
 const Main = imports.ui.main;
+const Screenshot = imports.ui.screenshot;
 
 const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown';
 const LOGIN_SCREEN_SCHEMA = 'org.gnome.login-screen';
@@ -20,6 +21,7 @@ const LOGOUT_ACTION_ID           = 'logout';
 const SUSPEND_ACTION_ID          = 'suspend';
 const SWITCH_USER_ACTION_ID      = 'switch-user';
 const LOCK_ORIENTATION_ACTION_ID = 'lock-orientation';
+const SCREENSHOT_UI_ACTION_ID    = 'open-screenshot-ui';
 
 let _singleton = null;
 
@@ -132,6 +134,14 @@ const SystemActions = GObject.registerClass({
             keywords: tokenizeKeywords(_('lock orientation;unlock orientation;screen;rotation')),
             available: false,
         });
+        this._actions.set(SCREENSHOT_UI_ACTION_ID, {
+            // Translators: The name of the screenshot UI action in search
+            name: C_('search-result', 'Take a Screenshot'),
+            iconName: 'applets-screenshooter-symbolic',
+            // Translators: A list of keywords that match the screenshot UI action, separated by semicolons
+            keywords: tokenizeKeywords(_('screenshot;screencast;snip;capture;record')),
+            available: true,
+        });
 
         this._loginScreenSettings = new Gio.Settings({ schema_id: LOGIN_SCREEN_SCHEMA });
         this._lockdownSettings = new Gio.Settings({ schema_id: LOCKDOWN_SCHEMA });
@@ -306,6 +316,9 @@ const SystemActions = GObject.registerClass({
         case LOCK_ORIENTATION_ACTION_ID:
             this.activateLockOrientation();
             break;
+        case SCREENSHOT_UI_ACTION_ID:
+            this.activateScreenshotUI();
+            break;
         }
     }
 
@@ -446,4 +459,18 @@ const SystemActions = GObject.registerClass({
 
         this._loginManager.suspend();
     }
+
+    activateScreenshotUI() {
+        if (!this._actions.get(SCREENSHOT_UI_ACTION_ID).available)
+            throw new Error('The screenshot UI action is not available!');
+
+        if (this._overviewHiddenId)
+            return;
+
+        this._overviewHiddenId = Main.overview.connect('hidden', () => {
+            Main.overview.disconnect(this._overviewHiddenId);
+            delete this._overviewHiddenId;
+            Screenshot.showScreenshotUI();
+        });
+    }
 });


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