[gnome-games/wip/exalm/cleanups: 2/5] display-header-bar: Don't subclass GtkHeaderBar



commit 6be03da2b148eebe29720e4ca30b4a3bbbbc81a6
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Wed May 29 16:34:49 2019 +0500

    display-header-bar: Don't subclass GtkHeaderBar
    
    It was made non-derivable in GTK4.

 data/ui/display-box.ui         |   2 +-
 data/ui/display-header-bar.ui  | 165 +++++++++++++++++++++--------------------
 src/ui/display-header-bar.vala |  13 +++-
 3 files changed, 95 insertions(+), 85 deletions(-)
---
diff --git a/data/ui/display-box.ui b/data/ui/display-box.ui
index 0967aa3a..db028f54 100644
--- a/data/ui/display-box.ui
+++ b/data/ui/display-box.ui
@@ -9,7 +9,7 @@
         <child type="titlebar">
           <object class="GamesDisplayHeaderBar" id="fullscreen_header_bar">
             <property name="visible">True</property>
-            <property name="show-close-button">False</property>
+            <property name="show-title-buttons">False</property>
             <signal name="back" handler="on_fullscreen_header_bar_back"/>
           </object>
         </child>
diff --git a/data/ui/display-header-bar.ui b/data/ui/display-header-bar.ui
index 8a2a8094..09e57473 100644
--- a/data/ui/display-header-bar.ui
+++ b/data/ui/display-header-bar.ui
@@ -1,107 +1,112 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="3.24"/>
-  <template class="GamesDisplayHeaderBar" parent="GtkHeaderBar">
+  <template class="GamesDisplayHeaderBar" parent="GtkBin">
     <property name="visible">True</property>
-    <property name="title" translatable="yes">Games</property>
-    <property name="show_close_button">True</property>
     <signal name="notify::is-fullscreen" handler="on_fullscreen_changed"/>
     <signal name="notify::can-fullscreen" handler="on_fullscreen_changed"/>
     <child>
-      <object class="GtkButton" id="back">
+      <object class="GtkHeaderBar" id="header_bar">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="valign">center</property>
-        <property name="use-underline">True</property>
-        <signal name="clicked" handler="on_back_clicked"/>
-        <style>
-          <class name="image-button"/>
-        </style>
-        <child internal-child="accessible">
-          <object class="AtkObject" id="a11y-back">
-            <property name="accessible-name" translatable="yes">Back</property>
-          </object>
-        </child>
+        <property name="title" translatable="yes">Games</property>
+        <property name="show_close_button">True</property>
         <child>
-          <object class="GtkImage" id="back_image">
+          <object class="GtkButton" id="back">
             <property name="visible">True</property>
-            <property name="icon-name">go-previous-symbolic</property>
-            <property name="icon-size">1</property>
+            <property name="can_focus">False</property>
+            <property name="valign">center</property>
+            <property name="use-underline">True</property>
+            <signal name="clicked" handler="on_back_clicked"/>
+            <style>
+              <class name="image-button"/>
+            </style>
+            <child internal-child="accessible">
+              <object class="AtkObject" id="a11y-back">
+                <property name="accessible-name" translatable="yes">Back</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkImage" id="back_image">
+                <property name="visible">True</property>
+                <property name="icon-name">go-previous-symbolic</property>
+                <property name="icon-size">1</property>
+              </object>
+            </child>
           </object>
         </child>
-      </object>
-    </child>
-    <child>
-      <object class="GtkButton" id="fullscreen">
-        <property name="visible">False</property>
-        <property name="can_focus">False</property>
-        <property name="valign">center</property>
-        <property name="use-underline">True</property>
-        <signal name="clicked" handler="on_fullscreen_clicked"/>
-        <style>
-          <class name="image-button"/>
-        </style>
-        <child internal-child="accessible">
-          <object class="AtkObject" id="a11y-fullscreen">
-            <property name="accessible-name" translatable="yes">Fullscreen</property>
+        <child>
+          <object class="GtkButton" id="fullscreen">
+            <property name="visible">False</property>
+            <property name="can_focus">False</property>
+            <property name="valign">center</property>
+            <property name="use-underline">True</property>
+            <signal name="clicked" handler="on_fullscreen_clicked"/>
+            <style>
+              <class name="image-button"/>
+            </style>
+            <child internal-child="accessible">
+              <object class="AtkObject" id="a11y-fullscreen">
+                <property name="accessible-name" translatable="yes">Fullscreen</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkImage" id="fullscreen_image">
+                <property name="visible">True</property>
+                <property name="icon-name">view-fullscreen-symbolic</property>
+                <property name="icon-size">1</property>
+              </object>
+            </child>
           </object>
+          <packing>
+            <property name="pack-type">end</property>
+          </packing>
         </child>
         <child>
-          <object class="GtkImage" id="fullscreen_image">
-            <property name="visible">True</property>
-            <property name="icon-name">view-fullscreen-symbolic</property>
-            <property name="icon-size">1</property>
+          <object class="GtkButton" id="restore">
+            <property name="visible">False</property>
+            <property name="can_focus">False</property>
+            <property name="valign">center</property>
+            <property name="use-underline">True</property>
+            <signal name="clicked" handler="on_restore_clicked"/>
+            <style>
+              <class name="image-button"/>
+            </style>
+            <child internal-child="accessible">
+              <object class="AtkObject" id="a11y-restore">
+                <property name="accessible-name" translatable="yes">Restore</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkImage" id="restore_image">
+                <property name="visible">True</property>
+                <property name="icon-name">view-restore-symbolic</property>
+                <property name="icon-size">1</property>
+              </object>
+            </child>
           </object>
+          <packing>
+            <property name="pack-type">end</property>
+          </packing>
         </child>
-      </object>
-      <packing>
-        <property name="pack-type">end</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkButton" id="restore">
-        <property name="visible">False</property>
-        <property name="can_focus">False</property>
-        <property name="valign">center</property>
-        <property name="use-underline">True</property>
-        <signal name="clicked" handler="on_restore_clicked"/>
-        <style>
-          <class name="image-button"/>
-        </style>
-        <child internal-child="accessible">
-          <object class="AtkObject" id="a11y-restore">
-            <property name="accessible-name" translatable="yes">Restore</property>
+        <child>
+          <object class="GamesMediaMenuButton" id="media_button">
+            <property name="visible">False</property>
+            <property name="valign">center</property>
+            <property name="use-underline">True</property>
           </object>
+          <packing>
+            <property name="pack-type">end</property>
+          </packing>
         </child>
         <child>
-          <object class="GtkImage" id="restore_image">
+          <object class="GamesInputModeSwitcher" id="input_mode_switcher">
             <property name="visible">True</property>
-            <property name="icon-name">view-restore-symbolic</property>
-            <property name="icon-size">1</property>
           </object>
+          <packing>
+            <property name="pack-type">end</property>
+          </packing>
         </child>
       </object>
-      <packing>
-        <property name="pack-type">end</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GamesMediaMenuButton" id="media_button">
-        <property name="visible">False</property>
-        <property name="valign">center</property>
-        <property name="use-underline">True</property>
-      </object>
-      <packing>
-        <property name="pack-type">end</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GamesInputModeSwitcher" id="input_mode_switcher">
-        <property name="visible">True</property>
-      </object>
-      <packing>
-        <property name="pack-type">end</property>
-      </packing>
     </child>
   </template>
 </interface>
diff --git a/src/ui/display-header-bar.vala b/src/ui/display-header-bar.vala
index 6d692157..9fc09f10 100644
--- a/src/ui/display-header-bar.vala
+++ b/src/ui/display-header-bar.vala
@@ -1,14 +1,18 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 [GtkTemplate (ui = "/org/gnome/Games/ui/display-header-bar.ui")]
-private class Games.DisplayHeaderBar : Gtk.HeaderBar {
+private class Games.DisplayHeaderBar : Gtk.Bin {
        public signal void back ();
 
        [GtkChild]
        private MediaMenuButton media_button;
 
        public string game_title {
-               set { title = value; }
+               set { header_bar.title = value; }
+       }
+
+       public bool show_title_buttons {
+               set { header_bar.show_close_button = value; }
        }
 
        public bool can_fullscreen { get; set; }
@@ -52,13 +56,14 @@ private class Games.DisplayHeaderBar : Gtk.HeaderBar {
                        _extra_widget = value;
 
                        if (extra_widget != null)
-                               pack_end (extra_widget);
+                               header_bar.pack_end (extra_widget);
                }
        }
 
+       [GtkChild]
+       private Gtk.HeaderBar header_bar;
        [GtkChild]
        private Gtk.Button fullscreen;
-
        [GtkChild]
        private Gtk.Button restore;
 


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