about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-02-25 16:41:25 +0100
committerhut <hut@lavabit.com>2010-02-25 20:37:11 +0100
commit7a268c8be8896d3ec71952a6fd261012e39c1c1a (patch)
tree101d930825a43be2ba53e37ae301d4a38111996e /ranger
parent0c2c782dd8ff7cfc74fc46dd68eda0b94d540058 (diff)
downloadranger-7a268c8be8896d3ec71952a6fd261012e39c1c1a.tar.gz
todo: finished #63: limit filesize in previews
Diffstat (limited to 'ranger')
-rw-r--r--ranger/defaults/options.py3
-rw-r--r--ranger/gui/widgets/browsercolumn.py4
-rw-r--r--ranger/shared/settings.py1
3 files changed, 7 insertions, 1 deletions
diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py
index 1f564eb0..6a1ae862 100644
--- a/ranger/defaults/options.py
+++ b/ranger/defaults/options.py
@@ -6,9 +6,12 @@ intact and the type of the value stays the same.
 
 from ranger.api.options import *
 
+one_kb = 1024
+
 colorscheme = colorschemes.default
 
 max_history_size = 20
+max_filesize_for_preview = 300 * one_kb
 scroll_offset = 2
 preview_files = True
 flushinput = True
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 956fd301..b07d86ed 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -137,8 +137,10 @@ class BrowserColumn(Pager, Widget):
 			self.last_redraw_time = time()
 
 	def _preview_this_file(self, target):
+		maxsize = self.settings.max_filesize_for_preview
 		return self.settings.preview_files \
-				and not PREVIEW_BLACKLIST.search(target.basename)
+				and not PREVIEW_BLACKLIST.search(target.basename) \
+				and (maxsize is None or maxsize >= target.size)
 
 	def _draw_file(self):
 		"""Draw a preview of the file, if the settings allow it"""
diff --git a/ranger/shared/settings.py b/ranger/shared/settings.py
index 4ae97e03..152dfbd1 100644
--- a/ranger/shared/settings.py
+++ b/ranger/shared/settings.py
@@ -19,6 +19,7 @@ preview_files max_history_size colorscheme
 collapse_preview update_title
 hidden_filter flushinput
 autosave_bookmarks
+max_filesize_for_preview
 """.split()
 
 # -- globalize the settings --