summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2016-07-04 20:09:23 +0200
committerhut <hut@lepus.uberspace.de>2016-07-04 20:09:23 +0200
commitf2c18a523e054308aca795b00030bfdf4de5985b (patch)
tree88980f58e2873f62c9d2a2eb748eabd62828a46e
parentb4e26110e2ef15404430a09b4e2ec9eb9959ce21 (diff)
downloadranger-f2c18a523e054308aca795b00030bfdf4de5985b.tar.gz
container.settings: use constants for `setopt` signal priorities
-rw-r--r--ranger/container/settings.py15
-rw-r--r--ranger/core/tab.py4
-rw-r--r--ranger/gui/widgets/view_miller.py3
3 files changed, 18 insertions, 4 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/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 a302c9d5..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
@@ -36,7 +37,7 @@ class ViewMiller(ViewBase):
 
         self.settings.signal_bind('setopt.column_ratios', self.request_clear)
         self.settings.signal_bind('setopt.column_ratios', self.rebuild,
-                priority=0.1)  # make sure it occurs *after* setting is updated
+                priority=settings.SIGNAL_PRIORITY_AFTER_SYNC)
 
         self.old_draw_borders = self.settings.draw_borders