[gnome-boxes/selection-mode-keyboard-shortcuts: 3/3] app-window, icon/list-view: Add "Unselect All" keyboard shortcut



commit 4a161e933d16377f7da56acc17f5fbe00634e31f
Author: Felipe Borges <felipeborges gnome org>
Date:   Sun Jan 14 19:56:51 2018 +0100

    app-window, icon/list-view: Add "Unselect All" keyboard shortcut
    
    Ctrl + Shift + A
    
    Fixes #16

 src/app-window.vala        | 5 +++++
 src/i-collection-view.vala | 1 +
 src/icon-view.vala         | 8 ++++++++
 src/list-view.vala         | 8 ++++++++
 4 files changed, 22 insertions(+)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index 26e9f536..5d19343c 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -388,6 +388,11 @@ public bool on_key_pressed (Widget widget, Gdk.EventKey event) {
             selection_mode = true;
             foreach_view ((view) => { view.select_all (); });
 
+            return true;
+        } else if (event.keyval == Gdk.Key.A &&
+                   (event.state & default_modifiers) == Gdk.ModifierType.CONTROL_MASK | 
Gdk.ModifierType.SHIFT_MASK) {
+            foreach_view ((view) => { view.unselect_all (); });
+
             return true;
         } else if (((direction == Gtk.TextDirection.LTR && // LTR
                      event.keyval == Gdk.Key.Left) ||      // ALT + Left -> back
diff --git a/src/i-collection-view.vala b/src/i-collection-view.vala
index fd4c2a6c..da64f823 100644
--- a/src/i-collection-view.vala
+++ b/src/i-collection-view.vala
@@ -7,4 +7,5 @@
     public abstract void activate_first_item ();
     public abstract void select_by_criteria (SelectionCriteria criteria);
     public abstract void select_all ();
+    public abstract void unselect_all ();
 }
diff --git a/src/icon-view.vala b/src/icon-view.vala
index 36101d72..3f25cefa 100644
--- a/src/icon-view.vala
+++ b/src/icon-view.vala
@@ -250,6 +250,14 @@ private void unselect_child (Gtk.FlowBoxChild child) {
         App.app.notify_property ("selected-items");
     }
 
+    public void unselect_all () {
+        flowbox.unselect_all ();
+
+        foreach_child (unselect_child);
+
+        App.app.notify_property ("selected-items");
+    }
+
     public void select_all () {
         flowbox.select_all ();
 
diff --git a/src/list-view.vala b/src/list-view.vala
index c2595149..76b49f83 100644
--- a/src/list-view.vala
+++ b/src/list-view.vala
@@ -336,4 +336,12 @@ public void select_all () {
 
         App.app.notify_property ("selected-items");
     }
+
+    public void unselect_all () {
+        list_box.unselect_all ();
+
+        foreach_row (unselect_row);
+
+        App.app.notify_property ("selected-items");
+    }
 }


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