mirror of
https://github.com/phc-dm/phc-tweaks.git
synced 2026-10-06 22:55:02 +00:00
feat: added filechooser connect_response
This commit is contained in:
+12
-2
@@ -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();
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user