summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-01-07 17:21:32 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2012-01-07 17:21:32 +0000
commitfe881c7ad53bbcd159fe53e325f06c30aca333a9 (patch)
treeb3d0ea9959bd5f766bfc0471b23cfcfd5489ee0e
parentad6bdafb1301aa062013ec9625053d1c0923f76c (diff)
parent23e32ea957e2d17deed1e75723b349a370fc195d (diff)
Merge branch 'message-sumary-212' into testing
-rw-r--r--alot/db.py15
-rw-r--r--alot/widgets.py15
2 files changed, 23 insertions, 7 deletions
diff --git a/alot/db.py b/alot/db.py
index 4a663ee3..06c8c1e5 100644
--- a/alot/db.py
+++ b/alot/db.py
@@ -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()