[gnome-clocks] Exit selection mode on ESC



commit dd904730566cd036017f7959086162f06573ff52
Author: Paolo Borelli <pborelli gnome org>
Date:   Mon Feb 25 22:54:23 2013 +0100

    Exit selection mode on ESC

 src/alarm.vala  |    8 ++++++++
 src/clock.vala  |    4 ++++
 src/window.vala |    9 +++++++++
 src/world.vala  |    8 ++++++++
 4 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/src/alarm.vala b/src/alarm.vala
index ec7560f..72df804 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -609,6 +609,14 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
         icon_view.unselect_all ();
     }
 
+    public bool escape_pressed () {
+        if (icon_view.mode == IconView.Mode.SELECTION) {
+            icon_view.mode = IconView.Mode.NORMAL;
+            return true;
+        }
+        return false;
+    }
+
     public void update_toolbar () {
         switch (toolbar.mode) {
         case Toolbar.Mode.NORMAL:
diff --git a/src/clock.vala b/src/clock.vala
index 96cede9..ad629f6 100644
--- a/src/clock.vala
+++ b/src/clock.vala
@@ -31,6 +31,10 @@ public interface Clock : GLib.Object {
     public virtual void activate_select_none () {
     }
 
+    public virtual bool escape_pressed () {
+        return false;
+    }
+
     public virtual void update_toolbar () {
     }
 }
diff --git a/src/window.vala b/src/window.vala
index b03ff1c..0aa690b 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -121,6 +121,15 @@ public class Window : Gtk.ApplicationWindow {
         ((Clock) stack.visible_child).activate_select_none ();
     }
 
+    public override bool key_press_event (Gdk.EventKey event) {
+        uint keyval;
+        if (((Gdk.Event*)(&event))->get_keyval (out keyval) && keyval == Gdk.Key.Escape) {
+            return ((Clock) stack.visible_child).escape_pressed ();
+        }
+
+        return false;
+    }
+
     private void on_about_activate () {
         const string copyright = "Copyright \xc2\xa9 2011 Collabora Ltd.\n" +
                                  "Copyright \xc2\xa9 2012-2013 Collabora Ltd., Seif Lotfy, Emily Gonyer\n" +
diff --git a/src/world.vala b/src/world.vala
index 4216c0b..f9bdb4a 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -337,6 +337,14 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
         icon_view.unselect_all ();
     }
 
+    public bool escape_pressed () {
+        if (icon_view.mode == IconView.Mode.SELECTION) {
+            icon_view.mode = IconView.Mode.NORMAL;
+            return true;
+        }
+        return false;
+    }
+
     public void update_toolbar () {
         toolbar.clear ();
         switch (toolbar.mode) {


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