[gnome-builder/gnome-builder-3-26] workbench: initialize global keybindings from workbench



commit dcc92309aea45a73099f94e6705bbb161eaf4610
Author: Christian Hergert <chergert redhat com>
Date:   Thu Nov 30 14:46:07 2017 -0800

    workbench: initialize global keybindings from workbench
    
    This code went through some refactoring in master, so this is just a
    minimal backport to ensure they activate from the older design in 3.26.
    
    Having these defined at the application layer would not ensure they could
    hook activation before the event was dispatched to the target widget.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=757919

 libide/workbench/ide-workbench-private.h   |    1 +
 libide/workbench/ide-workbench-shortcuts.c |   28 ++++++++++++++++++++++++++++
 libide/workbench/ide-workbench.c           |    1 +
 3 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/libide/workbench/ide-workbench-private.h b/libide/workbench/ide-workbench-private.h
index c818a60..86823d1 100644
--- a/libide/workbench/ide-workbench-private.h
+++ b/libide/workbench/ide-workbench-private.h
@@ -62,6 +62,7 @@ void     _ide_workbench_header_bar_set_fullscreen (IdeWorkbenchHeaderBar *self,
                                                    gboolean               fullscreen);
 void     _ide_workbench_add_perspective_shortcut  (IdeWorkbench          *self,
                                                    IdePerspective        *perspective);
+void     _ide_workbench_init_shortcuts            (IdeWorkbench          *self);
 
 G_END_DECLS
 
diff --git a/libide/workbench/ide-workbench-shortcuts.c b/libide/workbench/ide-workbench-shortcuts.c
index 78f2d79..533f915 100644
--- a/libide/workbench/ide-workbench-shortcuts.c
+++ b/libide/workbench/ide-workbench-shortcuts.c
@@ -25,6 +25,8 @@
 
 #include "ide-workbench-private.h"
 
+#define I_(s) (g_intern_string(s))
+
 void
 _ide_workbench_add_perspective_shortcut (IdeWorkbench   *self,
                                          IdePerspective *perspective)
@@ -64,3 +66,29 @@ _ide_workbench_add_perspective_shortcut (IdeWorkbench   *self,
                                                  GETTEXT_PACKAGE);
     }
 }
+
+void
+_ide_workbench_init_shortcuts (IdeWorkbench *self)
+{
+  DzlShortcutController *controller;
+
+  controller = dzl_shortcut_controller_find (GTK_WIDGET (self));
+
+  dzl_shortcut_controller_add_command_action (controller,
+                                              I_("org.gnome.builder.workbench.fullscreen"),
+                                              "F11",
+                                              DZL_SHORTCUT_PHASE_DISPATCH | DZL_SHORTCUT_PHASE_GLOBAL,
+                                              I_("win.fullscreen"));
+
+  dzl_shortcut_controller_add_command_action (controller,
+                                              I_("org.gnome.builder.workbench.global-search"),
+                                              "<Control>period",
+                                              DZL_SHORTCUT_PHASE_CAPTURE | DZL_SHORTCUT_PHASE_GLOBAL,
+                                              I_("win.global-search"));
+
+  dzl_shortcut_controller_add_command_action (controller,
+                                              I_("org.gnome.builder.workbench.build"),
+                                              "<Control>F7",
+                                              DZL_SHORTCUT_PHASE_CAPTURE | DZL_SHORTCUT_PHASE_GLOBAL,
+                                              I_("build-manager.build"));
+}
diff --git a/libide/workbench/ide-workbench.c b/libide/workbench/ide-workbench.c
index bbae014..5ae9a35 100644
--- a/libide/workbench/ide-workbench.c
+++ b/libide/workbench/ide-workbench.c
@@ -262,6 +262,7 @@ ide_workbench_constructed (GObject *object)
     }
 
   ide_workbench_actions_init (self);
+  _ide_workbench_init_shortcuts (self);
 }
 
 static void


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