[gnome-builder] preferences-editor: Add user-defined minimum word functionality



commit 9ae04886ca4ce9c80f98e9d526e816b3d82d24de
Author: Umang Jain <mailumangjain gmail com>
Date:   Thu Mar 30 09:09:23 2017 +0530

    preferences-editor: Add user-defined minimum word functionality
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780687

 .../gsettings/org.gnome.builder.editor.gschema.xml |    4 ++++
 libide/buffers/ide-buffer-manager.c                |   20 ++++++++++++++++++++
 libide/preferences/ide-preferences-builtin.c       |    1 +
 3 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/data/gsettings/org.gnome.builder.editor.gschema.xml 
b/data/gsettings/org.gnome.builder.editor.gschema.xml
index 864a41b..d6a5d72 100644
--- a/data/gsettings/org.gnome.builder.editor.gschema.xml
+++ b/data/gsettings/org.gnome.builder.editor.gschema.xml
@@ -69,6 +69,10 @@
       <range min="0" max="999"/>
       <default>0</default>
     </key>
+    <key name="minimum-word-size" type="i">
+      <range min="2" max="999"/>
+      <default>2</default>
+    </key>
     <key name="show-map" type="b">
       <default>false</default>
       <summary>Show overview map</summary>
diff --git a/libide/buffers/ide-buffer-manager.c b/libide/buffers/ide-buffer-manager.c
index f57cc78..2341319 100644
--- a/libide/buffers/ide-buffer-manager.c
+++ b/libide/buffers/ide-buffer-manager.c
@@ -109,6 +109,7 @@ enum {
   PROP_AUTO_SAVE,
   PROP_AUTO_SAVE_TIMEOUT,
   PROP_FOCUS_BUFFER,
+  PROP_MINIMUM_WORD_SIZE,
   LAST_PROP
 };
 
@@ -1320,6 +1321,10 @@ ide_buffer_manager_get_property (GObject    *object,
       g_value_set_object (value, ide_buffer_manager_get_focus_buffer (self));
       break;
 
+    case PROP_MINIMUM_WORD_SIZE:
+      g_object_get_property (G_OBJECT (self->word_completion), "minimum-word-size", value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -1347,6 +1352,10 @@ ide_buffer_manager_set_property (GObject      *object,
       ide_buffer_manager_set_focus_buffer (self, g_value_get_object (value));
       break;
 
+    case PROP_MINIMUM_WORD_SIZE:
+      g_object_set_property (G_OBJECT (self->word_completion), "minimum-word-size", value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -1385,6 +1394,15 @@ ide_buffer_manager_class_init (IdeBufferManagerClass *klass)
                          IDE_TYPE_BUFFER,
                          (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  properties [PROP_MINIMUM_WORD_SIZE] =
+    g_param_spec_uint ("minimum-word-size",
+                       "Minimum Word Size",
+                       "The minimum word size for word completion.",
+                       0,
+                       G_MAXUINT,
+                       0,
+                       (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
   g_object_class_install_properties (object_class, LAST_PROP, properties);
 
   /**
@@ -1551,6 +1569,8 @@ ide_buffer_manager_init (IdeBufferManager *self)
   self->timeouts = g_hash_table_new (g_direct_hash, g_direct_equal);
   self->word_completion = g_object_new (IDE_TYPE_COMPLETION_WORDS, NULL);
   self->settings = g_settings_new ("org.gnome.builder.editor");
+
+  g_settings_bind (self->settings, "minimum-word-size", self->word_completion, "minimum-word-size", 
G_SETTINGS_BIND_GET);
 }
 
 static void
diff --git a/libide/preferences/ide-preferences-builtin.c b/libide/preferences/ide-preferences-builtin.c
index f9e2333..c30504c 100644
--- a/libide/preferences/ide-preferences-builtin.c
+++ b/libide/preferences/ide-preferences-builtin.c
@@ -192,6 +192,7 @@ ide_preferences_builtin_register_code_insight (IdePreferences *preferences)
 
   ide_preferences_add_list_group (preferences, "code-insight", "completion", _("Completion"), 
GTK_SELECTION_NONE, 100);
   ide_preferences_add_switch (preferences, "code-insight", "completion", "org.gnome.builder.code-insight", 
"word-completion", NULL, NULL, _("Suggest words found in open files"), _("Suggests completions as you type 
based on words found in any open document"), NULL, 0);
+  ide_preferences_add_spin_button (preferences, "code-insight", "completion", "org.gnome.builder.editor", 
"minimum-word-size", NULL, _("Minimum word size"), _("Minimum word size for word completion"), NULL, 5);
   ide_preferences_add_switch (preferences, "code-insight", "completion", "org.gnome.builder.code-insight", 
"ctags-autocompletion", NULL, NULL, _("Suggest completions using Ctags"), _("Create and manages a Ctags 
database for completing class names, functions, and more"), NULL, 10);
   ide_preferences_add_switch (preferences, "code-insight", "completion", "org.gnome.builder.code-insight", 
"clang-autocompletion", NULL, NULL, _("Suggest completions using Clang (Experimental)"), _("Use Clang to 
suggest completions for C and C++ languages"), NULL, 20);
 


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