[gitg/wip/spellcheck] Correctly set spell checking language



commit eae7b5721924a5b94a092c7fdfd01cf2df3c114e
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sun Jul 7 13:10:21 2013 +0200

    Correctly set spell checking language

 gitg/commit/gitg-commit-dialog.vala |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/gitg/commit/gitg-commit-dialog.vala b/gitg/commit/gitg-commit-dialog.vala
index adef994..a7842ea 100644
--- a/gitg/commit/gitg-commit-dialog.vala
+++ b/gitg/commit/gitg-commit-dialog.vala
@@ -23,6 +23,9 @@ namespace GitgCommit
 [GtkTemplate (ui = "/org/gnome/gitg/ui/gitg-commit-dialog.ui")]
 class Dialog : Gtk.Dialog
 {
+       // Do this to pull in config.h before glib.h (for gettext...)
+       private const string version = Gitg.Config.VERSION;
+
        [GtkChild (name = "source_view_message")]
        private GtkSource.View d_source_view_message;
 
@@ -56,7 +59,7 @@ class Dialog : Gtk.Dialog
        private Settings? d_font_settings;
        private Settings? d_commit_settings;
        private bool d_enable_spell_checking;
-       private string d_spell_checking_language;
+       private string? d_spell_checking_language;
        private GtkSpell.Checker? d_spell_checker;
 
        public GtkSource.View source_view_message
@@ -188,18 +191,14 @@ class Dialog : Gtk.Dialog
        }
 
        [Notify]
-       public string spell_checking_language
+       public string? spell_checking_language
        {
                get { return d_spell_checking_language; }
 
                set
                {
                        d_spell_checking_language = value;
-
-                       if (d_spell_checker != null)
-                       {
-                               d_spell_checker.set_language(value);
-                       }
+                       set_spell_language();
                }
        }
 
@@ -218,7 +217,7 @@ class Dialog : Gtk.Dialog
                                        d_spell_checker = new GtkSpell.Checker();
                                        d_spell_checker.attach(d_source_view_message);
 
-                                       d_spell_checker.set_language(d_spell_checking_language);
+                                       set_spell_language();
 
                                        d_spell_checker.language_changed.connect(() => {
                                                spell_checking_language = d_spell_checker.get_language();
@@ -236,6 +235,22 @@ class Dialog : Gtk.Dialog
                }
        }
 
+       private void set_spell_language()
+       {
+               if (d_spell_checker != null && d_spell_checking_language != null)
+               {
+                       try
+                       {
+                               d_spell_checker.set_language(d_spell_checking_language);
+                       }
+                       catch
+                       {
+                               warning(_("Cannot set spell checking language: %s"), 
d_spell_checking_language);
+                               d_spell_checking_language = null;
+                       }
+               }
+       }
+
        private void load_author_info()
        {
                if (d_cancel_avatar != null)


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