mirror of
https://github.com/TakeV-Lambda/dino.git
synced 2024-11-04 23:07:45 +00:00
Add spell-checking using Gspell
This commit is contained in:
parent
f94d8f56c7
commit
830eba3a06
4 changed files with 54 additions and 0 deletions
14
cmake/FindGspell.cmake
Normal file
14
cmake/FindGspell.cmake
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
include(PkgConfigWithFallback)
|
||||||
|
find_pkg_config_with_fallback(Gspell
|
||||||
|
PKG_CONFIG_NAME gspell-1
|
||||||
|
LIB_NAMES gspell-1
|
||||||
|
INCLUDE_NAMES gspell.h
|
||||||
|
INCLUDE_DIR_SUFFIXES gspell-1 gspell-1/gspell
|
||||||
|
DEPENDS Gtk
|
||||||
|
)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(Gspell
|
||||||
|
REQUIRED_VARS Gspell_LIBRARY
|
||||||
|
VERSION_VAR Gspell_VERSION)
|
||||||
|
|
|
@ -10,6 +10,7 @@ find_packages(MAIN_PACKAGES REQUIRED
|
||||||
GObject
|
GObject
|
||||||
GTK3
|
GTK3
|
||||||
ICU
|
ICU
|
||||||
|
Gspell
|
||||||
)
|
)
|
||||||
|
|
||||||
set(RESOURCE_LIST
|
set(RESOURCE_LIST
|
||||||
|
@ -129,6 +130,7 @@ SOURCES
|
||||||
src/ui/chat_input/encryption_button.vala
|
src/ui/chat_input/encryption_button.vala
|
||||||
src/ui/chat_input/occupants_tab_completer.vala
|
src/ui/chat_input/occupants_tab_completer.vala
|
||||||
src/ui/chat_input/smiley_converter.vala
|
src/ui/chat_input/smiley_converter.vala
|
||||||
|
src/ui/chat_input/spell_checker.vala
|
||||||
src/ui/chat_input/view.vala
|
src/ui/chat_input/view.vala
|
||||||
|
|
||||||
src/ui/contact_details/blocking_provider.vala
|
src/ui/contact_details/blocking_provider.vala
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class ChatTextView : ScrolledWindow {
|
||||||
private int vscrollbar_min_height;
|
private int vscrollbar_min_height;
|
||||||
private SmileyConverter smiley_converter;
|
private SmileyConverter smiley_converter;
|
||||||
public EditHistory edit_history;
|
public EditHistory edit_history;
|
||||||
|
private SpellChecker spell_checker;
|
||||||
|
|
||||||
construct {
|
construct {
|
||||||
max_content_height = 300;
|
max_content_height = 300;
|
||||||
|
@ -47,6 +48,7 @@ public class ChatTextView : ScrolledWindow {
|
||||||
|
|
||||||
smiley_converter = new SmileyConverter(text_view);
|
smiley_converter = new SmileyConverter(text_view);
|
||||||
edit_history = new EditHistory(text_view);
|
edit_history = new EditHistory(text_view);
|
||||||
|
spell_checker = new SpellChecker(text_view);
|
||||||
|
|
||||||
this.get_vscrollbar().get_preferred_height(out vscrollbar_min_height, null);
|
this.get_vscrollbar().get_preferred_height(out vscrollbar_min_height, null);
|
||||||
this.vadjustment.notify["upper"].connect_after(on_upper_notify);
|
this.vadjustment.notify["upper"].connect_after(on_upper_notify);
|
||||||
|
@ -57,6 +59,7 @@ public class ChatTextView : ScrolledWindow {
|
||||||
|
|
||||||
public void initialize_for_conversation(Conversation conversation) {
|
public void initialize_for_conversation(Conversation conversation) {
|
||||||
edit_history.initialize_for_conversation(conversation);
|
edit_history.initialize_for_conversation(conversation);
|
||||||
|
spell_checker.initialize_for_conversation(conversation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void get_preferred_height(out int min_height, out int nat_height) {
|
public override void get_preferred_height(out int min_height, out int nat_height) {
|
||||||
|
|
35
main/src/ui/chat_input/spell_checker.vala
Normal file
35
main/src/ui/chat_input/spell_checker.vala
Normal file
|
@ -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<Conversation, Language> language_cache = new HashMap<Conversation, Language>(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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue