diff options
Diffstat (limited to 'ranger/shared/settings.py')
-rw-r--r-- | ranger/shared/settings.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/ranger/shared/settings.py b/ranger/shared/settings.py index a4a58e6e..c5544a47 100644 --- a/ranger/shared/settings.py +++ b/ranger/shared/settings.py @@ -39,6 +39,7 @@ ALLOWED_SETTINGS = { 'scroll_offset': int, 'preview_files': bool, 'preview_directories': bool, + 'mouse_enabled': bool, 'flushinput': bool, 'colorscheme': str, 'colorscheme_overlay': (type(None), type(lambda:0)), @@ -57,6 +58,9 @@ class SettingObject(SignalDispatcher): SignalDispatcher.__init__(self) self.__dict__['_settings'] = dict() self.__dict__['_setting_sources'] = list() + for name in ALLOWED_SETTINGS: + self.signal_bind('setopt.'+name, + self._raw_set_with_signal, priority=0.2) def __setattr__(self, name, value): if name[0] == '_': @@ -66,8 +70,6 @@ class SettingObject(SignalDispatcher): assert self._check_type(name, value) kws = dict(setting=name, value=value, previous=self._settings[name]) - self.signal_bind('setopt.'+name, - self._raw_set_with_signal, priority=0.2) self.signal_emit('setopt', **kws) self.signal_emit('setopt.'+name, **kws) @@ -89,6 +91,22 @@ class SettingObject(SignalDispatcher): self.__setattr__(name, value) return self._settings[name] + def __iter__(self): + for x in self._settings: + yield x + + def types_of(self, name): + try: + typ = ALLOWED_SETTINGS[name] + except KeyError: + return tuple() + else: + if isinstance(typ, tuple): + return typ + else: + return (typ, ) + + def _check_type(self, name, value): from inspect import isfunction typ = ALLOWED_SETTINGS[name] |