about summary refs log tree commit diff stats
path: root/ranger/gui/widgets/filelistcontainer.py
diff options
context:
space:
mode:
Diffstat (limited to 'ranger/gui/widgets/filelistcontainer.py')
-rw-r--r--ranger/gui/widgets/filelistcontainer.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/ranger/gui/widgets/filelistcontainer.py b/ranger/gui/widgets/filelistcontainer.py
index 9d95b389..594d0530 100644
--- a/ranger/gui/widgets/filelistcontainer.py
+++ b/ranger/gui/widgets/filelistcontainer.py
@@ -2,15 +2,19 @@
 from . import Widget
 from .filelist import FileList
 from ..displayable import DisplayableContainer
+from ranger import log
 
 class FileListContainer(Widget, DisplayableContainer):
 	ratios = None
 	preview = True
+	preview_available = True
 
 	def __init__(self, win, ratios, preview = True):
 		DisplayableContainer.__init__(self, win)
 		from functools import reduce
 		self.ratios = ratios
+		self.preview = preview
+
 		# normalize ratios:
 		ratio_sum = float(reduce(lambda x,y: x + y, ratios))
 		self.ratios = tuple(map(lambda x: x / ratio_sum, ratios))
@@ -34,10 +38,28 @@ class FileListContainer(Widget, DisplayableContainer):
 		"""Resize all the filelists according to the given ratio"""
 		DisplayableContainer.resize(self, y, x, hei, wid)
 		left = self.x
-		for ratio, i in zip(self.ratios, range(len(self.ratios))):
+
+		cut_off_last = self.preview and not self.preview_available
+
+		if cut_off_last:
+			generator = zip(self.ratios[:-1], range(len(self.ratios)-1))
+		else:
+			generator = zip(self.ratios, range(len(self.ratios)))
+
+		for ratio, i in generator:
 			wid = int(ratio * self.wid)
+			if cut_off_last and i == len(self.ratios) - 2:
+				wid += int(self.ratios[-1] * self.wid)
 			try:
 				self.container[i].resize(self.y, left, hei, max(1, wid-1))
 			except KeyError:
 				pass
 			left += wid
+	
+	def poke(self):
+		DisplayableContainer.poke(self)
+		if self.preview:
+			has_preview = self.container[-1].has_preview()
+			if self.preview_available != has_preview:
+				self.preview_available = has_preview
+				self.resize(self.y, self.x, self.hei, self.wid)