[gnome-boxes/gnome-3-18] filter-switcher: Insensitive on 'no boxes'



commit 49dc4d639ec672bceecce2c2b813f18fad00da39
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Sep 24 17:56:19 2015 +0100

    filter-switcher: Insensitive on 'no boxes'
    
    Where there is no boxes, the switcher is pretty much useless and hence
    should be disabled.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755468

 src/collection-filter-switcher.vala |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/src/collection-filter-switcher.vala b/src/collection-filter-switcher.vala
index 5f36bdd..47c7867 100644
--- a/src/collection-filter-switcher.vala
+++ b/src/collection-filter-switcher.vala
@@ -18,6 +18,7 @@ private class Boxes.CollectionFilterSwitcher: Gtk.ButtonBox {
 
         all_button.active = true;
         activate_button (all_button);
+        App.app.call_when_ready (on_app_ready);
 
         window.foreach_view ((view) => { view.filter.filter_func = null; });
     }
@@ -41,6 +42,17 @@ private class Boxes.CollectionFilterSwitcher: Gtk.ButtonBox {
         return (item is Machine) && !(item as Machine).is_local;
     }
 
+    private void on_app_ready () {
+        update_sensitivity ();
+
+        App.app.collection.item_added.connect (update_sensitivity);
+        App.app.collection.item_removed.connect (update_sensitivity);
+    }
+
+    private void update_sensitivity () {
+        sensitive = (App.app.collection.items.length != 0);
+    }
+
     [GtkCallback]
     private void activate_button (Gtk.ToggleButton button) {
         if (button == active_button)


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