summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-06-19 22:35:13 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2012-06-19 22:35:13 +0100
commit0f3e9b0e2d6f872de97532689bc8c7bc27221d60 (patch)
tree2af11d006a4e3056cf4b9a72290e6ebd6c44b3a5 /alot
parent66894a89719f60fb5d87a918439416ebabe2a8c6 (diff)
add `get_info` method to buffers
.. to gather some meta info on the current buffer
Diffstat (limited to 'alot')
-rw-r--r--alot/buffers.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/alot/buffers.py b/alot/buffers.py
index 47a745c1..07a7589d 100644
--- a/alot/buffers.py
+++ b/alot/buffers.py
@@ -41,6 +41,10 @@ class Buffer(object):
"""called before buffer is dismissed"""
pass
+ def get_info(self):
+ """return dict of meta infos about this buffer"""
+ return {}
+
class BufferlistBuffer(Buffer):
"""lists all active buffers"""
@@ -111,6 +115,11 @@ class EnvelopeBuffer(Buffer):
to = self.envelope.get('To', fallback='unset')
return '[envelope] to: %s' % (shorten_author_string(to, 400))
+ def get_info(self):
+ info = {}
+ info['to'] = self.envelope.get('To', fallback='unset')
+ return info
+
def rebuild(self):
displayed_widgets = []
hidden = settings.get('envelope_headers_blacklist')
@@ -132,7 +141,8 @@ class EnvelopeBuffer(Buffer):
# add header list widget iff header values exists
if lines:
key_att = settings.get_theming_attribute('envelope', 'header_key')
- value_att = settings.get_theming_attribute('envelope', 'header_value')
+ value_att = settings.get_theming_attribute('envelope',
+ 'header_value')
self.header_wgt = widgets.HeadersList(lines, key_att, value_att)
displayed_widgets.append(self.header_wgt)
@@ -177,6 +187,13 @@ class SearchBuffer(Buffer):
return formatstring % (self.querystring, self.result_count,
's' * (not (self.result_count == 1)))
+ def get_info(self):
+ info = {}
+ info['querystring'] = self.querystring
+ info['result_count'] = self.result_count
+ info['result_count_positive'] = 's' * (not (self.result_count == 1))
+ return info
+
def cleanup(self):
self.kill_filler_process()
@@ -250,6 +267,14 @@ class ThreadBuffer(Buffer):
self.message_count,
's' * (self.message_count > 1))
+ def get_info(self):
+ info = {}
+ info['subject'] = self.thread.get_subject()
+ info['authors'] = self.thread.get_authors_string()
+ info['tid'] = self.thread.get_thread_id()
+ info['message_count'] = self.message_count
+ return info
+
def get_selected_thread(self):
"""returns the displayed :class:`~alot.db.Thread`"""
return self.thread