diff --git a/Cargo.lock b/Cargo.lock index e1d6650..74ff170 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -465,6 +465,18 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "atk-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "251e0b7d90e33e0ba930891a505a9a35ece37b2dd37a14f3ffc306c13b980009" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + [[package]] name = "atomic-waker" version = "1.1.2" @@ -659,6 +671,16 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +[[package]] +name = "cairo-sys-rs" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51" +dependencies = [ + "libc", + "system-deps", +] + [[package]] name = "calloop" version = "0.6.5" @@ -719,6 +741,16 @@ dependencies = [ "libc", ] +[[package]] +name = "cfg-expr" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6100bc57b6209840798d95cb2775684849d332f7bd788db2a8c8caf7ef82a41a" +dependencies = [ + "smallvec", + "target-lexicon", +] + [[package]] name = "cfg-if" version = "0.1.10" @@ -739,9 +771,9 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "41daef31d7a747c5c847246f36de49ced6f7403b4cdabc807a97b5cc184cda7a" dependencies = [ "android-tzdata", "iana-time-zone", @@ -749,7 +781,7 @@ dependencies = [ "num-traits", "pure-rust-locales", "wasm-bindgen", - "windows-targets 0.48.5", + "windows-targets 0.52.0", ] [[package]] @@ -967,7 +999,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -982,7 +1014,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "quote", "syn 1.0.109", @@ -998,10 +1030,10 @@ dependencies = [ "fork", "i18n-embed", "i18n-embed-fl", - "lazy_static", "lexical-sort", "libcosmic", "log", + "once_cell", "paste", "rust-embed", "serde", @@ -1013,7 +1045,7 @@ dependencies = [ [[package]] name = "cosmic-text" version = "0.10.0" -source = "git+https://github.com/pop-os/cosmic-text.git#db1530c4ec14bcbb290f9c971d8a6197c90e189a" +source = "git+https://github.com/pop-os/cosmic-text.git#e0ae465f918cd1cffca3a8239547dcf8166d3f77" dependencies = [ "bitflags 2.4.2", "fontdb", @@ -1035,7 +1067,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "almost", "cosmic-config", @@ -1981,6 +2013,36 @@ dependencies = [ "slab", ] +[[package]] +name = "gdk-pixbuf-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7" +dependencies = [ + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gdk-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31ff856cb3386dae1703a920f803abafcc580e9b5f711ca62ed1620c25b51ff2" +dependencies = [ + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "pkg-config", + "system-deps", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -2050,6 +2112,19 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "gio-sys" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", + "winapi", +] + [[package]] name = "gl_generator" version = "0.14.0" @@ -2067,6 +2142,16 @@ version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5418c17512bdf42730f9032c74e1ae39afc408745ebb2acf72fbc4691c17945" +[[package]] +name = "glib-sys" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898" +dependencies = [ + "libc", + "system-deps", +] + [[package]] name = "glob" version = "0.3.1" @@ -2105,6 +2190,17 @@ dependencies = [ "wgpu", ] +[[package]] +name = "gobject-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44" +dependencies = [ + "glib-sys", + "libc", + "system-deps", +] + [[package]] name = "gpu-alloc" version = "0.6.0" @@ -2164,6 +2260,24 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1df00eed8d1f0db937f6be10e46e8072b0671accb504cf0f959c5c52c679f5b9" +[[package]] +name = "gtk-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771437bf1de2c1c0b496c11505bdf748e26066bbe942dfc8f614c9460f6d7722" +dependencies = [ + "atk-sys", + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gdk-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "system-deps", +] + [[package]] name = "guillotiere" version = "0.6.2" @@ -2264,9 +2378,9 @@ dependencies = [ [[package]] name = "i18n-embed" -version = "0.13.9" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92a86226a7a16632de6723449ee5fe70bac5af718bc642ee9ca2f0f6e14fa1fa" +checksum = "94205d95764f5bb9db9ea98fa77f89653365ca748e27161f5bbea2ffd50e459c" dependencies = [ "arc-swap", "fluent", @@ -2286,9 +2400,9 @@ dependencies = [ [[package]] name = "i18n-embed-fl" -version = "0.6.7" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26a3d3569737dfaac7fc1c4078e6af07471c3060b8e570bcd83cdd5f4685395" +checksum = "9fc1f8715195dffc4caddcf1cf3128da15fe5d8a137606ea8856c9300047d5a2" dependencies = [ "dashmap", "find-crate", @@ -2344,7 +2458,7 @@ dependencies = [ [[package]] name = "iced" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "iced_accessibility", "iced_core", @@ -2359,7 +2473,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "accesskit", "accesskit_winit", @@ -2368,7 +2482,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "bitflags 1.3.2", "instant", @@ -2384,7 +2498,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "futures", "iced_core", @@ -2397,7 +2511,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2420,7 +2534,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2433,7 +2547,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "iced_core", "iced_futures", @@ -2443,7 +2557,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "iced_core", "once_cell", @@ -2453,7 +2567,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "bytemuck", "cosmic-text", @@ -2471,7 +2585,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2491,7 +2605,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "iced_renderer", "iced_runtime", @@ -2505,7 +2619,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "iced_graphics", "iced_runtime", @@ -2801,7 +2915,7 @@ checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#efe4ce2f5b514e4d553ab82c0c873dca7585c028" +source = "git+https://github.com/pop-os/libcosmic.git#d6e23fe97751d40f181228d1d1c34b51fea23bea" dependencies = [ "apply", "ashpd", @@ -2823,6 +2937,7 @@ dependencies = [ "iced_winit", "lazy_static", "palette", + "rfd", "slotmap", "taffy", "thiserror", @@ -3699,6 +3814,18 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "pango-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + [[package]] name = "parking" version = "2.2.0" @@ -3974,9 +4101,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -4153,9 +4280,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", @@ -4165,9 +4292,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" dependencies = [ "aho-corasick", "memchr", @@ -4203,6 +4330,30 @@ dependencies = [ "usvg", ] +[[package]] +name = "rfd" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0d8ab342bcc5436e04d3a4c1e09e17d74958bfaddf8d5fad6f85607df0f994f" +dependencies = [ + "ashpd", + "block", + "dispatch", + "glib-sys", + "gobject-sys", + "gtk-sys", + "js-sys", + "log", + "objc", + "objc-foundation", + "objc_id", + "raw-window-handle 0.5.2", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows-sys 0.48.0", +] + [[package]] name = "rgb" version = "0.8.37" @@ -4241,9 +4392,9 @@ checksum = "3cd14fd5e3b777a7422cca79358c57a8f6e3a703d9ac187448d0daf220c2407f" [[package]] name = "rust-embed" -version = "6.8.1" +version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a36224c3276f8c4ebc8c20f158eca7ca4359c8db89991c4925132aaaf6702661" +checksum = "a82c0bbc10308ed323529fd3c1dce8badda635aa319a5ff0e6466f33b8101e3f" dependencies = [ "rust-embed-impl", "rust-embed-utils", @@ -4252,9 +4403,9 @@ dependencies = [ [[package]] name = "rust-embed-impl" -version = "6.8.1" +version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b94b81e5b2c284684141a2fb9e2a31be90638caf040bf9afbc5a0416afe1ac" +checksum = "6227c01b1783cdfee1bcf844eb44594cd16ec71c35305bf1c9fb5aade2735e16" dependencies = [ "proc-macro2", "quote", @@ -4265,9 +4416,9 @@ dependencies = [ [[package]] name = "rust-embed-utils" -version = "7.8.1" +version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d38ff6bf570dc3bb7100fce9f7b60c33fa71d80e88da3f2580df4ff2bdded74" +checksum = "8cb0a25bfbb2d4b4402179c2cf030387d9990857ce08a32592c6238db9fa8665" dependencies = [ "sha2", "walkdir", @@ -4757,6 +4908,19 @@ dependencies = [ "libc", ] +[[package]] +name = "system-deps" +version = "6.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2d580ff6a20c55dfb86be5f9c238f67835d0e81cbdea8bf5680e0897320331" +dependencies = [ + "cfg-expr", + "heck", + "pkg-config", + "toml 0.8.8", + "version-compare", +] + [[package]] name = "systemicons" version = "0.7.0" @@ -4783,6 +4947,12 @@ dependencies = [ "slotmap", ] +[[package]] +name = "target-lexicon" +version = "0.12.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae" + [[package]] name = "tempfile" version = "3.9.0" @@ -5273,6 +5443,12 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +[[package]] +name = "version-compare" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" + [[package]] name = "version_check" version = "0.9.4" @@ -5636,9 +5812,9 @@ dependencies = [ [[package]] name = "weezl" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" +checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" [[package]] name = "wgpu" diff --git a/Cargo.toml b/Cargo.toml index 6361846..707ff68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" chrono = { version = "0.4", features = ["unstable-locales"] } dirs = "5.0.1" env_logger = "0.10" -lazy_static = "1" +once_cell = "1.19" lexical-sort = "0.3.1" log = "0.4" paste = "1.0" @@ -15,9 +15,12 @@ serde = { version = "1", features = ["serde_derive"] } tokio = { version = "1" } trash = "3.2.0" # Internationalization -i18n-embed = { version = "0.13", features = ["fluent-system", "desktop-requester"] } -i18n-embed-fl = "0.6" -rust-embed = "6" +i18n-embed = { version = "0.14", features = [ + "fluent-system", + "desktop-requester", +] } +i18n-embed-fl = "0.7" +rust-embed = "8" [dependencies.libcosmic] git = "https://github.com/pop-os/libcosmic.git" diff --git a/src/localize.rs b/src/localize.rs index f5c6fb9..e0416ca 100644 --- a/src/localize.rs +++ b/src/localize.rs @@ -4,23 +4,22 @@ use i18n_embed::{ fluent::{fluent_language_loader, FluentLanguageLoader}, DefaultLocalizer, LanguageLoader, Localizer, }; +use once_cell::sync::Lazy; use rust_embed::RustEmbed; #[derive(RustEmbed)] #[folder = "i18n/"] struct Localizations; -lazy_static::lazy_static! { - pub static ref LANGUAGE_LOADER: FluentLanguageLoader = { - let loader: FluentLanguageLoader = fluent_language_loader!(); +pub static LANGUAGE_LOADER: Lazy = Lazy::new(|| { + let loader: FluentLanguageLoader = fluent_language_loader!(); - loader - .load_fallback_language(&Localizations) - .expect("Error while loading fallback language"); + loader + .load_fallback_language(&Localizations) + .expect("Error while loading fallback language"); - loader - }; -} + loader +}); #[macro_export] macro_rules! fl { diff --git a/src/mime_icon.rs b/src/mime_icon.rs index 1b029e6..6246ded 100644 --- a/src/mime_icon.rs +++ b/src/mime_icon.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only use cosmic::widget::icon; +use once_cell::sync::Lazy; use std::{collections::HashMap, path::Path, sync::Mutex}; pub const FALLBACK_MIME_ICON: &str = "text-x-generic"; @@ -39,10 +40,7 @@ impl MimeIconCache { .clone() } } - -lazy_static::lazy_static! { - static ref MIME_ICON_CACHE: Mutex = Mutex::new(MimeIconCache::new()); -} +static MIME_ICON_CACHE: Lazy> = Lazy::new(|| Mutex::new(MimeIconCache::new())); pub fn mime_icon>(path: P, size: u16) -> icon::Handle { //TODO: smarter path handling diff --git a/src/tab.rs b/src/tab.rs index f7bfe19..d2abb7c 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -8,6 +8,7 @@ use cosmic::{ }, theme, widget, Element, }; +use once_cell::sync::Lazy; use std::{ cmp::Ordering, collections::HashMap, @@ -24,41 +25,37 @@ const DOUBLE_CLICK_DURATION: Duration = Duration::from_millis(500); //TODO: configurable const ICON_SIZE_LIST: u16 = 32; const ICON_SIZE_GRID: u16 = 64; - -lazy_static::lazy_static! { - static ref SPECIAL_DIRS: HashMap = { - let mut special_dirs = HashMap::new(); - if let Some(dir) = dirs::document_dir() { - special_dirs.insert(dir, "folder-documents"); - } - if let Some(dir) = dirs::download_dir() { - special_dirs.insert(dir, "folder-download"); - } - if let Some(dir) = dirs::audio_dir() { - special_dirs.insert(dir, "folder-music"); - } - if let Some(dir) = dirs::picture_dir() { - special_dirs.insert(dir, "folder-pictures"); - } - if let Some(dir) = dirs::public_dir() { - special_dirs.insert(dir, "folder-publicshare"); - } - if let Some(dir) = dirs::template_dir() { - special_dirs.insert(dir, "folder-templates"); - } - if let Some(dir) = dirs::video_dir() { - special_dirs.insert(dir, "folder-videos"); - } - if let Some(dir) = dirs::desktop_dir() { - special_dirs.insert(dir, "user-desktop"); - } - if let Some(dir) = dirs::home_dir() { - special_dirs.insert(dir, "user-home"); - } - special_dirs - }; -} - +static SPECIAL_DIRS: Lazy> = Lazy::new(|| { + let mut special_dirs = HashMap::new(); + if let Some(dir) = dirs::document_dir() { + special_dirs.insert(dir, "folder-documents"); + } + if let Some(dir) = dirs::download_dir() { + special_dirs.insert(dir, "folder-download"); + } + if let Some(dir) = dirs::audio_dir() { + special_dirs.insert(dir, "folder-music"); + } + if let Some(dir) = dirs::picture_dir() { + special_dirs.insert(dir, "folder-pictures"); + } + if let Some(dir) = dirs::public_dir() { + special_dirs.insert(dir, "folder-publicshare"); + } + if let Some(dir) = dirs::template_dir() { + special_dirs.insert(dir, "folder-templates"); + } + if let Some(dir) = dirs::video_dir() { + special_dirs.insert(dir, "folder-videos"); + } + if let Some(dir) = dirs::desktop_dir() { + special_dirs.insert(dir, "user-desktop"); + } + if let Some(dir) = dirs::home_dir() { + special_dirs.insert(dir, "user-home"); + } + special_dirs +}); fn button_style(selected: bool) -> theme::Button { //TODO: move to libcosmic theme::Button::Custom {