about summary refs log tree commit diff
path: root/src/ui
diff options
context:
space:
mode:
authorRicky Kresslein <rk@lakoliu.com>2022-03-17 10:34:40 +0100
committerRicky Kresslein <rk@lakoliu.com>2022-03-17 10:34:40 +0100
commit72fff20922590e1b5cc5f15bff6e1ba4c7934812 (patch)
treea6e6f1cbd02a31bfc2a9a2f8e23eaff817ea2e7f /src/ui
parent917748d474e98c945ac0ef0347bc4dc3925b89c3 (diff)
downloadFurtherance-72fff20922590e1b5cc5f15bff6e1ba4c7934812.tar.zst
Right-clicking a task starts timer for that task
Diffstat (limited to 'src/ui')
-rwxr-xr-xsrc/ui/task_row.rs15
-rwxr-xr-xsrc/ui/window.rs10
2 files changed, 24 insertions, 1 deletions
diff --git a/src/ui/task_row.rs b/src/ui/task_row.rs
index d4bcaec..80d6795 100755
--- a/src/ui/task_row.rs
+++ b/src/ui/task_row.rs
@@ -22,7 +22,7 @@ use once_cell::sync::Lazy;
 use glib::clone;
 
 use crate::database::Task;
-use crate::ui::FurTaskDetails;
+use crate::ui::{FurTaskDetails, FurtheranceWindow};
 use crate::settings_manager;
 
 
@@ -100,8 +100,21 @@ impl FurTaskRow {
         for task in task_list.clone() {
             imp.tasks.lock().unwrap().push(task);
         }
+        let task_name_text = &task_list[0].task_name;
         imp.task_name_label.set_text(&imp.tasks.lock().unwrap()[0].task_name);
 
+        // Create right-click gesture
+        let gesture = gtk::GestureClick::new();
+        gesture.set_button(gtk::gdk::ffi::GDK_BUTTON_SECONDARY as u32);
+        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();
+        }));
+
+        self.add_controller(&gesture);
+
         // Add up all durations for task of said name to create total_time
         let mut total_time: i64 = 0;
         for task in &task_list {
diff --git a/src/ui/window.rs b/src/ui/window.rs
index 277daa5..36c20c1 100755
--- a/src/ui/window.rs
+++ b/src/ui/window.rs
@@ -327,6 +327,16 @@ impl FurtheranceWindow {
         let imp = imp::FurtheranceWindow::from_instance(self);
         *imp.subtract_idle.lock().unwrap() = val;
     }
+
+    pub fn set_task_input_text(&self, 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();
+    }
 }
 
 impl Default for FurtheranceWindow {