[gnome-games/wip/exalm/spinner-performance] collection-box: Move empty state into its own stack



commit f6ba87a31b111be58a8bbb231bd7f3ef9dbd7b6c
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Fri Sep 21 18:20:58 2018 +0500

    collection-box: Move empty state into its own stack

 data/ui/collection-box.ui  | 65 +++++++++++++++++++++++++---------------------
 src/ui/collection-box.vala | 10 ++++---
 2 files changed, 42 insertions(+), 33 deletions(-)
---
diff --git a/data/ui/collection-box.ui b/data/ui/collection-box.ui
index 5864ab3b..74e8957a 100644
--- a/data/ui/collection-box.ui
+++ b/data/ui/collection-box.ui
@@ -17,11 +17,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">viewstack</property>
             <property name="transition-type">GTK_STACK_TRANSITION_TYPE_CROSSFADE</property>
-            <signal name="notify::visible-child" handler="on_visible_child_changed"/>
             <child>
               <object class="GamesEmptyCollection" id="empty_collection">
                 <property name="visible">True</property>
@@ -31,34 +30,42 @@
               </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="GamesDevelopersView" id="developer_view">
-                <property name="visible">True</property>
-                <signal name="game-activated" handler="on_game_activated"/>
-              </object>
-              <packing>
-                <property name="name">developer</property>
-                <property name="title" translatable="yes">Developers</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GamesPlatformsView" id="platform_view">
-                <property name="visible">True</property>
-                <signal name="game-activated" handler="on_game_activated"/>
+                <property name="visible-child">collection_view</property>
+                <property name="transition-type">GTK_STACK_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="GamesDevelopersView" id="developer_view">
+                    <property name="visible">True</property>
+                    <signal name="game-activated" handler="on_game_activated"/>
+                  </object>
+                  <packing>
+                    <property name="name">developer</property>
+                    <property name="title" translatable="yes">Developers</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GamesPlatformsView" id="platform_view">
+                    <property name="visible">True</property>
+                    <signal name="game-activated" handler="on_game_activated"/>
+                  </object>
+                  <packing>
+                    <property name="name">platform</property>
+                    <property name="title" translatable="yes">Platforms</property>
+                  </packing>
+                </child>
               </object>
-              <packing>
-                <property name="name">platform</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 79bf0290..acc7a443 100644
--- a/src/ui/collection-box.vala
+++ b/src/ui/collection-box.vala
@@ -25,6 +25,8 @@ private class Games.CollectionBox : Gtk.Box {
        public Gtk.Stack viewstack {
                get { return _viewstack; }
        }
+       [GtkChild]
+       private Gtk.Stack empty_stack;
 
        private bool _is_collection_empty;
        public bool is_collection_empty {
@@ -32,9 +34,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;
                }
        }
 
@@ -82,7 +84,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;
@@ -92,7 +94,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]