diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-02-18 17:33:36 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-02-18 17:33:36 +0000 |
commit | d841321bdc4607fcb7e2d73bb3f6ebbbf1eba9cb (patch) | |
tree | 574925684355324a0287668d5e8406ae765f3e68 | |
parent | cf1d24bee09b20a61321aa70b6169a56d2abf8db (diff) |
add SettingsManager.get_tagstring_representation
that will return a doct containing normal and foccussed AttrSpecs
and translated string as given in
config subsections
[tags]
[[footag]]
fg =
bg =
focus_fg =
focus_bg =
translated =
-rw-r--r-- | alot/defaults/alot.rc.spec | 8 | ||||
-rw-r--r-- | alot/settings.py | 21 |
2 files changed, 29 insertions, 0 deletions
diff --git a/alot/defaults/alot.rc.spec b/alot/defaults/alot.rc.spec index 6ce5038e..4b7b93b0 100644 --- a/alot/defaults/alot.rc.spec +++ b/alot/defaults/alot.rc.spec @@ -173,3 +173,11 @@ user_agent = string(default='alot/$VERSION') r = string(default='reply') | = string(default='prompt "pipeto "') __many__ = string(default=None) + +[tags] + [[__many__]] + fg = string(default=None) + bg = string(default=None) + focus_fg = string(default=None) + focus_bg = string(default=None) + translated = string(default=None) diff --git a/alot/settings.py b/alot/settings.py index cd0cd320..ef8b21e2 100644 --- a/alot/settings.py +++ b/alot/settings.py @@ -117,6 +117,27 @@ class SettingsManager(object): colours = int(self._config.get('colourmode')) return self.theme.get_attribute(mode, name, colours) + def get_tagstring_representation(self, tag): + colours = int(self._config.get('colourmode')) + default_att = self.theme.get_attribute('global', 'tag', colours) + default_focus_att = self.theme.get_attribute('global', 'tag_focus', + colours) + if tag in self._config['tags']: + fg = self._config['tags'][tag]['fg'] or default_att.foreground + bg = self._config['tags'][tag]['bg'] or default_att.background + normal = urwid.AttrSpec(fg, bg, colours) + ffg = self._config['tags'][tag]['focus_fg'] or default_focus_att.foreground + fbg = self._config['tags'][tag]['focus_bg'] or default_focus_att.background + focussed = urwid.AttrSpec(ffg, fbg, colours) + translated = self._config['tags'][tag]['translated'] or tag + else: + normal = default_att + focussed = default_focus_att + translated = None + + return {'normal': normal, 'focussed': focussed, 'translated': translated} + + def get_hook(self, key): """return hook (`callable`) identified by `key`""" if self.hooks: |