diff --git a/src/main.rs b/src/main.rs index dfa56c4..6b46585 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,6 +11,7 @@ use chrono::{ use fltk::{ app, button, + frame, prelude::*, text, window::Window, @@ -98,6 +99,7 @@ struct JournalLine { struct Gui { time_popped_up: Option >, editor: text::TextEditor, + status: frame::Frame, wind: Window, } @@ -119,15 +121,31 @@ impl Gui { let mut but = button::ReturnButton::new (640 - 100, 480 - 50, 100, 50, "Submit"); but.emit (fltk_tx, Message::Submit); + let status = frame::Frame::new (0, 480 - 50, 640 - 100, 50, ""); + wind.set_label ("ANNOYING JOURNAL"); wind.end (); wind.show (); - Self { + let mut that = Self { time_popped_up: Some (Local::now ()), editor, + status, wind, - } + }; + + that.refresh_status (); + + that + } + + fn refresh_status (&mut self) { + let version = option_env! ("CARGO_PKG_VERSION").unwrap_or ("(???)"); + let time_popped_up = self.time_popped_up + .map (|x| x.to_rfc3339_opts (SecondsFormat::Secs, true)) + .unwrap_or_else (|| "(???)".to_string ()); + + self.status.set_label (&format! ("v{}, popped up at {}", version, time_popped_up)); } fn pop_up (&mut self) -> Result <(), Error> { @@ -137,6 +155,7 @@ impl Gui { } self.time_popped_up = Some (Local::now ()); + self.refresh_status (); self.wind.set_label ("ANNOYING JOURNAL"); self.wind.show (); self.editor.take_focus ()?;