mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-22 00:21:43 +01:00
The widget configuration enum moves to widgets/widget.rs of the core with
all thirteen variants (Keyboard, Media and Systray are no longer cfg-gated
or commented out per tree), plus `supported()`/`unsupported()`/`enabled()`
(enabled is now false for a widget the platform cannot run) and
`warn_unsupported`, which both shells call when they read the config. The
construction of the widget from its config (`as_boxed_bar_widget`, which
needs the runtime types) becomes the extension trait `WidgetConfigExt` in
each shell widget.rs; macOS builds a no-op `Unsupported` for the three
Windows-only widgets, which `enabled()` never lets through.
BEHAVIOUR (macOS), per D-coord-1: a macOS config with a `Keyboard`, `Media`
or `Systray` widget is now accepted and skipped with a logged warning ("the
Keyboard widget is not supported on this platform and is skipped"); before
it failed to deserialize (unknown variant), so the whole bar config was
rejected. Mac hand check: such a config starts the bar and logs the
warning. The macOS schema view removes the three variants from the
schema, so komorebi-for-mac/schema.bar.json and the nix options do not
change.
Verified: schema harness macOS and Windows byte-identical (3,774 / 9,091
lines); native bar-core tests 3+5; Windows clippy -D warnings --locked
clean (re-run after touching the files: Checking komorebi-bar-core and
komorebi-bar); macOS fake-CC check --locked 0 errors. Not run: the bars.
42 lines
1.9 KiB
Rust
42 lines
1.9 KiB
Rust
use crate::widgets::applications::Applications;
|
|
use crate::widgets::battery::Battery;
|
|
use crate::widgets::cpu::Cpu;
|
|
use crate::widgets::date::Date;
|
|
use crate::widgets::keyboard::Keyboard;
|
|
use crate::widgets::komorebi::Komorebi;
|
|
use crate::widgets::media::Media;
|
|
use crate::widgets::memory::Memory;
|
|
use crate::widgets::network::Network;
|
|
use crate::widgets::storage::Storage;
|
|
use crate::widgets::systray::Systray;
|
|
use crate::widgets::time::Time;
|
|
use crate::widgets::update::Update;
|
|
|
|
pub use komorebi_bar_core::widgets::widget::BarWidget;
|
|
pub use komorebi_bar_core::widgets::widget::WidgetConfig;
|
|
|
|
/// Turns a widget configuration into the widget that renders it.
|
|
pub trait WidgetConfigExt {
|
|
fn as_boxed_bar_widget(&self) -> Box<dyn BarWidget>;
|
|
}
|
|
|
|
impl WidgetConfigExt for WidgetConfig {
|
|
fn as_boxed_bar_widget(&self) -> Box<dyn BarWidget> {
|
|
match self {
|
|
WidgetConfig::Applications(config) => Box::new(Applications::from(config)),
|
|
WidgetConfig::Battery(config) => Box::new(Battery::from(*config)),
|
|
WidgetConfig::Cpu(config) => Box::new(Cpu::from(*config)),
|
|
WidgetConfig::Date(config) => Box::new(Date::from(config.clone())),
|
|
WidgetConfig::Keyboard(config) => Box::new(Keyboard::from(*config)),
|
|
WidgetConfig::Komorebi(config) => Box::new(Komorebi::from(config)),
|
|
WidgetConfig::Media(config) => Box::new(Media::from(*config)),
|
|
WidgetConfig::Memory(config) => Box::new(Memory::from(*config)),
|
|
WidgetConfig::Network(config) => Box::new(Network::from(*config)),
|
|
WidgetConfig::Storage(config) => Box::new(Storage::from(*config)),
|
|
WidgetConfig::Systray(config) => Box::new(Systray::from(config)),
|
|
WidgetConfig::Time(config) => Box::new(Time::from(config.clone())),
|
|
WidgetConfig::Update(config) => Box::new(Update::from(*config)),
|
|
}
|
|
}
|
|
}
|