examples: fix libcosmic features, warnings, etc.

This commit is contained in:
Michael Aaron Murphy 2025-12-05 17:59:42 +01:00
parent f39ad728c9
commit 05c6608842
No known key found for this signature in database
GPG key ID: B2732D4240C9212C
23 changed files with 40 additions and 46 deletions

View file

@ -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",
]

View file

@ -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",
]

View file

@ -10,5 +10,4 @@ chrono = "0.4.40"
[dependencies.libcosmic]
path = "../../"
default-features = false
features = ["debug", "winit", "tokio", "xdg-portal", "wgpu"]

View file

@ -113,6 +113,9 @@ where
{
fn update_title(&mut self) -> cosmic::app::Task<Message> {
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(),
)
}
}

View file

@ -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() {

View file

@ -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",
]

View file

@ -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<Self::Message> {
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(),

View file

@ -9,5 +9,4 @@ tracing-subscriber = "0.3.19"
[dependencies.libcosmic]
path = "../../"
default-features = false
features = ["debug", "winit", "tokio"]
features = ["debug", "winit", "wgpu", "tokio"]

View file

@ -79,7 +79,7 @@ impl cosmic::Application for App {
}
/// Creates a view after each update.
fn view(&self) -> Element<Self::Message> {
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<Message> {
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(),
)
}
}

View file

@ -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"]

View file

@ -110,7 +110,7 @@ impl cosmic::Application for App {
(app, Task::none())
}
fn header_start(&self) -> Vec<Element<Self::Message>> {
fn header_start(&self) -> Vec<Element<'_, Self::Message>> {
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<Self::Message> {
fn view(&self) -> Element<'_, Self::Message> {
let text = if self.config.hide_content {
cosmic::widget::text("")
} else {

View file

@ -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"] }

View file

@ -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<Self::Message> {
fn subscription(&self) -> Subscription<Self::Message> {
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<cosmic::Action<Self::Message>> {
fn update(&mut self, message: Self::Message) -> Task<cosmic::Action<Self::Message>> {
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<Self::Message> {
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<Self::Message> {
fn view(&self) -> Element<'_, Self::Message> {
self.view_window(self.core.main_window_id().unwrap())
}
}

View file

@ -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"]

View file

@ -172,7 +172,7 @@ impl cosmic::Application for App {
}
/// Creates a view after each update.
fn view(&self) -> Element<Self::Message> {
fn view(&self) -> Element<'_, Self::Message> {
let page_content = self
.nav_model
.active_data::<String>()

View file

@ -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

View file

@ -82,7 +82,7 @@ impl cosmic::Application for App {
(app, cmd)
}
fn header_end(&self) -> Vec<Element<Self::Message>> {
fn header_end(&self) -> Vec<Element<'_, Self::Message>> {
// 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<Self::Message> {
fn view(&self) -> Element<'_, Self::Message> {
let mut content = Vec::new();
if let Some(error) = self.error_status.as_deref() {

View file

@ -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

View file

@ -130,7 +130,7 @@ impl Application for SpinButtonExamplApp {
Task::none()
}
fn view(&self) -> Element<Self::Message> {
fn view(&'_ self) -> Element<'_, Self::Message> {
let space_xs = cosmic::theme::spacing().space_xs;
let vert_spinner_row = iced::widget::row![

View file

@ -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

View file

@ -204,7 +204,7 @@ impl cosmic::Application for App {
}
/// Creates a view after each update.
fn view(&self) -> Element<Self::Message> {
fn view(&self) -> Element<'_, Self::Message> {
cosmic::widget::responsive(|size| {
if size.width < 600.0 {
widget::compact_table(&self.table_model)

View file

@ -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"]

View file

@ -87,7 +87,7 @@ impl cosmic::Application for App {
}
/// Creates a view after each update.
fn view(&self) -> Element<Self::Message> {
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<Message> {
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())
}
}