feat: added filechooser connect_response

main
Antonio De Lucreziis 9 months ago
parent b88e642f4a
commit e7e83ff163

@ -1,5 +1,4 @@
use gtk::glib::property::PropertyGet; use gtk::{prelude::*, Box, Button, FileChooserAction, FileChooserDialog, Label, Orientation, ResponseType, Stack, StackSidebar};
use gtk::{prelude::*, Align, Box, Button, FileChooserAction, FileChooserDialog, Label, Orientation, ResponseType, Stack, StackSidebar};
use gtk::{glib, Application, ApplicationWindow}; use gtk::{glib, Application, ApplicationWindow};
const APP_ID: &str = "org.gtk_rs.HelloWorld2"; const APP_ID: &str = "org.gtk_rs.HelloWorld2";
@ -52,6 +51,17 @@ fn print_utils(window: &ApplicationWindow) -> Box {
// if file_chooser.response(ResponseType::Ok) == ResponseType::Ok { // if file_chooser.response(ResponseType::Ok) == ResponseType::Ok {
// let filename = file_chooser.filename(); } // let filename = file_chooser.filename(); }
file_chooser.connect_response(move |fcd: &FileChooserDialog, response: ResponseType| {
if response == ResponseType::Ok {
let file = fcd.file().expect("Couldn't get file");
let filename = file.path().expect("Couldn't get file path");
println!("Filename: {:?}", filename);
}
fcd.close();
});
file_chooser.show(); file_chooser.show();
})); }));

Loading…
Cancel
Save