[gnome-games/wip/exalm/views: 15/17] display-view: Handle key events
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/views: 15/17] display-view: Handle key events
- Date: Fri, 5 Oct 2018 14:00:59 +0000 (UTC)
commit 766048c65a32616d4eb340ac26cccbba8b1696a0
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Thu Oct 4 21:51:26 2018 +0500
display-view: Handle key events
src/ui/application-window.vala | 45 +-----------------------------------------
src/ui/display-view.vala | 37 ++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 44 deletions(-)
---
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 136a3ec5..76ae5be6 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -190,10 +190,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
return true;
}
- if (current_view == collection_view)
- return current_view.on_key_pressed (event);
-
- return handle_display_key_event (event);
+ return current_view.on_key_pressed (event);
}
[GtkCallback]
@@ -546,46 +543,6 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
return true;
}
- private bool handle_display_key_event (Gdk.EventKey event) {
- if (current_view != display_view)
- 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 &&
- display_view._header_bar.can_fullscreen) {
- is_fullscreen = !is_fullscreen;
- settings.set_boolean ("fullscreen", is_fullscreen);
-
- return true;
- }
-
- if (event.keyval == Gdk.Key.F11 && display_view._header_bar.can_fullscreen) {
- is_fullscreen = !is_fullscreen;
- settings.set_boolean ("fullscreen", is_fullscreen);
-
- return true;
- }
-
- if (event.keyval == Gdk.Key.Escape && display_view._header_bar.can_fullscreen) {
- is_fullscreen = false;
- settings.set_boolean ("fullscreen", false);
-
- return true;
- }
-
- if (((event.state & default_modifiers) == Gdk.ModifierType.MOD1_MASK) &&
- (((get_direction () == Gtk.TextDirection.LTR) && event.keyval == Gdk.Key.Left) ||
- ((get_direction () == Gtk.TextDirection.RTL) && event.keyval == Gdk.Key.Right))) {
- on_display_back ();
-
- return true;
- }
-
- return false;
- }
-
private void inhibit (Gtk.ApplicationInhibitFlags flags) {
if ((inhibit_flags & flags) == flags)
return;
diff --git a/src/ui/display-view.vala b/src/ui/display-view.vala
index bd6ac610..8e246e3b 100644
--- a/src/ui/display-view.vala
+++ b/src/ui/display-view.vala
@@ -38,10 +38,14 @@ private class Games.DisplayView: Gtk.Bin, ApplicationView {
public bool is_fullscreen { get; set; }
+ private Settings settings;
+
private Binding box_fullscreen_binding;
private Binding header_bar_fullscreen_binding;
construct {
+ settings = new Settings ("org.gnome.Games");
+
box_fullscreen_binding = bind_property ("is-fullscreen", box, "is-fullscreen",
BindingFlags.BIDIRECTIONAL);
header_bar_fullscreen_binding = bind_property ("is-fullscreen", _header_bar,
@@ -60,6 +64,39 @@ private class Games.DisplayView: Gtk.Bin, ApplicationView {
}
public bool on_key_pressed (Gdk.EventKey event) {
+ 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 &&
+ _header_bar.can_fullscreen) {
+ is_fullscreen = !is_fullscreen;
+ settings.set_boolean ("fullscreen", is_fullscreen);
+
+ return true;
+ }
+
+ if (event.keyval == Gdk.Key.F11 && _header_bar.can_fullscreen) {
+ is_fullscreen = !is_fullscreen;
+ settings.set_boolean ("fullscreen", is_fullscreen);
+
+ return true;
+ }
+
+ if (event.keyval == Gdk.Key.Escape && _header_bar.can_fullscreen) {
+ is_fullscreen = false;
+ settings.set_boolean ("fullscreen", false);
+
+ return true;
+ }
+
+ if (((event.state & default_modifiers) == Gdk.ModifierType.MOD1_MASK) &&
+ (((get_direction () == Gtk.TextDirection.LTR) && event.keyval == Gdk.Key.Left) ||
+ ((get_direction () == Gtk.TextDirection.RTL) && event.keyval == Gdk.Key.Right))) {
+ on_display_back ();
+
+ return true;
+ }
+
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]