diff --git a/.gitlab-ci/org.gnome.Fractal.CiTest.json b/.gitlab-ci/org.gnome.Fractal.CiTest.json index 4f92d565..2400cb1a 100644 --- a/.gitlab-ci/org.gnome.Fractal.CiTest.json +++ b/.gitlab-ci/org.gnome.Fractal.CiTest.json @@ -38,6 +38,21 @@ } ] }, + { + "name" : "libspelling", + "buildsystem" : "meson", + "config-opts" : [ + "-Ddocs=false", + "-Dvapi=false" + ], + "sources" : [ + { + "type" : "archive", + "url" : "https://download.gnome.org/sources/libspelling/0.2/libspelling-0.2.0.tar.xz", + "sha256" : "fdc5609e02818eca6fc172ff164caa8e52dba638d7590130af3dfb1f28b53421" + } + ] + }, { "name": "fractal", "buildsystem": "meson", diff --git a/Cargo.lock b/Cargo.lock index 564123c3..9a402046 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1527,6 +1527,7 @@ dependencies = [ "indexmap 2.0.2", "libadwaita", "libshumate", + "libspelling", "matrix-sdk", "matrix-sdk-ui", "mime", @@ -3051,6 +3052,35 @@ dependencies = [ "system-deps", ] +[[package]] +name = "libspelling" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "850363056ea48497686407e7e583c50c793896c151bbe7139ad4ea02fbf15e76" +dependencies = [ + "gio", + "glib", + "gtk4", + "libc", + "libspelling-sys", + "sourceview5", +] + +[[package]] +name = "libspelling-sys" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "377675d9465da676ebc05742743d5e5bc53a49be1138f463583181aea97da3c6" +dependencies = [ + "gio-sys", + "glib-sys", + "gobject-sys", + "gtk4-sys", + "libc", + "sourceview5-sys", + "system-deps", +] + [[package]] name = "libsqlite3-sys" version = "0.26.0" diff --git a/Cargo.toml b/Cargo.toml index 3af4e530..02159046 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,6 +72,7 @@ gst_video = { version = "0.21", package = "gstreamer-video" } gtk = { package = "gtk4", version = "0.7", features = ["v4_10"] } shumate = { package = "libshumate", version = "0.4" } sourceview = { package = "sourceview5", version = "0.7" } +spelling = { package = "libspelling", version = "0.1" } [dependencies.matrix-sdk] git = "https://github.com/zecakeh/matrix-rust-sdk.git" diff --git a/build-aux/org.gnome.Fractal.Devel.json b/build-aux/org.gnome.Fractal.Devel.json index 72fb84b0..34aa6ca1 100644 --- a/build-aux/org.gnome.Fractal.Devel.json +++ b/build-aux/org.gnome.Fractal.Devel.json @@ -47,6 +47,21 @@ } ] }, + { + "name" : "libspelling", + "buildsystem" : "meson", + "config-opts" : [ + "-Ddocs=false", + "-Dvapi=false" + ], + "sources" : [ + { + "type" : "archive", + "url" : "https://download.gnome.org/sources/libspelling/0.2/libspelling-0.2.0.tar.xz", + "sha256" : "fdc5609e02818eca6fc172ff164caa8e52dba638d7590130af3dfb1f28b53421" + } + ] + }, { "name": "fractal", "buildsystem": "meson", diff --git a/build-aux/org.gnome.Fractal.Hack.json b/build-aux/org.gnome.Fractal.Hack.json index a7f6a5dd..da6ada19 100644 --- a/build-aux/org.gnome.Fractal.Hack.json +++ b/build-aux/org.gnome.Fractal.Hack.json @@ -53,6 +53,21 @@ } ] }, + { + "name" : "libspelling", + "buildsystem" : "meson", + "config-opts" : [ + "-Ddocs=false", + "-Dvapi=false" + ], + "sources" : [ + { + "type" : "archive", + "url" : "https://download.gnome.org/sources/libspelling/0.2/libspelling-0.2.0.tar.xz", + "sha256" : "fdc5609e02818eca6fc172ff164caa8e52dba638d7590130af3dfb1f28b53421" + } + ] + }, { "name": "fractal", "buildsystem": "meson", diff --git a/meson.build b/meson.build index fe2c30f8..3f859740 100644 --- a/meson.build +++ b/meson.build @@ -33,6 +33,7 @@ dependency( default_options: ['gtk_doc=false', 'sysprof=false', 'gir=false', 'vapi=false', 'install_tests=false'] ) dependency('libpipewire-0.3', version: '>= 0.3.0') +dependency('libspelling-1', version: '>= 0.2.0') dependency('openssl', version: '>= 1.0.1') dependency('shumate-1.0', version: '>= 1.0.0') dependency('sqlite3', version: '>= 3.24.0') diff --git a/src/session/view/content/room_history/mod.rs b/src/session/view/content/room_history/mod.rs index e05af6f9..cc5b06ae 100644 --- a/src/session/view/content/room_history/mod.rs +++ b/src/session/view/content/room_history/mod.rs @@ -507,6 +507,15 @@ mod imp { // Tab auto-completion. self.completion.set_parent(&*self.message_entry); + + // Spellchecker. + let spell_checker = spelling::Checker::default(); + let adapter = spelling::TextBufferAdapter::new(&buffer, &spell_checker); + let extra_menu = adapter.menu_model(); + self.message_entry.set_extra_menu(Some(&extra_menu)); + self.message_entry + .insert_action_group("spelling", Some(&adapter)); + adapter.set_enabled(true); } fn setup_drop_target(&self) {