[gnome-boxes] collection-view: Keep track of hidden items



commit 62989461ccf5b0c97b1788647c29bdc02b62dabe
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Fri Jun 19 19:48:37 2015 +0100

    collection-view: Keep track of hidden items
    
    We don't immediately add new items to the view before UI is out of
    wizard state since commit 94414dc but we don't keep track of these
    hidden items, which results in these items being add to the view even if
    user cancel's their creation and items don't actually exist. This
    results in ghost VMs being added to the view.
    
    This patches fixes the issue by add a list of such hidden items and
    ensuring they don't get added if user changes their mind.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=749725

 src/collection-view.vala |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/src/collection-view.vala b/src/collection-view.vala
index 4b87bc0..abcc628 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -35,9 +35,11 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
     private Gtk.ListStore store;
     private Gtk.TreeModelFilter model_filter;
     private Boxes.ActionsPopover context_popover;
+    private GLib.List<CollectionItem> hidden_items;
 
     construct {
         category = new Category (_("New and Recent"), Category.Kind.NEW);
+        hidden_items = new GLib.List<CollectionItem> ();
         setup_view ();
         notify["ui-state"].connect (ui_state_changed);
     }
@@ -126,13 +128,18 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
         var window = machine.window;
         if (window.ui_state == UIState.WIZARD) {
             // Don't show newly created items until user is out of wizard
+            hidden_items.append (item);
+
             ulong ui_state_id = 0;
 
             ui_state_id = window.notify["ui-state"].connect (() => {
                 if (window.ui_state == UIState.WIZARD)
                     return;
 
-                add_item (item);
+                if (hidden_items.find (item) != null) {
+                    add_item (item);
+                    hidden_items.remove (item);
+                }
                 window.disconnect (ui_state_id);
             });
 
@@ -203,6 +210,8 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
     }
 
     public void remove_item (CollectionItem item) {
+        hidden_items.remove (item);
+
         var iter = item.get_data<Gtk.TreeIter?> ("iter");
         if (iter == null) {
             debug ("item not in view or already removed");


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