Implement get_config_dir() and get_state_dir() helper functions that detect
Flatpak sandboxing via FLATPAK_ID and use HOST_XDG_CONFIG_HOME/HOST_XDG_STATE_HOME
environment variables or fallback to HOME-based paths.
This allows libcosmic apps running in Flatpak sandboxes to properly read
system-wide COSMIC configuration (themes, corner radii, etc.) from the host.
It looks like these functions where previously implemented in a
different way that required these traits, but now it uses
`Subscription::run_with_id`, the `id` only needs to be `Hash + 'static`.
This also changes `widget::column::with_children` and
`widget::row::with_children` to take an `impl IntoIterator` instead
of a `Vec`, like the `iced` variants of these functions do.
This shouldn't be a breaking change since passing in a `Vec` will still
compile and function exactly as before.
(Using `iced::widget::Column::from_vec` or
`iced::widget::Row::from_vec` isn't possible, since the elements of the
`Vec` aren't checked, so the size of the resulting `Column` or `Row`
won't adapt to the size of its children. Perhaps a new function could
be added to mirror `iced`'s?)
* Use `tracing::error!` in places where `eprintln!` was used
* Loop over errors and print seperately
* Print errors with `Display` rather than `Debug`
* Don't print errors that should be ignored
- Matches https://github.com/pop-os/libcosmic/pull/949, for same
reasons.
With this, and the previous change, cosmic-panel no longer spams a bunch
of config errors from different applets on start.
When a transaction gets committed, the files gets written to a file in
the .atomicwrite[0-9a-Z] folder and then gets moved to their final
location. The watcher will emit two events:
- Modify(Name(To))
- Modify(Name(Both)
The last one will include both the source and the destination and is
essentially a duplicate of the first event. By discarding this event,
behavior seems to be the same, and all consumers of those events get
only notified once instead of twice when a configuration changes.
To reduce compile-times and avoid some overhead to binary size, this will modify some of our
generic functions to use non-generic inner functions where possible. The inner functions are
marked carefully with `#[inline(never)]` to prevent being inlined by LLVM at their callsites
While looking for generic functions to optimize, I have also taken the opportunity to annotate
public non-generic getters and setters with `#[inline]` to ensure that LLVM will inline them
across crate boundaries. By default, only generic functions are automatically inlined, and
only when enabling fat LTO are constant functions reliably inlined across crate boundaries.
This commit changes the hardcoded /usr/share paths in cosmic-config to
become performed via XDG lookups using the `xdg` crate.
This allows the installed files to be discovered on non-FHS Linux, e.g.
NixOS.
Hardcoded /var/lib/ is removed entirely because
1. nothing installs to it yet (only user of new_state is cosmic_bg
currently and it does not install to /var/lib)
2. it's intended for system states, not template for user state.
3. it's not part of XDG spec.
On Windows the known folder crate is used.
Signed-off-by: Gary Guo <gary@garyguo.net>
* feat: add support for dark / light mode switching and simultaneouscustom light / dark mode themes
* refactor(color-picker): optional initial color and fallback color
* refactor: used FixedPortion for layout of the settings item
This makes sure that the control always has at least the specified portion of the available space
* refactor: make all members of the ThemeBuilder public
* refactor: add and update palette colors
* fix(theme): typo and derive PartialEq for ThemeBuilder
* fix: update color picker usage
* feat: add more variables to the theme
* fix: radius on headerbar
* fix: Theme CosmicConfigEntry impl
* chore: specify rev of taffy
* fix: theme CosmicConfigEntry missing variables
* fix: apply theme type when theme mode changes
* wip: add plus icon to empty color picker button
* chore: fix rev and imports
* refactor(color-picker): allow custom size for the icon
* refactor(color_picker): make color_button public
* update iced