[gnome-games/wip/exalm/views: 9/20] collection-view: Handle empty collection



commit af3fd2a98fa6ed64c967a0aff2401123cdf26ccf
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Thu Oct 4 23:40:25 2018 +0500

    collection-view: Handle empty collection
    
    Move 'is-collection-empty' property out of ApplicationWindow.

 src/ui/application-window.vala | 13 -------------
 src/ui/collection-view.vala    | 19 +++++++++++++++++++
 2 files changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index d0cc56e5..bf710ac6 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -67,8 +67,6 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                set { _search_mode = value && (ui_state == UiState.COLLECTION); }
        }
 
-       public bool is_collection_empty { get; set; }
-
        public bool loading_notification { get; set; }
 
        [GtkChild]
@@ -85,10 +83,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
 
        private Binding box_search_binding;
        private Binding box_fullscreen_binding;
-       private Binding box_empty_collection_binding;
        private Binding header_bar_search_binding;
        private Binding header_bar_fullscreen_binding;
-       private Binding header_bar_empty_collection_binding;
        private Binding loading_notification_binding;
 
        private Cancellable run_game_cancellable;
@@ -110,10 +106,6 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                collection_view.window = this;
                display_view.window = this;
                collection_view.collection = collection;
-               collection.items_changed.connect (() => {
-                       is_collection_empty = collection.get_n_items () == 0;
-               });
-               is_collection_empty = collection.get_n_items () == 0;
        }
 
        construct {
@@ -147,11 +139,6 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                header_bar_fullscreen_binding = bind_property ("is-fullscreen", display_view.header_bar, 
"is-fullscreen",
                                                               BindingFlags.BIDIRECTIONAL);
 
-               box_empty_collection_binding = bind_property ("is-collection-empty", collection_view.box, 
"is-collection-empty",
-                                                             BindingFlags.BIDIRECTIONAL);
-               header_bar_empty_collection_binding = bind_property ("is-collection-empty", 
collection_view.header_bar, "is-collection-empty",
-                                                                    BindingFlags.BIDIRECTIONAL);
-
                konami_code = new KonamiCode (this);
                konami_code.code_performed.connect (on_konami_code_performed);
 
diff --git a/src/ui/collection-view.vala b/src/ui/collection-view.vala
index d3e51da3..6e2ee518 100644
--- a/src/ui/collection-view.vala
+++ b/src/ui/collection-view.vala
@@ -32,11 +32,30 @@ private class Games.CollectionView: Gtk.Bin, ApplicationView {
                construct set {
                        _collection = value;
                        box.collection = _collection;
+
+                       collection.items_changed.connect (() => {
+                               is_collection_empty = collection.get_n_items () == 0;
+                       });
+                       is_collection_empty = collection.get_n_items () == 0;
                }
        }
 
+       public bool is_collection_empty { get; set; }
+
+       private Binding box_empty_collection_binding;
+       private Binding header_bar_empty_collection_binding;
+
        construct {
                header_bar.viewstack = box.viewstack;
+               is_collection_empty = true;
+
+               box_empty_collection_binding = bind_property ("is-collection-empty", box,
+                                                             "is-collection-empty",
+                                                             BindingFlags.BIDIRECTIONAL);
+               header_bar_empty_collection_binding = bind_property ("is-collection-empty",
+                                                                    header_bar,
+                                                                    "is-collection-empty",
+                                                                    BindingFlags.BIDIRECTIONAL);
        }
 
        public CollectionView (ListModel collection) {


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