diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-02-18 10:40:24 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-02-18 10:40:24 +0000 |
commit | 9b2459725153ae1964d5ab9b83f03c5b92c4bae9 (patch) | |
tree | 7b09da83568009d2f680885cb9fc9f7ff3dad499 | |
parent | 5e5fe4553852bd9360fcb98ba80d3103836506c6 (diff) |
theme objects
that read in theme config files and provide urwid.AttrSpec objects
-rw-r--r-- | alot/settings.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/alot/settings.py b/alot/settings.py index 0f1a627b..5e67f5ea 100644 --- a/alot/settings.py +++ b/alot/settings.py @@ -6,6 +6,7 @@ import json import mailcap import codecs import logging +import urwid from configobj import ConfigObj, ConfigObjError, flatten_errors, Section from validate import Validator @@ -40,6 +41,23 @@ def read_config(configpath=None, specpath=None): return config +class Theme(object): + def __init__(self, path): + self._spec = os.path.join(DEFAULTSPATH, 'theme.rc.spec') + self._config = read_config(path, self._spec) + + def get_attribute(self, mode, name, colourmode): + fg = self._config['%dc' % colourmode][mode][name]['fg'] + bg = self._config['%dc' % colourmode][mode][name]['bg'] + if colourmode == 1: + bg = 'default' + elif colourmode == 256: + fg = fg or self._config['16c'][mode][name][fg] + bg = bg or self._config['16c'][mode][name][bg] + return urwid.AttrSpec(fg, bg, colourmode) + + + class FallbackConfigParser(SafeConfigParser): """:class:`~ConfigParser.SafeConfigParser` that allows fallback values""" def __init__(self): |