chore: Rust 2024 edition format

This commit is contained in:
Michael Aaron Murphy 2025-03-28 21:11:38 +01:00
parent 665e4e13b8
commit 1e5aaad61c
No known key found for this signature in database
GPG key ID: B2732D4240C9212C
35 changed files with 243 additions and 216 deletions

View file

@ -2,8 +2,8 @@
// SPDX-License-Identifier: GPL-3.0-only
use i18n_embed::{
fluent::{fluent_language_loader, FluentLanguageLoader},
DefaultLocalizer, LanguageLoader, Localizer,
fluent::{FluentLanguageLoader, fluent_language_loader},
};
use once_cell::sync::Lazy;
use rust_embed::RustEmbed;

View file

@ -9,16 +9,15 @@ use std::{
};
use cosmic::{
surface,
Apply, Element, Task, surface,
widget::{self, dropdown, icon, settings},
Apply, Element, Task,
};
use cosmic_config::{ConfigGet, ConfigSet};
use cosmic_settings_config::shortcuts::action::System;
use cosmic_settings_config::shortcuts::SystemActions;
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_config::shortcuts::action::System;
use cosmic_settings_page::{self as page, Section, section};
use freedesktop_desktop_entry::{
default_paths, get_languages_from_env, DesktopEntry, Iter as DesktopEntryIter,
DesktopEntry, Iter as DesktopEntryIter, default_paths, get_languages_from_env,
};
use mime_apps::App;
use slotmap::SlotMap;

View file

@ -2,10 +2,10 @@
// SPDX-License-Identifier: GPL-3.0-only
use cosmic::{
Apply, Element,
cosmic_config::{self, ConfigGet, ConfigSet},
iced::Length,
widget::{self, text},
Apply, Element,
};
use cosmic_settings_page::Section;
use cosmic_settings_page::{self as page, section};
@ -95,26 +95,30 @@ pub fn legacy_application_scaling() -> Section<crate::pages::Message> {
let descriptions = &section.descriptions;
widget::settings::section()
.title(&section.title)
.add(widget::settings::item_row(vec![widget::radio(
widget::column()
.push(text::body(&descriptions[system]))
.push(text::caption(&descriptions[system_desc])),
false,
Some(page.comp_config_descale_xwayland),
Message::SetXwaylandDescaling,
)
.width(Length::Fill)
.into()]))
.add(widget::settings::item_row(vec![widget::radio(
widget::column()
.push(text::body(&descriptions[native]))
.push(text::caption(&descriptions[native_desc])),
true,
Some(page.comp_config_descale_xwayland),
Message::SetXwaylandDescaling,
)
.width(Length::Fill)
.into()]))
.add(widget::settings::item_row(vec![
widget::radio(
widget::column()
.push(text::body(&descriptions[system]))
.push(text::caption(&descriptions[system_desc])),
false,
Some(page.comp_config_descale_xwayland),
Message::SetXwaylandDescaling,
)
.width(Length::Fill)
.into(),
]))
.add(widget::settings::item_row(vec![
widget::radio(
widget::column()
.push(text::body(&descriptions[native]))
.push(text::caption(&descriptions[native_desc])),
true,
Some(page.comp_config_descale_xwayland),
Message::SetXwaylandDescaling,
)
.width(Length::Fill)
.into(),
]))
.apply(Element::from)
.map(crate::pages::Message::LegacyApplications)
})

View file

@ -1,14 +1,14 @@
// Copyright 2024 System76 <info@system76.com>
// SPDX-License-Identifier: GPL-3.0-only
use cosmic::iced::{color, Alignment, Length};
use cosmic::iced::{Alignment, Length, color};
use cosmic::iced_core::text::Wrapping;
use cosmic::widget::{self, settings, text};
use cosmic::{theme, Apply, Element, Task};
use cosmic_settings_page::{self as page, section, Section};
use cosmic::{Apply, Element, Task, theme};
use cosmic_settings_page::{self as page, Section, section};
use cosmic_settings_subscriptions::bluetooth::*;
use futures::channel::oneshot;
use futures::StreamExt;
use futures::channel::oneshot;
use slab::Slab;
use slotmap::SlotMap;
use std::collections::{HashMap, HashSet};

View file

@ -5,11 +5,11 @@ use std::rc::Rc;
use std::sync::Arc;
use cosmic::{
Apply, Element, Task,
config::{CosmicTk, FontConfig},
iced_core::text::Wrapping,
theme,
widget::{self, settings, svg},
Apply, Element, Task,
};
use cosmic_config::ConfigSet;

View file

@ -5,9 +5,9 @@ use std::{collections::BTreeMap, path::PathBuf};
use super::Message;
use cosmic::{
Element,
iced::{Background, Length},
widget::{button, icon, text},
Element,
};
use tokio::io::AsyncBufReadExt;

View file

@ -1,11 +1,11 @@
use cosmic::{
Apply, Element, Task,
cosmic_config::CosmicConfigEntry,
iced::{Alignment, Length},
widget::{button, container, row},
Apply, Element, Task,
};
use cosmic_panel_config::CosmicPanelConfig;
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_page::{self as page, Section, section};
use slotmap::{Key, SlotMap};
use std::borrow::Cow;
@ -13,7 +13,7 @@ use crate::{
app,
pages::{
self,
desktop::panel::applets_inner::{self, lists, AppletsPage, ContextDrawer},
desktop::panel::applets_inner::{self, AppletsPage, ContextDrawer, lists},
},
};

View file

@ -2,12 +2,12 @@ use std::collections::HashMap;
use cosmic::Apply;
use cosmic::{
Element, Task,
cosmic_config::{ConfigSet, CosmicConfigEntry},
widget::{settings, text, toggler},
Element, Task,
};
use cosmic_panel_config::{CosmicPanelConfig, CosmicPanelContainerConfig};
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_page::{self as page, Section, section};
use slab::Slab;
use slotmap::SlotMap;
use tracing::error;

View file

@ -1,27 +1,27 @@
use cosmic::iced::Vector;
use cosmic::iced::clipboard::dnd::{
DndAction, DndDestinationRectangle, DndEvent, OfferEvent, SourceEvent,
};
use cosmic::iced::clipboard::mime::AsMimeTypes;
use cosmic::iced::id::Internal;
use cosmic::iced::Vector;
use cosmic::iced_core;
use cosmic::iced_core::clipboard::IconSurface;
use cosmic::widget::{button, column, container, icon, list_column, row, text, text_input, Column};
use cosmic::widget::{Column, button, column, container, icon, list_column, row, text, text_input};
use cosmic::{
Apply, Element,
cosmic_config::{Config, CosmicConfigEntry},
iced::{
core::window, event, mouse, overlay, touch, Alignment, Color, Length, Point, Rectangle,
Size,
Alignment, Color, Length, Point, Rectangle, Size, core::window, event, mouse, overlay,
touch,
},
iced_runtime::{core::id::Id, Task},
iced_runtime::{Task, core::id::Id},
iced_widget::core::{
layout, renderer,
widget::{tree, Operation, Tree},
Clipboard, Shell, Widget,
Clipboard, Shell, Widget, layout, renderer,
widget::{Operation, Tree, tree},
},
theme, Apply, Element,
theme,
};
use once_cell::sync::Lazy;
@ -30,7 +30,7 @@ use std::{borrow::Cow, fmt::Debug, mem, path::Path};
use crate::{app, pages};
use cosmic_panel_config::CosmicPanelConfig;
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_page::{self as page, Section, section};
use freedesktop_desktop_entry::DesktopEntry;
use slotmap::{Key, SlotMap};
use tracing::error;
@ -110,7 +110,7 @@ impl page::Page<crate::pages::Message> for Page {
sections: &mut SlotMap<section::Entity, Section<crate::pages::Message>>,
) -> Option<page::Content> {
Some(vec![
sections.insert(lists::<Page, _>(pages::Message::PanelApplet))
sections.insert(lists::<Page, _>(pages::Message::PanelApplet)),
])
}

View file

@ -1,12 +1,12 @@
use cosmic::{
cctk::sctk::reexports::client::{backend::ObjectId, protocol::wl_output::WlOutput, Proxy},
Element, Task,
cctk::sctk::reexports::client::{Proxy, backend::ObjectId, protocol::wl_output::WlOutput},
cosmic_config::{self, CosmicConfigEntry},
iced::{Alignment, Length},
surface, theme,
widget::{
button, container, dropdown, horizontal_space, icon, row, settings, slider, text, toggler,
},
Element, Task,
};
use cosmic::Apply;

View file

@ -1,8 +1,8 @@
use std::collections::HashMap;
use cosmic::{cosmic_config::CosmicConfigEntry, Task};
use cosmic::{Task, cosmic_config::CosmicConfigEntry};
use cosmic_panel_config::{CosmicPanelConfig, CosmicPanelContainerConfig};
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_page::{self as page, Section, section};
use slotmap::SlotMap;
use crate::pages::desktop::panel::inner::{

View file

@ -4,11 +4,11 @@
use super::Message;
use cosmic::iced::Radius;
use cosmic::iced_core::Border;
use cosmic::iced_core::{self, gradient::Linear, Background, Color, Degrees, Length};
use cosmic::iced_core::{self, Background, Color, Degrees, Length, gradient::Linear};
use cosmic::iced_runtime::core::image::Handle as ImageHandle;
use cosmic::prelude::*;
use cosmic::widget::{button, container, Space};
use cosmic::{iced, Element};
use cosmic::widget::{Space, button, container};
use cosmic::{Element, iced};
use cosmic_settings_wallpaper as wallpaper;
use slotmap::DefaultKey;
use std::sync::OnceLock;

View file

@ -2,14 +2,14 @@
// SPDX-License-Identifier: GPL-3.0-only
use cosmic::{
Apply, Element,
iced::Length,
surface,
widget::{self, settings, toggler},
Apply, Element,
};
use cosmic_config::{ConfigGet, ConfigSet};
use cosmic_settings_config::{shortcuts, Action, Binding, Shortcuts};
use cosmic_settings_config::{Action, Binding, Shortcuts, shortcuts};
use cosmic_settings_page::Section;
use cosmic_settings_page::{self as page, section};
use slab::Slab;

View file

@ -4,10 +4,10 @@
// TODO make settings work
use cosmic::{
Apply, Element,
cosmic_config::{self, ConfigGet, ConfigSet},
iced::Length,
widget::{radio, settings, text},
Apply, Element,
};
use cosmic_comp_config::workspace::{WorkspaceConfig, WorkspaceLayout, WorkspaceMode};
use cosmic_settings_page::Section;
@ -136,22 +136,26 @@ fn multi_behavior() -> Section<crate::pages::Message> {
let descriptions = &section.descriptions;
settings::section()
.title(&section.title)
.add(settings::item_row(vec![radio(
text::body(&descriptions[span]),
WorkspaceMode::Global,
Some(page.comp_workspace_config.workspace_mode),
Message::SetWorkspaceMode,
)
.width(Length::Fill)
.into()]))
.add(settings::item_row(vec![radio(
text::body(&descriptions[separate]),
WorkspaceMode::OutputBound,
Some(page.comp_workspace_config.workspace_mode),
Message::SetWorkspaceMode,
)
.width(Length::Fill)
.into()]))
.add(settings::item_row(vec![
radio(
text::body(&descriptions[span]),
WorkspaceMode::Global,
Some(page.comp_workspace_config.workspace_mode),
Message::SetWorkspaceMode,
)
.width(Length::Fill)
.into(),
]))
.add(settings::item_row(vec![
radio(
text::body(&descriptions[separate]),
WorkspaceMode::OutputBound,
Some(page.comp_workspace_config.workspace_mode),
Message::SetWorkspaceMode,
)
.width(Length::Fill)
.into(),
]))
.apply(Element::from)
.map(crate::pages::Message::DesktopWorkspaces)
})
@ -170,22 +174,26 @@ fn workspace_orientation() -> Section<crate::pages::Message> {
let descriptions = &section.descriptions;
settings::section()
.title(&section.title)
.add(settings::item_row(vec![radio(
text::body(&descriptions[vertical]),
WorkspaceLayout::Vertical,
Some(page.comp_workspace_config.workspace_layout),
Message::SetWorkspaceLayout,
)
.width(Length::Fill)
.into()]))
.add(settings::item_row(vec![radio(
text::body(&descriptions[horizontal]),
WorkspaceLayout::Horizontal,
Some(page.comp_workspace_config.workspace_layout),
Message::SetWorkspaceLayout,
)
.width(Length::Fill)
.into()]))
.add(settings::item_row(vec![
radio(
text::body(&descriptions[vertical]),
WorkspaceLayout::Vertical,
Some(page.comp_workspace_config.workspace_layout),
Message::SetWorkspaceLayout,
)
.width(Length::Fill)
.into(),
]))
.add(settings::item_row(vec![
radio(
text::body(&descriptions[horizontal]),
WorkspaceLayout::Horizontal,
Some(page.comp_workspace_config.workspace_layout),
Message::SetWorkspaceLayout,
)
.width(Length::Fill)
.into(),
]))
.apply(Element::from)
.map(crate::pages::Message::DesktopWorkspaces)
})

View file

@ -1,16 +1,16 @@
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
use cosmic::Renderer;
use cosmic::iced_core::renderer::Quad;
use cosmic::iced_core::widget::{tree, Tree};
use cosmic::iced_core::widget::{Tree, tree};
use cosmic::iced_core::{
self as core, Border, Clipboard, Element, Layout, Length, Rectangle, Renderer as IcedRenderer,
Shell, Size, Widget,
};
use cosmic::iced_core::{Point, layout, mouse, renderer, touch};
use cosmic::iced_core::{alignment, event, text};
use cosmic::iced_core::{layout, mouse, renderer, touch, Point};
use cosmic::widget::segmented_button::{self, SingleSelectModel};
use cosmic::Renderer;
use cosmic_randr_shell::{self as randr, OutputKey};
use randr::Transform;

View file

@ -6,16 +6,16 @@ pub mod arrangement;
use crate::{app, pages};
use arrangement::Arrangement;
use cosmic::iced::{time, Alignment, Length};
use cosmic::iced::{Alignment, Length, time};
use cosmic::iced_widget::scrollable::{Direction, RelativeOffset, Scrollbar};
use cosmic::widget::{
self, column, container, dropdown, list_column, segmented_button, tab_bar, text, toggler,
};
use cosmic::{surface, Apply, Element, Task};
use cosmic::{Apply, Element, Task, surface};
use cosmic_randr_shell::{
AdaptiveSyncAvailability, AdaptiveSyncState, List, Output, OutputKey, Transform,
};
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_page::{self as page, Section, section};
use once_cell::sync::Lazy;
use slab::Slab;
use slotmap::{Key, SecondaryMap, SlotMap};

View file

@ -6,15 +6,15 @@ pub mod shortcuts;
use std::cmp;
use cosmic::{
Apply, Element, Task,
cosmic_config::{self, ConfigSet},
iced::{Alignment, Color, Length},
iced_core::Border,
theme,
widget::{self, button, container, icon, radio, row, settings, ListColumn},
Apply, Element, Task,
widget::{self, ListColumn, button, container, icon, radio, row, settings},
};
use cosmic_comp_config::{KeyboardConfig, NumlockState, XkbConfig};
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_page::{self as page, Section, section};
use itertools::Itertools;
use slab::Slab;
use slotmap::{DefaultKey, Key, SlotMap};
@ -262,11 +262,13 @@ fn special_char_radio_row<'a>(
value: Option<&'static str>,
current_value: Option<&'a str>,
) -> cosmic::Element<'a, Message> {
settings::item_row(vec![radio(desc, value, Some(current_value), |_| {
Message::SpecialCharacterSelect(value)
})
.width(Length::Fill)
.into()])
settings::item_row(vec![
radio(desc, value, Some(current_value), |_| {
Message::SpecialCharacterSelect(value)
})
.width(Length::Fill)
.into(),
])
.into()
}
@ -651,14 +653,16 @@ impl Page {
let mut list = cosmic::widget::list_column();
for (desc, state) in options {
list = list.add(settings::item_row(vec![radio(
cosmic::widget::text(desc),
Some(state),
Some(Some(current)),
|_| Message::SetNumlockState(state),
)
.width(Length::Fill)
.into()]));
list = list.add(settings::item_row(vec![
radio(
cosmic::widget::text(desc),
Some(state),
Some(Some(current)),
|_| Message::SetNumlockState(state),
)
.width(Length::Fill)
.into(),
]));
}
cosmic::widget::container(list).padding(24).into()

View file

@ -8,9 +8,9 @@ use super::{ShortcutBinding, ShortcutMessage, ShortcutModel};
use cosmic::iced::{Alignment, Length};
use cosmic::widget::{self, button, icon};
use cosmic::{Apply, Element, Task};
use cosmic_settings_config::shortcuts::{Action, Shortcuts};
use cosmic_settings_config::Binding;
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_config::shortcuts::{Action, Shortcuts};
use cosmic_settings_page::{self as page, Section, section};
use slab::Slab;
use slotmap::{Key, SlotMap};
@ -441,11 +441,9 @@ fn shortcuts() -> Section<crate::pages::Message> {
.view::<Page>(move |_binder, page, _section| {
let content = if page.model.shortcut_models.is_empty() {
widget::settings::section()
.add(widget::settings::item_row(vec![widget::text::body(fl!(
"custom-shortcuts",
"none"
))
.into()]))
.add(widget::settings::item_row(vec![
widget::text::body(fl!("custom-shortcuts", "none")).into(),
]))
.into()
} else {
page.model.view().map(Message::Shortcut)

View file

@ -3,9 +3,9 @@
use super::{ShortcutMessage, ShortcutModel};
use cosmic::{Element, Task};
use cosmic_settings_config::shortcuts::action::ResizeDirection;
use cosmic_settings_config::shortcuts::Action;
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_config::shortcuts::action::ResizeDirection;
use cosmic_settings_page::{self as page, Section, section};
use slab::Slab;
pub struct Page {

View file

@ -3,9 +3,9 @@
//
use super::{ShortcutMessage, ShortcutModel};
use cosmic::{Element, Task};
use cosmic_settings_config::shortcuts::action::Direction;
use cosmic_settings_config::shortcuts::Action;
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_config::shortcuts::action::Direction;
use cosmic_settings_page::{self as page, Section, section};
use slab::Slab;
pub struct Page {

View file

@ -3,9 +3,9 @@
use super::{ShortcutMessage, ShortcutModel};
use cosmic::{Element, Task};
use cosmic_settings_config::shortcuts::action::{Direction, FocusDirection};
use cosmic_settings_config::shortcuts::Action;
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_config::shortcuts::action::{Direction, FocusDirection};
use cosmic_settings_page::{self as page, Section, section};
use slab::Slab;
pub struct Page {

View file

@ -3,9 +3,9 @@
use super::{ShortcutMessage, ShortcutModel};
use cosmic::{Element, Task};
use cosmic_settings_config::shortcuts::action::System as SystemAction;
use cosmic_settings_config::shortcuts::Action;
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_config::shortcuts::action::System as SystemAction;
use cosmic_settings_page::{self as page, Section, section};
use slab::Slab;
pub struct Page {

View file

@ -3,9 +3,9 @@
use super::{ShortcutMessage, ShortcutModel};
use cosmic::{Element, Task};
use cosmic_settings_config::shortcuts::action::Orientation;
use cosmic_settings_config::shortcuts::Action;
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_config::shortcuts::action::Orientation;
use cosmic_settings_page::{self as page, Section, section};
use slab::Slab;
pub struct Page {

View file

@ -3,8 +3,8 @@
use crate::app;
use cosmic::{
cosmic_config::{self, ConfigGet, ConfigSet},
Task,
cosmic_config::{self, ConfigGet, ConfigSet},
};
use cosmic_comp_config::input::{
AccelConfig, AccelProfile, ClickMethod, InputConfig, ScrollConfig, ScrollMethod, TapButtonMap,

View file

@ -5,9 +5,9 @@ use cosmic::cosmic_config::ConfigGet;
use cosmic::iced::{Alignment, Length};
use cosmic::widget::{self, row, settings, text};
use cosmic::{Apply, Element};
use cosmic_comp_config::CosmicCompConfig;
use cosmic_comp_config::input::{AccelProfile, ClickMethod, ScrollMethod};
use cosmic_comp_config::workspace::{WorkspaceConfig, WorkspaceLayout};
use cosmic_comp_config::CosmicCompConfig;
use cosmic_settings_page::Section;
use cosmic_settings_page::{self as page, section};
use slab::Slab;
@ -167,23 +167,27 @@ fn click_behavior() -> Section<crate::pages::Message> {
settings::section()
.title(&*section.title)
// Secondary click via two fingers, and middle-click via three fingers
.add(settings::item_row(vec![widget::radio(
text::body(&descriptions[click_finger]),
ClickMethod::Clickfinger,
page.input_touchpad.click_method,
|option| Message::SetSecondaryClickBehavior(Some(option), true),
)
.width(Length::Fill)
.into()]))
.add(settings::item_row(vec![
widget::radio(
text::body(&descriptions[click_finger]),
ClickMethod::Clickfinger,
page.input_touchpad.click_method,
|option| Message::SetSecondaryClickBehavior(Some(option), true),
)
.width(Length::Fill)
.into(),
]))
// Secondary and middle-click via button areas.
.add(settings::item_row(vec![widget::radio(
text::body(&descriptions[button_areas]),
ClickMethod::ButtonAreas,
page.input_touchpad.click_method,
|option| Message::SetSecondaryClickBehavior(Some(option), true),
)
.width(Length::Fill)
.into()]))
.add(settings::item_row(vec![
widget::radio(
text::body(&descriptions[button_areas]),
ClickMethod::ButtonAreas,
page.input_touchpad.click_method,
|option| Message::SetSecondaryClickBehavior(Some(option), true),
)
.width(Length::Fill)
.into(),
]))
.add(
settings::item::builder(&descriptions[tap_to_click]).toggler(
page.input_touchpad
@ -219,29 +223,33 @@ fn scrolling() -> Section<crate::pages::Message> {
settings::section()
.title(&section.title)
// Two-finger scrolling toggle
.add(settings::item_row(vec![widget::radio(
text::body(&descriptions[two_finger]),
ScrollMethod::TwoFinger,
page.input_touchpad
.scroll_config
.as_ref()
.and_then(|x| x.method),
|option| Message::SetScrollMethod(Some(option), true),
)
.width(Length::Fill)
.into()]))
.add(settings::item_row(vec![
widget::radio(
text::body(&descriptions[two_finger]),
ScrollMethod::TwoFinger,
page.input_touchpad
.scroll_config
.as_ref()
.and_then(|x| x.method),
|option| Message::SetScrollMethod(Some(option), true),
)
.width(Length::Fill)
.into(),
]))
// Edge scrolling toggle
.add(settings::item_row(vec![widget::radio(
text::body(&descriptions[edge]),
ScrollMethod::Edge,
page.input_touchpad
.scroll_config
.as_ref()
.and_then(|x| x.method),
|option| Message::SetScrollMethod(Some(option), true),
)
.width(Length::Fill)
.into()]))
.add(settings::item_row(vec![
widget::radio(
text::body(&descriptions[edge]),
ScrollMethod::Edge,
page.input_touchpad
.scroll_config
.as_ref()
.and_then(|x| x.method),
|option| Message::SetScrollMethod(Some(option), true),
)
.width(Length::Fill)
.into(),
]))
// Scroll speed slider
.add(settings::item(&descriptions[scroll_speed], {
let value = page

View file

@ -8,12 +8,12 @@ pub mod wired;
use std::{ffi::OsStr, process::Stdio, sync::Arc};
use anyhow::Context;
use cosmic::{widget, Apply, Element, Task};
use cosmic::{Apply, Element, Task, widget};
use cosmic_dbus_networkmanager::{
interface::enums::{DeviceState, DeviceType},
nm::NetworkManager,
};
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_page::{self as page, Section, section};
use cosmic_settings_subscriptions::network_manager;
use futures::StreamExt;
use slotmap::SlotMap;
@ -322,17 +322,17 @@ impl Page {
}
};
let mut devices_changed = std::pin::pin!(network_manager
.receive_devices_changed()
.await
.then(|_| async {
match network_manager::devices::list(&conn, |_| true).await {
Ok(devices) => {
Message::UpdateDevices(devices.into_iter().map(Arc::new).collect())
let mut devices_changed =
std::pin::pin!(network_manager.receive_devices_changed().await.then(
|_| async {
match network_manager::devices::list(&conn, |_| true).await {
Ok(devices) => Message::UpdateDevices(
devices.into_iter().map(Arc::new).collect(),
),
Err(why) => Message::Error(why.to_string()),
}
Err(why) => Message::Error(why.to_string()),
}
}));
));
while let Some(message) = devices_changed.next().await {
_ = emitter

View file

@ -8,14 +8,14 @@ use std::sync::Arc;
use anyhow::Context;
use cosmic::dialog::file_chooser::FileFilter;
use cosmic::{
Apply, Element, Task,
iced::{Alignment, Length},
iced_core::text::Wrapping,
widget::{self, icon},
Apply, Element, Task,
};
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_page::{self as page, Section, section};
use cosmic_settings_subscriptions::network_manager::{
self, current_networks::ActiveConnectionInfo, NetworkManagerState, UUID,
self, NetworkManagerState, UUID, current_networks::ActiveConnectionInfo,
};
use futures::{FutureExt, StreamExt};
use indexmap::IndexMap;

View file

@ -5,15 +5,15 @@ use std::{collections::BTreeSet, sync::Arc};
use anyhow::Context;
use cosmic::{
Apply, Element, Task,
iced::{Alignment, Length},
iced_core::text::Wrapping,
widget::{self, icon},
Apply, Element, Task,
};
use cosmic_dbus_networkmanager::interface::enums::DeviceState;
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_page::{self as page, Section, section};
use cosmic_settings_subscriptions::network_manager::{
self, current_networks::ActiveConnectionInfo, NetworkManagerState,
self, NetworkManagerState, current_networks::ActiveConnectionInfo,
};
use futures::StreamExt;

View file

@ -1,7 +1,7 @@
use chrono::{Duration, TimeDelta};
use futures::{future::join_all, FutureExt, Stream, StreamExt};
use futures::{FutureExt, Stream, StreamExt, future::join_all};
use upower_dbus::{BatteryState, BatteryType, DeviceProxy};
use zbus::{zvariant::ObjectPath, Connection};
use zbus::{Connection, zvariant::ObjectPath};
mod ppdaemon;
mod s76powerdaemon;
@ -284,7 +284,9 @@ async fn enumerate_devices<'a>() -> Result<Vec<upower_dbus::DeviceProxy<'a>>, zb
.filter_map(std::result::Result::err)
.collect();
if errors.len() > 1 {
eprintln!("Multiple errors occurs when fetching connected device: {errors:?}. Only the last one will be returned.");
eprintln!(
"Multiple errors occurs when fetching connected device: {errors:?}. Only the last one will be returned."
);
}
return Err(errors.pop().unwrap());
}

View file

@ -4,14 +4,14 @@ use self::backend::{GetCurrentPowerProfile, SetPowerProfile};
use backend::{Battery, ConnectedDevice, PowerProfile};
use chrono::TimeDelta;
use cosmic::Task;
use cosmic::iced::{Alignment, Length};
use cosmic::iced_widget::{column, row};
use cosmic::widget::{self, radio, settings, text};
use cosmic::Task;
use cosmic::{surface, Apply};
use cosmic::{Apply, surface};
use cosmic_config::{Config, CosmicConfigEntry};
use cosmic_idle_config::CosmicIdleConfig;
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_page::{self as page, Section, section};
use futures::StreamExt;
use itertools::Itertools;
use slab::Slab;
@ -383,16 +383,18 @@ fn profiles() -> Section<crate::pages::Message> {
section = profiles
.into_iter()
.map(|profile| {
settings::item_row(vec![radio(
widget::column::with_capacity(2)
.push(text::body(profile.title()))
.push(text::caption(profile.description())),
profile,
Some(current_profile),
Message::PowerProfileChange,
)
.width(Length::Fill)
.into()])
settings::item_row(vec![
radio(
widget::column::with_capacity(2)
.push(text::body(profile.title()))
.push(text::caption(profile.description())),
profile,
Some(current_profile),
Message::PowerProfileChange,
)
.width(Length::Fill)
.into(),
])
})
.fold(section, settings::Section::add);
} else {

View file

@ -1,7 +1,7 @@
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: GPL-3.0-only
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_page::{self as page, Section, section};
use cosmic::widget::{editable_input, list_column, settings, text};
use cosmic::{Apply, Task};

View file

@ -5,13 +5,13 @@ use std::str::FromStr;
use chrono::{Datelike, Timelike};
use cosmic::{
Apply, Element, Task,
cosmic_config::{self, ConfigGet, ConfigSet},
iced_core::text::Wrapping,
surface,
widget::{self, dropdown, settings},
Apply, Element, Task,
};
use cosmic_settings_page::{self as page, section, Section};
use cosmic_settings_page::{self as page, Section, section};
use icu::{
calendar::{DateTime, Iso},
datetime::DateTimeFormatter,

View file

@ -9,18 +9,18 @@ use std::sync::Arc;
use cosmic::iced::{Alignment, Border, Color, Length};
use cosmic::iced_core::text::Wrapping;
use cosmic::widget::{self, button, container};
use cosmic::{theme, Apply, Element};
use cosmic::{Apply, Element, theme};
use cosmic_config::{ConfigGet, ConfigSet};
use cosmic_settings_page::Section;
use cosmic_settings_page::{self as page, section};
use eyre::Context;
use fixed_decimal::FixedDecimal;
use icu::calendar::DateTime;
use icu::datetime::DateTimeFormatter;
use icu::datetime::options::components::{self, Bag};
use icu::datetime::options::preferences;
use icu::datetime::DateTimeFormatter;
use icu::decimal::options::FixedDecimalFormatterOptions;
use icu::decimal::FixedDecimalFormatter;
use icu::decimal::options::FixedDecimalFormatterOptions;
use locales_rs as locale;
use slotmap::{DefaultKey, SlotMap};
@ -228,7 +228,7 @@ impl Page {
.await;
Message::Refresh(Arc::new(page_reload().await))
})
});
}
Message::Refresh(result) => match Arc::into_inner(result).unwrap() {
@ -588,8 +588,9 @@ mod preferred_languages {
use super::Message;
use cosmic::{
Apply,
iced::{Alignment, Length},
widget, Apply,
widget,
};
use cosmic_settings_page::Section;
@ -646,7 +647,7 @@ mod preferred_languages {
mod formatting {
use super::Message;
use cosmic::{widget, Apply};
use cosmic::{Apply, widget};
use cosmic_settings_page::Section;
pub fn section() -> Section<crate::pages::Message> {

View file

@ -3,8 +3,9 @@ use std::any::TypeId;
use ashpd::desktop::location::{Location, LocationProxy};
use chrono::Datelike;
use cosmic::iced::{
futures::{channel::mpsc::Sender, future, SinkExt, StreamExt},
stream, Subscription,
Subscription,
futures::{SinkExt, StreamExt, channel::mpsc::Sender, future},
stream,
};
use sunrise::sunrise_sunset;
use tokio::select;

View file

@ -1,11 +1,11 @@
use cosmic::{
iced::{stream, Subscription},
iced::{Subscription, stream},
iced_futures::futures::{self, SinkExt},
};
use notify::{Config, Event, RecommendedWatcher, RecursiveMode, Watcher};
use std::fmt::Debug;
use std::hash::Hash;
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver};
use tokio::sync::mpsc::{UnboundedReceiver, unbounded_channel};
#[derive(Debug)]
pub enum State {