Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

BrainBlasted
Copy link
Contributor

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.

gio/src/action_entry.rs Outdated Show resolved Hide resolved
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.
@BrainBlasted BrainBlasted force-pushed the actionentry-activate-async branch from ad5f0a4 to 7c20e1b Compare January 19, 2023 17:36
@sdroege sdroege added this to the 0.17.0 milestone Jan 21, 2023
@sdroege
Copy link
Member

sdroege commented Jan 21, 2023

This should probably just call the helper function from #902 once merged.

@sdroege sdroege modified the milestones: 0.17.0, 0.18.0 Feb 8, 2023
@@ -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,
Copy link
Member

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.

Copy link
Member

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.

@bilelmoussaoui bilelmoussaoui modified the milestones: 0.18.0, 0.20 May 31, 2024
@sdroege sdroege modified the milestones: 0.20, 0.21 Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants