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