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



commit 325628e45971c64e409a9997a5d8b026861ccce2
Author: Felipe Borges <felipeborges gnome org>
Date:   Sun Jan 14 19:30:22 2018 +0100

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

 src/app-window.vala        | 6 ++++++
 src/i-collection-view.vala | 1 +
 src/icon-view.vala         | 8 ++++++++
 src/list-view.vala         | 8 ++++++++
 4 files changed, 23 insertions(+)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index 2b2e900e..26e9f536 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -382,6 +382,12 @@ public bool on_key_pressed (Widget widget, Gdk.EventKey event) {
                    (event.state & default_modifiers) == Gdk.ModifierType.CONTROL_MASK) {
             topbar.click_search_button ();
 
+            return true;
+        } else if (event.keyval == Gdk.Key.a &&
+                   (event.state & default_modifiers) == Gdk.ModifierType.CONTROL_MASK) {
+            selection_mode = true;
+            foreach_view ((view) => { view.select_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 6251fcc7..fd4c2a6c 100644
--- a/src/i-collection-view.vala
+++ b/src/i-collection-view.vala
@@ -6,4 +6,5 @@
     public abstract List<CollectionItem> get_selected_items ();
     public abstract void activate_first_item ();
     public abstract void select_by_criteria (SelectionCriteria criteria);
+    public abstract void select_all ();
 }
diff --git a/src/icon-view.vala b/src/icon-view.vala
index 12ba3626..36101d72 100644
--- a/src/icon-view.vala
+++ b/src/icon-view.vala
@@ -249,4 +249,12 @@ private void unselect_child (Gtk.FlowBoxChild child) {
 
         App.app.notify_property ("selected-items");
     }
+
+    public void select_all () {
+        flowbox.select_all ();
+
+        foreach_child (select_child);
+
+        App.app.notify_property ("selected-items");
+    }
 }
diff --git a/src/list-view.vala b/src/list-view.vala
index 726687fd..c2595149 100644
--- a/src/list-view.vala
+++ b/src/list-view.vala
@@ -328,4 +328,12 @@ private void unselect_row (Gtk.ListBoxRow box_row) {
 
         App.app.notify_property ("selected-items");
     }
+
+    public void select_all () {
+        list_box.select_all ();
+
+        foreach_row (select_row);
+
+        App.app.notify_property ("selected-items");
+    }
 }


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