log when the window popped up. Change the window title too
parent
f07ce8a5dd
commit
833692d7ed
18
src/main.rs
18
src/main.rs
|
@ -3,6 +3,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use chrono::{
|
use chrono::{
|
||||||
|
DateTime,
|
||||||
Local,
|
Local,
|
||||||
SecondsFormat,
|
SecondsFormat,
|
||||||
};
|
};
|
||||||
|
@ -123,11 +124,12 @@ enum Error {
|
||||||
#[derive (serde::Serialize)]
|
#[derive (serde::Serialize)]
|
||||||
struct JournalLine {
|
struct JournalLine {
|
||||||
text: String,
|
text: String,
|
||||||
|
time_popped_up: Option <String>,
|
||||||
time_submitted: String,
|
time_submitted: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Gui {
|
struct Gui {
|
||||||
armed: bool,
|
time_popped_up: Option <DateTime <Local>>,
|
||||||
editor: text::TextEditor,
|
editor: text::TextEditor,
|
||||||
wind: Window,
|
wind: Window,
|
||||||
}
|
}
|
||||||
|
@ -150,23 +152,25 @@ impl Gui {
|
||||||
let mut but = button::ReturnButton::new (640 - 100, 480 - 50, 100, 50, "Submit");
|
let mut but = button::ReturnButton::new (640 - 100, 480 - 50, 100, 50, "Submit");
|
||||||
but.emit (fltk_tx, Message::Submit);
|
but.emit (fltk_tx, Message::Submit);
|
||||||
|
|
||||||
|
wind.set_label ("ANNOYING JOURNAL");
|
||||||
wind.end ();
|
wind.end ();
|
||||||
wind.show ();
|
wind.show ();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
armed: true,
|
time_popped_up: Some (Local::now ()),
|
||||||
editor,
|
editor,
|
||||||
wind,
|
wind,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pop_up (&mut self) -> Result <(), Error> {
|
fn pop_up (&mut self) -> Result <(), Error> {
|
||||||
if ! self.armed {
|
if self.time_popped_up.is_some () {
|
||||||
eprintln! ("O4U6E36V Ignoring pop-up, not armed");
|
eprintln! ("O4U6E36V Ignoring pop-up, already popped up");
|
||||||
return Ok (());
|
return Ok (());
|
||||||
}
|
}
|
||||||
|
|
||||||
self.armed = false;
|
self.time_popped_up = Some (Local::now ());
|
||||||
|
self.wind.set_label ("ANNOYING JOURNAL");
|
||||||
self.wind.show ();
|
self.wind.show ();
|
||||||
self.editor.take_focus ()?;
|
self.editor.take_focus ()?;
|
||||||
|
|
||||||
|
@ -181,6 +185,7 @@ impl Gui {
|
||||||
|
|
||||||
let jl = JournalLine {
|
let jl = JournalLine {
|
||||||
text: buffer.text (),
|
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),
|
time_submitted: Local::now ().to_rfc3339_opts (SecondsFormat::Secs, true),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -198,7 +203,8 @@ impl Gui {
|
||||||
println! ("{}", s);
|
println! ("{}", s);
|
||||||
self.editor.set_buffer (text::TextBuffer::default ());
|
self.editor.set_buffer (text::TextBuffer::default ());
|
||||||
self.wind.iconize ();
|
self.wind.iconize ();
|
||||||
self.armed = true;
|
self.time_popped_up = None;
|
||||||
|
self.wind.set_label ("annoying journal");
|
||||||
|
|
||||||
Ok (())
|
Ok (())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue