~elementary-apps/pantheon-files/trunk

« back to all changes in this revision

Viewing changes to src/View/IconView.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:
49
49
            (tree as Gtk.CellLayout).add_attribute (icon_renderer, "file", FM.ListModel.ColumnID.FILE_COLUMN);
50
50
 
51
51
            connect_tree_signals ();
 
52
            tree.realize.connect ((w) => {
 
53
                tree.grab_focus ();
 
54
            });
52
55
        }
53
56
 
54
57
        protected override void set_up_name_renderer () {
63
66
        }
64
67
 
65
68
 
66
 
        private void connect_tree_signals () {
 
69
        protected override void connect_tree_signals () {
67
70
            tree.selection_changed.connect (on_view_selection_changed);
68
 
 
69
 
            tree.realize.connect ((w) => {
70
 
                tree.grab_focus ();
71
 
            });
 
71
        }
 
72
        protected override void disconnect_tree_signals () {
 
73
            tree.selection_changed.disconnect (on_view_selection_changed);
72
74
        }
73
75
 
74
76
        protected override Gtk.Widget? create_view () {
134
136
        }
135
137
 
136
138
        public override void unselect_all () {
137
 
                tree.unselect_all ();
 
139
            tree.unselect_all ();
138
140
        }
139
141
 
140
 
        public override void select_path (Gtk.TreePath? path) {
 
142
        /* Avoid using this function with "cursor_follows = true" to select large numbers of files one by one
 
143
         * It would take an exponentially long time. Use "select_files" function in parent class.
 
144
         */ 
 
145
        public override void select_path (Gtk.TreePath? path, bool cursor_follows = false) {
141
146
            if (path != null) {
142
 
                /* Ensure cursor follows last selection */
143
 
                tree.set_cursor (path, null, false); /* This selects path but does not unselect the rest (unlike TreeView) */
144
 
                tree.select_path (path);
 
147
                tree.select_path (path);  /* This selects path but does not unselect the rest (unlike TreeView) */
 
148
 
 
149
                if (cursor_follows) {
 
150
                    tree.set_cursor (path, null, false);
 
151
                }
145
152
            }
146
153
        }
147
154
 
362
369
                end_path = direction_change ? last_selected : first_selected;
363
370
            }
364
371
 
 
372
            /* Cursor follows when selecting path */
365
373
            if (before_first) {
366
374
                do {
367
375
                    p2 = p.copy ();
368
 
                    select_path (p);
 
376
                    select_path (p, true);
369
377
                    p.next ();
370
378
                } while (p.compare (p2) != 0 && p.compare (end_path) <= 0);
371
379
            } else if (after_last) {
372
380
                do {
373
 
                    select_path (p);
 
381
                    select_path (p, true);
374
382
                    p2 = p.copy ();
375
383
                    p.prev ();
376
384
                } while (p.compare (p2) != 0 && p.compare (end_path) >= 0);
377
385
            } else {/* between first and last */
378
386
                do {
379
387
                    p2 = p.copy ();
380
 
                    select_path (p);
 
388
                    select_path (p, true);
381
389
                    p.prev ();
382
390
                } while (p.compare (p2) != 0 && p.compare (first_selected) >= 0);
383
391