[gnome-shell] screenshot-ui: Add two key bindings from g-s-d



commit b0ebbb00b8cb13524608216b705ecf38c777711c
Author: Ivan Molodetskikh <yalterz gmail com>
Date:   Sat Jan 15 19:06:49 2022 +0300

    screenshot-ui: Add two key bindings from g-s-d
    
    These two are moving into gnome-shell to unify screenshot handling and
    allow for same-frame capturing.
    
    While we're at it, move the keybindings .xml file from g-c-c here
    because it belongs to gnome-shell.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2107>

 data/50-gnome-shell-screenshots.xml | 17 +++++++++++++++++
 data/meson.build                    |  1 +
 data/org.gnome.shell.gschema.xml.in | 10 +++++++++-
 js/ui/screenshot.js                 | 36 ++++++++++++++++++++++++++++++++++++
 po/POTFILES.in                      |  1 +
 5 files changed, 64 insertions(+), 1 deletion(-)
---
diff --git a/data/50-gnome-shell-screenshots.xml b/data/50-gnome-shell-screenshots.xml
new file mode 100644
index 0000000000..d99f60bd21
--- /dev/null
+++ b/data/50-gnome-shell-screenshots.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<KeyListEntries schema="org.gnome.shell.keybindings"
+                group="system"
+                name="Screenshots"
+                wm_name="GNOME Shell"
+                package="gnome-shell">
+
+    <KeyListEntry name="show-screenshot-ui"
+                  description="Take a screenshot interactively"/>
+
+    <KeyListEntry name="screenshot"
+                  description="Take a screenshot"/>
+
+    <KeyListEntry name="screenshot-window"
+                  description="Take a screenshot of a window"/>
+
+</KeyListEntries>
\ No newline at end of file
diff --git a/data/meson.build b/data/meson.build
index 311a2b8f91..30d4917d8e 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -79,6 +79,7 @@ configure_file(
 
 keybinding_files = [
   '50-gnome-shell-launchers.xml',
+  '50-gnome-shell-screenshots.xml',
   '50-gnome-shell-system.xml',
 ]
 
diff --git a/data/org.gnome.shell.gschema.xml.in b/data/org.gnome.shell.gschema.xml.in
index 1dadb13c28..e686d2203d 100644
--- a/data/org.gnome.shell.gschema.xml.in
+++ b/data/org.gnome.shell.gschema.xml.in
@@ -232,7 +232,15 @@
     </key>
     <key name="show-screenshot-ui" type="as">
       <default>["Print"]</default>
-      <summary>Show screenshot UI</summary>
+      <summary>Take a screenshot interactively</summary>
+    </key>
+    <key name="screenshot-window" type="as">
+      <default>["&lt;Alt&gt;Print"]</default>
+      <summary>Take a screenshot of a window</summary>
+    </key>
+    <key name="screenshot" type="as">
+      <default>["&lt;Shift&gt;Print"]</default>
+      <summary>Take a screenshot</summary>
     </key>
   </schema>
 
diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js
index 2b70d1d0cf..cc81490c98 100644
--- a/js/ui/screenshot.js
+++ b/js/ui/screenshot.js
@@ -1288,6 +1288,42 @@ var ScreenshotUI = GObject.registerClass({
             uiModes,
             showScreenshotUI
         );
+
+        Main.wm.addKeybinding(
+            'screenshot-window',
+            new Gio.Settings({ schema_id: 'org.gnome.shell.keybindings' }),
+            Meta.KeyBindingFlags.IGNORE_AUTOREPEAT | Meta.KeyBindingFlags.PER_WINDOW,
+            uiModes,
+            async (_display, window, _binding) => {
+                try {
+                    const actor = window.get_compositor_private();
+                    const content = actor.paint_to_content(null);
+                    const texture = content.get_texture();
+
+                    await captureScreenshot(texture, null, 1, null);
+                } catch (e) {
+                    logError(e, 'Error capturing screenshot');
+                }
+            }
+        );
+
+        Main.wm.addKeybinding(
+            'screenshot',
+            new Gio.Settings({ schema_id: 'org.gnome.shell.keybindings' }),
+            Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+            uiModes,
+            async () => {
+                try {
+                    const shooter = new Shell.Screenshot();
+                    const [content] = await shooter.to_content();
+                    const texture = content.get_texture();
+
+                    await captureScreenshot(texture, null, 1, null);
+                } catch (e) {
+                    logError(e, 'Error capturing screenshot');
+                }
+            }
+        );
     }
 
     _refreshButtonLayout() {
diff --git a/po/POTFILES.in b/po/POTFILES.in
index aafc3e3450..2f6bd0ae76 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,7 @@
 # List of source files containing translatable strings.
 # Please keep this file sorted alphabetically.
 data/50-gnome-shell-launchers.xml
+data/50-gnome-shell-screenshots.xml
 data/50-gnome-shell-system.xml
 data/org.gnome.Shell.desktop.in.in
 data/org.gnome.shell.gschema.xml.in


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