[gnome-builder] source-view: disable <Return> accelerator from completion window



commit 93c3d916dcaee264de1d1bdf42fb087bd4f9ddfc
Author: Christian Hergert <christian hergert me>
Date:   Sat May 16 05:33:51 2015 -0700

    source-view: disable <Return> accelerator from completion window
    
    I've noticed a problem where completion proposals are getting activated
    when all you want to do is enter a newline. This results in having to
    hit escape a lot just to escape the autocompletion.
    
    Instead, we'll just rely on tab (and accelerators) to complete and make
    Return just add a new line.

 libide/ide-source-view.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index fa02a1c..2238b5f 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -5118,6 +5118,8 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
   GtkTextViewClass *text_view_class = GTK_TEXT_VIEW_CLASS (klass);
   GtkSourceViewClass *source_view_class = GTK_SOURCE_VIEW_CLASS (klass);
+  GtkBindingSet *binding_set;
+  GTypeClass *completion_class;
 
   object_class->constructed = ide_source_view_constructed;
   object_class->dispose = ide_source_view_dispose;
@@ -5828,6 +5830,17 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
                   NULL, NULL, NULL,
                   G_TYPE_NONE,
                   0);
+
+  /*
+   * <Return> while the completion window is displayed is actually really easy
+   * to accidentally activate. Therefore, we are switching to just Tab or the
+   * <Alt>Number accelerators. For example, "void<Return>" can easily activate
+   * search results like "voidfp" or "voidId".
+   */
+  completion_class = g_type_class_ref (GTK_SOURCE_TYPE_COMPLETION);
+  binding_set = gtk_binding_set_by_class (completion_class);
+  gtk_binding_entry_remove (binding_set, GDK_KEY_Return, 0);
+  g_type_class_unref (completion_class);
 }
 
 static void


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