From 830eba3a06506fd5ac527a74c8ce4ad5ba39cbf0 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Thu, 22 Mar 2018 16:10:52 +0100 Subject: Add spell-checking using Gspell --- main/src/ui/chat_input/spell_checker.vala | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 main/src/ui/chat_input/spell_checker.vala (limited to 'main/src/ui/chat_input/spell_checker.vala') diff --git a/main/src/ui/chat_input/spell_checker.vala b/main/src/ui/chat_input/spell_checker.vala new file mode 100644 index 00000000..a05d9251 --- /dev/null +++ b/main/src/ui/chat_input/spell_checker.vala @@ -0,0 +1,35 @@ +using Gdk; +using Gee; +using Gspell; + +using Dino.Entities; + +namespace Dino.Ui { + +public class SpellChecker { + + private Conversation? conversation; + private TextView gspell_view; + private HashMap language_cache = new HashMap(Conversation.hash_func, Conversation.equals_func); + + public SpellChecker(Gtk.TextView text_input) { + this.gspell_view = TextView.get_from_gtk_text_view(text_input); + gspell_view.basic_setup(); + } + + public void initialize_for_conversation(Conversation conversation) { + Checker spell_checker = TextBuffer.get_from_gtk_text_buffer(gspell_view.view.buffer).spell_checker; + + if (this.conversation != null) language_cache[this.conversation] = spell_checker.language; + + this.conversation = conversation; + + if (language_cache.has_key(this.conversation)) { + spell_checker.language = language_cache[conversation]; + } else { + spell_checker.language = null; + } + } +} + +} -- cgit v1.2.3-54-g00ecf