From 05c66088422b7a03e54ac1f96ff50339cc7776cf Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Fri, 5 Dec 2025 17:59:42 +0100 Subject: [PATCH] examples: fix libcosmic features, warnings, etc. --- examples/about/Cargo.toml | 3 --- examples/application/Cargo.toml | 3 --- examples/calendar/Cargo.toml | 1 - examples/calendar/src/main.rs | 5 ++++- examples/config/src/main.rs | 2 +- examples/context-menu/Cargo.toml | 3 +-- examples/context-menu/src/main.rs | 4 +--- examples/image-button/Cargo.toml | 3 +-- examples/image-button/src/main.rs | 7 +++++-- examples/menu/Cargo.toml | 3 +-- examples/menu/src/main.rs | 4 ++-- examples/multi-window/Cargo.toml | 2 +- examples/multi-window/src/window.rs | 12 ++++++------ examples/nav-context/Cargo.toml | 3 +-- examples/nav-context/src/main.rs | 2 +- examples/open-dialog/Cargo.toml | 3 +-- examples/open-dialog/src/main.rs | 10 +++++++--- examples/spin-button/Cargo.toml | 2 +- examples/spin-button/src/main.rs | 2 +- examples/table-view/Cargo.toml | 3 +-- examples/table-view/src/main.rs | 2 +- examples/text-input/Cargo.toml | 3 +-- examples/text-input/src/main.rs | 4 ++-- 23 files changed, 40 insertions(+), 46 deletions(-) diff --git a/examples/about/Cargo.toml b/examples/about/Cargo.toml index 0f598535..d2642cd6 100644 --- a/examples/about/Cargo.toml +++ b/examples/about/Cargo.toml @@ -8,18 +8,15 @@ open = "5.3.2" [dependencies.libcosmic] path = "../../" -default-features = false features = [ "debug", "winit", "tokio", "xdg-portal", - "dbus-config", "desktop", "a11y", "wayland", "wgpu", "single-instance", - "multi-window", "about", ] diff --git a/examples/application/Cargo.toml b/examples/application/Cargo.toml index e5ae2f30..28c13117 100644 --- a/examples/application/Cargo.toml +++ b/examples/application/Cargo.toml @@ -14,16 +14,13 @@ tracing-log = "0.2.0" [dependencies.libcosmic] path = "../../" -default-features = false features = [ "debug", "winit", "tokio", "xdg-portal", - "dbus-config", "a11y", "wgpu", "single-instance", - "multi-window", "surface-message", ] diff --git a/examples/calendar/Cargo.toml b/examples/calendar/Cargo.toml index 18bc6b49..9ffb838c 100644 --- a/examples/calendar/Cargo.toml +++ b/examples/calendar/Cargo.toml @@ -10,5 +10,4 @@ chrono = "0.4.40" [dependencies.libcosmic] path = "../../" -default-features = false features = ["debug", "winit", "tokio", "xdg-portal", "wgpu"] diff --git a/examples/calendar/src/main.rs b/examples/calendar/src/main.rs index fec7b543..589bc1ff 100644 --- a/examples/calendar/src/main.rs +++ b/examples/calendar/src/main.rs @@ -113,6 +113,9 @@ where { fn update_title(&mut self) -> cosmic::app::Task { self.set_header_title(String::from("Calendar Demo")); - self.set_window_title(String::from("Calendar Demo")) + self.set_window_title( + String::from("Calendar Demo"), + self.core.main_window_id().unwrap(), + ) } } diff --git a/examples/config/src/main.rs b/examples/config/src/main.rs index f606e15c..f6fb5c0d 100644 --- a/examples/config/src/main.rs +++ b/examples/config/src/main.rs @@ -4,7 +4,7 @@ use cosmic_config::{Config, ConfigGet, ConfigSet}; fn test_config(config: Config) { - let watcher = config + let _watcher = config .watch(|config, keys| { println!("Changed: {:?}", keys); for key in keys.iter() { diff --git a/examples/context-menu/Cargo.toml b/examples/context-menu/Cargo.toml index 9a24a1c8..45cbf78a 100644 --- a/examples/context-menu/Cargo.toml +++ b/examples/context-menu/Cargo.toml @@ -10,13 +10,12 @@ tracing-log = "0.2.0" [dependencies.libcosmic] path = "../../" -default-features = false features = [ "debug", "winit", + "wgpu", "tokio", "xdg-portal", - "multi-window", "surface-message", "wayland", ] diff --git a/examples/context-menu/src/main.rs b/examples/context-menu/src/main.rs index c744f963..db66ba1b 100644 --- a/examples/context-menu/src/main.rs +++ b/examples/context-menu/src/main.rs @@ -37,7 +37,6 @@ pub enum Message { pub struct App { core: Core, button_label: String, - show_context: bool, hide_content: bool, } @@ -69,7 +68,6 @@ impl cosmic::Application for App { core, button_label: String::from("Right click me"), hide_content: false, - show_context: false, }; app.set_header_title("COSMIC Context Menu Demo".into()); @@ -102,7 +100,7 @@ impl cosmic::Application for App { } /// Creates a view after each update. - fn view(&self) -> Element { + fn view(&self) -> Element<'_, Self::Message> { let widget = cosmic::widget::context_menu( cosmic::widget::button::text(self.button_label.to_string()).on_press(Message::Clicked), self.context_menu(), diff --git a/examples/image-button/Cargo.toml b/examples/image-button/Cargo.toml index 110be619..cf61955a 100644 --- a/examples/image-button/Cargo.toml +++ b/examples/image-button/Cargo.toml @@ -9,5 +9,4 @@ tracing-subscriber = "0.3.19" [dependencies.libcosmic] path = "../../" -default-features = false -features = ["debug", "winit", "tokio"] +features = ["debug", "winit", "wgpu", "tokio"] diff --git a/examples/image-button/src/main.rs b/examples/image-button/src/main.rs index 34d907e7..0ac906ca 100644 --- a/examples/image-button/src/main.rs +++ b/examples/image-button/src/main.rs @@ -79,7 +79,7 @@ impl cosmic::Application for App { } /// Creates a view after each update. - fn view(&self) -> Element { + fn view(&self) -> Element<'_, Self::Message> { let mut content = cosmic::widget::column().spacing(12); for (id, image) in self.images.iter().enumerate() { @@ -108,6 +108,9 @@ where { fn update_title(&mut self) -> Task { self.set_header_title(String::from("Image Button Demo")); - self.set_window_title(String::from("Image Button Demo")) + self.set_window_title( + String::from("Image Button Demo"), + self.core.main_window_id().unwrap(), + ) } } diff --git a/examples/menu/Cargo.toml b/examples/menu/Cargo.toml index c83a216d..dcab1ef5 100644 --- a/examples/menu/Cargo.toml +++ b/examples/menu/Cargo.toml @@ -10,5 +10,4 @@ tracing-log = "0.2.0" [dependencies.libcosmic] path = "../../" -default-features = false -features = ["debug", "winit", "tokio", "xdg-portal", "multi-window"] +features = ["debug", "winit", "tokio", "xdg-portal", "wgpu"] diff --git a/examples/menu/src/main.rs b/examples/menu/src/main.rs index 7037a62c..8b5a1cb7 100644 --- a/examples/menu/src/main.rs +++ b/examples/menu/src/main.rs @@ -110,7 +110,7 @@ impl cosmic::Application for App { (app, Task::none()) } - fn header_start(&self) -> Vec> { + fn header_start(&self) -> Vec> { vec![menu_bar(&self.config, &self.key_binds)] } @@ -137,7 +137,7 @@ impl cosmic::Application for App { } /// Creates a view after each update. - fn view(&self) -> Element { + fn view(&self) -> Element<'_, Self::Message> { let text = if self.config.hide_content { cosmic::widget::text("") } else { diff --git a/examples/multi-window/Cargo.toml b/examples/multi-window/Cargo.toml index 168bd4ec..0b5440f8 100644 --- a/examples/multi-window/Cargo.toml +++ b/examples/multi-window/Cargo.toml @@ -6,4 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -libcosmic = { path = "../..", features = ["debug", "winit", "tokio", "single-instance", "multi-window", "dbus-config", "wgpu", "wayland"] } +libcosmic = { path = "../..", features = ["debug", "winit", "tokio", "single-instance", "wgpu", "wayland"] } diff --git a/examples/multi-window/src/window.rs b/examples/multi-window/src/window.rs index 96d166d4..74ab5386 100644 --- a/examples/multi-window/src/window.rs +++ b/examples/multi-window/src/window.rs @@ -2,11 +2,11 @@ use std::collections::HashMap; use cosmic::{ app::Core, - iced::{self, event, window}, + iced::{self, event, window, Subscription}, iced_core::{id, Alignment, Length, Point}, iced_widget::{column, container, scrollable, text}, + prelude::*, widget::{button, header_bar}, - ApplicationExt, Task, }; #[derive(Debug, Clone, PartialEq)] @@ -57,7 +57,7 @@ impl cosmic::Application for MultiWindow { (windows, cosmic::app::Task::none()) } - fn subscription(&self) -> cosmic::iced_futures::Subscription { + fn subscription(&self) -> Subscription { event::listen_with(|event, _, id| { if let iced::Event::Window(window_event) = event { match window_event { @@ -74,7 +74,7 @@ impl cosmic::Application for MultiWindow { }) } - fn update(&mut self, message: Self::Message) -> iced::Task> { + fn update(&mut self, message: Self::Message) -> Task> { match message { Message::CloseWindow(id) => window::close(id), Message::WindowClosed(id) => { @@ -119,7 +119,7 @@ impl cosmic::Application for MultiWindow { } } - fn view_window(&self, id: window::Id) -> cosmic::prelude::Element { + fn view_window(&self, id: window::Id) -> Element<'_, Self::Message> { let w = self.windows.get(&id).unwrap(); let input_id = w.input_id.clone(); @@ -152,7 +152,7 @@ impl cosmic::Application for MultiWindow { } } - fn view(&self) -> cosmic::prelude::Element { + fn view(&self) -> Element<'_, Self::Message> { self.view_window(self.core.main_window_id().unwrap()) } } diff --git a/examples/nav-context/Cargo.toml b/examples/nav-context/Cargo.toml index a1b95413..93dbe3e9 100644 --- a/examples/nav-context/Cargo.toml +++ b/examples/nav-context/Cargo.toml @@ -10,5 +10,4 @@ tracing-log = "0.2.0" [dependencies.libcosmic] path = "../../" -default-features = false -features = ["debug", "winit", "tokio", "xdg-portal", "multi-window"] +features = ["debug", "winit", "tokio", "xdg-portal", "wgpu"] diff --git a/examples/nav-context/src/main.rs b/examples/nav-context/src/main.rs index be458171..fdfb90f9 100644 --- a/examples/nav-context/src/main.rs +++ b/examples/nav-context/src/main.rs @@ -172,7 +172,7 @@ impl cosmic::Application for App { } /// Creates a view after each update. - fn view(&self) -> Element { + fn view(&self) -> Element<'_, Self::Message> { let page_content = self .nav_model .active_data::() diff --git a/examples/open-dialog/Cargo.toml b/examples/open-dialog/Cargo.toml index 3fa07d42..2a734da0 100644 --- a/examples/open-dialog/Cargo.toml +++ b/examples/open-dialog/Cargo.toml @@ -16,6 +16,5 @@ tracing-subscriber = "0.3.19" url = "2.5.4" [dependencies.libcosmic] -features = ["debug", "winit", "multi-window", "wayland", "tokio"] +features = ["debug", "winit", "wgpu", "wayland", "tokio"] path = "../../" -default-features = false diff --git a/examples/open-dialog/src/main.rs b/examples/open-dialog/src/main.rs index 0edac466..10e46315 100644 --- a/examples/open-dialog/src/main.rs +++ b/examples/open-dialog/src/main.rs @@ -82,7 +82,7 @@ impl cosmic::Application for App { (app, cmd) } - fn header_end(&self) -> Vec> { + fn header_end(&self) -> Vec> { // Places a button the header to create open dialogs. vec![button::suggested("Open").on_press(Message::OpenFile).into()] } @@ -186,13 +186,17 @@ impl cosmic::Application for App { Message::CloseError => { self.error_status = None; } - Message::Surface(surface) => {} + Message::Surface(action) => { + return cosmic::task::message(cosmic::Action::Cosmic( + cosmic::app::Action::Surface(action), + )); + } } Task::none() } - fn view(&self) -> Element { + fn view(&self) -> Element<'_, Self::Message> { let mut content = Vec::new(); if let Some(error) = self.error_status.as_deref() { diff --git a/examples/spin-button/Cargo.toml b/examples/spin-button/Cargo.toml index 3088a313..a522050b 100644 --- a/examples/spin-button/Cargo.toml +++ b/examples/spin-button/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" fraction = "0.15.3" [dependencies.libcosmic] -features = ["debug", "multi-window", "wayland", "winit", "desktop", "tokio"] +features = ["debug", "wgpu", "winit", "desktop", "tokio"] path = "../.." default-features = false diff --git a/examples/spin-button/src/main.rs b/examples/spin-button/src/main.rs index 310c5107..47db4dce 100644 --- a/examples/spin-button/src/main.rs +++ b/examples/spin-button/src/main.rs @@ -130,7 +130,7 @@ impl Application for SpinButtonExamplApp { Task::none() } - fn view(&self) -> Element { + fn view(&'_ self) -> Element<'_, Self::Message> { let space_xs = cosmic::theme::spacing().space_xs; let vert_spinner_row = iced::widget::row![ diff --git a/examples/table-view/Cargo.toml b/examples/table-view/Cargo.toml index ba3bd88e..41669cb8 100644 --- a/examples/table-view/Cargo.toml +++ b/examples/table-view/Cargo.toml @@ -10,6 +10,5 @@ tracing-log = "0.2.0" chrono = "*" [dependencies.libcosmic] -features = ["debug", "multi-window", "wayland", "winit", "desktop", "tokio"] +features = ["debug", "wgpu", "winit", "desktop", "tokio"] path = "../.." -default-features = false diff --git a/examples/table-view/src/main.rs b/examples/table-view/src/main.rs index 6bd773bc..bbd9cf5b 100644 --- a/examples/table-view/src/main.rs +++ b/examples/table-view/src/main.rs @@ -204,7 +204,7 @@ impl cosmic::Application for App { } /// Creates a view after each update. - fn view(&self) -> Element { + fn view(&self) -> Element<'_, Self::Message> { cosmic::widget::responsive(|size| { if size.width < 600.0 { widget::compact_table(&self.table_model) diff --git a/examples/text-input/Cargo.toml b/examples/text-input/Cargo.toml index 1cc35d1d..fb1bdf28 100644 --- a/examples/text-input/Cargo.toml +++ b/examples/text-input/Cargo.toml @@ -10,5 +10,4 @@ tracing-log = "0.2.0" [dependencies.libcosmic] path = "../../" -default-features = false -features = ["debug", "winit", "tokio", "xdg-portal"] +features = ["debug", "winit", "wgpu", "tokio", "xdg-portal"] diff --git a/examples/text-input/src/main.rs b/examples/text-input/src/main.rs index 573b9dc1..ea99666c 100644 --- a/examples/text-input/src/main.rs +++ b/examples/text-input/src/main.rs @@ -87,7 +87,7 @@ impl cosmic::Application for App { } /// Creates a view after each update. - fn view(&self) -> Element { + fn view(&self) -> Element<'_, Self::Message> { let editable = cosmic::widget::editable_input( "Input text here", &self.input, @@ -118,6 +118,6 @@ where fn update_title(&mut self) -> Task { let window_title = format!("COSMIC TextInputs Demo"); self.set_header_title(window_title.clone()); - self.set_window_title(window_title) + self.set_window_title(window_title, self.core.main_window_id().unwrap()) } }