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



commit 068d22ad62421df731bd92f1461b23843216c324
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 f3f5996e..621c26df 100644
--- a/src/ui/sidebar-view.vala
+++ b/src/ui/sidebar-view.vala
@@ -22,8 +22,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]