summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-10-11 07:23:38 +0200
committerhut <hut@lavabit.com>2010-10-11 07:28:02 +0200
commite3ad1e7ecdedcd3f8badec20b243ab2079262e98 (patch)
treebef0c7ddd9f17920eb032582ee3ec3be99f32702
parent3744fed33e482856ffbdd692a4fba1e2ce3037dd (diff)
downloadranger-e3ad1e7ecdedcd3f8badec20b243ab2079262e98.tar.gz
widgets.browserview: fix collapse_preview option
-rw-r--r--ranger/core/actions.py7
-rw-r--r--ranger/gui/widgets/browserview.py13
2 files changed, 18 insertions, 2 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 235be620..a815b111 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -581,6 +581,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 			# self.previews['/tmp/foo.jpg'][(80, 24)] = "the content..."
 			# self.previews['/tmp/foo.jpg']['loading'] = False
 			# A -1 in tuples means "any"; (80, -1) = wid. of 80 and any hei.
+			# The key 'foundpreview' is added later. Values in (True, False)
 			try:
 				data = self.previews[path]
 			except:
@@ -600,6 +601,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 					exit = signal.process.poll()
 					content = signal.loader.stdout_buffer
 					content += signal.process.stdout.read()
+					data['foundpreview'] = True
 					if exit == 0:
 						data[(width, height)] = content
 					elif exit == 3:
@@ -608,8 +610,11 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 						data[(width, -1)] = content
 					elif exit == 5:
 						data[(-1, -1)] = content
+					elif exit == 1:
+						data[(-1, -1)] = None
+						data['foundpreview'] = False
 					else:
-						data[(-1, -1)] = None # XXX
+						data[(-1, -1)] = None
 					if self.env.cf.path == path:
 						self.ui.browser.pager.need_redraw = True
 						self.ui.browser.need_redraw = True
diff --git a/ranger/gui/widgets/browserview.py b/ranger/gui/widgets/browserview.py
index 142e7985..bbaee6a2 100644
--- a/ranger/gui/widgets/browserview.py
+++ b/ranger/gui/widgets/browserview.py
@@ -28,6 +28,7 @@ class BrowserView(Widget, DisplayableContainer):
 	draw_bookmarks = False
 	stretch_ratios = None
 	need_clear = False
+	old_collapse = False
 
 	def __init__(self, win, ratios, preview = True):
 		DisplayableContainer.__init__(self, win)
@@ -196,8 +197,18 @@ class BrowserView(Widget, DisplayableContainer):
 
 	def _collapse(self):
 		# Should the last column be cut off? (Because there is no preview)
-		return self.settings.collapse_preview and self.preview and \
+		result = self.settings.collapse_preview and self.preview and \
 			not self.columns[-1].has_preview() and self.stretch_ratios
+		if result:
+			return True
+		if self.columns[-1].target:
+			target = self.columns[-1].target
+			try:
+				result = not self.fm.previews[target.realpath]['foundpreview']
+			except:
+				return self.old_collapse
+		self.old_collapse = result
+		return result
 
 	def resize(self, y, x, hei, wid):
 		"""Resize all the columns according to the given ratio"""