[gnome-games] ui: Bind on_display_back to mouse return button



commit 462b57fb801cdc8b42e2c7d51807ff8479e7a9f1
Author: RoubyPA <pa rouby gmail com>
Date:   Wed Jan 17 16:45:20 2018 +0100

    ui: Bind on_display_back to mouse return button
    
    Go back from the game display to the collection by pressing return
    button.

 data/ui/application-window.ui  |  1 +
 src/ui/application-window.vala | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
---
diff --git a/data/ui/application-window.ui b/data/ui/application-window.ui
index 1f7e41a..517df9f 100644
--- a/data/ui/application-window.ui
+++ b/data/ui/application-window.ui
@@ -9,6 +9,7 @@
     <property name="show_menubar">False</property>
     <signal name="delete-event" after="yes" handler="on_delete_event"/>
     <signal name="key-press-event" after="yes" handler="on_key_pressed"/>
+    <signal name="button-press-event" after="yes" handler="on_button_pressed"/>
     <signal name="window-state-event" after="yes" handler="on_window_state_event"/>
     <signal name="notify::has-toplevel-focus" after="yes" handler="on_toplevel_focus"/>
     <child>
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 4ea906d..faf8d48 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -200,6 +200,20 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                return handle_collection_key_event (event) || handle_display_key_event (event);
        }
 
+       [GtkCallback]
+       public bool on_button_pressed (Gdk.EventButton event) {
+               // Mouse button 8 is the navigation previous button
+               if (event.button == 8) {
+                       if (ui_state != UiState.DISPLAY)
+                               return false;
+
+                       on_display_back ();
+                       return true;
+               }
+
+               return false;
+       }
+
        [GtkCallback]
        public bool on_window_state_event (Gdk.EventWindowState event) {
                var is_maximized = (bool) (event.new_window_state & Gdk.WindowState.MAXIMIZED);


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