[gnome-builder] workbench: register accelerator for perspectives



commit bd45ef08203699b3acad25d7a708a34ed700fade
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 27 19:10:32 2016 -0700

    workbench: register accelerator for perspectives
    
    When adding a perspective, we can register their accelerator for them.

 libide/workbench/ide-workbench.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/libide/workbench/ide-workbench.c b/libide/workbench/ide-workbench.c
index edaeddb..431b1e7 100644
--- a/libide/workbench/ide-workbench.c
+++ b/libide/workbench/ide-workbench.c
@@ -21,11 +21,12 @@
 #include <glib/gi18n.h>
 
 #include "ide-debug.h"
+#include "ide-macros.h"
 
+#include "application/ide-application.h"
 #include "editor/ide-editor-perspective.h"
 #include "genesis/ide-genesis-perspective.h"
 #include "greeter/ide-greeter-perspective.h"
-#include "ide-macros.h"
 #include "preferences/ide-preferences-perspective.h"
 #include "util/ide-gtk.h"
 #include "util/ide-window-settings.h"
@@ -601,6 +602,7 @@ void
 ide_workbench_add_perspective (IdeWorkbench   *self,
                                IdePerspective *perspective)
 {
+  g_autofree gchar *accel= NULL;
   g_autofree gchar *icon_name = NULL;
   g_autofree gchar *id = NULL;
   g_autofree gchar *title = NULL;
@@ -642,6 +644,19 @@ ide_workbench_add_perspective (IdeWorkbench   *self,
                          ide_workbench_compare_perspective,
                          NULL);
     }
+
+  accel = ide_perspective_get_accelerator (perspective);
+
+  if (accel != NULL)
+    {
+      const gchar *accel_map[] = { accel, NULL };
+      g_autofree gchar *action_name = NULL;
+
+      action_name = g_strdup_printf ("win.perspective('%s')", id);
+      gtk_application_set_accels_for_action (GTK_APPLICATION (IDE_APPLICATION_DEFAULT),
+                                             action_name, accel_map);
+
+    }
 }
 
 void


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