[gnome-games] ui: Add ApplicationWindow.handle_collection_key_event()



commit 8d332783859fdb464deb362d113790db017c7fdd
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Fri Aug 26 08:36:06 2016 +0200

    ui: Add ApplicationWindow.handle_collection_key_event()
    
    Add the handle_collection_key_event() method to ApplicationWindow to
    handle collection specific key bindings.
    
    This will help to make the code easier to read as more key bindings are
    going to be added in the next commit.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769438

 src/ui/application-window.vala |   30 ++++++++++++++++++------------
 1 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index ab0835a..1be8a5f 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -137,18 +137,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                        return true;
                }
 
-               if ((event.keyval == Gdk.Key.f || event.keyval == Gdk.Key.F) &&
-                   (event.state & default_modifiers) == Gdk.ModifierType.CONTROL_MASK) {
-                       if (!search_mode)
-                               search_mode = true;
-
-                       return true;
-               }
-
-               if (ui_state == UiState.COLLECTION && collection_box.search_bar_handle_event (event))
-                       return true;
-
-               return false;
+               return handle_collection_key_event (event);
        }
 
        [GtkCallback]
@@ -330,4 +319,21 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                else
                        display_box.runner.pause ();
        }
+
+       private bool handle_collection_key_event (Gdk.EventKey event) {
+               if (ui_state != UiState.COLLECTION)
+                       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) {
+                       if (!search_mode)
+                               search_mode = true;
+
+                       return true;
+               }
+
+               return collection_box.search_bar_handle_event (event);
+       }
 }


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