[latexila/wip/gspell] spell: add global settings to the preferences dialog



commit 166685ed8a6a072fbee6bc56e0544a6c9d49bd8b
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Sep 18 19:22:17 2015 +0200

    spell: add global settings to the preferences dialog

 src/preferences_dialog.vala  |   40 ++++++++++++
 src/ui/preferences_dialog.ui |  141 +++++++++++++++++++++++++++++++-----------
 2 files changed, 144 insertions(+), 37 deletions(-)
---
diff --git a/src/preferences_dialog.vala b/src/preferences_dialog.vala
index bc2d246..87e7ba8 100644
--- a/src/preferences_dialog.vala
+++ b/src/preferences_dialog.vala
@@ -80,6 +80,7 @@ public class PreferencesDialog : Dialog
         init_editor_tab (builder);
         init_font_and_colors_tab (builder);
         init_interactive_completion_setting (builder);
+        init_spell_checking_settings (builder);
         init_other_tab (builder);
 
         // pack notebook
@@ -292,6 +293,45 @@ public class PreferencesDialog : Dialog
             (n) => ngettext ("character", "characters", n));
     }
 
+    private void init_spell_checking_settings (Builder builder)
+    {
+        GLib.Settings editor_settings =
+            new GLib.Settings ("org.gnome.latexila.preferences.editor");
+
+        /* Language */
+
+        Gspell.LanguageChooserButton spell_language_button =
+            builder.get_object ("spell_language_button") as Gspell.LanguageChooserButton;
+
+        unowned Gspell.Language? lang = null;
+        string lang_key = editor_settings.get_string ("spell-checking-language");
+        if (lang_key[0] != '\0')
+            lang = Gspell.Language.from_key (lang_key);
+
+        Gspell.Checker checker = new Gspell.Checker (lang);
+        spell_language_button.set_language (checker.get_language ());
+
+        spell_language_button.notify["language"].connect (() =>
+        {
+            unowned Gspell.Language? selected_lang =
+                spell_language_button.get_language ();
+
+            if (selected_lang != null)
+            {
+                editor_settings.set_string ("spell-checking-language",
+                    selected_lang.to_key ());
+            }
+            else
+                editor_settings.set_string ("spell-checking-language", "");
+        });
+
+        /* Inline checker */
+
+        var inline_spell_checkbutton = builder.get_object ("inline_spell_checkbutton");
+        editor_settings.bind ("highlight-misspelled-words", inline_spell_checkbutton,
+            "active", SettingsBindFlags.DEFAULT);
+    }
+
     private void init_other_tab (Builder builder)
     {
         GLib.Settings latex_settings =
diff --git a/src/ui/preferences_dialog.ui b/src/ui/preferences_dialog.ui
index f0e93f9..180c84e 100644
--- a/src/ui/preferences_dialog.ui
+++ b/src/ui/preferences_dialog.ui
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <!-- interface-requires gtk+ 3.0 -->
+  <requires lib="gtk+" version="3.0"/>
   <object class="GtkWindow" id="window1">
     <property name="can_focus">False</property>
     <child>
@@ -434,6 +434,59 @@
             <property name="border_width">8</property>
             <property name="row_spacing">18</property>
             <child>
+              <object class="GtkGrid" id="grid9">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="column_spacing">5</property>
+                <child>
+                  <object class="GtkCheckButton" id="interactive_comp_checkbutton">
+                    <property name="label" translatable="yes">Interactive completion after</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkSpinButton" id="interactive_comp_spinbutton">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="has_tooltip">True</property>
+                    <property name="tooltip_markup" translatable="yes">Number of characters after 
&amp;apos;\&amp;apos;</property>
+                    <property name="tooltip_text" translatable="yes">Number of characters after 
'\'</property>
+                    <property name="invisible_char">●</property>
+                    <property name="primary_icon_activatable">False</property>
+                    <property name="secondary_icon_activatable">False</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="interactive_comp_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label">characters</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkGrid" id="grid15">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
@@ -513,26 +566,24 @@
               </object>
               <packing>
                 <property name="left_attach">0</property>
-                <property name="top_attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+                <property name="top_attach">2</property>
               </packing>
             </child>
             <child>
-              <object class="GtkGrid" id="grid9">
+              <object class="GtkGrid" id="grid6">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="halign">start</property>
-                <property name="column_spacing">5</property>
+                <property name="row_spacing">6</property>
                 <child>
-                  <object class="GtkCheckButton" id="interactive_comp_checkbutton">
-                    <property name="label" translatable="yes">Interactive completion after</property>
-                    <property name="use_action_appearance">False</property>
+                  <object class="GtkLabel" id="label3">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="draw_indicator">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="tooltip_text" translatable="yes">From the menu, the spell checking 
settings can also be changed on a file-by-file basis.</property>
+                    <property name="label" translatable="yes">Default Spell Checking Settings</property>
+                    <property name="xalign">0</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
@@ -542,43 +593,59 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkSpinButton" id="interactive_comp_spinbutton">
+                  <object class="GtkGrid" id="grid8">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="has_tooltip">True</property>
-                    <property name="tooltip_markup" translatable="yes">Number of characters after 
&amp;apos;\&amp;apos;</property>
-                    <property name="tooltip_text" translatable="yes">Number of characters after 
'\'</property>
-                    <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
-                    <property name="primary_icon_activatable">False</property>
-                    <property name="secondary_icon_activatable">False</property>
+                    <property name="can_focus">False</property>
+                    <property name="margin_start">12</property>
+                    <property name="column_spacing">12</property>
+                    <child>
+                      <object class="GtkLabel" id="label7">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Language:</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GspellLanguageChooserButton" id="spell_language_button">
+                        <property name="label" translatable="yes">button</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="top_attach">0</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">1</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="interactive_comp_label">
+                  <object class="GtkCheckButton" id="inline_spell_checkbutton">
+                    <property name="label" translatable="yes">Highlight misspelled words</property>
+                    <property name="use_action_appearance">False</property>
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label">characters</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="margin_start">12</property>
+                    <property name="draw_indicator">True</property>
                   </object>
                   <packing>
-                    <property name="left_attach">2</property>
-                    <property name="top_attach">0</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">2</property>
                   </packing>
                 </child>
               </object>
               <packing>
                 <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+                <property name="top_attach">1</property>
               </packing>
             </child>
           </object>


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