diff --git a/Cargo.lock b/Cargo.lock index 86a4f79..a95b2b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,6 +24,15 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" +[[package]] +name = "addr2line" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -119,18 +128,54 @@ dependencies = [ "libloading", ] +[[package]] +name = "async-channel" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "better-panic" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fa9e1d11a268684cbd90ed36370d7577afb6c62d912ddff5c15fc34343e5036" +dependencies = [ + "backtrace", + "console", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -348,12 +393,60 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "color-eyre" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" +dependencies = [ + "backtrace", + "color-spantrace", + "eyre", + "indenter", + "once_cell", + "owo-colors", + "tracing-error", +] + +[[package]] +name = "color-spantrace" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba75b3d9449ecdccb27ecbc479fdc0b87fa2dd43d2f8298f9bf0e59aacc8dce" +dependencies = [ + "once_cell", + "owo-colors", + "tracing-core", + "tracing-error", +] + [[package]] name = "color_quant" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "concurrent-queue" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "console" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d79fbe8970a77e3e34151cc13d3b3e248aa0faaecb9f6091fa07ebefe5ad60" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "windows-sys 0.42.0", +] + [[package]] name = "const_panic" version = "0.2.7" @@ -418,9 +511,13 @@ name = "cosmic-settings" version = "0.1.0" dependencies = [ "apply", + "async-channel", + "better-panic", "bytecheck", + "color-eyre", "derive_setters", "dirs", + "generator", "i18n-embed", "i18n-embed-fl", "libcosmic", @@ -825,6 +922,12 @@ dependencies = [ "syn", ] +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "error-code" version = "2.3.1" @@ -844,6 +947,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + [[package]] name = "expat-sys" version = "2.1.6" @@ -869,6 +978,16 @@ dependencies = [ "threadpool", ] +[[package]] +name = "eyre" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +dependencies = [ + "indenter", + "once_cell", +] + [[package]] name = "fastrand" version = "1.8.0" @@ -1174,6 +1293,19 @@ dependencies = [ "byteorder", ] +[[package]] +name = "generator" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266041a359dfa931b370ef684cceb84b166beb14f7f0421f4a6a3d0c446d12e" +dependencies = [ + "cc", + "libc", + "log", + "rustversion", + "windows", +] + [[package]] name = "generic-array" version = "0.14.6" @@ -1217,6 +1349,12 @@ dependencies = [ "weezl", ] +[[package]] +name = "gimli" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "221996f774192f0f718773def8201c4ae31f02616a54ccfc2d358bb0e5cefdec" + [[package]] name = "glam" version = "0.21.3" @@ -1634,6 +1772,12 @@ dependencies = [ "tiff", ] +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + [[package]] name = "indexmap" version = "1.9.2" @@ -2256,6 +2400,15 @@ dependencies = [ "objc", ] +[[package]] +name = "object" +version = "0.30.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.17.0" @@ -2337,6 +2490,12 @@ dependencies = [ "ttf-parser 0.18.1", ] +[[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + [[package]] name = "palette" version = "0.6.1" @@ -2892,12 +3051,24 @@ dependencies = [ "ordered-multimap", ] +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + [[package]] name = "rustc-hash" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustversion" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" + [[package]] name = "rustybuzz" version = "0.4.0" @@ -3043,6 +3214,15 @@ dependencies = [ "digest", ] +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + [[package]] name = "simplecss" version = "0.2.1" @@ -3281,6 +3461,15 @@ dependencies = [ "syn", ] +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", +] + [[package]] name = "threadpool" version = "1.8.1" @@ -3375,6 +3564,48 @@ dependencies = [ "toml_datetime", ] +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-error" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" +dependencies = [ + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70" +dependencies = [ + "sharded-slab", + "thread_local", + "tracing-core", +] + [[package]] name = "ttf-parser" version = "0.12.3" @@ -3547,6 +3778,12 @@ dependencies = [ "xmlwriter", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "vec_map" version = "0.8.2" @@ -3956,6 +4193,19 @@ dependencies = [ "thiserror", ] +[[package]] +name = "windows" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1c4bd0a50ac6020f65184721f758dba47bb9fbc2133df715ec74a237b26794a" +dependencies = [ + "windows_aarch64_msvc 0.39.0", + "windows_i686_gnu 0.39.0", + "windows_i686_msvc 0.39.0", + "windows_x86_64_gnu 0.39.0", + "windows_x86_64_msvc 0.39.0", +] + [[package]] name = "windows-sys" version = "0.36.1" @@ -3996,6 +4246,12 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +[[package]] +name = "windows_aarch64_msvc" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7711666096bd4096ffa835238905bb33fb87267910e154b18b44eaabb340f2" + [[package]] name = "windows_aarch64_msvc" version = "0.42.1" @@ -4008,6 +4264,12 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +[[package]] +name = "windows_i686_gnu" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "763fc57100a5f7042e3057e7e8d9bdd7860d330070251a73d003563a3bb49e1b" + [[package]] name = "windows_i686_gnu" version = "0.42.1" @@ -4020,6 +4282,12 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +[[package]] +name = "windows_i686_msvc" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bc7cbfe58828921e10a9f446fcaaf649204dcfe6c1ddd712c5eebae6bda1106" + [[package]] name = "windows_i686_msvc" version = "0.42.1" @@ -4032,6 +4300,12 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6868c165637d653ae1e8dc4d82c25d4f97dd6605eaa8d784b5c6e0ab2a252b65" + [[package]] name = "windows_x86_64_gnu" version = "0.42.1" @@ -4050,6 +4324,12 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +[[package]] +name = "windows_x86_64_msvc" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e4d40883ae9cae962787ca76ba76390ffa29214667a111db9e0a1ad8377e809" + [[package]] name = "windows_x86_64_msvc" version = "0.42.1" diff --git a/Cargo.toml b/Cargo.toml index 0201dce..200f6c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,15 +7,19 @@ rust-version = "1.65.0" [dependencies] apply = "0.3.0" +async-channel = "1.8.0" +better-panic = "0.3.0" +bytecheck = "0.6.9" +color-eyre = "0.6.2" derive_setters = "0.1.5" +dirs = "4.0.0" +generator = "0.7.2" i18n-embed-fl = "0.6.5" once_cell = "1.17.0" regex = "1.7.1" +rkyv = { version = "0.7.39", features = ["validation"]} rust-embed = "6.4.2" slotmap = "1.0.6" -dirs = "4.0.0" -rkyv = { version = "0.7.39", features = ["validation"]} -bytecheck = "0.6.9" [dependencies.i18n-embed] version = "0.13.8" @@ -26,3 +30,13 @@ git = "https://github.com/pop-os/libcosmic" branch = "settings-improv" default-features = false features = ["debug", "winit", "dyrend"] + +[profile.dev] +opt-level = 3 +incremental = true + +[profile.release] +opt-level = "s" +overflow-checks = true +lto = "thin" +incremental = false \ No newline at end of file diff --git a/i18n/en/cosmic_settings.ftl b/i18n/en/cosmic_settings.ftl index 20f361d..6e3be57 100644 --- a/i18n/en/cosmic_settings.ftl +++ b/i18n/en/cosmic_settings.ftl @@ -1,5 +1,7 @@ app = COSMIC Settings +unknown = Unknown + ## Desktop desktop = Desktop @@ -128,6 +130,7 @@ about = About .desc = Device name, hardware information, operating system defaults. about-device = Device name + .desc = This name appears to other network or bluetooth devices. about-hardware = Hardware .model = Hardware model diff --git a/justfile b/justfile index 26e4877..bde5156 100644 --- a/justfile +++ b/justfile @@ -38,8 +38,8 @@ clean-dist: clean rm -rf .cargo vendor vendor.tar target # Run the application for testing purposes -run: - cargo run --release +run *args: + cargo run {{args}} # Compile debug build of cosmic-settings build-debug *args: diff --git a/src/app.rs b/src/app.rs index 0882b3b..35ca83e 100644 --- a/src/app.rs +++ b/src/app.rs @@ -48,19 +48,21 @@ pub struct SettingsApp { #[allow(dead_code)] #[derive(Clone, Debug)] pub enum Message { + About(system::about::Message), Close, - Desktop(desktop::Message), DateAndTime(time::date::Message), + Desktop(desktop::Message), Drag, KeyboardNav(keyboard_nav::Message), Maximize, Minimize, NavBar(segmented_button::Entity), + None, + Page(page::Entity), Search(search::Message), ToggleNavBar, ToggleNavBarCondensed, WindowResize(u32, u32), - Page(page::Entity), } impl Application for SettingsApp { @@ -117,14 +119,16 @@ impl Application for SettingsApp { // app.insert_page::(); // app.insert_page::(); + let mut command = Command::none(); + for (id, info) in app.pages.pages.iter() { if info.id == &*app.config.active_page { - app.activate_page(id); + command = app.activate_page(id); break; } } - (app, Command::none()) + (app, command) } fn title(&self) -> String { @@ -167,14 +171,14 @@ impl Application for SettingsApp { return self.search.focus(); } }, - Message::Page(page) => self.activate_page(page), + Message::Page(page) => return self.activate_page(page), Message::Drag => return drag(window::Id::new(0)), Message::Close => return close(window::Id::new(0)), Message::Minimize => return minimize(window::Id::new(0), true), Message::Maximize => return toggle_maximize(window::Id::new(0)), Message::NavBar(key) => { if let Some(page) = self.nav_bar.data::(key).copied() { - self.activate_page(page); + return self.activate_page(page); } } Message::ToggleNavBar => self.nav_bar_toggled = !self.nav_bar_toggled, @@ -190,7 +194,12 @@ impl Application for SettingsApp { Message::Search(search::Message::Clear) => { self.search_clear(); } - Message::Search(_) => {} + Message::None | Message::Search(_) => {} + Message::About(message) => { + if let Some(model) = self.pages.resource_mut::() { + model.update(message); + } + } Message::Desktop(message) => { if let Some(model) = self.pages.resource_mut::() { model.update(message); @@ -300,7 +309,7 @@ impl Application for SettingsApp { impl SettingsApp { /// Activates a page. - fn activate_page(&mut self, page: page::Entity) { + fn activate_page(&mut self, page: page::Entity) -> Command { self.nav_bar_toggled_condensed = false; let current_page = self.active_page; self.active_page = page; @@ -314,6 +323,8 @@ impl SettingsApp { self.search_clear(); self.search.state = search::State::Inactive; self.activate_navbar(page); + + self.pages.init_page(page).unwrap_or(Command::none()) } /// Activates the navbar item associated with a page. diff --git a/src/main.rs b/src/main.rs index 9d80e9e..9978567 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,7 +24,14 @@ use i18n_embed::DesktopLanguageRequester; /// # Errors /// /// Returns error if iced fails to run the application. -pub fn main() -> cosmic::iced::Result { +pub fn main() -> color_eyre::Result<()> { + better_panic::install(); + color_eyre::install()?; + + if std::env::var("RUST_SPANTRACE").is_err() { + std::env::set_var("RUST_SPANTRACE", "0"); + } + let localizer = crate::localize::localizer(); let requested_languages = DesktopLanguageRequester::requested_languages(); @@ -35,5 +42,7 @@ pub fn main() -> cosmic::iced::Result { settings::set_default_icon_theme("Pop"); let mut settings = settings(); settings.window.min_size = Some((600, 300)); - SettingsApp::run(settings) + SettingsApp::run(settings)?; + + Ok(()) } diff --git a/src/page/mod.rs b/src/page/mod.rs index 16f06a5..0239752 100644 --- a/src/page/mod.rs +++ b/src/page/mod.rs @@ -36,6 +36,12 @@ pub trait Page { fn sub_pages(page: Insert) -> Insert { page } + + #[must_use] + #[allow(unused)] + fn load(page: Entity) -> crate::Message { + crate::Message::None + } } #[derive(Setters)] diff --git a/src/page/model.rs b/src/page/model.rs index cab4834..015a393 100644 --- a/src/page/model.rs +++ b/src/page/model.rs @@ -12,6 +12,7 @@ use slotmap::{SecondaryMap, SlotMap, SparseSecondaryMap}; pub struct Model { pub pages: SlotMap, + pub page_load: SecondaryMap crate::Message>, pub resource: HashMap>, pub storage: HashMap>>, pub sub_pages: SparseSecondaryMap>, @@ -24,6 +25,7 @@ impl Default for Model { Self { content: SparseSecondaryMap::new(), pages: SlotMap::with_key(), + page_load: SecondaryMap::new(), resource: HashMap::new(), sections: SlotMap::with_key(), storage: HashMap::new(), @@ -79,9 +81,29 @@ impl Model { .and_then(|storage| storage.remove(id)); } + pub fn init_page(&mut self, id: page::Entity) -> Option> { + if let Some(func) = self.page_load.get(id).copied() { + let (tx, rx) = async_channel::bounded(1); + + std::thread::spawn(move || { + println!("loading page"); + let _res = tx.send_blocking(func(id)); + }); + + let future = async move { dbg!(rx.recv().await.unwrap_or(crate::Message::None)) }; + + return Some(cosmic::iced::Command::single( + cosmic::iced_native::command::Action::Future(Box::pin(future)), + )); + } + + None + } + // Registers a new page in the settings panel. pub fn register(&mut self) -> Insert { let id = self.pages.insert(P::page()); + self.page_load.insert(id, P::load); if let Some(content) = P::content(&mut self.sections) { self.content.insert(id, content); @@ -118,13 +140,17 @@ impl Model { &'a self, rule: &'a Regex, ) -> impl Iterator + 'a { - SearchIter { - content: self.content.iter(), - model: self, - sections: None, - rule, - page: page::Entity::default(), - } + generator::Gn::new_scoped_local(|mut s| { + for (page, sections) in self.content.iter() { + for id in sections { + if self.sections[*id].matches_search(rule) { + s.yield_((page, *id)); + } + } + } + + generator::done!(); + }) } /// Returns the sub-pages of a page, if it has any. @@ -175,37 +201,3 @@ impl<'a> Insert<'a> { self } } - -pub struct SearchIter<'a> { - model: &'a Model, - content: slotmap::sparse_secondary::Iter<'a, page::Entity, Content>, - sections: Option>, - page: page::Entity, - rule: &'a Regex, -} - -impl<'a> Iterator for SearchIter<'a> { - type Item = (page::Entity, section::Entity); - - fn next(&mut self) -> Option { - 'outer: loop { - if let Some(sections) = self.sections.as_mut() { - for id in sections { - if self.model.sections[*id].matches_search(self.rule) { - return Some((self.page, *id)); - } - } - - self.sections = None; - } - - if let Some((page, content)) = self.content.next() { - self.page = page; - self.sections = Some(content.iter()); - continue 'outer; - } - - return None; - } - } -} diff --git a/src/page/system/about.rs b/src/page/system/about.rs index 1bd1752..a971912 100644 --- a/src/page/system/about.rs +++ b/src/page/system/about.rs @@ -11,10 +11,42 @@ use cosmic::{ }; use slotmap::SlotMap; +#[derive(Clone, Debug)] +pub enum Message { + Info(Info), +} + +#[derive(Clone, Debug, Default)] +pub struct Model { + info: Info, + support_page: page::Entity, +} + +#[derive(Clone, Debug, Default)] +pub struct Info { + hardware_model: String, + memory: String, + processor: String, + graphics: String, + disk_capacity: String, + operating_system: String, + os_architecture: String, + desktop_environment: String, + windowing_system: String, +} + +impl Model { + pub fn update(&mut self, message: Message) { + match message { + Message::Info(info) => self.info = dbg!(info), + } + } +} + pub struct Page; impl page::Page for Page { - type Model = super::Model; + type Model = Model; fn page() -> page::Meta { page::Meta::new("about", "help-about-symbolic") @@ -31,15 +63,30 @@ impl page::Page for Page { sections.insert(related()), ]) } + + fn load(page: page::Entity) -> crate::Message { + let info = Info { + windowing_system: std::env::var("XDG_SESSION_TYPE") + .ok() + .unwrap_or_else(|| fl!("unknown")), + ..Info::default() + }; + + crate::Message::About(Message::Info(info)) + } } fn device() -> Section { Section::new() - .descriptions(vec![fl!("about-device")]) + .descriptions(vec![fl!("about-device"), fl!("about-device", "desc")]) .view_fn(|_app, section| { - list_column() - .add(settings::item(§ion.descriptions[0], text("TODO"))) - .into() + let desc = §ion.descriptions; + + let device_name = settings::item::builder(&desc[0]) + .description(&desc[1]) + .control(text("TODO")); + + list_column().add(device_name).into() }) } @@ -50,6 +97,8 @@ fn distributor_logo() -> Section { icon("distributor-logo", 78), horizontal_space(Length::Fill), ) + // Add extra padding to reach 40px from the first section. + .padding([0, 16, 0, 16]) .into() }) } @@ -85,13 +134,18 @@ fn os() -> Section { fl!("about-os", "desktop-environment"), fl!("about-os", "windowing-system"), ]) - .view_fn(|_app, section| { + .view_fn(|app, section| { + let model = app + .pages + .resource::() + .expect("missing system->about model"); + let desc = §ion.descriptions; settings::view_section(§ion.title) .add(settings::item(&desc[0], text("TODO"))) .add(settings::item(&desc[1], text("TODO"))) .add(settings::item(&desc[2], text("TODO"))) - .add(settings::item(&desc[3], text("TODO"))) + .add(settings::item(&desc[3], text(&model.info.windowing_system))) .into() }) }