[gnome-games] ui: Add key bindings to toggle fullscreen



commit 8c4416d2729cbe7da4a4052e4afeb7d1be86e7a1
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Fri Aug 26 08:41:42 2016 +0200

    ui: Add key bindings to toggle fullscreen
    
    Add the Ctrl+F and F11 key bindings to toggle fullscreen and add the
    Escape key binding to restore the window.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769438

 src/ui/application-window.vala |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 1be8a5f..969f9ed 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -137,7 +137,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                        return true;
                }
 
-               return handle_collection_key_event (event);
+               return handle_collection_key_event (event) || handle_display_key_event (event);
        }
 
        [GtkCallback]
@@ -336,4 +336,32 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
 
                return collection_box.search_bar_handle_event (event);
        }
+
+       private bool handle_display_key_event (Gdk.EventKey event) {
+               if (ui_state != UiState.DISPLAY)
+                       return false;
+
+               var default_modifiers = Gtk.accelerator_get_default_mod_mask ();
+
+               if ((event.keyval == Gdk.Key.f || event.keyval == Gdk.Key.F) &&
+                   (event.state & default_modifiers) == Gdk.ModifierType.CONTROL_MASK) {
+                       is_fullscreen = !is_fullscreen;
+
+                       return true;
+               }
+
+               if (event.keyval == Gdk.Key.F11) {
+                       is_fullscreen = !is_fullscreen;
+
+                       return true;
+               }
+
+               if (event.keyval == Gdk.Key.Escape) {
+                       is_fullscreen = false;
+
+                       return true;
+               }
+
+               return false;
+       }
 }


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