From 2f54c11604e6c36ead5e561032faa15f56146675 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Wed, 22 May 2024 15:48:40 -0400 Subject: [PATCH] fix: cargo fmt --- cosmic-settings/src/pages/mod.rs | 2 +- cosmic-settings/src/pages/power/mod.rs | 63 +++++++++++++------------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/cosmic-settings/src/pages/mod.rs b/cosmic-settings/src/pages/mod.rs index 213985d..f6c5b81 100644 --- a/cosmic-settings/src/pages/mod.rs +++ b/cosmic-settings/src/pages/mod.rs @@ -7,10 +7,10 @@ pub mod desktop; pub mod display; pub mod input; pub mod networking; +pub mod power; pub mod sound; pub mod system; pub mod time; -pub mod power; #[derive(Clone, Debug)] pub enum Message { diff --git a/cosmic-settings/src/pages/power/mod.rs b/cosmic-settings/src/pages/power/mod.rs index 81fbd57..4089bf1 100644 --- a/cosmic-settings/src/pages/power/mod.rs +++ b/cosmic-settings/src/pages/power/mod.rs @@ -1,7 +1,7 @@ -use cosmic_settings_page::{self as page, section, Section}; use backend::PowerProfile; use cosmic::iced::widget; use cosmic::{widget::settings, Apply}; +use cosmic_settings_page::{self as page, section, Section}; use slotmap::SlotMap; pub mod backend; @@ -14,7 +14,7 @@ impl page::Page for Page { page::Info::new("power", "battery-symbolic") .title(fl!("power")) .description(fl!("power", "desc")) - } + } fn content( &self, @@ -38,46 +38,45 @@ impl Page { } } - fn profiles() -> Section { Section::default() - .title(fl!("power-profiles")) - .descriptions(vec![fl!("power", "desc").into()]) - .view::(|_binder, page, section| { - let runtime = tokio::runtime::Runtime::new().unwrap(); + .title(fl!("power-profiles")) + .descriptions(vec![fl!("power", "desc").into()]) + .view::(|_binder, page, section| { + let runtime = tokio::runtime::Runtime::new().unwrap(); - let profiles = backend::get_power_profiles(); + let profiles = backend::get_power_profiles(); - let current_profile = runtime.block_on(backend::get_current_power_profile()); + let current_profile = runtime.block_on(backend::get_current_power_profile()); - let mut section = settings::view_section(§ion.title); + let mut section = settings::view_section(§ion.title); - let mut widgets = Vec::new(); + let mut widgets = Vec::new(); - for profile in profiles { - let selected = if current_profile == profile { - Some(true) - } else { - None - }; + for profile in profiles { + let selected = if current_profile == profile { + Some(true) + } else { + None + }; - let widget = widget::Radio::new("", true, selected, |_| { - Message::PowerProfileChange(profile.clone()) - }); - let item = settings::item::builder(profile.title()) - .description(profile.description()) - .control(widget); - widgets.push(item); - } + let widget = widget::Radio::new("", true, selected, |_| { + Message::PowerProfileChange(profile.clone()) + }); + let item = settings::item::builder(profile.title()) + .description(profile.description()) + .control(widget); + widgets.push(item); + } - for item in widgets { - section = section.add(item); - } + for item in widgets { + section = section.add(item); + } - section - .apply(cosmic::Element::from) - .map(crate::pages::Message::Power) - }) + section + .apply(cosmic::Element::from) + .map(crate::pages::Message::Power) + }) } impl page::AutoBind for Page {}