From a1fd4a45794a41796acdf49f8aedcdc2dc7a5275 Mon Sep 17 00:00:00 2001 From: Jacek Czaja Date: Sun, 3 Dec 2023 19:36:27 +0100 Subject: [PATCH] - Cosmetic fixes and removing all calculation results when adding or removing documents --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/gui.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8009667..f7dabef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -393,7 +393,7 @@ dependencies = [ [[package]] name = "etradeTaxReturnHelper" -version = "0.3.2" +version = "0.3.3" dependencies = [ "calamine", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 0b109a0..25c5b31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "etradeTaxReturnHelper" -version = "0.3.2" +version = "0.3.3" edition = "2021" description = "Parses etrade financial documents for transaction details (income, tax paid, cost basis) and compute total income and total tax paid according to chosen tax residency (currency)" license = "BSD-3-Clause" diff --git a/src/gui.rs b/src/gui.rs index 1ff0749..0c907c2 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -146,6 +146,9 @@ pub mod gui { fn create_choose_documents_dialog( browser: Rc>, + tdisplay: Rc>, + sdisplay: Rc>, + ndisplay: Rc>, load_button: &mut Button, ) { load_button.set_callback(move |_| { @@ -175,6 +178,21 @@ pub mod gui { .expect_and_log("Unable to extract choosen file name"); filelist.add(&filename); } + let mut buffer = sdisplay + .borrow() + .buffer() + .expect_and_log("Error: No buffer assigned to Summary TextDisplay"); + let mut nbuffer = ndisplay + .borrow() + .buffer() + .expect_and_log("Error: No buffer assigned to Notes TextDisplay"); + let mut tbuffer = tdisplay + .borrow() + .buffer() + .expect_and_log("Error: No buffer assigned to Transactions TextDisplay"); + buffer.set_text(""); + tbuffer.set_text(""); + nbuffer.set_text(""); }); } @@ -220,7 +238,7 @@ pub mod gui { ))); //feed_input(&mut browser.borrow_mut()); - let mut load_button = Button::new(0, 300, DOCUMENTS_COL_WIDTH, 30, "Add"); + let mut load_button = Button::new(0, 300, DOCUMENTS_COL_WIDTH, 30, "1. Add"); load_button.set_label_font(Font::HelveticaBold); let mut clear_button = Button::new(0, 300, DOCUMENTS_COL_WIDTH, 30, "Remove All"); clear_button.set_label_font(Font::HelveticaBold); @@ -267,7 +285,7 @@ pub mod gui { ))); sdisplay.borrow_mut().set_buffer(buffer); - let mut execute_button = Button::new(0, 300, SUMMARY_COL_WIDTH, 30, "Execute"); + let mut execute_button = Button::new(0, 300, SUMMARY_COL_WIDTH, 30, "2. Execute"); execute_button.set_label_font(Font::HelveticaBold); pack3.end(); @@ -277,13 +295,20 @@ pub mod gui { let mut frame4 = Frame::new(0, pack.height(), WIND_SIZE_X, 30, "Notes:"); frame4.set_frame(FrameType::EngravedFrame); let mut buffer = TextBuffer::default(); - buffer.set_text("Hi! Please >>Add<< your documents and click >>Execute<<"); + buffer.set_text("Hi!\n\n 1. Add your documents \n 2. Execute calculation"); let ndisplay = Rc::new(RefCell::new(TextDisplay::new(0, 30, WIND_SIZE_X, 270, ""))); ndisplay.borrow_mut().set_buffer(buffer); + ndisplay.borrow_mut().set_text_size(20); uberpack.end(); - create_choose_documents_dialog(browser.clone(), &mut load_button); + create_choose_documents_dialog( + browser.clone(), + tdisplay.clone(), + sdisplay.clone(), + ndisplay.clone(), + &mut load_button, + ); create_clear_documents( browser.clone(), tdisplay.clone(), @@ -385,6 +410,21 @@ pub mod gui { list.remove(idx); } } + + let mut buffer = sdisplay + .borrow() + .buffer() + .expect_and_log("Error: No buffer assigned to Summary TextDisplay"); + let mut nbuffer = ndisplay + .borrow() + .buffer() + .expect_and_log("Error: No buffer assigned to Notes TextDisplay"); + let mut tbuffer = tdisplay.borrow().buffer().expect_and_log( + "Error: No buffer assigned to Transactions TextDisplay", + ); + buffer.set_text(""); + tbuffer.set_text(""); + nbuffer.set_text(""); } true }