[gnome-boxes] selectionbar: Exit selection mode after an action



commit 647d8ac879928590828895127cffea80db24321b
Author: Arnel A. Borja <arnelborja src gnome org>
Date:   Thu Aug 29 23:50:38 2013 +0800

    selectionbar: Exit selection mode after an action
    
    Close selection mode once an action is performed. Always show
    selectionbar even if there are no selected items.
    
    This is to follow the new design for Content Selection Pattern at
    https://wiki.gnome.org/GnomeOS/Design/Whiteboards/SelectionPattern
    
    https://bugzilla.gnome.org/show_bug.cgi?id=706818

 src/app.vala          |    7 ++-----
 src/selectionbar.vala |   15 +++++----------
 2 files changed, 7 insertions(+), 15 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index a98c717..e9c9be5 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -845,6 +845,8 @@ private class Boxes.App: Boxes.UI {
         if (num_selected == 0)
             return;
 
+        selection_mode = false;
+
         var message = (num_selected == 1) ? _("Box '%s' has been deleted").printf (selected_items.data.name) 
:
                                             ngettext ("%u box has been deleted",
                                                       "%u boxes have been deleted",
@@ -870,11 +872,6 @@ private class Boxes.App: Boxes.UI {
         };
 
         notificationbar.display_for_action (message, Gtk.Stock.UNDO, (owned) undo, (owned) really_remove);
-
-        // go out of selection mode if there are no more boxes
-        if (App.app.collection.items.length == 0) {
-            App.app.selection_mode = false;
-        }
     }
 
     private bool on_key_pressed (Widget widget, Gdk.EventKey event) {
diff --git a/src/selectionbar.vala b/src/selectionbar.vala
index 4490214..ee418e8 100644
--- a/src/selectionbar.vala
+++ b/src/selectionbar.vala
@@ -25,6 +25,8 @@ private class Boxes.Selectionbar: Gtk.Revealer {
                    continue;
                machine.config.set_category ("favorite", favorite_btn.active);
            }
+
+           App.app.selection_mode = false;
         });
 
         pause_btn = new Gtk.Button ();
@@ -45,6 +47,7 @@ private class Boxes.Selectionbar: Gtk.Revealer {
            }
 
            pause_btn.sensitive = false;
+           App.app.selection_mode = false;
         });
 
         remove_btn = new Gtk.Button.from_stock (Gtk.Stock.DELETE);
@@ -62,11 +65,10 @@ private class Boxes.Selectionbar: Gtk.Revealer {
         show_all ();
 
         App.app.notify["selection-mode"].connect (() => {
-            update_visible ();
+            reveal_child = App.app.selection_mode;
         });
 
         App.app.notify["selected-items"].connect (() => {
-            update_visible ();
             update_favorite_btn ();
             update_properties_btn ();
             update_pause_btn ();
@@ -74,13 +76,6 @@ private class Boxes.Selectionbar: Gtk.Revealer {
         });
     }
 
-    private void update_visible () {
-        if (!App.app.selection_mode)
-            reveal_child = false;
-        else
-            reveal_child = App.app.selected_items.length () > 0;
-    }
-
     private void update_favorite_btn () {
         var active = false;
         var sensitive = App.app.selected_items.length () > 0;
@@ -135,7 +130,7 @@ private class Boxes.Selectionbar: Gtk.Revealer {
             }
         }
 
-        var sensitive = true;
+        var sensitive = App.app.selected_items.length () > 0;
         foreach (var item in App.app.selected_items) {
             ulong can_delete_id = 0;
             can_delete_id = item.notify["can-delete"].connect (() => {


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