[gnome-boxes/remove-selection-mode] app-window, list/icon-views: Remove Selection Mode




commit ba7535942ff68f5e2e6c1e93411dc4665dd41f36
Author: Felipe Borges <felipeborges gnome org>
Date:   Sat Dec 25 16:26:44 2021 +0100

    app-window, list/icon-views: Remove Selection Mode
    
    Merry Christmas!

 data/gnome-boxes.gresource.xml |   2 -
 data/ui/app-window.ui          |  35 -------
 data/ui/collection-toolbar.ui  |  28 ------
 data/ui/icon-view-child.ui     |  11 ---
 data/ui/icon-view.ui           |   1 +
 data/ui/list-view-row.ui       |  11 ---
 data/ui/list-view.ui           |   2 +
 data/ui/selection-toolbar.ui   | 121 -------------------------
 data/ui/selectionbar.ui        |  88 ------------------
 data/ui/topbar.ui              |  10 --
 src/app-window.vala            |  56 ++----------
 src/app.vala                   |  35 -------
 src/collection-toolbar.vala    |  17 ----
 src/i-collection-view.vala     |  11 ---
 src/icon-view-child.vala       |  26 ------
 src/icon-view.vala             | 158 +-------------------------------
 src/list-view-row.vala         |  25 -----
 src/list-view.vala             | 201 +++--------------------------------------
 src/meson.build                |   3 -
 src/searchbar.vala             |   2 +-
 src/selection-toolbar.vala     |  55 -----------
 src/selectionbar.vala          | 183 -------------------------------------
 src/topbar.vala                |  17 +---
 23 files changed, 25 insertions(+), 1073 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index ebd8a51b..ab59b007 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -20,8 +20,6 @@
     <file preprocess="xml-stripblanks">ui/list-view-row.ui</file>
     <file preprocess="xml-stripblanks">ui/notification.ui</file>
     <file preprocess="xml-stripblanks">ui/searchbar.ui</file>
-    <file preprocess="xml-stripblanks">ui/selectionbar.ui</file>
-    <file preprocess="xml-stripblanks">ui/selection-toolbar.ui</file>
     <file preprocess="xml-stripblanks">ui/topbar.ui</file>
     <file preprocess="xml-stripblanks">ui/transfer-info-row.ui</file>
     <file preprocess="xml-stripblanks">ui/transfer-popover.ui</file>
diff --git a/data/ui/app-window.ui b/data/ui/app-window.ui
index 7ce38033..3e1a85a6 100644
--- a/data/ui/app-window.ui
+++ b/data/ui/app-window.ui
@@ -1,34 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <!-- interface-requires gtk+ 3.9 -->
-
-  <!-- Widget hierarchy:
-
-    window = new Boxes.ApplicationWindow ();
-     |
-     |-> main_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
-           |-> topbar = new Boxes.Topbar (); // as titlebar
-           |
-           |-> searchbar = new Searchbar ();
-           |
-           |-> notification_overlay = new Gtk.Overlay ();
-           |    |
-           |    |-> notificationbar = Boxes.Notificationbar ();
-           |    |
-           |    |-> below_bin = new Gtk.Stack ();
-           |        |
-           |        |-> icon_view = new Boxes.IconView ();
-           |        |
-           |        |-> list_view = new Boxes.ListView ();
-           |        |
-           |        |-> empty_boxes = new Boxes.EmptyBoxes ();
-           |        |
-           |        |-> display_page = new Boxes.DisplayPage ();
-           |
-           |-> selectionbar = new Boxes.Selectionbar ();
-
-  -->
-
   <template class="BoxesAppWindow" parent="HdyApplicationWindow">
     <property name="visible">False</property>
     <property name="show-menubar">False</property>
@@ -161,12 +132,6 @@
             </child>
           </object>
         </child>
-
-        <child>
-          <object class="BoxesSelectionbar" id="selectionbar">
-            <property name="visible">True</property>
-          </object>
-        </child>
       </object>
     </child>
   </template>
diff --git a/data/ui/collection-toolbar.ui b/data/ui/collection-toolbar.ui
index 7465f04a..6bc66a5c 100644
--- a/data/ui/collection-toolbar.ui
+++ b/data/ui/collection-toolbar.ui
@@ -83,34 +83,6 @@
       </packing>
     </child>
 
-    <child>
-      <object class="GtkButton" id="select_btn">
-        <property name="visible">True</property>
-        <property name="valign">center</property>
-        <property name="use-underline">True</property>
-        <signal name="clicked" handler="on_select_btn_clicked"/>
-        <style>
-          <class name="image-button"/>
-        </style>
-        <child internal-child="accessible">
-          <object class="AtkObject" id="a11y-button3">
-            <property name="accessible-name" translatable="yes">Select Items</property>
-          </object>
-        </child>
-        <child>
-          <object class="GtkImage" id="select_image">
-            <property name="visible">True</property>
-            <property name="icon-name">object-select-symbolic</property>
-            <property name="icon-size">1</property>
-          </object>
-        </child>
-      </object>
-
-      <packing>
-        <property name="pack-type">end</property>
-      </packing>
-    </child>
-
     <child>
       <object class="GtkButton" id="list_btn">
         <property name="visible">True</property>
diff --git a/data/ui/icon-view-child.ui b/data/ui/icon-view-child.ui
index 63c40936..20127189 100644
--- a/data/ui/icon-view-child.ui
+++ b/data/ui/icon-view-child.ui
@@ -24,17 +24,6 @@
                 <property name="height-request">16</property>
               </object>
             </child>
-
-            <child>
-              <object class="GtkCheckButton" id="selection_button">
-                <property name="visible">False</property>
-                <property name="can-focus">False</property>
-              </object>
-              <packing>
-                <property name="pack-type">end</property>
-              </packing>
-            </child>
-
           </object>
         </child>
 
diff --git a/data/ui/icon-view.ui b/data/ui/icon-view.ui
index de9237b4..0cefd149 100644
--- a/data/ui/icon-view.ui
+++ b/data/ui/icon-view.ui
@@ -22,6 +22,7 @@
             <property name="column-spacing">20</property>
             <property name="row-spacing">6</property>
             <property name="valign">start</property>
+            <property name="selection-mode">none</property>
             <signal name="button-release-event" handler="on_button_press_event"/>
             <signal name="child-activated" handler="on_child_activated"/>
             <signal name="key-press-event" handler="on_key_press_event"/>
diff --git a/data/ui/list-view-row.ui b/data/ui/list-view-row.ui
index 9e0a6a63..cb965ad5 100644
--- a/data/ui/list-view-row.ui
+++ b/data/ui/list-view-row.ui
@@ -10,17 +10,6 @@
     <property name="orientation">horizontal</property>
     <property name="spacing">16</property>
 
-    <child>
-      <object class="GtkCheckButton" id="selection_button">
-        <property name="visible">False</property>
-        <property name="can-focus">False</property>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">True</property>
-      </packing>
-    </child>
-
     <child>
       <object class="GtkStack" id="stack">
         <property name="visible">True</property>
diff --git a/data/ui/list-view.ui b/data/ui/list-view.ui
index 08c065a4..dfaf7389 100644
--- a/data/ui/list-view.ui
+++ b/data/ui/list-view.ui
@@ -24,6 +24,8 @@
             <property name="margin-top">12</property>
             <property name="margin-bottom">12</property>
             <property name="valign">start</property>
+            <property name="selection-mode">none</property>
+            <signal name="row-activated" handler="on_row_activated"/>
             <signal name="button-release-event" handler="on_button_press_event"/>
             <signal name="key-press-event" handler="on_key_press_event"/>
             <style>
diff --git a/data/ui/topbar.ui b/data/ui/topbar.ui
index 058d8095..bcd09a26 100644
--- a/data/ui/topbar.ui
+++ b/data/ui/topbar.ui
@@ -18,16 +18,6 @@
       </packing>
     </child>
 
-    <!-- Collection (selection mode) -->
-    <child>
-      <object class="BoxesSelectionToolbar" id="selection_toolbar">
-      </object>
-
-      <packing>
-        <property name="name">selection</property>
-      </packing>
-    </child>
-
     <!-- Display -->
     <child>
       <object class="BoxesDisplayToolbar" id="display_toolbar">
diff --git a/src/app-window.vala b/src/app-window.vala
index baed07f3..4b6f78c2 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -38,7 +38,6 @@
             }
         }
     }
-    public signal void item_selected (CollectionItem item);
 
     private GLib.Binding status_bind;
     private ulong got_error_id;
@@ -57,15 +56,6 @@
     }
     private bool maximized { get { return WindowState.MAXIMIZED in get_window ().get_state (); } }
 
-    private bool _selection_mode;
-    public bool selection_mode { get { return _selection_mode; }
-        set {
-            return_if_fail (ui_state == UIState.COLLECTION);
-
-            _selection_mode = value;
-        }
-    }
-
     public Notificationbar notificationbar {
         get {
             return _notificationbar;
@@ -77,8 +67,6 @@
     [GtkChild]
     public unowned Topbar topbar;
     [GtkChild]
-    public unowned Selectionbar selectionbar;
-    [GtkChild]
     public unowned DisplayPage display_page;
     [GtkChild]
     public unowned Hdy.StatusPage empty_boxes;
@@ -92,8 +80,7 @@
     private unowned ListView list_view;
 
     public ViewType view_type { get; set; default = ViewType.ICON; }
-
-    public ICollectionView view {
+    public Gtk.Widget view {
         get {
             switch (view_type) {
             default:
@@ -105,8 +92,6 @@
         }
     }
 
-    private ICollectionView[] views;
-
     public GLib.Settings settings;
 
     public bool first_run {
@@ -131,7 +116,7 @@ public AppWindow (Gtk.Application app) {
         settings = new GLib.Settings ("org.gnome.boxes");
 
         Gtk.Window.set_default_icon_name (Config.APPLICATION_ID);
-        Hdy.StyleManager.get_default ().color_scheme = PREFER_DARK;
+        //Hdy.StyleManager.get_default ().color_scheme = PREFER_DARK;
 
         var provider = Boxes.load_css ("gtk-style.css");
         Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (),
@@ -158,8 +143,6 @@ public AppWindow (Gtk.Application app) {
             move (x, y);
         }
 
-        views = { icon_view, list_view };
-
         if (app.application_id == "org.gnome.BoxesDevel") {
             get_style_context ().add_class ("devel");
         }
@@ -170,7 +153,6 @@ public void setup_ui () {
         display_page.setup_ui (this);
         icon_view.setup_ui (this);
         list_view.setup_ui (this);
-        selectionbar.setup_ui (this);
         searchbar.setup_ui (this);
         troubleshoot_view.setup_ui (this);
         notificationbar.searchbar = searchbar;
@@ -213,13 +195,7 @@ private void save_window_geometry () {
     }
 
     private void ui_state_changed () {
-        // The order is important for some widgets here (e.g properties must change its state before wizard 
so it can
-        // flush any deferred changes for wizard to pick-up when going back from properties to wizard 
(review).
-        foreach (var ui in new Boxes.UI[] { topbar,
-                                            icon_view,
-                                            list_view }) {
-            ui.set_state (ui_state);
-        }
+        topbar.set_state (ui_state);
 
         if (ui_state != UIState.COLLECTION)
             searchbar.search_mode_enabled = false;
@@ -233,7 +209,6 @@ private void ui_state_changed () {
             else
                 below_bin.visible_child = empty_boxes;
             fullscreened = false;
-            foreach_view ((view) => { view.visible = true; });
 
             if (status_bind != null) {
                 status_bind.unbind ();  // FIXME: We shouldn't neeed to explicitly unbind (Vala bug?)
@@ -280,11 +255,6 @@ private void ui_state_changed () {
             current_item.set_state (ui_state);
     }
 
-    public void foreach_view (Func<ICollectionView> func) {
-        foreach (var view in views)
-            func (view);
-    }
-
     public void show_vm_assistant (string? path = null) {
         new Boxes.VMAssistant (this, path).run ();
     }
@@ -341,7 +311,7 @@ public void connect_to (Machine machine) {
     }
 
     public void select_item (CollectionItem item) {
-        if (ui_state != UIState.COLLECTION || selection_mode)
+        if (ui_state != UIState.COLLECTION)
             return;
 
         return_if_fail (item is Machine);
@@ -360,12 +330,11 @@ public void select_item (CollectionItem item) {
             connect_to (machine);
         else
             warning ("unknown item, fix your code");
-
-        item_selected (item);
     }
 
     public void filter (string text) {
-        foreach_view ((view) => { view.filter.text = text; });
+        icon_view.filter.text = text;
+        list_view.filter.text = text;
     }
 
     [GtkCallback]
@@ -402,17 +371,6 @@ 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 (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
@@ -421,8 +379,6 @@ public bool on_key_pressed (Widget widget, Gdk.EventKey event) {
                    (event.state & default_modifiers) == Gdk.ModifierType.MOD1_MASK) {
             topbar.click_back_button ();
             return true;
-        } else if (event.keyval == Gdk.Key.Escape) { // ESC -> cancel
-            topbar.click_cancel_button ();
         }
 
         return false;
diff --git a/src/app.vala b/src/app.vala
index fd0d3bdd..adf55cdf 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -70,18 +70,6 @@ public App () {
         action.activate.connect (() => { quit_app (); });
         add_action (action);
 
-        action = new GLib.SimpleAction ("select-all", null);
-        action.activate.connect (() => { main_window.view.select_by_criteria (SelectionCriteria.ALL); });
-        add_action (action);
-
-        action = new GLib.SimpleAction ("select-running", null);
-        action.activate.connect (() => { main_window.view.select_by_criteria (SelectionCriteria.RUNNING); });
-        add_action (action);
-
-        action = new GLib.SimpleAction ("select-none", null);
-        action.activate.connect (() => { main_window.view.select_by_criteria (SelectionCriteria.NONE); });
-        add_action (action);
-
         action = new GLib.SimpleAction ("help", null);
         action.activate.connect (() => {
             try {
@@ -368,17 +356,6 @@ public bool open_uuid (string uuid) {
         return false;
     }
 
-    public void open_selected_items_in_new_window () {
-        var selected_items = main_window.view.get_selected_items ();
-
-        main_window.selection_mode = false;
-
-        foreach (var item in selected_items) {
-            if (item is Machine)
-                open_in_new_window (item as Machine);
-        }
-    }
-
     public void open_in_new_window (Machine machine) {
         if (machine.window != main_window) {
             machine.window.present ();
@@ -575,10 +552,6 @@ private void suspend_machines () {
         debug ("Running boxes suspended");
     }
 
-    public List<CollectionItem> selected_items {
-        owned get { return main_window.view.get_selected_items (); }
-    }
-
     /**
      * Deletes specified items, while allowing user to undo it.
      *
@@ -630,14 +603,6 @@ public void delete_machines_undoable (owned List<CollectionItem> items,
         main_window.notificationbar.display_for_action (msg, _("_Undo"), (owned) undo, (owned) 
really_remove);
     }
 
-    public void remove_selected_items () {
-        var selected_items = main_window.view.get_selected_items ();
-
-        main_window.selection_mode = false;
-
-        delete_machines_undoable ((owned) selected_items);
-    }
-
     public AppWindow add_new_window () {
         var window = new Boxes.AppWindow (this);
 
diff --git a/src/collection-toolbar.vala b/src/collection-toolbar.vala
index 09b3bd20..6294e896 100644
--- a/src/collection-toolbar.vala
+++ b/src/collection-toolbar.vala
@@ -6,8 +6,6 @@
     [GtkChild]
     private unowned Button search_btn;
     [GtkChild]
-    private unowned Button select_btn;
-    [GtkChild]
     private unowned Button list_btn;
     [GtkChild]
     private unowned Button grid_btn;
@@ -25,10 +23,6 @@
     public void setup_ui (AppWindow window) {
         this.window = window;
 
-        update_select_btn ();
-        App.app.collection.item_added.connect (update_select_btn);
-        App.app.collection.item_removed.connect (update_select_btn);
-
         update_search_btn ();
         App.app.collection.item_added.connect (update_search_btn);
         App.app.collection.item_removed.connect (update_search_btn);
@@ -76,19 +70,10 @@ private void on_grid_btn_clicked () {
         update_view_type (AppWindow.ViewType.ICON);
     }
 
-    [GtkCallback]
-    private void on_select_btn_clicked () {
-        window.selection_mode = true;
-    }
-
     private void update_search_btn () {
         search_btn.sensitive = App.app.collection.length != 0;
     }
 
-    private void update_select_btn () {
-        select_btn.sensitive = App.app.collection.length != 0;
-    }
-
     private void update_view_type (AppWindow.ViewType view_type) {
         window.view_type = view_type;
         window.settings.set_enum ("view", view_type);
@@ -100,7 +85,6 @@ private void ui_state_changed () {
         switch (window.ui_state) {
         case UIState.COLLECTION:
             back_btn.hide ();
-            select_btn.show ();
             search_btn.show ();
             new_btn.show ();
             grid_btn.visible = window.view_type != AppWindow.ViewType.ICON;
@@ -110,7 +94,6 @@ private void ui_state_changed () {
         case UIState.CREDS:
             new_btn.hide ();
             back_btn.visible = (window == App.app.main_window);
-            select_btn.hide ();
             search_btn.hide ();
             grid_btn.hide ();
             list_btn.hide ();
diff --git a/src/icon-view-child.vala b/src/icon-view-child.vala
index dd9b4f38..fbfe880f 100644
--- a/src/icon-view-child.vala
+++ b/src/icon-view-child.vala
@@ -4,32 +4,11 @@
 
 [GtkTemplate (ui = "/org/gnome/Boxes/ui/icon-view-child.ui")]
 private class Boxes.IconViewChild : Gtk.Box {
-    public bool _selection_mode = false;
-    public bool selection_mode {
-        get { return _selection_mode; }
-        set {
-            _selection_mode = value;
-
-            selection_button.visible = _selection_mode;
-
-            if (!_selection_mode)
-                selected = false;
-        }
-    }
-
-    public bool _selected = false;
-    public bool selected {
-        get { return _selected; }
-        set { _selected = selection_mode && value; }
-    }
-
     public CollectionItem item { get; private set; }
     private Machine machine {
         get { return item as Machine; }
     }
 
-    [GtkChild]
-    private unowned Gtk.CheckButton selection_button;
     [GtkChild]
     private unowned Gtk.Stack stack;
     [GtkChild]
@@ -45,9 +24,6 @@
 
     private Boxes.MachineThumbnailer thumbnailer;
 
-    private Binding selected_binding;
-
-
     public IconViewChild (CollectionItem item) {
         this.item = item;
 
@@ -59,8 +35,6 @@ public IconViewChild (CollectionItem item) {
         });
         thumbnail.set_from_pixbuf (thumbnailer.thumbnail);
 
-        selected_binding = bind_property ("selected", selection_button, "active", 
BindingFlags.BIDIRECTIONAL);
-
         machine.config.notify["categories"].connect (update_favorite);
         machine.notify["under-construction"].connect (update_thumbnail);
 
diff --git a/src/icon-view.vala b/src/icon-view.vala
index 3ff0924c..e7cd5a85 100644
--- a/src/icon-view.vala
+++ b/src/icon-view.vala
@@ -1,16 +1,7 @@
 // This file is part of GNOME Boxes. License: LGPLv2+
 
-public enum Boxes.SelectionCriteria {
-    ALL,
-    NONE,
-    RUNNING
-}
-
 [GtkTemplate (ui = "/org/gnome/Boxes/ui/icon-view.ui")]
-private class Boxes.IconView: Gtk.ScrolledWindow, Boxes.ICollectionView, Boxes.UI {
-    public UIState previous_ui_state { get; protected set; }
-    public UIState ui_state { get; protected set; }
-
+private class Boxes.IconView: Gtk.ScrolledWindow {
     public CollectionFilter filter { get; protected set; }
 
     [GtkChild]
@@ -37,74 +28,14 @@
         });
 
         setup_flowbox ();
-
-        notify["ui-state"].connect (ui_state_changed);
     }
 
     public void setup_ui (AppWindow window) {
         this.window = window;
 
-        window.notify["selection-mode"].connect (() => {
-            flowbox.selection_mode = window.selection_mode ? Gtk.SelectionMode.MULTIPLE :
-                                                             Gtk.SelectionMode.NONE;
-            update_selection_mode ();
-        });
-
         context_popover = new Boxes.ActionsPopover (window);
     }
 
-    public void select_by_criteria (SelectionCriteria criteria) {
-        window.selection_mode = true;
-
-        switch (criteria) {
-        default:
-        case SelectionCriteria.ALL:
-            foreach_child ((box_child) => { select_child (box_child); });
-
-            break;
-        case SelectionCriteria.NONE:
-            foreach_child ((box_child) => { unselect_child (box_child); });
-
-            break;
-        case SelectionCriteria.RUNNING:
-            foreach_child ((box_child) => {
-                var item = get_item_for_child (box_child);
-                if (item != null && item is Machine) {
-                    var machine = item as Machine;
-                    if (machine.is_running)
-                        select_child (box_child);
-                } else
-                    unselect_child (box_child);
-            });
-
-            break;
-        }
-
-        App.app.notify_property ("selected-items");
-    }
-
-    public List<CollectionItem> get_selected_items () {
-        var selected = new List<CollectionItem> ();
-
-        foreach (var box_child in flowbox.get_selected_children ()) {
-            var item = get_item_for_child (box_child);
-            selected.append (item);
-        }
-
-        return (owned) selected;
-    }
-
-    public void activate_first_item () {
-        Gtk.FlowBoxChild first_child = null;
-        foreach_child ((box_child) => {
-            if (first_child == null)
-                first_child = box_child;
-        });
-
-        if (first_child == null)
-            flowbox.child_activated (first_child);
-    }
-
     private void setup_flowbox () {
         flowbox.bind_model (App.app.collection.items, (item) => {
             var child = new Gtk.FlowBoxChild ();
@@ -112,10 +43,6 @@ private void setup_flowbox () {
             var box = new IconViewChild (item as CollectionItem);
             child.add (box);
 
-            box.notify["selected"].connect (() => {
-                propagate_view_child_selection (child);
-            });
-
             box.visible = true;
             child.visible = true;
 
@@ -133,16 +60,6 @@ private void setup_flowbox () {
         return view.item;
     }
 
-    private void foreach_child (Func<Gtk.FlowBoxChild> func) {
-        flowbox.forall ((child) => {
-            var view_child = child as Gtk.FlowBoxChild;
-            if (view_child == null)
-                return;
-
-            func (view_child);
-        });
-    }
-
     private bool model_filter (Gtk.FlowBoxChild child) {
         if (child  == null)
             return false;
@@ -154,23 +71,8 @@ private bool model_filter (Gtk.FlowBoxChild child) {
         return filter.filter (item as CollectionItem);
     }
 
-    private void ui_state_changed () {
-        if (ui_state == UIState.COLLECTION)
-            flowbox.unselect_all ();
-    }
-
     [GtkCallback]
     private void on_child_activated (Gtk.FlowBoxChild child) {
-        if (window.selection_mode) {
-            var view_child = child.get_child () as IconViewChild;
-            if (view_child.selected)
-                unselect_child (child);
-            else
-                select_child (child);
-
-            return;
-        }
-
         var item = get_item_for_child (child);
         if (item is LibvirtMachine) {
             var machine = item as LibvirtMachine;
@@ -179,8 +81,6 @@ private void on_child_activated (Gtk.FlowBoxChild child) {
         }
 
         window.select_item (item);
-
-        update_selection_mode ();
     }
 
     [GtkCallback]
@@ -219,60 +119,4 @@ private bool launch_context_popover_for_child (Gtk.FlowBoxChild child) {
 
         return true;
     }
-
-    private void update_selection_mode () {
-        foreach_child ((child) => {
-            var view_child = child.get_child () as Boxes.IconViewChild;
-
-            if (view_child.selection_mode != window.selection_mode)
-                view_child.selection_mode = window.selection_mode;
-
-            unselect_child (child);
-        });
-    }
-
-    private void propagate_view_child_selection (Gtk.FlowBoxChild child) {
-        var view_child = child.get_child () as IconViewChild;
-
-        if (view_child.selected)
-            select_child (child);
-        else
-            unselect_child (child);
-    }
-
-    private void select_child (Gtk.FlowBoxChild child) {
-        var view_child = child.get_child () as IconViewChild;
-
-        flowbox.select_child (child);
-        if (!view_child.selected)
-            view_child.selected = true;
-
-        App.app.notify_property ("selected-items");
-    }
-
-    private void unselect_child (Gtk.FlowBoxChild child) {
-        var view_child = child.get_child () as IconViewChild;
-
-        flowbox.unselect_child (child);
-        if (view_child.selected)
-            view_child.selected = false;
-
-        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 ();
-
-        foreach_child (select_child);
-
-        App.app.notify_property ("selected-items");
-    }
 }
diff --git a/src/list-view-row.vala b/src/list-view-row.vala
index a26a1427..b40fc5b3 100644
--- a/src/list-view-row.vala
+++ b/src/list-view-row.vala
@@ -10,32 +10,11 @@
     public const Gdk.RGBA FRAME_BORDER_COLOR = { 0x81 / 255.0, 0x85 / 255.0, 0x84 / 255.0, 1.0 };
     public const Gdk.RGBA FRAME_BACKGROUND_COLOR = { 0x4b / 255.0, 0x50 / 255.0, 0x50 / 255.0, 1.0 };
 
-    public bool _selection_mode = false;
-    public bool selection_mode {
-        get { return _selection_mode; }
-        set {
-            _selection_mode = value;
-
-            selection_button.visible = _selection_mode;
-
-            if (!_selection_mode)
-                selected = false;
-        }
-    }
-
-    public bool _selected = false;
-    public bool selected {
-        get { return _selected; }
-        set { _selected = selection_mode && value; }
-    }
-
     public CollectionItem item { get; private set; }
     private Machine machine {
         get { return item as Machine; }
     }
 
-    [GtkChild]
-    private unowned Gtk.CheckButton selection_button;
     [GtkChild]
     private unowned Gtk.Stack stack;
     [GtkChild]
@@ -55,8 +34,6 @@
 
     private Boxes.MachineThumbnailer thumbnailer;
 
-    private Binding selected_binding;
-
     public ListViewRow (CollectionItem item) {
         this.item = item;
 
@@ -69,8 +46,6 @@ public ListViewRow (CollectionItem item) {
         });
         thumbnail.set_from_pixbuf (thumbnailer.thumbnail);
 
-        selected_binding = bind_property ("selected", selection_button, "active", 
BindingFlags.BIDIRECTIONAL);
-
         machine.config.notify["categories"].connect (update_favorite);
         machine.notify["under-construction"].connect (update_thumbnail);
         machine.notify["info"].connect (update_info);
diff --git a/src/list-view.vala b/src/list-view.vala
index 00f348fb..e3d6dd2c 100644
--- a/src/list-view.vala
+++ b/src/list-view.vala
@@ -1,10 +1,7 @@
 // This file is part of GNOME Boxes. License: LGPLv2+
 
 [GtkTemplate (ui = "/org/gnome/Boxes/ui/list-view.ui")]
-private class Boxes.ListView: Gtk.ScrolledWindow, Boxes.ICollectionView, Boxes.UI {
-    public UIState previous_ui_state { get; protected set; }
-    public UIState ui_state { get; protected set; }
-
+private class Boxes.ListView: Gtk.ScrolledWindow {
     public CollectionFilter filter { get; protected set; }
 
     [GtkChild]
@@ -54,27 +51,17 @@ public override void dispose () {
     construct {
         items_connections = new HashTable<CollectionItem, ItemConnections> (direct_hash, direct_equal);
 
-
         size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.VERTICAL);
         filter = new CollectionFilter ();
         filter.notify["text"].connect (() => {
             list_box.invalidate_filter ();
         });
         setup_list_box ();
-
-        notify["ui-state"].connect (ui_state_changed);
     }
 
     public void setup_ui (AppWindow window) {
         this.window = window;
 
-        window.notify["selection-mode"].connect (() => {
-            list_box.selection_mode = window.selection_mode ? Gtk.SelectionMode.MULTIPLE :
-                                                              Gtk.SelectionMode.NONE;
-
-            update_selection_mode ();
-        });
-
         context_popover = new Boxes.ActionsPopover (window);
     }
 
@@ -92,60 +79,6 @@ private void remove_row (Gtk.Widget row) {
         size_group.remove_widget (row);
     }
 
-    public void select_by_criteria (SelectionCriteria criteria) {
-        window.selection_mode = true;
-
-        switch (criteria) {
-        default:
-        case SelectionCriteria.ALL:
-            foreach_row ((box_row) => { select_row (box_row); });
-
-            break;
-        case SelectionCriteria.NONE:
-            foreach_row ((box_row) => { unselect_row (box_row); });
-
-            break;
-        case SelectionCriteria.RUNNING:
-            foreach_row ((box_row) => {
-                var item = get_item_for_row (box_row);
-                assert (item != null);
-
-                if (item != null && item is Machine) {
-                    var machine = item as Machine;
-                    if (machine.is_running)
-                        select_row (box_row);
-                } else
-                    unselect_row (box_row);
-            });
-
-            break;
-        }
-
-        App.app.notify_property ("selected-items");
-    }
-
-    public List<CollectionItem> get_selected_items () {
-        var selected = new List<CollectionItem> ();
-
-        foreach (var box_row in list_box.get_selected_rows ()) {
-            var item = get_item_for_row (box_row);
-            selected.append (item);
-        }
-
-        return (owned) selected;
-    }
-
-    public void activate_first_item () {
-        Gtk.ListBoxRow first_row = null;
-        foreach_row ((box_row) => {
-            if (first_row == null)
-                first_row = box_row;
-        });
-
-        if (first_row == null)
-            list_box.row_activated (first_row);
-    }
-
     private void setup_list_box () {
         list_box.bind_model (App.app.collection.items, (item) => {
             var box_row = new Gtk.ListBoxRow ();
@@ -153,32 +86,13 @@ private void setup_list_box () {
             var view_row = new ListViewRow (item as CollectionItem);
             box_row.add (view_row);
 
-            view_row.notify["selected"].connect (() => {
-                propagate_view_row_selection (view_row);
-            });
-
             box_row.visible = true;
             view_row.visible = true;
 
             return box_row;
         });
-        list_box.selection_mode = Gtk.SelectionMode.NONE;
         list_box.set_filter_func (model_filter);
 
-        list_box.row_activated.connect ((box_row) => {
-            if (window.selection_mode)
-                return;
-
-            var item = get_item_for_row (box_row);
-            if (item is LibvirtMachine) {
-                var libvirt_machine = item as LibvirtMachine;
-                if (libvirt_machine.importing)
-                    return;
-            }
-
-            window.select_item (item);
-        });
-
         var container = list_box as Gtk.Container;
         container.add.connect (add_row);
         container.remove.connect (remove_row);
@@ -192,16 +106,6 @@ private void setup_list_box () {
         return view.item;
     }
 
-    private void foreach_row (Func<Gtk.ListBoxRow> func) {
-        list_box.forall ((child) => {
-            var box_row = child as Gtk.ListBoxRow;
-            if (box_row == null)
-                return;
-
-            func (box_row);
-        });
-    }
-
     private bool model_filter (Gtk.ListBoxRow box_row) {
         var view = box_row.get_child () as ListViewRow;
         if (view  == null)
@@ -214,9 +118,16 @@ private bool model_filter (Gtk.ListBoxRow box_row) {
         return filter.filter (item as CollectionItem);
     }
 
-    private void ui_state_changed () {
-        if (ui_state == UIState.COLLECTION)
-            list_box.unselect_all ();
+    [GtkCallback]
+    private void on_row_activated (Gtk.ListBoxRow row) {
+        var item = get_item_for_row (row);
+        if (item is LibvirtMachine) {
+            var libvirt_machine = item as LibvirtMachine;
+            if (libvirt_machine.importing)
+                return;
+        }
+
+        window.select_item (item);
     }
 
     [GtkCallback]
@@ -224,31 +135,10 @@ private bool on_button_press_event (Gdk.EventButton event) {
         if (event.type != Gdk.EventType.BUTTON_RELEASE)
             return false;
 
-        switch (event.button) {
-        case 1:
-            return on_button_1_press_event (event);
-        case 3:
+        if (event.button == 3)
             return on_button_3_press_event (event);
-        default:
-            return false;
-        }
-    }
-
-    private bool on_button_1_press_event (Gdk.EventButton event) {
-        if (!window.selection_mode)
-            return false;
-
-        // Necessary to avoid treating an event from a child widget which would mess with getting the 
correct row.
-        if (event.window != list_box.get_window ())
-            return false;
-
-        var box_row = list_box.get_row_at_y ((int) event.y);
-        if (box_row == null)
-            return false;
-
-        toggle_row_selected (box_row);
 
-        return true;
+        return false;
     }
 
     private bool on_button_3_press_event (Gdk.EventButton event) {
@@ -283,71 +173,6 @@ private bool launch_context_popover_for_row (Gtk.ListBoxRow box_row) {
         return true;
     }
 
-    private void update_selection_mode () {
-        foreach_row ((box_row) => {
-            var view_row = box_row.get_child () as ListViewRow;
-
-            if (view_row.selection_mode != window.selection_mode)
-                view_row.selection_mode = window.selection_mode;
-
-            unselect_row (box_row);
-        });
-    }
-
-    private void propagate_view_row_selection (ListViewRow view_row) {
-        var box_row = view_row.parent as Gtk.ListBoxRow;
-
-        if (view_row.selected)
-            select_row (box_row);
-        else
-            unselect_row (box_row);
-    }
-
-    private void toggle_row_selected (Gtk.ListBoxRow box_row) {
-        var view_row = box_row.get_child () as ListViewRow;
-
-        if (view_row.selected)
-            unselect_row (box_row);
-        else
-            select_row (box_row);
-    }
-
-    private void select_row (Gtk.ListBoxRow box_row) {
-        var view_row = box_row.get_child () as ListViewRow;
-
-        list_box.select_row (box_row);
-        if (!view_row.selected)
-            view_row.selected = true;
-
-        App.app.notify_property ("selected-items");
-    }
-
-    private void unselect_row (Gtk.ListBoxRow box_row) {
-        var view_row = box_row.get_child () as ListViewRow;
-
-        list_box.unselect_row (box_row);
-        if (view_row.selected)
-            view_row.selected = false;
-
-        App.app.notify_property ("selected-items");
-    }
-
-    public void select_all () {
-        list_box.select_all ();
-
-        foreach_row (select_row);
-
-        App.app.notify_property ("selected-items");
-    }
-
-    public void unselect_all () {
-        list_box.unselect_all ();
-
-        foreach_row (unselect_row);
-
-        App.app.notify_property ("selected-items");
-    }
-
     [GtkCallback]
     private void on_size_allocate (Gtk.Allocation allocation) {
         // Work around for https://gitlab.gnome.org/GNOME/gnome-boxes/issues/76
diff --git a/src/meson.build b/src/meson.build
index c858ce90..c2cf02db 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -53,7 +53,6 @@ vala_sources = [
   'display-toolbar.vala',
   'display.vala',
   'downloads-hub.vala',
-  'i-collection-view.vala',
   'icon-view.vala',
   'installer-media.vala',
   'installed-media.vala',
@@ -76,8 +75,6 @@ vala_sources = [
   'portals.vala',
   'search.vala',
   'searchbar.vala',
-  'selectionbar.vala',
-  'selection-toolbar.vala',
   'shared-folders.vala',
   'transfer-info-row.vala',
   'troubleshoot-view.vala',
diff --git a/src/searchbar.vala b/src/searchbar.vala
index 741750cb..cdc4d367 100644
--- a/src/searchbar.vala
+++ b/src/searchbar.vala
@@ -34,7 +34,7 @@ private void on_search_changed () {
 
     [GtkCallback]
     private void on_search_activated () {
-        window.view.activate_first_item ();
+        //FIXME window.view.activate_first_item ();
     }
 
     [GtkCallback]
diff --git a/src/topbar.vala b/src/topbar.vala
index 60221acc..bf873460 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -3,13 +3,12 @@
 
 public enum Boxes.TopbarPage {
     COLLECTION,
-    SELECTION,
     DISPLAY
 }
 
 [GtkTemplate (ui = "/org/gnome/Boxes/ui/topbar.ui")]
 private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
-    private const string[] page_names = { "collection", "selection", "display" };
+    private const string[] page_names = { "collection", "display" };
 
     public UIState previous_ui_state { get; protected set; }
     public UIState ui_state { get; protected set; }
@@ -17,8 +16,6 @@
     [GtkChild]
     private unowned CollectionToolbar collection_toolbar;
     [GtkChild]
-    private unowned SelectionToolbar selection_toolbar;
-    [GtkChild]
     public unowned DisplayToolbar display_toolbar;
 
     private AppWindow window;
@@ -27,12 +24,6 @@ public void click_back_button () {
         collection_toolbar.click_back_button ();
     }
 
-    // Clicks the appropriate cancel button dependent on the ui state.
-    public void click_cancel_button () {
-        if (window.ui_state == UIState.COLLECTION && window.selection_mode)
-            window.selection_mode = false;
-    }
-
     public void click_search_button () {
         if (window.ui_state == UIState.COLLECTION)
             collection_toolbar.click_search_button ();
@@ -70,17 +61,11 @@ public void pop_main_menu () {
     public void setup_ui (AppWindow window) {
         this.window = window;
 
-        window.notify["selection-mode"].connect (() => {
-            page = window.selection_mode ?
-                TopbarPage.SELECTION : page = TopbarPage.COLLECTION;
-        });
-
         var toolbar = window.display_page.toolbar;
         toolbar.bind_property ("title", display_toolbar, "title", BindingFlags.SYNC_CREATE);
         toolbar.bind_property ("subtitle", display_toolbar, "subtitle", BindingFlags.SYNC_CREATE);
 
         collection_toolbar.setup_ui (window);
-        selection_toolbar.setup_ui (window);
         display_toolbar.setup_ui (window);
         status = _("Boxes");
     }


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