The Entry does have a text() method which gives you a GString (because Entry implements Editable), that can be converted to a rust str using as_str().
So in order to get the current text from an entry, you can do the following:
let my_input_value = my_input.text().as_str();
For completeness, here is the updated build_ui function:
pub fn build_ui(app: &Application) {
let button = Button::builder()
.label("Submit")
.margin_top(12)
.margin_bottom(12)
.margin_start(12)
.margin_end(12)
.build();
let input = gtk::Entry::builder()
.placeholder_text("input")
.margin_top(12)
.margin_bottom(12)
.margin_start(12)
.margin_end(12)
.build();
let gtk_box = gtk::Box::builder()
.orientation(Orientation::Vertical)
.build();
gtk_box.append(&input);
gtk_box.append(&button);
button.connect_clicked(move | _button| {
println!("{}", input.text().as_str());
});
let window = ApplicationWindow::builder()
.application(app)
.title("gtk-app")
.child(>k_box)
.default_height(720)
.default_width(360)
.build();
window.present();
}
Edit
Because GString implements Display the following works as well:
println!("{}", input.text());