diff --git a/src/main.rs b/src/main.rs index 11d746b..2265dbe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ use std::{ }; use chrono::{ + DateTime, Local, SecondsFormat, }; @@ -123,11 +124,12 @@ enum Error { #[derive (serde::Serialize)] struct JournalLine { text: String, + time_popped_up: Option , time_submitted: String, } struct Gui { - armed: bool, + time_popped_up: Option >, editor: text::TextEditor, wind: Window, } @@ -150,23 +152,25 @@ impl Gui { let mut but = button::ReturnButton::new (640 - 100, 480 - 50, 100, 50, "Submit"); but.emit (fltk_tx, Message::Submit); + wind.set_label ("ANNOYING JOURNAL"); wind.end (); wind.show (); Self { - armed: true, + time_popped_up: Some (Local::now ()), editor, wind, } } fn pop_up (&mut self) -> Result <(), Error> { - if ! self.armed { - eprintln! ("O4U6E36V Ignoring pop-up, not armed"); + if self.time_popped_up.is_some () { + eprintln! ("O4U6E36V Ignoring pop-up, already popped up"); return Ok (()); } - self.armed = false; + self.time_popped_up = Some (Local::now ()); + self.wind.set_label ("ANNOYING JOURNAL"); self.wind.show (); self.editor.take_focus ()?; @@ -181,6 +185,7 @@ impl Gui { let jl = JournalLine { text: buffer.text (), + time_popped_up: self.time_popped_up.map (|x| x.to_rfc3339_opts (SecondsFormat::Secs, true)), time_submitted: Local::now ().to_rfc3339_opts (SecondsFormat::Secs, true), }; @@ -198,7 +203,8 @@ impl Gui { println! ("{}", s); self.editor.set_buffer (text::TextBuffer::default ()); self.wind.iconize (); - self.armed = true; + self.time_popped_up = None; + self.wind.set_label ("annoying journal"); Ok (()) }