[gnome-games/wip/exalm/unified-window: 49/60] display-box: Use the same headerbar in fullscreen and windowed



commit 063c0f56fd1ba8bccde402d227c527b85754cc64
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Apr 10 17:09:56 2020 +0500

    display-box: Use the same headerbar in fullscreen and windowed
    
    Since TitlebarBox allows to toggle overlaying now, we can get rid of the
    "normal" DisplayHeaderBar and use the fullscreen one both when windowed
    and in fullscreen.

 data/ui/display-box.ui         | 11 ++---------
 data/ui/display-header-bar.ui  |  2 +-
 src/ui/display-box.vala        | 33 ++++++++-------------------------
 src/ui/display-header-bar.vala |  1 -
 src/ui/display-view.vala       | 23 ++---------------------
 src/ui/fullscreen-box.vala     |  5 ++---
 6 files changed, 15 insertions(+), 60 deletions(-)
---
diff --git a/data/ui/display-box.ui b/data/ui/display-box.ui
index 537a024a..2559143e 100644
--- a/data/ui/display-box.ui
+++ b/data/ui/display-box.ui
@@ -5,26 +5,19 @@
     <property name="visible">True</property>
     <property name="orientation">vertical</property>
     <signal name="notify::is-showing-snapshots" handler="update_fullscreen_box"/>
-    <signal name="notify::is-menu-open" handler="update_fullscreen_box"/>
     <signal name="notify::is-fullscreen" handler="update_fullscreen_box"/>
-    <child>
-      <object class="GamesDisplayHeaderBar" id="header_bar">
-        <property name="visible">True</property>
-      </object>
-    </child>
     <child>
       <object class="GamesFullscreenBox" id="fullscreen_box">
         <property name="visible">True</property>
         <property name="is-fullscreen" bind-source="GamesDisplayBox" bind-property="is-fullscreen" 
bind-flags="bidirectional"/>
         <child type="titlebar">
-          <object class="GamesDisplayHeaderBar" id="fullscreen_header_bar">
+          <object class="GamesDisplayHeaderBar" id="header_bar">
             <property name="visible">True</property>
-            <property name="show-title-buttons">False</property>
             <property name="can-fullscreen" bind-source="GamesDisplayBox" bind-property="can-fullscreen" 
bind-flags="bidirectional"/>
             <property name="game-title" bind-source="GamesDisplayBox" bind-property="game-title" 
bind-flags="bidirectional"/>
             <property name="is-showing-snapshots" bind-source="GamesDisplayBox" 
bind-property="is-showing-snapshots" bind-flags="bidirectional"/>
             <signal name="notify::is-menu-open" handler="update_fullscreen_box"/>
-            <signal name="back" handler="on_fullscreen_header_bar_back"/>
+            <signal name="back" handler="on_header_bar_back"/>
           </object>
         </child>
         <child>
diff --git a/data/ui/display-header-bar.ui b/data/ui/display-header-bar.ui
index f78950dd..0b289498 100644
--- a/data/ui/display-header-bar.ui
+++ b/data/ui/display-header-bar.ui
@@ -15,7 +15,7 @@
           <object class="HdyHeaderBar" id="ingame_header_bar">
             <property name="visible">True</property>
             <property name="title" bind-source="GamesDisplayHeaderBar" bind-property="game-title" 
bind-flags="bidirectional"/>
-            <property name="show-close-button" bind-source="GamesDisplayHeaderBar" 
bind-property="show-title-buttons" bind-flags="bidirectional|sync-create"/>
+            <property name="show-close-button" bind-source="GamesDisplayHeaderBar" 
bind-property="is-fullscreen" bind-flags="bidirectional|sync-create|invert-boolean"/>
             <style>
               <class name="titlebar"/>
             </style>
diff --git a/src/ui/display-box.vala b/src/ui/display-box.vala
index 2d11aafc..9b76fb30 100644
--- a/src/ui/display-box.vala
+++ b/src/ui/display-box.vala
@@ -6,22 +6,9 @@ private class Games.DisplayBox : Gtk.Box {
        public signal void snapshots_hidden ();
        public signal void restart ();
 
-       private bool _is_fullscreen;
-       public bool is_fullscreen {
-               get { return _is_fullscreen; }
-               set {
-                       _is_fullscreen = value;
-
-                       windowed_header_bar.visible = !value;
-               }
-       }
-
+       public bool is_fullscreen { get; set; }
        public bool is_showing_snapshots { get; set; }
 
-       public DisplayHeaderBar header_bar {
-               get { return fullscreen_header_bar; }
-       }
-
        private Runner _runner;
        public Runner runner {
                get { return _runner; }
@@ -47,9 +34,12 @@ private class Games.DisplayBox : Gtk.Box {
                }
        }
 
+       public MediaSet? media_set {
+               set { header_bar.media_set = value; }
+       }
+
        public bool can_fullscreen { get; set; }
        public string game_title { get; set; }
-       public bool is_menu_open { get; set; }
 
        [GtkChild]
        private Gtk.Stack stack;
@@ -62,17 +52,11 @@ private class Games.DisplayBox : Gtk.Box {
        [GtkChild]
        private FullscreenBox fullscreen_box;
        [GtkChild]
-       private DisplayHeaderBar fullscreen_header_bar;
+       private DisplayHeaderBar header_bar;
        [GtkChild]
        private FlashBox flash_box;
        [GtkChild]
        private SnapshotsList snapshots_list;
-       [GtkChild (name="header_bar")]
-       private DisplayHeaderBar _header_bar;
-
-       public DisplayHeaderBar windowed_header_bar {
-               get { return _header_bar; }
-       }
 
        public void display_running_game_failed (Game game, string error_message) {
                stack.visible_child = error_display;
@@ -87,14 +71,13 @@ private class Games.DisplayBox : Gtk.Box {
 
        [GtkCallback]
        public void update_fullscreen_box () {
-               fullscreen_box.autohide = !is_menu_open &&
-                                         !fullscreen_header_bar.is_menu_open &&
+               fullscreen_box.autohide = !header_bar.is_menu_open &&
                                          !is_showing_snapshots;
                fullscreen_box.overlay = is_fullscreen && !is_showing_snapshots;
        }
 
        [GtkCallback]
-       private void on_fullscreen_header_bar_back () {
+       private void on_header_bar_back () {
                back ();
        }
 
diff --git a/src/ui/display-header-bar.vala b/src/ui/display-header-bar.vala
index a8d2fbc8..ba9c3c17 100644
--- a/src/ui/display-header-bar.vala
+++ b/src/ui/display-header-bar.vala
@@ -10,7 +10,6 @@ private class Games.DisplayHeaderBar : Gtk.Bin {
        private MediaMenuButton media_button;
 
        public string game_title { get; set; }
-       public bool show_title_buttons { get; set; default = true; }
 
        public bool can_fullscreen { get; set; }
        public bool is_fullscreen { get; set; }
diff --git a/src/ui/display-view.vala b/src/ui/display-view.vala
index 883289ee..34745c96 100644
--- a/src/ui/display-view.vala
+++ b/src/ui/display-view.vala
@@ -6,7 +6,6 @@ private class Games.DisplayView : Object, UiView {
        public signal void back ();
 
        private DisplayBox box;
-       private DisplayHeaderBar header_bar;
 
        public Gtk.Widget content_box {
                get { return box; }
@@ -69,10 +68,8 @@ private class Games.DisplayView : Object, UiView {
 
        construct {
                box = new DisplayBox ();
-               header_bar = box.windowed_header_bar;
 
                box.back.connect (on_display_back);
-               header_bar.back.connect (on_display_back);
 
                box.snapshots_hidden.connect (on_snapshots_hidden);
 
@@ -80,32 +77,18 @@ private class Games.DisplayView : Object, UiView {
 
                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,
-                              "is-fullscreen", BindingFlags.BIDIRECTIONAL);
 
                bind_property ("is-showing-snapshots", box,
                               "is-showing-snapshots", BindingFlags.BIDIRECTIONAL);
-               bind_property ("is-showing-snapshots", header_bar,
-                              "is-showing-snapshots", BindingFlags.BIDIRECTIONAL);
 
                bind_property ("runner", box,
                               "runner", BindingFlags.BIDIRECTIONAL);
-               bind_property ("runner", header_bar,
-                              "runner", BindingFlags.BIDIRECTIONAL);
 
                bind_property ("game-title", box,
                               "game-title", BindingFlags.BIDIRECTIONAL);
-               bind_property ("game-title", header_bar,
-                              "game-title", BindingFlags.BIDIRECTIONAL);
-
-               header_bar.notify["is-menu-open"].connect (() => {
-                       box.is_menu_open = header_bar.is_menu_open;
-               });
 
                focus_out_timeout_id = -1;
 
@@ -318,8 +301,7 @@ private class Games.DisplayView : Object, UiView {
                        return;
 
                can_fullscreen = runner.can_fullscreen;
-               header_bar.media_set = runner.media_set;
-               box.header_bar.media_set = runner.media_set;
+               box.media_set = runner.media_set;
 
                runner.crash.connect (message => {
                        runner.stop ();
@@ -524,8 +506,7 @@ private class Games.DisplayView : Object, UiView {
        private void reset_display_page () {
                can_fullscreen = false;
                runner = null;
-               header_bar.media_set = null;
-               box.header_bar.media_set = null;
+               box.media_set = null;
 
                update_actions ();
        }
diff --git a/src/ui/fullscreen-box.vala b/src/ui/fullscreen-box.vala
index f8c82181..60ec5342 100644
--- a/src/ui/fullscreen-box.vala
+++ b/src/ui/fullscreen-box.vala
@@ -50,7 +50,7 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
                                        cursor_timeout_id = -1;
                                }
 
-                               titlebar_box.reveal_titlebar = is_fullscreen;
+                               titlebar_box.reveal_titlebar = true;
                                show_cursor (true);
                        }
                }
@@ -129,7 +129,7 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
                        return;
 
                ui_timeout_id = Timeout.add (INACTIVITY_TIME_MILLISECONDS, hide_ui);
-               titlebar_box.reveal_titlebar = is_fullscreen;
+               titlebar_box.reveal_titlebar = true;
        }
 
        private bool hide_ui () {
@@ -173,7 +173,6 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
                        cursor_timeout_id = -1;
                }
 
-               titlebar_box.reveal_titlebar = false;
                on_cursor_moved ();
        }
 


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