[gnome-games/wip/exalm/spinner: 15/21] sidebar-view: Add existing items when changing model



commit d3f3eeda6fe06924391e8bb7a8cd0b89ad3e01f0
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sat Sep 22 15:43:42 2018 +0500

    sidebar-view: Add existing items when changing model
    
    Prevents sidebar from being empty initially after changing list model.

 src/ui/sidebar-view.vala | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/ui/sidebar-view.vala b/src/ui/sidebar-view.vala
index 3e7385fa..626870cc 100644
--- a/src/ui/sidebar-view.vala
+++ b/src/ui/sidebar-view.vala
@@ -59,8 +59,15 @@ private abstract class Games.SidebarView : Gtk.Box {
                        _model = value;
                        collection_view.model = _model;
 
-                       if (model != null)
+                       if (model != null) {
+                               uint n_items = model.get_n_items ();
+                               for (uint i = 0; i < n_items; i++) {
+                                       var game = model.get_item (i) as Game;
+                                       game_added (game);
+                               }
+
                                model_items_changed_id = model.items_changed.connect (on_model_changed);
+                       }
                }
        }
 


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