feat(config): add CosmicTk config for configuring window controls

This commit is contained in:
Michael Aaron Murphy 2024-03-05 16:05:33 +01:00 committed by Jeremy Soller
parent 912f0665ef
commit 4f07d05ee8
6 changed files with 87 additions and 11 deletions

7
src/config/mod.rs Normal file
View file

@ -0,0 +1,7 @@
// Copyright 2024 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
//! Configurations available to libcosmic applications.
pub mod toolkit;
pub use toolkit::CosmicTk;

35
src/config/toolkit.rs Normal file
View file

@ -0,0 +1,35 @@
// Copyright 2024 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
//! Configurations for the libcosmic toolkit.
use cosmic_config::cosmic_config_derive::CosmicConfigEntry;
use cosmic_config::{Config, CosmicConfigEntry};
/// ID for the `CosmicTk` config.
pub const ID: &str = "com.system76.CosmicTk";
#[derive(Clone, CosmicConfigEntry, Debug, Eq, PartialEq)]
#[version = 1]
pub struct CosmicTk {
/// Show minimize button in window header.
pub show_minimize: bool,
/// Show maximize button in window header.
pub show_maximize: bool,
}
impl Default for CosmicTk {
fn default() -> Self {
Self {
show_minimize: true,
show_maximize: true,
}
}
}
impl CosmicTk {
pub fn config() -> Result<Config, cosmic_config::Error> {
Config::new(ID, Self::VERSION)
}
}