[gnome-games/wip/exalm/views: 16/18] display-view: Handle key events
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/views: 16/18] display-view: Handle key events
- Date: Sun, 7 Oct 2018 07:25:22 +0000 (UTC)
commit 4d9b6836df80fb14f56488cd8149929775e07746
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 4a90e74c..0ce6eb0d 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 c731df43..007b304b 100644
--- a/src/ui/display-view.vala
+++ b/src/ui/display-view.vala
@@ -37,10 +37,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,
@@ -59,6 +63,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]