summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/container/settings.py15
-rw-r--r--ranger/core/main.py12
-rw-r--r--ranger/core/tab.py4
-rw-r--r--ranger/gui/widgets/view_miller.py4
4 files changed, 29 insertions, 6 deletions
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index a7911251..a5d71874 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -8,6 +8,15 @@ from ranger.gui.colorscheme import _colorscheme_name_to_class
 import re
 import os.path
 
+# Use these priority constants to trigger events at specific points in time
+# during processing of the signals "setopt" and "setopt.<some_setting_name>"
+SIGNAL_PRIORITY_RAW        = 2.0  # signal.value will be raw
+SIGNAL_PRIORITY_SANITIZE   = 1.0  # (Internal) post-processing signal.value
+SIGNAL_PRIORITY_BETWEEN    = 0.6  # sanitized signal.value, old fm.settings.XYZ
+SIGNAL_PRIORITY_SYNC       = 0.2  # (Internal) updating fm.settings.XYZ
+SIGNAL_PRIORITY_AFTER_SYNC = 0.1  # after fm.settings.XYZ was updated
+
+
 ALLOWED_SETTINGS = {
     'automatically_count_files': bool,
     'autosave_bookmarks': bool,
@@ -97,9 +106,11 @@ class Settings(SignalDispatcher, FileManagerAware):
         self.__dict__['_settings'] = dict()
         for name in ALLOWED_SETTINGS:
             self.signal_bind('setopt.' + name,
-                    self._sanitize, priority=1.0)
+                    self._sanitize,
+                    priority=SIGNAL_PRIORITY_SANITIZE)
             self.signal_bind('setopt.' + name,
-                    self._raw_set_with_signal, priority=0.2)
+                    self._raw_set_with_signal,
+                    priority=SIGNAL_PRIORITY_SYNC)
 
     def _sanitize(self, signal):
         name, value = signal.setting, signal.value
diff --git a/ranger/core/main.py b/ranger/core/main.py
index 000ded68..118a7480 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -303,8 +303,16 @@ def load_settings(fm, clean):
             ranger.fm = fm
             for plugin in sorted(plugins):
                 try:
-                    module = __import__('plugins', fromlist=[plugin])
-                    fm.commands.load_commands_from_module(module)
+                    try:
+                        # importlib does not exist before python2.7.  It's
+                        # required for loading commands from plugins, so you
+                        # can't use that feature in python2.6.
+                        import importlib
+                    except ImportError:
+                        module = __import__('plugins', fromlist=[plugin])
+                    else:
+                        module = importlib.import_module('plugins.' + plugin)
+                        fm.commands.load_commands_from_module(module)
                     fm.log.append("Loaded plugin '%s'." % plugin)
                 except Exception as e:
                     fm.log.append("Error in plugin '%s'" % plugin)
diff --git a/ranger/core/tab.py b/ranger/core/tab.py
index 7b60a5b1..fa40a12b 100644
--- a/ranger/core/tab.py
+++ b/ranger/core/tab.py
@@ -5,6 +5,7 @@ import os
 import sys
 from os.path import abspath, normpath, join, expanduser, isdir
 
+from ranger.container import settings
 from ranger.container.history import History
 from ranger.core.shared import FileManagerAware, SettingsAware
 from ranger.ext.signals import SignalDispatcher
@@ -22,7 +23,8 @@ class Tab(FileManagerAware, SettingsAware):
         # NOTE: in the line below, weak=True works only in python3.  In python2,
         # weak references are not equal to the original object when tested with
         # "==", and this breaks _set_thisfile_from_signal and _on_tab_change.
-        self.fm.signal_bind('move', self._set_thisfile_from_signal, priority=0.1,
+        self.fm.signal_bind('move', self._set_thisfile_from_signal,
+                priority=settings.SIGNAL_PRIORITY_AFTER_SYNC,
                 weak=(sys.version_info[0] >= 3))
         self.fm.signal_bind('tab.change', self._on_tab_change,
                 weak=(sys.version_info[0] >= 3))
diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py
index 732c6170..90046456 100644
--- a/ranger/gui/widgets/view_miller.py
+++ b/ranger/gui/widgets/view_miller.py
@@ -5,6 +5,7 @@
 
 import curses
 import _curses
+from ranger.container import settings
 from ranger.ext.signals import Signal
 from .browsercolumn import BrowserColumn
 from .pager import Pager
@@ -35,7 +36,8 @@ class ViewMiller(ViewBase):
                     self._request_clear_if_has_borders, weak=True)
 
         self.settings.signal_bind('setopt.column_ratios', self.request_clear)
-        self.settings.signal_bind('setopt.column_ratios', self.rebuild)
+        self.settings.signal_bind('setopt.column_ratios', self.rebuild,
+                priority=settings.SIGNAL_PRIORITY_AFTER_SYNC)
 
         self.old_draw_borders = self.settings.draw_borders