[gnome-sound-recorder/bilelmoussaoui/fixes: 12/12] add few keyboard shortcuts & a shortcuts window




commit 1e4c90a9a38d43067784e2cfdeee66dfe2ca85a9
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Wed Sep 9 06:43:25 2020 +0200

    add few keyboard shortcuts & a shortcuts window

 data/org.gnome.SoundRecorder.data.gresource.xml |   1 +
 data/ui/help-overlay.ui                         | 124 ++++++++++++++++++++++++
 data/ui/window.ui                               |   5 +
 po/POTFILES.in                                  |   2 +
 src/application.js                              |   9 ++
 src/row.js                                      |   9 +-
 src/window.js                                   |  13 ++-
 7 files changed, 158 insertions(+), 5 deletions(-)
---
diff --git a/data/org.gnome.SoundRecorder.data.gresource.xml b/data/org.gnome.SoundRecorder.data.gresource.xml
index ca14163..f446c3d 100644
--- a/data/org.gnome.SoundRecorder.data.gresource.xml
+++ b/data/org.gnome.SoundRecorder.data.gresource.xml
@@ -5,6 +5,7 @@
     <file>ui/recorder.ui</file>
     <file>ui/row.ui</file>
     <file>ui/window.ui</file>
+    <file alias="gtk/help-overlay.ui">ui/help-overlay.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">icons/skip-back-symbolic.svg</file>
     <file compressed="true" preprocess="xml-stripblanks">icons/skip-forward-symbolic.svg</file>
   </gresource>
diff --git a/data/ui/help-overlay.ui b/data/ui/help-overlay.ui
new file mode 100644
index 0000000..8f7d3a7
--- /dev/null
+++ b/data/ui/help-overlay.ui
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+<!-- interface-requires gtk+ 3.17 -->
+  <object class="GtkShortcutsWindow" id="help_overlay">
+    <property name="modal">1</property>
+    <child>
+      <object class="GtkShortcutsSection">
+        <property name="visible">1</property>
+        <property name="section-name">shortcuts</property>
+        <property name="max-height">10</property>
+        <child>
+
+          <object class="GtkShortcutsGroup">
+            <property name="visible">1</property>
+            <property name="title" translatable="yes" context="shortcut window">General</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">F10</property>
+                <property name="title" translatable="yes" context="shortcut window">Open menu</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;question</property>
+                <property name="title" translatable="yes" context="shortcut window">Keyboard 
shortcuts</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;Q</property>
+                <property name="title" translatable="yes" context="shortcut window">Quit</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">1</property>
+            <property name="title" translatable="yes" context="shortcut window">Recorder</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;R</property>
+                <property name="title" translatable="yes" context="shortcut window">Start/Resume 
Recording</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;P</property>
+                <property name="title" translatable="yes" context="shortcut window">Pause</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;S</property>
+                <property name="title" translatable="yes" context="shortcut window">Stop</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;C</property>
+                <property name="title" translatable="yes" context="shortcut window">Cancel</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">1</property>
+            <property name="title" translatable="yes" context="shortcut window">Recording</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">P</property>
+                <property name="title" translatable="yes" context="shortcut window">Play / Pause</property>
+              </object>
+            </child>
+             <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">B</property>
+                <property name="title" translatable="yes" context="shortcut window">Seek Backward</property>
+              </object>
+            </child>
+             <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">F</property>
+                <property name="title" translatable="yes" context="shortcut window">Seek Forward</property>
+              </object>
+            </child>
+             <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">Delete</property>
+                <property name="title" translatable="yes" context="shortcut window">Delete 
Recording</property>
+              </object>
+            </child>
+             <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">F2</property>
+                <property name="title" translatable="yes" context="shortcut window">Rename 
Recording</property>
+              </object>
+            </child>
+             <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;s</property>
+                <property name="title" translatable="yes" context="shortcut window">Export</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
\ No newline at end of file
diff --git a/data/ui/window.ui b/data/ui/window.ui
index 70f93af..e29196e 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -77,6 +77,7 @@
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
+                    <property name="action_name">win.open-primary-menu</property>
                     <property name="menu_model">primaryMenu</property>
                     <child>
                       <object class="GtkImage">
@@ -327,6 +328,10 @@
       </item>
     </submenu>
     <section>
+      <item>
+        <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
+        <attribute name="action">win.show-help-overlay</attribute>
+      </item>
       <item>
         <attribute name="action">app.about</attribute>
         <attribute name="label" translatable="yes">About Sound Recorder</attribute>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6c26701..cdab85f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,6 +3,8 @@
 data/appdata/org.gnome.SoundRecorder.metainfo.xml.in.in
 data/org.gnome.SoundRecorder.desktop.in.in
 data/org.gnome.SoundRecorder.gschema.xml.in
+data/ui/help-overlay.ui
+data/ui/recorder.ui
 data/ui/row.ui
 data/ui/window.ui
 src/application.js
diff --git a/src/application.js b/src/application.js
index 78a9cca..cba91d1 100644
--- a/src/application.js
+++ b/src/application.js
@@ -67,11 +67,20 @@ var Application = GObject.registerClass(class Application extends Gtk.Applicatio
         this.add_action(quitAction);
 
         this.add_accelerator('<Primary>q', 'app.quit', null);
+        this.add_accelerator('F10', 'win.open-primary-menu', null);
+        this.add_accelerator('<Primary>question', 'win.show-help-overlay', null);
         this.add_accelerator('<Primary>r', 'recorder.start', null);
         this.add_accelerator('<Primary>p', 'recorder.pause', null);
         this.add_accelerator('<Primary>r', 'recorder.resume', null);
         this.add_accelerator('<Primary>c', 'recorder.cancel', null);
         this.add_accelerator('<Primary>s', 'recorder.stop', null);
+        this.add_accelerator('p', 'recording.play', null);
+        this.add_accelerator('p', 'recording.pause', null);
+        this.add_accelerator('b', 'recording.seek-backward', null);
+        this.add_accelerator('f', 'recording.seek-forward', null);
+        this.add_accelerator('F2', 'recording.rename', null);
+        this.add_accelerator('Delete', 'recording.delete', null);
+        this.add_accelerator('<Primary>s', 'recording.export', null);
     }
 
     vfunc_startup() {
diff --git a/src/row.js b/src/row.js
index c5040c2..48aa32f 100644
--- a/src/row.js
+++ b/src/row.js
@@ -129,7 +129,7 @@ var Row = GObject.registerClass({
         this.insert_action_group('recording', this.actionGroup);
 
         this.waveform.connect('button-press-event', _ => {
-            pauseAction.activate();
+            pauseAction.activate(null);
         });
 
         this._entry.connect('key-press-event', (_, event) => {
@@ -180,13 +180,14 @@ var Row = GObject.registerClass({
         if (state) {
             if (!this.expanded)
                 this.activate();
-
             this._entry.grab_focus();
             this._saveBtn.grab_default();
             this._rightStack.visible_child_name = 'save';
         } else {
             this._rightStack.visible_child_name = 'options';
+            this.grab_focus();
         }
+        this.actionGroup.lookup('rename').enabled = !state;
     }
 
     get editMode() {
@@ -207,11 +208,11 @@ var Row = GObject.registerClass({
 
         switch (rowState) {
         case RowState.PLAYING:
-            this.actionGroup.lookup('play').set_enabled(false);
+            this.actionGroup.lookup('play').enabled = false;
             this._playbackStack.visible_child_name = 'pause';
             break;
         case RowState.PAUSED:
-            this.actionGroup.lookup('play').set_enabled(true);
+            this.actionGroup.lookup('play').enabled = true;
             this._playbackStack.visible_child_name = 'play';
             break;
         }
diff --git a/src/window.js b/src/window.js
index 4ab0417..ff92f2e 100644
--- a/src/window.js
+++ b/src/window.js
@@ -18,7 +18,7 @@
 *
 */
 
-const { GLib, GObject, Gst, GstPlayer, Handy } = imports.gi;
+const { Gio, GLib, GObject, Gst, GstPlayer, Gtk, Handy } = imports.gi;
 
 const { Recorder } = imports.recorder;
 const { RecordingList } = imports.recordingList;
@@ -74,6 +74,17 @@ var Window = GObject.registerClass({
             );
         });
 
+        const builder = Gtk.Builder.new_from_resource('/org/gnome/SoundRecorder/gtk/help-overlay.ui');
+        const dialog = builder.get_object('help_overlay');
+        this.set_help_overlay(dialog);
+
+        let openMenuAction = new Gio.SimpleAction({ name: 'open-primary-menu', state: new GLib.Variant('b', 
true) });
+        openMenuAction.connect('activate', action => {
+            const state = action.get_state().get_boolean();
+            action.state = new GLib.Variant('b', !state);
+        });
+        this.add_action(openMenuAction);
+
         this._notificationCloseBtn.connect('clicked', _ => {
             this._notificationRevealer.reveal_child = false;
             if (this.deleteSignalId && this.deleteSignalId > 0) {


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