rust-gnome

HOWTO: Idiomatic Rust for callbacks with gtk (rust-gnome)

回眸只為那壹抹淺笑 提交于 2019-12-18 05:45:07
问题 I am currently learning Rust and looking to use it for developing a GUI based application with GTK+. My problem relates to registering callbacks to respond to GTK events/signals and mutating state within those callbacks. I have a working but inelegant solution, so I would like to ask if there is a cleaner, more idiomatic solution. I have implemented my code as a struct with method implementations, where the struct maintains references to the GTK widgets along with other state that it needs.

HOWTO: Idiomatic Rust for callbacks with gtk (rust-gnome)

这一生的挚爱 提交于 2019-12-05 02:07:59
I am currently learning Rust and looking to use it for developing a GUI based application with GTK+. My problem relates to registering callbacks to respond to GTK events/signals and mutating state within those callbacks. I have a working but inelegant solution, so I would like to ask if there is a cleaner, more idiomatic solution. I have implemented my code as a struct with method implementations, where the struct maintains references to the GTK widgets along with other state that it needs. It constructs a closure that is passed to the GtkWidget::connect* functions in order to receive events,