Commit 304377c7 authored by Michael Gratton's avatar Michael Gratton 🤞

Merge branch 'wip/spellcheck-subject' into 'mainline'

Spellcheck composer subject

See merge request !240
parents 10af58a5 bb872b28
Pipeline #84202 failed with stages
in 102 minutes and 36 seconds
......@@ -24,8 +24,8 @@ variables:
FEDORA_DEPS: meson vala
desktop-file-utils enchant2-devel folks-devel gcr-devel
glib2-devel gmime-devel gnome-online-accounts-devel
gtk3-devel iso-codes-devel json-glib-devel itstool
libcanberra-devel libgee-devel libhandy-devel
gspell-devel gtk3-devel iso-codes-devel json-glib-devel
itstool libcanberra-devel libgee-devel libhandy-devel
libsecret-devel libunwind-devel libxml2-devel
libytnef-devel sqlite-devel webkitgtk4-devel
FEDORA_TEST_DEPS: Xvfb tar xz
......@@ -35,11 +35,11 @@ variables:
desktop-file-utils gettext iso-codes itstool
libcanberra-dev libenchant-dev libfolks-dev
libgcr-3-dev libgee-0.8-dev libglib2.0-dev
libgmime-2.6-dev libgoa-1.0-dev libgtk-3-dev
libhandy-0.0-dev libjson-glib-dev libmessaging-menu-dev
libsecret-1-dev libsqlite3-dev libunity-dev
libunwind-dev libwebkit2gtk-4.0-dev libxml2-dev
libytnef0-dev
libgmime-2.6-dev libgoa-1.0-dev libgspell-1-dev
libgtk-3-dev libhandy-0.0-dev libjson-glib-dev
libmessaging-menu-dev libsecret-1-dev libsqlite3-dev
libunity-dev libunwind-dev libwebkit2gtk-4.0-dev
libxml2-dev libytnef0-dev
UBUNTU_TEST_DEPS: xauth xvfb
fedora:
......
......@@ -42,10 +42,11 @@ Install them by running this command:
sudo yum install meson vala \
desktop-file-utils enchant2-devel folks-devel gcr-devel \
glib2-devel gmime-devel gnome-online-accounts-devel gtk3-devel \
iso-codes-devel json-glib-devel libcanberra-devel \
libgee-devel libhandy-devel libsecret-devel libunwind-devel \
libxml2-devel libytnef-devel sqlite-devel webkitgtk4-devel
glib2-devel gmime-devel gnome-online-accounts-devel \
gspell-devel gtk3-devel iso-codes-devel json-glib-devel \
libcanberra-devel libgee-devel libhandy-devel libsecret-devel \
libunwind-devel libxml2-devel libytnef-devel sqlite-devel \
webkitgtk4-devel
Installing dependencies on Ubuntu/Debian
----------------------------------------
......@@ -55,9 +56,10 @@ Install them by running this command:
sudo apt-get install meson build-essential valac \
desktop-file-utils iso-codes gettext libcanberra-dev \
libenchant-dev libfolks-dev libgcr-3-dev libgee-0.8-dev \
libglib2.0-dev libgmime-2.6-dev libgoa-1.0-dev libgtk-3-dev \
libjson-glib-dev libhandy-dev libsecret-1-dev libsqlite3-dev \
libunwind-dev libwebkit2gtk-4.0-dev libxml2-dev libytnef0-dev
libglib2.0-dev libgmime-2.6-dev libgoa-1.0-dev libgspell-1-dev \
libgtk-3-dev libjson-glib-dev libhandy-dev libsecret-1-dev \
libsqlite3-dev libunwind-dev libwebkit2gtk-4.0-dev \
libxml2-dev libytnef0-dev
And for Ubuntu Unity integration:
......
......@@ -62,6 +62,7 @@ gdk = dependency('gdk-3.0', version: '>=' + target_gtk)
gee = dependency('gee-0.8', version: '>= 0.8.5')
gio = dependency('gio-2.0', version: '>=' + target_glib)
goa = dependency('goa-1.0')
gspell = dependency('gspell-1')
gthread = dependency('gthread-2.0', version: '>=' + target_glib)
iso_codes = dependency('iso-codes')
javascriptcoregtk = dependency('javascriptcoregtk-4.0', version: '>=' + target_webkit)
......
......@@ -100,6 +100,27 @@
}
]
},
{
"name" : "gspell",
"config-opts" : [
"--disable-gtk-doc",
"--disable-gtk-doc-html"
],
"cleanup" : [
"/bin",
"/include",
"/lib/pkgconfig",
"*.la",
"/share"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/gspell.git",
"branch" : "master"
}
]
},
{
"name": "libical",
"cleanup": [
......
......@@ -386,6 +386,9 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
get { return (ComposerContainer) parent; }
}
private Gspell.Checker subject_spell_checker = new Gspell.Checker(null);
private Gspell.Entry subject_spell_entry;
/** Fired when the current saved draft's id has changed. */
public signal void draft_id_changed(Geary.EmailIdentifier? id);
......@@ -456,6 +459,11 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
this.to_entry.margin_top = this.cc_entry.margin_top = this.bcc_entry.margin_top = this.reply_to_entry.margin_top = 6;
this.subject_spell_entry = Gspell.Entry.get_from_gtk_entry(
this.subject_entry
);
update_subject_spell_checker();
this.editor = new ComposerWebView(config);
this.editor.set_hexpand(true);
this.editor.set_vexpand(true);
......@@ -2014,6 +2022,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
);
this.spell_check_popover.selection_changed.connect((active_langs) => {
this.config.spell_check_languages = active_langs;
update_subject_spell_checker();
});
}
this.spell_check_popover.toggle();
......@@ -2207,6 +2216,51 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
this.editor.update_signature(Geary.HTML.smart_escape(sig));
}
private void update_subject_spell_checker() {
Gspell.Language? lang = null;
string[] langs = this.config.spell_check_languages;
if (langs.length == 1) {
lang = Gspell.Language.lookup(langs[0]);
} else {
// Since GSpell doesn't support multiple languages (see
// <https://gitlab.gnome.org/GNOME/gspell/issues/5>) and
// we don't support spell checker language priority, use
// the first matching most preferred language, if any.
foreach (string pref in
Util.International.get_user_preferred_languages()) {
if (pref in langs) {
lang = Gspell.Language.lookup(pref);
if (lang != null) {
break;
}
}
}
if (lang == null) {
// No preferred lang found, so just use first
// supported matching langauge
foreach (string pref in langs) {
lang = Gspell.Language.lookup(pref);
if (lang != null) {
break;
}
}
}
}
Gspell.EntryBuffer buffer =
Gspell.EntryBuffer.get_from_gtk_entry_buffer(
this.subject_entry.buffer
);
Gspell.Checker checker = null;
if (lang != null) {
checker = this.subject_spell_checker;
checker.language = lang;
}
this.subject_spell_entry.inline_spell_checking = (checker != null);
buffer.spell_checker = checker;
}
private async ComposerLinkPopover new_link_popover(ComposerLinkPopover.Type type,
string url) {
var selection_id = "";
......
......@@ -121,6 +121,7 @@ geary_client_dependencies = [
gee,
gio,
goa,
gspell,
gtk,
json_glib,
libcanberra,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment