Skip to content

Commit

Permalink
- Cosmetic fixes and removing all calculation results when adding or
Browse files Browse the repository at this point in the history
  removing documents
  • Loading branch information
jczaja committed Dec 3, 2023
1 parent 54474f7 commit a1fd4a4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
48 changes: 44 additions & 4 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ pub mod gui {

fn create_choose_documents_dialog(
browser: Rc<RefCell<MultiBrowser>>,
tdisplay: Rc<RefCell<TextDisplay>>,
sdisplay: Rc<RefCell<TextDisplay>>,
ndisplay: Rc<RefCell<TextDisplay>>,
load_button: &mut Button,
) {
load_button.set_callback(move |_| {
Expand Down Expand Up @@ -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("");
});
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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(),
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit a1fd4a4

Please sign in to comment.