about summary refs log tree commit diff
path: root/src/ui/window.rs
diff options
context:
space:
mode:
authorRicky Kresslein <rk@lakoliu.com>2022-04-09 12:17:14 +0300
committerRicky Kresslein <rk@lakoliu.com>2022-04-09 12:17:14 +0300
commite3a44b30e9d728d9129cfca5d656ae2e186b37f3 (patch)
treeb90b93f417721762c93ebf265bd2786f5ac7be54 /src/ui/window.rs
parent707e8ed72d248bcc80a19c9220c1cc6de4dba28d (diff)
downloadFurtherance-e3a44b30e9d728d9129cfca5d656ae2e186b37f3.tar.zst
Add system notifications for idle (Issue #15)
Diffstat (limited to 'src/ui/window.rs')
-rwxr-xr-xsrc/ui/window.rs16
1 files changed, 9 insertions, 7 deletions
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;
     }