[gnome-builder] ctrl w split keybindings and such



commit cce5e5556b7e01ea081f99b360d23cc46e6bf557
Author: Christian Hergert <christian hergert me>
Date:   Wed Mar 18 23:31:30 2015 -0700

    ctrl w split keybindings and such

 data/keybindings/vim.css            |    6 ++--
 src/editor/gb-editor-view-actions.c |   47 +++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 3 deletions(-)
---
diff --git a/data/keybindings/vim.css b/data/keybindings/vim.css
index 36b94eb..4f96c30 100644
--- a/data/keybindings/vim.css
+++ b/data/keybindings/vim.css
@@ -899,10 +899,10 @@
   bind "v" { "action" ("view-stack", "split-left", "") "grab_focus" () };
   bind "<ctrl>v" { "action" ("view-stack", "split-left", "") "grab_focus" () };
 
-  bind "c" { "action" ("view-stack", "close", "") };
-  bind "<ctrl>c" { "action" ("view-stack", "close", "") };
+  bind "c" { "action" ("view", "close", "") };
+  bind "<ctrl>c" { "action" ("view", "close", "") };
 
-  bind "s" { "action" ("view-stack", "split-down", "true") };
+  bind "s" { "action" ("view", "toggle-split", "") };
 }
 
 @binding-set builder-vim-source-view-visual-line-g
diff --git a/src/editor/gb-editor-view-actions.c b/src/editor/gb-editor-view-actions.c
index cee477b..db9f7b6 100644
--- a/src/editor/gb-editor-view-actions.c
+++ b/src/editor/gb-editor-view-actions.c
@@ -226,16 +226,63 @@ gb_editor_view_actions_save (GSimpleAction *action,
   g_clear_object (&progress);
 }
 
+static gboolean
+set_split_view (gpointer data)
+{
+  g_autoptr(GbEditorView) self = data;
+
+  g_assert (GB_IS_EDITOR_VIEW (self));
+
+  gb_view_set_split_view (GB_VIEW (self), (self->frame2 == NULL));
+
+  return G_SOURCE_REMOVE;
+}
+
+static void
+gb_editor_view_actions_toggle_split (GSimpleAction *action,
+                                     GVariant      *param,
+                                     gpointer       user_data)
+{
+  GbEditorView *self = user_data;
+
+  g_assert (GB_IS_EDITOR_VIEW (self));
+
+  g_timeout_add (0, set_split_view, g_object_ref (self));
+}
+
+static void
+gb_editor_view_actions_close (GSimpleAction *action,
+                              GVariant      *param,
+                              gpointer       user_data)
+{
+  GbEditorView *self = user_data;
+
+  g_assert (GB_IS_EDITOR_VIEW (self));
+
+  /* just close our current frame if we have split view */
+  if (self->frame2 != NULL)
+    {
+      /* todo: swap frame1/frame2 if frame2 was last focused. */
+      g_timeout_add (0, set_split_view, g_object_ref (self));
+    }
+  else
+    {
+      gb_widget_activate_action (GTK_WIDGET (self), "view-stack", "close", NULL);
+    }
+}
+
 static GActionEntry GbEditorViewActions[] = {
   { "auto-indent", NULL, NULL, "false", gb_editor_view_actions_auto_indent },
   { "language", NULL, "s", "''", gb_editor_view_actions_language },
   { "highlight-current-line", NULL, NULL, "false", gb_editor_view_actions_highlight_current_line },
+  { "close", gb_editor_view_actions_close },
   { "save", gb_editor_view_actions_save },
   { "show-line-numbers", NULL, NULL, "false", gb_editor_view_actions_show_line_numbers },
   { "show-right-margin", NULL, NULL, "false", gb_editor_view_actions_show_right_margin },
   { "smart-backspace", NULL, NULL, "false", gb_editor_view_actions_smart_backspace },
   { "tab-width", NULL, "i", "8", gb_editor_view_actions_tab_width },
   { "use-spaces", NULL, "b", "false", gb_editor_view_actions_use_spaces },
+  { "toggle-split", gb_editor_view_actions_toggle_split },
 };
 
 void


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