[gnome-games/wip/exalm/libhandy2: 11/21] ui: Drop custom headerbars from preferences pages



commit ef8e569655f2b2e142616b9935e30aee98aa30c2
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Wed Sep 12 02:37:57 2018 +0500

    ui: Drop custom headerbars from preferences pages
    
    Just set title instead.

 data/ui/preferences-page-controllers.ui  |  5 -----
 data/ui/preferences-page-plugins.ui      |  5 -----
 data/ui/preferences-page-video.ui        |  5 -----
 data/ui/preferences-window.ui            |  8 ++++++++
 src/ui/preferences-page-controllers.vala |  7 -------
 src/ui/preferences-page-plugins.vala     |  7 -------
 src/ui/preferences-page-video.vala       |  7 -------
 src/ui/preferences-page.vala             |  1 -
 src/ui/preferences-window.vala           | 26 ++++++++------------------
 9 files changed, 16 insertions(+), 55 deletions(-)
---
diff --git a/data/ui/preferences-page-controllers.ui b/data/ui/preferences-page-controllers.ui
index 486d9582..f0fe2fd8 100644
--- a/data/ui/preferences-page-controllers.ui
+++ b/data/ui/preferences-page-controllers.ui
@@ -67,9 +67,4 @@
       </object>
     </child>
   </template>
-  <object class="GtkHeaderBar" id="header_bar">
-    <property name="visible">True</property>
-    <property name="expand">True</property>
-    <property name="title" translatable="yes">Controllers</property>
-  </object>
 </interface>
diff --git a/data/ui/preferences-page-plugins.ui b/data/ui/preferences-page-plugins.ui
index e135a45e..90c0eb61 100644
--- a/data/ui/preferences-page-plugins.ui
+++ b/data/ui/preferences-page-plugins.ui
@@ -34,9 +34,4 @@
       </object>
     </child>
   </template>
-  <object class="GtkHeaderBar" id="header_bar">
-    <property name="visible">True</property>
-    <property name="expand">True</property>
-    <property name="title" translatable="yes">Extensions</property>
-  </object>
 </interface>
diff --git a/data/ui/preferences-page-video.ui b/data/ui/preferences-page-video.ui
index 3f0c038e..e3c1dde5 100644
--- a/data/ui/preferences-page-video.ui
+++ b/data/ui/preferences-page-video.ui
@@ -44,9 +44,4 @@
       </object>
     </child>
   </template>
-  <object class="GtkHeaderBar" id="header_bar">
-    <property name="visible">True</property>
-    <property name="expand">True</property>
-    <property name="title" translatable="yes">Video</property>
-  </object>
 </interface>
diff --git a/data/ui/preferences-window.ui b/data/ui/preferences-window.ui
index 2b597a2d..0b9e4c3e 100644
--- a/data/ui/preferences-window.ui
+++ b/data/ui/preferences-window.ui
@@ -29,6 +29,14 @@
                 <property name="visible">True</property>
               </object>
             </child>
+            <child>
+              <object class="GtkHeaderBar" id="right_header_bar">
+                <property name="name">right_header_bar</property>
+                <property name="visible">True</property>
+                <property name="hexpand">True</property>
+                <property name="show-close-button">True</property>
+              </object>
+            </child>
           </object>
         </child>
       </object>
diff --git a/src/ui/preferences-page-controllers.vala b/src/ui/preferences-page-controllers.vala
index f5b3d18f..902d1420 100644
--- a/src/ui/preferences-page-controllers.vala
+++ b/src/ui/preferences-page-controllers.vala
@@ -2,13 +2,6 @@
 
 [GtkTemplate (ui = "/org/gnome/Games/ui/preferences-page-controllers.ui")]
 private class Games.PreferencesPageControllers: Gtk.Bin, PreferencesPage {
-       [GtkChild (name = "header_bar")]
-       private Gtk.HeaderBar _header_bar;
-       public Gtk.HeaderBar header_bar {
-               protected set {}
-               get { return _header_bar; }
-       }
-
        public PreferencesSubpage subpage { get; protected set; }
 
        [GtkChild]
diff --git a/src/ui/preferences-page-plugins.vala b/src/ui/preferences-page-plugins.vala
index f0bb2bbe..091b4021 100644
--- a/src/ui/preferences-page-plugins.vala
+++ b/src/ui/preferences-page-plugins.vala
@@ -2,13 +2,6 @@
 
 [GtkTemplate (ui = "/org/gnome/Games/ui/preferences-page-plugins.ui")]
 private class Games.PreferencesPagePlugins: Gtk.Bin, PreferencesPage {
-       [GtkChild (name = "header_bar")]
-       private Gtk.HeaderBar _header_bar;
-       public Gtk.HeaderBar header_bar {
-               get { return _header_bar; }
-               protected set {}
-       }
-
        public PreferencesSubpage subpage { get; protected set; }
 
        [GtkChild]
diff --git a/src/ui/preferences-page-video.vala b/src/ui/preferences-page-video.vala
index 11cc7710..0077428b 100644
--- a/src/ui/preferences-page-video.vala
+++ b/src/ui/preferences-page-video.vala
@@ -2,13 +2,6 @@
 
 [GtkTemplate (ui = "/org/gnome/Games/ui/preferences-page-video.ui")]
 private class Games.PreferencesPageVideo: Gtk.Bin, PreferencesPage {
-       [GtkChild (name = "header_bar")]
-       private Gtk.HeaderBar _header_bar;
-       public Gtk.HeaderBar header_bar {
-               protected set {}
-               get { return _header_bar; }
-       }
-
        public PreferencesSubpage subpage { get; protected set; }
 
        private string _filter_active;
diff --git a/src/ui/preferences-page.vala b/src/ui/preferences-page.vala
index e04e4f54..de44674e 100644
--- a/src/ui/preferences-page.vala
+++ b/src/ui/preferences-page.vala
@@ -1,6 +1,5 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 private interface Games.PreferencesPage: Gtk.Widget {
-       public abstract Gtk.HeaderBar header_bar { get; protected set; }
        public abstract PreferencesSubpage subpage { get; protected set; }
 }
diff --git a/src/ui/preferences-window.vala b/src/ui/preferences-window.vala
index 5870f7dd..54cefc63 100644
--- a/src/ui/preferences-window.vala
+++ b/src/ui/preferences-window.vala
@@ -7,26 +7,14 @@ private class Games.PreferencesWindow : Gtk.Window {
        [GtkChild]
        private Gtk.Box titlebar_box;
        [GtkChild]
+       private Gtk.HeaderBar right_header_bar;
+       [GtkChild]
        private Gtk.Stack main_stack;
        [GtkChild]
        private Gtk.Box content_box;
        [GtkChild]
        private Gtk.Stack stack;
 
-       private Gtk.HeaderBar _right_header_bar;
-       public Gtk.HeaderBar right_header_bar {
-               get { return _right_header_bar; }
-               set {
-                       if (_right_header_bar != null)
-                               titlebar_box.remove (_right_header_bar);
-                       if (value != null) {
-                               titlebar_box.pack_end (value);
-                               value.show_close_button = true;
-                       }
-                       _right_header_bar = value;
-               }
-       }
-
        private PreferencesSubpage _subpage;
        public PreferencesSubpage subpage {
                get { return _subpage; }
@@ -58,7 +46,6 @@ private class Games.PreferencesWindow : Gtk.Window {
        // until the transition animation has ended
        private PreferencesSubpage previous_subpage;
 
-       private Binding right_header_bar_binding;
        private Binding subpage_binding;
 
        public PreferencesWindow () {
@@ -69,13 +56,16 @@ private class Games.PreferencesWindow : Gtk.Window {
        private void visible_child_changed () {
                var page = stack.visible_child as PreferencesPage;
                if (page == null) {
-                       right_header_bar = null;
+                       right_header_bar.title = "";
                        subpage = null;
 
                        return;
                }
-               right_header_bar_binding = page.bind_property ("header-bar", this, "right_header_bar",
-                                                              BindingFlags.SYNC_CREATE);
+
+               var title = "";
+               stack.child_get (page, "title", out title, null);
+               right_header_bar.title = title;
+
                subpage_binding = page.bind_property ("subpage", this, "subpage",
                                                      BindingFlags.SYNC_CREATE);
        }


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