[gnome-builder/wip/chergert/shortcuts: 1339/1339] wip



commit 90b8ac8d8771b5edbfa7e13c64ee7bc0eae926ac
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jun 15 01:17:21 2017 -0700

    wip

 data/shortcuts/default.keytheme              |    6 ++++
 data/shortcuts/emacs.keytheme                |    5 +++
 data/shortcuts/vim.keytheme                  |    6 ++++
 libide/application/ide-application-actions.c |    9 +++++-
 libide/application/ide-application.c         |   28 +++++++++++++++++---
 libide/preferences/ide-preferences-builtin.c |   10 +++++++
 libide/resources/libide.gresource.xml        |    6 ++++
 libide/workbench/ide-workbench-shortcuts.h   |   35 ++++++++++++++++++++++++++
 libide/workbench/ide-workbench.c             |    9 ++++++
 9 files changed, 107 insertions(+), 7 deletions(-)
---
diff --git a/data/shortcuts/default.keytheme b/data/shortcuts/default.keytheme
new file mode 100644
index 0000000..b18c2ec
--- /dev/null
+++ b/data/shortcuts/default.keytheme
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<theme name="default">
+  <property name="title">Builder</property>
+  <property name="subtitle" translatable="yes">Builder's default keyboard shortcuts which mimic 
Gedit</property>
+
+</theme>
diff --git a/data/shortcuts/emacs.keytheme b/data/shortcuts/emacs.keytheme
new file mode 100644
index 0000000..d2499e6
--- /dev/null
+++ b/data/shortcuts/emacs.keytheme
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<theme name="emacs">
+  <property name="title">Emacs</property>
+  <property name="subtitle" translatable="yes">Emulates the Emacs text editor</property>
+</theme>
diff --git a/data/shortcuts/vim.keytheme b/data/shortcuts/vim.keytheme
new file mode 100644
index 0000000..203c5a4
--- /dev/null
+++ b/data/shortcuts/vim.keytheme
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<theme name="vim">
+  <property name="title">Vim</property>
+  <property name="subtitle" translatable="yes">Emulates the Vim text editor</property>
+
+</theme>
diff --git a/libide/application/ide-application-actions.c b/libide/application/ide-application-actions.c
index acccd32..9ee5797 100644
--- a/libide/application/ide-application-actions.c
+++ b/libide/application/ide-application-actions.c
@@ -300,19 +300,22 @@ ide_application_actions_shortcuts (GSimpleAction *action,
                                    gpointer       user_data)
 {
   IdeApplication *self = user_data;
+  DzlShortcutManager *manager;
   GtkWindow *window;
   GtkWindow *parent = NULL;
   GList *list;
 
   g_assert (IDE_IS_APPLICATION (self));
 
+  manager = dzl_application_get_shortcut_manager (DZL_APPLICATION (self));
+
   list = gtk_application_get_windows (GTK_APPLICATION (self));
 
   for (; list; list = list->next)
     {
       window = list->data;
 
-      if (IDE_IS_SHORTCUTS_WINDOW (window))
+      if (DZL_IS_SHORTCUTS_WINDOW (window))
         {
           gtk_window_present (window);
           return;
@@ -325,12 +328,14 @@ ide_application_actions_shortcuts (GSimpleAction *action,
         }
     }
 
-  window = g_object_new (IDE_TYPE_SHORTCUTS_WINDOW,
+  window = g_object_new (DZL_TYPE_SHORTCUTS_WINDOW,
                          "application", self,
                          "window-position", GTK_WIN_POS_CENTER,
                          "transient-for", parent,
                          NULL);
 
+  dzl_shortcut_manager_add_shortcuts_to_window (manager, DZL_SHORTCUTS_WINDOW (window));
+
   gtk_window_present (GTK_WINDOW (window));
 }
 
diff --git a/libide/application/ide-application.c b/libide/application/ide-application.c
index cc8d60d..66f58cc 100644
--- a/libide/application/ide-application.c
+++ b/libide/application/ide-application.c
@@ -94,15 +94,26 @@ ide_application_register_keybindings (IdeApplication *self)
 {
   g_autoptr(GSettings) settings = NULL;
   g_autofree gchar *name = NULL;
+  DzlShortcutManager *shortcuts;
+  guint n_themes;
 
   IDE_ENTRY;
 
   g_assert (IDE_IS_APPLICATION (self));
 
+  shortcuts = dzl_application_get_shortcut_manager (DZL_APPLICATION (self));
+
+  /* Log the themes we discovered to aide in debugging. */
+  n_themes = g_list_model_get_n_items (G_LIST_MODEL (shortcuts));
+  for (guint i = 0; i < n_themes; i++)
+    {
+      g_autoptr(DzlShortcutTheme) theme = g_list_model_get_item (G_LIST_MODEL (shortcuts), i);
+      g_debug ("Found shortcut theme ā€œ%sā€", dzl_shortcut_theme_get_name (theme));
+    }
+
+  /* Now bind our GSetting to the particular setting */
   settings = g_settings_new ("org.gnome.builder.editor");
-  name = g_settings_get_string (settings, "keybindings");
-  self->keybindings = ide_keybindings_new (GTK_APPLICATION (self), name);
-  g_settings_bind (settings, "keybindings", self->keybindings, "mode", G_SETTINGS_BIND_GET);
+  g_settings_bind (settings, "keybindings", shortcuts, "theme-name", G_SETTINGS_BIND_GET);
 
   IDE_EXIT;
 }
@@ -361,7 +372,6 @@ ide_application_startup (GApplication *application)
       ide_application_make_skeleton_dirs (self);
       ide_language_defaults_init_async (NULL, ide_application_language_defaults_cb, NULL);
       ide_application_register_settings (self);
-      ide_application_register_keybindings (self);
       ide_application_actions_init (self);
 
       modeline_parser_init ();
@@ -372,7 +382,15 @@ ide_application_startup (GApplication *application)
   G_APPLICATION_CLASS (ide_application_parent_class)->startup (application);
 
   if (self->mode == IDE_APPLICATION_MODE_PRIMARY)
-    ide_application_register_plugin_accessories (self);
+    {
+      /*
+       * These need to be registered after chaining up to the
+       * DzlApplication::startup() so that all of the other resources have been
+       * properly loaded.
+       */
+      ide_application_register_keybindings (self);
+      ide_application_register_plugin_accessories (self);
+    }
 
   ide_application_load_addins (self);
 }
diff --git a/libide/preferences/ide-preferences-builtin.c b/libide/preferences/ide-preferences-builtin.c
index 87e485a..d55cc3a 100644
--- a/libide/preferences/ide-preferences-builtin.c
+++ b/libide/preferences/ide-preferences-builtin.c
@@ -134,6 +134,8 @@ ide_preferences_builtin_register_appearance (DzlPreferences *preferences)
 static void
 ide_preferences_builtin_register_keyboard (DzlPreferences *preferences)
 {
+  GtkWidget *editor;
+
   dzl_preferences_add_page (preferences, "keyboard", _("Keyboard"), 400);
 
   dzl_preferences_add_list_group (preferences, "keyboard", "mode", _("Emulation"), GTK_SELECTION_NONE, 0);
@@ -144,6 +146,14 @@ ide_preferences_builtin_register_keyboard (DzlPreferences *preferences)
   dzl_preferences_add_list_group (preferences, "keyboard", "movements", _("Movement"), GTK_SELECTION_NONE, 
100);
   dzl_preferences_add_switch (preferences, "keyboard", "movements", "org.gnome.builder.editor", 
"smart-home-end", NULL, NULL, _("Smart Home and End"), _("Home moves to first non-whitespace character"), 
NULL, 0);
   dzl_preferences_add_switch (preferences, "keyboard", "movements", "org.gnome.builder.editor", 
"smart-backspace", NULL, NULL, _("Smart Backspace"), _("Backspace will remove extra space to keep you aligned 
with your indentation"), NULL, 100);
+
+  dzl_preferences_add_group (preferences, "keyboard", "editing", NULL, 200);
+
+  /* add our shortcut editing widget */
+  editor = dzl_shortcut_theme_editor_new ();
+  g_object_bind_property (dzl_shortcut_manager_get_default(), "theme", editor, "theme", 
G_BINDING_SYNC_CREATE);
+  gtk_widget_show (editor);
+  dzl_preferences_add_custom (preferences, "keyboard", "editing", GTK_WIDGET (editor), NULL, 0);
 }
 
 static void
diff --git a/libide/resources/libide.gresource.xml b/libide/resources/libide.gresource.xml
index 2b79289..9110731 100644
--- a/libide/resources/libide.gresource.xml
+++ b/libide/resources/libide.gresource.xml
@@ -49,6 +49,12 @@
     <file compressed="true" alias="vim.css">../../data/keybindings/vim.css</file>
   </gresource>
 
+  <gresource prefix="/org/gnome/builder/shortcuts">
+    <file compressed="true" alias="default.keytheme">../../data/shortcuts/default.keytheme</file>
+    <file compressed="true" alias="emacs.keytheme">../../data/shortcuts/emacs.keytheme</file>
+    <file compressed="true" alias="vim.keytheme">../../data/shortcuts/vim.keytheme</file>
+  </gresource>
+
   <gresource prefix="/org/gnome/builder/ui">
     <file compressed="true" alias="ide-editor-frame.ui">../editor/ide-editor-frame.ui</file>
     <file compressed="true" 
alias="ide-editor-layout-stack-controls.ui">../editor/ide-editor-layout-stack-controls.ui</file>
diff --git a/libide/workbench/ide-workbench-shortcuts.h b/libide/workbench/ide-workbench-shortcuts.h
new file mode 100644
index 0000000..33b4f7d
--- /dev/null
+++ b/libide/workbench/ide-workbench-shortcuts.h
@@ -0,0 +1,35 @@
+/* ide-workbench-shortcuts.h
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * 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/>.
+ */
+
+#ifndef IDE_WORKBENCH_SHORTCUTS_H
+#define IDE_WORKBENCH_SHORTCUTS_H
+
+#include <dazzle.h>
+
+G_BEGIN_DECLS
+
+static const DzlShortcutEntry ide_workbench_shortcuts[] = {
+  { "org.gnome.Builder.Shortcuts",  "<Primary><Shift>question", N_("Application"), N_("Application"), 
N_("Keyboard Shortcuts") },
+  { "org.gnome.Builder.Help",       "F1",                       N_("Application"), N_("Application"), 
N_("Help") },
+  { "org.gnome.Builder.About",      "<Shift>F1",                N_("Application"), N_("Application"), 
N_("About") },
+  { "org.gnome.Builder.Quit",       "<Primary>q",               N_("Application"), N_("Application"), 
N_("Quit") },
+};
+
+G_END_DECLS
+
+#endif /* IDE_WORKBENCH_SHORTCUTS_H */
diff --git a/libide/workbench/ide-workbench.c b/libide/workbench/ide-workbench.c
index fe803ff..4f2db5e 100644
--- a/libide/workbench/ide-workbench.c
+++ b/libide/workbench/ide-workbench.c
@@ -18,6 +18,9 @@
 
 #define G_LOG_DOMAIN "ide-workbench"
 
+#include "config.h"
+
+#include <dazzle.h>
 #include <glib/gi18n.h>
 
 #include "ide-debug.h"
@@ -37,6 +40,7 @@
 #include "workbench/ide-workbench-addin.h"
 #include "workbench/ide-workbench-header-bar.h"
 #include "workbench/ide-workbench-private.h"
+#include "workbench/ide-workbench-shortcuts.h"
 #include "workbench/ide-workbench.h"
 
 #define STABLIZE_DELAY_MSEC 50
@@ -421,6 +425,11 @@ ide_workbench_init (IdeWorkbench *self)
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
+  dzl_shortcut_manager_add_shortcut_entries (NULL,
+                                             ide_workbench_shortcuts,
+                                             G_N_ELEMENTS (ide_workbench_shortcuts),
+                                             GETTEXT_PACKAGE);
+
   self->perspectives = g_list_store_new (IDE_TYPE_PERSPECTIVE);
 
   ide_window_settings_register (GTK_WINDOW (self));


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