summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/core/actions.py2
-rw-r--r--ranger/core/loader.py2
-rw-r--r--ranger/fsobject/file.py19
-rw-r--r--ranger/gui/widgets/browsercolumn.py3
4 files changed, 15 insertions, 11 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index e290db58..59eef2be 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -569,7 +569,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 			return
 
 		pager = self.ui.open_embedded_pager()
-		pager.set_source(self.env.cf.get_preview_source(pager))
+		pager.set_source(self.env.cf.get_preview_source(pager.wid, pager.hei))
 
 	# --------------------------
 	# -- Tabs
diff --git a/ranger/core/loader.py b/ranger/core/loader.py
index 66f7017c..c03ecc29 100644
--- a/ranger/core/loader.py
+++ b/ranger/core/loader.py
@@ -74,7 +74,7 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware):
 						self.fm.notify(error, bad=True)
 			except select.error:
 				pass
-			sleep(0.02)
+#			sleep(0.02)
 			yield
 		self.finished = True
 		self.signal_emit('after', process=process)
diff --git a/ranger/fsobject/file.py b/ranger/fsobject/file.py
index 5458b8b1..2701537c 100644
--- a/ranger/fsobject/file.py
+++ b/ranger/fsobject/file.py
@@ -56,6 +56,7 @@ class File(FileSystemObject):
 	is_file = True
 	preview_data = None
 	preview_known = False
+	preview_loading = False
 
 	@property
 	def firstbytes(self):
@@ -94,22 +95,24 @@ class File(FileSystemObject):
 			return False
 		return True
 
-	def update_preview(self, signal):
+	def _update_preview(self, signal):
 		self.preview_known = True
 		self.preview_data = None
 		if not signal.process.poll():
 			self.preview_data = signal.process.stdout.read()
-			self.fm.ui.pager.need_redraw = True
-			self.fm.ui.redraw()
+		if self.fm.env.cf.path == self.path:
+			self.fm.ui.browser.pager.need_redraw = True
+			self.fm.ui.browser.need_redraw = True
 
-	def get_preview_source(self, widget):
+	def get_preview_source(self, width, height):
 		if self.fm.settings.preview_script:
-			if self.preview_known:
+			if self.preview_known or self.preview_loading:
 				return self.preview_data
+			self.preview_loading = True
 			loadable = CommandLoader(args=[self.fm.settings.preview_script,
-				self.path, str(widget.wid), str(widget.hei)],
+				self.path, str(width), str(height)],
 				descr="Getting preview of %s" % self.path)
-			loadable.signal_bind('after', self.update_preview, weak=True)
+			loadable.signal_bind('after', self._update_preview, weak=True)
 			self.fm.loader.add(loadable)
-			return "loading..."
+			return None
 		return open(self.path, 'r')
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 63323f65..eb898e2a 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -156,8 +156,9 @@ class BrowserColumn(Pager):
 			return
 
 		try:
-			f = self.target.get_preview_source(self)
+			f = self.target.get_preview_source(self.wid, self.hei)
 		except:
+			raise # XXX
 			Pager.close(self)
 		else:
 			if f is None:
56' href='#n256'>256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276