From 5fc51ecda078373f0d2e2223f537a992d3a40854 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sun, 2 Feb 2025 18:32:17 +0100 Subject: [PATCH] wip --- Cargo.lock | 309 ++++++++------------- Cargo.toml | 30 +- src/components/base/card_entry.rs | 26 +- src/components/base/error.rs | 13 +- src/components/bluetooth/bluetooth_box.rs | 38 ++- src/components/wifi/saved_wifi_entry.rs | 35 ++- src/components/wifi/wifi_address_entry.rs | 185 ++++++------ src/components/wifi/wifi_box.rs | 12 +- src/components/wifi/wifi_entry.rs | 83 ++++-- src/components/wifi/wifi_event_handlers.rs | 2 +- src/components/wifi/wifi_options.rs | 146 ++++++---- src/components/wifi/wifi_route_entry.rs | 199 +++++++------ src/components/window/reset_window.rs | 14 +- src/components/window/sidebar_entry.rs | 2 +- 14 files changed, 596 insertions(+), 498 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0530042..1342bbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,12 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "anyhow" -version = "1.0.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" - [[package]] name = "autocfg" version = "1.2.0" @@ -52,28 +46,27 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] name = "cairo-rs" -version = "0.19.4" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ac2a4d0e69036cf0062976f6efcba1aaee3e448594e6514bb2ddf87acce562" +checksum = "ae50b5510d86cf96ac2370e66d8dc960882f3df179d6a5a1e52bd94a1416c0f7" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.8.0", "cairo-sys-rs", "glib", "libc", - "thiserror", ] [[package]] name = "cairo-sys-rs" -version = "0.19.2" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3bb3119664efbd78b5e6c93957447944f16bdbced84c17a9f41c7829b81e64" +checksum = "f18b6bb8e43c7eb0f2aac7976afe0c61b6f5fc2ab7bc4c139537ea56c92290df" dependencies = [ "glib-sys", "libc", @@ -88,9 +81,9 @@ checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" [[package]] name = "cfg-expr" -version = "0.15.8" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" +checksum = "8d4ba6e40bd1184518716a6e1a781bf9160e286d219ccdb8ab2612e74cfe4789" dependencies = [ "smallvec", "target-lexicon", @@ -158,19 +151,6 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "dbus" version = "0.9.7" @@ -222,9 +202,9 @@ dependencies = [ [[package]] name = "fork" -version = "0.1.23" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60e74d3423998a57e9d906e49252fb79eb4a04d5cdfe188fb1b7ff9fc076a8ed" +checksum = "05dc8b302e04a1c27f4fe694439ef0f29779ca4edc205b7b58f00db04e29656d" dependencies = [ "libc", ] @@ -285,7 +265,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.98", ] [[package]] @@ -320,9 +300,9 @@ dependencies = [ [[package]] name = "gdk-pixbuf" -version = "0.19.2" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6a23f8a0b5090494fd04924662d463f8386cc678dd3915015a838c1a3679b92" +checksum = "b6efc7705f7863d37b12ad6974cbb310d35d054f5108cdc1e69037742f573c4c" dependencies = [ "gdk-pixbuf-sys", "gio", @@ -332,9 +312,9 @@ dependencies = [ [[package]] name = "gdk-pixbuf-sys" -version = "0.19.0" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcbd04c1b2c4834cc008b4828bc917d062483b88d26effde6342e5622028f96" +checksum = "67f2587c9202bf997476bbba6aaed4f78a11538a2567df002a5f57f5331d0b5c" dependencies = [ "gio-sys", "glib-sys", @@ -345,9 +325,9 @@ dependencies = [ [[package]] name = "gdk4" -version = "0.8.1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9100b25604183f2fd97f55ef087fae96ab4934d7215118a35303e422688e6e4b" +checksum = "d0196720118f880f71fe7da971eff58cc43a89c9cf73f46076b7cb1e60889b15" dependencies = [ "cairo-rs", "gdk-pixbuf", @@ -360,9 +340,9 @@ dependencies = [ [[package]] name = "gdk4-sys" -version = "0.8.1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0b76874c40bb8d1c7d03a7231e23ac75fa577a456cd53af32ec17ec8f121626" +checksum = "60b0e1340bd15e7a78810cf39fed9e5d85f0a8f80b1d999d384ca17dcc452b60" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -383,9 +363,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "gio" -version = "0.19.4" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f91a0518c2ec539f099d3f945ab2d6a83ec372a9ef40a21906343b191182845" +checksum = "a517657589a174be9f60c667f1fec8b7ac82ed5db4ebf56cf073a3b5955d8e2e" dependencies = [ "futures-channel", "futures-core", @@ -396,14 +376,13 @@ dependencies = [ "libc", "pin-project-lite", "smallvec", - "thiserror", ] [[package]] name = "gio-sys" -version = "0.19.0" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf8e1d9219bb294636753d307b030c1e8a032062cba74f493c431a5c8b81ce4" +checksum = "8446d9b475730ebef81802c1738d972db42fde1c5a36a627ebc4d665fc87db04" dependencies = [ "glib-sys", "gobject-sys", @@ -414,11 +393,11 @@ dependencies = [ [[package]] name = "glib" -version = "0.19.4" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1407b2ce171e654720be10d57d4054d3ff2f10a13d5b37e6819b41439832f7" +checksum = "f969edf089188d821a30cde713b6f9eb08b20c63fc2e584aba2892a7984a8cc0" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.8.0", "futures-channel", "futures-core", "futures-executor", @@ -431,36 +410,35 @@ dependencies = [ "libc", "memchr", "smallvec", - "thiserror", ] [[package]] name = "glib-build-tools" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "108f374fff60efd14b0d70d8916e7213aed18d7dd071ba3e9334ed2dac1dc86a" +checksum = "7029c2651d9b5d5a3eea93ec8a1995665c6d3a69ce9bf6042ad9064d134736d8" dependencies = [ "gio", ] [[package]] name = "glib-macros" -version = "0.19.4" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8bba315e8ce8aa59631545358450f4962557e89b5f7db7442e7153b47037f71" +checksum = "715601f8f02e71baef9c1f94a657a9a77c192aea6097cf9ae7e5e177cd8cde68" dependencies = [ "heck", "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.98", ] [[package]] name = "glib-sys" -version = "0.19.0" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630f097773d7c7a0bb3258df4e8157b47dc98bbfa0e60ad9ab56174813feced4" +checksum = "b360ff0f90d71de99095f79c526a5888c9c92fc9ee1b19da06c6f5e75f0c2a53" dependencies = [ "libc", "system-deps", @@ -468,9 +446,9 @@ dependencies = [ [[package]] name = "gobject-sys" -version = "0.19.0" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e2b1080b9418dd0c58b498da3a5c826030343e0ef07bde6a955d28de54979" +checksum = "67a56235e971a63bfd75abb13ef70064e1346388723422a68580d8a6fbac6423" dependencies = [ "glib-sys", "libc", @@ -479,9 +457,9 @@ dependencies = [ [[package]] name = "graphene-rs" -version = "0.19.2" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e4d388e96c5f29e2b2f67045d229ddf826d0a8d6d282f94ed3b34452222c91" +checksum = "f39d3bcd2e24fd9c2874a56f277b72c03e728de9bdc95a8d4ef4c962f10ced98" dependencies = [ "glib", "graphene-sys", @@ -490,9 +468,9 @@ dependencies = [ [[package]] name = "graphene-sys" -version = "0.19.0" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "236ed66cc9b18d8adf233716f75de803d0bf6fc806f60d14d948974a12e240d0" +checksum = "11a68d39515bf340e879b72cecd4a25c1332557757ada6e8aba8654b4b81d23a" dependencies = [ "glib-sys", "libc", @@ -502,9 +480,9 @@ dependencies = [ [[package]] name = "gsk4" -version = "0.8.1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c65036fc8f99579e8cb37b12487969b707ab23ec8ab953682ff347cbd15d396e" +checksum = "32b9188db0a6219e708b6b6e7225718e459def664023dbddb8395ca1486d8102" dependencies = [ "cairo-rs", "gdk4", @@ -517,9 +495,9 @@ dependencies = [ [[package]] name = "gsk4-sys" -version = "0.8.1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd24c814379f9c3199dc53e52253ee8d0f657eae389ab282c330505289d24738" +checksum = "bca10fc65d68528a548efa3d8747934adcbe7058b73695c9a7f43a25352fce14" dependencies = [ "cairo-sys-rs", "gdk4-sys", @@ -533,9 +511,9 @@ dependencies = [ [[package]] name = "gtk4" -version = "0.8.1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa82753b8c26277e4af1446c70e35b19aad4fb794a7b143859e7eeb9a4025d83" +checksum = "b697ff938136625f6acf75f01951220f47a45adcf0060ee55b4671cf734dac44" dependencies = [ "cairo-rs", "field-offset", @@ -554,23 +532,21 @@ dependencies = [ [[package]] name = "gtk4-macros" -version = "0.8.1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40300bf071d2fcd4c94eacc09e84ec6fe73129d2ceb635cf7e55b026b5443567" +checksum = "0ed1786c4703dd196baf7e103525ce0cf579b3a63a0570fe653b7ee6bac33999" dependencies = [ - "anyhow", "proc-macro-crate", - "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.98", ] [[package]] name = "gtk4-sys" -version = "0.8.1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0db1b104138f087ccdc81d2c332de5dd049b89de3d384437cc1093b17cd2da18" +checksum = "3af4b680cee5d2f786a2f91f1c77e95ecf2254522f0ca4edf3a2dce6cb35cecf" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -587,9 +563,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "heck" @@ -605,9 +581,9 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "indexmap" -version = "2.2.6" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", "hashbrown", @@ -615,26 +591,16 @@ dependencies = [ [[package]] name = "ipnetwork" -version = "0.20.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf466541e9d546596ee94f9f69590f89473455f88372423e0008fc1a7daf100e" -dependencies = [ - "serde", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "cf370abdafd54d13e54a620e8c3e1145f28e46cc9d704bc6d94414559df41763" [[package]] name = "libadwaita" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91b4990248b9e1ec5e72094a2ccaea70ec3809f88f6fd52192f2af306b87c5d9" +checksum = "8611ee9fb85e7606c362b513afcaf5b59853f79e4d98caaaf581d99465014247" dependencies = [ - "gdk-pixbuf", "gdk4", "gio", "glib", @@ -646,9 +612,9 @@ dependencies = [ [[package]] name = "libadwaita-sys" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a748e4e92be1265cd9e93d569c0b5dfc7814107985aa6743d670ab281ea1a8" +checksum = "b099a223560118d4d4fa04b6d23f3ea5b7171fe1d83dfb7e6b45b54cdfc83af9" dependencies = [ "gdk4-sys", "gio-sys", @@ -677,9 +643,9 @@ dependencies = [ [[package]] name = "libloading" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", "windows-targets 0.52.5", @@ -687,9 +653,9 @@ dependencies = [ [[package]] name = "libpulse-binding" -version = "2.28.1" +version = "2.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed3557a2dfc380c8f061189a01c6ae7348354e0c9886038dc6c171219c08eaff" +checksum = "b6b1040a6c4c4d1e9e852000f6202df1a02a4f074320de336ab21e4fd317b538" dependencies = [ "bitflags 1.3.2", "libc", @@ -730,9 +696,9 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[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" @@ -804,15 +770,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "pango" -version = "0.19.3" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1264d13deb823cc652f26cfe59afb1ec4b9db2a5bd27c41b738c879cc1bfaa1" +checksum = "9e89bd74250a03a05cec047b43465469102af803be2bf5e5a1088f8b8455e087" dependencies = [ "gio", "glib", @@ -822,9 +788,9 @@ dependencies = [ [[package]] name = "pango-sys" -version = "0.19.0" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52ef6a881c19fbfe3b1484df5cad411acaaba29dbec843941c3110d19f340ea" +checksum = "71787e0019b499a5eda889279e4adb455a4f3fdd6870cd5ab7f4a5aa25df6699" dependencies = [ "glib-sys", "gobject-sys", @@ -882,35 +848,11 @@ dependencies = [ "toml_edit 0.21.1", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -927,8 +869,7 @@ dependencies = [ [[package]] name = "re_set-lib" version = "5.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69ec9fc4d9e919feb030e5382de1aa49447404a57ecc19361bf7710f1cf9063e" +source = "git+https://github.com/Xetibo/ReSet-Lib.git?branch=dashie-2#5aaadeaa68272d563177399fa546f62a14f90bf8" dependencies = [ "dbus", "dbus-crossroads", @@ -969,8 +910,7 @@ dependencies = [ [[package]] name = "reset_daemon" version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f72dd51da41c2fc3ac37ae55fbdeb2670d32cad39cc85cc95a9ea25fc02b6086" +source = "git+https://github.com/Xetibo/ReSet-Daemon.git?branch=dashie-2#5b630a497278b55a6321830971a7c219732f993d" dependencies = [ "crossbeam", "dbus", @@ -1000,12 +940,27 @@ dependencies = [ "semver", ] +[[package]] +name = "scc" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28e1c91382686d21b5ac7959341fcb9780fa7c03773646995a87c950fa7be640" +dependencies = [ + "sdd", +] + [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sdd" +version = "3.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478f121bb72bbf63c52c93011ea1791dca40140dfe13f8336c4c5ac952c33aa9" + [[package]] name = "semver" version = "1.0.22" @@ -1029,41 +984,41 @@ checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.98", ] [[package]] name = "serde_spanned" -version = "0.6.5" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] [[package]] name = "serial_test" -version = "3.0.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ad9342b3aaca7cb43c45c097dd008d4907070394bd0751a0aa8817e5a018d" +checksum = "1b258109f244e1d6891bf1053a55d63a5cd4f8f4c30cf9a1280989f80e7a1fa9" dependencies = [ - "dashmap", "futures", - "lazy_static", "log", + "once_cell", "parking_lot", + "scc", "serial_test_derive", ] [[package]] name = "serial_test_derive" -version = "3.0.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93fb4adc70021ac1b47f7d45e8cc4169baaa7ea58483bc5b721d19a26202212" +checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.98", ] [[package]] @@ -1104,9 +1059,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.59" +version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", @@ -1115,9 +1070,9 @@ dependencies = [ [[package]] name = "system-deps" -version = "6.2.2" +version = "7.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" +checksum = "66d23aaf9f331227789a99e8de4c91bf46703add012bdfd45fdecdfb2975a005" dependencies = [ "cfg-expr", "heck", @@ -1128,29 +1083,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.14" +version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" - -[[package]] -name = "thiserror" -version = "1.0.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.59", -] +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tokio" @@ -1176,26 +1111,26 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.98", ] [[package]] name = "toml" -version = "0.8.12" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.9", + "toml_edit 0.22.23", ] [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] @@ -1213,15 +1148,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.9" +version = "0.22.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" +checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.6", + "winnow 0.7.0", ] [[package]] @@ -1236,12 +1171,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1420,9 +1349,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.6" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" +checksum = "7e49d2d35d3fad69b39b94139037ecfb4f359f08958b9c11e7315ce770462419" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 6c37d34..630d2d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,22 +11,24 @@ name = "ReSet" path = "src/main.rs" [dependencies] -reset_daemon = "2.2.0" -re_set-lib = "5.2.5" -adw = { version = "0.6.0", package = "libadwaita", features = ["v1_4"] } +#reset_daemon = "2.2.0" +reset_daemon = { git = "https://github.com/Xetibo/ReSet-Daemon.git", branch = "dashie-2" } +#re_set-lib = "5.2.5" +re_set-lib = { git = "https://github.com/Xetibo/ReSet-Lib.git", branch = "dashie-2" } +adw = { version = "0.7.1", package = "libadwaita", features = ["v1_4"] } dbus = "0.9.7" -gtk = { version = "0.8.1", package = "gtk4", features = ["v4_12"] } -glib = "0.19.3" +gtk = { version = "0.9.5", package = "gtk4", features = ["v4_12"] } +glib = "0.20.7" tokio = { version = "1.36.0", features = [ - "rt", - "time", - "net", - "macros", - "rt-multi-thread", - "sync", + "rt", + "time", + "net", + "macros", + "rt-multi-thread", + "sync", ] } -fork = "0.1.23" -ipnetwork = "0.20.0" +fork = "0.2.0" +ipnetwork = "0.21.1" [build-dependencies] -glib-build-tools = "0.19.0" +glib-build-tools = "0.20.0" diff --git a/src/components/base/card_entry.rs b/src/components/base/card_entry.rs index e0e82f1..b8bf7e9 100644 --- a/src/components/base/card_entry.rs +++ b/src/components/base/card_entry.rs @@ -45,18 +45,22 @@ impl CardEntry { entry.set_model(Some(&list)); entry.set_selected(index); entry.set_use_subtitle(true); - entry.connect_selected_notify(clone!(@weak imp => move |dropdown| { - let selected = dropdown.selected_item(); - if selected.is_none() { - return; + entry.connect_selected_notify(clone!( + #[weak] + imp, + move |dropdown| { + let selected = dropdown.selected_item(); + if selected.is_none() { + return; + } + let selected = selected.unwrap(); + let selected = selected.downcast_ref::().unwrap(); + let selected = selected.string().to_string(); + let map = imp.reset_card_map.borrow(); + let (device_index, profile_name) = map.get(&selected).unwrap(); + set_card_profile_of_device(*device_index, profile_name.clone()); } - let selected = selected.unwrap(); - let selected = selected.downcast_ref::().unwrap(); - let selected = selected.string().to_string(); - let map = imp.reset_card_map.borrow(); - let (device_index, profile_name) = map.get(&selected).unwrap(); - set_card_profile_of_device(*device_index, profile_name.clone()); - })); + )); entry.set_factory(Some(&create_dropdown_label_factory())); } entry diff --git a/src/components/base/error.rs b/src/components/base/error.rs index 84afc07..1fcd9fa 100644 --- a/src/components/base/error.rs +++ b/src/components/base/error.rs @@ -20,12 +20,13 @@ unsafe impl Sync for ReSetError {} impl ReSetError { pub fn new() -> Self { let error: ReSetError = Object::builder().build(); - error - .imp() - .reset_error_button - .connect_clicked(clone!(@strong error => move |_| { - error.popdown(); - })); + error.imp().reset_error_button.connect_clicked(clone!( + #[strong] + error, + move |_| { + error.popdown(); + } + )); error } } diff --git a/src/components/bluetooth/bluetooth_box.rs b/src/components/bluetooth/bluetooth_box.rs index d299908..91c0c4b 100644 --- a/src/components/bluetooth/bluetooth_box.rs +++ b/src/components/bluetooth/bluetooth_box.rs @@ -17,7 +17,7 @@ use gtk::{gio, StringObject}; use re_set_lib::{ bluetooth::bluetooth_structures::{BluetoothAdapter, BluetoothDevice}, signals::{BluetoothDeviceAdded, BluetoothDeviceChanged, BluetoothDeviceRemoved}, - ERROR + ERROR, }; #[cfg(debug_assertions)] @@ -90,23 +90,31 @@ fn setup_callbacks( let bluetooth_box_discover = bluetooth_box.clone(); imp.reset_bluetooth_discoverable_switch - .connect_active_notify(clone!(@weak imp => move |state| { - set_bluetooth_adapter_visibility( - imp.reset_current_bluetooth_adapter.borrow().path.clone(), - state.is_active(), - bluetooth_box_discover.clone() - ); - })); + .connect_active_notify(clone!( + #[weak] + imp, + move |state| { + set_bluetooth_adapter_visibility( + imp.reset_current_bluetooth_adapter.borrow().path.clone(), + state.is_active(), + bluetooth_box_discover.clone(), + ); + } + )); let bluetooth_box_pairable = bluetooth_box.clone(); imp.reset_bluetooth_pairable_switch - .connect_active_notify(clone!(@weak imp => move |state| { - set_bluetooth_adapter_pairability( - imp.reset_current_bluetooth_adapter.borrow().path.clone(), - state.is_active(), - bluetooth_box_pairable.clone() - ); - })); + .connect_active_notify(clone!( + #[weak] + imp, + move |state| { + set_bluetooth_adapter_pairability( + imp.reset_current_bluetooth_adapter.borrow().path.clone(), + state.is_active(), + bluetooth_box_pairable.clone(), + ); + } + )); imp.reset_bluetooth_switch .connect_state_set(move |_, state| { diff --git a/src/components/wifi/saved_wifi_entry.rs b/src/components/wifi/saved_wifi_entry.rs index 985edbd..ba64c5b 100644 --- a/src/components/wifi/saved_wifi_entry.rs +++ b/src/components/wifi/saved_wifi_entry.rs @@ -45,20 +45,31 @@ impl SavedWifiEntry { suffix_box.append(&delete_button); entry.add_suffix(&suffix_box); - edit_button.connect_clicked( - clone!(@ weak entry_imp, @ weak wifi_box => move |_| { - let _option = get_connection_settings(entry_imp.reset_connection_path.borrow().clone()); - wifi_box.reset_wifi_navigation.push(&*WifiOptions::new(_option, entry_imp.reset_connection_path.borrow().clone())); - }), - ); + edit_button.connect_clicked(clone!( + #[weak] + entry_imp, + #[weak] + wifi_box, + move |_| { + let _option = + get_connection_settings(entry_imp.reset_connection_path.borrow().clone()); + wifi_box.reset_wifi_navigation.push(&*WifiOptions::new( + _option, + entry_imp.reset_connection_path.borrow().clone(), + )); + } + )); let entry_ref = entry.clone(); - delete_button.connect_clicked(clone!(@weak wifi_box => move |_| { - delete_connection(entry_ref.imp().reset_connection_path.take()); - // FUTURE TODO: handle error - wifi_box.reset_stored_wifi_list.remove(&*entry_ref); - - })); + delete_button.connect_clicked(clone!( + #[weak] + wifi_box, + move |_| { + delete_connection(entry_ref.imp().reset_connection_path.take()); + // FUTURE TODO: handle error + wifi_box.reset_stored_wifi_list.remove(&*entry_ref); + } + )); entry } } diff --git a/src/components/wifi/wifi_address_entry.rs b/src/components/wifi/wifi_address_entry.rs index 3d3264d..45cfab7 100644 --- a/src/components/wifi/wifi_address_entry.rs +++ b/src/components/wifi/wifi_address_entry.rs @@ -51,94 +51,123 @@ impl WifiAddressEntry { let self_imp = self.imp(); let conn = connection.clone(); - self_imp.reset_address_address.connect_changed(clone!(@weak self_imp => move |entry| { - let address_input = entry.text(); - let mut conn = conn.borrow_mut(); + self_imp.reset_address_address.connect_changed(clone!( + #[weak] + self_imp, + move |entry| { + let address_input = entry.text(); + let mut conn = conn.borrow_mut(); - if address_input.is_empty() { - self_imp.reset_address_address.remove_css_class("error"); - self_imp.reset_address_row.set_title("Add new address"); - return; - } - let result = match self_imp.protocol.get() { - IpProtocol::IPv4 => Ipv4Addr::from_str(address_input.as_str()).map(IpAddr::V4), - IpProtocol::IPv6 => Ipv6Addr::from_str(address_input.as_str()).map(IpAddr::V6), - }; - match result { - Ok(ip_addr) => { + if address_input.is_empty() { self_imp.reset_address_address.remove_css_class("error"); - let address_data = match self_imp.protocol.get() { - IpProtocol::IPv4 => &mut conn.ipv4.address_data, - IpProtocol::IPv6 => &mut conn.ipv6.address_data, - }; - address_data.push(Address::new_no_options(ip_addr.to_string(), self_imp.prefix.get().1)); - *self_imp.address.borrow_mut() = (true, ip_addr.to_string()); + self_imp.reset_address_row.set_title("Add new address"); + return; } - Err(_) => { - self_imp.reset_address_address.add_css_class("error"); - *self_imp.address.borrow_mut() = (false, String::default()); + let result = match self_imp.protocol.get() { + IpProtocol::IPv4 => Ipv4Addr::from_str(address_input.as_str()).map(IpAddr::V4), + IpProtocol::IPv6 => Ipv6Addr::from_str(address_input.as_str()).map(IpAddr::V6), + }; + match result { + Ok(ip_addr) => { + self_imp.reset_address_address.remove_css_class("error"); + let address_data = match self_imp.protocol.get() { + IpProtocol::IPv4 => &mut conn.ipv4.address_data, + IpProtocol::IPv6 => &mut conn.ipv6.address_data, + }; + address_data.push(Address::new_no_options( + ip_addr.to_string(), + self_imp.prefix.get().1, + )); + *self_imp.address.borrow_mut() = (true, ip_addr.to_string()); + } + Err(_) => { + self_imp.reset_address_address.add_css_class("error"); + *self_imp.address.borrow_mut() = (false, String::default()); + } } - } - set_row_name(&self_imp); - })); - - let conn = connection.clone(); - self_imp.reset_address_prefix.connect_changed(clone!(@weak self_imp => move |entry| { - let prefix_input = entry.text(); - let prefix = prefix_input.parse::(); - let mut conn = conn.borrow_mut(); - - let handle_error = || { - if self_imp.reset_address_prefix.text().is_empty() { - self_imp.reset_address_prefix.remove_css_class("error"); - } else { - self_imp.reset_address_prefix.add_css_class("error"); - } - self_imp.prefix.set((false, 0)); set_row_name(&self_imp); - }; - - if prefix_input.is_empty() || prefix.is_err() { - handle_error(); - return; } - - let prefix = prefix.unwrap(); - match self_imp.protocol.get() { - IpProtocol::IPv4 if prefix <= 32 => { - self_imp.prefix.set((true, prefix as u32)); - self_imp.reset_address_prefix.remove_css_class("error"); - if let Ok(address2) = Ipv4Addr::from_str(self_imp.reset_address_address.text().as_str()) { - if let Some(addr) = conn.ipv4.address_data.iter_mut() - .find(|conn_addr| *conn_addr.address == address2.to_string()) { - addr.prefix = prefix as u32; - } - } - } - IpProtocol::IPv6 if prefix <= 128 => { - self_imp.prefix.set((true, prefix as u32)); - self_imp.reset_address_prefix.remove_css_class("error"); - if let Ok(address2) = Ipv6Addr::from_str(self_imp.reset_address_address.text().as_str()) { - if let Some(addr) = conn.ipv6.address_data.iter_mut() - .find(|conn_addr| *conn_addr.address == address2.to_string()) { - addr.prefix = prefix as u32; - } - } - } - _ => handle_error() - } - set_row_name(&self_imp); - })); + )); let conn = connection.clone(); - self_imp.reset_address_remove.connect_clicked( - clone!(@weak self_imp, @weak self as what => move |_| { + self_imp.reset_address_prefix.connect_changed(clone!( + #[weak] + self_imp, + move |entry| { + let prefix_input = entry.text(); + let prefix = prefix_input.parse::(); + let mut conn = conn.borrow_mut(); + + let handle_error = || { + if self_imp.reset_address_prefix.text().is_empty() { + self_imp.reset_address_prefix.remove_css_class("error"); + } else { + self_imp.reset_address_prefix.add_css_class("error"); + } + self_imp.prefix.set((false, 0)); + set_row_name(&self_imp); + }; + + if prefix_input.is_empty() || prefix.is_err() { + handle_error(); + return; + } + + let prefix = prefix.unwrap(); + match self_imp.protocol.get() { + IpProtocol::IPv4 if prefix <= 32 => { + self_imp.prefix.set((true, prefix as u32)); + self_imp.reset_address_prefix.remove_css_class("error"); + if let Ok(address2) = + Ipv4Addr::from_str(self_imp.reset_address_address.text().as_str()) + { + if let Some(addr) = conn + .ipv4 + .address_data + .iter_mut() + .find(|conn_addr| *conn_addr.address == address2.to_string()) + { + addr.prefix = prefix as u32; + } + } + } + IpProtocol::IPv6 if prefix <= 128 => { + self_imp.prefix.set((true, prefix as u32)); + self_imp.reset_address_prefix.remove_css_class("error"); + if let Ok(address2) = + Ipv6Addr::from_str(self_imp.reset_address_address.text().as_str()) + { + if let Some(addr) = conn + .ipv6 + .address_data + .iter_mut() + .find(|conn_addr| *conn_addr.address == address2.to_string()) + { + addr.prefix = prefix as u32; + } + } + } + _ => handle_error(), + } + set_row_name(&self_imp); + } + )); + + let conn = connection.clone(); + self_imp.reset_address_remove.connect_clicked(clone!( + #[weak] + self_imp, + #[weak(rename_to = entry)] + self, + move |_| { let address = self_imp.reset_address_address.text(); let mut conn = conn.borrow_mut(); - conn.ipv4.address_data.retain(|addr| addr.address != address); - what.unparent(); - }), - ); + conn.ipv4 + .address_data + .retain(|addr| addr.address != address); + entry.unparent(); + } + )); } } diff --git a/src/components/wifi/wifi_box.rs b/src/components/wifi/wifi_box.rs index 5f4ab7b..1c7b784 100644 --- a/src/components/wifi/wifi_box.rs +++ b/src/components/wifi/wifi_box.rs @@ -82,8 +82,12 @@ fn setup_callbacks(listeners: Arc, wifi_box: Arc) -> Arc @default-return glib::Propagation::Proceed, move |_, value| { + imp.reset_wifi_switch.connect_state_set(clone!( + #[weak] + imp, + #[upgrade_or] + glib::Propagation::Proceed, + move |_, value| { if imp.reset_switch_initial.load(Ordering::SeqCst) { return glib::Propagation::Proceed; } @@ -105,8 +109,8 @@ fn setup_callbacks(listeners: Arc, wifi_box: Arc) -> Arc move |_| { - let access_point = entry_imp.access_point.borrow(); - if *entry_imp.connected.borrow() { - click_disconnect(stored_entry.clone()); - } else if access_point.stored { - click_stored_network(stored_entry.clone()); - } else { - click_new_network(new_entry.clone()); + entry.connect_activated(clone!( + #[weak] + entry_imp, + move |_| { + let access_point = entry_imp.access_point.borrow(); + if *entry_imp.connected.borrow() { + click_disconnect(stored_entry.clone()); + } else if access_point.stored { + click_stored_network(stored_entry.clone()); + } else { + click_new_network(new_entry.clone()); + } } - })); + )); entry.setup_callbacks(wifi_box); entry } pub fn setup_callbacks(&self, wifi_box: &WifiBox) { let self_imp = self.imp(); - self_imp.reset_wifi_edit_button.borrow().connect_clicked(clone!(@ weak self_imp, @ weak wifi_box => move |_| { - let _option = get_connection_settings(self_imp.access_point.borrow().associated_connection.clone()); - wifi_box.reset_wifi_navigation.push(&*WifiOptions::new(_option, self_imp.access_point.borrow().associated_connection.clone())); - })); + self_imp + .reset_wifi_edit_button + .borrow() + .connect_clicked(clone!( + #[weak] + self_imp, + #[weak] + wifi_box, + move |_| { + let _option = get_connection_settings( + self_imp.access_point.borrow().associated_connection.clone(), + ); + wifi_box.reset_wifi_navigation.push(&*WifiOptions::new( + _option, + self_imp.access_point.borrow().associated_connection.clone(), + )); + } + )); } } @@ -233,16 +251,33 @@ pub fn click_new_network(entry: Arc) { let entry_imp = entry.imp(); let popup_imp = entry_imp.reset_wifi_popup.imp(); - popup_imp - .reset_popup_entry - .connect_activate(clone!(@weak entry as orig_entry, @weak entry_imp => move |entry| { - connect_new_network(orig_entry, entry_imp.access_point.clone().take(), entry.text().to_string()); - })); - popup_imp.reset_popup_button.connect_clicked( - clone!(@weak entry as orig_entry,@weak entry_imp, @weak popup_imp => move |_| { - let entry = entry_imp.reset_wifi_popup.imp().reset_popup_entry.text().to_string(); - connect_new_network(orig_entry, entry_imp.access_point.clone().take(), entry); - }), - ); + popup_imp.reset_popup_entry.connect_activate(clone!( + #[weak(rename_to = orig_entry)] + entry, + #[weak] + entry_imp, + move |entry| { + connect_new_network( + orig_entry, + entry_imp.access_point.clone().take(), + entry.text().to_string(), + ); + } + )); + popup_imp.reset_popup_button.connect_clicked(clone!( + #[weak(rename_to = orig_entry)] + entry, + #[weak] + entry_imp, + move |_| { + let entry = entry_imp + .reset_wifi_popup + .imp() + .reset_popup_entry + .text() + .to_string(); + connect_new_network(orig_entry, entry_imp.access_point.clone().take(), entry); + } + )); entry_imp.reset_wifi_popup.popup(); } diff --git a/src/components/wifi/wifi_event_handlers.rs b/src/components/wifi/wifi_event_handlers.rs index 9bf42b1..d0f3bcb 100644 --- a/src/components/wifi/wifi_event_handlers.rs +++ b/src/components/wifi/wifi_event_handlers.rs @@ -76,7 +76,7 @@ pub fn access_point_changed_handler(wifi_box: Arc, ir: AccessPointChang entry_imp .reset_wifi_strength .borrow() - .set_from_icon_name(match strength { + .set_icon_name(match strength { WifiStrength::Excellent => Some("network-wireless-signal-excellent-symbolic"), WifiStrength::Ok => Some("network-wireless-signal-ok-symbolic"), WifiStrength::Weak => Some("network-wireless-signal-weak-symbolic"), diff --git a/src/components/wifi/wifi_options.rs b/src/components/wifi/wifi_options.rs index 0adbb60..4e1271b 100644 --- a/src/components/wifi/wifi_options.rs +++ b/src/components/wifi/wifi_options.rs @@ -235,31 +235,45 @@ fn setup_callbacks(wifi_options: &Arc, path: Path<'static>) { let imp = wifi_options.imp(); // General - imp.reset_wifi_auto_connect - .connect_active_notify(clone!(@weak imp => move |x| { + imp.reset_wifi_auto_connect.connect_active_notify(clone!( + #[weak] + imp, + move |x| { imp.connection.borrow_mut().settings.autoconnect = x.is_active(); - })); - imp.reset_wifi_metered - .connect_active_notify(clone!(@weak imp => move |x| { + } + )); + imp.reset_wifi_metered.connect_active_notify(clone!( + #[weak] + imp, + move |x| { imp.connection.borrow_mut().settings.metered = if x.is_active() { 1 } else { 2 }; - })); - imp.wifi_options_apply_button - .connect_clicked(clone!(@weak imp => move |_| { + } + )); + imp.wifi_options_apply_button.connect_clicked(clone!( + #[weak] + imp, + move |_| { let prop = imp.connection.borrow().convert_to_propmap(); set_connection_settings(path.clone(), prop); - })); + } + )); // IPv4 let wifi_options_ip4 = wifi_options.clone(); - imp.reset_ip4_method - .connect_selected_notify(clone!(@weak imp => move |dropdown| { + imp.reset_ip4_method.connect_selected_notify(clone!( + #[weak] + imp, + move |dropdown| { let selected = dropdown.selected(); let mut conn = imp.connection.borrow_mut(); conn.ipv4.method = DNSMethod4::from_i32(selected as i32); wifi_options_ip4.set_ip4_visibility(selected); - })); + } + )); - imp.reset_ip4_dns - .connect_changed(clone!(@weak imp => move |entry| { + imp.reset_ip4_dns.connect_changed(clone!( + #[weak] + imp, + move |entry| { let dns_input = entry.text(); let mut conn = imp.connection.borrow_mut(); conn.ipv4.dns.clear(); @@ -275,15 +289,21 @@ fn setup_callbacks(wifi_options: &Arc, path: Path<'static>) { imp.reset_ip4_dns.add_css_class("error"); } } - })); - imp.reset_ip4_address_add_button - .connect_clicked(clone!(@weak imp => move |_| { + } + )); + imp.reset_ip4_address_add_button.connect_clicked(clone!( + #[weak] + imp, + move |_| { let address = &WifiAddressEntry::new(None, imp.connection.clone(), IPv4); imp.reset_ip4_address_group.add(address); - })); + } + )); - imp.reset_ip4_gateway - .connect_changed(clone!(@weak imp => move |entry| { + imp.reset_ip4_gateway.connect_changed(clone!( + #[weak] + imp, + move |entry| { let gateway_input = entry.text(); let mut conn = imp.connection.borrow_mut(); conn.ipv4.gateway.clear(); @@ -297,19 +317,25 @@ fn setup_callbacks(wifi_options: &Arc, path: Path<'static>) { } else { imp.reset_ip4_gateway.add_css_class("error"); } - })); + } + )); // IPv6 let wifi_options_ip6 = wifi_options.clone(); - imp.reset_ip6_method - .connect_selected_notify(clone!(@weak imp => move |dropdown| { + imp.reset_ip6_method.connect_selected_notify(clone!( + #[weak] + imp, + move |dropdown| { let selected = dropdown.selected(); let mut conn = imp.connection.borrow_mut(); conn.ipv6.method = DNSMethod6::from_i32(selected as i32); wifi_options_ip6.set_ip6_visibility(selected); - })); + } + )); - imp.reset_ip6_dns - .connect_changed(clone!(@weak imp => move |entry| { + imp.reset_ip6_dns.connect_changed(clone!( + #[weak] + imp, + move |entry| { let dns_input = entry.text(); let mut conn = imp.connection.borrow_mut(); conn.ipv6.dns.clear(); @@ -325,15 +351,21 @@ fn setup_callbacks(wifi_options: &Arc, path: Path<'static>) { imp.reset_ip6_dns.add_css_class("error"); } } - })); - imp.reset_ip6_address_add_button - .connect_clicked(clone!(@weak imp => move |_| { + } + )); + imp.reset_ip6_address_add_button.connect_clicked(clone!( + #[weak] + imp, + move |_| { let address = &WifiAddressEntry::new(None, imp.connection.clone(), IPv4); imp.reset_ip6_address_group.add(address); - })); + } + )); - imp.reset_ip6_gateway - .connect_changed(clone!(@weak imp => move |entry| { + imp.reset_ip6_gateway.connect_changed(clone!( + #[weak] + imp, + move |entry| { let gateway_input = entry.text(); let mut conn = imp.connection.borrow_mut(); conn.ipv6.gateway.clear(); @@ -347,31 +379,40 @@ fn setup_callbacks(wifi_options: &Arc, path: Path<'static>) { } else { imp.reset_ip6_gateway.add_css_class("error"); } - })); + } + )); // Security imp.reset_wifi_security_dropdown - .connect_selected_notify(clone!(@weak imp => move |dropdown| { - let selected = dropdown.selected(); - let mut conn = imp.connection.borrow_mut(); + .connect_selected_notify(clone!( + #[weak] + imp, + move |dropdown| { + let selected = dropdown.selected(); + let mut conn = imp.connection.borrow_mut(); - match selected { - 0 => { // None - imp.reset_wifi_password.set_visible(false); - conn.security.key_management = KeyManagement::NONE; - conn.security.authentication_algorithm = String::from("none"); - }, - 1 => { // WPA/WPA2 Personal - imp.reset_wifi_password.set_visible(true); - conn.security.key_management = KeyManagement::WPAPSK; - conn.security.authentication_algorithm = String::from("none"); - }, - _ => {} + match selected { + 0 => { + // None + imp.reset_wifi_password.set_visible(false); + conn.security.key_management = KeyManagement::NONE; + conn.security.authentication_algorithm = String::from("none"); + } + 1 => { + // WPA/WPA2 Personal + imp.reset_wifi_password.set_visible(true); + conn.security.key_management = KeyManagement::WPAPSK; + conn.security.authentication_algorithm = String::from("none"); + } + _ => {} + } } - })); + )); - imp.reset_wifi_password - .connect_changed(clone!(@weak imp => move |entry| { + imp.reset_wifi_password.connect_changed(clone!( + #[weak] + imp, + move |entry| { let password_input = entry.text(); if password_input.len() < 8 && !password_input.is_empty() { entry.add_css_class("error"); @@ -380,7 +421,8 @@ fn setup_callbacks(wifi_options: &Arc, path: Path<'static>) { } let mut conn = imp.connection.borrow_mut(); conn.security.psk = password_input.to_string(); - })); + } + )); imp.reset_available_networks.set_activatable(true); imp.reset_available_networks diff --git a/src/components/wifi/wifi_route_entry.rs b/src/components/wifi/wifi_route_entry.rs index b6ae08e..079b0a6 100644 --- a/src/components/wifi/wifi_route_entry.rs +++ b/src/components/wifi/wifi_route_entry.rs @@ -54,89 +54,115 @@ impl WifiRouteEntry { fn setup_callbacks(&self, connection: Rc>) { let self_imp = self.imp(); let conn = connection.clone(); - self_imp.reset_route_address.connect_changed(clone!(@weak self_imp => move |entry| { - let address_input = entry.text(); - let mut conn = conn.borrow_mut(); + self_imp.reset_route_address.connect_changed(clone!( + #[weak] + self_imp, + move |entry| { + let address_input = entry.text(); + let mut conn = conn.borrow_mut(); - if address_input.is_empty() { - self_imp.reset_route_address.remove_css_class("error"); - self_imp.reset_route_row.set_title("Add new address"); - return; - } - let result = match self_imp.protocol.get() { - IpProtocol::IPv4 => Ipv4Addr::from_str(address_input.as_str()).map(IpAddr::V4), - IpProtocol::IPv6 => Ipv6Addr::from_str(address_input.as_str()).map(IpAddr::V6), - }; - match result { - Ok(ip_addr) => { + if address_input.is_empty() { self_imp.reset_route_address.remove_css_class("error"); - let address_data = match self_imp.protocol.get() { - IpProtocol::IPv4 => &mut conn.ipv4.route_data, - IpProtocol::IPv6 => &mut conn.ipv6.route_data, - }; - address_data.push(Address::new(ip_addr.to_string(), self_imp.prefix.get().1 as u32,self_imp.gateway.borrow().clone() ,self_imp.metric.get())); - *self_imp.address.borrow_mut() = (true, ip_addr.to_string()); + self_imp.reset_route_row.set_title("Add new address"); + return; } - Err(_) => { - self_imp.reset_route_address.add_css_class("error"); - *self_imp.address.borrow_mut() = (false, String::default()); + let result = match self_imp.protocol.get() { + IpProtocol::IPv4 => Ipv4Addr::from_str(address_input.as_str()).map(IpAddr::V4), + IpProtocol::IPv6 => Ipv6Addr::from_str(address_input.as_str()).map(IpAddr::V6), + }; + match result { + Ok(ip_addr) => { + self_imp.reset_route_address.remove_css_class("error"); + let address_data = match self_imp.protocol.get() { + IpProtocol::IPv4 => &mut conn.ipv4.route_data, + IpProtocol::IPv6 => &mut conn.ipv6.route_data, + }; + address_data.push(Address::new( + ip_addr.to_string(), + self_imp.prefix.get().1, + self_imp.gateway.borrow().clone(), + self_imp.metric.get(), + )); + *self_imp.address.borrow_mut() = (true, ip_addr.to_string()); + } + Err(_) => { + self_imp.reset_route_address.add_css_class("error"); + *self_imp.address.borrow_mut() = (false, String::default()); + } } - } - set_row_title(&self_imp); - })); - - let conn = connection.clone(); - self_imp.reset_route_prefix.connect_changed(clone!(@weak self_imp => move |entry| { - let prefix_input = entry.text(); - let prefix = prefix_input.parse::(); - let mut conn = conn.borrow_mut(); - - let handle_error = || { - if self_imp.reset_route_prefix.text().is_empty() { - self_imp.reset_route_prefix.remove_css_class("error"); - } else { - self_imp.reset_route_prefix.add_css_class("error"); - } - self_imp.prefix.set((false, 0)); set_row_title(&self_imp); - }; - - if prefix_input.is_empty() || prefix.is_err() { - handle_error(); - return; } - - let prefix = prefix.unwrap(); - match self_imp.protocol.get() { - IpProtocol::IPv4 if prefix <= 32 => { - self_imp.prefix.set((true, prefix as u32)); - self_imp.reset_route_prefix.remove_css_class("error"); - if let Ok(address2) = Ipv4Addr::from_str(self_imp.reset_route_address.text().as_str()) { - if let Some(addr) = conn.ipv4.route_data.iter_mut() - .find(|conn_addr| *conn_addr.address == address2.to_string()) { - addr.prefix = prefix as u32; - } - } - } - IpProtocol::IPv6 if prefix <= 128 => { - self_imp.prefix.set((true, prefix as u32)); - self_imp.reset_route_prefix.remove_css_class("error"); - if let Ok(address2) = Ipv6Addr::from_str(self_imp.reset_route_address.text().as_str()) { - if let Some(addr) = conn.ipv6.route_data.iter_mut() - .find(|conn_addr| *conn_addr.address == address2.to_string()) { - addr.prefix = prefix as u32; - } - } - } - _ => handle_error() - } - set_row_title(&self_imp); - })); + )); let conn = connection.clone(); - self_imp - .reset_route_gateway - .connect_changed(clone!(@weak self_imp => move |entry| { + self_imp.reset_route_prefix.connect_changed(clone!( + #[weak] + self_imp, + move |entry| { + let prefix_input = entry.text(); + let prefix = prefix_input.parse::(); + let mut conn = conn.borrow_mut(); + + let handle_error = || { + if self_imp.reset_route_prefix.text().is_empty() { + self_imp.reset_route_prefix.remove_css_class("error"); + } else { + self_imp.reset_route_prefix.add_css_class("error"); + } + self_imp.prefix.set((false, 0)); + set_row_title(&self_imp); + }; + + if prefix_input.is_empty() || prefix.is_err() { + handle_error(); + return; + } + + let prefix = prefix.unwrap(); + match self_imp.protocol.get() { + IpProtocol::IPv4 if prefix <= 32 => { + self_imp.prefix.set((true, prefix as u32)); + self_imp.reset_route_prefix.remove_css_class("error"); + if let Ok(address2) = + Ipv4Addr::from_str(self_imp.reset_route_address.text().as_str()) + { + if let Some(addr) = conn + .ipv4 + .route_data + .iter_mut() + .find(|conn_addr| *conn_addr.address == address2.to_string()) + { + addr.prefix = prefix as u32; + } + } + } + IpProtocol::IPv6 if prefix <= 128 => { + self_imp.prefix.set((true, prefix as u32)); + self_imp.reset_route_prefix.remove_css_class("error"); + if let Ok(address2) = + Ipv6Addr::from_str(self_imp.reset_route_address.text().as_str()) + { + if let Some(addr) = conn + .ipv6 + .route_data + .iter_mut() + .find(|conn_addr| *conn_addr.address == address2.to_string()) + { + addr.prefix = prefix as u32; + } + } + } + _ => handle_error(), + } + set_row_title(&self_imp); + } + )); + + let conn = connection.clone(); + self_imp.reset_route_gateway.connect_changed(clone!( + #[weak] + self_imp, + move |entry| { let gateway_input = entry.text(); let mut conn = conn.borrow_mut(); @@ -157,8 +183,9 @@ impl WifiRouteEntry { IpProtocol::IPv4 => &mut conn.ipv4.route_data, IpProtocol::IPv6 => &mut conn.ipv6.route_data, }; - if let Some(address) = address_data.iter_mut() - .find(|conn_addr| *conn_addr.address == self_imp.reset_route_address.text()) { + if let Some(address) = address_data.iter_mut().find(|conn_addr| { + *conn_addr.address == self_imp.reset_route_address.text() + }) { address.gateway = Some(ip_addr.to_string()); } *self_imp.gateway.borrow_mut() = Some(ip_addr.to_string()); @@ -169,12 +196,14 @@ impl WifiRouteEntry { } } set_row_subtitle(&self_imp); - })); + } + )); let conn = connection.clone(); - self_imp - .reset_route_metric - .connect_changed(clone!(@weak self_imp => move |entry| { + self_imp.reset_route_metric.connect_changed(clone!( + #[weak] + self_imp, + move |entry| { let metric_input = entry.text(); let mut conn = conn.borrow_mut(); @@ -192,8 +221,9 @@ impl WifiRouteEntry { IpProtocol::IPv4 => &mut conn.ipv4.route_data, IpProtocol::IPv6 => &mut conn.ipv6.route_data, }; - if let Some(address) = address_data.iter_mut() - .find(|conn_addr| *conn_addr.address == self_imp.reset_route_address.text()) { + if let Some(address) = address_data.iter_mut().find(|conn_addr| { + *conn_addr.address == self_imp.reset_route_address.text() + }) { address.metric = Some(metric); } self_imp.metric.set(Some(metric)); @@ -204,7 +234,8 @@ impl WifiRouteEntry { } } set_row_subtitle(&self_imp); - })); + } + )); } } diff --git a/src/components/window/reset_window.rs b/src/components/window/reset_window.rs index f72d552..f79221a 100644 --- a/src/components/window/reset_window.rs +++ b/src/components/window/reset_window.rs @@ -62,12 +62,12 @@ impl ReSetWindow { self_imp.reset_sidebar_breakpoint.add_setter( &Object::from(self_imp.reset_overlay_split_view.get()), "collapsed", - &true.to_value(), + Some(&true.to_value()), ); self_imp.reset_sidebar_breakpoint.add_setter( &Object::from(self_imp.reset_sidebar_toggle.get()), "visible", - &true.to_value(), + Some(&true.to_value()), ); } @@ -202,11 +202,13 @@ impl ReSetWindow { self_imp.position.clone(), ); - self_imp - .reset_sidebar_list - .connect_row_activated(clone!(@ weak self_imp => move |_, _| { + self_imp.reset_sidebar_list.connect_row_activated(clone!( + #[weak] + self_imp, + move |_, _| { self_imp.reset_search_entry.set_text(""); - })); + } + )); let mut i = 0; for info in sidebar_list { if info.parent.is_none() && i != 0 { diff --git a/src/components/window/sidebar_entry.rs b/src/components/window/sidebar_entry.rs index 158ed66..d20b1ef 100644 --- a/src/components/window/sidebar_entry.rs +++ b/src/components/window/sidebar_entry.rs @@ -18,7 +18,7 @@ impl SidebarEntry { entry_imp.reset_sidebar_label.get().set_text(info.name()); entry_imp .reset_sidebar_image - .set_from_icon_name(Some(info.icon_name())); + .set_icon_name(Some(info.icon_name())); if let Some(boxes) = info.plugin_boxes() { entry_imp.plugin_boxes.borrow_mut().extend(boxes); }