Add cosmic-comp-config feature
This commit is contained in:
parent
7c9f04adcc
commit
9d56b0d551
4 changed files with 51 additions and 36 deletions
|
|
@ -112,6 +112,7 @@ gettext = ["dep:gettext-rs"]
|
|||
|
||||
# Default features for Linux
|
||||
linux = [
|
||||
"cosmic-comp-config",
|
||||
"page-accessibility",
|
||||
"page-about",
|
||||
"page-bluetooth",
|
||||
|
|
@ -133,9 +134,9 @@ linux = [
|
|||
|
||||
# Pages
|
||||
page-accessibility = [
|
||||
"cosmic-comp-config",
|
||||
"dep:sctk",
|
||||
"dep:cosmic-protocols",
|
||||
"dep:cosmic-comp-config",
|
||||
"dep:cosmic-settings-config",
|
||||
"dep:cosmic-settings-daemon-config",
|
||||
"dep:cosmic-settings-accessibility-subscription",
|
||||
|
|
@ -151,14 +152,14 @@ page-date = ["dep:timedate-zbus", "dep:zbus"]
|
|||
page-default-apps = ["dep:cosmic-settings-config", "dep:mime-apps"]
|
||||
page-display = ["dep:udev"]
|
||||
page-input = [
|
||||
"cosmic-comp-config",
|
||||
"gettext",
|
||||
"dep:cosmic-comp-config",
|
||||
"dep:cosmic-settings-config",
|
||||
"dep:udev",
|
||||
"dep:xkeysym",
|
||||
"wayland",
|
||||
]
|
||||
page-legacy-applications = ["dep:cosmic-comp-config"]
|
||||
page-legacy-applications = ["cosmic-comp-config", "dep:cosmic-randr"]
|
||||
page-networking = [
|
||||
"dep:cosmic-settings-network-manager-subscription",
|
||||
"xdg-portal",
|
||||
|
|
@ -170,15 +171,20 @@ page-power = ["dep:upower_dbus", "dep:zbus"]
|
|||
page-region = ["gettext", "dep:locales-rs", "dep:locale1", "dep:zbus"]
|
||||
page-sound = ["dep:cosmic-settings-sound-subscription"]
|
||||
page-users = ["xdg-portal", "dep:accounts-zbus", "dep:zbus", "dep:zbus_polkit"]
|
||||
page-window-management = ["dep:cosmic-settings-config"]
|
||||
page-workspaces = ["dep:cosmic-comp-config"]
|
||||
page-window-management = ["cosmic-comp-config", "dep:cosmic-settings-config"]
|
||||
page-workspaces = ["cosmic-comp-config"]
|
||||
|
||||
# Other features
|
||||
a11y = ["libcosmic/a11y"]
|
||||
ashpd = ["dep:ashpd"]
|
||||
cosmic-comp-config = ["dep:cosmic-comp-config"]
|
||||
dbus-config = ["libcosmic/dbus-config", "cosmic-config/dbus"]
|
||||
single-instance = ["libcosmic/single-instance"]
|
||||
test = []
|
||||
wayland = ["libcosmic/wayland", "dep:cosmic-panel-config", "dep:cosmic-randr"]
|
||||
wayland = [
|
||||
"libcosmic/wayland",
|
||||
"dep:cosmic-panel-config",
|
||||
"dep:cosmic-randr"
|
||||
]
|
||||
wgpu = ["libcosmic/wgpu"]
|
||||
xdg-portal = ["ashpd", "libcosmic/xdg-portal"]
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ use cosmic::{
|
|||
settings, text_input,
|
||||
},
|
||||
};
|
||||
#[cfg(any(feature = "page-window-management", feature = "page-accessibility"))]
|
||||
#[cfg(feature = "cosmic-comp-config")]
|
||||
use cosmic_comp_config::CosmicCompConfig;
|
||||
#[cfg(feature = "wayland")]
|
||||
use cosmic_panel_config::CosmicPanelConfig;
|
||||
|
|
@ -169,7 +169,7 @@ pub enum Message {
|
|||
PageMessage(crate::pages::Message),
|
||||
#[cfg(feature = "wayland")]
|
||||
PanelConfig(Box<CosmicPanelConfig>),
|
||||
#[cfg(any(feature = "page-window-management", feature = "page-accessibility"))]
|
||||
#[cfg(feature = "cosmic-comp-config")]
|
||||
CompConfig(Box<CosmicCompConfig>),
|
||||
SearchActivate,
|
||||
SearchActivateWith(String),
|
||||
|
|
@ -358,7 +358,7 @@ impl cosmic::Application for SettingsApp {
|
|||
Message::PanelConfig(Box::new(update.config))
|
||||
}),
|
||||
page.subscription(self.core()).map(Message::PageMessage),
|
||||
#[cfg(any(feature = "page-window-management", feature = "page-accessibility"))]
|
||||
#[cfg(feature = "cosmic-comp-config")]
|
||||
self.core()
|
||||
.watch_config::<CosmicCompConfig>("com.system76.CosmicComp")
|
||||
.map(|update| {
|
||||
|
|
@ -780,7 +780,7 @@ impl cosmic::Application for SettingsApp {
|
|||
return Task::batch(tasks);
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "page-window-management", feature = "page-accessibility"))]
|
||||
#[cfg(feature = "cosmic-comp-config")]
|
||||
Message::CompConfig(comp_config) => {
|
||||
let mut tasks = Vec::new();
|
||||
|
||||
|
|
|
|||
|
|
@ -42,11 +42,11 @@ pub struct Content {
|
|||
tk_config: Option<Config>,
|
||||
|
||||
comp_config: cosmic_config::Config,
|
||||
clip_floating: bool,
|
||||
clip_tiled: bool,
|
||||
shadow_tiled: bool,
|
||||
#[cfg(feature = "cosmic-comp-config")]
|
||||
appearance_conf: cosmic_comp_config::AppearanceConfig,
|
||||
}
|
||||
|
||||
#[cfg(feature = "cosmic-comp-config")]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum CornerMessage {
|
||||
ClipFloating(bool),
|
||||
|
|
@ -79,6 +79,7 @@ impl From<&theme_manager::Manager> for Content {
|
|||
fn from(theme_manager: &theme_manager::Manager) -> Self {
|
||||
let theme = theme_manager.theme();
|
||||
let comp_config = cosmic_config::Config::new("com.system76.CosmicComp", 1).unwrap();
|
||||
#[cfg(feature = "cosmic-comp-config")]
|
||||
let appearance_conf = comp_config
|
||||
.get::<cosmic_comp_config::AppearanceConfig>("appearance_settings")
|
||||
.unwrap_or_default();
|
||||
|
|
@ -129,9 +130,8 @@ impl From<&theme_manager::Manager> for Content {
|
|||
icon_handles: Vec::new(),
|
||||
tk_config: CosmicTk::config().ok(),
|
||||
comp_config,
|
||||
clip_floating: appearance_conf.clip_floating_windows,
|
||||
clip_tiled: appearance_conf.clip_tiled_windows,
|
||||
shadow_tiled: appearance_conf.shadow_tiled_windows,
|
||||
#[cfg(feature = "cosmic-comp-config")]
|
||||
appearance_conf,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -257,6 +257,7 @@ impl Content {
|
|||
Task::none()
|
||||
}
|
||||
|
||||
#[cfg(feature = "cosmic-comp-config")]
|
||||
pub fn update_shadow_and_corners(
|
||||
&mut self,
|
||||
message: CornerMessage,
|
||||
|
|
@ -264,22 +265,20 @@ impl Content {
|
|||
) -> Task<app::Message> {
|
||||
match message {
|
||||
CornerMessage::ClipFloating(enabled) => {
|
||||
self.clip_floating = enabled;
|
||||
self.appearance_conf.clip_floating_windows = enabled;
|
||||
}
|
||||
CornerMessage::ClipTiled(enabled) => {
|
||||
self.clip_tiled = enabled;
|
||||
self.appearance_conf.clip_tiled_windows = enabled;
|
||||
}
|
||||
CornerMessage::ShadowTiled(enabled) => {
|
||||
self.shadow_tiled = enabled;
|
||||
self.appearance_conf.shadow_tiled_windows = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
let conf = cosmic_comp_config::AppearanceConfig {
|
||||
clip_floating_windows: self.clip_floating,
|
||||
clip_tiled_windows: self.clip_tiled,
|
||||
shadow_tiled_windows: self.shadow_tiled,
|
||||
};
|
||||
if let Err(err) = self.comp_config.set("appearance_settings", conf) {
|
||||
if let Err(err) = self
|
||||
.comp_config
|
||||
.set("appearance_settings", self.appearance_conf)
|
||||
{
|
||||
error!(?err, "Failed to set config 'appearance_settings'");
|
||||
}
|
||||
|
||||
|
|
@ -471,6 +470,7 @@ impl Content {
|
|||
crate::pages::Message::CloseContextDrawer,
|
||||
),
|
||||
|
||||
#[cfg(feature = "cosmic-comp-config")]
|
||||
ContextView::ShadowAndCorners => context_drawer(
|
||||
self.shadow_and_corners(),
|
||||
crate::pages::Message::CloseContextDrawer,
|
||||
|
|
@ -527,13 +527,14 @@ impl Content {
|
|||
.map(crate::pages::Message::Appearance)
|
||||
}
|
||||
|
||||
#[cfg(feature = "cosmic-comp-config")]
|
||||
pub fn shadow_and_corners(&self) -> Element<'_, crate::pages::Message> {
|
||||
let Spacing { space_m, .. } = cosmic::theme::spacing();
|
||||
|
||||
cosmic::iced::widget::column![
|
||||
settings::section().title(fl!("shadows-floating")).add(
|
||||
settings::item::builder(fl!("shadows-floating", "clip"))
|
||||
.toggler(self.clip_floating, |b| {
|
||||
.toggler(self.appearance_conf.clip_floating_windows, |b| {
|
||||
Message::DrawerCorners(CornerMessage::ClipFloating(b))
|
||||
})
|
||||
),
|
||||
|
|
@ -541,13 +542,13 @@ impl Content {
|
|||
.title(fl!("shadows-tiling"))
|
||||
.add(
|
||||
settings::item::builder(fl!("shadows-tiling", "clip"))
|
||||
.toggler(self.clip_tiled, |b| {
|
||||
.toggler(self.appearance_conf.clip_tiled_windows, |b| {
|
||||
Message::DrawerCorners(CornerMessage::ClipTiled(b))
|
||||
})
|
||||
)
|
||||
.add(
|
||||
settings::item::builder(fl!("shadows-tiling", "shadow"))
|
||||
.toggler(self.shadow_tiled, |b| {
|
||||
.toggler(self.appearance_conf.shadow_tiled_windows, |b| {
|
||||
Message::DrawerCorners(CornerMessage::ShadowTiled(b))
|
||||
})
|
||||
)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ pub enum ContextView {
|
|||
ApplicationBackground,
|
||||
ContainerBackground,
|
||||
ControlComponent,
|
||||
#[cfg(feature = "cosmic-comp-config")]
|
||||
ShadowAndCorners,
|
||||
CustomAccent,
|
||||
IconsAndToolkit,
|
||||
|
|
@ -126,6 +127,7 @@ pub enum Message {
|
|||
|
||||
DrawerOpen(ContextView),
|
||||
DrawerColor(ColorPickerUpdate),
|
||||
#[cfg(feature = "cosmic-comp-config")]
|
||||
DrawerCorners(drawer::CornerMessage),
|
||||
DrawerFont(drawer::FontMessage),
|
||||
DrawerIcon(drawer::IconMessage),
|
||||
|
|
@ -265,6 +267,7 @@ impl Page {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "cosmic-comp-config")]
|
||||
Message::DrawerCorners(message) => {
|
||||
if let Some(context_view) = self.context_view.as_ref() {
|
||||
tasks.push(self.drawer.update_shadow_and_corners(message, context_view));
|
||||
|
|
@ -598,6 +601,7 @@ impl Page {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
pub fn update_dock_padding(roundness: Roundness) {
|
||||
let dock_config_helper = CosmicPanelConfig::cosmic_config("Dock").ok();
|
||||
|
||||
|
|
@ -855,17 +859,21 @@ pub fn experimental() -> Section<crate::pages::Message> {
|
|||
Message::DrawerOpen(ContextView::IconsAndToolkit),
|
||||
);
|
||||
|
||||
let shadow_and_corners = crate::widget::go_next_item(
|
||||
&descriptions[shadow_and_corners_txt],
|
||||
Message::DrawerOpen(ContextView::ShadowAndCorners),
|
||||
);
|
||||
|
||||
settings::section()
|
||||
let mut section = settings::section()
|
||||
.title(&*section.title)
|
||||
.add(system_font)
|
||||
.add(mono_font)
|
||||
.add(icons_and_toolkit)
|
||||
.add(shadow_and_corners)
|
||||
.add(icons_and_toolkit);
|
||||
|
||||
#[cfg(feature = "cosmic-comp-config")]
|
||||
{
|
||||
section = section.add(crate::widget::go_next_item(
|
||||
&descriptions[shadow_and_corners_txt],
|
||||
Message::DrawerOpen(ContextView::ShadowAndCorners),
|
||||
));
|
||||
}
|
||||
|
||||
section
|
||||
.apply(Element::from)
|
||||
.map(crate::pages::Message::Appearance)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue