[gitg/wip/spellcheck: 11/13] Correctly set spell checking language
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/wip/spellcheck: 11/13] Correctly set spell checking language
- Date: Sun, 7 Jul 2013 13:30:40 +0000 (UTC)
commit 308b36ec135fd1cec957ad7e4092b2e666cf7154
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 7eb38ea..9c64c5a 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;
@@ -71,7 +74,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
@@ -203,18 +206,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();
}
}
@@ -233,7 +232,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();
@@ -251,6 +250,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]