From 7fe6d250b44c1f06d4b578b8cdbd4fb055dedc28 Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 25 Dec 2009 06:33:54 +0100 Subject: schedule loading of directories whereever possible --- ranger/fsobject/directory.py | 36 ++++++++++++++++++------------------ ranger/gui/widgets/filelist.py | 6 +++--- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py index f5aeade4..136752f8 100644 --- a/ranger/fsobject/directory.py +++ b/ranger/fsobject/directory.py @@ -170,32 +170,33 @@ class Directory(FileSystemObject, SettingsAware): self.loading = False self.load_generator = None - def load_content(self, schedule=False): + def load_content(self, schedule=None): """ Loads the contents of the directory. Use this sparingly since it takes rather long. """ - self.load_once() - - if schedule is None: - schedule = self.size > 30 + if not self.loading: + self.load_once() + + if schedule is None: + schedule = self.size > 30 + + if self.load_generator is None: + self.load_generator = self.load_bit_by_bit() - if self.load_generator is None: - self.load_generator = self.load_bit_by_bit() + if schedule and self.fm: + self.fm.loader.add(self) + else: + for _ in self.load_generator: + pass + self.load_generator = None - if schedule and self.fm: - self.fm.loader.add(self) - else: + elif not schedule or not self.fm: for _ in self.load_generator: pass self.load_generator = None - elif not schedule or not self.fm: - for _ in self.load_generator: - pass - self.load_generator = None - def sort(self): """Sort the containing files""" @@ -322,8 +323,7 @@ class Directory(FileSystemObject, SettingsAware): def load_content_once(self, *a, **k): """Load the contents of the directory if not done yet""" if not self.content_loaded: - if not self.loading: - self.load_content(*a, **k) + self.load_content(*a, **k) return True return False @@ -351,7 +351,7 @@ class Directory(FileSystemObject, SettingsAware): cached_mtime = 0 if real_mtime != cached_mtime: - self.load_content() + self.load_content(*a, **k) return True return False diff --git a/ranger/gui/widgets/filelist.py b/ranger/gui/widgets/filelist.py index 8b4443d3..999cfd12 100644 --- a/ranger/gui/widgets/filelist.py +++ b/ranger/gui/widgets/filelist.py @@ -74,7 +74,7 @@ class FileList(Widget): def finalize(self): if self.postpone_drawing: - self.target.load_content_if_outdated(schedule=None) + self.target.load_content_if_outdated() self.draw_directory() self.postpone_drawing = False @@ -140,8 +140,8 @@ class FileList(Widget): self.color_reset() return - self.target.load_content_if_outdated() - self.target.sort_if_outdated() + if not self.target.load_content_if_outdated(): + self.target.sort_if_outdated() if self.main_display: base_color.append('maindisplay') -- cgit 1.4.1-2-gfad0 /mu/blame/subx/039debug.cc?h=hlt&id=0b91d25cf591888252d5e99e7986e2544de31695'>blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63