Skip to content

Commit

Permalink
replace filechooser with native file chooser (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfraczek authored Apr 13, 2024
1 parent 04b1c65 commit ea9548e
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,31 +158,22 @@ pub mod gui {
load_button: &mut Button,
) {
load_button.set_callback(move |_| {
let mut chooser = dialog::FileChooser::new(
".",
"*.{pdf,xlsx,csv}",
dialog::FileChooserType::Multi,
"Choose e-trade documents with transactions (PDF and/or XLSX)",
);
let mut chooser = dialog::FileDialog::new(dialog::FileDialogType::BrowseMultiFile);
chooser.set_directory(&".");
chooser.set_filter("*.{pdf,xlsx,csv}");
chooser.set_title("Choose e-trade documents with transactions (PDF and/or XLSX)");
chooser.show();
chooser.window().set_pos(300, 300);
while chooser.shown() {
app::wait();
}

// User hit cancel?
if chooser.value(1).is_none() {
log::info!("User hit Cancel in file choosing");
return;
if let Some(message) = chooser.error_message() {
if message != "No error" {
log::info!("Error in chooser: {}", message);
return;
}
}
let nc = chooser.count();
log::info!("{nc} were selected");
let filenames = chooser.filenames();
log::info!("{} were selected", filenames.len());
let mut filelist = browser.borrow_mut();
for d in 1..=nc {
let filename = chooser
.value(d)
.expect_and_log("Unable to extract choosen file name");
filelist.add(&filename);
for filename in filenames {
filelist.add(&filename.to_string_lossy());
}
let mut buffer = sdisplay
.borrow()
Expand Down

0 comments on commit ea9548e

Please sign in to comment.