[gnome-games] collection-haeder-bar: Don't subclass GtkStack



commit 9935808bb8d9aa658c69eb104596553bc11403b0
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Mon Aug 19 21:08:08 2019 +0500

    collection-haeder-bar: Don't subclass GtkStack
    
    Instead, subclass GtkBin and include a stack.

 data/ui/collection-header-bar.ui  | 253 +++++++++++++++++++-------------------
 src/ui/collection-header-bar.vala |   8 +-
 2 files changed, 134 insertions(+), 127 deletions(-)
---
diff --git a/data/ui/collection-header-bar.ui b/data/ui/collection-header-bar.ui
index 12012a6b..d3725e1d 100644
--- a/data/ui/collection-header-bar.ui
+++ b/data/ui/collection-header-bar.ui
@@ -1,171 +1,176 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="3.24"/>
-  <template class="GamesCollectionHeaderBar" parent="GtkStack">
+  <template class="GamesCollectionHeaderBar" parent="GtkBin">
     <property name="visible">True</property>
-    <property name="transition-type">slide-left-right</property>
     <child>
-      <object class="HdyHeaderBar">
+      <object class="GtkStack" id="stack">
         <property name="visible">True</property>
-        <property name="show-close-button">True</property>
-        <property name="centering-policy">strict</property>
+        <property name="transition-type">slide-left-right</property>
         <child>
-          <object class="GtkButton" id="add_game">
+          <object class="HdyHeaderBar">
             <property name="visible">True</property>
-            <property name="valign">center</property>
-            <property name="use-underline">True</property>
-            <property name="action-name">app.add-game-files</property>
-            <style>
-              <class name="image-button"/>
-            </style>
-            <child internal-child="accessible">
-              <object class="AtkObject" id="a11y-back">
-                <property name="accessible-name" translatable="yes">Add game files…</property>
-              </object>
-            </child>
+            <property name="show-close-button">True</property>
+            <property name="centering-policy">strict</property>
             <child>
-              <object class="GtkImage" id="add_game_image">
+              <object class="GtkButton" id="add_game">
                 <property name="visible">True</property>
-                <property name="icon-name">list-add-symbolic</property>
-                <property name="icon-size">1</property>
+                <property name="valign">center</property>
+                <property name="use-underline">True</property>
+                <property name="action-name">app.add-game-files</property>
+                <style>
+                  <class name="image-button"/>
+                </style>
+                <child internal-child="accessible">
+                  <object class="AtkObject" id="a11y-back">
+                    <property name="accessible-name" translatable="yes">Add game files…</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkImage" id="add_game_image">
+                    <property name="visible">True</property>
+                    <property name="icon-name">list-add-symbolic</property>
+                    <property name="icon-size">1</property>
+                  </object>
+                </child>
               </object>
+              <packing>
+                <property name="pack-type">start</property>
+              </packing>
             </child>
-          </object>
-          <packing>
-            <property name="pack-type">start</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkMenuButton" id="menu">
-            <property name="popover">menu_popover</property>
-            <!-- Translators: tooltip for the application menu button -->
-            <property name="tooltip-text" translatable="yes">Menu</property>
-            <property name="use-underline">True</property>
-            <property name="valign">center</property>
-            <property name="visible">True</property>
-            <style>
-              <class name="image-button"/>
-            </style>
             <child>
-              <object class="GtkImage" id="menu_image">
+              <object class="GtkMenuButton" id="menu">
+                <property name="popover">menu_popover</property>
+                <!-- Translators: tooltip for the application menu button -->
+                <property name="tooltip-text" translatable="yes">Menu</property>
+                <property name="use-underline">True</property>
+                <property name="valign">center</property>
                 <property name="visible">True</property>
-                <property name="icon-name">open-menu-symbolic</property>
-                <property name="icon-size">1</property>
+                <style>
+                  <class name="image-button"/>
+                </style>
+                <child>
+                  <object class="GtkImage" id="menu_image">
+                    <property name="visible">True</property>
+                    <property name="icon-name">open-menu-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 type="title">
-          <object class="HdySqueezer" id="title_squeezer">
-            <property name="visible">True</property>
-            <property name="transition-type">crossfade</property>
-            <signal name="notify::visible-child" handler="on_squeezer_visible_child_changed"/>
-            <child>
-              <object class="HdyViewSwitcher" id="view_switcher">
+            <child type="title">
+              <object class="HdySqueezer" id="title_squeezer">
                 <property name="visible">True</property>
-                <property name="policy">wide</property>
+                <property name="transition-type">crossfade</property>
+                <signal name="notify::visible-child" handler="on_squeezer_visible_child_changed"/>
+                <child>
+                  <object class="HdyViewSwitcher" id="view_switcher">
+                    <property name="visible">True</property>
+                    <property name="policy">wide</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkLabel">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Games</property>
+                    <style>
+                      <class name="title"/>
+                    </style>
+                  </object>
+                </child>
               </object>
             </child>
             <child>
-              <object class="GtkLabel">
+              <object class="GtkToggleButton" id="search">
                 <property name="visible">True</property>
-                <property name="label" translatable="yes">Games</property>
+                <property name="valign">center</property>
+                <property name="use-underline">True</property>
                 <style>
-                  <class name="title"/>
+                  <class name="image-button"/>
                 </style>
+                <child internal-child="accessible">
+                  <object class="AtkObject" id="a11y-search">
+                    <property name="accessible-name" translatable="yes">Search</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkImage" id="search_image">
+                    <property name="visible">True</property>
+                    <property name="icon-name">edit-find-symbolic</property>
+                    <property name="icon-size">1</property>
+                  </object>
+                </child>
               </object>
-            </child>
-          </object>
-        </child>
-        <child>
-          <object class="GtkToggleButton" id="search">
-            <property name="visible">True</property>
-            <property name="valign">center</property>
-            <property name="use-underline">True</property>
-            <style>
-              <class name="image-button"/>
-            </style>
-            <child internal-child="accessible">
-              <object class="AtkObject" id="a11y-search">
-                <property name="accessible-name" translatable="yes">Search</property>
-              </object>
-            </child>
-            <child>
-              <object class="GtkImage" id="search_image">
-                <property name="visible">True</property>
-                <property name="icon-name">edit-find-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>
+            <property name="name">main</property>
           </packing>
         </child>
-      </object>
-      <packing>
-        <property name="name">main</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkHeaderBar" id="subview_header_bar">
-        <property name="visible">True</property>
-        <property name="show_close_button">True</property>
         <child>
-          <object class="GtkButton">
+          <object class="GtkHeaderBar" id="subview_header_bar">
             <property name="visible">True</property>
-            <property name="valign">center</property>
-            <property name="use-underline">True</property>
-            <signal name="clicked" handler="on_subview_back_clicked"/>
-            <style>
-              <class name="image-button"/>
-            </style>
-            <child internal-child="accessible">
-              <object class="AtkObject">
-                <property name="accessible-name" translatable="yes">Back</property>
-              </object>
-            </child>
+            <property name="show_close_button">True</property>
             <child>
-              <object class="GtkImage">
+              <object class="GtkButton">
                 <property name="visible">True</property>
-                <property name="icon-name">go-previous-symbolic</property>
-                <property name="icon-size">1</property>
-              </object>
-            </child>
-          </object>
-        </child>
-        <child>
-          <object class="GtkToggleButton" id="search_subview">
-            <property name="visible">True</property>
-            <property name="valign">center</property>
-            <property name="use-underline">True</property>
-            <style>
-              <class name="image-button"/>
-            </style>
-            <child internal-child="accessible">
-              <object class="AtkObject">
-                <property name="accessible-name" translatable="yes">Search</property>
+                <property name="valign">center</property>
+                <property name="use-underline">True</property>
+                <signal name="clicked" handler="on_subview_back_clicked"/>
+                <style>
+                  <class name="image-button"/>
+                </style>
+                <child internal-child="accessible">
+                  <object class="AtkObject">
+                    <property name="accessible-name" translatable="yes">Back</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkImage">
+                    <property name="visible">True</property>
+                    <property name="icon-name">go-previous-symbolic</property>
+                    <property name="icon-size">1</property>
+                  </object>
+                </child>
               </object>
             </child>
             <child>
-              <object class="GtkImage">
+              <object class="GtkToggleButton" id="search_subview">
                 <property name="visible">True</property>
-                <property name="icon-name">edit-find-symbolic</property>
-                <property name="icon-size">1</property>
+                <property name="valign">center</property>
+                <property name="use-underline">True</property>
+                <style>
+                  <class name="image-button"/>
+                </style>
+                <child internal-child="accessible">
+                  <object class="AtkObject">
+                    <property name="accessible-name" translatable="yes">Search</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkImage">
+                    <property name="visible">True</property>
+                    <property name="icon-name">edit-find-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>
+            <property name="name">subview</property>
           </packing>
         </child>
       </object>
-      <packing>
-        <property name="name">subview</property>
-      </packing>
     </child>
   </template>
   <object class="GtkPopover" id="menu_popover">
diff --git a/src/ui/collection-header-bar.vala b/src/ui/collection-header-bar.vala
index 905844a9..0801b79d 100644
--- a/src/ui/collection-header-bar.vala
+++ b/src/ui/collection-header-bar.vala
@@ -1,7 +1,7 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 [GtkTemplate (ui = "/org/gnome/Games/ui/collection-header-bar.ui")]
-private class Games.CollectionHeaderBar : Gtk.Stack {
+private class Games.CollectionHeaderBar : Gtk.Bin {
        public bool search_mode { get; set; }
        private Gtk.Stack _viewstack;
        public Gtk.Stack viewstack {
@@ -39,6 +39,8 @@ private class Games.CollectionHeaderBar : Gtk.Stack {
                }
        }
 
+       [GtkChild]
+       private Gtk.Stack stack;
        [GtkChild]
        private Gtk.HeaderBar subview_header_bar;
        [GtkChild]
@@ -78,14 +80,14 @@ private class Games.CollectionHeaderBar : Gtk.Stack {
 
        private void update_subview () {
                bool show_subview = adaptive_state.is_subview_open && adaptive_state.is_folded;
-               visible_child_name = show_subview ? "subview" : "main";
+               stack.visible_child_name = show_subview ? "subview" : "main";
        }
 
        private void update_folded () {
                bool show_subview = adaptive_state.is_subview_open && adaptive_state.is_folded;
 
                // FIXME: have a transition here. Crossfade doens't work well at the moment
-               set_visible_child_full (show_subview ? "subview" : "main", Gtk.StackTransitionType.NONE);
+               stack.set_visible_child_full (show_subview ? "subview" : "main", 
Gtk.StackTransitionType.NONE);
        }
 
        private void update_subview_title () {


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