[gnome-shell] status/system: Add screenshot item



commit 1e9749a78227f848ea5749d510b74a4252adfe0b
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun Aug 21 18:23:06 2022 +0200

    status/system: Add screenshot item
    
    We got a shiny new screenshot UI last cycle, but only relatively
    obscure ways of launching it: Keyboard shortcut or overview search.
    
    The new quick settings provides us with a natural place to expose
    the functionality more prominently, and at the same time reduce
    the emptiness of the top row, in particular on systems without a
    battery and when locked.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2439>

 js/ui/status/system.js | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/status/system.js b/js/ui/status/system.js
index a45697adb4..4577307225 100644
--- a/js/ui/status/system.js
+++ b/js/ui/status/system.js
@@ -1,11 +1,12 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported Indicator */
 
-const {Atk, Clutter, Gio, GObject, Shell, St, UPowerGlib: UPower} = imports.gi;
+const {Atk, Clutter, Gio, GLib, GObject, Meta, Shell, St, UPowerGlib: UPower} = imports.gi;
 
 const SystemActions = imports.misc.systemActions;
 const Main = imports.ui.main;
 const PopupMenu = imports.ui.popupMenu;
+const {PopupAnimation} = imports.ui.boxpointer;
 
 const {QuickSettingsItem, QuickToggle, SystemIndicator} = imports.ui.quickSettings;
 const {loadInterfaceXML} = imports.misc.fileUtils;
@@ -93,6 +94,27 @@ const PowerToggle = GObject.registerClass({
     }
 });
 
+const ScreenshotItem = GObject.registerClass(
+class ScreenshotItem extends QuickSettingsItem {
+    _init() {
+        super._init({
+            style_class: 'icon-button',
+            can_focus: true,
+            icon_name: 'camera-photo-symbolic',
+            visible: !Main.sessionMode.isGreeter,
+        });
+
+        this.connect('clicked', () => {
+            const topMenu = Main.panel.statusArea.quickSettings.menu;
+            Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
+                Main.screenshotUI.open().catch(logError);
+                return GLib.SOURCE_REMOVE;
+            });
+            topMenu.close(PopupAnimation.NONE);
+        });
+    }
+});
+
 const SettingsItem = GObject.registerClass(
 class SettingsItem extends QuickSettingsItem {
     _init() {
@@ -242,6 +264,9 @@ class SystemItem extends QuickSettingsItem {
             GObject.BindingFlags.SYNC_CREATE);
         this.child.add_child(this._laptopSpacer);
 
+        const screenshotItem = new ScreenshotItem();
+        this.child.add_child(screenshotItem);
+
         const settingsItem = new SettingsItem();
         this.child.add_child(settingsItem);
 


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