diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-07-15 18:29:38 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-07-15 18:29:38 +0100 |
commit | 5415fd0ed790f148fbc507a4d87912f803ea23dc (patch) | |
tree | 88d78df7460a217b8d12a60232c8167b86930f47 | |
parent | fc3318c7167d7369cd7064f35f16a1d7bbbed231 (diff) |
move thread move theming to more durable config syntax
-rw-r--r-- | alot/defaults/default.theme | 9 | ||||
-rw-r--r-- | alot/defaults/theme.spec | 7 | ||||
-rw-r--r-- | alot/settings/__init__.py | 8 | ||||
-rw-r--r-- | alot/settings/theme.py | 9 | ||||
-rw-r--r-- | alot/widgets.py | 8 |
5 files changed, 24 insertions, 17 deletions
diff --git a/alot/defaults/default.theme b/alot/defaults/default.theme index eb058154..402eb3ec 100644 --- a/alot/defaults/default.theme +++ b/alot/defaults/default.theme @@ -25,9 +25,12 @@ header = 'default','','white','dark gray','white','dark gray' header_key = 'default','','white','dark gray','white','dark gray' header_value = 'default','','light gray','dark gray','light gray','dark gray' - summary_even = 'default','','white','light blue','white','#068' - summary_focus = 'standout','','white','dark cyan','#ff8','g58' - summary_odd = 'default','','white','dark blue','white','#006' + + [[summary]] + even = 'default','','white','light blue','white','#068' + odd = 'default','','white','dark blue','white','#006' + focus = 'standout','','white','dark cyan','#ff8','g58' + [envelope] body = 'default','','light gray','default','light gray','default' header = 'default','','white','dark gray','white','dark gray' diff --git a/alot/defaults/theme.spec b/alot/defaults/theme.spec index 3adbed41..27ed7e48 100644 --- a/alot/defaults/theme.spec +++ b/alot/defaults/theme.spec @@ -52,9 +52,10 @@ header = attrtriple header_key = attrtriple header_value = attrtriple - summary_even = attrtriple - summary_focus = attrtriple - summary_odd = attrtriple + [[summary]] + even = attrtriple + odd = attrtriple + focus = attrtriple [envelope] body = attrtriple header = attrtriple diff --git a/alot/settings/__init__.py b/alot/settings/__init__.py index 67dd4094..60cf5c50 100644 --- a/alot/settings/__init__.py +++ b/alot/settings/__init__.py @@ -217,7 +217,7 @@ class SettingsManager(object): value = fallback return value - def get_theming_attribute(self, mode, name): + def get_theming_attribute(self, mode, name, part=None): """ looks up theming attribute @@ -228,7 +228,7 @@ class SettingsManager(object): :rtype: urwid.AttrSpec """ colours = int(self._config.get('colourmode')) - return self._theme.get_attribute(mode, name, colours) + return self._theme.get_attribute(colours, mode, name, part) def get_threadline_theming(self, thread): """ @@ -292,8 +292,8 @@ class SettingsManager(object): # global default attributes for tagstrings. # These could contain values '' and 'default' which we interpret as # "use the values from the widget below" - default_normal = theme.get_attribute('global', 'tag', colourmode) - default_focus = theme.get_attribute('global', 'tag_focus', colourmode) + default_normal = theme.get_attribute(colourmode, 'global', 'tag') + 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) diff --git a/alot/settings/theme.py b/alot/settings/theme.py index 520bb535..ea154504 100644 --- a/alot/settings/theme.py +++ b/alot/settings/theme.py @@ -42,19 +42,22 @@ class Theme(object): msg = 'missing threadline parts: %s' % diff raise ConfigError(msg) - def get_attribute(self, mode, name, colourmode): + def get_attribute(self, colourmode, mode, name, part=None): """ returns requested attribute :param mode: ui-mode (e.g. `search`,`thread`...) :type mode: str - :param name: identifier of the atttribute + :param name: of the atttribute :type name: str :param colourmode: colour mode; in [1, 16, 256] :type colourmode: int :rtype: urwid.AttrSpec """ - return self._config[mode][name][self._colours.index(colourmode)] + thmble = self._config[mode][name] + if part is not None: + thmble = thmble[part] + return thmble[self._colours.index(colourmode)] def get_threadline_theming(self, thread, colourmode): """ diff --git a/alot/widgets.py b/alot/widgets.py index 518911e2..b3223ad8 100644 --- a/alot/widgets.py +++ b/alot/widgets.py @@ -649,9 +649,10 @@ class MessageSummaryWidget(urwid.WidgetWrap): self.message = message self.even = even if even: - attr = settings.get_theming_attribute('thread', 'summary_even') + attr = settings.get_theming_attribute('thread', 'summary', 'even') else: - attr = settings.get_theming_attribute('thread', 'summary_odd') + attr = settings.get_theming_attribute('thread', 'summary', 'odd') + focus_att = settings.get_theming_attribute('thread', 'summary', 'focus') cols = [] sumstr = self.__str__() @@ -660,12 +661,11 @@ class MessageSummaryWidget(urwid.WidgetWrap): thread_tags = message.get_thread().get_tags(intersection=True) outstanding_tags = set(message.get_tags()).difference(thread_tags) - tag_widgets = [TagWidget(t) for t in outstanding_tags] + tag_widgets = [TagWidget(t, attr, focus_att) for t in outstanding_tags] tag_widgets.sort(tag_cmp, lambda tag_widget: tag_widget.translated) for tag_widget in tag_widgets: if not tag_widget.hidden: cols.append(('fixed', tag_widget.width(), tag_widget)) - focus_att = settings.get_theming_attribute('thread', 'summary_focus') line = urwid.AttrMap(urwid.Columns(cols, dividechars=1), attr, focus_att) urwid.WidgetWrap.__init__(self, line) |