From 6dad7b9222168602c5c23fc001be290110721ec5 Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 11 Oct 2010 08:11:22 +0200 Subject: Added boolean option use_preview_script --- ranger/container/settingobject.py | 1 + ranger/core/actions.py | 2 +- ranger/defaults/options.py | 6 ++++-- ranger/fsobject/file.py | 3 ++- ranger/gui/widgets/browserview.py | 4 +++- 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: -- cgit 1.4.1-2-gfad0