diff --git a/Cargo.lock b/Cargo.lock index e466a42..1ca46ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -749,43 +749,20 @@ dependencies = [ "libc", ] -[[package]] -name = "cosmic-config" -version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic?tag=cosmic-config-derive#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" -dependencies = [ - "atomicwrites", - "cosmic-config-derive 0.1.0 (git+https://github.com/pop-os/libcosmic?tag=cosmic-config-derive)", - "dirs 5.0.1", - "iced_futures 0.6.0 (git+https://github.com/pop-os/libcosmic?tag=cosmic-config-derive)", - "notify", - "ron", - "serde", -] - [[package]] name = "cosmic-config" version = "0.1.0" source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "atomicwrites", - "cosmic-config-derive 0.1.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", + "cosmic-config-derive", "dirs 5.0.1", - "iced_futures 0.6.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", + "iced_futures", "notify", "ron", "serde", ] -[[package]] -name = "cosmic-config-derive" -version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic?tag=cosmic-config-derive#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" -dependencies = [ - "quote", - "syn 1.0.109", -] - [[package]] name = "cosmic-config-derive" version = "0.1.0" @@ -798,10 +775,10 @@ dependencies = [ [[package]] name = "cosmic-panel-config" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-panel#1ef8ca7dd07bbbc6bd86ce8421dc3c759d4a837b" +source = "git+https://github.com/pop-os/cosmic-panel?branch=bg_jammy#89e47c3a57249c353dd8c4c19bea037d133f98f7" dependencies = [ "anyhow", - "cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic?tag=cosmic-config-derive)", + "cosmic-config", "ron", "serde", "tracing", @@ -817,7 +794,6 @@ dependencies = [ "async-channel", "bytecheck", "color-eyre", - "cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic?tag=cosmic-config-derive)", "cosmic-panel-config", "cosmic-settings-page", "cosmic-settings-system", @@ -899,7 +875,7 @@ version = "0.1.0" source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "anyhow", - "cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", + "cosmic-config", "csscolorparser", "directories", "lazy_static", @@ -2103,8 +2079,8 @@ version = "0.9.0" source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "iced_accessibility", - "iced_core 0.9.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", - "iced_futures 0.6.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", + "iced_core", + "iced_futures", "iced_renderer", "iced_sctk", "iced_widget", @@ -2122,18 +2098,6 @@ dependencies = [ "accesskit_unix", ] -[[package]] -name = "iced_core" -version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic?tag=cosmic-config-derive#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" -dependencies = [ - "bitflags 1.3.2", - "instant", - "log", - "thiserror", - "twox-hash", -] - [[package]] name = "iced_core" version = "0.9.0" @@ -2149,25 +2113,13 @@ dependencies = [ "twox-hash", ] -[[package]] -name = "iced_futures" -version = "0.6.0" -source = "git+https://github.com/pop-os/libcosmic?tag=cosmic-config-derive#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" -dependencies = [ - "futures", - "iced_core 0.9.0 (git+https://github.com/pop-os/libcosmic?tag=cosmic-config-derive)", - "log", - "wasm-bindgen-futures", - "wasm-timer", -] - [[package]] name = "iced_futures" version = "0.6.0" source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "futures", - "iced_core 0.9.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", + "iced_core", "log", "tokio", "wasm-bindgen-futures", @@ -2182,7 +2134,7 @@ dependencies = [ "bitflags 1.3.2", "bytemuck", "glam", - "iced_core 0.9.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", + "iced_core", "image", "kamadak-exif", "log", @@ -2209,8 +2161,8 @@ version = "0.1.0" source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "iced_accessibility", - "iced_core 0.9.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", - "iced_futures 0.6.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", + "iced_core", + "iced_futures", "smithay-client-toolkit 0.17.0", "thiserror", ] @@ -2223,7 +2175,7 @@ dependencies = [ "enum-repr", "float-cmp", "futures", - "iced_futures 0.6.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", + "iced_futures", "iced_graphics", "iced_runtime", "iced_style", @@ -2241,7 +2193,7 @@ name = "iced_style" version = "0.8.0" source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ - "iced_core 0.9.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", + "iced_core", "once_cell", "palette", ] @@ -2611,13 +2563,13 @@ version = "0.1.0" source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "apply", - "cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", + "cosmic-config", "cosmic-theme", "derive_setters", "fraction", "freedesktop-icons", "iced", - "iced_core 0.9.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", + "iced_core", "iced_runtime", "iced_sctk", "iced_style", diff --git a/app/Cargo.toml b/app/Cargo.toml index 65b2b8b..e2c691e 100644 --- a/app/Cargo.toml +++ b/app/Cargo.toml @@ -27,8 +27,7 @@ tokio = "1.27.0" downcast-rs = "1.2.0" log = "0.4" env_logger = "0.10" -cosmic-panel-config = { git = "https://github.com/pop-os/cosmic-panel" } -cosmic-config = { git = "https://github.com/pop-os/libcosmic", tag = "cosmic-config-derive" } +cosmic-panel-config = { git = "https://github.com/pop-os/cosmic-panel", branch = "bg_jammy" } [dependencies.i18n-embed] version = "0.13.8" diff --git a/app/src/pages/desktop/panel/mod.rs b/app/src/pages/desktop/panel/mod.rs index 4e45356..7cd2f85 100644 --- a/app/src/pages/desktop/panel/mod.rs +++ b/app/src/pages/desktop/panel/mod.rs @@ -1,4 +1,5 @@ use cosmic::{ + cosmic_config::{self, CosmicConfigEntry}, iced::widget::{button, container, horizontal_space, pick_list, row}, iced::Length, iced_widget::slider, @@ -9,8 +10,9 @@ use cosmic::{ }; use apply::Apply; -use cosmic_config::CosmicConfigEntry; -use cosmic_panel_config::{AutoHide, CosmicPanelConfig, CosmicPanelOuput, PanelAnchor, PanelSize}; +use cosmic_panel_config::{ + AutoHide, CosmicPanelBackground, CosmicPanelConfig, CosmicPanelOuput, PanelAnchor, PanelSize, +}; use cosmic_settings_page::{self as page, section, Section}; use slotmap::SlotMap; use std::{borrow::Cow, collections::HashMap}; @@ -21,7 +23,6 @@ pub struct Page { config_helper: Option, panel_config: Option, // TODO move these into panel config - appearance: Appearance, pub outputs: HashMap, } @@ -39,7 +40,6 @@ impl Default for Page { Self { config_helper, panel_config, - appearance: Appearance::Dark, outputs: HashMap::new(), } } @@ -143,9 +143,10 @@ pub fn style() -> Section { ]) .view::(|_binder, page, section| { let descriptions = §ion.descriptions; - let panel_config = match page.panel_config.as_ref() { - Some(panel_config) => panel_config, - None => return Element::from(text(fl!("unknown"))), + let panel_config = if let Some(panel_config) = page.panel_config.as_ref() { + panel_config + } else { + return Element::from(text(fl!("unknown"))); }; settings::view_section(§ion.title) .add(settings::item( @@ -164,7 +165,7 @@ pub fn style() -> Section { &descriptions[2], pick_list( Cow::from(vec![Appearance::Match, Appearance::Light, Appearance::Dark]), - Some(page.appearance), + panel_config.background.clone().try_into().ok(), Message::Appearance, ), )) @@ -204,18 +205,9 @@ pub fn style() -> Section { &descriptions[4], row![ text(fl!("number", HashMap::from_iter(vec![("number", 0)]))), - slider( - 0..=100, - (match panel_config.background { - cosmic_panel_config::CosmicPanelBackground::ThemeDefault(Some( - a, - )) - | cosmic_panel_config::CosmicPanelBackground::Color([_, _, _, a]) => - a, - _ => 0.0, - } * 100.0) as i32, - |v| Message::Opacity(v as f32 / 100.0), - ), + slider(0..=100, (panel_config.opacity * 100.0) as i32, |v| { + Message::Opacity(v as f32 / 100.0) + },), text(fl!("number", HashMap::from_iter(vec![("number", 100)]))), ] .spacing(12), @@ -358,6 +350,28 @@ impl ToString for Appearance { } } +impl TryFrom for Appearance { + type Error = (); + fn try_from(value: CosmicPanelBackground) -> Result { + match value { + CosmicPanelBackground::ThemeDefault => Ok(Appearance::Match), + CosmicPanelBackground::Light => Ok(Appearance::Light), + CosmicPanelBackground::Dark => Ok(Appearance::Dark), + _ => Err(()), + } + } +} + +impl From for CosmicPanelBackground { + fn from(appearance: Appearance) -> Self { + match appearance { + Appearance::Match => CosmicPanelBackground::ThemeDefault, + Appearance::Light => CosmicPanelBackground::Light, + Appearance::Dark => CosmicPanelBackground::Dark, + } + } +} + #[derive(Clone, Debug)] pub enum Message { // panel messages @@ -424,8 +438,13 @@ impl Page { _ = panel_config.write_entry(helper); } - Message::Appearance(_) => { - //TODO update panel config to support these kinds of configs + Message::Appearance(a) => { + let helper = self.config_helper.as_ref().unwrap(); + let panel_config = self.panel_config.as_mut().unwrap(); + + panel_config.background = a.into(); + + _ = panel_config.write_entry(helper); } Message::ExtendToEdge(enabled) => { let helper = self.config_helper.as_ref().unwrap(); @@ -439,14 +458,7 @@ impl Page { let helper = self.config_helper.as_ref().unwrap(); let panel_config = self.panel_config.as_mut().unwrap(); - match &mut panel_config.background { - cosmic_panel_config::CosmicPanelBackground::ThemeDefault(o) => { - *o = Some(opacity); - } - cosmic_panel_config::CosmicPanelBackground::Color([_, _, _, o]) => { - *o = opacity; - } - } + panel_config.opacity = opacity; _ = panel_config.write_entry(helper); }