From e3a44b30e9d728d9129cfca5d656ae2e186b37f3 Mon Sep 17 00:00:00 2001 From: Ricky Kresslein Date: Sat, 9 Apr 2022 12:17:14 +0300 Subject: Add system notifications for idle (Issue #15) --- src/ui/window.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/ui/window.rs') diff --git a/src/ui/window.rs b/src/ui/window.rs index a9b43bd..d252ef7 100755 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -296,10 +296,9 @@ impl FurtheranceWindow { let h = idle_time / 60 / 60; let m = (idle_time / 60) - (h * 60); let s = idle_time - (m * 60); - let idle_time_str = format!( - "{}{:02}:{:02}:{:02}{}", gettext("You have been idle for "), h, m, s, - gettext(".\nWould you like to discard that time, or continue the clock?") - ); + let idle_time_str = format!("{}{:02}:{:02}:{:02}", gettext("You have been idle for "), h, m, s); + let question_str = gettext("\nWould you like to discard that time, or continue the clock?"); + let idle_time_msg = format!("{}{}", idle_time_str, question_str); let dialog = gtk::MessageDialog::with_markup( Some(self), @@ -312,7 +311,10 @@ impl FurtheranceWindow { (&gettext("Discard"), gtk::ResponseType::Reject), (&gettext("Continue"), gtk::ResponseType::Accept) ]); - dialog.set_secondary_text(Some(&idle_time_str)); + dialog.set_secondary_text(Some(&idle_time_msg)); + + let app = FurtheranceApplication::default(); + app.system_notification(&idle_time_str, &question_str, dialog.clone()); dialog.connect_response(clone!( @weak self as this, @@ -331,7 +333,7 @@ impl FurtheranceWindow { dialog.show() } - fn reset_vars(&self) { + pub fn reset_vars(&self) { let imp = imp::FurtheranceWindow::from_instance(self); *imp.stored_idle.lock().unwrap() = 0; *imp.idle_notified.lock().unwrap() = false; @@ -339,7 +341,7 @@ impl FurtheranceWindow { *imp.subtract_idle.lock().unwrap() = false; } - fn set_subtract_idle(&self, val: bool) { + pub fn set_subtract_idle(&self, val: bool) { let imp = imp::FurtheranceWindow::from_instance(self); *imp.subtract_idle.lock().unwrap() = val; } -- cgit 1.4.1