diff --git a/src/applet/mod.rs b/src/applet/mod.rs index 6cbc129e..fc3a9cf2 100644 --- a/src/applet/mod.rs +++ b/src/applet/mod.rs @@ -197,7 +197,7 @@ impl Context { } let symbolic = icon.symbolic; - crate::widget::button( + crate::widget::button::custom( layer_container( widget::icon(icon) .style(if symbolic { @@ -417,7 +417,7 @@ pub fn style() -> ::Style { pub fn menu_button<'a, Message>( content: impl Into>, ) -> crate::widget::Button<'a, Message> { - crate::widget::button(content) + crate::widget::button::custom(content) .style(Button::AppletMenu) .padding(menu_control_padding()) .width(Length::Fill) diff --git a/src/keyboard_nav.rs b/src/keyboard_nav.rs index 95657e40..ae4c0f9d 100644 --- a/src/keyboard_nav.rs +++ b/src/keyboard_nav.rs @@ -3,12 +3,8 @@ //! Subscribe to common application keyboard shortcuts. -use iced::{event, keyboard, mouse, Command, Event, Subscription}; -use iced_core::{ - keyboard::key::Named, - widget::{operation, Id, Operation}, - Rectangle, -}; +use iced::{event, keyboard, Event, Subscription}; +use iced_core::keyboard::key::Named; use iced_futures::event::listen_raw; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] diff --git a/src/widget/button/icon.rs b/src/widget/button/icon.rs index bef314ef..aa3c2bec 100644 --- a/src/widget/button/icon.rs +++ b/src/widget/button/icon.rs @@ -1,7 +1,7 @@ // Copyright 2023 System76 // SPDX-License-Identifier: MPL-2.0 -use super::{button, Builder, Style}; +use super::{Builder, Style}; use crate::widget::{ icon::{self, Handle}, tooltip, @@ -159,7 +159,7 @@ impl<'a, Message: Clone + 'static> From> for Element<'a, Mes .padding(builder.padding) .spacing(builder.spacing) .align_items(Alignment::Center) - .apply(button) + .apply(super::custom) } else { crate::widget::row::with_children(content) .padding(builder.padding) @@ -167,7 +167,7 @@ impl<'a, Message: Clone + 'static> From> for Element<'a, Mes .height(builder.height) .spacing(builder.spacing) .align_items(Alignment::Center) - .apply(button) + .apply(super::custom) }; let button = button diff --git a/src/widget/button/link.rs b/src/widget/button/link.rs index 52cc44b1..3128ca7e 100644 --- a/src/widget/button/link.rs +++ b/src/widget/button/link.rs @@ -82,7 +82,7 @@ impl<'a, Message: Clone + 'static> From> for Element<'a, Mes .height(builder.height) .spacing(builder.spacing) .align_items(Alignment::Center) - .apply(button) + .apply(button::custom) .padding(0) .id(builder.id) .on_press_maybe(builder.on_press.take()) diff --git a/src/widget/button/mod.rs b/src/widget/button/mod.rs index c9cf555a..4a83b12e 100644 --- a/src/widget/button/mod.rs +++ b/src/widget/button/mod.rs @@ -43,8 +43,8 @@ use iced_core::widget::Id; use iced_core::{Length, Padding}; use std::borrow::Cow; -/// A button with the default style, which may contain any widget as its content. -pub fn button<'a, Message>(content: impl Into>) -> Button<'a, Message> { +/// A button with a custom element for its content. +pub fn custom<'a, Message>(content: impl Into>) -> Button<'a, Message> { Button::new(content) } diff --git a/src/widget/button/text.rs b/src/widget/button/text.rs index a30dfedb..b5dccc84 100644 --- a/src/widget/button/text.rs +++ b/src/widget/button/text.rs @@ -1,7 +1,7 @@ // Copyright 2023 System76 // SPDX-License-Identifier: MPL-2.0 -use super::{button, Builder, Style}; +use super::{Builder, Style}; use crate::widget::{icon, row, tooltip}; use crate::{ext::CollectionWidget, Element}; use apply::Apply; @@ -124,7 +124,7 @@ impl<'a, Message: Clone + 'static> From> for Element<'a, Mes .height(builder.height) .spacing(builder.spacing) .align_items(Alignment::Center) - .apply(button) + .apply(super::custom) .padding(0) .id(builder.id) .on_press_maybe(builder.on_press.take()) diff --git a/src/widget/calendar.rs b/src/widget/calendar.rs index 38dfc6b7..f86841a9 100644 --- a/src/widget/calendar.rs +++ b/src/widget/calendar.rs @@ -143,7 +143,7 @@ fn date_button( button::Style::Text }; - let button = button( + let button = button::custom( text(format!("{}", date.day())) .horizontal_alignment(Horizontal::Center) .vertical_alignment(Vertical::Center), diff --git a/src/widget/color_picker/mod.rs b/src/widget/color_picker/mod.rs index 0da50c15..d7f42adf 100644 --- a/src/widget/color_picker/mod.rs +++ b/src/widget/color_picker/mod.rs @@ -369,7 +369,7 @@ where ) // TODO copy paste input contents .trailing_icon({ - let button = button(crate::widget::icon( + let button = button::custom(crate::widget::icon( from_name("edit-copy-symbolic").size(spacing.space_s).into(), )) .on_press(on_update(ColorPickerUpdate::Copied(Instant::now()))) @@ -442,7 +442,7 @@ where inner = inner.push( column![ horizontal::light().width(self.width), - button( + button::custom( text(reset_to_default) .width(self.width) .horizontal_alignment(iced_core::alignment::Horizontal::Center) @@ -458,14 +458,14 @@ where inner = inner.push( column![ horizontal::light().width(self.width), - button( + button::custom( text(cancel) .width(self.width) .horizontal_alignment(iced_core::alignment::Horizontal::Center) ) .width(self.width) .on_press(on_update(ColorPickerUpdate::Cancel)), - button( + button::custom( text(save) .width(self.width) .horizontal_alignment(iced_core::alignment::Horizontal::Center) @@ -781,7 +781,7 @@ pub fn color_button<'a, Message: 'static>( ) -> crate::widget::Button<'a, Message> { let spacing = THEME.lock().unwrap().cosmic().spacing; - button(if color.is_some() { + button::custom(if color.is_some() { Element::from(vertical_space(Length::Fixed(f32::from(spacing.space_s)))) } else { Element::from(column![ diff --git a/src/widget/menu/menu_tree.rs b/src/widget/menu/menu_tree.rs index 97590c57..f1aab351 100644 --- a/src/widget/menu/menu_tree.rs +++ b/src/widget/menu/menu_tree.rs @@ -143,7 +143,7 @@ where pub fn menu_button<'a, Message: 'a>( children: Vec>, ) -> crate::widget::Button<'a, Message> { - widget::button( + widget::button::custom( widget::Row::with_children(children) .align_items(Alignment::Center) .height(Length::Fill) @@ -192,7 +192,7 @@ pub fn menu_root<'a, Message, Renderer: renderer::Renderer>( where Element<'a, Message, crate::Theme, Renderer>: From>, { - widget::button(widget::text(label)) + widget::button::custom(widget::text(label)) .padding([4, 12]) .style(theme::Button::MenuRoot) .into() diff --git a/src/widget/mod.rs b/src/widget/mod.rs index 7ef318f8..60bfcc3d 100644 --- a/src/widget/mod.rs +++ b/src/widget/mod.rs @@ -96,7 +96,7 @@ pub mod aspect_ratio; pub mod button; #[doc(inline)] -pub use button::{button, Button, IconButton, LinkButton, TextButton}; +pub use button::{Button, IconButton, LinkButton, TextButton}; pub(crate) mod common; diff --git a/src/widget/nav_bar_toggle.rs b/src/widget/nav_bar_toggle.rs index 8b3dfa3c..06c7abd1 100644 --- a/src/widget/nav_bar_toggle.rs +++ b/src/widget/nav_bar_toggle.rs @@ -4,9 +4,7 @@ //! A button for toggling the navigation side panel. use crate::{widget, Element}; -use apply::Apply; use derive_setters::Setters; -use iced::Length; #[derive(Setters)] pub struct NavBarToggle { diff --git a/src/widget/settings/item.rs b/src/widget/settings/item.rs index 723d53a5..fe86d95e 100644 --- a/src/widget/settings/item.rs +++ b/src/widget/settings/item.rs @@ -8,7 +8,6 @@ use crate::{ Element, }; use derive_setters::Setters; -use iced::alignment::Horizontal; use iced_core::{text::Wrap, Length}; use taffy::AlignContent; diff --git a/src/widget/spin_button/mod.rs b/src/widget/spin_button/mod.rs index 4aa07670..d0fbbca2 100644 --- a/src/widget/spin_button/mod.rs +++ b/src/widget/spin_button/mod.rs @@ -53,7 +53,7 @@ impl<'a, Message: 'static> SpinButton<'a, Message> { .height(Length::Fixed(32.0)) .align_x(Horizontal::Center) .align_y(Vertical::Center) - .apply(button) + .apply(button::custom) .width(Length::Fixed(32.0)) .height(Length::Fixed(32.0)) .style(theme::Button::Text) @@ -73,7 +73,7 @@ impl<'a, Message: 'static> SpinButton<'a, Message> { .height(Length::Fixed(32.0)) .align_x(Horizontal::Center) .align_y(Vertical::Center) - .apply(button) + .apply(button::custom) .width(Length::Fixed(32.0)) .height(Length::Fixed(32.0)) .style(theme::Button::Text) diff --git a/src/widget/text_input/input.rs b/src/widget/text_input/input.rs index 570a791a..eaf633a4 100644 --- a/src/widget/text_input/input.rs +++ b/src/widget/text_input/input.rs @@ -145,7 +145,7 @@ where "image-red-eye-symbolic" }) .size(16) - .apply(crate::widget::button) + .apply(crate::widget::button::custom) .style(crate::theme::Button::Icon) .on_press(msg) .padding([spacing, spacing, spacing, spacing]) @@ -501,7 +501,7 @@ where self.trailing_icon( crate::widget::icon::from_name("edit-clear-symbolic") .size(16) - .apply(crate::widget::button) + .apply(crate::widget::button::custom) .style(crate::theme::Button::Icon) .width(32) .height(32) diff --git a/src/widget/toaster/mod.rs b/src/widget/toaster/mod.rs index 7a9cea78..481d799f 100644 --- a/src/widget/toaster/mod.rs +++ b/src/widget/toaster/mod.rs @@ -80,6 +80,7 @@ pub enum Duration { } impl Duration { + #[cfg(feature = "tokio")] fn duration(&self) -> std::time::Duration { match self { Duration::Short => std::time::Duration::from_millis(5000), @@ -183,7 +184,9 @@ impl Toasts { ); } + #[cfg(feature = "tokio")] let duration = toast.duration.duration(); + let id = self.toasts.insert(toast); self.queue.push_back(id);