[gnome-games/wip/exalm/views: 6/17] collection-view: Handle empty collection



commit 330f108285da8bd2ffcaad72e3682a0da1abb7b8
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 756a3f9c..cc2971ab 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 65d6e2a8..16d1b398 100644
--- a/src/ui/collection-view.vala
+++ b/src/ui/collection-view.vala
@@ -33,11 +33,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]