[gnome-games] collection-box: Use a second stack for empty state



commit f81ee0d6a532a5ac6ad205f1d00a2083d3d977db
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Mon Jan 27 20:49:23 2020 +0500

    collection-box: Use a second stack for empty state

 data/ui/collection-box.ui  | 55 ++++++++++++++++++++++++++--------------------
 src/ui/collection-box.vala | 10 +++++----
 2 files changed, 37 insertions(+), 28 deletions(-)
---
diff --git a/data/ui/collection-box.ui b/data/ui/collection-box.ui
index 7684f45f..e26ad5e9 100644
--- a/data/ui/collection-box.ui
+++ b/data/ui/collection-box.ui
@@ -25,11 +25,10 @@
         <property name="visible">True</property>
         <property name="vexpand">True</property>
         <child>
-          <object class="GtkStack" id="viewstack">
+          <object class="GtkStack" id="empty_stack">
             <property name="visible">True</property>
-            <property name="visible-child">collection_view</property>
+            <property name="visible-child">empty_collection</property>
             <property name="transition-type">crossfade</property>
-            <signal name="notify::visible-child" handler="on_visible_child_changed"/>
             <style>
               <class name="background"/>
             </style>
@@ -42,29 +41,37 @@
               </packing>
             </child>
             <child>
-              <object class="GamesCollectionIconView" id="collection_view">
+              <object class="GtkStack" id="viewstack">
                 <property name="visible">True</property>
-                <signal name="game-activated" handler="on_game_activated"/>
-              </object>
-              <packing>
-                <property name="name">games</property>
-                <property name="title" translatable="yes">Games</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GamesPlatformsView" id="platform_view">
-                <property name="visible">True</property>
-                <property name="is-folded" bind-source="GamesCollectionBox" bind-property="is-folded" 
bind-flags="bidirectional"/>
-                <property name="is-subview-open" bind-source="GamesCollectionBox" 
bind-property="is-subview-open" bind-flags="bidirectional"/>
-                <property name="subview-title" bind-source="GamesCollectionBox" 
bind-property="subview-title" bind-flags="bidirectional"/>
-                <signal name="game-activated" handler="on_game_activated"/>
+                <property name="visible-child">collection_view</property>
+                <property name="transition-type">crossfade</property>
+                <signal name="notify::visible-child" handler="on_visible_child_changed"/>
+                <child>
+                  <object class="GamesCollectionIconView" id="collection_view">
+                    <property name="visible">True</property>
+                    <signal name="game-activated" handler="on_game_activated"/>
+                  </object>
+                  <packing>
+                    <property name="name">games</property>
+                    <property name="title" translatable="yes">Games</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GamesPlatformsView" id="platform_view">
+                    <property name="visible">True</property>
+                    <property name="is-folded" bind-source="GamesCollectionBox" bind-property="is-folded" 
bind-flags="bidirectional"/>
+                    <property name="is-subview-open" bind-source="GamesCollectionBox" 
bind-property="is-subview-open" bind-flags="bidirectional"/>
+                    <property name="subview-title" bind-source="GamesCollectionBox" 
bind-property="subview-title" bind-flags="bidirectional"/>
+                    <signal name="game-activated" handler="on_game_activated"/>
+                  </object>
+                  <packing>
+                    <property name="name">platform</property>
+                    <!-- FIXME: the icon is meant to be used for text formatting -->
+                    <property name="icon-name">view-list-bullet-symbolic</property>
+                    <property name="title" translatable="yes">Platforms</property>
+                  </packing>
+                </child>
               </object>
-              <packing>
-                <property name="name">platform</property>
-                <!-- FIXME: the icon is meant to be used for text formatting -->
-                <property name="icon-name">view-list-bullet-symbolic</property>
-                <property name="title" translatable="yes">Platforms</property>
-              </packing>
             </child>
           </object>
         </child>
diff --git a/src/ui/collection-box.vala b/src/ui/collection-box.vala
index aa49817d..b35bd7dc 100644
--- a/src/ui/collection-box.vala
+++ b/src/ui/collection-box.vala
@@ -18,6 +18,8 @@ private class Games.CollectionBox : Gtk.Box {
        private CollectionIconView collection_view;
        [GtkChild]
        private PlatformsView platform_view;
+       [GtkChild]
+       private Gtk.Stack empty_stack;
        [GtkChild (name = "viewstack")]
        private Gtk.Stack _viewstack;
        [GtkChild]
@@ -33,9 +35,9 @@ private class Games.CollectionBox : Gtk.Box {
                set {
                        _is_collection_empty = value;
                        if (_is_collection_empty)
-                               viewstack.visible_child = empty_collection;
+                               empty_stack.visible_child = empty_collection;
                        else
-                               viewstack.visible_child = collection_view;
+                               empty_stack.visible_child = viewstack;
                }
        }
 
@@ -78,7 +80,7 @@ private class Games.CollectionBox : Gtk.Box {
 
                        assert (current_view != null);
 
-                       if (current_view.prev != null && current_view.prev.data != empty_collection)
+                       if (current_view.prev != null)
                                viewstack.visible_child = current_view.prev.data;
 
                        return true;
@@ -88,7 +90,7 @@ private class Games.CollectionBox : Gtk.Box {
 
                        assert (current_view != null);
 
-                       if (current_view.next != null && current_view.next.data != empty_collection)
+                       if (current_view.next != null)
                                viewstack.visible_child = current_view.next.data;
 
                        return true;


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