diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-01-07 17:21:32 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-01-07 17:21:32 +0000 |
commit | fe881c7ad53bbcd159fe53e325f06c30aca333a9 (patch) | |
tree | b3d0ea9959bd5f766bfc0471b23cfcfd5489ee0e | |
parent | ad6bdafb1301aa062013ec9625053d1c0923f76c (diff) | |
parent | 23e32ea957e2d17deed1e75723b349a370fc195d (diff) |
Merge branch 'message-sumary-212' into testing
-rw-r--r-- | alot/db.py | 15 | ||||
-rw-r--r-- | alot/widgets.py | 15 |
2 files changed, 23 insertions, 7 deletions
@@ -362,15 +362,20 @@ class Thread(object): """returns id of this thread""" return self._id - def get_tags(self): + def get_tags(self, intersection=False): """ returns tagsstrings attached to this thread - :rtype: list of str + :param intersection: return tags present in all contained messages + instead of in at least one (union) + :type intersection: bool + :rtype: set of str """ - l = list(self._tags) - l.sort() - return l + tags = set(list(self._tags)) + if intersection: + for m in self.get_messages().keys(): + tags = tags.intersection(set(m.get_tags())) + return tags def add_tags(self, tags): """ diff --git a/alot/widgets.py b/alot/widgets.py index 17141917..79bab28b 100644 --- a/alot/widgets.py +++ b/alot/widgets.py @@ -580,9 +580,20 @@ class MessageSummaryWidget(urwid.WidgetWrap): attr = 'thread_summary_even' else: attr = 'thread_summary_odd' + cols = [] + sumstr = self.__str__() - txt = urwid.AttrMap(urwid.Text(sumstr), attr, 'thread_summary_focus') - urwid.WidgetWrap.__init__(self, txt) + txt = urwid.Text(sumstr) + cols.append(txt) + + 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.sort(tag_cmp, lambda tag_widget: tag_widget.translated) + for tag_widget in tag_widgets: + cols.append(('fixed', tag_widget.width(), tag_widget)) + line = urwid.AttrMap(urwid.Columns(cols, dividechars=1), attr, 'thread_summary_focus') + urwid.WidgetWrap.__init__(self, line) def __str__(self): author, address = self.message.get_author() |