-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
action_entry: Add activate_async helper #903
base: main
Are you sure you want to change the base?
Conversation
This is a helper function in a similar vein to gtk4-rs's `install_action_async ()` for widgets. It allows applications to install actions that use async/await without having to manually create a glib::MainContext in the callback.
ad5f0a4
to
7c20e1b
Compare
This should probably just call the helper function from #902 once merged. |
@@ -87,6 +88,30 @@ where | |||
self | |||
} | |||
|
|||
pub fn activate_async<Fut, F>(mut self, callback: F) -> Self | |||
where | |||
F: Fn(&O, &SimpleAction, Option<&Variant>) -> Fut + 'static + Clone, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why require Clone
here? I think it would be better if you would instead use an Rc
instead of a Box
for storing the callback. Then you get cloning for free and don't make it the user's problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any chance we resolve this? it would be cool to merge this already without waiting endlessly for #902.
This is a helper function in a similar vein to
gtk4-rs's
install_action_async ()
for widgets.It allows applications to install actions
that use async/await without having to manually
create a glib::MainContext in the callback.