summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-24 14:42:30 +0100
committerhut <hut@lavabit.com>2009-12-24 14:42:30 +0100
commitd35bac82e6ebdbd12701f868efb104ea54c316eb (patch)
tree0eab00389332178758070d4f01bc86deaf699a29
parente92fe17a449cad78c79a905fd53ec73f8a41051c (diff)
downloadranger-d35bac82e6ebdbd12701f868efb104ea54c316eb.tar.gz
misc clean ups
-rw-r--r--ranger/fsobject/directory.py13
-rw-r--r--ranger/fsobject/loader.py28
-rw-r--r--ranger/gui/widgets/console.py7
3 files changed, 27 insertions, 21 deletions
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index f91f99d9..b83e1592 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -169,7 +169,8 @@ class Directory(SuperClass, SettingsAware):
 #		yield
 
 	def load_content(self, schedule=False):
-		"""Loads the contents of the directory. Use this sparingly since
+		"""
+		Loads the contents of the directory. Use this sparingly since
 		it takes rather long.
 		"""
 
@@ -248,7 +249,8 @@ class Directory(SuperClass, SettingsAware):
 		return self.pointed_file
 
 	def move_pointer_to_file_path(self, path):
-		"""Move the index pointer to the index of the file object
+		"""
+		Move the index pointer to the index of the file object
 		with the given path.
 		"""
 		if path is None: return
@@ -291,9 +293,7 @@ class Directory(SuperClass, SettingsAware):
 		return False
 
 	def correct_pointer(self):
-		"""make sure the pointer is in the valid range of:
-		0:len(self.files)-1 (or None if directory is empty.)
-		"""
+		"""Make sure the pointer is in the valid range"""
 
 		if self.files is None or len(self.files) == 0:
 			self.pointed_index = None
@@ -320,7 +320,8 @@ class Directory(SuperClass, SettingsAware):
 		return False
 
 	def load_content_if_outdated(self, *a, **k):
-		"""Load the contents of the directory if it's
+		"""
+		Load the contents of the directory if it's
 		outdated or not done yet
 		"""
 		if self.load_content_once(*a, **k): return True
diff --git a/ranger/fsobject/loader.py b/ranger/fsobject/loader.py
index 483595c3..5923ff95 100644
--- a/ranger/fsobject/loader.py
+++ b/ranger/fsobject/loader.py
@@ -4,39 +4,43 @@ from ranger import log
 import math
 
 def status_generator():
+	"""Generate a rotating line which can be used as a throbber"""
 	while True:
 		yield '/'
 		yield '-'
 		yield '\\'
 		yield '|'
 
-def delayfunc(n):
-#	if n < 4:
-		return 0.05
-#	else:
-#		return 0.15
-#		return math.log(n-2) * 0.2
-
 class Loader(object):
-	seconds_of_work_time = 0.1
+	seconds_of_work_time = 0.05
+
 	def __init__(self):
 		self.queue = deque()
 		self.item = None
 		self.load_generator = None
 		self.status_generator = status_generator()
-		self.tick = 0
 		self.rotate()
 		self.old_item = None
 	
 	def rotate(self):
+		"""Rotate the throbber"""
+		# TODO: move all throbber logic to UI
 		self.status = next(self.status_generator)
 	
 	def add(self, obj):
+		"""
+		Add an object to the queue.
+		It should have a load_generator method.
+		"""
 		while obj in self.queue:
 			self.queue.remove(obj)
 		self.queue.appendleft(obj)
 
 	def work(self):
+		"""
+		Load items from the queue if there are any.
+		Stop after approximately self.seconds_of_work_time.
+		"""
 		while True:
 			# get the first item with a proper load_generator
 			try:
@@ -49,12 +53,11 @@ class Loader(object):
 				return
 
 		self.rotate()
-		self.tick += 1
 		if item != self.old_item:
-			self.tick = 0
 			self.old_item = item
 
-		end_time = time() + delayfunc(self.tick)
+		end_time = time() + self.seconds_of_work_time
+
 		try:
 			while time() < end_time:
 				next(item.load_generator)
@@ -63,4 +66,5 @@ class Loader(object):
 			self.queue.popleft()
 	
 	def has_work(self):
+		"""Is there anything to load?"""
 		return bool(self.queue)
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index ee80e639..2a4e24d9 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -267,8 +267,8 @@ class OpenConsole(Console):
 
 
 class QuickOpenConsole(Console):
-
-	"""The QuickOpenConsole allows you to open files with
+	"""
+	The QuickOpenConsole allows you to open files with
 	pre-defined programs and modes very quickly. By adding flags
 	to the command, you can specify precisely how the program is run,
 	ie. the d-flag will run it detached from the filemanager.
@@ -290,7 +290,8 @@ class QuickOpenConsole(Console):
 		Console.execute(self)
 
 	def _get_app_flags_mode(self):
-		"""extracts the application, flags and mode from
+		"""
+		Extracts the application, flags and mode from
 		a string entered into the "openwith_quick" console.
 		"""
 		# examples:
/pager.py?h=v1.9.2&id=a78cfb7eee02d27f03b5355d9e42a6ba9522d430'>a78cfb7e ^
06aefcf5 ^
f257e476 ^
06aefcf5 ^

a78cfb7e ^
06aefcf5 ^
45076ed4 ^
ea87d005 ^
06aefcf5 ^


ea87d005 ^
33cb688a ^

ea87d005 ^
f257e476 ^
45076ed4 ^















a78cfb7e ^
45076ed4 ^
ea87d005 ^
a78cfb7e ^































43e0f44a ^






a78cfb7e ^
a406a33d ^





6613bf41 ^
a406a33d ^

292b4476 ^
a406a33d ^





a406a33d ^


292b4476 ^
06aefcf5 ^

c4e869dd ^



















06aefcf5 ^
c4e869dd ^
ea87d005 ^
5715beca ^
f257e476 ^


5715beca ^

d538bd40 ^
43e0f44a ^
5715beca ^
1a8d64f1 ^
f257e476 ^


43e0f44a ^
f257e476 ^





5715beca ^


f257e476 ^

06aefcf5 ^
b4cb1f7d ^

b3125849 ^

d6e2900a ^
b4cb1f7d ^

f257e476 ^
a406a33d ^
f257e476 ^



811f5bb8 ^

6613bf41 ^

811f5bb8 ^




f257e476 ^

ea87d005 ^
f257e476 ^






43e0f44a ^





f257e476 ^


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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231