GSettings Macro
Macro for typesafe GSettings key access
The macro's main purpose is to reduce the risk of mistyping a key,
using the wrong method to access values, inputing incorrect values,
and reduce boilerplate. Additionally, the summary, the
description, and the default of the value are included in the
documentation of each generated methods. This would be beneficial
if you use tools like rust-analyzer.
Example
use gen_settings;
use ;
;
let settings = default;
// `i` DBus type
settings.set_window_width;
assert_eq!
// enums
settings.set_alert_sound;
assert_eq!;
// bitflags
settings.set_space_style;
assert_eq!;
// customly defined
settings.set_cache_dir;
assert_eq!;
For more examples and detailed information see the documentation.
Generated methods
The procedural macro generates code for each key for following
gio::Settings methods:
set->set_#key, which panics when writing in a readonly key, andtry_set_#key, which behaves the same as the original method.get->get_#keyconnect_changed->connect_#key_changedbind->bind_#keycreate_action->create_#key_action
Known issues
- Not updating when the gschema file is modified
- Use hacks like
include_str! - See https://github.com/rust-lang/rust/issues/73921 or https://github.com/rust-lang/rust/issues/55904
- Use hacks like
Todos
- Remove serde dependency
- Add way to map setter and getters value
- Add
bind_#key writable,user_#key_value,reset_#key,connect_#key_writable_changedvariants