[gnome-clocks] Use Escape in the timer and stopwatch



commit b193709572acfbf4e0c6d11b9894f7769176fee8
Author: Paolo Borelli <pborelli gnome org>
Date:   Thu Dec 10 00:19:41 2015 +0100

    Use Escape in the timer and stopwatch

 src/stopwatch.vala |   17 +++++++++++++++++
 src/timer.vala     |   10 ++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/stopwatch.vala b/src/stopwatch.vala
index ee984d4..38a7a2a 100644
--- a/src/stopwatch.vala
+++ b/src/stopwatch.vala
@@ -320,6 +320,23 @@ public class Face : Gtk.Box, Clocks.Clock {
     public override void grab_focus () {
         left_button.grab_focus ();
     }
+
+    public bool escape_pressed () {
+        switch (state) {
+        case State.RESET:
+            return false;
+        case State.STOPPED:
+            reset ();
+            break;
+        case State.RUNNING:
+            stop ();
+            break;
+        default:
+            assert_not_reached ();
+        }
+
+        return true;
+    }
 }
 
 } // namespace Stopwatch
diff --git a/src/timer.vala b/src/timer.vala
index c51ece3..adc557f 100644
--- a/src/timer.vala
+++ b/src/timer.vala
@@ -321,6 +321,16 @@ public class Face : Gtk.Stack, Clocks.Clock {
             start_button.grab_focus ();
         }
     }
+
+    public bool escape_pressed () {
+        if (state == State.STOPPED) {
+            return false;
+        }
+
+        reset ();
+
+        return true;
+    }
 }
 
 } // namespace Timer


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]