Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

gio: Add Settings::bind_with_mapping() binding #210

Merged
merged 1 commit into from
Dec 10, 2020

Conversation

ids1024
Copy link
Contributor

@ids1024 ids1024 commented Dec 9, 2020

Using boxed Fn mainly to have a reasonable way to pass None.

gio/Cargo.toml Outdated Show resolved Hide resolved
gio/src/settings.rs Outdated Show resolved Hide resolved
gio/src/settings.rs Outdated Show resolved Hide resolved
gio/src/settings.rs Outdated Show resolved Hide resolved
gio/src/settings.rs Outdated Show resolved Hide resolved
@ids1024 ids1024 force-pushed the g_settings_bind_with_mapping branch 3 times, most recently from c5ac035 to b6ce6d0 Compare December 9, 2020 17:06
@ids1024
Copy link
Contributor Author

ids1024 commented Dec 9, 2020

Now this commit is using:

get_mapping: Option<Box<dyn Fn(&glib::Variant, glib::Type) -> Option<glib::Value>>>,
set_mapping: Option<Box<dyn Fn(&glib::Value, glib::VariantType) -> Option<glib::Variant>>>,

Which seems like a reasonable Rust function signature, matching the capabilities of the C API. Most implementations will probably use closures ignoring the Type and VariantType arguments, but that's easy enough.

@ids1024 ids1024 force-pushed the g_settings_bind_with_mapping branch from b6ce6d0 to d278d96 Compare December 10, 2020 16:22
@ids1024
Copy link
Contributor Author

ids1024 commented Dec 10, 2020

Updated to use a builder pattern. Still doesn't seem like a perfect API, but I suppose I'm at least happy to not be writing Some(Box::new(...)) when using it.

gio/src/settings.rs Outdated Show resolved Hide resolved
@sdroege
Copy link
Member

sdroege commented Dec 10, 2020

Updated to use a builder pattern. Still doesn't seem like a perfect API, but I suppose I'm at least happy to not be writing Some(Box::new(...)) when using it.

Yeah writing the Some(Box::new()) in user code is always annoying, so this is a huge usability improvement IMHO.

This now wraps `g_settings_bind_with_mapping`, so mapping can optionally
be specified.
@ids1024 ids1024 force-pushed the g_settings_bind_with_mapping branch from d278d96 to b738524 Compare December 10, 2020 16:30
@sdroege sdroege merged commit a0d0926 into gtk-rs:master Dec 10, 2020
@ids1024 ids1024 deleted the g_settings_bind_with_mapping branch December 10, 2020 20:38
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants