diff --git a/examples/about/src/main.rs b/examples/about/src/main.rs index 0625e15..5450b47 100644 --- a/examples/about/src/main.rs +++ b/examples/about/src/main.rs @@ -61,7 +61,7 @@ impl cosmic::Application for App { &mut self.core } - /// Creates the application, and optionally emits command on initialize. + /// Creates the application, and optionally emits task on initialize. fn init(core: Core, _flags: Self::Flags) -> (Self, Task) { let nav_model = nav_bar::Model::default(); diff --git a/examples/application/src/main.rs b/examples/application/src/main.rs index bf2b5a5..a77b9d7 100644 --- a/examples/application/src/main.rs +++ b/examples/application/src/main.rs @@ -89,7 +89,7 @@ impl cosmic::Application for App { &mut self.core } - /// Creates the application, and optionally emits command on initialize. + /// Creates the application, and optionally emits task on initialize. fn init(core: Core, input: Self::Flags) -> (Self, Task) { let mut nav_model = nav_bar::Model::default(); diff --git a/examples/calendar/src/main.rs b/examples/calendar/src/main.rs index 5306d92..bfad551 100644 --- a/examples/calendar/src/main.rs +++ b/examples/calendar/src/main.rs @@ -49,7 +49,7 @@ impl cosmic::Application for App { &mut self.core } - /// Creates the application, and optionally emits command on initialize. + /// Creates the application, and optionally emits task on initialize. fn init(core: Core, _input: Self::Flags) -> (Self, Task) { let now = Local::now(); diff --git a/examples/context-menu/src/main.rs b/examples/context-menu/src/main.rs index 5ade496..840cf86 100644 --- a/examples/context-menu/src/main.rs +++ b/examples/context-menu/src/main.rs @@ -64,7 +64,7 @@ impl cosmic::Application for App { &mut self.core } - /// Creates the application, and optionally emits command on initialize. + /// Creates the application, and optionally emits task on initialize. fn init(core: Core, _input: Self::Flags) -> (Self, Task) { let mut app = App { core, diff --git a/examples/image-button/src/main.rs b/examples/image-button/src/main.rs index 406f0d1..34d907e 100644 --- a/examples/image-button/src/main.rs +++ b/examples/image-button/src/main.rs @@ -50,7 +50,7 @@ impl cosmic::Application for App { &mut self.core } - /// Creates the application, and optionally emits command on initialize. + /// Creates the application, and optionally emits task on initialize. fn init(core: Core, _input: Self::Flags) -> (Self, Task) { let mut app = App { core, diff --git a/examples/menu/src/main.rs b/examples/menu/src/main.rs index 1b564a1..5b65732 100644 --- a/examples/menu/src/main.rs +++ b/examples/menu/src/main.rs @@ -96,7 +96,7 @@ impl cosmic::Application for App { &mut self.core } - /// Creates the application, and optionally emits command on initialize. + /// Creates the application, and optionally emits task on initialize. fn init(core: Core, _input: Self::Flags) -> (Self, Task) { let app = App { core, diff --git a/examples/nav-context/src/main.rs b/examples/nav-context/src/main.rs index 2285292..58e2084 100644 --- a/examples/nav-context/src/main.rs +++ b/examples/nav-context/src/main.rs @@ -105,7 +105,7 @@ impl cosmic::Application for App { &mut self.core } - /// Creates the application, and optionally emits command on initialize. + /// Creates the application, and optionally emits task on initialize. fn init(core: Core, input: Self::Flags) -> (Self, Task) { let mut nav_model = nav_bar::Model::default(); diff --git a/examples/open-dialog/src/main.rs b/examples/open-dialog/src/main.rs index a195888..5ae2df4 100644 --- a/examples/open-dialog/src/main.rs +++ b/examples/open-dialog/src/main.rs @@ -65,7 +65,7 @@ impl cosmic::Application for App { &mut self.core } - /// Creates the application, and optionally emits command on initialize. + /// Creates the application, and optionally emits task on initialize. fn init(core: Core, _input: Self::Flags) -> (Self, Task) { let id = core.main_window_id().unwrap(); let mut app = App { @@ -109,7 +109,7 @@ impl cosmic::Application for App { self.set_header_title(url.to_string()); // Reads the selected file into memory. - return cosmic::command::future(async move { + return cosmic::task::future(async move { // Check if its a valid local file path. let path = match url.scheme() { "file" => url.to_file_path().unwrap(), @@ -145,7 +145,7 @@ impl cosmic::Application for App { // Creates a new open dialog. Message::OpenFile => { - return cosmic::command::future(async move { + return cosmic::task::future(async move { eprintln!("opening new dialog"); #[cfg(feature = "rfd")] diff --git a/examples/text-input/src/main.rs b/examples/text-input/src/main.rs index de6bbd9..573b9dc 100644 --- a/examples/text-input/src/main.rs +++ b/examples/text-input/src/main.rs @@ -54,7 +54,7 @@ impl cosmic::Application for App { &mut self.core } - /// Creates the application, and optionally emits command on initialize. + /// Creates the application, and optionally emits task on initialize. fn init(core: Core, _input: Self::Flags) -> (Self, Task) { let mut app = App { core, diff --git a/src/app/command.rs b/src/app/command.rs index ff51a7d..b39118f 100644 --- a/src/app/command.rs +++ b/src/app/command.rs @@ -9,19 +9,19 @@ use super::Message; /// Commands for COSMIC applications. pub type Task = iced::Task>; -/// Creates a command which yields a [`crate::app::Message`]. +/// Creates a task which yields a [`crate::app::Message`]. pub fn message(message: Message) -> Task { - crate::command::message(message) + crate::task::message(message) } /// Convenience methods for building message-based commands. pub mod message { - /// Creates a command which yields an application message. + /// Creates a task which yields an application message. pub fn app(message: M) -> crate::app::Task { super::message(super::Message::App(message)) } - /// Creates a command which yields a cosmic message. + /// Creates a task which yields a cosmic message. pub fn cosmic(message: crate::app::cosmic::Message) -> crate::app::Task { super::message(super::Message::Cosmic(message)) } @@ -32,7 +32,7 @@ impl crate::app::Core { let Some(id) = id.or(self.main_window) else { return iced::Task::none(); }; - crate::command::drag(id).map(Message::Cosmic) + crate::task::drag(id).map(Message::Cosmic) } pub fn maximize( @@ -43,14 +43,14 @@ impl crate::app::Core { let Some(id) = id.or(self.main_window) else { return iced::Task::none(); }; - crate::command::maximize(id, maximized).map(Message::Cosmic) + crate::task::maximize(id, maximized).map(Message::Cosmic) } pub fn minimize(&self, id: Option) -> iced::Task> { let Some(id) = id.or(self.main_window) else { return iced::Task::none(); }; - crate::command::minimize(id).map(Message::Cosmic) + crate::task::minimize(id).map(Message::Cosmic) } pub fn set_scaling_factor(&self, factor: f32) -> iced::Task> { @@ -65,7 +65,7 @@ impl crate::app::Core { let Some(id) = id.or(self.main_window) else { return iced::Task::none(); }; - crate::command::set_title(id, title).map(Message::Cosmic) + crate::task::set_title(id, title).map(Message::Cosmic) } pub fn set_windowed( @@ -75,7 +75,7 @@ impl crate::app::Core { let Some(id) = id.or(self.main_window) else { return iced::Task::none(); }; - crate::command::set_windowed(id).map(Message::Cosmic) + crate::task::set_windowed(id).map(Message::Cosmic) } pub fn toggle_maximize( @@ -85,7 +85,7 @@ impl crate::app::Core { let Some(id) = id.or(self.main_window) else { return iced::Task::none(); }; - crate::command::toggle_maximize(id).map(Message::Cosmic) + crate::task::toggle_maximize(id).map(Message::Cosmic) } } diff --git a/src/app/mod.rs b/src/app/mod.rs index 88dee95..eb53a67 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -452,7 +452,7 @@ where /// Grants access to the COSMIC Core. fn core_mut(&mut self) -> &mut Core; - /// Creates the application, and optionally emits command on initialize. + /// Creates the application, and optionally emits task on initialize. fn init(core: Core, flags: Self::Flags) -> (Self, Task); /// Displays a context drawer on the side of the application window when `Some`. diff --git a/src/dialog/file_chooser/mod.rs b/src/dialog/file_chooser/mod.rs index 0f328e3..186f762 100644 --- a/src/dialog/file_chooser/mod.rs +++ b/src/dialog/file_chooser/mod.rs @@ -11,7 +11,7 @@ //! # Open a file //! //! ```no_run -//! cosmic::command::future(async { +//! cosmic::task::future(async { //! use cosmic::dialog::file_chooser; //! //! let dialog = file_chooser::open::Dialog::new() @@ -30,7 +30,7 @@ //! # Open multiple files //! //! ```no_run -//! cosmic::command::future(async { +//! cosmic::task::future(async { //! use cosmic::dialog::file_chooser; //! //! let dialog = file_chooser::open::Dialog::new() @@ -49,7 +49,7 @@ //! # Open a folder //! //! ```no_run -//! cosmic::command::future(async { +//! cosmic::task::future(async { //! use cosmic::dialog::file_chooser; //! //! let dialog = file_chooser::open::Dialog::new() @@ -68,7 +68,7 @@ //! # Open multiple folders //! //! ```no_run -//! cosmic::command::future(async { +//! cosmic::task::future(async { //! use cosmic::dialog::file_chooser; //! //! let dialog = file_chooser::open::Dialog::new() diff --git a/src/lib.rs b/src/lib.rs index fc8758c..cc39614 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,8 +22,8 @@ pub use app::{Application, ApplicationExt}; #[cfg(feature = "applet")] pub mod applet; -pub use iced::Task; -pub mod command; +pub use app::Task; +pub mod task; pub mod config; diff --git a/src/command/mod.rs b/src/task/mod.rs similarity index 84% rename from src/command/mod.rs rename to src/task/mod.rs index 2a509bc..379ea19 100644 --- a/src/command/mod.rs +++ b/src/task/mod.rs @@ -9,19 +9,19 @@ use iced_core::window::Mode; use iced_runtime::{task, Action}; use std::future::Future; -/// Yields a command which contains a batch of commands. +/// Yields a task which contains a batch of tasks. pub fn batch, Y: Send + 'static>( - commands: impl IntoIterator>, + tasks: impl IntoIterator>, ) -> Task { - Task::batch(commands).map(Into::into) + Task::batch(tasks).map(Into::into) } -/// Yields a command which will run the future on the runtime executor. +/// Yields a task which will run the future on the runtime executor. pub fn future, Y: 'static>(future: impl Future + Send + 'static) -> Task { Task::future(async move { future.await.into() }) } -/// Yields a command which will return a message. +/// Yields a task which will return a message. pub fn message, Y: 'static>(message: X) -> Task { future(async move { message.into() }) } diff --git a/src/widget/toaster/mod.rs b/src/widget/toaster/mod.rs index 7f7634c..2ed8289 100644 --- a/src/widget/toaster/mod.rs +++ b/src/widget/toaster/mod.rs @@ -193,7 +193,7 @@ impl Toasts { #[cfg(feature = "tokio")] { let on_close = self.on_close; - crate::command::future(async move { + crate::task::future(async move { tokio::time::sleep(duration).await; on_close(id) })