Compare commits
2 Commits
f07ce8a5dd
...
7ccc3b0e77
Author | SHA1 | Date |
---|---|---|
_ | 7ccc3b0e77 | |
_ | 833692d7ed |
|
@ -8,7 +8,7 @@ license = "AGPL-3.0"
|
|||
name = "annoying_journal"
|
||||
readme = "README.md"
|
||||
repository = "https://six-five-six-four.com/git/reactor/annoying_journal"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
|
||||
exclude = [
|
||||
"COPYING",
|
||||
|
|
18
src/main.rs
18
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 <String>,
|
||||
time_submitted: String,
|
||||
}
|
||||
|
||||
struct Gui {
|
||||
armed: bool,
|
||||
time_popped_up: Option <DateTime <Local>>,
|
||||
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 (())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue