summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-10-09 16:05:51 +0200
committerhut <hut@lavabit.com>2010-10-09 16:05:51 +0200
commit6ccd4598961587723b7e277964f5f78ba3cb19bd (patch)
treec4e01b91e4bc281ca9be00e7c6318772e372c970
parent91cfd75cf564605dc01826a7980087b4a4ee6871 (diff)
downloadranger-6ccd4598961587723b7e277964f5f78ba3cb19bd.tar.gz
core.loader: throw more signals
-rw-r--r--ranger/core/loader.py9
-rw-r--r--ranger/fsobject/file.py10
2 files changed, 14 insertions, 5 deletions
diff --git a/ranger/core/loader.py b/ranger/core/loader.py
index 1ea50f4d..5e652a28 100644
--- a/ranger/core/loader.py
+++ b/ranger/core/loader.py
@@ -55,6 +55,7 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware):
 	object is removed from the queue (type ^C in ranger)
 	"""
 	finished = False
+	process = None
 	def __init__(self, args, descr, silent=False):
 		SignalDispatcher.__init__(self)
 		Loadable.__init__(self, self.generate(), descr)
@@ -68,7 +69,7 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware):
 		if self.silent:
 			while process.poll() is None:
 				yield
-				sleep(0.02)
+				sleep(0.03)
 		else:
 			while process.poll() is None:
 				yield
@@ -80,8 +81,7 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware):
 						if error:
 							self.fm.notify(error, bad=True)
 				except select.error:
-					pass
-				sleep(0.01)
+					sleep(0.03)
 		self.finished = True
 		self.signal_emit('after', process=process)
 
@@ -89,13 +89,16 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware):
 		if not self.finished and not self.paused:
 			self.process.send_signal(20)
 		Loadable.pause(self)
+		self.signal_emit('pause', process=self.process)
 
 	def unpause(self):
 		if not self.finished and self.paused:
 			self.process.send_signal(18)
 		Loadable.unpause(self)
+		self.signal_emit('unpause', process=self.process)
 
 	def destroy(self):
+		self.signal_emit('destroy', process=self.process)
 		if self.process:
 			self.process.kill()
 
diff --git a/ranger/fsobject/file.py b/ranger/fsobject/file.py
index 4076b136..d7e667a2 100644
--- a/ranger/fsobject/file.py
+++ b/ranger/fsobject/file.py
@@ -95,7 +95,7 @@ class File(FileSystemObject):
 			return False
 		return True
 
-	def _update_preview(self, signal):
+	def _loader_after(self, signal):
 		self.preview_known = True
 		self.preview_data = None
 		if not signal.process.poll():
@@ -104,6 +104,11 @@ class File(FileSystemObject):
 			self.fm.ui.browser.pager.need_redraw = True
 			self.fm.ui.browser.need_redraw = True
 
+	def _loader_destroy(self, signal):
+		self.preview_known = False
+		self.preview_loading = False
+		self.preview_data = None
+
 	def get_preview_source(self, width, height):
 		if self.fm.settings.preview_script:
 			if self.preview_known or self.preview_loading:
@@ -112,7 +117,8 @@ class File(FileSystemObject):
 			loadable = CommandLoader(args=[self.fm.settings.preview_script,
 				self.path, str(width), str(height)],
 				silent=True, descr="Getting preview of %s" % self.path)
-			loadable.signal_bind('after', self._update_preview, weak=True)
+			loadable.signal_bind('after', self._loader_after, weak=True)
+			loadable.signal_bind('destroy', self._loader_destroy, weak=True)
 			self.fm.loader.add(loadable)
 			return None
 		return open(self.path, 'r')
documentation, DESIGN' href='/danisanti/profani-tty/commit/DESIGN?id=95dbb68b388dc4cf13491b9e04b197b17144f745'>95dbb68b ^
278cd9dd ^
95dbb68b ^
1b717024 ^
95dbb68b ^






1b717024 ^
95dbb68b ^





1b717024 ^
95dbb68b ^



















1b717024 ^
95dbb68b ^

1b717024 ^
95dbb68b ^





1b717024 ^
95dbb68b ^










1b717024 ^
95dbb68b ^
1b717024 ^
95dbb68b ^















1b717024 ^
95dbb68b ^




1b717024 ^
95dbb68b ^








1b717024 ^
95dbb68b ^






1b717024 ^

95dbb68b ^








7e620763 ^

95dbb68b ^
1b717024 ^
7e620763 ^










2429d23f ^
7e620763 ^
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