Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Add Glade signal handlers example if applicable #336

Closed
adnan449 opened this issue Dec 31, 2020 · 1 comment
Closed

Add Glade signal handlers example if applicable #336

adnan449 opened this issue Dec 31, 2020 · 1 comment

Comments

@adnan449
Copy link

Glade makes it possible to connect to functions to emitted signals. In python they usually create a class called Handler and define methods there. And in Glade the author connects those methods names to appropriate signals: https://python-gtk-3-tutorial.readthedocs.io/en/latest/builder.html#example

Does Gtk-rs offer any such solutions? Thank you.

@sdroege
Copy link
Member

sdroege commented Jan 1, 2021

builder.connect_signals(move |_, handler_name| {
// This is the one-time callback to register signals.
// Here we map each handler name to its handler.
if handler_name == "button1_clicked" {
// Return the signal handler.
Box::new(clone!(@weak dialog => @default-return None, move |_| {
dialog.show_all();
None
}))
} else {
panic!("Unknown handler name {}", handler_name)
}
});
is an example of that. It's not very convenient yet, see gtk-rs/gtk3-rs#128

@sdroege sdroege closed this as completed Jan 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants