~elementary-apps/pantheon-files/trunk

« back to all changes in this revision

Viewing changes to src/View/AbstractTreeView.vala

  • Committer: RabbitBot
  • Author(s): Jeremy Wootten
  • Date: 2017-06-07 16:22:32 UTC
  • mfrom: (2367.1.7 fix-hang-on-large-copy)
  • Revision ID: rabbitbot-20170607162232-dqzt767tmp62ywrk
Fix hang on selecting many files after paste or view change.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
 
65
65
        protected void set_up_view () {
66
66
            connect_tree_signals ();
 
67
            tree.realize.connect ((w) => {
 
68
                tree.grab_focus ();
 
69
                tree.columns_autosize ();
 
70
            });
67
71
        }
68
72
 
69
73
        protected override void set_up_name_renderer () {
76
80
            name_renderer.yalign = 0.5f;
77
81
        }
78
82
 
79
 
        protected void connect_tree_signals () {
 
83
        protected override void connect_tree_signals () {
80
84
            tree.get_selection ().changed.connect (on_view_selection_changed);
81
 
 
82
 
            tree.realize.connect ((w) => {
83
 
                tree.grab_focus ();
84
 
                tree.columns_autosize ();
85
 
            });
 
85
        }
 
86
        protected override void disconnect_tree_signals () {
 
87
            tree.get_selection ().changed.disconnect (on_view_selection_changed);
86
88
        }
87
89
 
88
90
        protected override Gtk.Widget? create_view () {
131
133
            tree.get_selection ().unselect_all ();
132
134
        }
133
135
 
134
 
        public override void select_path (Gtk.TreePath? path) {
 
136
        /* Avoid using this function with "cursor_follows = true" to select large numbers of files one by one
 
137
         * It would take an exponentially long time. Use "select_files" function in parent class.
 
138
         */  
 
139
        public override void select_path (Gtk.TreePath? path, bool cursor_follows = false) {
135
140
            if (path != null) {
136
141
                var selection = tree.get_selection ();
137
 
                /* Unlike for IconView, set_cursor unselects previously selected paths (Gtk bug?),
138
 
                 * so we have to remember them and reselect afterwards */ 
139
 
                GLib.List<Gtk.TreePath> selected_paths = null;
140
 
                selection.selected_foreach ((m, p, i) => {
141
 
                    selected_paths.prepend (p);
142
 
                });
143
 
                /* Ensure cursor follows last selection */
144
 
                tree.set_cursor (path, null, false);  /* This selects path but unselects rest! */
145
142
                selection.select_path (path);
146
 
                selected_paths.@foreach ((p) => {
147
 
                    selection.select_path (p);
148
 
                });
 
143
                if (cursor_follows) {
 
144
                    /* Unlike for IconView, set_cursor unselects previously selected paths (Gtk bug?),
 
145
                     * so we have to remember them and reselect afterwards */ 
 
146
                    GLib.List<Gtk.TreePath> selected_paths = null;
 
147
                    selection.selected_foreach ((m, p, i) => {
 
148
                        selected_paths.prepend (p);
 
149
                    });
 
150
                    /* Ensure cursor follows last selection */
 
151
                    tree.set_cursor (path, null, false);  /* This selects path but unselects rest! */
 
152
 
 
153
                    selected_paths.@foreach ((p) => {
 
154
                       selection.select_path (p);
 
155
                    });
 
156
                }
149
157
            }
150
158
        }
151
159
        public override void unselect_path (Gtk.TreePath? path) {