diff --git a/Cargo.lock b/Cargo.lock index 447d230..6a607c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,7 +22,7 @@ source = "git+https://github.com/wash2/accesskit.git?tag=winit-0.28#db6f2587f663 dependencies = [ "accesskit", "accesskit_consumer", - "async-channel", + "async-channel 1.9.0", "atspi", "futures-lite 1.13.0", "log", @@ -213,16 +213,29 @@ dependencies = [ ] [[package]] -name = "async-executor" -version = "1.6.0" +name = "async-channel" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0c4a4f319e45986f347ee47fef8bf5e81c9abc3f6f58dc2391439f30df65f0" +checksum = "d37875bd9915b7d67c2f117ea2c30a0989874d0b2cb694fe25403c85763c0c9e" dependencies = [ - "async-lock 2.8.0", + "concurrent-queue", + "event-listener 3.1.0", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de517d5a758a65a16d18d8f605e7a6beed477444cca270116af40fd3cd59d27" +dependencies = [ + "async-lock 3.1.0", "async-task", "concurrent-queue", "fastrand 2.0.1", - "futures-lite 1.13.0", + "futures-lite 2.0.1", "slab", ] @@ -244,7 +257,7 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" dependencies = [ - "async-channel", + "async-channel 1.9.0", "async-executor", "async-io 1.13.0", "async-lock 2.8.0", @@ -279,7 +292,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41ed9d5715c2d329bf1b4da8d60455b99b187f27ba726df2883799af9af60997" dependencies = [ - "async-lock 3.0.0", + "async-lock 3.1.0", "cfg-if", "concurrent-queue", "futures-io", @@ -304,11 +317,11 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45e900cdcd39bb94a14487d3f7ef92ca222162e6c7c3fe7cb3550ea75fb486ed" +checksum = "deb2ab2aa8a746e221ab826c73f48bc6ba41be6763f0855cb249eb6d154cf1d7" dependencies = [ - "event-listener 3.0.1", + "event-listener 3.1.0", "event-listener-strategy", "pin-project-lite", ] @@ -324,7 +337,7 @@ dependencies = [ "async-signal", "blocking", "cfg-if", - "event-listener 3.0.1", + "event-listener 3.1.0", "futures-lite 1.13.0", "rustix 0.38.21", "windows-sys 0.48.0", @@ -365,7 +378,7 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" dependencies = [ - "async-channel", + "async-channel 1.9.0", "async-global-executor", "async-io 1.13.0", "async-lock 2.8.0", @@ -526,16 +539,16 @@ dependencies = [ [[package]] name = "blocking" -version = "1.4.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c36a4d0d48574b3dd360b4b7d95cc651d2b6557b6402848a27d4b228a473e2a" +checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ - "async-channel", - "async-lock 2.8.0", + "async-channel 2.1.0", + "async-lock 3.1.0", "async-task", "fastrand 2.0.1", "futures-io", - "futures-lite 1.13.0", + "futures-lite 2.0.1", "piper", "tracing", ] @@ -625,9 +638,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.83" +version = "1.0.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "0f8e7c90afad890484a21653d08b6e209ae34770fb5ee298f9c699fcc1e5c856" dependencies = [ "libc", ] @@ -833,7 +846,7 @@ dependencies = [ [[package]] name = "cosmic-comp-config" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-comp#f3a8ff8600d2825de945e2130008f9b2c6d64990" +source = "git+https://github.com/pop-os/cosmic-comp#9a04fa2abdd53cbe4798dcaaf42bea89d8d073d1" dependencies = [ "input", "serde", @@ -842,7 +855,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "atomicwrites", "calloop", @@ -857,7 +870,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "quote", "syn 1.0.109", @@ -884,7 +897,7 @@ dependencies = [ "anyhow", "apply", "ashpd 0.6.7", - "async-channel", + "async-channel 1.9.0", "color-eyre", "cosmic-comp-config", "cosmic-panel-config", @@ -912,6 +925,7 @@ dependencies = [ "rust-embed", "serde", "slotmap", + "static_init", "tokio", "tracing", "tracing-subscriber", @@ -993,7 +1007,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "almost", "cosmic-config", @@ -1323,9 +1337,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" dependencies = [ "humantime", "is-terminal", @@ -1342,9 +1356,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" dependencies = [ "libc", "windows-sys 0.48.0", @@ -1352,9 +1366,9 @@ dependencies = [ [[package]] name = "etagere" -version = "0.2.9" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf70b9ea3a235a7432b4f481854815e2d4fb2fe824c1f5fb09b8985dd06b3e9" +checksum = "fcf22f748754352918e082e0039335ee92454a5d62bcaf69b5e8daf5907d9644" dependencies = [ "euclid", "svg_fmt", @@ -1377,9 +1391,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "3.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cec0252c2afff729ee6f00e903d479fba81784c8e2bd77447673471fdfaea1" +checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" dependencies = [ "concurrent-queue", "parking", @@ -1392,7 +1406,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d96b852f1345da36d551b9473fa1e2b1eb5c5195585c6c018118bc92a8d91160" dependencies = [ - "event-listener 3.0.1", + "event-listener 3.1.0", "pin-project-lite", ] @@ -1519,7 +1533,7 @@ dependencies = [ "intl-memoizer", "intl_pluralrules", "rustc-hash", - "self_cell", + "self_cell 0.10.3", "smallvec", "unic-langid", ] @@ -1803,9 +1817,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "js-sys", @@ -2107,7 +2121,7 @@ dependencies = [ [[package]] name = "iced" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "iced_accessibility", "iced_core", @@ -2122,7 +2136,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "accesskit", "accesskit_unix", @@ -2131,7 +2145,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "bitflags 1.3.2", "iced_accessibility", @@ -2146,7 +2160,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.7.0" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "futures", "iced_core", @@ -2159,7 +2173,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2177,7 +2191,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2190,7 +2204,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.1.1" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "iced_accessibility", "iced_core", @@ -2202,7 +2216,7 @@ dependencies = [ [[package]] name = "iced_sctk" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "enum-repr", "float-cmp", @@ -2226,7 +2240,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "iced_core", "once_cell", @@ -2236,7 +2250,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "bytemuck", "cosmic-text", @@ -2254,7 +2268,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.11.1" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2276,7 +2290,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.1.3" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "iced_renderer", "iced_runtime", @@ -2675,7 +2689,7 @@ checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#484417787a4d7ebf7c3db9473729563ee917e546" +source = "git+https://github.com/pop-os/libcosmic#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "apply", "ashpd 0.5.0", @@ -2761,9 +2775,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" [[package]] name = "litemap" @@ -3896,7 +3910,7 @@ dependencies = [ "bitflags 2.4.1", "errno", "libc", - "linux-raw-sys 0.4.10", + "linux-raw-sys 0.4.11", "windows-sys 0.48.0", ] @@ -3962,9 +3976,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "self_cell" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ef965a420fe14fdac7dd018862966a4c14094f900e1650bbc71ddd7d580c8af" +checksum = "e14e4d63b804dc0c7ec4a1e52bcb63f02c7ac94476755aa579edac21e01f915d" +dependencies = [ + "self_cell 1.0.2", +] + +[[package]] +name = "self_cell" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e388332cd64eb80cd595a00941baf513caffae8dce9cfd0467fc9c66397dade6" [[package]] name = "serde" @@ -4087,9 +4110,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "smithay-client-toolkit" @@ -4224,6 +4247,34 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "static_init" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a2a1c578e98c1c16fc3b8ec1328f7659a500737d7a0c6d625e73e830ff9c1f6" +dependencies = [ + "bitflags 1.3.2", + "cfg_aliases", + "libc", + "parking_lot 0.11.2", + "parking_lot_core 0.8.6", + "static_init_macro", + "winapi", +] + +[[package]] +name = "static_init_macro" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a2595fc3aa78f2d0e45dd425b22282dd863273761cc77780914b2cf3003acf" +dependencies = [ + "cfg_aliases", + "memchr", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "strict-num" version = "0.1.1" @@ -4465,9 +4516,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.33.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" dependencies = [ "backtrace", "bytes", @@ -5598,7 +5649,7 @@ dependencies = [ [[package]] name = "xdg-shell-wrapper-config" version = "0.1.0" -source = "git+https://github.com/pop-os/xdg-shell-wrapper#fa62a8c865cc5ba391a48fe4753a8687d8ab8ded" +source = "git+https://github.com/pop-os/xdg-shell-wrapper#f2ca1c3dee8f66c40bdc91cb39de69a62aaaf22f" dependencies = [ "serde", "wayland-protocols-wlr", diff --git a/app/Cargo.toml b/app/Cargo.toml index 876cbea..54be2dd 100644 --- a/app/Cargo.toml +++ b/app/Cargo.toml @@ -41,6 +41,7 @@ image = "0.24.6" serde = { version = "1.0.180", features = ["derive"] } ashpd = "0.6.2" ron = "0.8" +static_init = "1.0.3" [dependencies.i18n-embed] version = "0.13.9" diff --git a/app/src/pages/desktop/wallpaper/mod.rs b/app/src/pages/desktop/wallpaper/mod.rs index a29cddc..324223d 100644 --- a/app/src/pages/desktop/wallpaper/mod.rs +++ b/app/src/pages/desktop/wallpaper/mod.rs @@ -6,7 +6,6 @@ mod widgets; use std::{ collections::HashMap, path::{Path, PathBuf}, - time::Instant, }; use apply::Apply; @@ -22,6 +21,7 @@ use cosmic_settings_page::Section; use cosmic_settings_page::{self as page, section}; use image::imageops::FilterType::Lanczos3; use slotmap::{DefaultKey, SecondaryMap, SlotMap}; +use static_init::dynamic; const SYSTEM_WALLPAPER_DIR: &str = "/usr/share/backgrounds/pop/"; @@ -46,7 +46,7 @@ const HOUR_2: usize = 5; pub enum Message { ChangeCategory(usize), ColorSelect(wallpaper::Color), - Fit(String), + Fit(usize), Output(segmented_button::Entity), RotationFrequency(usize), SameBackground(bool), @@ -364,11 +364,11 @@ impl Page { #[must_use] pub fn display_image_view(&self) -> cosmic::Element { match self.cached_display_handle { - Some(ref handle) => cosmic::iced::widget::image(handle.clone()) + Some(ref handle) => cosmic::widget::image(handle.clone()) .width(Length::Fixed(SIMULATED_WIDTH as f32)) .into(), - None => cosmic::iced::widget::Space::new(SIMULATED_WIDTH, SIMULATED_HEIGHT).into(), + None => cosmic::widget::Space::new(SIMULATED_WIDTH, SIMULATED_HEIGHT).into(), } } @@ -382,14 +382,8 @@ impl Page { self.cached_display_handle = None; } - Message::Fit(option) => { - self.selected_fit = self - .fit_options - .iter() - .enumerate() - .find(|(_, key)| **key == option) - .map_or(0, |(indice, _)| indice); - + Message::Fit(selection) => { + self.selected_fit = selection; self.cache_display_image(); } @@ -512,8 +506,6 @@ impl page::Page for Page { fn load(&self, _page: page::Entity) -> Option> { Some(Box::pin(async move { - let start = Instant::now(); - let (config, outputs) = wallpaper::config(); let mut backgrounds = wallpaper::load_each_from_path(SYSTEM_WALLPAPER_DIR.into()); @@ -533,11 +525,6 @@ impl page::Page for Page { update.selection_handles.insert(id, selection_handle); } - tracing::debug!( - "loaded wallpapers in {:?}", - Instant::now().duration_since(start) - ); - crate::pages::Message::DesktopWallpaper(Message::Update(Box::new(( config, outputs, update, )))) @@ -547,18 +534,28 @@ impl page::Page for Page { impl page::AutoBind for Page {} +#[dynamic] +static WALLPAPER_SAME: String = fl!("wallpaper", "same"); + +#[dynamic] +static WALLPAPER_FIT: String = fl!("wallpaper", "fit"); + +#[dynamic] +static WALLPAPER_SLIDE: String = fl!("wallpaper", "slide"); + +#[dynamic] +static WALLPAPER_CHANGE: String = fl!("wallpaper", "change"); + #[allow(clippy::too_many_lines)] pub fn settings() -> Section { Section::default() .descriptions(vec![ - fl!("wallpaper", "same"), - fl!("wallpaper", "fit"), - fl!("wallpaper", "slide"), - fl!("wallpaper", "change"), + WALLPAPER_SAME.clone(), + WALLPAPER_FIT.clone(), + WALLPAPER_SLIDE.clone(), + WALLPAPER_CHANGE.clone(), ]) - .view::(|_binder, page, section| { - let descriptions = §ion.descriptions; - + .view::(|_binder, page, _section| { let mut children = Vec::with_capacity(3); let mut show_slideshow_toggle = true; @@ -590,7 +587,7 @@ pub fn settings() -> Section { .vertical_alignment(alignment::Vertical::Center) .width(Length::Fill) .height(Length::Fill) - .apply(cosmic::iced::widget::container) + .apply(cosmic::widget::container) .width(Length::Fill) .height(Length::Fixed(32.0)) .into() @@ -600,32 +597,29 @@ pub fn settings() -> Section { .into() }); - let background_fit = cosmic::iced::widget::pick_list( - &page.fit_options, - page.fit_options.get(page.selected_fit).cloned(), - Message::Fit, - ); + let background_fit = + cosmic::widget::dropdown(&page.fit_options, Some(page.selected_fit), Message::Fit); children.push({ let mut column = list_column() .add(settings::item( - &descriptions[0], + &*WALLPAPER_SAME, toggler(None, page.config.same_on_all, Message::SameBackground), )) - .add(settings::item(&descriptions[1], background_fit)); + .add(settings::item(&*WALLPAPER_FIT, background_fit)); if show_slideshow_toggle { column = column.add(settings::item( - &descriptions[2], + &*WALLPAPER_SLIDE, toggler(None, slideshow_enabled, Message::Slideshow), )); } - // The rotation frequency pick list should only be shown when the slideshow is enabled. + // The rotation frequency dropdown should only be shown when the slideshow is enabled. if slideshow_enabled { column .add(settings::item( - &descriptions[3], + &*WALLPAPER_CHANGE, dropdown( &page.rotation_options, Some(page.selected_rotation), @@ -649,18 +643,31 @@ pub fn settings() -> Section { match page.active_category { // Displays system wallpapers that are available to select from CATEGORY_SYSTEM_WALLPAPERS => { - children.push(widgets::wallpaper_select_options(page)); + children.push(widgets::wallpaper_select_options( + page, + if let Choice::Background(selection) = page.selection.active { + Some(selection) + } else { + None + }, + )); } // Displays colors and gradients that are available to select from CATEGORY_COLOR => { - children.push(widgets::color_select_options()); + children.push(widgets::color_select_options( + if let Choice::Color(ref color) = page.selection.active { + Some(color) + } else { + None + }, + )); } _ => (), } - cosmic::iced::widget::column(children) + cosmic::widget::column::with_children(children) .spacing(22) .apply(Element::from) .map(crate::pages::Message::DesktopWallpaper) diff --git a/app/src/pages/desktop/wallpaper/widgets.rs b/app/src/pages/desktop/wallpaper/widgets.rs index e2cd046..7af0f28 100644 --- a/app/src/pages/desktop/wallpaper/widgets.rs +++ b/app/src/pages/desktop/wallpaper/widgets.rs @@ -5,7 +5,7 @@ use super::Message; use cosmic::iced_core::{self, gradient::Linear, Background, BorderRadius, Color, Degrees, Length}; use cosmic::iced_runtime::core::image::Handle as ImageHandle; use cosmic::prelude::*; -use cosmic::widget::{button, container, image, space}; +use cosmic::widget::{button, container, space}; use cosmic::{iced, Element}; use cosmic_settings_desktop::wallpaper; use slotmap::DefaultKey; @@ -15,10 +15,11 @@ const COLUMN_SPACING: u16 = 12; const ROW_SPACING: u16 = 16; /// A button for selecting a color or gradient. -pub fn color_button(color: wallpaper::Color) -> Element<'static, Message> { +pub fn color_button(color: wallpaper::Color, selected: bool) -> Element<'static, Message> { button(color_image(color.clone(), COLOR_WIDTH, COLOR_WIDTH, 8.0)) .padding(0) - .style(button::Style::IconVertical) + .selected(selected) + .style(button::Style::Image) .on_press(Message::ColorSelect(color)) .into() } @@ -64,22 +65,32 @@ pub fn color_image( } /// Color selection list -pub fn color_select_options() -> Element<'static, Message> { +pub fn color_select_options(selected: Option<&wallpaper::Color>) -> Element<'static, Message> { let mut vec = Vec::with_capacity(wallpaper::DEFAULT_COLORS.len()); for color in wallpaper::DEFAULT_COLORS { - vec.push(color_button(color.clone())); + vec.push(color_button( + color.clone(), + selected.map_or(false, |selection| selection == color), + )); } flex_select_row(vec) } /// Background selection list -pub fn wallpaper_select_options(page: &super::Page) -> Element { +pub fn wallpaper_select_options( + page: &super::Page, + selected: Option, +) -> Element { let mut vec = Vec::with_capacity(page.selection.selection_handles.len()); for (id, handle) in &page.selection.selection_handles { - vec.push(wallpaper_button(handle, id)); + vec.push(wallpaper_button( + handle, + id, + selected.map_or(false, |selection| id == selection), + )); } flex_select_row(vec) @@ -95,12 +106,9 @@ fn flex_select_row(elements: Vec>) -> Element { .into() } -fn wallpaper_button(handle: &ImageHandle, id: DefaultKey) -> Element { - let image = image(handle.clone()).apply(iced::Element::from); - - button(image) - .padding(0) - .style(cosmic::theme::Button::Transparent) +fn wallpaper_button(handle: &ImageHandle, id: DefaultKey, selected: bool) -> Element { + cosmic::widget::button::image(handle.clone()) + .selected(selected) .on_press(Message::Select(id)) .into() } diff --git a/justfile b/justfile index 5c17987..27bda0d 100644 --- a/justfile +++ b/justfile @@ -30,7 +30,7 @@ desktop := appid + '.desktop' desktop-src := 'resources' / desktop desktop-dest := clean(rootdir / prefix) / 'share' / 'applications' / desktop -iconsdir := clean(rootdir / prefix) / 'share' / 'icons' / 'hicolor' +iconsdir := clean(rootdir / prefix) / 'share' / 'icons' / 'hicolor' [private] default: build-release @@ -75,11 +75,11 @@ install-file src dest: (install-cmd '-Dm0644' src dest) install: (install-bin bin-src bin-dest) (install-file desktop-src desktop-dest) find 'resources'/'default_schema' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -d '\n' -I {} install -Dm0644 'resources'/'default_schema'/{} {{default-schema-target}}/{} find 'resources'/'icons' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -d '\n' -I {} install -Dm0644 'resources'/'icons'/{} {{iconsdir}}/{} - + # Run the application for testing purposes run *args: env RUST_LOG=debug RUST_BACKTRACE=full cargo run --release {{args}} - @just resources/icons/install + # Run `cargo test` test: cargo test @@ -89,7 +89,7 @@ uninstall: rm -rf {{bin-dest}} {{desktop-dest}} find 'resources'/'default_schema' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -d '\n' -I {} rm -rf {{default-schema-target}}/{} find 'resources'/'icons' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -d '\n' -I {} rm {{iconsdir}}/{} - + # Vendor Cargo dependencies locally vendor: mkdir -p .cargo