[gnome-sound-recorder/wip/add-help-docus: 2/2] app, window: Add "Help" entry to the menu




commit 98f3adfa69cb375ede4d43558c5069023858c9ee
Author: Felipe Borges <felipeborges gnome org>
Date:   Wed Jul 7 13:12:46 2021 +0200

    app, window: Add "Help" entry to the menu

 data/ui/window.ui  |  4 ++++
 src/application.js | 14 ++++++++++++++
 2 files changed, 18 insertions(+)
---
diff --git a/data/ui/window.ui b/data/ui/window.ui
index 58e8608..f96c425 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -271,6 +271,10 @@
         <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
         <attribute name="action">win.show-help-overlay</attribute>
       </item>
+      <item>
+        <attribute name="action">app.help</attribute>
+        <attribute name="label" translatable="yes">_Help</attribute>
+      </item>
       <item>
         <attribute name="action">app.about</attribute>
         <attribute name="label" translatable="yes">About Sound Recorder</attribute>
diff --git a/src/application.js b/src/application.js
index d9ab61a..71a2e73 100644
--- a/src/application.js
+++ b/src/application.js
@@ -56,6 +56,10 @@ var Application = GObject.registerClass(class Application extends Gtk.Applicatio
         const channelAction = Settings.create_action('audio-channel');
         this.add_action(channelAction);
 
+        let helpAction = new Gio.SimpleAction({ name: 'help' });
+        helpAction.connect('activate', this._showHelp.bind(this));
+        this.add_action(helpAction);
+
         let aboutAction = new Gio.SimpleAction({ name: 'about' });
         aboutAction.connect('activate', this._showAbout.bind(this));
         this.add_action(aboutAction);
@@ -145,4 +149,14 @@ var Application = GObject.registerClass(class Application extends Gtk.Applicatio
             aboutDialog.close();
         });
     }
+
+    _showHelp() {
+        try {
+            Gtk.show_uri_on_window(this.window,
+                                   "help:gnome-sound-recorder",
+                                   Gtk.get_current_event_time());
+        } catch (e) {
+            error(`Failed to display help: ${e}`);
+        }
+    }
 });


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