[gnome-games/wip/exalm/views] display-view: Handle keys
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/views] display-view: Handle keys
- Date: Thu, 4 Oct 2018 17:58:23 +0000 (UTC)
commit eda3cefb7d50490d2169f585f51436720f667246
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Thu Oct 4 21:51:26 2018 +0500
display-view: Handle keys
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 5c059018..e3dafa50 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -189,10 +189,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]
@@ -545,46 +542,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.display_header_bar.can_fullscreen) {
- is_fullscreen = !is_fullscreen;
- settings.set_boolean ("fullscreen", is_fullscreen);
-
- return true;
- }
-
- if (event.keyval == Gdk.Key.F11 && display_view.display_header_bar.can_fullscreen) {
- is_fullscreen = !is_fullscreen;
- settings.set_boolean ("fullscreen", is_fullscreen);
-
- return true;
- }
-
- if (event.keyval == Gdk.Key.Escape && display_view.display_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 30079af4..6df23af9 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", display_box,
"is-fullscreen",
BindingFlags.BIDIRECTIONAL);
@@ -62,6 +66,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 &&
+ display_header_bar.can_fullscreen) {
+ is_fullscreen = !is_fullscreen;
+ settings.set_boolean ("fullscreen", is_fullscreen);
+
+ return true;
+ }
+
+ if (event.keyval == Gdk.Key.F11 && display_header_bar.can_fullscreen) {
+ is_fullscreen = !is_fullscreen;
+ settings.set_boolean ("fullscreen", is_fullscreen);
+
+ return true;
+ }
+
+ if (event.keyval == Gdk.Key.Escape && display_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]