about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech.siewierski@onet.pl>2017-07-06 23:20:11 +0200
committerWojciech Siewierski <wojciech.siewierski@onet.pl>2017-07-06 23:23:41 +0200
commit3788a8345b35f65dd365719d772d8ce6add5783d (patch)
tree054011d06b901018dd7d7fa07ec2d1210b453636
parentef78e4e5daedf4f8e843190631935030bf5331bb (diff)
downloadranger-3788a8345b35f65dd365719d772d8ce6add5783d.tar.gz
Properly handle toggling 'preview_images'
1. Don't use the cached image previews if 'preview_images' is turned off.
2. Wipe the preview cache after toggling 'preview_images' for it to
   take effect immediately.
-rw-r--r--ranger/core/actions.py3
-rw-r--r--ranger/core/fm.py5
2 files changed, 7 insertions, 1 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 3b30fe6b..eb091186 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -1025,7 +1025,8 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
             return path
 
         cacheimg = os.path.join(ranger.args.cachedir, self.sha1_encode(path))
-        if os.path.isfile(cacheimg) and \
+        if self.settings.preview_images and \
+                os.path.isfile(cacheimg) and \
                 os.path.getmtime(cacheimg) > os.path.getmtime(path):
             data['foundpreview'] = True
             data['imagepreview'] = True
diff --git a/ranger/core/fm.py b/ranger/core/fm.py
index e53d36e1..9f409a94 100644
--- a/ranger/core/fm.py
+++ b/ranger/core/fm.py
@@ -104,6 +104,11 @@ class FM(Actions,  # pylint: disable=too-many-instance-attributes
         self.settings.signal_bind('setopt.preview_images_method', set_image_displayer,
                                   priority=settings.SIGNAL_PRIORITY_AFTER_SYNC)
 
+        self.settings.signal_bind(
+            'setopt.preview_images',
+            lambda signal: setattr(signal.fm, 'previews', {}),
+        )
+
         if ranger.args.clean:
             self.tags = TagsDummy("")
         elif self.tags is None: