[gnome-builder] workbench: move workbench shortcuts



commit 4e7c2afc9e80e81f152d557ff237b06de003161e
Author: Christian Hergert <chergert redhat com>
Date:   Sat Nov 18 00:18:04 2017 -0800

    workbench: move workbench shortcuts
    
    These should be defined on the workbench controller, with other
    workbench shortcut setup.

 src/libide/application/ide-application-shortcuts.c |   30 +----------
 src/libide/workbench/ide-workbench-private.h       |    1 +
 src/libide/workbench/ide-workbench-shortcuts.c     |   55 ++++++++++++++++++++
 src/libide/workbench/ide-workbench.c               |    1 +
 4 files changed, 60 insertions(+), 27 deletions(-)
---
diff --git a/src/libide/application/ide-application-shortcuts.c 
b/src/libide/application/ide-application-shortcuts.c
index befa1f5..00961ae 100644
--- a/src/libide/application/ide-application-shortcuts.c
+++ b/src/libide/application/ide-application-shortcuts.c
@@ -44,7 +44,7 @@ _ide_application_init_shortcuts (IdeApplication *self)
                                    NC_("shortcut window", "Help"),
                                    NC_("shortcut window", "Show the help window"),
                                    NULL);
-  dzl_shortcut_theme_set_accel_for_action (theme, "app.help", "F1", DZL_SHORTCUT_PHASE_DISPATCH);
+  dzl_shortcut_theme_set_accel_for_action (theme, "app.help", "F1", DZL_SHORTCUT_PHASE_GLOBAL);
 
   dzl_shortcut_manager_add_action (manager,
                                    I_("app.preferences"),
@@ -52,7 +52,7 @@ _ide_application_init_shortcuts (IdeApplication *self)
                                    NC_("shortcut window", "Preferences"),
                                    NC_("shortcut window", "Show the preferences window"),
                                    NULL);
-  dzl_shortcut_theme_set_accel_for_action (theme, "app.preferences", "<Primary>comma", 
DZL_SHORTCUT_PHASE_DISPATCH);
+  dzl_shortcut_theme_set_accel_for_action (theme, "app.preferences", "<Primary>comma", 
DZL_SHORTCUT_PHASE_GLOBAL);
 
   dzl_shortcut_manager_add_action (manager,
                                    I_("app.shortcuts"),
@@ -60,29 +60,5 @@ _ide_application_init_shortcuts (IdeApplication *self)
                                    NC_("shortcut window", "Help"),
                                    NC_("shortcut window", "Show the shortcuts window"),
                                    NULL);
-  dzl_shortcut_theme_set_accel_for_action (theme, "app.shortcuts", "<Primary>F1", 
DZL_SHORTCUT_PHASE_DISPATCH);
-
-  dzl_shortcut_manager_add_action (manager,
-                                   I_("win.fullscreen"),
-                                   NC_("shortcut window", "Workbench shortcuts"),
-                                   NC_("shortcut window", "General"),
-                                   NC_("shortcut window", "Toggle window to fullscreen"),
-                                   NULL);
-  dzl_shortcut_theme_set_accel_for_action (theme, "win.fullscreen", "F11", DZL_SHORTCUT_PHASE_DISPATCH);
-
-  dzl_shortcut_manager_add_action (manager,
-                                   I_("win.global-search"),
-                                   NC_("shortcut window", "Workbench shortcuts"),
-                                   NC_("shortcut window", "Search"),
-                                   NC_("shortcut window", "Focus to the global search entry"),
-                                   NULL);
-  dzl_shortcut_theme_set_accel_for_action (theme, "win.global-search", "<Primary>period", 
DZL_SHORTCUT_PHASE_DISPATCH);
-
-  dzl_shortcut_manager_add_action (manager,
-                                   I_("build-manager.build"),
-                                   NC_("shortcut window", "Workbench shortcuts"),
-                                   NC_("shortcut window", "Build and Run"),
-                                   NC_("shortcut window", "Trigger a build"),
-                                   NULL);
-  dzl_shortcut_theme_set_accel_for_action (theme, "build-manager.build", "<Control>F7", 
DZL_SHORTCUT_PHASE_DISPATCH);
+  dzl_shortcut_theme_set_accel_for_action (theme, "app.shortcuts", "<Primary>F1", DZL_SHORTCUT_PHASE_GLOBAL);
 }
diff --git a/src/libide/workbench/ide-workbench-private.h b/src/libide/workbench/ide-workbench-private.h
index d821d21..a0e5d74 100644
--- a/src/libide/workbench/ide-workbench-private.h
+++ b/src/libide/workbench/ide-workbench-private.h
@@ -61,5 +61,6 @@ 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/src/libide/workbench/ide-workbench-shortcuts.c b/src/libide/workbench/ide-workbench-shortcuts.c
index 33c1c58..54078ff 100644
--- a/src/libide/workbench/ide-workbench-shortcuts.c
+++ b/src/libide/workbench/ide-workbench-shortcuts.c
@@ -25,6 +25,28 @@
 
 #include "workbench/ide-workbench-private.h"
 
+#define I_(s) (g_intern_static_string(s))
+
+static DzlShortcutEntry workbench_shortcuts[] = {
+  { "org.gnome.builder.workbench.fullscreen",
+    0, NULL,
+    NC_("shortcut window", "Workbench shortcuts"),
+    NC_("shortcut window", "General"),
+    NC_("shortcut window", "Toggle window to fullscreen") },
+
+  { "org.gnome.builder.workbench.global-search",
+    0, NULL,
+    NC_("shortcut window", "Workbench shortcuts"),
+    NC_("shortcut window", "Search"),
+    NC_("shortcut window", "Focus to the global search entry") },
+
+  { "org.gnome.builder.workbench.build",
+    0, NULL,
+    NC_("shortcut window", "Workbench shortcuts"),
+    NC_("shortcut window", "Build and Run"),
+    NC_("shortcut window", "Trigger a build") },
+};
+
 void
 _ide_workbench_add_perspective_shortcut (IdeWorkbench   *self,
                                          IdePerspective *perspective)
@@ -35,6 +57,7 @@ _ide_workbench_add_perspective_shortcut (IdeWorkbench   *self,
   g_assert (IDE_IS_PERSPECTIVE (perspective));
 
   accel = ide_perspective_get_accelerator (perspective);
+
   if (accel != NULL)
     {
       DzlShortcutController *controller;
@@ -52,6 +75,7 @@ _ide_workbench_add_perspective_shortcut (IdeWorkbench   *self,
       };
 
       controller = dzl_shortcut_controller_find (GTK_WIDGET (self));
+
       dzl_shortcut_controller_add_command_action (controller,
                                                   command_id,
                                                   accel,
@@ -64,3 +88,34 @@ _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_DISPATCH | 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_DISPATCH | DZL_SHORTCUT_PHASE_GLOBAL,
+                                              I_("build-manager.build"));
+
+  dzl_shortcut_manager_add_shortcut_entries (NULL,
+                                             workbench_shortcuts,
+                                             G_N_ELEMENTS (workbench_shortcuts),
+                                             GETTEXT_PACKAGE);
+}
diff --git a/src/libide/workbench/ide-workbench.c b/src/libide/workbench/ide-workbench.c
index e9385ae..d9356e3 100644
--- a/src/libide/workbench/ide-workbench.c
+++ b/src/libide/workbench/ide-workbench.c
@@ -266,6 +266,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]