From a0a1791db1179dc739c4cf17d124fcd45d0e6ead Mon Sep 17 00:00:00 2001 From: Brage Fuglseth Date: Sat, 13 Jul 2024 09:43:29 +0200 Subject: [PATCH] project: Update to gtk-rs 0.9 --- Cargo.lock | 324 ++++++++++++------------ Cargo.toml | 4 +- src/widgets/custom_text_dialog.rs | 15 +- src/widgets/text_language_dialog.rs | 51 ++-- src/widgets/text_view/colors.rs | 22 +- src/widgets/text_view/input.rs | 124 ++++++---- src/widgets/window.rs | 14 +- src/widgets/window/focus.rs | 62 +++-- src/widgets/window/session.rs | 372 +++++++++++++++++----------- src/widgets/window/ui_state.rs | 76 ++++-- 10 files changed, 623 insertions(+), 441 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7957cdd..f0d9319 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,9 +25,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "block" @@ -43,9 +43,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cairo-rs" -version = "0.19.4" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ac2a4d0e69036cf0062976f6efcba1aaee3e448594e6514bb2ddf87acce562" +checksum = "797fd5a634dcb0ad0d7d583df794deb0a236d88e759cd34b7da20198c6c9d145" dependencies = [ "bitflags", "cairo-sys-rs", @@ -56,9 +56,9 @@ dependencies = [ [[package]] name = "cairo-sys-rs" -version = "0.19.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3bb3119664efbd78b5e6c93957447944f16bdbced84c17a9f41c7829b81e64" +checksum = "428290f914b9b86089f60f5d8a9f6e440508e1bcff23b25afd51502b0a2da88f" dependencies = [ "glib-sys", "libc", @@ -67,9 +67,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.96" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd" +checksum = "907d8581360765417f8f2e0e7d602733bbed60156b4465b7617243689ef9b83d" [[package]] name = "cfg-expr" @@ -89,9 +89,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -117,15 +117,15 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "either" -version = "1.11.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "endi" @@ -199,7 +199,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -224,9 +224,9 @@ dependencies = [ [[package]] name = "gdk-pixbuf" -version = "0.19.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6a23f8a0b5090494fd04924662d463f8386cc678dd3915015a838c1a3679b92" +checksum = "28bb53ecb56857c683c9ec859908e076dd3969c7d67598bd8b1ce095d211304a" dependencies = [ "gdk-pixbuf-sys", "gio", @@ -236,9 +236,9 @@ dependencies = [ [[package]] name = "gdk-pixbuf-sys" -version = "0.19.5" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fdbf021f8b9d19e30fb9ea6d6e5f2b6a712fe4645417c69f86f6ff1e1444a8f" +checksum = "9f6681a0c1330d1d3968bec1529f7172d62819ef0bdbb0d18022320654158b03" dependencies = [ "gio-sys", "glib-sys", @@ -249,9 +249,9 @@ dependencies = [ [[package]] name = "gdk4" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db265c9dd42d6a371e09e52deab3a84808427198b86ac792d75fd35c07990a07" +checksum = "4b7d7237c1487ed4b300aac7744efcbf1319e12d60d7afcd6f505414bd5b5dea" dependencies = [ "cairo-rs", "gdk-pixbuf", @@ -264,9 +264,9 @@ dependencies = [ [[package]] name = "gdk4-sys" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9418fb4e8a67074919fe7604429c45aa74eb9df82e7ca529767c6d4e9dc66dd" +checksum = "a67576c8ec012156d7f680e201a807b4432a77babb3157e0555e990ab6bcd878" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -281,9 +281,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -312,9 +312,9 @@ dependencies = [ [[package]] name = "gio" -version = "0.19.5" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be548be810e45dd31d3bbb89c6210980bb7af9bca3ea1292b5f16b75f8e394a7" +checksum = "398e3da68749fdc32783cbf7521ec3f65c9cf946db8c7774f8460af49e52c6e2" dependencies = [ "futures-channel", "futures-core", @@ -330,9 +330,9 @@ dependencies = [ [[package]] name = "gio-sys" -version = "0.19.5" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4bdbef451b0f0361e7f762987cc6bebd5facab1d535e85a3cf1115dfb08db40" +checksum = "e4feb96b31c32730ea3e1e89aecd2e4e37ecb1c473ad8f685e3430a159419f63" dependencies = [ "glib-sys", "gobject-sys", @@ -343,9 +343,9 @@ dependencies = [ [[package]] name = "glib" -version = "0.19.5" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be682de2914107f591efdbe2debf05d9ad70726310ee2b6a3802a697649fcc55" +checksum = "fee90a615ce05be7a32932cfb8adf2c4bbb4700e80d37713c981fb24c0c56238" dependencies = [ "bitflags", "futures-channel", @@ -365,22 +365,22 @@ dependencies = [ [[package]] name = "glib-macros" -version = "0.19.5" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed782fa3e949c31146671da6e7a227a5e7d354660df1db6d0aac4974dc82a3c" +checksum = "4da558d8177c0c8c54368818b508a4244e1286fce2858cef4e547023f0cfa5ef" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] name = "glib-sys" -version = "0.19.5" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "767d23ead9bbdfcbb1c2242c155c8128a7d13dde7bf69c176f809546135e2282" +checksum = "4958c26e5a01c9af00dea669a97369eccbec29a8e6d125c24ea2d85ee7467b60" dependencies = [ "libc", "system-deps", @@ -388,9 +388,9 @@ dependencies = [ [[package]] name = "gobject-sys" -version = "0.19.5" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3787b0bfacca12bb25f8f822b0dbee9f7e4a86e6469a29976d332d2c14c945b" +checksum = "c6908864f5ffff15b56df7e90346863904f49b949337ed0456b9287af61903b8" dependencies = [ "glib-sys", "libc", @@ -399,9 +399,9 @@ dependencies = [ [[package]] name = "graphene-rs" -version = "0.19.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e4d388e96c5f29e2b2f67045d229ddf826d0a8d6d282f94ed3b34452222c91" +checksum = "630e940ad5824f90221d6579043a9cd1f8bec86b4a17faaf7827d58eb16e8c1f" dependencies = [ "glib", "graphene-sys", @@ -410,9 +410,9 @@ dependencies = [ [[package]] name = "graphene-sys" -version = "0.19.5" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60e7381afdd7be43bd10a89d3b6741d162aabbca3a8db73505afb6a3aea59d" +checksum = "6fb8fade7b754982f47ebbed241fd2680816fdd4598321784da10b9e1168836a" dependencies = [ "glib-sys", "libc", @@ -422,9 +422,9 @@ dependencies = [ [[package]] name = "gsk4" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7563884bf6939f4468e5d94654945bdd9afcaf8c3ba4c5dd17b5342b747221be" +checksum = "1f3cf2091e1af185b347b3450817d93dea6fe435df7abd4c2cd7fb5bcb4cfda8" dependencies = [ "cairo-rs", "gdk4", @@ -437,9 +437,9 @@ dependencies = [ [[package]] name = "gsk4-sys" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23024bf2636c38bbd1f822f58acc9d1c25b28da896ff0f291a1a232d4272b3dc" +checksum = "6aa69614a26d8760c186c3690f1b0fbb917572ca23ef83137445770ceddf8cde" dependencies = [ "cairo-sys-rs", "gdk4-sys", @@ -453,9 +453,9 @@ dependencies = [ [[package]] name = "gtk4" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b04e11319b08af11358ab543105a9e49b0c491faca35e2b8e7e36bfba8b671ab" +checksum = "eaffc6c743c9160514cc9b67eace364e5dc5798369fa809cdb04e035c21c5c5d" dependencies = [ "cairo-rs", "field-offset", @@ -474,21 +474,21 @@ dependencies = [ [[package]] name = "gtk4-macros" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec655a7ef88d8ce9592899deb8b2d0fa50bab1e6dd69182deb764e643c522408" +checksum = "188211f546ce5801f6d0245c37b6249143a2cb4fa040e54829ca1e76796e9f09" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] name = "gtk4-sys" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c8aa86b7f85ea71d66ea88c1d4bae1cfacf51ca4856274565133838d77e57b5" +checksum = "1114a207af8ada02cf4658a76692f4190f06f093380d5be07e3ca8b43aa7c666" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -537,12 +537,6 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -561,18 +555,18 @@ dependencies = [ [[package]] name = "include_dir" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18762faeff7122e89e0857b02f7ce6fcc0d101d5e9ad2ad7846cc01d61b7f19e" +checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd" dependencies = [ "include_dir_macros", ] [[package]] name = "include_dir_macros" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b139284b5cf57ecfa712bcc66950bb635b31aff41c188e8a4cfc758eca374a3f" +checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75" dependencies = [ "proc-macro2", "quote", @@ -614,17 +608,16 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libadwaita" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91b4990248b9e1ec5e72094a2ccaea70ec3809f88f6fd52192f2af306b87c5d9" +checksum = "2ff9c222b5c783729de45185f07b2fec2d43a7f9c63961e777d3667e20443878" dependencies = [ - "gdk-pixbuf", "gdk4", "gio", "glib", @@ -636,9 +629,9 @@ dependencies = [ [[package]] name = "libadwaita-sys" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a748e4e92be1265cd9e93d569c0b5dfc7814107985aa6743d670ab281ea1a8" +checksum = "1c44d8bdbad31d6639e1f20cc9c1424f1a8e02d751fc28d44659bf743fb9eca6" dependencies = [ "gdk4-sys", "gio-sys", @@ -652,9 +645,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "litrs" @@ -689,9 +682,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memoffset" @@ -704,9 +697,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] @@ -742,9 +735,9 @@ dependencies = [ [[package]] name = "pango" -version = "0.19.5" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504ce6e805439ea2c6791168fe7ef8e3da0c1b2ef82c44bc450dbc330592920d" +checksum = "54768854025df6903061d0084fd9702a253ddfd60db7d9b751d43b76689a7f0a" dependencies = [ "gio", "glib", @@ -754,9 +747,9 @@ dependencies = [ [[package]] name = "pango-sys" -version = "0.19.5" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4829555bdbb83692ddeaf5a6927fb2d025c8131e5ecaa4f7619fff6985d3505" +checksum = "b07cc57d10cee4ec661f718a6902cee18c2f4cfae08e87e5a390525946913390" dependencies = [ "glib-sys", "gobject-sys", @@ -799,9 +792,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -877,9 +870,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", @@ -889,9 +882,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -900,9 +893,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "rustc_version" @@ -915,21 +908,21 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "092474d1a01ea8278f69e6a358998405fae5b8b963ddaeb2b0b04a128bf1dfb0" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "safe-transmute" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98a01dab6acf992653be49205bdd549f32f17cb2803e8eacf1560bf97259aae8" +checksum = "3944826ff8fa8093089aba3acb4ef44b9446a99a16f3bf4e74af3f77d340ab7d" [[package]] name = "same-file" @@ -942,35 +935,35 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.200" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.200" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ "itoa", "ryu", @@ -979,9 +972,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" dependencies = [ "serde", ] @@ -1009,39 +1002,28 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strum" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" [[package]] name = "strum_macros" -version = "0.26.2" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck 0.4.1", + "heck", "proc-macro2", "quote", "rustversion", - "syn 2.0.60", -] - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "syn", ] [[package]] name = "syn" -version = "2.0.60" +version = "2.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" dependencies = [ "proc-macro2", "quote", @@ -1050,12 +1032,12 @@ dependencies = [ [[package]] name = "system-deps" -version = "6.2.2" +version = "7.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" +checksum = "6c81f13d9a334a6c242465140bd262fae382b752ff2011c4f7419919a9c97922" dependencies = [ "cfg-expr", - "heck 0.5.0", + "heck", "pkg-config", "toml", "version-compare", @@ -1063,9 +1045,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.14" +version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2" [[package]] name = "temp-dir" @@ -1075,41 +1057,41 @@ checksum = "1f227968ec00f0e5322f9b8173c7a0cbcff6181a0a5b28e9892491c286277231" [[package]] name = "thiserror" -version = "1.0.59" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.59" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] name = "toml" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.12", + "toml_edit 0.22.15", ] [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" dependencies = [ "serde", ] @@ -1127,15 +1109,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.12" +version = "0.22.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" +checksum = "d59a3a72298453f564e2b111fa896f8d07fabb36f51f06d7e875fc5e0b5a3ef1" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.8", + "winnow 0.6.13", ] [[package]] @@ -1220,9 +1202,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -1236,51 +1218,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -1293,18 +1275,18 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.8" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" dependencies = [ "memchr", ] [[package]] name = "zvariant" -version = "4.0.3" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e9282c6945d9e27742ba7ad7191325546636295de7b83f6735af73159b32ac7" +checksum = "1724a2b330760dc7d2a8402d841119dc869ef120b139d29862d6980e9c75bfc9" dependencies = [ "endi", "serde", @@ -1314,24 +1296,24 @@ dependencies = [ [[package]] name = "zvariant_derive" -version = "4.0.3" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0142549e559746ff09d194dd43d256a554299d286cc56460a082b8ae24652aa1" +checksum = "55025a7a518ad14518fb243559c058a2e5b848b015e31f1d90414f36e3317859" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn", "zvariant_utils", ] [[package]] name = "zvariant_utils" -version = "1.1.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75fa7291bdd68cd13c4f97cc9d78cbf16d96305856dfc7ac942aeff4c2de7d5a" +checksum = "fc242db087efc22bd9ade7aa7809e4ba828132edc312871584a6b4391bdf8786" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] diff --git a/Cargo.toml b/Cargo.toml index 3e868d9..483edf1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,10 +17,10 @@ unidecode = "0.3.0" [dependencies.gtk] package = "gtk4" -version = "0.8" +version = "0.9" features = ["v4_14", "blueprint"] [dependencies.adw] package = "libadwaita" -version = "0.6" +version = "0.7" features = ["v1_5"] diff --git a/src/widgets/custom_text_dialog.rs b/src/widgets/custom_text_dialog.rs index 62e13c1..1d92f8b 100644 --- a/src/widgets/custom_text_dialog.rs +++ b/src/widgets/custom_text_dialog.rs @@ -86,11 +86,16 @@ mod imp { .sync_create() .build(); - save_button.connect_clicked(glib::clone!(@weak self as imp => move |_| { - imp.apply_changes.set(true); - imp.obj().emit_by_name_with_values("save", &[imp.text().into()]); - imp.obj().close(); - })); + save_button.connect_clicked(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_| { + imp.apply_changes.set(true); + imp.obj() + .emit_by_name_with_values("save", &[imp.text().into()]); + imp.obj().close(); + } + )); } } impl WidgetImpl for KpCustomTextDialog {} diff --git a/src/widgets/text_language_dialog.rs b/src/widgets/text_language_dialog.rs index bea7890..a513776 100644 --- a/src/widgets/text_language_dialog.rs +++ b/src/widgets/text_language_dialog.rs @@ -72,15 +72,21 @@ mod imp { .sync_create() .build(); - self.search_entry - .connect_search_changed(glib::clone!(@weak self as imp => move |_| { + self.search_entry.connect_search_changed(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_| { imp.update_search_state(); - })); + } + )); - self.search_entry - .connect_stop_search(glib::clone!(@weak self as imp => move |_| { + self.search_entry.connect_stop_search(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_| { imp.obj().close(); - })); + } + )); } } impl WidgetImpl for KpTextLanguageDialog {} @@ -192,23 +198,34 @@ mod imp { } pub(super) fn connect_row_checked(&self, row: &KpLanguageRow) { - row.connect_checked_notify(glib::clone!(@weak self as imp => move |row| { - if row.checked() { - imp.selected_language.set(row.language()); - imp.obj().emit_by_name::<()>("language-changed", &[]); + row.connect_checked_notify(glib::clone!( + #[weak(rename_to = imp)] + self, + move |row| { + if row.checked() { + imp.selected_language.set(row.language()); + imp.obj().emit_by_name::<()>("language-changed", &[]); + } } - })); + )); self.obj().connect_local( "language-changed", false, - glib::clone!(@weak row, @weak self as imp => @default-return None, move |_| { - if row.language() == imp.selected_language.get() && !row.checked() { - row.set_checked(true); - } + glib::clone!( + #[weak] + row, + #[weak(rename_to = imp)] + self, + #[upgrade_or_default] + move |_| { + if row.language() == imp.selected_language.get() && !row.checked() { + row.set_checked(true); + } - None - }), + None + } + ), ); } diff --git a/src/widgets/text_view/colors.rs b/src/widgets/text_view/colors.rs index e73c468..4cf0ea3 100644 --- a/src/widgets/text_view/colors.rs +++ b/src/widgets/text_view/colors.rs @@ -5,8 +5,6 @@ use unicode_segmentation::UnicodeSegmentation; impl imp::KpTextView { pub(super) fn setup_color_scheme(&self) { - let obj = self.obj(); - let text_view = self.text_view.get(); let buf = text_view.buffer(); @@ -88,12 +86,20 @@ impl imp::KpTextView { tag_mistake_dark_hc.set_background_rgba(Some(&gdk::RGBA::new(0.961, 0.379, 0.316, 1.))); let style = adw::StyleManager::default(); - style.connect_dark_notify(glib::clone!(@weak obj => move |_| { - obj.imp().update_colors(); - })); - style.connect_high_contrast_notify(glib::clone!(@weak obj => move |_| { - obj.imp().update_colors(); - })); + style.connect_dark_notify(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_| { + imp.update_colors(); + } + )); + style.connect_high_contrast_notify(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_| { + imp.update_colors(); + } + )); self.update_colors(); } diff --git a/src/widgets/text_view/input.rs b/src/widgets/text_view/input.rs index 4ad2a46..4152f42 100644 --- a/src/widgets/text_view/input.rs +++ b/src/widgets/text_view/input.rs @@ -8,94 +8,124 @@ impl imp::KpTextView { input_context.set_client_widget(Some(&*obj.upcast_ref::())); - input_context.connect_commit(glib::clone!(@weak self as imp => move |_, text| { - let obj = imp.obj(); + input_context.connect_commit(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_, text| { + let obj = imp.obj(); - if obj.accepts_input() { - if !obj.running() { - obj.set_running(true); - } + if obj.accepts_input() { + if !obj.running() { + obj.set_running(true); + } - imp.push_typed_text(text); + imp.push_typed_text(text); + } } - })); + )); + + input_context.connect_preedit_changed(glib::clone!( + #[weak(rename_to = imp)] + self, + move |ctx| { + let obj = imp.obj(); - input_context.connect_preedit_changed(glib::clone!(@weak self as imp => move |ctx| { - let obj = imp.obj(); + let (preedit, _, _) = ctx.preedit_string(); + let preedit = preedit.as_str(); + let preedit_has_changed = imp.previous_preedit.borrow().as_str() != preedit; - let (preedit, _, _) = ctx.preedit_string(); - let preedit = preedit.as_str(); - let preedit_has_changed = imp.previous_preedit.borrow().as_str() != preedit; + if preedit_has_changed && obj.accepts_input() { + if !obj.running() { + obj.set_running(true); + } - if preedit_has_changed && obj.accepts_input() { - if !obj.running() { - obj.set_running(true); + *imp.previous_preedit.borrow_mut() = preedit.to_string(); + imp.typed_text_changed(); } - - *imp.previous_preedit.borrow_mut() = preedit.to_string(); - imp.typed_text_changed(); } + )); - })); - - input_context.connect_retrieve_surrounding( - glib::clone!(@weak self as imp => @default-return false, move |ctx| { + input_context.connect_retrieve_surrounding(glib::clone!( + #[weak(rename_to = imp)] + self, + #[upgrade_or_default] + move |ctx| { let current_typed = imp.typed_text.borrow(); let typed_len = current_typed.len() as i32; ctx.set_surrounding_with_selection(¤t_typed, typed_len, typed_len); true - }), - ); + } + )); - input_context.connect_delete_surrounding( - glib::clone!(@weak self as imp => @default-return false, move |_, offset, _| { + input_context.connect_delete_surrounding(glib::clone!( + #[weak(rename_to = imp)] + self, + #[upgrade_or_default] + move |_, offset, _| { // The cursor will always be at the end of the typed text, // so we can safely just pop the {offset} last characters imp.pop_typed_text(offset.abs() as usize); true - }), - ); - - obj.connect_has_focus_notify(glib::clone!(@weak input_context => move |obj| { - if obj.has_focus() { - input_context.focus_in(); - } else { - input_context.focus_out(); } - })); + )); + + obj.connect_has_focus_notify(glib::clone!( + #[weak] + input_context, + move |obj| { + if obj.has_focus() { + input_context.focus_in(); + } else { + input_context.focus_out(); + } + } + )); input_context.set_input_hints(gtk::InputHints::NO_SPELLCHECK); let click_gesture = gtk::GestureClick::new(); - click_gesture.connect_released( - glib::clone!(@weak input_context => move |controller, _, _, _| { + click_gesture.connect_released(glib::clone!( + #[weak] + input_context, + move |controller, _, _, _| { input_context.activate_osk(controller.current_event()); - }), - ); + } + )); self.obj().add_controller(click_gesture); let event_controller = gtk::EventControllerKey::new(); event_controller.set_im_context(Some(&input_context)); - event_controller.connect_key_pressed(glib::clone!(@weak self as imp => @default-return glib::signal::Propagation::Proceed, move |controller, key, _, modifier| { + event_controller.connect_key_pressed(glib::clone!( + #[weak(rename_to = imp)] + self, + #[upgrade_or] + glib::signal::Propagation::Proceed, + move |controller, key, _, modifier| { let obj = imp.obj(); match (obj.accepts_input(), key) { - (true, gdk::Key::BackSpace) if modifier.contains(gdk::ModifierType::CONTROL_MASK) => { + (true, gdk::Key::BackSpace) + if modifier.contains(gdk::ModifierType::CONTROL_MASK) => + { imp.pop_typed_text_word(); glib::signal::Propagation::Stop - }, + } (true, gdk::Key::BackSpace) => { imp.pop_typed_text(1); glib::signal::Propagation::Stop - }, + } (true, gdk::Key::Return) => { - controller.im_context().expect("input controller has im context").emit_by_name_with_values("commit", &["\n".into()]); + controller + .im_context() + .expect("input controller has im context") + .emit_by_name_with_values("commit", &["\n".into()]); glib::signal::Propagation::Stop } - _ => glib::signal::Propagation::Proceed + _ => glib::signal::Propagation::Proceed, } - })); + } + )); self.obj().add_controller(event_controller); self.input_context.replace(Some(input_context)); diff --git a/src/widgets/window.rs b/src/widgets/window.rs index 6d87b64..4923a65 100644 --- a/src/widgets/window.rs +++ b/src/widgets/window.rs @@ -232,11 +232,15 @@ mod imp { &["Sophie Herold https://www.patreon.com/sophieh"], ); - about.connect_closed(glib::clone!(@weak self as imp => move |_| { - imp.focus_text_view(); - })); - - about.present(self.obj().upcast_ref::()); + about.connect_closed(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_| { + imp.focus_text_view(); + } + )); + + about.present(Some(self.obj().upcast_ref::())); } } } diff --git a/src/widgets/window/focus.rs b/src/widgets/window/focus.rs index db15a00..bde79e9 100644 --- a/src/widgets/window/focus.rs +++ b/src/widgets/window/focus.rs @@ -4,13 +4,18 @@ const UNFOCUSED_TIMEOUT_MILLIS: u64 = 2000; impl imp::KpWindow { pub(super) fn setup_focus(&self) { - self.focus_button - .connect_clicked(glib::clone!(@weak self as imp => move |_| { + self.focus_button.connect_clicked(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_| { imp.focus_text_view(); - })); + } + )); - self.obj().connect_focus_widget_notify( - glib::clone!(@weak self as imp => move |_| { + self.obj().connect_focus_widget_notify(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_| { let text_view = imp.text_view.get(); let bottom_stack_empty = imp.bottom_stack_empty.get(); let just_start_typing = imp.just_start_typing.get(); @@ -29,34 +34,49 @@ impl imp::KpWindow { (false, _) => { let timeout = glib::timeout_add_local_once( Duration::from_millis(UNFOCUSED_TIMEOUT_MILLIS), - glib::clone!(@weak bottom_stack, - @weak focus_button, - @weak imp - => move || { - if !imp.text_view_focused() && imp.obj().visible_dialog().is_none() && imp.main_stack.visible_child_name().unwrap() == "session" { + glib::clone!( + #[weak] + bottom_stack, + #[weak] + focus_button, + #[weak] + imp, + move || { + if !imp.text_view_focused() + && imp.obj().visible_dialog().is_none() + && imp.main_stack.visible_child_name().unwrap() == "session" + { bottom_stack.set_visible_child(&focus_button); text_view.add_css_class("unfocused"); } - } - )); + } + ), + ); - let Some(previous_event) = imp.last_unfocus_event - .replace(Some(timeout)) else { return; }; + let Some(previous_event) = imp.last_unfocus_event.replace(Some(timeout)) + else { + return; + }; - let Some(previous_timestamp) = imp.last_unfocus_timestamp - .replace(Some(Instant::now())) else { return; }; + let Some(previous_timestamp) = + imp.last_unfocus_timestamp.replace(Some(Instant::now())) + else { + return; + }; - if (Instant::now() - previous_timestamp).as_millis() < UNFOCUSED_TIMEOUT_MILLIS.into() { + if (Instant::now() - previous_timestamp).as_millis() + < UNFOCUSED_TIMEOUT_MILLIS.into() + { previous_event.remove(); } } }; - }), - ); + } + )); } pub(super) fn text_view_focused(&self) -> bool { - if let Some(focus) = self.obj().focus_widget() { + if let Some(focus) = self.obj().focus() { focus == self.text_view.get() } else { false @@ -64,6 +84,6 @@ impl imp::KpWindow { } pub(super) fn focus_text_view(&self) { - self.obj().set_focus_widget(Some(&self.text_view.get())); + self.obj().set_focus(Some(&self.text_view.get())); } } diff --git a/src/widgets/window/session.rs b/src/widgets/window/session.rs index 2356c5d..0c8c7b3 100644 --- a/src/widgets/window/session.rs +++ b/src/widgets/window/session.rs @@ -22,12 +22,14 @@ impl imp::KpWindow { .position(|session_type| session_type == self.session_type.get()) .unwrap(); session_type_dropdown.set_selected(selected_type_index as u32); - session_type_dropdown.connect_selected_item_notify( - glib::clone!(@weak self as imp => move |_| { + session_type_dropdown.connect_selected_item_notify(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_| { imp.update_original_text(); imp.focus_text_view(); - }), - ); + } + )); setup_ellipsizing_dropdown_factory(&session_type_dropdown); @@ -41,20 +43,25 @@ impl imp::KpWindow { .position(|duration| duration == self.duration.get()) .unwrap(); duration_dropdown.set_selected(selected_duration_index as u32); - duration_dropdown.connect_selected_item_notify( - glib::clone!(@weak self as imp => move |_| { + duration_dropdown.connect_selected_item_notify(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_| { imp.update_time(); imp.focus_text_view(); - }), - ); + } + )); setup_ellipsizing_dropdown_factory(&duration_dropdown); - self.custom_button - .connect_clicked(glib::clone!(@weak self as imp => move |_| { + self.custom_button.connect_clicked(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_| { let current_text = imp.custom_text.borrow(); imp.show_custom_text_dialog(¤t_text); - })); + } + )); self.add_recent_language(self.language.get()); } @@ -62,44 +69,65 @@ impl imp::KpWindow { pub(super) fn setup_text_view(&self) { let text_view = self.text_view.get(); - text_view.connect_running_notify(glib::clone!(@weak self as imp => move |text_view| { - if text_view.running() { - imp.start(); - } - })); - - text_view.connect_local("typed-text-changed", true, glib::clone!(@weak self as imp => @default-return None, move |values| { - if !imp.running.get() { return None; } - - let text_view = values.get(0).unwrap().get::().unwrap(); - - let original_grapheme_count = text_view.original_grapheme_count(); - let typed_grapheme_count = text_view.typed_grapheme_count(); - - if typed_grapheme_count >= original_grapheme_count { - if text_view.last_grapheme_state() != GraphemeState::Unfinished { - imp.finish(); + text_view.connect_running_notify(glib::clone!( + #[weak(rename_to = imp)] + self, + move |text_view| { + if text_view.running() { + imp.start(); } } + )); - if typed_grapheme_count > original_grapheme_count.checked_sub(CHUNK_GRAPHEME_COUNT / 2).unwrap_or(CHUNK_GRAPHEME_COUNT) { - imp.extend_original_text(); - } - - match imp.session_type.get() { - SessionType::Simple | SessionType::Advanced => (), - SessionType::Custom => { - let (current_word, total_words) = text_view.progress(); - - // Translators: The `{}` blocks will be replaced with the current word count and the total word count. - // Do not translate them! The slash sign is a special unicode character, if your language doesn't - // use a completely different sign, you should probably copy and paste it from the original string. - imp.running_title.set_title(&i18n_fmt! { i18n_fmt("{} ⁄ {}", current_word, total_words) }); + text_view.connect_local( + "typed-text-changed", + true, + glib::clone!( + #[weak(rename_to = imp)] + self, + #[upgrade_or_default] + move |values| { + if !imp.running.get() { + return None; + } + + let text_view = values.get(0).unwrap().get::().unwrap(); + + let original_grapheme_count = text_view.original_grapheme_count(); + let typed_grapheme_count = text_view.typed_grapheme_count(); + + if typed_grapheme_count >= original_grapheme_count { + if text_view.last_grapheme_state() != GraphemeState::Unfinished { + imp.finish(); + } + } + + if typed_grapheme_count + > original_grapheme_count + .checked_sub(CHUNK_GRAPHEME_COUNT / 2) + .unwrap_or(CHUNK_GRAPHEME_COUNT) + { + imp.extend_original_text(); + } + + match imp.session_type.get() { + SessionType::Simple | SessionType::Advanced => (), + SessionType::Custom => { + let (current_word, total_words) = text_view.progress(); + + // Translators: The `{}` blocks will be replaced with the current word count and the total word count. + // Do not translate them! The slash sign is a special unicode character, if your language doesn't + // use a completely different sign, you should probably copy and paste it from the original string. + imp.running_title.set_title( + &i18n_fmt! { i18n_fmt("{} ⁄ {}", current_word, total_words) }, + ); + } + } + + None } - } - - None - })); + ), + ); } pub(super) fn update_original_text(&self) { @@ -151,27 +179,38 @@ impl imp::KpWindow { dialog.connect_local( "language-changed", true, - glib::clone!(@weak self as imp => @default-return None, move |values| { - let dialog: KpTextLanguageDialog = values - .get(0) - .expect("signal contains value at index 0") - .get() - .expect("value sent with signal is dialog"); - - imp.language.set(dialog.selected_language()); - imp.settings().set_string("text-language", &dialog.selected_language().to_string()).unwrap(); - imp.update_original_text(); - - None - }), + glib::clone!( + #[weak(rename_to = imp)] + self, + #[upgrade_or_default] + move |values| { + let dialog: KpTextLanguageDialog = values + .get(0) + .expect("signal contains value at index 0") + .get() + .expect("value sent with signal is dialog"); + + imp.language.set(dialog.selected_language()); + imp.settings() + .set_string("text-language", &dialog.selected_language().to_string()) + .unwrap(); + imp.update_original_text(); + + None + } + ), ); - dialog.connect_closed(glib::clone!(@weak self as imp => move |dialog| { - imp.add_recent_language(dialog.selected_language()); - imp.focus_text_view(); - })); + dialog.connect_closed(glib::clone!( + #[weak(rename_to = imp)] + self, + move |dialog| { + imp.add_recent_language(dialog.selected_language()); + imp.focus_text_view(); + } + )); - dialog.present(self.obj().upcast_ref::()); + dialog.present(Some(self.obj().upcast_ref::())); } fn add_recent_language(&self, language: Language) { @@ -210,50 +249,70 @@ impl imp::KpWindow { dialog.connect_local( "save", true, - glib::clone!(@weak self as imp => @default-return None, move |values| { - let text: &str = values - .get(1) - .expect("save signal contains text to be saved") - .get().expect("value from save signal is string"); - - imp.settings().set_string("custom-text", &text).unwrap(); - *imp.custom_text.borrow_mut() = text.to_string(); - imp.update_original_text(); - - None - }), + glib::clone!( + #[weak(rename_to = imp)] + self, + #[upgrade_or_default] + move |values| { + let text: &str = values + .get(1) + .expect("save signal contains text to be saved") + .get() + .expect("value from save signal is string"); + + imp.settings().set_string("custom-text", &text).unwrap(); + *imp.custom_text.borrow_mut() = text.to_string(); + imp.update_original_text(); + + None + } + ), ); dialog.connect_local( "discard", true, - glib::clone!(@weak self as imp => @default-return None, move |values| { - let discarded_text: String = values - .get(1) - .expect("save signal contains text to be saved") - .get::<&str>().expect("value from save signal is string") - .into(); - - let toast = adw::Toast::builder() - .title(&gettext("Changes discarded")) - .button_label(&gettext("Restore")) - .build(); - - toast.connect_button_clicked(glib::clone!(@weak imp => move |_| { - imp.show_custom_text_dialog(&discarded_text); - })); - - imp.toast_overlay.add_toast(toast); - - None - }), + glib::clone!( + #[weak(rename_to = imp)] + self, + #[upgrade_or_default] + move |values| { + let discarded_text: String = values + .get(1) + .expect("save signal contains text to be saved") + .get::<&str>() + .expect("value from save signal is string") + .into(); + + let toast = adw::Toast::builder() + .title(&gettext("Changes discarded")) + .button_label(&gettext("Restore")) + .build(); + + toast.connect_button_clicked(glib::clone!( + #[weak] + imp, + move |_| { + imp.show_custom_text_dialog(&discarded_text); + } + )); + + imp.toast_overlay.add_toast(toast); + + None + } + ), ); - dialog.connect_closed(glib::clone!(@weak self as imp => move |_| { - imp.focus_text_view(); - })); + dialog.connect_closed(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_| { + imp.focus_text_view(); + } + )); - dialog.present(self.obj().upcast_ref::()); + dialog.present(Some(self.obj().upcast_ref::())); } pub(super) fn extend_original_text(&self) { @@ -281,22 +340,35 @@ impl imp::KpWindow { glib::timeout_add_local( Duration::from_millis(100), - glib::clone!(@weak self as imp, @strong duration => @default-return ControlFlow::Break, move || { - let start_time = imp.start_time.get().expect("start time is set when session is running"); - - if !imp.running.get() { return ControlFlow::Break; }; - - if let Some(diff) = duration.checked_sub(start_time.elapsed()) { - let seconds = diff.as_secs() + 1; - - // add trailing zero for second values below 10 - imp.update_timer(seconds); - ControlFlow::Continue - } else { - imp.finish(); - ControlFlow::Break + glib::clone!( + #[weak(rename_to = imp)] + self, + #[strong] + duration, + #[upgrade_or] + ControlFlow::Break, + move || { + let start_time = imp + .start_time + .get() + .expect("start time is set when session is running"); + + if !imp.running.get() { + return ControlFlow::Break; + }; + + if let Some(diff) = duration.checked_sub(start_time.elapsed()) { + let seconds = diff.as_secs() + 1; + + // add trailing zero for second values below 10 + imp.update_timer(seconds); + ControlFlow::Continue + } else { + imp.finish(); + ControlFlow::Break + } } - }), + ), ); } @@ -395,10 +467,13 @@ impl imp::KpWindow { self.main_stack.set_visible_child_name("results"); - self.obj().set_focus_widget(None::<>k::Widget>); + self.obj().set_focus(None::<>k::Widget>); glib::timeout_add_local_once( Duration::from_millis(500), - glib::clone!(@weak continue_button => move || { + glib::clone!( + #[weak] + continue_button, + move || { continue_button.grab_focus(); } ), @@ -427,29 +502,50 @@ fn setup_ellipsizing_dropdown_factory(dropdown: >k::DropDown) { .set_child(Some(&box_)); }); - factory.connect_bind(glib::clone!(@weak dropdown => move |_, obj| { - let list_item = obj.downcast_ref::().unwrap(); - let child = list_item.child().unwrap(); - let box_ = child.downcast_ref::().unwrap(); - let first_child = box_.first_child().unwrap(); - let last_child = box_.last_child().unwrap(); - let string_object = list_item.item().unwrap().downcast::().unwrap(); - - let label = first_child.downcast_ref::().unwrap(); - label.set_label(string_object.string().as_str()); - - let is_in_popover = child.parent().unwrap().parent().unwrap().type_() == gtk::ListView::static_type(); - - if is_in_popover { - label.set_ellipsize(pango::EllipsizeMode::None); - dropdown.connect_selected_item_notify(glib::clone!(@weak last_child, @weak string_object => move |dropdown| { - last_child.set_opacity(if dropdown.selected_item().unwrap() == string_object { 1. } else { 0. }); - })); - } else { - label.set_ellipsize(pango::EllipsizeMode::End); - last_child.set_visible(false); + factory.connect_bind(glib::clone!( + #[weak] + dropdown, + move |_, obj| { + let list_item = obj.downcast_ref::().unwrap(); + let child = list_item.child().unwrap(); + let box_ = child.downcast_ref::().unwrap(); + let first_child = box_.first_child().unwrap(); + let last_child = box_.last_child().unwrap(); + let string_object = list_item + .item() + .unwrap() + .downcast::() + .unwrap(); + + let label = first_child.downcast_ref::().unwrap(); + label.set_label(string_object.string().as_str()); + + let is_in_popover = + child.parent().unwrap().parent().unwrap().type_() == gtk::ListView::static_type(); + + if is_in_popover { + label.set_ellipsize(pango::EllipsizeMode::None); + dropdown.connect_selected_item_notify(glib::clone!( + #[weak] + last_child, + #[weak] + string_object, + move |dropdown| { + last_child.set_opacity( + if dropdown.selected_item().unwrap() == string_object { + 1. + } else { + 0. + }, + ); + } + )); + } else { + label.set_ellipsize(pango::EllipsizeMode::End); + last_child.set_visible(false); + } } - })); + )); dropdown.set_factory(Some(&factory)); dropdown.notify("selected-item"); diff --git a/src/widgets/window/ui_state.rs b/src/widgets/window/ui_state.rs index 280f6c9..3f86f6a 100644 --- a/src/widgets/window/ui_state.rs +++ b/src/widgets/window/ui_state.rs @@ -2,17 +2,23 @@ use super::*; impl imp::KpWindow { pub(super) fn setup_stop_button(&self) { - self.stop_button - .connect_clicked(glib::clone!(@weak self as imp => move |_| { + self.stop_button.connect_clicked(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_| { imp.ready(); - })); + } + )); } pub(super) fn setup_continue_button(&self) { - self.continue_button - .connect_clicked(glib::clone!(@weak self as imp => move |_| { + self.continue_button.connect_clicked(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_| { imp.ready(); - })); + } + )); } pub(super) fn setup_ui_hiding(&self) { @@ -30,38 +36,54 @@ impl imp::KpWindow { self.text_view.connect_local( "typed-text-changed", true, - glib::clone!(@weak self as imp, @strong device => @default-return None, move |_| { - if imp.show_cursor.get() && imp.running.get() { - imp.header_bar_running.add_css_class("hide-controls"); - imp.hide_cursor(); + glib::clone!( + #[weak(rename_to = imp)] + self, + #[upgrade_or_default] + move |_| { + if imp.show_cursor.get() && imp.running.get() { + imp.header_bar_running.add_css_class("hide-controls"); + imp.hide_cursor(); + } + + None } - - None - }), + ), ); let motion_ctrl = gtk::EventControllerMotion::new(); - motion_ctrl.connect_motion(glib::clone!(@weak self as imp, @strong device => move |_,_,_| { - if !imp.show_cursor.get() && device.timestamp() > imp.cursor_hidden_timestamp.get() { - imp.show_cursor(); - - if imp.running.get() { - imp.header_bar_running.remove_css_class("hide-controls"); + motion_ctrl.connect_motion(glib::clone!( + #[weak(rename_to = imp)] + self, + #[strong] + device, + move |_, _, _| { + if !imp.show_cursor.get() && device.timestamp() > imp.cursor_hidden_timestamp.get() + { + imp.show_cursor(); + + if imp.running.get() { + imp.header_bar_running.remove_css_class("hide-controls"); + } } } - })); + )); obj.add_controller(motion_ctrl); let click_gesture = gtk::GestureClick::new(); - click_gesture.connect_released(glib::clone!(@weak self as imp => move |_, _, _, _| { - if !imp.show_cursor.get() { - imp.show_cursor(); - - if imp.running.get() { - imp.header_bar_running.remove_css_class("hide-controls"); + click_gesture.connect_released(glib::clone!( + #[weak(rename_to = imp)] + self, + move |_, _, _, _| { + if !imp.show_cursor.get() { + imp.show_cursor(); + + if imp.running.get() { + imp.header_bar_running.remove_css_class("hide-controls"); + } } } - })); + )); obj.add_controller(click_gesture); }