summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2013-02-10 21:22:46 +0100
committerhut <hut@lavabit.com>2013-02-10 21:22:46 +0100
commita9bd6171c682f5c2235f435d539998770aeaddaf (patch)
tree7002a85c1409f2c869f5bd91c34ef34c5476d3d3
parentf2cc491647fa0cb2cd37488d007d549a5c80ebc2 (diff)
downloadranger-a9bd6171c682f5c2235f435d539998770aeaddaf.tar.gz
ext.img_display: disable preview_images when unsupported
-rw-r--r--ranger/ext/img_display.py5
-rw-r--r--ranger/gui/widgets/pager.py2
2 files changed, 6 insertions, 1 deletions
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py
index a89f6d8b..307c7b75 100644
--- a/ranger/ext/img_display.py
+++ b/ranger/ext/img_display.py
@@ -15,6 +15,9 @@ from subprocess import Popen, PIPE
 W3MIMGDISPLAY_PATH = '/usr/lib/w3m/w3mimgdisplay'
 W3MIMGDISPLAY_OPTIONS = []
 
+class ImgDisplayUnsupportedException(Exception):
+    pass
+
 def _get_font_dimensions():
     """
     Get the height and width of a character displayed in the terminal in
@@ -49,7 +52,7 @@ def draw(path, start_x, start_y, max_width, max_height):
     """
     fontw, fonth = _get_font_dimensions()
     if fontw == 0 or fonth == 0:
-      return
+        raise ImgDisplayUnsupportedException()
 
     max_width_pixels = max_width * fontw
     max_height_pixels = max_height * fonth
diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py
index e9ce8b5c..4e8161a5 100644
--- a/ranger/gui/widgets/pager.py
+++ b/ranger/gui/widgets/pager.py
@@ -84,6 +84,8 @@ class Pager(Widget):
             self.need_redraw_image = False
             try:
                 img_display.draw(self.image, self.x, self.y, self.wid, self.hei)
+            except img_display.ImgDisplayUnsupportedException:
+                self.fm.settings.preview_images = False
             except Exception as e:
                 self.fm.notify(e, bad=True)