[gnome-builder] vim: keep focus on original widget when adding splits from vim



commit bc46a31c7cad99c9b59d34fcf45c703eb6769b56
Author: Christian Hergert <christian hergert me>
Date:   Tue Jan 20 21:34:22 2015 -0800

    vim: keep focus on original widget when adding splits from vim

 src/editor/gb-editor-view.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-view.c b/src/editor/gb-editor-view.c
index edc9376..1ff381e 100644
--- a/src/editor/gb-editor-view.c
+++ b/src/editor/gb-editor-view.c
@@ -670,15 +670,20 @@ gb_editor_view_on_vim_split (GbEditorView     *self,
                              GbSourceVimSplit  split,
                              GbSourceVim      *vim)
 {
+  GtkWidget *toplevel;
+  GtkWidget *focus = NULL;
   gboolean ret = FALSE;
 
   g_return_val_if_fail (GB_IS_EDITOR_VIEW (self), FALSE);
   g_return_val_if_fail (split, FALSE);
   g_return_val_if_fail (GB_IS_SOURCE_VIM (vim), FALSE);
 
+  toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
+
   switch (split)
     {
     case GB_SOURCE_VIM_SPLIT_HORIZONTAL:
+      focus = gtk_window_get_focus (GTK_WINDOW (toplevel));
       if (!gb_editor_view_get_split_enabled (self))
         {
           gb_editor_view_toggle_split (self);
@@ -687,6 +692,7 @@ gb_editor_view_on_vim_split (GbEditorView     *self,
       break;
 
     case GB_SOURCE_VIM_SPLIT_VERTICAL:
+      focus = gtk_window_get_focus (GTK_WINDOW (toplevel));
       gb_widget_activate_action (GTK_WIDGET (self),
                                  "stack", "split-document-right",
                                  NULL);
@@ -737,6 +743,9 @@ gb_editor_view_on_vim_split (GbEditorView     *self,
       break;
     }
 
+  if (focus)
+    gtk_widget_grab_focus (focus);
+
   return ret;
 }
 


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