aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/data/settings_dialog.ui14
-rw-r--r--main/src/ui/chat_input/spell_checker.vala80
-rw-r--r--main/src/ui/settings_dialog.vala3
3 files changed, 1 insertions, 96 deletions
diff --git a/main/data/settings_dialog.ui b/main/data/settings_dialog.ui
index 00870ebb..a8b24135 100644
--- a/main/data/settings_dialog.ui
+++ b/main/data/settings_dialog.ui
@@ -2,7 +2,7 @@
<interface>
<template class="DinoUiSettingsDialog" parent="AdwPreferencesWindow">
<property name="default-width">500</property>
- <property name="default-height">420</property>
+ <property name="default-height">360</property>
<property name="modal">True</property>
<property name="search-enabled">False</property>
<child>
@@ -66,18 +66,6 @@
</child>
</object>
</child>
- <child>
- <object class="AdwActionRow">
- <property name="title" translatable="yes">Check _Spelling</property>
- <property name="use-underline">True</property>
- <property name="activatable-widget">check_spelling_switch</property>
- <child type="suffix">
- <object class="GtkSwitch" id="check_spelling_switch">
- <property name="valign">center</property>
- </object>
- </child>
- </object>
- </child>
</object>
</child>
</object>
diff --git a/main/src/ui/chat_input/spell_checker.vala b/main/src/ui/chat_input/spell_checker.vala
deleted file mode 100644
index bdd9d51a..00000000
--- a/main/src/ui/chat_input/spell_checker.vala
+++ /dev/null
@@ -1,80 +0,0 @@
-using Gdk;
-using Gee;
-
-using Dino.Entities;
-
-namespace Dino.Ui {
-
-public class SpellChecker {
-
- private Conversation? conversation;
- private Gtk.TextView text_input;
-
- public SpellChecker(Gtk.TextView text_input) {
- this.text_input = text_input;
-
- // We can't keep a reference to GspellTextView/Buffer around, otherwise they'd get freed twice
- Gspell.TextView text_view = Gspell.TextView.get_from_gtk_text_view(text_input);
- Gspell.TextBuffer text_buffer = Gspell.TextBuffer.get_from_gtk_text_buffer(text_view.view.buffer);
-
- text_view.basic_setup();
- text_buffer.spell_checker.notify["language"].connect(lang_changed);
-
- // Enable/Disable spell checking live
- Dino.Application.get_default().settings.notify["check-spelling"].connect((obj, _) => {
- if (((Dino.Entities.Settings) obj).check_spelling) {
- initialize_for_conversation(this.conversation);
- } else {
- text_buffer.set_spell_checker(null);
- }
- });
- }
-
- public void initialize_for_conversation(Conversation conversation) {
- this.conversation = conversation;
-
- Gspell.TextView text_view = Gspell.TextView.get_from_gtk_text_view(text_input);
- Gspell.TextBuffer text_buffer = Gspell.TextBuffer.get_from_gtk_text_buffer(text_view.view.buffer);
-
- if (!Dino.Application.get_default().settings.check_spelling) {
- text_buffer.set_spell_checker(null);
- return;
- }
- if (text_buffer.spell_checker == null) text_buffer.spell_checker = new Gspell.Checker(null);
-
- // Set the conversation language (from cache or db)
- text_buffer.spell_checker.notify["language"].disconnect(lang_changed);
-
- var db = Dino.Application.get_default().db;
- Qlite.RowOption row_option = db.conversation_settings.select()
- .with(db.conversation_settings.conversation_id, "=", conversation.id)
- .with(db.conversation_settings.key, "=", "lang")
- .single().row();
- if (row_option.is_present()) {
- string lang_code = row_option.inner[db.conversation_settings.value];
- Gspell.Language? lang = Gspell.Language.lookup(lang_code);
- text_buffer.spell_checker.language = lang;
- } else {
- text_buffer.spell_checker.language = null;
- }
-
- text_buffer.spell_checker.notify["language"].connect(lang_changed);
- }
-
- private void lang_changed() {
- var db = Dino.Application.get_default().db;
-
- Gspell.TextView text_view = Gspell.TextView.get_from_gtk_text_view(text_input);
- Gspell.TextBuffer text_buffer = Gspell.TextBuffer.get_from_gtk_text_buffer(text_view.view.buffer);
- Gspell.Checker spell_checker = text_buffer.spell_checker;
- if (spell_checker.language.get_code() == null) return;
-
- db.conversation_settings.upsert()
- .value(db.conversation_settings.conversation_id, conversation.id, true)
- .value(db.conversation_settings.key, "lang", true)
- .value(db.conversation_settings.value, spell_checker.language.get_code())
- .perform();
- }
-}
-
-}
diff --git a/main/src/ui/settings_dialog.vala b/main/src/ui/settings_dialog.vala
index 068cc894..3635879c 100644
--- a/main/src/ui/settings_dialog.vala
+++ b/main/src/ui/settings_dialog.vala
@@ -9,7 +9,6 @@ class SettingsDialog : Adw.PreferencesWindow {
[GtkChild] private unowned Switch marker_switch;
[GtkChild] private unowned Switch notification_switch;
[GtkChild] private unowned Switch emoji_switch;
- [GtkChild] private unowned Switch check_spelling_switch;
Dino.Entities.Settings settings = Dino.Application.get_default().settings;
@@ -20,13 +19,11 @@ class SettingsDialog : Adw.PreferencesWindow {
marker_switch.active = settings.send_marker;
notification_switch.active = settings.notifications;
emoji_switch.active = settings.convert_utf8_smileys;
- check_spelling_switch.active = settings.check_spelling;
typing_switch.notify["active"].connect(() => { settings.send_typing = typing_switch.active; } );
marker_switch.notify["active"].connect(() => { settings.send_marker = marker_switch.active; } );
notification_switch.notify["active"].connect(() => { settings.notifications = notification_switch.active; } );
emoji_switch.notify["active"].connect(() => { settings.convert_utf8_smileys = emoji_switch.active; });
- check_spelling_switch.notify["active"].connect(() => { settings.check_spelling = check_spelling_switch.active; });
}
}