[gnome-clocks/gnome-3-22] handle mouse "back" button



commit c3635502195c9bb90f03971031e2312340baaf3f
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Oct 9 11:05:13 2016 +0200

    handle mouse "back" button
    
    https://bugzilla.gnome.org/show_bug.cgi?id=771936

 src/clock.vala  |    3 +++
 src/window.vala |   12 ++++++++++++
 src/world.vala  |    6 ++++++
 3 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/src/clock.vala b/src/clock.vala
index 73335ca..bcede58 100644
--- a/src/clock.vala
+++ b/src/clock.vala
@@ -45,6 +45,9 @@ public interface Clock : GLib.Object {
         return false;
     }
 
+    public virtual void back () {
+    }
+
     public virtual void update_header_bar () {
     }
 }
diff --git a/src/window.vala b/src/window.vala
index 308b35b..2dabc9a 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -186,6 +186,18 @@ public class Window : Gtk.ApplicationWindow {
         return base.key_press_event (event);
     }
 
+    public override bool button_release_event (Gdk.EventButton event) {
+        const uint BUTTON_BACK = 8;
+        uint button;
+
+        if (((Gdk.Event)(event)).get_button (out button) && button == BUTTON_BACK) {
+            ((Clock) stack.visible_child).back ();
+            return true;
+        }
+
+        return base.button_release_event (event);
+    }
+
     protected override bool configure_event (Gdk.EventConfigure event) {
         if (get_realized () && !(Gdk.WindowState.MAXIMIZED in get_window ().get_state ())) {
             int width, height;
diff --git a/src/world.vala b/src/world.vala
index afa2ccf..c382ce5 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -438,6 +438,12 @@ public class Face : Gtk.Stack, Clocks.Clock {
         return content_view.escape_pressed ();
     }
 
+    public void back () {
+        if (visible_child == standalone) {
+            reset_view ();
+        }
+    }
+
     public void reset_view () {
         standalone_location = null;
         visible_child = locations.get_n_items () == 0 ? empty_view : content_view;


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