summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-10-11 08:11:22 +0200
committerhut <hut@lavabit.com>2010-10-11 08:11:22 +0200
commit6dad7b9222168602c5c23fc001be290110721ec5 (patch)
treec8faea0a101bf05368d15888181473fb22b784cd
parenta0ca73c855d4925780253c8294d725892455cc51 (diff)
downloadranger-6dad7b9222168602c5c23fc001be290110721ec5.tar.gz
Added boolean option use_preview_script
-rw-r--r--ranger/container/settingobject.py1
-rw-r--r--ranger/core/actions.py2
-rw-r--r--ranger/defaults/options.py6
-rw-r--r--ranger/fsobject/file.py3
-rw-r--r--ranger/gui/widgets/browserview.py4
5 files changed, 11 insertions, 5 deletions
diff --git a/ranger/container/settingobject.py b/ranger/container/settingobject.py
index c8bd8b49..51d6db1a 100644
--- a/ranger/container/settingobject.py
+++ b/ranger/container/settingobject.py
@@ -48,6 +48,7 @@ ALLOWED_SETTINGS = {
 	'sort': str,
 	'tilde_in_titlebar': bool,
 	'update_title': bool,
+	'use_preview_script': bool,
 	'xterm_alt_key': bool,
 }
 
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index a815b111..2f6d2719 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -576,7 +576,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 	# -- Previews
 	# --------------------------
 	def get_preview(self, path, width, height):
-		if self.settings.preview_script:
+		if self.settings.preview_script and self.settings.use_preview_script:
 			# self.previews is a 2 dimensional dict:
 			# self.previews['/tmp/foo.jpg'][(80, 24)] = "the content..."
 			# self.previews['/tmp/foo.jpg']['loading'] = False
diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py
index 3c20c6fb..845e451f 100644
--- a/ranger/defaults/options.py
+++ b/ranger/defaults/options.py
@@ -40,12 +40,14 @@ hidden_filter = regexp(
 show_hidden = False
 
 # Which script is used to generate file previews?
-#preview_script = None
-
 # Ranger ships with scope.sh, a script that calls external programs (see
 # README for dependencies) to preview images, archives, etc.
 preview_script = '~/.config/ranger/scope.sh'
 
+# Use that external preview script or display internal plain text previews?
+# Set to False by default for performance and stability reasons
+use_preview_script = False
+
 # Show dotfiles in the bookmark preview box?
 show_hidden_bookmarks = True
 
diff --git a/ranger/fsobject/file.py b/ranger/fsobject/file.py
index 5fd90b96..9fce3255 100644
--- a/ranger/fsobject/file.py
+++ b/ranger/fsobject/file.py
@@ -83,7 +83,8 @@ class File(FileSystemObject):
 			return False
 		if not self.accessible:
 			return False
-		if self.fm.settings.preview_script:
+		if self.fm.settings.preview_script and \
+				self.fm.settings.use_preview_script:
 			return True
 		if self.image or self.container:
 			return False
diff --git a/ranger/gui/widgets/browserview.py b/ranger/gui/widgets/browserview.py
index e222c582..8a8f6e14 100644
--- a/ranger/gui/widgets/browserview.py
+++ b/ranger/gui/widgets/browserview.py
@@ -202,7 +202,9 @@ class BrowserView(Widget, DisplayableContainer):
 			return False
 		result = not self.columns[-1].has_preview()
 		target = self.columns[-1].target
-		if not result and target and target.is_file:
+		if not result and target and target.is_file and \
+			self.fm.settings.preview_script and \
+			self.fm.settings.use_preview_script:
 			try:
 				result = not self.fm.previews[target.realpath]['foundpreview']
 			except: