[gnome-games] display-view: Bind can-fullscreen property



commit 6213d6d7f4a3a373d3b6325feaaaf08cd692eece
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Tue Jan 28 19:17:07 2020 +0500

    display-view: Bind can-fullscreen property

 src/ui/display-box.vala  |  7 +++++++
 src/ui/display-view.vala | 17 ++++++++++-------
 2 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/src/ui/display-box.vala b/src/ui/display-box.vala
index 6f3ff94a..05aaaeea 100644
--- a/src/ui/display-box.vala
+++ b/src/ui/display-box.vala
@@ -48,6 +48,8 @@ private class Games.DisplayBox : Gtk.Bin {
                }
        }
 
+       public bool can_fullscreen { get; set; }
+
        [GtkChild]
        private Gtk.Stack stack;
        [GtkChild]
@@ -65,6 +67,11 @@ private class Games.DisplayBox : Gtk.Bin {
 
        private int fullscreen_header_bar_height;
 
+       construct {
+               bind_property ("can-fullscreen", header_bar,
+                              "can-fullscreen", BindingFlags.BIDIRECTIONAL);
+       }
+
        public void display_running_game_failed (Game game, string error_message) {
                stack.visible_child = error_display;
                error_display.running_game_failed (game, error_message);
diff --git a/src/ui/display-view.vala b/src/ui/display-view.vala
index 0f29f63e..543e45b2 100644
--- a/src/ui/display-view.vala
+++ b/src/ui/display-view.vala
@@ -40,6 +40,7 @@ private class Games.DisplayView : Object, UiView {
 
        public Gtk.Window window { get; construct; }
 
+       public bool can_fullscreen { get; set; }
        public bool is_fullscreen { get; set; }
        public bool is_showing_snapshots { get; set; }
 
@@ -76,6 +77,11 @@ private class Games.DisplayView : Object, UiView {
 
                settings = new Settings ("org.gnome.Games");
 
+               bind_property ("can-fullscreen", box,
+                              "can-fullscreen", BindingFlags.BIDIRECTIONAL);
+               bind_property ("can-fullscreen", header_bar,
+                              "can-fullscreen", BindingFlags.BIDIRECTIONAL);
+
                bind_property ("is-fullscreen", box,
                               "is-fullscreen", BindingFlags.BIDIRECTIONAL);
                bind_property ("is-fullscreen", header_bar,
@@ -116,15 +122,14 @@ private class Games.DisplayView : Object, UiView {
                        return true;
 
                if ((keyval == Gdk.Key.f || keyval == Gdk.Key.F) && ctrl_pressed &&
-                   header_bar.can_fullscreen && !is_showing_snapshots) {
+                   can_fullscreen && !is_showing_snapshots) {
                        is_fullscreen = !is_fullscreen;
                        settings.set_boolean ("fullscreen", is_fullscreen);
 
                        return true;
                }
 
-               if (keyval == Gdk.Key.F11 && header_bar.can_fullscreen &&
-                   !is_showing_snapshots) {
+               if (keyval == Gdk.Key.F11 && can_fullscreen && !is_showing_snapshots) {
                        is_fullscreen = !is_fullscreen;
                        settings.set_boolean ("fullscreen", is_fullscreen);
 
@@ -291,8 +296,7 @@ private class Games.DisplayView : Object, UiView {
                if (runner == null)
                        return;
 
-               header_bar.can_fullscreen = runner.can_fullscreen;
-               box.header_bar.can_fullscreen = runner.can_fullscreen;
+               can_fullscreen = runner.can_fullscreen;
                header_bar.runner = runner;
                box.runner = runner;
                header_bar.media_set = runner.media_set;
@@ -490,8 +494,7 @@ private class Games.DisplayView : Object, UiView {
        }
 
        private void reset_display_page () {
-               header_bar.can_fullscreen = false;
-               box.header_bar.can_fullscreen = false;
+               can_fullscreen = false;
                header_bar.runner = null;
                box.runner = null;
                header_bar.media_set = null;


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