[gnome-builder] application: port to DzlShortcuts classes
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] application: port to DzlShortcuts classes
- Date: Tue, 15 Aug 2017 16:11:37 +0000 (UTC)
commit 57a9acfb0b74c04e1b3306b38c5e60b84258d229
Author: Sebastien Lafargue <slafargue gnome org>
Date: Sun Aug 13 23:23:50 2017 +0200
application: port to DzlShortcuts classes
libide/application/ide-application-actions.c | 19 ------
libide/application/ide-application-private.h | 1 +
libide/application/ide-application-shortcuts.c | 80 ++++++++++++++++++++++++
libide/application/ide-application.c | 1 +
libide/meson.build | 1 +
5 files changed, 83 insertions(+), 19 deletions(-)
---
diff --git a/libide/application/ide-application-actions.c b/libide/application/ide-application-actions.c
index 317c2bf..f78933b 100644
--- a/libide/application/ide-application-actions.c
+++ b/libide/application/ide-application-actions.c
@@ -416,28 +416,9 @@ static const GActionEntry IdeApplicationActions[] = {
void
ide_application_actions_init (IdeApplication *self)
{
- static const gchar *global_search[] = { "<control>period", NULL };
- static const gchar *new_file[] = { "<control>n", NULL };
- static const gchar *shortcuts[] = { "<control>F1", "<control><shift>question", NULL };
- static const gchar *help[] = { "F1", NULL };
- static const gchar *command_bar[] = { "<ctrl>Return", "<ctrl>KP_Enter", NULL };
- static const gchar *build[] = { "<ctrl>F7", NULL };
- static const gchar *fullscreen[] = { "F11", NULL };
-
g_action_map_add_action_entries (G_ACTION_MAP (self), IdeApplicationActions,
G_N_ELEMENTS (IdeApplicationActions), self);
- /*
- * FIXME: Once we get a new shortcuts engine, port these to that.
- */
- gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.help", help);
- gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.shortcuts", shortcuts);
- gtk_application_set_accels_for_action (GTK_APPLICATION (self), "perspective.new-file", new_file);
- gtk_application_set_accels_for_action (GTK_APPLICATION (self), "win.fullscreen", fullscreen);
- gtk_application_set_accels_for_action (GTK_APPLICATION (self), "win.global-search", global_search);
- gtk_application_set_accels_for_action (GTK_APPLICATION (self), "win.show-command-bar", command_bar);
- gtk_application_set_accels_for_action (GTK_APPLICATION (self), "build-manager.build", build);
-
ide_application_actions_update (self);
}
diff --git a/libide/application/ide-application-private.h b/libide/application/ide-application-private.h
index c7c5cf4..5ae77d4 100644
--- a/libide/application/ide-application-private.h
+++ b/libide/application/ide-application-private.h
@@ -80,6 +80,7 @@ void ide_application_open_async (IdeApplication *self
gboolean ide_application_open_finish (IdeApplication *self,
GAsyncResult *reuslt,
GError **error);
+void _ide_application_init_shortcuts (IdeApplication *self);
G_END_DECLS
diff --git a/libide/application/ide-application-shortcuts.c b/libide/application/ide-application-shortcuts.c
new file mode 100644
index 0000000..afbd604
--- /dev/null
+++ b/libide/application/ide-application-shortcuts.c
@@ -0,0 +1,80 @@
+/* ide-application-shortcuts.c
+ *
+ * Copyright (C) 2017 Sebastien Lafargue <slafargue 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define G_LOG_DOMAIN "ide-application-shortcuts"
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <dazzle.h>
+
+#include "ide-application-private.h"
+
+#define I_(s) (g_intern_static_string(s))
+
+void
+_ide_application_init_shortcuts (IdeApplication *self)
+{
+ DzlShortcutManager *manager;
+ DzlShortcutTheme *theme;
+
+ g_assert (IDE_IS_APPLICATION (self));
+
+ manager = dzl_application_get_shortcut_manager (DZL_APPLICATION (self));
+ theme = g_object_ref (dzl_shortcut_manager_get_theme (manager));
+
+ dzl_shortcut_manager_add_action (manager,
+ I_("app.help"),
+ N_("Workbench shortcuts"),
+ N_("Help"),
+ N_("Show the help window"),
+ NULL);
+ dzl_shortcut_theme_set_accel_for_action (theme, "app.help", "F1", DZL_SHORTCUT_PHASE_DISPATCH);
+
+ dzl_shortcut_manager_add_action (manager,
+ I_("app.shortcuts"),
+ N_("Workbench shortcuts"),
+ N_("Help"),
+ N_("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"),
+ N_("Workbench shortcuts"),
+ N_("General"),
+ N_("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"),
+ N_("Workbench shortcuts"),
+ N_("Search"),
+ N_("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"),
+ N_("Workbench shortcuts"),
+ N_("Build and Run"),
+ N_("Trigger a build"),
+ NULL);
+ dzl_shortcut_theme_set_accel_for_action (theme, "build-manager.build", "<Control>F7",
DZL_SHORTCUT_PHASE_DISPATCH);
+}
diff --git a/libide/application/ide-application.c b/libide/application/ide-application.c
index aa055b4..d37e025 100644
--- a/libide/application/ide-application.c
+++ b/libide/application/ide-application.c
@@ -387,6 +387,7 @@ ide_application_startup (GApplication *application)
ide_application_register_settings (self);
ide_application_register_keybindings (self);
ide_application_actions_init (self);
+ _ide_application_init_shortcuts (self);
modeline_parser_init ();
}
diff --git a/libide/meson.build b/libide/meson.build
index f032e9b..b9a4902 100644
--- a/libide/meson.build
+++ b/libide/meson.build
@@ -443,6 +443,7 @@ libide_sources = libide_generated_headers + libide_public_sources + [
'application/ide-application-command-line.c',
'application/ide-application-plugins.c',
'application/ide-application-private.h',
+ 'application/ide-application-shortcuts.c',
'application/ide-application-tests.c',
'application/ide-application-tests.h',
'buffers/ide-buffer-private.h',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]