summaryrefslogtreecommitdiff
path: root/alot/settings/manager.py
diff options
context:
space:
mode:
Diffstat (limited to 'alot/settings/manager.py')
-rw-r--r--alot/settings/manager.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/alot/settings/manager.py b/alot/settings/manager.py
index 5d2098b0..2945c125 100644
--- a/alot/settings/manager.py
+++ b/alot/settings/manager.py
@@ -13,10 +13,10 @@ import os
import re
from configobj import ConfigObj, Section
+from urwid import AttrSpec
from .errors import ConfigError, NoMatchingAccount
from .utils import read_config
-from .utils import resolve_att
from .theme import Theme
from ..account import SendmailAccount
@@ -29,6 +29,20 @@ DEFAULTSPATH = os.path.join(os.path.dirname(__file__), '..', 'defaults')
DATA_DIRS = get_xdg_env('XDG_DATA_DIRS',
'/usr/local/share:/usr/share').split(':')
+def _resolve_att(a, fallback):
+ """ replace '' and 'default' by fallback values """
+ if a is None:
+ return fallback
+ if a.background in ['default', '']:
+ bg = fallback.background
+ else:
+ bg = a.background
+ if a.foreground in ['default', '']:
+ fg = fallback.foreground
+ else:
+ fg = a.foreground
+ return AttrSpec(fg, bg)
+
def _pretty_datetime(d):
"""
translates :class:`datetime` `d` to a "sup-style" human readable string.
@@ -428,15 +442,15 @@ class SettingsManager:
default_focus = theme.get_attribute(colourmode, 'global', 'tag_focus')
# local defaults for tagstring attributes. depend on next lower widget
- fallback_normal = resolve_att(onebelow_normal, default_normal)
- fallback_focus = resolve_att(onebelow_focus, default_focus)
+ fallback_normal = _resolve_att(onebelow_normal, default_normal)
+ fallback_focus = _resolve_att(onebelow_focus, default_focus)
for sec in cfg['tags'].sections:
if re.match('^{}$'.format(sec), tag):
- normal = resolve_att(colourpick(cfg['tags'][sec]['normal']),
- fallback_normal)
- focus = resolve_att(colourpick(cfg['tags'][sec]['focus']),
- fallback_focus)
+ normal = _resolve_att(colourpick(cfg['tags'][sec]['normal']),
+ fallback_normal)
+ focus = _resolve_att(colourpick(cfg['tags'][sec]['focus']),
+ fallback_focus)
translated = cfg['tags'][sec]['translated']
if translated is None: