[gnome-boxes/wip/feborges/flowbox: 22/24] list-view: Use container "add" signal to setup child



commit ff62c45d81a31b206e9feec52732b9275983f17d
Author: Felipe Borges <felipeborges gnome org>
Date:   Thu Jan 4 14:08:28 2018 +0100

    list-view: Use container "add" signal to setup child
    
    Instead of relying on our own add_item handler we can now connect
    to the "add" signal of the list_view directly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=791839

 src/list-view.vala |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/list-view.vala b/src/list-view.vala
index f188391..2e28a33 100644
--- a/src/list-view.vala
+++ b/src/list-view.vala
@@ -82,14 +82,18 @@ private class Boxes.ListView: Gtk.ScrolledWindow, Boxes.ICollectionView, Boxes.U
     }
 
     public void add_item (CollectionItem item) {
-        var machine = item as Machine;
-
-        items_connections[item] = new ItemConnections (this, machine);
     }
 
     public void remove_item (CollectionItem item) {
     }
 
+    private void add_row (Gtk.Widget row) {
+        var item = row as CollectionItem;
+        var machine = item as Machine;
+
+        items_connections[item] = new ItemConnections (this, machine);
+    }
+
     private void remove_row (Gtk.Widget row) {
         var item = row as CollectionItem;
         items_connections.remove (item);
@@ -177,6 +181,7 @@ private class Boxes.ListView: Gtk.ScrolledWindow, Boxes.ICollectionView, Boxes.U
             window.select_item (item);
         });
 
+        (list_box as Gtk.Container).add.connect (add_row);
         (list_box as Gtk.Container).remove.connect (remove_row);
 
         update_selection_mode ();


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