diff --git a/Cargo.lock b/Cargo.lock index 75c4a3ff..0ca87a70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -856,6 +856,7 @@ dependencies = [ name = "cosmic-applet-tiling" version = "0.1.0" dependencies = [ + "cosmic-time", "i18n-embed 0.14.0", "i18n-embed-fl 0.7.0", "libcosmic", @@ -906,12 +907,26 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" dependencies = [ "atomicwrites", - "cosmic-config-derive", + "cosmic-config-derive 0.1.0 (git+https://github.com/edfloreshz/libcosmic)", "dirs 5.0.1", - "iced_futures", + "iced_futures 0.7.0 (git+https://github.com/edfloreshz/libcosmic)", + "notify", + "ron", + "serde", +] + +[[package]] +name = "cosmic-config" +version = "0.1.0" +source = "git+https://github.com/pop-os/libcosmic#b404497e7636d44ba0fffa9b88e26f5b76d2b789" +dependencies = [ + "atomicwrites", + "cosmic-config-derive 0.1.0 (git+https://github.com/pop-os/libcosmic)", + "dirs 5.0.1", + "iced_futures 0.7.0 (git+https://github.com/pop-os/libcosmic)", "notify", "ron", "serde", @@ -920,7 +935,16 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "cosmic-config-derive" +version = "0.1.0" +source = "git+https://github.com/pop-os/libcosmic#b404497e7636d44ba0fffa9b88e26f5b76d2b789" dependencies = [ "quote", "syn 1.0.109", @@ -942,16 +966,16 @@ dependencies = [ [[package]] name = "cosmic-notifications-config" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-notifications#35fd49d2b8147859d8b08d68b346096c356a8d15" +source = "git+https://github.com/edfloreshz/cosmic-notifications#58e948e6260d2088a7da9128173c76b9cb6db7f3" dependencies = [ - "cosmic-config", + "cosmic-config 0.1.0 (git+https://github.com/edfloreshz/libcosmic)", "serde", ] [[package]] name = "cosmic-notifications-util" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-notifications#35fd49d2b8147859d8b08d68b346096c356a8d15" +source = "git+https://github.com/edfloreshz/cosmic-notifications#58e948e6260d2088a7da9128173c76b9cb6db7f3" dependencies = [ "bytemuck", "fast_image_resize", @@ -972,10 +996,10 @@ dependencies = [ [[package]] name = "cosmic-panel-config" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-panel#edfd24ed3b712de397057906924e4f7e8b6252c4" +source = "git+https://github.com/pop-os/cosmic-panel#7b56316ddcdd3e921b61cf3fe3f69b4bcae437d3" dependencies = [ "anyhow", - "cosmic-config", + "cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic)", "ron", "serde", "tracing", @@ -1019,10 +1043,10 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" dependencies = [ "almost", - "cosmic-config", + "cosmic-config 0.1.0 (git+https://github.com/edfloreshz/libcosmic)", "csscolorparser", "lazy_static", "palette", @@ -1033,7 +1057,7 @@ dependencies = [ [[package]] name = "cosmic-time" version = "0.3.0" -source = "git+https://github.com/pop-os/cosmic-time#4013946f9bd9d2e53bf44310b7db783fc8105b79" +source = "git+https://github.com/edfloreshz/cosmic-time#dfe7211c5c402685cc361b17a148574f37d86df2" dependencies = [ "float-cmp", "libcosmic", @@ -2359,11 +2383,11 @@ dependencies = [ [[package]] name = "iced" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" dependencies = [ "iced_accessibility", - "iced_core", - "iced_futures", + "iced_core 0.10.0 (git+https://github.com/edfloreshz/libcosmic)", + "iced_futures 0.7.0 (git+https://github.com/edfloreshz/libcosmic)", "iced_renderer", "iced_sctk", "iced_widget", @@ -2374,7 +2398,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" dependencies = [ "accesskit", "accesskit_unix", @@ -2383,7 +2407,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" dependencies = [ "bitflags 1.3.2", "iced_accessibility", @@ -2395,29 +2419,53 @@ dependencies = [ "twox-hash", ] +[[package]] +name = "iced_core" +version = "0.10.0" +source = "git+https://github.com/pop-os/libcosmic#b404497e7636d44ba0fffa9b88e26f5b76d2b789" +dependencies = [ + "bitflags 1.3.2", + "instant", + "log", + "thiserror", + "twox-hash", +] + [[package]] name = "iced_futures" version = "0.7.0" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" dependencies = [ "futures", - "iced_core", + "iced_core 0.10.0 (git+https://github.com/edfloreshz/libcosmic)", "log", "tokio", "wasm-bindgen-futures", "wasm-timer", ] +[[package]] +name = "iced_futures" +version = "0.7.0" +source = "git+https://github.com/pop-os/libcosmic#b404497e7636d44ba0fffa9b88e26f5b76d2b789" +dependencies = [ + "futures", + "iced_core 0.10.0 (git+https://github.com/pop-os/libcosmic)", + "log", + "wasm-bindgen-futures", + "wasm-timer", +] + [[package]] name = "iced_graphics" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" dependencies = [ "bitflags 1.3.2", "bytemuck", "glam", "half", - "iced_core", + "iced_core 0.10.0 (git+https://github.com/edfloreshz/libcosmic)", "image", "kamadak-exif", "log", @@ -2428,7 +2476,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2441,11 +2489,11 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.1.1" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" dependencies = [ "iced_accessibility", - "iced_core", - "iced_futures", + "iced_core 0.10.0 (git+https://github.com/edfloreshz/libcosmic)", + "iced_futures 0.7.0 (git+https://github.com/edfloreshz/libcosmic)", "smithay-client-toolkit 0.17.0", "thiserror", ] @@ -2453,12 +2501,12 @@ dependencies = [ [[package]] name = "iced_sctk" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" dependencies = [ "enum-repr", "float-cmp", "futures", - "iced_futures", + "iced_futures 0.7.0 (git+https://github.com/edfloreshz/libcosmic)", "iced_graphics", "iced_runtime", "iced_style", @@ -2475,9 +2523,9 @@ dependencies = [ [[package]] name = "iced_style" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" dependencies = [ - "iced_core", + "iced_core 0.10.0 (git+https://github.com/edfloreshz/libcosmic)", "once_cell", "palette", ] @@ -2485,7 +2533,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" dependencies = [ "bytemuck", "cosmic-text", @@ -2503,7 +2551,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.11.1" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2524,7 +2572,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.1.3" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" dependencies = [ "iced_renderer", "iced_runtime", @@ -2790,19 +2838,19 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#fcdefcd8fbca53705ba761b97e25453bc35e40c0" +source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae" dependencies = [ "apply", "ashpd", - "cosmic-config", + "cosmic-config 0.1.0 (git+https://github.com/edfloreshz/libcosmic)", "cosmic-panel-config", "cosmic-theme", "derive_setters", "fraction", "freedesktop-icons", "iced", - "iced_core", - "iced_futures", + "iced_core 0.10.0 (git+https://github.com/edfloreshz/libcosmic)", + "iced_futures 0.7.0 (git+https://github.com/edfloreshz/libcosmic)", "iced_renderer", "iced_runtime", "iced_sctk", @@ -5790,7 +5838,7 @@ dependencies = [ [[package]] name = "xdg-shell-wrapper-config" version = "0.1.0" -source = "git+https://github.com/pop-os/xdg-shell-wrapper#9ae1c4c838fe58e887b62d2a990d73ab2f6cb629" +source = "git+https://github.com/pop-os/xdg-shell-wrapper#5acfa50fc458ffc68a800d9b42ce34dea3a7bece" dependencies = [ "serde", "wayland-protocols-wlr", diff --git a/Cargo.toml b/Cargo.toml index a6c28ebd..a12cbe57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,11 +23,11 @@ cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-c cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = [ "client", ], rev = "e39748e" } -cosmic-time = { git = "https://github.com/pop-os/cosmic-time", default-features = false, features = [ +cosmic-time = { git = "https://github.com/edfloreshz/cosmic-time", default-features = false, features = [ "libcosmic", "once_cell", ] } -libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = [ +libcosmic = { git = "https://github.com/edfloreshz/libcosmic", default-features = false, features = [ "applet", "tokio", "wayland", diff --git a/cosmic-app-list/src/app.rs b/cosmic-app-list/src/app.rs index 49f6f68d..4bee290e 100755 --- a/cosmic-app-list/src/app.rs +++ b/cosmic-app-list/src/app.rs @@ -52,7 +52,6 @@ use itertools::Itertools; use rand::{thread_rng, Rng}; use std::borrow::Cow; use std::collections::HashMap; -use std::path::Path; use std::path::PathBuf; use std::str::FromStr; use std::time::Duration; @@ -114,10 +113,9 @@ impl DockItem { .. } = self; - let cosmic_icon = cosmic::widget::icon( - Path::new(&desktop_info.icon), - applet_helper.suggested_size().0, - ); + let cosmic_icon = cosmic::widget::icon::from_path(PathBuf::from(&desktop_info.icon)) + .icon() + .size(applet_helper.suggested_size().0); let dot_radius = 2; let dots = (0..toplevels.len()) @@ -134,12 +132,13 @@ impl DockItem { border_radius: 4.0.into(), border_width: 0.0, border_color: Color::TRANSPARENT, + icon_color: Some(Color::TRANSPARENT), }, ))) .into() }) .collect_vec(); - let icon_wrapper = match applet_helper.anchor { + let icon_wrapper: Element<_> = match applet_helper.anchor { PanelAnchor::Left => row(vec![column(dots).spacing(4).into(), cosmic_icon.into()]) .align_items(iced::Alignment::Center) .spacing(4) @@ -158,8 +157,8 @@ impl DockItem { .into(), }; - let icon_button = cosmic::widget::button(Button::Text) - .custom(vec![icon_wrapper]) + let icon_button = cosmic::widget::button(icon_wrapper) + .style(Button::Text) .padding(8); let icon_button = if interaction_enabled { dnd_source( @@ -879,10 +878,10 @@ impl cosmic::Application for CosmicAppList { } else if self.is_listening_for_dnd && self.favorite_list.is_empty() { // show star indicating favorite_list is drag target favorites.push( - container(cosmic::widget::icon( - "starred-symbolic.symbolic", - self.core.applet_helper.suggested_size().0, - )) + container( + cosmic::widget::icon::from_name("starred-symbolic.symbolic") + .size(self.core.applet_helper.suggested_size().0), + ) .padding(8) .into(), ); @@ -962,11 +961,11 @@ impl cosmic::Application for CosmicAppList { } else if !self.active_list.is_empty() { vec![active] } else { - vec![cosmic::widget::icon( - "com.system76.CosmicAppList", - self.core.applet_helper.suggested_size().0, - ) - .into()] + vec![ + cosmic::widget::icon::from_name("com.system76.CosmicAppList") + .size(self.core.applet_helper.suggested_size().0) + .into(), + ] }; let content = match &self.core.applet_helper.anchor { @@ -997,11 +996,10 @@ impl cosmic::Application for CosmicAppList { fn view_window(&self, id: window::Id) -> Element { if let Some((_, item, _)) = self.dnd_source.as_ref().filter(|s| s.0 == id) { - cosmic::widget::icon( - Path::new(&item.desktop_info.icon), - self.core.applet_helper.suggested_size().0, - ) - .into() + cosmic::widget::icon::from_path(PathBuf::from(&item.desktop_info.icon)) + .icon() + .size(self.core.applet_helper.suggested_size().0) + .into() } else if let Some(( _popup_id, DockItem { @@ -1019,8 +1017,8 @@ impl cosmic::Application for CosmicAppList { let mut content = column![ iced::widget::text(&desktop_info.name).horizontal_alignment(Horizontal::Center), - cosmic::widget::button(Button::Text) - .custom(vec![iced::widget::text(fl!("new-window")).into()]) + cosmic::widget::button(iced::widget::text(fl!("new-window"))) + .style(Button::Text) .on_press(Message::Exec(desktop_info.exec.clone())), ] .padding(8) @@ -1035,8 +1033,8 @@ impl cosmic::Application for CosmicAppList { info.title.clone() }; list_col = list_col.push( - cosmic::widget::button(Button::Text) - .custom(vec![iced::widget::text(title).into()]) + cosmic::widget::button(iced::widget::text(title)) + .style(Button::Text) .on_press(Message::Activate(handle.clone())), ); } @@ -1045,25 +1043,25 @@ impl cosmic::Application for CosmicAppList { content = content.push(divider::horizontal::light()); } content = content.push(if is_favorite { - cosmic::widget::button(Button::Text) - .custom(vec![iced::widget::text(fl!("unfavorite")).into()]) + cosmic::widget::button(iced::widget::text(fl!("unfavorite"))) + .style(Button::Text) .on_press(Message::UnFavorite(desktop_info.id.clone())) } else { - cosmic::widget::button(Button::Text) - .custom(vec![iced::widget::text(fl!("favorite")).into()]) + cosmic::widget::button(iced::widget::text(fl!("favorite"))) + .style(Button::Text) .on_press(Message::Favorite(desktop_info.id.clone())) }); content = match toplevels.len() { 0 => content, 1 => content.push( - cosmic::widget::button(Button::Text) - .custom(vec![iced::widget::text(fl!("quit")).into()]) + cosmic::widget::button(iced::widget::text(fl!("quit"))) + .style(Button::Text) .on_press(Message::Quit(desktop_info.id.clone())), ), _ => content.push( - cosmic::widget::button(Button::Text) - .custom(vec![iced::widget::text(&fl!("quit-all")).into()]) + cosmic::widget::button(iced::widget::text(&fl!("quit-all"))) + .style(Button::Text) .on_press(Message::Quit(desktop_info.id.clone())), ), }; diff --git a/cosmic-applet-audio/src/main.rs b/cosmic-applet-audio/src/main.rs index 61a4f840..91f40d16 100644 --- a/cosmic-applet-audio/src/main.rs +++ b/cosmic-applet-audio/src/main.rs @@ -4,7 +4,6 @@ use cosmic::app::Command; use cosmic::iced::widget; use cosmic::iced::Limits; use cosmic::iced_runtime::core::alignment::Horizontal; -use cosmic::theme::Svg; use cosmic::app::applet::applet_button_theme; use cosmic::widget::{button, divider, icon}; @@ -370,7 +369,9 @@ impl cosmic::Application for Audio { } else { column![ row![ - icon(self.icon_name.as_str(), 24).style(Svg::Symbolic), + icon::from_name(self.icon_name.as_str()) + .size(24) + .symbolic(true), slider(0.0..=100.0, out_f64, Message::SetOutputVolume) .width(Length::FillPortion(5)), text(format!("{}%", out_f64.round())) @@ -382,7 +383,9 @@ impl cosmic::Application for Audio { .align_items(Alignment::Center) .padding([8, 24]), row![ - icon(self.input_icon_name.as_str(), 24).style(Svg::Symbolic), + icon::from_name(self.input_icon_name.as_str()) + .size(24) + .symbolic(true), slider(0.0..=100.0, in_f64, Message::SetInputVolume) .width(Length::FillPortion(5)), text(format!("{}%", in_f64.round())) @@ -455,8 +458,8 @@ impl cosmic::Application for Audio { container(divider::horizontal::light()) .padding([12, 24]) .width(Length::Fill), - button(applet_button_theme()) - .custom(vec![text(fl!("sound-settings")).size(14).into()]) + button(text(fl!("sound-settings")).size(14)) + .style(applet_button_theme()) .padding([8, 24]) .width(Length::Fill) ] @@ -487,8 +490,8 @@ fn revealer( column![revealer_head(open, title, selected, toggle)].width(Length::Fill), |col, (id, name)| { col.push( - button(applet_button_theme()) - .custom(vec![text(name).size(14).into()]) + button(text(name).size(14)) + .style(applet_button_theme()) .on_press(change(id.clone())) .width(Length::Fill) .padding([8, 48]), @@ -505,15 +508,15 @@ fn revealer_head( title: String, selected: String, toggle: Message, -) -> widget::Button<'static, Message, Renderer> { - button(applet_button_theme()) - .custom(vec![ - text(title).width(Length::Fill).size(14).into(), - text(selected).size(10).into(), - ]) - .padding([8, 24]) - .width(Length::Fill) - .on_press(toggle) +) -> cosmic::widget::Button<'static, Message, Renderer> { + button(column![ + text(title).width(Length::Fill).size(14), + text(selected).size(10), + ]) + .style(applet_button_theme()) + .padding([8, 24]) + .width(Length::Fill) + .on_press(toggle) } fn pretty_name(name: Option) -> String { diff --git a/cosmic-applet-battery/src/app.rs b/cosmic-applet-battery/src/app.rs index 322201a1..d7b49576 100644 --- a/cosmic-applet-battery/src/app.rs +++ b/cosmic-applet-battery/src/app.rs @@ -19,7 +19,6 @@ use cosmic::iced::{ }; use cosmic::iced_runtime::core::layout::Limits; use cosmic::iced_style::application; -use cosmic::theme::Svg; use cosmic::widget::{button, divider, icon}; use cosmic::{Element, Theme}; use cosmic_time::{anim, chain, id, once_cell::sync::Lazy, Instant, Timeline}; @@ -309,7 +308,7 @@ impl cosmic::Application for CosmicBatteryApplet { .popup_container( column![ row![ - icon(&*self.icon_name, 24).style(Svg::Symbolic), + icon::from_name(&*self.icon_name).size(24).symbolic(true), column![name, description] ] .padding([0, 24]) @@ -318,63 +317,57 @@ impl cosmic::Application for CosmicBatteryApplet { container(divider::horizontal::light()) .width(Length::Fill) .padding([0, 12]), - button(applet_button_theme()) - .custom(vec![row![ + button( + row![ column![ text(fl!("battery")).size(14), text(fl!("battery-desc")).size(10) ] .width(Length::Fill), - icon("emblem-ok-symbolic", 12).size(12).style( - match self.power_profile { - Power::Battery => Svg::SymbolicActive, - _ => Svg::Default, - } - ), + icon::from_name("emblem-ok-symbolic") + .size(12) + .symbolic(matches!(self.power_profile, Power::Battery)), ] .align_items(Alignment::Center) - .into()]) - .padding([8, 24]) - .on_press(Message::SelectProfile(Power::Battery)) - .width(Length::Fill), - button(applet_button_theme()) - .custom(vec![row![ + ) + .style(applet_button_theme()) + .padding([8, 24]) + .on_press(Message::SelectProfile(Power::Battery)) + .width(Length::Fill), + button( + row![ column![ text(fl!("balanced")).size(14), text(fl!("balanced-desc")).size(10) ] .width(Length::Fill), - icon("emblem-ok-symbolic", 12).size(12).style( - match self.power_profile { - Power::Balanced => Svg::SymbolicActive, - _ => Svg::Default, - } - ), + icon::from_name("emblem-ok-symbolic") + .size(12) + .symbolic(matches!(self.power_profile, Power::Balanced)), ] .align_items(Alignment::Center) - .into()]) - .padding([8, 24]) - .on_press(Message::SelectProfile(Power::Balanced)) - .width(Length::Fill), - button(applet_button_theme()) - .custom(vec![row![ + ) + .style(applet_button_theme()) + .padding([8, 24]) + .on_press(Message::SelectProfile(Power::Balanced)) + .width(Length::Fill), + button( + row![ column![ text(fl!("performance")).size(14), text(fl!("performance-desc")).size(10) ] .width(Length::Fill), - icon("emblem-ok-symbolic", 12).size(12).style( - match self.power_profile { - Power::Performance => Svg::SymbolicActive, - _ => Svg::Default, - } - ), + icon::from_name("emblem-ok-symbolic") + .size(12) + .symbolic(matches!(self.power_profile, Power::Performance)), ] .align_items(Alignment::Center) - .into()]) - .padding([8, 24]) - .on_press(Message::SelectProfile(Power::Performance)) - .width(Length::Fill), + ) + .style(applet_button_theme()) + .padding([8, 24]) + .on_press(Message::SelectProfile(Power::Performance)) + .width(Length::Fill), container(divider::horizontal::light()) .width(Length::Fill) .padding([0, 12]), @@ -396,7 +389,9 @@ impl cosmic::Application for CosmicBatteryApplet { .width(Length::Fill) .padding([0, 12]), row![ - icon(self.display_icon_name.as_str(), 24).style(Svg::Symbolic), + icon::from_name(self.display_icon_name.as_str()) + .size(24) + .symbolic(true), slider( 1..=100, (self.screen_brightness * 100.0) as i32, @@ -410,7 +405,9 @@ impl cosmic::Application for CosmicBatteryApplet { .padding([0, 24]) .spacing(12), row![ - icon("keyboard-brightness-symbolic", 24).style(Svg::Symbolic), + icon::from_name("keyboard-brightness-symbolic") + .size(24) + .symbolic(true), slider( 0..=100, (self.kbd_brightness * 100.0) as i32, @@ -426,11 +423,8 @@ impl cosmic::Application for CosmicBatteryApplet { container(divider::horizontal::light()) .width(Length::Fill) .padding([0, 12]), - button(applet_button_theme()) - .custom(vec![text(fl!("power-settings")) - .size(14) - .width(Length::Fill) - .into()]) + button(text(fl!("power-settings")).size(14).width(Length::Fill)) + .style(applet_button_theme()) .on_press(Message::OpenBatterySettings) .width(Length::Fill) .padding([8, 24]) diff --git a/cosmic-applet-bluetooth/src/app.rs b/cosmic-applet-bluetooth/src/app.rs index 032dba8b..890a0d1a 100644 --- a/cosmic-applet-bluetooth/src/app.rs +++ b/cosmic-applet-bluetooth/src/app.rs @@ -1,6 +1,6 @@ use crate::bluetooth::{BluerDeviceStatus, BluerRequest, BluerState}; use cosmic::app::{applet::applet_button_theme, Command}; -use cosmic::iced_style; +use cosmic::widget::button::StyleSheet; use cosmic::{ iced::{ self, @@ -13,8 +13,8 @@ use cosmic::{ layout::Limits, window, }, - iced_style::{application, button::StyleSheet}, - theme::{Button, Svg}, + iced_style::application, + theme::Button, widget::{button, divider, icon, toggler}, Element, Theme, }; @@ -291,13 +291,21 @@ impl cosmic::Application for CosmicBluetoothApplet { fn view_window(&self, _id: window::Id) -> Element { let button_style = || Button::Custom { - active: Box::new(|t| iced_style::button::Appearance { + active: Box::new(|active, t| button::Appearance { border_radius: 0.0.into(), - ..t.active(&Button::Text) + ..t.active(active, &Button::Standard) }), - hover: Box::new(|t| iced_style::button::Appearance { + disabled: Box::new(|t| button::Appearance { border_radius: 0.0.into(), - ..t.hovered(&Button::Text) + ..t.disabled(&Button::Text) + }), + hovered: Box::new(|hovered, t| button::Appearance { + border_radius: 0.0.into(), + ..t.hovered(hovered, &Button::Text) + }), + pressed: Box::new(|pressed, t| button::Appearance { + border_radius: 0.0.into(), + ..t.pressed(pressed, &Button::Text) }), }; let mut known_bluetooth = column![]; @@ -308,7 +316,7 @@ impl cosmic::Application for CosmicBluetoothApplet { .map_or(false, |(dev, _, _)| d.address == dev.address) }) { let mut row = row![ - icon(dev.icon.as_str(), 16).style(Svg::Symbolic), + icon::from_name(dev.icon.as_str()).size(16).symbolic(true), text(dev.name.clone()) .size(14) .horizontal_alignment(Horizontal::Left) @@ -329,14 +337,17 @@ impl cosmic::Application for CosmicBluetoothApplet { } BluerDeviceStatus::Paired => {} BluerDeviceStatus::Connecting | BluerDeviceStatus::Disconnecting => { - row = row.push(icon("process-working-symbolic", 24).style(Svg::Symbolic)); + row = row.push( + icon::from_name("process-working-symbolic") + .size(24) + .symbolic(true), + ); } BluerDeviceStatus::Disconnected | BluerDeviceStatus::Pairing => continue, }; known_bluetooth = known_bluetooth.push( - button(applet_button_theme()) - .custom(vec![row.into()]) + button(row) .style(applet_button_theme()) .on_press(match dev.status { BluerDeviceStatus::Connected => { @@ -390,34 +401,31 @@ impl cosmic::Application for CosmicBluetoothApplet { } else { "go-next-symbolic" }; - let available_connections_btn = button(Button::Secondary) - .custom( - vec![ - text(fl!("other-devices")) - .size(14) - .width(Length::Fill) - .height(Length::Fixed(24.0)) - .vertical_alignment(Vertical::Center) - .into(), - container(icon(dropdown_icon, 14).style(Svg::Symbolic)) - .align_x(Horizontal::Center) - .align_y(Vertical::Center) - .width(Length::Fixed(24.0)) - .height(Length::Fixed(24.0)) - .into(), - ] - .into(), - ) - .padding([8, 24]) - .style(button_style()) - .on_press(Message::ToggleVisibleDevices(!self.show_visible_devices)); + let available_connections_btn = button(row![ + text(fl!("other-devices")) + .size(14) + .width(Length::Fill) + .height(Length::Fixed(24.0)) + .vertical_alignment(Vertical::Center), + container(icon::from_name(dropdown_icon).size(14).symbolic(true)) + .align_x(Horizontal::Center) + .align_y(Vertical::Center) + .width(Length::Fixed(24.0)) + .height(Length::Fixed(24.0)) + ]) + .style(Button::Standard) + .padding([8, 24]) + .style(button_style()) + .on_press(Message::ToggleVisibleDevices(!self.show_visible_devices)); content = content.push(available_connections_btn); let mut list_column: Vec> = Vec::with_capacity(self.bluer_state.devices.len()); if let Some((device, pin, _)) = self.request_confirmation.as_ref() { let row = column![ - icon(device.icon.as_str(), 16).style(Svg::Symbolic), + icon::from_name(device.icon.as_str()) + .size(16) + .symbolic(true), text(&device.name) .size(14) .horizontal_alignment(Horizontal::Left) @@ -437,34 +445,28 @@ impl cosmic::Application for CosmicBluetoothApplet { .width(Length::Fill) .size(22), row![ - button(Button::Secondary) - .custom( - vec![text(fl!("cancel")) - .size(14) - .width(Length::Fill) - .height(Length::Fixed(24.0)) - .vertical_alignment(Vertical::Center) - .into(),] - .into(), - ) - .padding([8, 24]) - .style(button_style()) - .on_press(Message::Cancel) - .width(Length::Fill), - button(Button::Secondary) - .custom( - vec![text(fl!("confirm")) - .size(14) - .width(Length::Fill) - .height(Length::Fixed(24.0)) - .vertical_alignment(Vertical::Center) - .into(),] - .into(), - ) - .padding([8, 24]) - .style(button_style()) - .on_press(Message::Confirm) - .width(Length::Fill), + button( + text(fl!("cancel")) + .size(14) + .width(Length::Fill) + .height(Length::Fixed(24.0)) + .vertical_alignment(Vertical::Center) + ) + .padding([8, 24]) + .style(button_style()) + .on_press(Message::Cancel) + .width(Length::Fill), + button( + text(fl!("confirm")) + .size(14) + .width(Length::Fill) + .height(Length::Fixed(24.0)) + .vertical_alignment(Vertical::Center) + ) + .padding([8, 24]) + .style(button_style()) + .on_press(Message::Confirm) + .width(Length::Fill), ] ] .padding([0, 24]) @@ -472,39 +474,37 @@ impl cosmic::Application for CosmicBluetoothApplet { list_column.push(row.into()); } let mut visible_devices_count = 0; - if self.show_visible_devices { - if self.bluer_state.bluetooth_enabled { - let mut visible_devices = column![]; - for dev in self.bluer_state.devices.iter().filter(|d| { - matches!( - d.status, - BluerDeviceStatus::Disconnected | BluerDeviceStatus::Pairing - ) && !self - .request_confirmation - .as_ref() - .map_or(false, |(dev, _, _)| d.address == dev.address) - }) { - let row = row![ - icon(dev.icon.as_str(), 16).style(Svg::Symbolic), - text(dev.name.clone()) - .horizontal_alignment(Horizontal::Left) - .size(14), - ] - .width(Length::Fill) - .align_items(Alignment::Center) - .spacing(12); - visible_devices = visible_devices.push( - button(applet_button_theme()) - .custom(vec![row.width(Length::Fill).into()]) - .on_press(Message::Request(BluerRequest::PairDevice( - dev.address.clone(), - ))) - .width(Length::Fill), - ); - visible_devices_count += 1; - } - list_column.push(visible_devices.into()); + if self.show_visible_devices && self.bluer_state.bluetooth_enabled { + let mut visible_devices = column![]; + for dev in self.bluer_state.devices.iter().filter(|d| { + matches!( + d.status, + BluerDeviceStatus::Disconnected | BluerDeviceStatus::Pairing + ) && !self + .request_confirmation + .as_ref() + .map_or(false, |(dev, _, _)| d.address == dev.address) + }) { + let row = row![ + icon::from_name(dev.icon.as_str()).size(16).symbolic(true), + text(dev.name.clone()) + .horizontal_alignment(Horizontal::Left) + .size(14), + ] + .width(Length::Fill) + .align_items(Alignment::Center) + .spacing(12); + visible_devices = visible_devices.push( + button(row.width(Length::Fill)) + .style(applet_button_theme()) + .on_press(Message::Request(BluerRequest::PairDevice( + dev.address.clone(), + ))) + .width(Length::Fill), + ); + visible_devices_count += 1; } + list_column.push(visible_devices.into()); } let item_counter = visible_devices_count // request confirmation is pretty big diff --git a/cosmic-applet-graphics/src/dbus.rs b/cosmic-applet-graphics/src/dbus.rs index 1e046ee5..071ef5d5 100644 --- a/cosmic-applet-graphics/src/dbus.rs +++ b/cosmic-applet-graphics/src/dbus.rs @@ -89,7 +89,10 @@ pub async fn init() -> Option<(Connection, PowerDaemonProxy<'static>)> { _ => return None, }; - if matches!(proxy.introspect().await, Err(zbus::fdo::Error::ServiceUnknown(_))) { + if matches!( + proxy.introspect().await, + Err(zbus::fdo::Error::ServiceUnknown(_)) + ) { return None; } diff --git a/cosmic-applet-graphics/src/main.rs b/cosmic-applet-graphics/src/main.rs index 186ad3b9..ac2e7091 100644 --- a/cosmic-applet-graphics/src/main.rs +++ b/cosmic-applet-graphics/src/main.rs @@ -6,5 +6,7 @@ mod window; use window::*; pub fn main() -> cosmic::iced::Result { + localize::localize(); + cosmic::app::applet::run::(true, ()) } diff --git a/cosmic-applet-graphics/src/window.rs b/cosmic-applet-graphics/src/window.rs index 89ca01ea..1fb7c4eb 100644 --- a/cosmic-applet-graphics/src/window.rs +++ b/cosmic-applet-graphics/src/window.rs @@ -15,7 +15,7 @@ use cosmic::{ iced::widget::{column, container, row, text}, iced::{self, Length}, iced_runtime::core::window, - theme::{Svg, Theme}, + theme::Theme, widget::{button, divider}, Element, }; @@ -135,7 +135,7 @@ impl cosmic::Application for Window { if dbus.is_none() { eprintln!("Could not connect to com.system76.PowerDaemon. Exiting."); std::process::exit(0); - } + } self.dbus = dbus; return iced::Command::perform( get_current_graphics(self.dbus.as_ref().unwrap().1.clone()), @@ -218,9 +218,11 @@ impl cosmic::Application for Window { .on_press(Message::TogglePopup) .style(Button::Text) .into(), - PanelAnchor::Top | PanelAnchor::Bottom => button(Button::Text) - .custom(vec![row![ - icon(ID, self.core.applet_helper.suggested_size().0,).style(Svg::Symbolic), + PanelAnchor::Top | PanelAnchor::Bottom => button( + row![ + icon::from_name(ID) + .size(self.core.applet_helper.suggested_size().0) + .symbolic(true), text(match self.graphics_mode.map(|g| g.inner()) { Some(Graphics::Integrated) => fl!("integrated"), Some(Graphics::Nvidia) => fl!("nvidia"), @@ -232,160 +234,125 @@ impl cosmic::Application for Window { ] .spacing(8) .padding([0, self.core.applet_helper.suggested_size().0 / 2]) - .align_items(Alignment::Center) - .into()]) - .style(Button::Text) - .on_press(Message::TogglePopup) - .padding(8) - .width(Length::Shrink) - .height(Length::Shrink) - .into(), + .align_items(Alignment::Center), + ) + .style(Button::Standard) + .on_press(Message::TogglePopup) + .padding(8) + .width(Length::Shrink) + .height(Length::Shrink) + .into(), } } fn view_window(&self, _id: window::Id) -> Element { + let symbolic = matches!( + self.graphics_mode, + Some(GraphicsMode::CurrentGraphicsMode(Graphics::Integrated)) + | Some(GraphicsMode::AppliedGraphicsMode(Graphics::Integrated)) + | Some(GraphicsMode::SelectedGraphicsMode { + new: Graphics::Integrated, + .. + }) + ); let content_list = vec![ - button(applet_button_theme()) - .custom(vec![row![ + button( + row![ column![ text(format!("{} {}", fl!("integrated"), fl!("graphics"))).size(14), text(fl!("integrated-desc")).size(12) ] .width(Length::Fill), - icon( - match self.graphics_mode { - Some(GraphicsMode::SelectedGraphicsMode { - new: Graphics::Integrated, - .. - }) => "process-working-symbolic", - _ => "emblem-ok-symbolic", - }, - 12 - ) - .size(12) - .style(match self.graphics_mode { - Some(GraphicsMode::CurrentGraphicsMode(Graphics::Integrated)) => - Svg::SymbolicActive, - Some(GraphicsMode::AppliedGraphicsMode(Graphics::Integrated)) => - Svg::SymbolicActive, + icon::from_name(match self.graphics_mode { Some(GraphicsMode::SelectedGraphicsMode { new: Graphics::Integrated, .. - }) => Svg::Symbolic, - _ => Svg::Default, - },), - ] - .align_items(Alignment::Center) - .into()]) - .padding([8, 24]) - .on_press(Message::SelectGraphicsMode(Graphics::Integrated)) - .width(Length::Fill) - .into(), - button(applet_button_theme()) - .custom(vec![row![ - column![text(format!("{} {}", fl!("nvidia"), fl!("graphics"))).size(14),] - .width(Length::Fill), - icon( - match self.graphics_mode { - Some(GraphicsMode::SelectedGraphicsMode { - new: Graphics::Nvidia, - .. - }) => "process-working-symbolic", - _ => "emblem-ok-symbolic", - }, - 12 - ) + }) => "process-working-symbolic", + _ => "emblem-ok-symbolic", + }) .size(12) - .style(match self.graphics_mode { - Some(GraphicsMode::CurrentGraphicsMode(Graphics::Nvidia)) => - Svg::SymbolicActive, - Some(GraphicsMode::AppliedGraphicsMode(Graphics::Nvidia)) => - Svg::SymbolicActive, + .symbolic(symbolic) + .prefer_svg(!symbolic) + ] + .align_items(Alignment::Center), + ) + .style(applet_button_theme()) + .padding([8, 24]) + .on_press(Message::SelectGraphicsMode(Graphics::Integrated)) + .width(Length::Fill) + .into(), + button( + row![ + column![text(format!("{} {}", fl!("nvidia"), fl!("graphics"))).size(14)] + .width(Length::Fill), + icon::from_name(match self.graphics_mode { Some(GraphicsMode::SelectedGraphicsMode { new: Graphics::Nvidia, .. - }) => Svg::Symbolic, - _ => Svg::Default, - }), + }) => "process-working-symbolic", + _ => "emblem-ok-symbolic", + },) + .size(12) + .symbolic(symbolic) + .prefer_svg(!symbolic), ] - .align_items(Alignment::Center) - .into()]) - .padding([8, 24]) - .on_press(Message::SelectGraphicsMode(Graphics::Nvidia)) - .width(Length::Fill) - .into(), - button(applet_button_theme()) - .custom(vec![row![ + .align_items(Alignment::Center), + ) + .style(applet_button_theme()) + .padding([8, 24]) + .on_press(Message::SelectGraphicsMode(Graphics::Nvidia)) + .width(Length::Fill) + .into(), + button( + row![ column![ text(format!("{} {}", fl!("hybrid"), fl!("graphics"))).size(14), text(fl!("hybrid-desc")).size(12) ] .width(Length::Fill), - icon( - match self.graphics_mode { - Some(GraphicsMode::SelectedGraphicsMode { - new: Graphics::Hybrid, - .. - }) => "process-working-symbolic", - _ => "emblem-ok-symbolic", - }, - 12 - ) - .size(12) - .style(match self.graphics_mode { - Some(GraphicsMode::CurrentGraphicsMode(Graphics::Hybrid)) => - Svg::SymbolicActive, - Some(GraphicsMode::AppliedGraphicsMode(Graphics::Hybrid)) => - Svg::SymbolicActive, + icon::from_name(match self.graphics_mode { Some(GraphicsMode::SelectedGraphicsMode { new: Graphics::Hybrid, .. - }) => Svg::Symbolic, - _ => Svg::Default, - }) + }) => "process-working-symbolic", + _ => "emblem-ok-symbolic", + },) + .size(12) + .symbolic(symbolic) + .prefer_svg(!symbolic), ] - .align_items(Alignment::Center) - .into()]) - .padding([8, 24]) - .on_press(Message::SelectGraphicsMode(Graphics::Hybrid)) - .width(Length::Fill) - .into(), - button(applet_button_theme()) - .custom(vec![row![ + .align_items(Alignment::Center), + ) + .style(applet_button_theme()) + .padding([8, 24]) + .on_press(Message::SelectGraphicsMode(Graphics::Hybrid)) + .width(Length::Fill) + .into(), + button( + row![ column![ text(format!("{} {}", fl!("compute"), fl!("graphics"))).size(14), text(fl!("compute-desc")).size(12) ] .width(Length::Fill), - icon( - match self.graphics_mode { - Some(GraphicsMode::SelectedGraphicsMode { - new: Graphics::Compute, - .. - }) => "process-working-symbolic", - _ => "emblem-ok-symbolic", - }, - 12 - ) - .size(12) - .style(match self.graphics_mode { - Some(GraphicsMode::CurrentGraphicsMode(Graphics::Compute)) => - Svg::SymbolicActive, - Some(GraphicsMode::AppliedGraphicsMode(Graphics::Compute)) => - Svg::SymbolicActive, + icon::from_name(match self.graphics_mode { Some(GraphicsMode::SelectedGraphicsMode { new: Graphics::Compute, .. - }) => Svg::Symbolic, - _ => Svg::Default, - }), + }) => "process-working-symbolic", + _ => "emblem-ok-symbolic", + },) + .size(12) + .symbolic(symbolic) + .prefer_svg(!symbolic) ] - .align_items(Alignment::Center) - .into()]) - .padding([8, 24]) - .on_press(Message::SelectGraphicsMode(Graphics::Compute)) - .width(Length::Fill) - .into(), + .align_items(Alignment::Center), + ) + .style(applet_button_theme()) + .padding([8, 24]) + .on_press(Message::SelectGraphicsMode(Graphics::Compute)) + .width(Length::Fill) + .into(), ]; self.core diff --git a/cosmic-applet-network/src/app.rs b/cosmic-applet-network/src/app.rs index be5c5857..bbe01a2f 100644 --- a/cosmic-applet-network/src/app.rs +++ b/cosmic-applet-network/src/app.rs @@ -1,6 +1,6 @@ use cosmic::app::Command; -use cosmic::iced_style; use cosmic::iced_widget::Row; +use cosmic::widget::button::StyleSheet; use cosmic::{ iced::{ wayland::popup::{destroy_popup, get_popup}, @@ -12,8 +12,8 @@ use cosmic::{ layout::Limits, window, }, - iced_style::{application, button::StyleSheet}, - theme::{Button, Svg}, + iced_style::application, + theme::Button, widget::{button, divider, icon}, Element, Theme, }; @@ -406,13 +406,21 @@ impl cosmic::Application for CosmicNetworkApplet { fn view_window(&self, _id: window::Id) -> Element { let button_style = || Button::Custom { - active: Box::new(|t| iced_style::button::Appearance { + active: Box::new(|active, t| button::Appearance { border_radius: 0.0.into(), - ..t.active(&Button::Text) + ..t.active(active, &Button::Standard) }), - hover: Box::new(|t| iced_style::button::Appearance { + disabled: Box::new(|t| button::Appearance { border_radius: 0.0.into(), - ..t.hovered(&Button::Text) + ..t.disabled(&Button::Text) + }), + hovered: Box::new(|hovered, t| button::Appearance { + border_radius: 0.0.into(), + ..t.hovered(hovered, &Button::Text) + }), + pressed: Box::new(|pressed, t| button::Appearance { + border_radius: 0.0.into(), + ..t.pressed(pressed, &Button::Text) }), }; let mut vpn_ethernet_col = column![]; @@ -473,7 +481,10 @@ impl cosmic::Application for CosmicNetworkApplet { ); } let mut btn_content = vec![ - icon(wifi_icon(*strength), 24).style(Svg::Symbolic).into(), + icon::from_name(wifi_icon(*strength)) + .size(24) + .symbolic(true) + .into(), column![text(name).size(14), Column::with_children(ipv4)] .width(Length::Fill) .into(), @@ -481,8 +492,9 @@ impl cosmic::Application for CosmicNetworkApplet { match state { ActiveConnectionState::Activating | ActiveConnectionState::Deactivating => { btn_content.push( - icon("process-working-symbolic", 24) - .style(Svg::Symbolic) + icon::from_name("process-working-symbolic") + .size(24) + .symbolic(true) .into(), ); } @@ -496,14 +508,15 @@ impl cosmic::Application for CosmicNetworkApplet { _ => {} }; known_wifi = known_wifi.push( - column![button(Button::Secondary) - .custom(vec![Row::with_children(btn_content) + column![button( + Row::with_children(btn_content) .align_items(Alignment::Center) .spacing(8) - .into()]) - .padding([8, 24]) - .style(button_style()) - .on_press(Message::Disconnect(name.clone()))] + ) + .style(Button::Standard) + .padding([8, 24]) + .style(button_style()) + .on_press(Message::Disconnect(name.clone()))] .align_items(Alignment::Center), ); } @@ -547,7 +560,9 @@ impl cosmic::Application for CosmicNetworkApplet { if self.nm_state.airplane_mode { content = content.push( column!( - icon("airplane-mode-symbolic", 48).style(Svg::Symbolic), + icon::from_name("airplane-mode-symbolic") + .size(48) + .symbolic(true), text(fl!("airplane-mode-on")).size(14), text(fl!("turn-off-airplane-mode")).size(12) ) @@ -562,40 +577,45 @@ impl cosmic::Application for CosmicNetworkApplet { let ssid = text(&known.ssid).size(14).width(Length::Fill); if known.working { btn_content.push( - icon("network-wireless-acquiring-symbolic", 24) - .style(Svg::Symbolic) + icon::from_name("network-wireless-acquiring-symbolic") + .size(24) + .symbolic(true) .into(), ); btn_content.push(ssid.into()); btn_content.push( - icon("process-working-symbolic", 24) - .style(Svg::Symbolic) + icon::from_name("process-working-symbolic") + .size(24) + .symbolic(true) .into(), ); } else if matches!(known.state, DeviceState::Unavailable) { btn_content.push( - icon("network-wireless-disconnected-symbolic", 24) - .style(Svg::Symbolic) + icon::from_name("network-wireless-disconnected-symbolic") + .size(24) + .symbolic(true) .into(), ); btn_content.push(ssid.into()); } else { btn_content.push( - icon(wifi_icon(known.strength), 24) - .style(Svg::Symbolic) + icon::from_name(wifi_icon(known.strength)) + .size(24) + .symbolic(true) .into(), ); btn_content.push(ssid.into()); } - let mut btn = button(Button::Secondary) - .custom(vec![Row::with_children(btn_content) + let mut btn = button( + Row::with_children(btn_content) .align_items(Alignment::Center) - .spacing(8) - .into()]) - .padding([8, 24]) - .width(Length::Fill) - .style(button_style()); + .spacing(8), + ) + .style(Button::Suggested) + .padding([8, 24]) + .width(Length::Fill) + .style(button_style()); btn = match known.state { DeviceState::Failed | DeviceState::Unknown @@ -615,27 +635,22 @@ impl cosmic::Application for CosmicNetworkApplet { } else { "go-next-symbolic" }; - let available_connections_btn = button(Button::Secondary) - .custom( - vec![ - text(fl!("visible-wireless-networks")) - .size(14) - .width(Length::Fill) - .height(Length::Fixed(24.0)) - .vertical_alignment(Vertical::Center) - .into(), - container(icon(dropdown_icon, 14).style(Svg::Symbolic)) - .align_x(Horizontal::Center) - .align_y(Vertical::Center) - .width(Length::Fixed(24.0)) - .height(Length::Fixed(24.0)) - .into(), - ] - .into(), - ) - .padding([8, 24]) - .style(button_style()) - .on_press(Message::ToggleVisibleNetworks); + let available_connections_btn = button(row![ + text(fl!("visible-wireless-networks")) + .size(14) + .width(Length::Fill) + .height(Length::Fixed(24.0)) + .vertical_alignment(Vertical::Center), + container(icon::from_name(dropdown_icon).size(14).symbolic(true)) + .align_x(Horizontal::Center) + .align_y(Vertical::Center) + .width(Length::Fixed(24.0)) + .height(Length::Fixed(24.0)), + ]) + .style(Button::Text) + .padding([8, 24]) + .style(button_style()) + .on_press(Message::ToggleVisibleNetworks); content = content.push(available_connections_btn); } if self.show_visible_networks { @@ -646,7 +661,9 @@ impl cosmic::Application for CosmicNetworkApplet { password, } => { let id = row![ - icon("network-wireless-acquiring-symbolic", 24).style(Svg::Symbolic), + icon::from_name("network-wireless-acquiring-symbolic") + .size(24) + .symbolic(true), text(&access_point.ssid).size(14), ] .align_items(Alignment::Center) @@ -663,15 +680,11 @@ impl cosmic::Application for CosmicNetworkApplet { .password(), container(text(fl!("router-wps-button"))).padding(8), row![ - button(Button::Secondary) - .custom(vec![container(text(fl!("cancel"))) - .padding([0, 24]) - .into()]) + button(container(text(fl!("cancel"))).padding([0, 24])) + .style(Button::Suggested) .on_press(Message::CancelNewConnection), - button(Button::Secondary) - .custom(vec![container(text(fl!("connect"))) - .padding([0, 24]) - .into()]) + button(container(text(fl!("connect"))).padding([0, 24])) + .style(Button::Suggested) .on_press(Message::SubmitPassword) ] .spacing(24) @@ -683,7 +696,9 @@ impl cosmic::Application for CosmicNetworkApplet { } NewConnectionState::Waiting(access_point) => { let id = row![ - icon("network-wireless-acquiring-symbolic", 24).style(Svg::Symbolic), + icon::from_name("network-wireless-acquiring-symbolic") + .size(24) + .symbolic(true), text(&access_point.ssid).size(14), ] .align_items(Alignment::Center) @@ -691,7 +706,9 @@ impl cosmic::Application for CosmicNetworkApplet { .spacing(12); let connecting = row![ id, - icon("process-working-symbolic", 24).style(Svg::Symbolic), + icon::from_name("process-working-symbolic") + .size(24) + .symbolic(true), ] .spacing(8) .padding([0, 24]); @@ -699,7 +716,9 @@ impl cosmic::Application for CosmicNetworkApplet { } NewConnectionState::Failure(access_point) => { let id = row![ - icon("network-wireless-error-symbolic", 24).style(Svg::Symbolic), + icon::from_name("network-wireless-error-symbolic") + .size(24) + .symbolic(true), text(&access_point.ssid).size(14), ] .align_items(Alignment::Center) @@ -711,13 +730,11 @@ impl cosmic::Application for CosmicNetworkApplet { text(fl!("unable-to-connect")), text(fl!("check-wifi-connection")), row![ - button(Button::Secondary) - .custom(vec![container(text("Cancel")).padding([0, 24]).into()]) + button(container(text("Cancel")).padding([0, 24])) + .style(Button::Suggested) .on_press(Message::CancelNewConnection), - button(Button::Secondary) - .custom(vec![container(text("Connect")) - .padding([0, 24]) - .into()]) + button(container(text("Connect")).padding([0, 24])) + .style(Button::Suggested) .on_press(Message::SelectWirelessAccessPoint( access_point.clone() )) @@ -741,20 +758,23 @@ impl cosmic::Application for CosmicNetworkApplet { { continue; } - let button = button(button_style()) - .custom(vec![row![ - icon(wifi_icon(ap.strength), 16).style(Svg::Symbolic), + let button = button( + row![ + icon::from_name(wifi_icon(ap.strength)) + .size(16) + .symbolic(true), text(&ap.ssid) .size(14) .height(Length::Fixed(24.0)) .vertical_alignment(Vertical::Center) ] .align_items(Alignment::Center) - .spacing(12) - .into()]) - .on_press(Message::SelectWirelessAccessPoint(ap.clone())) - .width(Length::Fill) - .padding([8, 24]); + .spacing(12), + ) + .style(button_style()) + .on_press(Message::SelectWirelessAccessPoint(ap.clone())) + .width(Length::Fill) + .padding([8, 24]); list_col.push(button.into()); } content = content diff --git a/cosmic-applet-notifications/Cargo.toml b/cosmic-applet-notifications/Cargo.toml index bc268fba..215e9527 100644 --- a/cosmic-applet-notifications/Cargo.toml +++ b/cosmic-applet-notifications/Cargo.toml @@ -10,8 +10,8 @@ libcosmic.workspace = true cosmic-time.workspace = true nix = "0.26" tokio = { version = "1.24.1", features = ["sync", "rt", "tracing", "macros", "net", "io-util", "io-std"] } -cosmic-notifications-util = { git = "https://github.com/pop-os/cosmic-notifications" } -cosmic-notifications-config = { git = "https://github.com/pop-os/cosmic-notifications" } +cosmic-notifications-util = { git = "https://github.com/edfloreshz/cosmic-notifications" } +cosmic-notifications-config = { git = "https://github.com/edfloreshz/cosmic-notifications" } # cosmic-notifications-util = { path = "../../cosmic-notifications-daemon/cosmic-notifications-util" } # cosmic-notifications-config = { path = "../../cosmic-notifications-daemon/cosmic-notifications-config" } tracing = "0.1" diff --git a/cosmic-applet-notifications/src/main.rs b/cosmic-applet-notifications/src/main.rs index 37fb6836..2068eb66 100644 --- a/cosmic-applet-notifications/src/main.rs +++ b/cosmic-applet-notifications/src/main.rs @@ -6,18 +6,15 @@ use cosmic::cosmic_config::{config_subscription, Config, CosmicConfigEntry}; use cosmic::iced::wayland::popup::{destroy_popup, get_popup}; use cosmic::iced::Limits; use cosmic::iced::{ - widget::{button, column, row, text, Row}, + widget::{column, row, text, Row}, window, Alignment, Length, Subscription, }; use cosmic::iced_core::alignment::Horizontal; -use cosmic::iced_core::image; -use cosmic::iced_widget::image::Handle; use cosmic::iced_style::application; use cosmic::iced_widget::{horizontal_rule, scrollable, Column}; -use cosmic::theme::Svg; -use cosmic::widget::{container, icon}; +use cosmic::widget::{button, container, icon}; use cosmic::Renderer; use cosmic::{Element, Theme}; use cosmic_notifications_config::NotificationsConfig; @@ -348,112 +345,113 @@ impl cosmic::Application for Notifications { continue; } let name = c.1[0].app_name.clone(); - let notif_elems: Vec<_> = - c.1.iter() - .rev() - .map(|n| { - let app_name = text(if n.app_name.len() > 24 { - Cow::from(format!( - "{:.26}...", - n.app_name.lines().next().unwrap_or_default() - )) - } else { - Cow::from(&n.app_name) - }) - .size(12) - .width(Length::Fill); - - let duration_since = text(duration_ago_msg(n)).size(12); - - let close_notif = - button(icon("window-close-symbolic", 16).style(Svg::Symbolic)) - .on_press(Message::Dismissed(n.id)) - .style(cosmic::theme::Button::Text); - Element::from( - column!( - match n.image() { - Some(cosmic_notifications_util::Image::File(path)) => { - row![ - icon(path.as_path(), 16), - app_name, - duration_since, - close_notif - ] - .spacing(8) - .align_items(Alignment::Center) - } - Some(cosmic_notifications_util::Image::Name(name)) => { - row![ - icon(name.as_str(), 16), - app_name, - duration_since, - close_notif - ] - .spacing(8) - .align_items(Alignment::Center) - } - Some(cosmic_notifications_util::Image::Data { - width, - height, - data, - }) => { - let handle = image::Handle::from_pixels( - *width, - *height, - data.clone(), - ); - row![ - icon(handle, 16), - app_name, - duration_since, - close_notif - ] - .spacing(8) - .align_items(Alignment::Center) - } - None => row![app_name, duration_since, close_notif] - .spacing(8) - .align_items(Alignment::Center), - }, - column![ - text(n.summary.lines().next().unwrap_or_default()) - .width(Length::Fill) - .size(14), - text(n.body.lines().next().unwrap_or_default()) - .width(Length::Fill) - .size(12) - ] - ) - .width(Length::Fill), - ) + let notif_elems: Vec<_> = c + .1 + .iter() + .rev() + .map(|n| { + let app_name = text(if n.app_name.len() > 24 { + Cow::from(format!( + "{:.26}...", + n.app_name.lines().next().unwrap_or_default() + )) + } else { + Cow::from(&n.app_name) }) - .collect(); + .size(12) + .width(Length::Fill); + + let duration_since = text(duration_ago_msg(n)).size(12); + + let close_notif = button( + icon::from_name("window-close-symbolic") + .size(16) + .symbolic(true), + ) + .on_press(Message::Dismissed(n.id)) + .style(cosmic::theme::Button::Text); + Element::from( + column!( + match n.image() { + Some(cosmic_notifications_util::Image::File(path)) => { + row![ + icon::from_path(PathBuf::from(path)).icon().size(16), + app_name, + duration_since, + close_notif + ] + .spacing(8) + .align_items(Alignment::Center) + } + Some(cosmic_notifications_util::Image::Name(name)) => { + row![ + icon::from_name(name.as_str()).size(16), + app_name, + duration_since, + close_notif + ] + .spacing(8) + .align_items(Alignment::Center) + } + Some(cosmic_notifications_util::Image::Data { + width, + height, + data, + }) => { + row![ + icon::from_raster_pixels(*width, *height, data.clone()) + .icon() + .size(16), + app_name, + duration_since, + close_notif + ] + .spacing(8) + .align_items(Alignment::Center) + } + None => row![app_name, duration_since, close_notif] + .spacing(8) + .align_items(Alignment::Center), + }, + column![ + text(n.summary.lines().next().unwrap_or_default()) + .width(Length::Fill) + .size(14), + text(n.body.lines().next().unwrap_or_default()) + .width(Length::Fill) + .size(12) + ] + ) + .width(Length::Fill), + ) + }) + .collect(); let show_more_icon = c.1.last().and_then(|n| { info!("app_icon: {:?}", &n.app_icon); if n.app_icon.is_empty() { match n.image().cloned() { - Some(Image::File(p)) => Some(cosmic::widget::IconSource::Path( - Cow::Owned(PathBuf::from(p)), - )), + Some(Image::File(p)) => { + Some(cosmic::widget::icon::from_path(PathBuf::from(p))) + } Some(Image::Name(name)) => { - Some(cosmic::widget::IconSource::Name(Cow::Owned(name))) + Some(cosmic::widget::icon::from_name(name).handle()) } Some(Image::Data { width, height, data, - }) => Some(cosmic::widget::IconSource::Handle(icon::Handle::Image( - Handle::from_pixels(width, height, data), - ))), + }) => Some(cosmic::widget::icon::from_raster_pixels( + width, height, data, + )), None => None, } } else if let Some(path) = url::Url::parse(&n.app_icon) .ok() .and_then(|u| u.to_file_path().ok()) { - Some(cosmic::widget::IconSource::Path(Cow::Owned(path))) + Some(cosmic::widget::icon::from_path(path)) } else { - Some(cosmic::widget::IconSource::Name(Cow::Borrowed(&n.app_icon))) + Some(cosmic::widget::icon::from_name(n.app_icon.clone()).handle()) } }); let card_list = anim!( @@ -499,7 +497,7 @@ impl cosmic::Application for Notifications { } // todo put into libcosmic doing so will fix the row_button's border radius -fn row_button(content: Vec>) -> cosmic::iced::widget::Button { +fn row_button(content: Vec>) -> cosmic::widget::Button { button( Row::with_children(content) .spacing(4) @@ -512,7 +510,7 @@ fn row_button(content: Vec>) -> cosmic::iced::widget::Button cosmic::widget::Icon { - icon(name, size).style(Svg::Symbolic) + icon::from_name(name).size(size).symbolic(true).icon() } fn duration_ago_msg(notification: &Notification) -> String { diff --git a/cosmic-applet-power/src/main.rs b/cosmic-applet-power/src/main.rs index 44f280b4..4b986a36 100644 --- a/cosmic-applet-power/src/main.rs +++ b/cosmic-applet-power/src/main.rs @@ -24,7 +24,7 @@ use cosmic::iced::{ window, Alignment, Length, Subscription, }; use cosmic::iced_style::application; -use cosmic::theme::{self, Svg}; +use cosmic::theme; use cosmic::{app::Command, Element, Theme}; use logind_zbus::manager::ManagerProxy; @@ -42,6 +42,8 @@ use crate::cosmic_session::CosmicSessionProxy; use crate::session_manager::SessionManagerProxy; pub fn main() -> cosmic::iced::Result { + localize::localize(); + cosmic::app::applet::run::(false, ()) } @@ -76,11 +78,19 @@ enum Message { } impl cosmic::Application for Power { - type Message = Message; type Executor = cosmic::SingleThreadExecutor; type Flags = (); + type Message = Message; const APP_ID: &'static str = "com.system76.CosmicAppletPower"; + fn core(&self) -> &cosmic::app::Core { + &self.core + } + + fn core_mut(&mut self) -> &mut cosmic::app::Core { + &mut self.core + } + fn init(core: cosmic::app::Core, _flags: ()) -> (Power, Command) { ( Power { @@ -92,16 +102,8 @@ impl cosmic::Application for Power { ) } - fn core(&self) -> &cosmic::app::Core { - &self.core - } - - fn core_mut(&mut self) -> &mut cosmic::app::Core { - &mut self.core - } - - fn style(&self) -> Option<::Style> { - Some(cosmic::app::applet::style()) + fn on_close_requested(&self, id: window::Id) -> Option { + Some(Message::Closed(id)) } fn subscription(&self) -> Subscription { @@ -294,11 +296,13 @@ impl cosmic::Application for Power { )) .size(16), row![ - button(theme::Button::Primary) - .custom(vec![text(fl!("confirm")).size(14).into()]) + button(text(fl!("confirm")).size(14)) + .padding(2) + .style(theme::Button::Suggested) .on_press(Message::Confirm), - button(theme::Button::Primary) - .custom(vec![text(fl!("cancel")).size(14).into()]) + button(text(fl!("cancel")).size(14)) + .padding(2) + .style(theme::Button::Standard) .on_press(Message::Cancel), ] .spacing(24) @@ -310,7 +314,8 @@ impl cosmic::Application for Power { container( container(content) .style(cosmic::theme::Container::custom(|theme| { - cosmic::iced_style::container::Appearance { + container::Appearance { + icon_color: Some(theme.cosmic().background.on.into()), text_color: Some(theme.cosmic().background.on.into()), background: Some( Color::from(theme.cosmic().background.base).into(), @@ -338,36 +343,37 @@ impl cosmic::Application for Power { } } - fn on_close_requested(&self, id: window::Id) -> Option { - Some(Message::Closed(id)) + fn style(&self) -> Option<::Style> { + Some(cosmic::app::applet::style()) } } // ### UI Helplers -fn row_button(content: Vec>) -> widget::Button { - button(applet_button_theme()) - .custom(vec![Row::with_children(content) +fn row_button(content: Vec>) -> cosmic::widget::Button { + button( + Row::with_children(content) .spacing(4) - .align_items(Alignment::Center) - .into()]) - .width(Length::Fill) - .padding([8, 24]) + .align_items(Alignment::Center), + ) + .style(applet_button_theme()) + .width(Length::Fill) + .padding([8, 24]) } -fn power_buttons<'a>(name: &'a str, msg: String) -> widget::Button<'a, Message, Renderer> { - widget::button( +fn power_buttons(name: &str, msg: String) -> cosmic::widget::Button { + cosmic::widget::button( column![text_icon(name, 40), text(msg).size(14)] .spacing(4) .align_items(Alignment::Center), ) .width(Length::Fill) .height(Length::Fixed(76.0)) - .style(theme::Button::Text) + .style(theme::Button::Standard) } fn text_icon(name: &str, size: u16) -> cosmic::widget::Icon { - icon(name, size).style(Svg::Symbolic) + icon::from_name(name).size(size).symbolic(true).icon() } // ### System helpers diff --git a/cosmic-applet-status-area/src/components/status_menu.rs b/cosmic-applet-status-area/src/components/status_menu.rs index fa804f44..1f32f60a 100644 --- a/cosmic-applet-status-area/src/components/status_menu.rs +++ b/cosmic-applet-status-area/src/components/status_menu.rs @@ -1,4 +1,5 @@ -use cosmic::{iced, theme}; +use cosmic::app::applet::applet_button_theme; +use cosmic::iced; use crate::subscriptions::status_notifier_item::{Layout, StatusNotifierItem}; @@ -107,27 +108,28 @@ fn layout_view(layout: &Layout, expanded: Option) -> cosmic::Element { let mut children: Vec> = vec![text.into()]; if is_submenu { - let icon = cosmic::widget::icon( - if is_expanded { - "go-down-symbolic" - } else { - "go-next-symbolic" - }, - 14, - ) - .style(theme::Svg::Symbolic); + let icon = cosmic::widget::icon::from_name(if is_expanded { + "go-down-symbolic" + } else { + "go-next-symbolic" + }) + .size(14) + .symbolic(true); children.push(icon.into()); } if let Some(icon_data) = i.icon_data() { let handle = iced::widget::image::Handle::from_memory(icon_data.to_vec()); children.insert(0, iced::widget::Image::new(handle).into()); } else if let Some(icon_name) = i.icon_name() { - let icon = cosmic::widget::icon(icon_name, 14).style(theme::Svg::Symbolic); + let icon = cosmic::widget::icon::from_name(icon_name) + .size(14) + .symbolic(true); children.insert(0, icon.into()); } if i.toggle_state() == Some(1) { - let icon = cosmic::widget::icon("emblem-ok-symbolic", 14) - .style(theme::Svg::Symbolic); + let icon = cosmic::widget::icon::from_name("emblem-ok-symbolic") + .size(14) + .symbolic(true); children.push(icon.into()); } let button = row_button(children).on_press(Msg::Click(i.id(), is_submenu)); @@ -158,13 +160,14 @@ fn layout_view(layout: &Layout, expanded: Option) -> cosmic::Element { .into() } -fn row_button(content: Vec>) -> iced::widget::Button { - cosmic::widget::button(cosmic::app::applet::applet_button_theme()) - .custom(vec![iced::widget::Row::with_children(content) +fn row_button(content: Vec>) -> cosmic::widget::Button { + cosmic::widget::button( + iced::widget::Row::with_children(content) .spacing(8) .align_items(iced::Alignment::Center) - .width(iced::Length::Fill) - .into()]) - .width(iced::Length::Fill) - .padding([8, 24]) + .width(iced::Length::Fill), + ) + .style(applet_button_theme()) + .width(iced::Length::Fill) + .padding([8, 24]) } diff --git a/cosmic-applet-tiling/Cargo.toml b/cosmic-applet-tiling/Cargo.toml index 4d70b3b1..12febab5 100644 --- a/cosmic-applet-tiling/Cargo.toml +++ b/cosmic-applet-tiling/Cargo.toml @@ -8,6 +8,7 @@ edition = "2021" [dependencies] libcosmic.workspace = true +cosmic-time.workspace = true once_cell = "1" i18n-embed = { version = "0.14.0", features = ["fluent-system", "desktop-requester"] } i18n-embed-fl = "0.7.0" diff --git a/cosmic-applet-tiling/data/icons/scalable/apps/com.system76.CosmicAppletTiling.Off.svg b/cosmic-applet-tiling/data/icons/scalable/apps/com.system76.CosmicAppletTiling.Off.svg new file mode 100644 index 00000000..ff4616b0 --- /dev/null +++ b/cosmic-applet-tiling/data/icons/scalable/apps/com.system76.CosmicAppletTiling.Off.svg @@ -0,0 +1,163 @@ + + + + + + + + + image/svg+xml + + Pop Symbolic Icon Theme + + + + + + + + + + + + + Pop Symbolic Icon Theme + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cosmic-applet-tiling/data/icons/scalable/apps/com.system76.CosmicAppletTiling.On.svg b/cosmic-applet-tiling/data/icons/scalable/apps/com.system76.CosmicAppletTiling.On.svg new file mode 100644 index 00000000..d57bd0d5 --- /dev/null +++ b/cosmic-applet-tiling/data/icons/scalable/apps/com.system76.CosmicAppletTiling.On.svg @@ -0,0 +1,161 @@ + + + + + + + image/svg+xml + + Pop Symbolic Icon Theme + + + + + + + + + + + + + Pop Symbolic Icon Theme + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cosmic-applet-tiling/data/icons/scalable/apps/com.system76.CosmicAppletTiling.svg b/cosmic-applet-tiling/data/icons/scalable/apps/com.system76.CosmicAppletTiling.svg deleted file mode 100644 index 3d5c7509..00000000 --- a/cosmic-applet-tiling/data/icons/scalable/apps/com.system76.CosmicAppletTiling.svg +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cosmic-applet-tiling/src/window.rs b/cosmic-applet-tiling/src/window.rs index ed303de7..90ffcdef 100644 --- a/cosmic-applet-tiling/src/window.rs +++ b/cosmic-applet-tiling/src/window.rs @@ -1,27 +1,32 @@ use crate::fl; use cosmic::app::Core; -use cosmic::cosmic_theme::palette::rgb::Rgb; use cosmic::iced::wayland::popup::{destroy_popup, get_popup}; use cosmic::iced::window::Id; -use cosmic::iced::{Command, Limits}; +use cosmic::iced::{Command, Length, Limits, Subscription}; use cosmic::iced_runtime::core::window; use cosmic::iced_style::application; -use cosmic::theme::{Button, Svg}; -use cosmic::widget::{button, list_column, settings, spin_button, text, toggler}; +use cosmic::widget::{column, container, divider, spin_button, text}; use cosmic::{Element, Theme}; +use cosmic_time::{anim, chain, id, Timeline}; +use once_cell::sync::Lazy; +use std::time::Instant; +use cosmic::iced_widget::row; const ID: &str = "com.system76.CosmicAppletTiling"; +const ON: &str = "com.system76.CosmicAppletTiling.On"; +const OFF: &str = "com.system76.CosmicAppletTiling.Off"; + +static TILE_WINDOWS: Lazy = Lazy::new(id::Toggler::unique); +static SHOW_ACTIVE_HINTS: Lazy = Lazy::new(id::Toggler::unique); #[derive(Default)] pub struct Window { core: Core, popup: Option, + timeline: Timeline, id_ctr: u128, tile_windows: bool, - show_window_titles: bool, show_active_hint: bool, - active_border_radius: spin_button::Model, - active_hint_color: Rgb, gaps: spin_button::Model, } @@ -29,11 +34,9 @@ pub struct Window { pub enum Message { TogglePopup, PopupClosed(Id), - ToggleTileWindows(bool), - ToggleShowWindowTitles(bool), - ToggleShowActiveHint(bool), - HandleActiveBorderRadius(spin_button::Message), - SetActiveHintColor(Rgb), + Frame(Instant), + ToggleTileWindows(chain::Toggler, bool), + ToggleShowActiveHint(chain::Toggler, bool), HandleGaps(spin_button::Message), } @@ -57,17 +60,24 @@ impl cosmic::Application for Window { ) -> (Self, Command>) { let window = Window { core, - active_border_radius: spin_button::Model::default().max(99).min(0).step(1), gaps: spin_button::Model::default().max(99).min(0).step(1), ..Default::default() }; (window, Command::none()) } - fn on_close_requested(&self, id: window::Id) -> Option { + fn on_close_requested(&self, id: Id) -> Option { Some(Message::PopupClosed(id)) } + fn subscription(&self) -> Subscription { + let timeline = self + .timeline + .as_subscription() + .map(|(_, now)| Message::Frame(now)); + Subscription::batch(vec![timeline]) + } + fn update(&mut self, message: Self::Message) -> Command> { match message { Message::TogglePopup => { @@ -94,18 +104,15 @@ impl cosmic::Application for Window { self.popup = None; } } - Message::ToggleTileWindows(toggled) => self.tile_windows = toggled, - Message::ToggleShowWindowTitles(toggled) => self.show_window_titles = toggled, - Message::ToggleShowActiveHint(toggled) => self.show_active_hint = toggled, - Message::HandleActiveBorderRadius(msg) => match msg { - spin_button::Message::Increment => self - .active_border_radius - .update(spin_button::Message::Increment), - spin_button::Message::Decrement => self - .active_border_radius - .update(spin_button::Message::Decrement), - }, - Message::SetActiveHintColor(_) => {} + Message::Frame(now) => self.timeline.now(now), + Message::ToggleTileWindows(chain, toggled) => { + self.timeline.set_chain(chain).start(); + self.tile_windows = toggled + } + Message::ToggleShowActiveHint(chain, toggled) => { + self.timeline.set_chain(chain).start(); + self.show_active_hint = toggled + } Message::HandleGaps(msg) => match msg { spin_button::Message::Increment => { self.gaps.update(spin_button::Message::Increment) @@ -121,64 +128,66 @@ impl cosmic::Application for Window { fn view(&self) -> Element { self.core .applet_helper - .icon_button(ID) + .icon_button(OFF) .on_press(Message::TogglePopup) - .style(Button::Text) .into() } fn view_window(&self, _id: Id) -> Element { - let content_list = list_column() - .add(settings::item( - fl!("tile-windows"), - toggler(None, self.tile_windows, |value| { - Message::ToggleTileWindows(value) - }), - )) - .add(settings::item( - fl!("floating-window-exceptions"), - button(Button::Card).icon(Svg::Symbolic, "arrow-right", 16), - )) - .add( - settings::view_section(fl!("shortcuts")) - .add(settings::item( - fl!("launcher"), - text(format!("{} + /", fl!("super"))), - )) - .add(settings::item( - fl!("navigate-windows"), - text(format!("{} + {}", fl!("super"), fl!("arrow-keys"))), - )) - .add(settings::item( - fl!("toggle-tiling"), - text(format!("{} + Y", fl!("super"))), - )) - .add(settings::item(fl!("view-all"), text(""))), + let content_list = cosmic::widget::column() + .padding(20) + .spacing(10) + .push( + container( + anim!( + TILE_WINDOWS, + &self.timeline, + fl!("tile-windows"), + self.tile_windows, + |chain, enable| { Message::ToggleTileWindows(chain, enable) }, + ) + .text_size(14) + .width(Length::Fill), + ) + .padding([0, 12]), ) - .add(settings::item( - fl!("show-window-titles"), - toggler(None, self.show_window_titles, |value| { - Message::ToggleShowWindowTitles(value) - }), - )) - .add(settings::item( - fl!("show-active-hint"), - toggler(None, self.show_active_hint, |value| { - Message::ToggleShowActiveHint(value) - }), - )) - .add(settings::item( - fl!("active-border-radius"), - spin_button( - self.active_border_radius.value.to_string(), - Message::HandleActiveBorderRadius, - ), - )) - .add(settings::item(fl!("active-hint-color"), text("TODO"))) - .add(settings::item( - fl!("gaps"), + .push(divider::horizontal::light()) + .push( + column() + .push(row!( + text(fl!("launcher")).size(14).width(Length::Fill), + text(format!("{} + /", fl!("super"))).size(14), + )) + .push(row!( + text(fl!("navigate-windows")).size(14).width(Length::Fill), + text(format!("{} + {}", fl!("super"), fl!("arrow-keys"))).size(14), + )) + .push(row!( + text(fl!("toggle-tiling")).size(14).width(Length::Fill), + text(format!("{} + Y", fl!("super"))).size(14), + )) + .spacing(10) + .padding([0, 20, 0, 20]), + ) + .push(divider::horizontal::light()) + .push( + container( + anim!( + SHOW_ACTIVE_HINTS, + &self.timeline, + fl!("show-active-hint"), + self.show_active_hint, + |chain, enable| { Message::ToggleShowActiveHint(chain, enable) }, + ) + .text_size(14) + .width(Length::Fill), + ) + .padding([0, 12]), + ) + .push(row!( + text(fl!("gaps")).size(14).width(Length::Fill), spin_button(self.gaps.value.to_string(), Message::HandleGaps), - )); + ).padding([0, 10, 0, 10])); self.core.applet_helper.popup_container(content_list).into() } diff --git a/cosmic-applet-time/src/main.rs b/cosmic-applet-time/src/main.rs index cd26611f..a359a550 100644 --- a/cosmic-applet-time/src/main.rs +++ b/cosmic-applet-time/src/main.rs @@ -179,24 +179,20 @@ impl cosmic::Application for Time { self.core.applet_helper.anchor, PanelAnchor::Top | PanelAnchor::Bottom ) { - column![text(self.now.format("%b %-d %-I:%M %p").to_string()).size(14)] + column![cosmic::widget::text(self.now.format("%b %-d %-I:%M %p").to_string()).size(14)] } else { let mut date_time_col = column![ - icon( - "emoji-recent-symbolic", - self.core.applet_helper.suggested_size().0 - ) - .style(theme::Svg::Symbolic), + icon::from_name("emoji-recent-symbolic") + .size(self.core.applet_helper.suggested_size().0) + .symbolic(true), text(self.now.format("%I").to_string()).size(14), text(self.now.format("%M").to_string()).size(14), text(self.now.format("%p").to_string()).size(14), vertical_space(Length::Fixed(4.0)), // TODO better calendar icon? - icon( - "calendar-go-today-symbolic", - self.core.applet_helper.suggested_size().0 - ) - .style(theme::Svg::Symbolic), + icon::from_name("calendar-go-today-symbolic") + .size(self.core.applet_helper.suggested_size().0) + .symbolic(true), ] .align_items(Alignment::Center) .spacing(4); @@ -207,7 +203,7 @@ impl cosmic::Application for Time { }, ) .on_press(Message::TogglePopup) - .style(theme::Button::Text); + .style(theme::iced::Button::Text); if let Some(tracker) = self.rectangle_tracker.as_ref() { tracker.container(0, button).into() diff --git a/cosmic-applet-workspaces/src/components/app.rs b/cosmic-applet-workspaces/src/components/app.rs index e0011e26..9cb3eada 100644 --- a/cosmic-applet-workspaces/src/components/app.rs +++ b/cosmic-applet-workspaces/src/components/app.rs @@ -5,7 +5,6 @@ use cosmic::iced::mouse::{self, ScrollDelta}; use cosmic::iced::widget::{column, container, row, text}; use cosmic::iced::{subscription, widget::button, Event::Mouse, Length, Subscription}; use cosmic::iced_style::application; -use cosmic::theme::Button; use cosmic::{Element, Theme}; use cosmic_protocols::workspace::v1::client::zcosmic_workspace_handle_v1; @@ -135,9 +134,13 @@ impl cosmic::Application for IcedWorkspacesApplet { .padding(0); Some( btn.style(match w.1 { - Some(zcosmic_workspace_handle_v1::State::Active) => Button::Primary, - Some(zcosmic_workspace_handle_v1::State::Urgent) => Button::Destructive, - None => Button::Secondary, + Some(zcosmic_workspace_handle_v1::State::Active) => { + cosmic::theme::iced::Button::Primary + } + Some(zcosmic_workspace_handle_v1::State::Urgent) => { + cosmic::theme::iced::Button::Destructive + } + None => cosmic::theme::iced::Button::Secondary, _ => return None, }) .into(), diff --git a/cosmic-panel-button/src/main.rs b/cosmic-panel-button/src/main.rs index 7c10276b..079f8110 100644 --- a/cosmic-panel-button/src/main.rs +++ b/cosmic-panel-button/src/main.rs @@ -1,3 +1,4 @@ +use cosmic::iced_widget::text; use cosmic::{app, iced, iced_style::application, theme::Theme}; use freedesktop_desktop_entry::DesktopEntry; use std::{env, fs, process::Command}; @@ -52,8 +53,8 @@ impl cosmic::Application for Button { fn view(&self) -> cosmic::Element { // TODO icon? - cosmic::widget::button(cosmic::theme::Button::Text) - .text(&self.desktop.name) + cosmic::widget::button(text(&self.desktop.name)) + .style(cosmic::theme::Button::Text) .on_press(Msg::Press) .into() } @@ -61,8 +62,7 @@ impl cosmic::Application for Button { pub fn main() -> iced::Result { let id = env::args() - .skip(1) - .next() + .nth(1) .expect("Requires desktop file id as argument."); let filename = format!("{id}.desktop");