[gnome-builder/wip/afranke/userdoc: 2/3] Hook help into the UI



commit 4e244411251e12c4932f8640c8e3568c504f480a
Author: Alexandre Franke <alexandre franke gmail com>
Date:   Wed Jan 27 21:53:30 2016 +0100

    Hook help into the UI

 data/gtk/menus.ui                |    4 ++++
 libide/ide-application-actions.c |   37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/data/gtk/menus.ui b/data/gtk/menus.ui
index d380096..5d7d1f7 100644
--- a/data/gtk/menus.ui
+++ b/data/gtk/menus.ui
@@ -27,6 +27,10 @@
         <attribute name="action">app.shortcuts</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>
diff --git a/libide/ide-application-actions.c b/libide/ide-application-actions.c
index 356170d..ceb7229 100644
--- a/libide/ide-application-actions.c
+++ b/libide/ide-application-actions.c
@@ -133,6 +133,42 @@ ide_application_actions_about (GSimpleAction *action,
 }
 
 static void
+ide_application_actions_help (GSimpleAction *action,
+                               GVariant      *param,
+                               gpointer       user_data)
+{
+  IdeApplication *self = user_data;
+  GList *windows = NULL;
+  GtkWindow *bench = NULL;
+  GdkScreen *screen = NULL;
+  GError *err = NULL;
+
+  g_assert (IDE_IS_APPLICATION (self));
+
+  windows = gtk_application_get_windows (GTK_APPLICATION (self));
+
+  for (; windows; windows = windows->next)
+    {
+      if (IDE_IS_WORKBENCH (windows->data))
+        {
+          bench = windows->data;
+          break;
+        }
+    }
+
+  screen = gtk_window_get_screen (GTK_WINDOW(bench));
+  gtk_show_uri (screen,
+                "help:gnome-builder",
+                gtk_get_current_event_time (),
+                &err);
+  if (err)
+    {
+      g_message ("Unable to open help: %s\n", err->message);
+      g_error_free (err);
+    }
+}
+
+static void
 ide_application_actions_open_project (GSimpleAction *action,
                                       GVariant      *variant,
                                       gpointer       user_data)
@@ -260,6 +296,7 @@ static const GActionEntry IdeApplicationActions[] = {
   { "preferences",  ide_application_actions_preferences },
   { "quit",         ide_application_actions_quit },
   { "shortcuts",    ide_application_actions_shortcuts },
+  { "help",         ide_application_actions_help },
 };
 
 void


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