~jeremywootten/pantheon-files/fix-backspace-in-columnv-view

« back to all changes in this revision

Viewing changes to src/View/Slot.vala

merge various-fixes-part4-fix-network-drag-drop-copy-paste r2049

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
        private int preferred_column_width;
25
25
        private FM.AbstractDirectoryView? dir_view = null;
26
26
 
 
27
        private uint reload_timeout_id = 0;
 
28
        private uint path_change_timeout_id = 0;
 
29
 
27
30
        protected bool updates_frozen = false;
28
31
        protected bool original_reload_request = false;
29
32
        public bool has_autosized = false;
143
146
                /* ViewContainer listens to this signal takes care of updating appearance
144
147
                 * If allow_mode_change is false View Container will not automagically
145
148
                 * switch to icon view for icon folders (needed for Miller View) */
 
149
 
146
150
                dir_view.clear (); /* clear model but do not change directory */
 
151
 
147
152
                /* Only need to initialise directory once - the slot that originally received the
148
153
                 * reload request does this */ 
149
154
                if (original_reload_request) {
 
155
                    schedule_reload ();
 
156
                    original_reload_request = false;
 
157
                }
 
158
            }
 
159
        }
 
160
 
 
161
        private void schedule_reload () {
 
162
            /* Allow time for other slots showing this directory to prepare for reload */
 
163
            if (reload_timeout_id > 0) {
 
164
                warning ("Path change request received too rapidly");
 
165
                return;
 
166
            }
 
167
            reload_timeout_id = Timeout.add (50, ()=> {
150
168
                    directory.reload ();
151
 
                    original_reload_request = false;
152
 
                }
153
 
            }
 
169
                    reload_timeout_id = 0;
 
170
                    return false;
 
171
            });
154
172
        }
155
173
 
156
174
        private void set_up_directory (GLib.File loc) {
172
190
         * due to undiagnosed bug.
173
191
         */  
174
192
        private void schedule_path_change_request (GLib.File loc, int flag, bool make_root) {
175
 
            GLib.Timeout.add (20, () => {
 
193
            if (path_change_timeout_id > 0) {
 
194
                warning ("Path change request received too rapidly");
 
195
                return;
 
196
            }
 
197
            path_change_timeout_id = GLib.Timeout.add (20, () => {
176
198
                on_dir_view_path_change_request (loc, flag, make_root);
 
199
                path_change_timeout_id = 0; 
177
200
                return false;
178
201
            });
179
202
        }
350
373
        }
351
374
 
352
375
        public override void cancel () {
 
376
            cancel_timeouts ();
 
377
 
353
378
            if (directory != null)
354
379
                directory.cancel ();
355
380
 
388
413
                return null;
389
414
            }
390
415
        }
 
416
 
 
417
        private void cancel_timeouts () {
 
418
            cancel_timeout (ref reload_timeout_id);
 
419
            cancel_timeout (ref path_change_timeout_id);
 
420
        }
 
421
 
 
422
        private void cancel_timeout (ref uint id) {
 
423
            if (id > 0) {
 
424
                Source.remove (id);
 
425
                id = 0;
 
426
            }
 
427
        }
391
428
    }
392
429
}