[gnome-builder/wip/completion-words: 2/2] editor: wire a preference switch for word completion



commit 9534e57a851fdecbfb0886de96d2acfcdcaf3bc3
Author: Christian Hergert <christian hergert me>
Date:   Fri Oct 10 16:51:23 2014 -0700

    editor: wire a preference switch for word completion

 data/org.gnome.builder.editor.gschema.xml.in |    5 +++++
 src/preferences/gb-preferences-window.c      |   12 +++++++++++-
 src/resources/ui/gb-preferences-window.ui    |   26 ++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 1 deletions(-)
---
diff --git a/data/org.gnome.builder.editor.gschema.xml.in b/data/org.gnome.builder.editor.gschema.xml.in
index 200f987..c89de51 100644
--- a/data/org.gnome.builder.editor.gschema.xml.in
+++ b/data/org.gnome.builder.editor.gschema.xml.in
@@ -11,5 +11,10 @@
       <summary>Jump to the last position when reopening a file.</summary>
       <description>Whether or not VIM style keybindings should be used in the source code 
editor.</description>
     </key>
+    <key name="word-completion" type="b">
+      <default>true</default>
+      <summary>Enable auto-completion of words in document.</summary>
+      <description>If enabled, words within the current document will be available for 
auto-completion.</description>
+    </key>
   </schema>
 </schemalist>
diff --git a/src/preferences/gb-preferences-window.c b/src/preferences/gb-preferences-window.c
index afef37a..2b1ea10 100644
--- a/src/preferences/gb-preferences-window.c
+++ b/src/preferences/gb-preferences-window.c
@@ -35,8 +35,9 @@ struct _GbPreferencesWindowPrivate
   GtkSearchBar    *search_bar;
   GtkStack        *stack;
 
-  GtkSwitch       *vim_switch;
   GtkSwitch       *restore_insert_mark_switch;
+  GtkSwitch       *vim_switch;
+  GtkSwitch       *word_completion_switch;
 
   GtkEntry        *git_author_name_entry;
   GtkEntry        *git_author_email_entry;
@@ -91,6 +92,9 @@ load_editor (GbPreferencesWindow *window)
   g_settings_bind (settings, "restore-insert-mark",
                    priv->restore_insert_mark_switch, "active",
                    G_SETTINGS_BIND_DEFAULT);
+  g_settings_bind (settings, "word-completion",
+                   priv->word_completion_switch, "active",
+                   G_SETTINGS_BIND_DEFAULT);
 
   g_object_unref (settings);
 }
@@ -107,6 +111,11 @@ load_git (GbPreferencesWindow *window)
   if (!config)
     return;
 
+  /*
+   * TODO: These should be bound to a config wrapper object that will sync
+   *       the values back to the underlying config.
+   */
+
   value = ggit_config_get_string (config, "user.name", NULL);
   if (value)
     gtk_entry_set_text (window->priv->git_author_name_entry, value);
@@ -192,6 +201,7 @@ gb_preferences_window_class_init (GbPreferencesWindowClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, GbPreferencesWindow, search_entry);
   gtk_widget_class_bind_template_child_private (widget_class, GbPreferencesWindow, stack);
   gtk_widget_class_bind_template_child_private (widget_class, GbPreferencesWindow, vim_switch);
+  gtk_widget_class_bind_template_child_private (widget_class, GbPreferencesWindow, word_completion_switch);
 
   g_type_ensure (GB_TYPE_SIDEBAR);
 }
diff --git a/src/resources/ui/gb-preferences-window.ui b/src/resources/ui/gb-preferences-window.ui
index a3487af..5034dd5 100644
--- a/src/resources/ui/gb-preferences-window.ui
+++ b/src/resources/ui/gb-preferences-window.ui
@@ -162,6 +162,32 @@
                     <property name="height">1</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkLabel" id="word_completion_label">
+                    <property name="visible">True</property>
+                    <property name="halign">start</property>
+                    <property name="hexpand">True</property>
+                    <property name="label" translatable="Yes">Enable auto-completion of words in the 
document.</property>
+                  </object>
+                  <packing>
+                    <property name="left-attach">0</property>
+                    <property name="width">1</property>
+                    <property name="top-attach">2</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkSwitch" id="word_completion_switch">
+                    <property name="visible">True</property>
+                    <property name="active">False</property>
+                  </object>
+                  <packing>
+                    <property name="left-attach">1</property>
+                    <property name="width">1</property>
+                    <property name="top-attach">2</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="name">editor</property>


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