[gnome-builder] split and vim



commit 1570c255710797a019977a814ae4761d2e620c2c
Author: Christian Hergert <christian hergert me>
Date:   Wed Mar 18 19:33:58 2015 -0700

    split and vim

 data/keybindings/vim.css          |   23 +++++++++++++++++++++++
 src/views/gb-view-stack-actions.c |   24 +++++++++++++++++++++++-
 2 files changed, 46 insertions(+), 1 deletions(-)
---
diff --git a/data/keybindings/vim.css b/data/keybindings/vim.css
index a40dcf7..3a2c0cc 100644
--- a/data/keybindings/vim.css
+++ b/data/keybindings/vim.css
@@ -444,6 +444,9 @@
   /* navigation */
   bind "<ctrl>o" { "action" ("navigation", "go-backward", "") };
   bind "<ctrl>i" { "action" ("navigation", "go-forward", "") };
+
+  /* window controls */
+  bind "<ctrl>w" { "set-mode" ("vim-normal-ctrl-w", transient) };
 }
 
 @binding-set builder-vim-source-view-normal-bracket
@@ -891,6 +894,17 @@
   bind "q" { "begin-macro" () };
 }
 
+ binding-set builder-vim-source-view-normal-ctrl-w
+{
+  bind "v" { "action" ("view", "split-left", "") "grab_focus" () };
+  bind "<ctrl>v" { "action" ("view", "split-left", "") "grab_focus" () };
+
+  bind "c" { "action" ("view", "close", "") };
+  bind "<ctrl>c" { "action" ("view", "close", "") };
+
+  bind "s" { "action" ("view", "split-down", "true") };
+}
+
 @binding-set builder-vim-source-view-visual-line-g
 {
   bind "g" { "movement" (first-line, 1, 1, 0)
@@ -1345,6 +1359,15 @@ IdeSourceViewMode.vim-normal-indent {
                     builder-vim-source-view-normal-indent;
 }
 
+IdeSourceViewMode.vim-normal-ctrl-w {
+  -IdeSourceViewMode-suppress-unbound: true;
+  -IdeSourceViewMode-coalesce-undo: true;
+  -IdeSourceViewMode-block-cursor: true;
+
+  gtk-key-bindings: builder-vim-source-view,
+                    builder-vim-source-view-normal-ctrl-w;
+}
+
 IdeSourceViewMode.vim-normal-y {
   -IdeSourceViewMode-suppress-unbound: true;
   -IdeSourceViewMode-coalesce-undo: true;
diff --git a/src/views/gb-view-stack-actions.c b/src/views/gb-view-stack-actions.c
index 3b464df..1661544 100644
--- a/src/views/gb-view-stack-actions.c
+++ b/src/views/gb-view-stack-actions.c
@@ -25,10 +25,26 @@
 #include "gb-view-stack-private.h"
 
 static void
+gb_view_stack_actions_close_cb (GObject      *object,
+                                GAsyncResult *result,
+                                gpointer      user_data)
+{
+  GbViewStack *self = (GbViewStack *)object;
+  g_autoptr(GbView) view = user_data;
+
+  g_assert (GB_IS_VIEW_STACK (self));
+  g_assert (GB_IS_VIEW (view));
+
+  gb_view_stack_remove (self, view);
+}
+
+
+static void
 gb_view_stack_actions_close (GSimpleAction *action,
                              GVariant      *param,
                              gpointer       user_data)
 {
+  g_autoptr(GTask) task = NULL;
   GbViewStack *self = user_data;
   GtkWidget *active_view;
 
@@ -38,7 +54,13 @@ gb_view_stack_actions_close (GSimpleAction *action,
   if (active_view == NULL || !GB_IS_VIEW (active_view))
     return;
 
-  gb_view_stack_remove (self, GB_VIEW (active_view));
+
+  /*
+   * Queue until we are out of this potential signalaction. (Which mucks things
+   * up since it expects the be able to continue working with the widget).
+   */
+  task = g_task_new (self, NULL, gb_view_stack_actions_close_cb, g_object_ref (active_view));
+  g_task_return_boolean (task, TRUE);
 }
 
 static void


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