This commit is contained in:
Ashley Wulber 2024-10-23 09:23:29 -04:00 committed by Ashley Wulber
parent 35717797b7
commit 88fbd8f96b
12 changed files with 741 additions and 742 deletions

1363
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -46,8 +46,7 @@ package = "smithay-client-toolkit"
# rev = "c583de8" # rev = "c583de8"
[profile.release] [profile.release]
opt-level = 1 lto = "thin"
# lto = "thin"
# [patch.'https://github.com/smithay/client-toolkit/'] # [patch.'https://github.com/smithay/client-toolkit/']
# smithay-client-toolkit = { git = "https://github.com/smithay/client-toolkit//", rev = "c583de8" } # smithay-client-toolkit = { git = "https://github.com/smithay/client-toolkit//", rev = "c583de8" }

View file

@ -52,7 +52,7 @@ pub struct SettingsApp {
} }
impl SettingsApp { impl SettingsApp {
fn subTask_to_page(&self, cmd: &PageCommands) -> Option<Entity> { fn subtask_to_page(&self, cmd: &PageCommands) -> Option<Entity> {
match cmd { match cmd {
PageCommands::About => self.pages.page_id::<system::about::Page>(), PageCommands::About => self.pages.page_id::<system::about::Page>(),
PageCommands::Appearance => self.pages.page_id::<desktop::appearance::Page>(), PageCommands::Appearance => self.pages.page_id::<desktop::appearance::Page>(),
@ -153,7 +153,7 @@ impl cosmic::Application for SettingsApp {
app.insert_page::<system::Page>(); app.insert_page::<system::Page>();
let active_id = match flags.sub_command { let active_id = match flags.sub_command {
Some(p) => app.subTask_to_page(&p), Some(p) => app.subtask_to_page(&p),
None => app None => app
.pages .pages
.find_page_by_id(&app.config.active_page) .find_page_by_id(&app.config.active_page)
@ -517,7 +517,7 @@ impl cosmic::Application for SettingsApp {
.map(Into::into), .map(Into::into),
); );
} }
return Command::batch(commands); return Task::batch(commands);
} }
Message::OutputRemoved(output) => { Message::OutputRemoved(output) => {
@ -537,7 +537,7 @@ impl cosmic::Application for SettingsApp {
.map(Into::into), .map(Into::into),
); );
} }
return Command::batch(commands); return Task::batch(commands);
} }
Message::PanelConfig(config) if config.name.to_lowercase().contains("panel") => { Message::PanelConfig(config) if config.name.to_lowercase().contains("panel") => {
@ -644,7 +644,7 @@ impl cosmic::Application for SettingsApp {
cosmic::app::DbusActivationDetails::ActivateAction { action, .. } => { cosmic::app::DbusActivationDetails::ActivateAction { action, .. } => {
PageCommands::from_str(&action) PageCommands::from_str(&action)
.ok() .ok()
.and_then(|action| self.subTask_to_page(&action)) .and_then(|action| self.subtask_to_page(&action))
.map(|e| self.activate_page(e)) .map(|e| self.activate_page(e))
} }
} }

View file

@ -92,7 +92,7 @@ pub async fn watch(
.receive_interfaces_removed() .receive_interfaces_removed()
.await?; .await?;
let (mut property_watcher, mut property_watcher_Task) = DevicePropertyWatcher::new(); let (mut property_watcher, mut property_watcher_task) = DevicePropertyWatcher::new();
for (path, interfaces) in managed_object_proxy.get_managed_objects().await? { for (path, interfaces) in managed_object_proxy.get_managed_objects().await? {
if interfaces.contains_key("org.bluez.Device1") if interfaces.contains_key("org.bluez.Device1")
@ -105,7 +105,7 @@ pub async fn watch(
while !property_watcher.rx.is_terminated() { while !property_watcher.rx.is_terminated() {
futures::select! { futures::select! {
Task = property_watcher.rx.next() => match Task { task = property_watcher.rx.next() => match task {
Some(DevicePropertyWatcherTask::Add(path)) => { Some(DevicePropertyWatcherTask::Add(path)) => {
property_watcher.insert(&connection, path).await?; property_watcher.insert(&connection, path).await?;
} }
@ -144,7 +144,7 @@ pub async fn watch(
Ok(device) => { Ok(device) => {
match bluetooth::Device::from_device(&device).await { match bluetooth::Device::from_device(&device).await {
Ok(device) => { Ok(device) => {
property_watcher_Task property_watcher_task
.send(DevicePropertyWatcherTask::Add(args.object_path.to_owned().into())).await.map_err(|e| zbus::Error::Failure(e.to_string()))?; .send(DevicePropertyWatcherTask::Add(args.object_path.to_owned().into())).await.map_err(|e| zbus::Error::Failure(e.to_string()))?;
tx tx
@ -170,7 +170,7 @@ pub async fn watch(
Some(signal) => { Some(signal) => {
let args = signal.args()?; let args = signal.args()?;
if args.interfaces.contains(&"org.bluez.Device1") { if args.interfaces.contains(&"org.bluez.Device1") {
property_watcher_Task.send(DevicePropertyWatcherTask::Removed( property_watcher_task.send(DevicePropertyWatcherTask::Removed(
args.object_path.to_owned().into(), args.object_path.to_owned().into(),
)).await.map_err(|e| zbus::Error::Failure(e.to_string()))?; )).await.map_err(|e| zbus::Error::Failure(e.to_string()))?;
tx tx

View file

@ -7,11 +7,10 @@ use std::sync::Arc;
use cosmic::{ use cosmic::{
config::{CosmicTk, FontConfig}, config::{CosmicTk, FontConfig},
iced::Length, iced::Length,
iced_core::text::Wrap, iced_core::text::Wrapping,
iced_style::svg::Appearance,
theme, theme,
widget::{self, settings}, widget::{self, settings, svg},
Apply, Command, Element, Apply, Element, Task,
}; };
use cosmic_config::ConfigSet; use cosmic_config::ConfigSet;
use ustr::Ustr; use ustr::Ustr;
@ -76,7 +75,7 @@ pub fn selection_context<'a>(
let svg_accent = Rc::new(|theme: &cosmic::Theme| { let svg_accent = Rc::new(|theme: &cosmic::Theme| {
let color = theme.cosmic().accent_color().into(); let color = theme.cosmic().accent_color().into();
Appearance { color: Some(color) } svg::Style { color: Some(color) }
}); });
let search_input = widget::search_input(fl!("type-to-search"), search) let search_input = widget::search_input(fl!("type-to-search"), search)
@ -87,22 +86,24 @@ pub fn selection_context<'a>(
let selected = &**family == current_font; let selected = &**family == current_font;
list.add( list.add(
settings::item_row(vec![ settings::item_row(vec![
widget::text::body(&**family).wrap(Wrap::Word).into(), widget::text::body(&**family)
widget::horizontal_space(Length::Fill).into(), .wrapping(Wrapping::Word)
.into(),
widget::horizontal_space().width(Length::Fill).into(),
if selected { if selected {
widget::icon::from_name("object-select-symbolic") widget::icon::from_name("object-select-symbolic")
.size(16) .size(16)
.icon() .icon()
.style(cosmic::theme::Svg::Custom(svg_accent.clone())) .class(cosmic::theme::Svg::Custom(svg_accent.clone()))
.into() .into()
} else { } else {
widget::horizontal_space(16).into() widget::horizontal_space().width(16).into()
}, },
]) ])
.apply(widget::container) .apply(widget::container)
.style(cosmic::theme::Container::List) .class(cosmic::theme::Container::List)
.apply(widget::button::custom) .apply(widget::button::custom)
.style(cosmic::theme::Button::Transparent) .class(cosmic::theme::Button::Transparent)
.on_press(super::Message::FontSelect(system, family.clone())), .on_press(super::Message::FontSelect(system, family.clone())),
) )
}); });
@ -148,7 +149,7 @@ impl Model {
} }
} }
pub fn update(&mut self, message: Message) -> Command<crate::app::Message> { pub fn update(&mut self, message: Message) -> Task<crate::app::Message> {
match message { match message {
Message::InterfaceFontFamily(id) => { Message::InterfaceFontFamily(id) => {
if let Some(family) = self.interface_font_families.get(id) { if let Some(family) = self.interface_font_families.get(id) {
@ -203,7 +204,7 @@ impl Model {
} }
} }
Command::none() Task::none()
} }
} }

View file

@ -6,7 +6,6 @@ use std::{collections::BTreeMap, path::PathBuf};
use super::Message; use super::Message;
use cosmic::{ use cosmic::{
iced::{Background, Length}, iced::{Background, Length},
prelude::CollectionWidget,
widget::{button, icon, text}, widget::{button, icon, text},
Element, Element,
}; };
@ -43,7 +42,7 @@ pub fn button(
.take(ICON_PREV_ROW) .take(ICON_PREV_ROW)
.cloned() .cloned()
// TODO: Maybe allow choosable sizes/zooming // TODO: Maybe allow choosable sizes/zooming
.map(|handle| handle.icon().size(ICON_THUMB_SIZE)), .map(|handle| handle.icon().size(ICON_THUMB_SIZE).into()),
) )
.spacing(theme.space_xxxs()) .spacing(theme.space_xxxs())
.into(), .into(),
@ -54,7 +53,7 @@ pub fn button(
.skip(ICON_PREV_ROW) .skip(ICON_PREV_ROW)
.cloned() .cloned()
// TODO: Maybe allow choosable sizes/zooming // TODO: Maybe allow choosable sizes/zooming
.map(|handle| handle.icon().size(ICON_THUMB_SIZE)), .map(|handle| handle.icon().size(ICON_THUMB_SIZE).into()),
) )
.spacing(theme.space_xxxs()) .spacing(theme.space_xxxs())
.into(), .into(),
@ -66,9 +65,9 @@ pub fn button(
.selected(selected) .selected(selected)
.padding([theme.space_xs(), theme.space_xs() + 1]) .padding([theme.space_xs(), theme.space_xs() + 1])
// Image button's style mostly works, but it needs a background to fit the design // Image button's style mostly works, but it needs a background to fit the design
.style(button::Style::Custom { .class(button::ButtonClass::Custom {
active: Box::new(move |focused, theme| { active: Box::new(move |focused, theme| {
let mut appearance = <cosmic::theme::Theme as button::StyleSheet>::active( let mut appearance = <cosmic::theme::Theme as button::Catalog>::active(
theme, theme,
focused, focused,
selected, selected,
@ -78,7 +77,7 @@ pub fn button(
appearance appearance
}), }),
disabled: Box::new(move |theme| { disabled: Box::new(move |theme| {
let mut appearance = <cosmic::theme::Theme as button::StyleSheet>::disabled( let mut appearance = <cosmic::theme::Theme as button::Catalog>::disabled(
theme, theme,
&cosmic::theme::Button::Image, &cosmic::theme::Button::Image,
); );
@ -86,7 +85,7 @@ pub fn button(
appearance appearance
}), }),
hovered: Box::new(move |focused, theme| { hovered: Box::new(move |focused, theme| {
let mut appearance = <cosmic::theme::Theme as button::StyleSheet>::hovered( let mut appearance = <cosmic::theme::Theme as button::Catalog>::hovered(
theme, theme,
focused, focused,
selected, selected,
@ -96,7 +95,7 @@ pub fn button(
appearance appearance
}), }),
pressed: Box::new(move |focused, theme| { pressed: Box::new(move |focused, theme| {
let mut appearance = <cosmic::theme::Theme as button::StyleSheet>::pressed( let mut appearance = <cosmic::theme::Theme as button::Catalog>::pressed(
theme, theme,
focused, focused,
selected, selected,

View file

@ -16,7 +16,7 @@ use cosmic::cosmic_theme::{
LIGHT_THEME_BUILDER_ID, LIGHT_THEME_BUILDER_ID,
}; };
use cosmic::iced_core::{alignment, Color, Length}; use cosmic::iced_core::{alignment, Color, Length};
use cosmic::iced_widget::scrollable; use cosmic::iced_widget::scrollable::{Direction, Scrollbar};
use cosmic::widget::icon::{from_name, icon}; use cosmic::widget::icon::{from_name, icon};
use cosmic::widget::{ use cosmic::widget::{
button, color_picker::ColorPickerUpdate, container, flex_row, horizontal_space, radio, row, button, color_picker::ColorPickerUpdate, container, flex_row, horizontal_space, radio, row,
@ -1407,11 +1407,11 @@ impl page::Page<crate::pages::Message> for Page {
_: page::Entity, _: page::Entity,
_sender: tokio::sync::mpsc::Sender<crate::pages::Message>, _sender: tokio::sync::mpsc::Sender<crate::pages::Message>,
) -> Task<crate::pages::Message> { ) -> Task<crate::pages::Message> {
task::batch(vec![ cosmic::command::batch(vec![
// Load icon themes // Load icon themes
task::future(icon_themes::fetch()).map(crate::pages::Message::Appearance), cosmic::command::future(icon_themes::fetch()).map(crate::pages::Message::Appearance),
// Load font families // Load font families
task::future(async move { cosmic::command::future(async move {
let (mono, interface) = font_config::load_font_families(); let (mono, interface) = font_config::load_font_families();
Message::FontConfig(font_config::Message::LoadedFonts(mono, interface)) Message::FontConfig(font_config::Message::LoadedFonts(mono, interface))
}) })
@ -1690,7 +1690,7 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
.padding([0, 0, 16, 0]) .padding([0, 0, 16, 0])
.spacing(16) .spacing(16)
) )
.direction(scrollable::Direction::Horizontal(Scrollbar::new())) .direction(Direction::Horizontal(Scrollbar::new()))
] ]
.padding([16, space_s, 0, space_s]) .padding([16, space_s, 0, space_s])
.spacing(space_xxs), .spacing(space_xxs),

View file

@ -13,9 +13,7 @@ use crate::{
app, app,
pages::{ pages::{
self, self,
desktop::panel::applets_inner::{ desktop::panel::applets_inner::{self, lists, AppletsPage, ContextDrawer},
self, lists, AppletsPage, ContextDrawer,
},
}, },
}; };

View file

@ -12,14 +12,9 @@ use cosmic_settings_page as page;
#[derive(Debug)] #[derive(Debug)]
#[allow(clippy::struct_excessive_bools)] #[allow(clippy::struct_excessive_bools)]
#[derive(Default)]
pub struct Page {} pub struct Page {}
impl Default for Page {
fn default() -> Self {
Self {}
}
}
impl page::Page<crate::pages::Message> for Page { impl page::Page<crate::pages::Message> for Page {
fn info(&self) -> page::Info { fn info(&self) -> page::Info {
page::Info::new("desktop", "video-display-symbolic").title(fl!("desktop")) page::Info::new("desktop", "video-display-symbolic").title(fl!("desktop"))

View file

@ -242,23 +242,15 @@ pub fn window_controls() -> Section<crate::pages::Message> {
.title(&section.title) .title(&section.title)
.add(settings::item( .add(settings::item(
&descriptions[active_window_hint], &descriptions[active_window_hint],
toggler(None, page.show_active_hint, Message::ShowActiveWindowHint), toggler(page.show_active_hint).on_toggle(Message::ShowActiveWindowHint),
)) ))
.add(settings::item( .add(settings::item(
&descriptions[maximize], &descriptions[maximize],
toggler( toggler(cosmic::config::show_maximize()).on_toggle(Message::ShowMaximizeButton),
None,
cosmic::config::show_maximize(),
Message::ShowMaximizeButton,
),
)) ))
.add(settings::item( .add(settings::item(
&descriptions[minimize], &descriptions[minimize],
toggler( toggler(cosmic::config::show_minimize()).on_toggle(Message::ShowMinimizeButton),
None,
cosmic::config::show_minimize(),
Message::ShowMinimizeButton,
),
)) ))
.apply(Element::from) .apply(Element::from)
.map(crate::pages::Message::WindowManagement) .map(crate::pages::Message::WindowManagement)

View file

@ -508,12 +508,10 @@ impl Page {
.on_input(Message::InputSourceSearch) .on_input(Message::InputSourceSearch)
.on_clear(Message::InputSourceSearch(String::new())); .on_clear(Message::InputSourceSearch(String::new()));
let toggler = settings::item::builder(fl!("show-extended-input-sources")) let toggler = settings::item::builder(fl!("show-extended-input-sources")).toggler(
.toggler( self.show_extended_input_sources,
self.show_extended_input_sources, Message::SetShowExtendedInputSources,
Message::SetShowExtendedInputSources, );
)
.label(fl!("show-extended-input-sources"));
let mut list = widget::list_column(); let mut list = widget::list_column();

View file

@ -147,7 +147,7 @@ pub fn page_list_item<'a, Message: 'static + Clone>(
row::with_capacity(2) row::with_capacity(2)
.push(text::body(info)) .push(text::body(info))
.push(container(icon::from_name("go-next-symbolic").size(20)).padding(8)) .push(container(icon::from_name("go-next-symbolic").size(20)).padding(8))
.align_items(alignment::Alignment::Center), .align_y(alignment::Alignment::Center),
) )
.padding(0) .padding(0)
.spacing(space_xxs) .spacing(space_xxs)
@ -206,19 +206,19 @@ pub fn go_next_with_item<'a, Msg: Clone + 'static>(
msg: Msg, msg: Msg,
) -> cosmic::Element<'_, Msg> { ) -> cosmic::Element<'_, Msg> {
settings::item_row(vec![ settings::item_row(vec![
text::body(description).wrap(Wrap::Word).into(), text::body(description).wrapping(Wrapping::Word).into(),
horizontal_space(Length::Fill).into(), horizontal_space().width(Length::Fill).into(),
widget::row::with_capacity(2) widget::row::with_capacity(2)
.push(item) .push(item)
.push(icon::from_name("go-next-symbolic").size(16).icon()) .push(icon::from_name("go-next-symbolic").size(16).icon())
.align_items(alignment::Alignment::Center) .align_y(alignment::Alignment::Center)
.spacing(cosmic::theme::active().cosmic().spacing.space_s) .spacing(cosmic::theme::active().cosmic().spacing.space_s)
.into(), .into(),
]) ])
.apply(widget::container) .apply(widget::container)
.style(cosmic::theme::Container::List) .class(cosmic::theme::Container::List)
.apply(button::custom) .apply(button::custom)
.style(theme::Button::Transparent) .class(theme::Button::Transparent)
.on_press(msg) .on_press(msg)
.into() .into()
} }