[devhelp] help: add Help menu items and GAction to open the user doc



commit ed1d5b6bd026ceb750544810ed8475b96d77f118
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Jan 21 10:47:11 2018 +0100

    help: add Help menu items and GAction to open the user doc

 src/dh-app.c     |   31 +++++++++++++++++++++++++++----
 src/dh-window.ui |    4 ++++
 src/menus.ui     |    6 +++++-
 3 files changed, 36 insertions(+), 5 deletions(-)
---
diff --git a/src/dh-app.c b/src/dh-app.c
index 5e48578..6a35126 100644
--- a/src/dh-app.c
+++ b/src/dh-app.c
@@ -4,7 +4,7 @@
  * Copyright (C) 2002 Mikael Hallendal <micke imendio com>
  * Copyright (C) 2004-2008 Imendio AB
  * Copyright (C) 2012 Aleksander Morgado <aleksander gnu org>
- * Copyright (C) 2017 Sébastien Wilmet <swilmet gnome org>
+ * Copyright (C) 2017, 2018 Sébastien Wilmet <swilmet gnome org>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -53,6 +53,25 @@ preferences_cb (GSimpleAction *action,
 }
 
 static void
+help_cb (GSimpleAction *action,
+         GVariant      *parameter,
+         gpointer       user_data)
+{
+        DhApp *app = DH_APP (user_data);
+        GtkWindow *window;
+        GError *error = NULL;
+
+        window = (GtkWindow *) dh_app_get_active_main_window (app, FALSE);
+
+        gtk_show_uri_on_window (window, "help:devhelp", GDK_CURRENT_TIME, &error);
+
+        if (error != NULL) {
+                g_warning ("Failed to open the documentation: %s", error->message);
+                g_clear_error (&error);
+        }
+}
+
+static void
 about_cb (GSimpleAction *action,
           GVariant      *parameter,
           gpointer       user_data)
@@ -192,6 +211,7 @@ add_action_entries (DhApp *app)
                 /* General actions */
                 { "new-window", new_window_cb },
                 { "preferences", preferences_cb },
+                { "help", help_cb },
                 { "about", about_cb },
                 { "quit", quit_cb },
 
@@ -250,15 +270,18 @@ setup_accelerators (GtkApplication *app)
         accels[0] = "<Control>Page_Up";
         gtk_application_set_accels_for_action (app, "win.prev-tab", accels);
 
-        accels[0] = "F9";
-        gtk_application_set_accels_for_action (app, "win.show-sidebar", accels);
-
         accels[0] = "<Control>w";
         gtk_application_set_accels_for_action (app, "win.close", accels);
 
         accels[0] = "<Control>q";
         gtk_application_set_accels_for_action (app, "app.quit", accels);
 
+        accels[0] = "F1";
+        gtk_application_set_accels_for_action (app, "app.help", accels);
+
+        accels[0] = "F9";
+        gtk_application_set_accels_for_action (app, "win.show-sidebar", accels);
+
         accels[0] = "F10";
         gtk_application_set_accels_for_action (app, "win.gear-menu", accels);
 
diff --git a/src/dh-window.ui b/src/dh-window.ui
index 0815284..ec04a53 100644
--- a/src/dh-window.ui
+++ b/src/dh-window.ui
@@ -84,6 +84,10 @@
         <attribute name="action">win.show-help-overlay</attribute>
       </item>
       <item>
+        <attribute name="label" translatable="yes">_Help</attribute>
+        <attribute name="action">app.help</attribute>
+      </item>
+      <item>
         <attribute name="label" translatable="yes">_About Devhelp</attribute>
         <attribute name="action">app.about</attribute>
       </item>
diff --git a/src/menus.ui b/src/menus.ui
index 29671f7..3e67f73 100644
--- a/src/menus.ui
+++ b/src/menus.ui
@@ -3,7 +3,7 @@
 <!--
   Copyright (C) 2010 Imendio AB
   Copyright (C) 2012 Aleksander Morgado <aleksander gnu org>
-  Copyright (C) 2017 Sébastien Wilmet <swilmet gnome org>
+  Copyright (C) 2017, 2018 Sébastien Wilmet <swilmet gnome org>
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -43,6 +43,10 @@
         <attribute name="action">win.show-help-overlay</attribute>
       </item>
       <item>
+        <attribute name="label" translatable="yes">_Help</attribute>
+        <attribute name="action">app.help</attribute>
+      </item>
+      <item>
         <attribute name="label" translatable="yes">_About</attribute>
         <attribute name="action">app.about</attribute>
       </item>


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