From f0dd262d5df1232ef8dbf0cf3af5bf415e474659 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Fri, 10 Jan 2025 18:34:41 +0100 Subject: [PATCH] fix: libcosmic api changes --- Cargo.lock | 13 --------- cosmic-settings/Cargo.toml | 1 - .../pages/desktop/appearance/font_config.rs | 12 ++++---- .../src/pages/desktop/appearance/mod.rs | 28 +++++++++++++------ 4 files changed, 25 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e549d8c..f228f6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1684,7 +1684,6 @@ dependencies = [ "udev", "upower_dbus", "url", - "ustr", "xkb-data", "zbus 4.4.0", "zbus_polkit", @@ -7487,18 +7486,6 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" -[[package]] -name = "ustr" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18b19e258aa08450f93369cf56dd78063586adf19e92a75b338a800f799a0208" -dependencies = [ - "ahash 0.8.11", - "byteorder", - "lazy_static", - "parking_lot 0.12.3", -] - [[package]] name = "usvg" version = "0.42.0" diff --git a/cosmic-settings/Cargo.toml b/cosmic-settings/Cargo.toml index 1d18f3d..172dadb 100644 --- a/cosmic-settings/Cargo.toml +++ b/cosmic-settings/Cargo.toml @@ -67,7 +67,6 @@ url = "2.5.2" xkb-data = "0.2.1" zbus = { version = "4.4.0", features = ["tokio"], optional = true } zbus_polkit = { version = "4.0.0" } -ustr = "1.0.0" fontdb = "0.16.2" fixed_decimal = "0.5.6" mime = "0.3.17" diff --git a/cosmic-settings/src/pages/desktop/appearance/font_config.rs b/cosmic-settings/src/pages/desktop/appearance/font_config.rs index c7c6471..ce0c7d9 100644 --- a/cosmic-settings/src/pages/desktop/appearance/font_config.rs +++ b/cosmic-settings/src/pages/desktop/appearance/font_config.rs @@ -12,7 +12,6 @@ use cosmic::{ Apply, Element, Task, }; use cosmic_config::ConfigSet; -use ustr::Ustr; const INTERFACE_FONT: &str = "interface_font"; const MONOSPACE_FONT: &str = "monospace_font"; @@ -67,7 +66,7 @@ pub fn load_font_families() -> (Vec>, Vec>) { pub fn selection_context<'a>( families: &'a [Arc], search: &'a str, - current_font: &'a str, + current_font: &str, system: bool, ) -> Element<'a, super::Message> { let space_l = theme::active().cosmic().spacing.space_l; @@ -152,12 +151,10 @@ impl Model { match message { Message::InterfaceFontFamily(id) => { if let Some(family) = self.interface_font_families.get(id) { - let family = Ustr::from(family); - update_config( INTERFACE_FONT, FontConfig { - family, + family: family.to_string(), weight: cosmic::iced::font::Weight::Normal, style: cosmic::iced::font::Style::Normal, stretch: cosmic::iced::font::Stretch::Normal, @@ -166,8 +163,9 @@ impl Model { self.interface_font_family = Some(id); + let family = family.clone(); tokio::spawn(async move { - set_gnome_font_name(family.as_str()).await; + set_gnome_font_name(family.as_ref()).await; }); } } @@ -191,7 +189,7 @@ impl Model { update_config( MONOSPACE_FONT, FontConfig { - family: Ustr::from(family), + family: family.to_string(), weight: cosmic::iced::font::Weight::Normal, style: cosmic::iced::font::Style::Normal, stretch: cosmic::iced::font::Stretch::Normal, diff --git a/cosmic-settings/src/pages/desktop/appearance/mod.rs b/cosmic-settings/src/pages/desktop/appearance/mod.rs index d6be60d..f704f6d 100644 --- a/cosmic-settings/src/pages/desktop/appearance/mod.rs +++ b/cosmic-settings/src/pages/desktop/appearance/mod.rs @@ -1550,10 +1550,16 @@ impl page::Page for Page { } else { &self.font_filter }; - let current_font = cosmic::config::interface_font().family.as_str(); - font_config::selection_context(filter, &self.font_search, current_font, true) - .map(crate::pages::Message::Appearance) + let current_font = cosmic::config::interface_font(); + + font_config::selection_context( + filter, + &self.font_search, + current_font.family.as_str(), + true, + ) + .map(crate::pages::Message::Appearance) } ContextView::MonospaceFont => { @@ -1562,10 +1568,16 @@ impl page::Page for Page { } else { &self.font_filter }; - let current_font = cosmic::config::monospace_font().family.as_str(); - font_config::selection_context(filter, &self.font_search, current_font, false) - .map(crate::pages::Message::Appearance) + let current_font = cosmic::config::monospace_font(); + + font_config::selection_context( + filter, + &self.font_search, + current_font.family.as_str(), + false, + ) + .map(crate::pages::Message::Appearance) } ContextView::IconsAndToolkit => self.icons_and_toolkit(), @@ -2065,13 +2077,13 @@ pub fn experimental() -> Section { let system_font = crate::widget::go_next_with_item( &descriptions[interface_font_txt], - text::body(cosmic::config::interface_font().family.as_str()), + text::body(cosmic::config::interface_font().family), Message::DisplaySystemFont, ); let mono_font = crate::widget::go_next_with_item( &descriptions[monospace_font_txt], - text::body(cosmic::config::monospace_font().family.as_str()), + text::body(cosmic::config::monospace_font().family), Message::DisplayMonoFont, );