[gnome-builder/wip/gtk4-port] libide/editor: add setting for selecting first completion



commit e82a5c0bd05f4dd40783d820246c2fa09726babc
Author: Christian Hergert <chergert redhat com>
Date:   Wed Apr 20 14:45:55 2022 -0700

    libide/editor: add setting for selecting first completion
    
    Having a toggle to avoid selecting the first item can be nice in situations
    where users feel they are over activating results when unnecessary.

 data/gsettings/org.gnome.builder.editor.gschema.xml | 5 +++++
 src/libide/editor/ide-editor-page-settings.c        | 6 ++++++
 2 files changed, 11 insertions(+)
---
diff --git a/data/gsettings/org.gnome.builder.editor.gschema.xml 
b/data/gsettings/org.gnome.builder.editor.gschema.xml
index a17450495..945229b35 100644
--- a/data/gsettings/org.gnome.builder.editor.gschema.xml
+++ b/data/gsettings/org.gnome.builder.editor.gschema.xml
@@ -149,5 +149,10 @@
       <summary>Enable Snippets</summary>
       <description>Allow expanding snippets from the editor by pressing tab after the snippet 
trigger.</description>
     </key>
+    <key name="select-first-completion" type="b">
+      <default>true</default>
+      <summary>Select First Completion</summary>
+      <description>Automatically select the first auto-completion entry.</description>
+    </key>
   </schema>
 </schemalist>
diff --git a/src/libide/editor/ide-editor-page-settings.c b/src/libide/editor/ide-editor-page-settings.c
index d466b2d9b..2e24dfdd1 100644
--- a/src/libide/editor/ide-editor-page-settings.c
+++ b/src/libide/editor/ide-editor-page-settings.c
@@ -126,6 +126,7 @@ void
 _ide_editor_page_settings_init (IdeEditorPage *self)
 {
   static GSettings *editor_settings;
+  GtkSourceCompletion *completion;
 
   IDE_ENTRY;
 
@@ -193,6 +194,11 @@ _ide_editor_page_settings_init (IdeEditorPage *self)
                                 font_name_to_font_desc,
                                 NULL, NULL, NULL);
 
+  completion = gtk_source_view_get_completion (GTK_SOURCE_VIEW (self->view));
+  g_settings_bind (editor_settings, "select-first-completion",
+                   completion, "select-on-show",
+                   G_SETTINGS_BIND_GET);
+
 #if 0
   ide_binding_group_bind (self->view_file_settings,
                           "insert-matching-brace", self->view, "insert-matching-brace",


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