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

book: Rename action to correct name #1510

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions book/listings/todo/8/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,13 @@ impl Window {

// ANCHOR: setup_actions
// Create action to create new collection and add to action group "win"
let action_new_list = gio::SimpleAction::new("new-collection", None);
action_new_list.connect_activate(clone!(@weak self as window => move |_, _| {
window.new_collection();
}));
self.add_action(&action_new_list);
let action_new_collection = gio::SimpleAction::new("new-collection", None);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you switch to ActionEntry::builder, you would no longer need the clone! usage here :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you give me an example how I would use that?
I don't get it from the docs alone

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, found a couple of examples in other apps.

action_new_collection.connect_activate(
clone!(@weak self as window => move |_, _| {
window.new_collection();
}),
);
self.add_action(&action_new_collection);
// ANCHOR_END: setup_actions
}

Expand Down
Loading