[latexila/wip/gspell] spell: update global settings to open tabs



commit 3b291d3e2c883b09b289256602606c8806119a03
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Sep 26 18:03:25 2015 +0200

    spell: update global settings to open tabs
    
    The spell checking setup is updated if the metadata doesn't exist.

 src/document_view.vala     |   12 +++++++++++-
 src/main_window_tools.vala |   12 ++++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/src/document_view.vala b/src/document_view.vala
index 4e53a46..60cb377 100644
--- a/src/document_view.vala
+++ b/src/document_view.vala
@@ -233,6 +233,16 @@ public class DocumentView : Gtk.SourceView
             _spell_checker.set_language (get_spell_language ());
             setup_inline_spell_checker ();
         });
+
+        _editor_settings.changed["spell-checking-language"].connect (() =>
+        {
+            _spell_checker.set_language (get_spell_language ());
+        });
+
+        _editor_settings.changed["highlight-misspelled-words"].connect (() =>
+        {
+            setup_inline_spell_checker ();
+        });
     }
 
     private unowned Gspell.Language? get_spell_language ()
@@ -249,7 +259,7 @@ public class DocumentView : Gtk.SourceView
         return Gspell.Language.from_key (lang_key);
     }
 
-    private void setup_inline_spell_checker ()
+    public void setup_inline_spell_checker ()
     {
         Document doc = get_buffer () as Document;
 
diff --git a/src/main_window_tools.vala b/src/main_window_tools.vala
index 6732ffd..a538113 100644
--- a/src/main_window_tools.vala
+++ b/src/main_window_tools.vala
@@ -40,6 +40,7 @@ public class MainWindowTools
 
     private unowned MainWindow _main_window;
     private Gtk.ActionGroup _action_group;
+    private GLib.Settings _editor_settings;
 
     public MainWindowTools (MainWindow main_window, UIManager ui_manager)
     {
@@ -57,6 +58,17 @@ public class MainWindowTools
         {
             update_inline_spell_checker_action_state ();
         });
+
+        _editor_settings = new GLib.Settings ("org.gnome.latexila.preferences.editor");
+
+        _editor_settings.changed["highlight-misspelled-words"].connect (() =>
+        {
+            // Ensure that the active_view is updated first.
+            if (_main_window.active_view != null)
+                _main_window.active_view.setup_inline_spell_checker ();
+
+            update_inline_spell_checker_action_state ();
+        });
     }
 
     private void update_inline_spell_checker_action_state ()


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