[gnome-games/wip/exalm/views: 6/14] application-window: Move 'is-collection-empty' to CollectionView



commit 9e892f9369b1b884e342aba25d759b75f69e456d
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Thu Oct 4 21:15:41 2018 +0500

    application-window: Move 'is-collection-empty' to CollectionView

 src/ui/application-window.vala | 13 -------------
 src/ui/collection-view.vala    | 20 ++++++++++++++++++++
 2 files changed, 20 insertions(+), 13 deletions(-)
---
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 7d838674..b075d507 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 {
@@ -146,11 +138,6 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                header_bar_fullscreen_binding = bind_property ("is-fullscreen", 
display_view.display_header_bar, "is-fullscreen",
                                                               BindingFlags.BIDIRECTIONAL);
 
-               box_empty_collection_binding = bind_property ("is-collection-empty", 
collection_view.collection_box, "is-collection-empty",
-                                                             BindingFlags.BIDIRECTIONAL);
-               header_bar_empty_collection_binding = bind_property ("is-collection-empty", 
collection_view.collection_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 d2509f7c..695fb369 100644
--- a/src/ui/collection-view.vala
+++ b/src/ui/collection-view.vala
@@ -33,11 +33,31 @@ private class Games.CollectionView: Gtk.Bin, ApplicationView {
                construct set {
                        _collection = value;
                        collection_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 {
                collection_header_bar.viewstack = collection_box.viewstack;
+               is_collection_empty = true;
+
+               box_empty_collection_binding = bind_property ("is-collection-empty",
+                                                             collection_box,
+                                                             "is-collection-empty",
+                                                             BindingFlags.BIDIRECTIONAL);
+               header_bar_empty_collection_binding = bind_property ("is-collection-empty",
+                                                                    collection_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]