about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/gtk/history_box.ui23
-rwxr-xr-xsrc/gtk/window.ui2
-rwxr-xr-xsrc/ui/task_row.rs3
-rwxr-xr-xsrc/ui/window.rs41
4 files changed, 46 insertions, 23 deletions
diff --git a/src/gtk/history_box.ui b/src/gtk/history_box.ui
index b761624..b5c9a34 100755
--- a/src/gtk/history_box.ui
+++ b/src/gtk/history_box.ui
@@ -31,7 +31,7 @@
                     <property name="column_spacing">12</property>
                     <child>
                       <object class="GtkImage">
-                        <property name="icon_name">list-add-symbolic</property>
+                        <property name="icon_name">input-keyboard-symbolic</property>
                         <layout>
                           <property name="column">0</property>
                           <property name="row">0</property>
@@ -50,7 +50,7 @@
                     </child>
                     <child>
                       <object class="GtkImage">
-                        <property name="icon_name">window-new-symbolic</property>
+                        <property name="icon_name">accessories-text-editor-symbolic</property>
                         <layout>
                           <property name="column">0</property>
                           <property name="row">1</property>
@@ -67,6 +67,25 @@
                         </layout>
                       </object>
                     </child>
+                    <child>
+                      <object class="GtkImage">
+                        <property name="icon_name">input-mouse-symbolic</property>
+                        <layout>
+                          <property name="column">0</property>
+                          <property name="row">2</property>
+                        </layout>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkLabel">
+                        <property name="halign">start</property>
+                        <property name="label" translatable="yes">Right-click a task to duplicate it</property>
+                        <layout>
+                          <property name="column">1</property>
+                          <property name="row">2</property>
+                        </layout>
+                      </object>
+                    </child>
                   </object>
                 </property>
               </object>
diff --git a/src/gtk/window.ui b/src/gtk/window.ui
index 186a57a..073dab9 100755
--- a/src/gtk/window.ui
+++ b/src/gtk/window.ui
@@ -37,6 +37,8 @@
               <child>
                 <object class="GtkLabel" id="watch">
                   <property name="label">00:00:00</property>
+                  <property name="margin_start">12</property>
+                  <property name="margin_end">12</property>
                   <attributes>
                     <attribute name="weight" value="bold"/>
                     <attribute name="scale" value="5"/>
diff --git a/src/ui/task_row.rs b/src/ui/task_row.rs
index 80d6795..f55aba4 100755
--- a/src/ui/task_row.rs
+++ b/src/ui/task_row.rs
@@ -109,8 +109,7 @@ impl FurTaskRow {
         gesture.connect_pressed(clone!(@strong task_name_text => move |gesture, _, _, _| {
             gesture.set_state(gtk::EventSequenceState::Claimed);
             let window = FurtheranceWindow::default();
-            window.set_task_input_text(task_name_text.to_string());
-            window.start_timer();
+            window.duplicate_task(task_name_text.to_string());
         }));
 
         self.add_controller(&gesture);
diff --git a/src/ui/window.rs b/src/ui/window.rs
index 36efb90..c955451 100755
--- a/src/ui/window.rs
+++ b/src/ui/window.rs
@@ -21,7 +21,7 @@ use gtk::subclass::prelude::*;
 use gtk::{gio, glib, CompositeTemplate};
 use glib::{clone, timeout_add_local};
 use std::time::Duration;
-use std::sync::{Arc, Mutex};
+use std::sync::Mutex;
 use std::rc::Rc;
 use std::cell::RefCell;
 use chrono::{DateTime, Local, Duration as ChronDur};
@@ -58,6 +58,7 @@ mod imp {
         pub idle_time_reached: Mutex<bool>,
         pub subtract_idle: Mutex<bool>,
         pub idle_start_time: Mutex<String>,
+        pub running: Mutex<bool>,
     }
 
     #[glib::object_subclass]
@@ -102,7 +103,7 @@ impl FurtheranceWindow {
             .expect("Failed to create FurtheranceWindow")
     }
 
-    pub fn inapp_notification(&self, text: &str) {
+    pub fn display_toast(&self, text: &str) {
         // Display in-app notifications
         let imp = imp::FurtheranceWindow::from_instance(self);
         let toast = adw::Toast::new(text);
@@ -162,13 +163,14 @@ impl FurtheranceWindow {
 
     fn setup_signals(&self) {
         let imp = imp::FurtheranceWindow::from_instance(self);
-        let running = Arc::new(Mutex::new(false));
+        // running = false
+        *imp.running.lock().unwrap() = false;
         let start_time = Rc::new(RefCell::new(Local::now()));
         let stop_time = Rc::new(RefCell::new(Local::now()));
 
         imp.start_button.connect_clicked(clone!(
-            @weak self as this,
-            @strong running => move |button| {
+            @weak self as this => move |button| {
+            let imp2 = imp::FurtheranceWindow::from_instance(&this);
             if this.get_task_text().trim().is_empty() {
                 let dialog = gtk::MessageDialog::with_markup(
                     Some(&this),
@@ -185,17 +187,18 @@ impl FurtheranceWindow {
                 }));
 
             } else {
-                if !*running.lock().unwrap() {
+                if !*imp2.running.lock().unwrap() {
                     let mut secs: u32 = 0;
                     let mut mins: u32 = 0;
                     let mut hrs: u32 = 0;
 
-                    *running.lock().unwrap() = true;
+                    *imp2.running.lock().unwrap() = true;
                     *start_time.borrow_mut() = Local::now();
                     this.activate_task_input(false);
                     let duration = Duration::new(1,0);
-                    timeout_add_local(duration, clone!(@strong running as running_clone => move || {
-                        if *running_clone.lock().unwrap() {
+                    timeout_add_local(duration, clone!(@strong this as this_clone => move || {
+                        let imp3 = imp::FurtheranceWindow::from_instance(&this_clone);
+                        if *imp3.running.lock().unwrap() {
                             secs += 1;
                             if secs > 59 {
                                 secs = 0;
@@ -206,14 +209,14 @@ impl FurtheranceWindow {
                                 }
                             }
                             let watch_text: &str = &format!("{:02}:{:02}:{:02}", hrs, mins, secs).to_string();
-                            this.set_watch_time(watch_text);
+                            this_clone.set_watch_time(watch_text);
                         }
-                        Continue(*running_clone.lock().unwrap())
+                        Continue(*imp3.running.lock().unwrap())
                     }));
                     button.set_icon_name("media-playback-stop-symbolic");
                 } else {
                     *stop_time.borrow_mut() = Local::now();
-                    *running.lock().unwrap() = false;
+                    *imp2.running.lock().unwrap() = false;
                     button.set_icon_name("media-playback-start-symbolic");
                     this.set_watch_time("00:00:00");
                     this.activate_task_input(true);
@@ -330,14 +333,14 @@ impl FurtheranceWindow {
         *imp.subtract_idle.lock().unwrap() = val;
     }
 
-    pub fn set_task_input_text(&self, text: String) {
+    pub fn duplicate_task(&self, task_name_text: String) {
         let imp = imp::FurtheranceWindow::from_instance(self);
-        imp.task_input.set_text(&text);
-    }
-
-    pub fn start_timer(&self) {
-        let imp = imp::FurtheranceWindow::from_instance(self);
-        imp.start_button.emit_clicked();
+        if !*imp.running.lock().unwrap() {
+            imp.task_input.set_text(&task_name_text);
+            imp.start_button.emit_clicked();
+        } else {
+            self.display_toast("Stop the timer to duplicate a task.");
+        }
     }
 }