summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2013-01-26 16:43:05 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2013-03-03 13:48:20 +0000
commit0ba2b85b816a1ddb1de189c8d87794485f2cad29 (patch)
tree5db20e03fafd674f3521e76b11df943136c924f9 /alot
parent067c23cc17d89bef54a868fdf8d071447ef8f8b1 (diff)
move ThreadTree to widgets.thread
Diffstat (limited to 'alot')
-rw-r--r--alot/buffers.py2
-rw-r--r--alot/walker.py50
-rw-r--r--alot/widgets/thread.py49
3 files changed, 50 insertions, 51 deletions
diff --git a/alot/buffers.py b/alot/buffers.py
index 5e40b4e4..39be38d3 100644
--- a/alot/buffers.py
+++ b/alot/buffers.py
@@ -16,7 +16,7 @@ from alot.widgets.globals import HeadersList
from alot.widgets.globals import AttachmentWidget
from alot.widgets.bufferlist import BufferlineWidget
from alot.widgets.search import ThreadlineWidget
-from alot.walker import ThreadTree
+from alot.widgets.thread import ThreadTree
from alot.foreign.urwidtrees import ArrowTree, TreeBox
diff --git a/alot/walker.py b/alot/walker.py
index 49d01c8f..d1d0a898 100644
--- a/alot/walker.py
+++ b/alot/walker.py
@@ -3,8 +3,6 @@
# For further details see the COPYING file
import urwid
import logging
-from alot.foreign.urwidtrees import Tree
-from alot.widgets.thread import MessageWidget
class PipeWalker(urwid.ListWalker):
@@ -79,51 +77,3 @@ class PipeWalker(urwid.ListWalker):
def get_lines(self):
return self.lines
-
-
-class ThreadTree(Tree):
- def __init__(self, thread):
- self._thread = thread
- self.root = thread.get_toplevel_messages()[0].get_message_id()
- self._parent_of = {}
- self._first_child_of = {}
- self._last_child_of = {}
- self._next_sibling_of = {}
- self._prev_sibling_of = {}
- self._message = {}
-
- for parent, childlist in thread.get_messages().items():
- pid = parent.get_message_id()
- self._message[pid] = MessageWidget(parent)
-
- if childlist:
- cid = childlist[0].get_message_id()
- self._first_child_of[pid] = cid
- self._parent_of[cid] = pid
-
- last_cid = cid
- for child in childlist[1:]:
- cid = child.get_message_id()
- self._parent_of[cid] = pid
- self._prev_sibling_of[cid] = last_cid
- self._next_sibling_of[last_cid] = cid
- last_cid = cid
- self._last_child_of[pid] = last_cid
-
- def __getitem__(self, pos):
- return self._message.get(pos, None)
-
- def parent_position(self, pos):
- return self._parent_of.get(pos, None)
-
- def first_child_position(self, pos):
- return self._first_child_of.get(pos, None)
-
- def last_child_position(self, pos):
- return self._last_child_of.get(pos, None)
-
- def next_sibling_position(self, pos):
- return self._next_sibling_of.get(pos, None)
-
- def prev_sibling_position(self, pos):
- return self._prev_sibling_of.get(pos, None)
diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py
index ba3569bc..9353af19 100644
--- a/alot/widgets/thread.py
+++ b/alot/widgets/thread.py
@@ -14,6 +14,7 @@ from alot.helper import tag_cmp
from alot.widgets.globals import HeadersList
from alot.widgets.globals import TagWidget
from alot.widgets.globals import AttachmentWidget
+from alot.foreign.urwidtrees import Tree
class MessageWidget(urwid.WidgetWrap):
@@ -311,3 +312,51 @@ class MessageBodyWidget(urwid.AttrMap):
bodytxt = message.extract_body(msg)
att = settings.get_theming_attribute('thread', 'body')
urwid.AttrMap.__init__(self, urwid.Text(bodytxt), att)
+
+
+class ThreadTree(Tree):
+ def __init__(self, thread):
+ self._thread = thread
+ self.root = thread.get_toplevel_messages()[0].get_message_id()
+ self._parent_of = {}
+ self._first_child_of = {}
+ self._last_child_of = {}
+ self._next_sibling_of = {}
+ self._prev_sibling_of = {}
+ self._message = {}
+
+ for parent, childlist in thread.get_messages().items():
+ pid = parent.get_message_id()
+ self._message[pid] = MessageWidget(parent)
+
+ if childlist:
+ cid = childlist[0].get_message_id()
+ self._first_child_of[pid] = cid
+ self._parent_of[cid] = pid
+
+ last_cid = cid
+ for child in childlist[1:]:
+ cid = child.get_message_id()
+ self._parent_of[cid] = pid
+ self._prev_sibling_of[cid] = last_cid
+ self._next_sibling_of[last_cid] = cid
+ last_cid = cid
+ self._last_child_of[pid] = last_cid
+
+ def __getitem__(self, pos):
+ return self._message.get(pos, None)
+
+ def parent_position(self, pos):
+ return self._parent_of.get(pos, None)
+
+ def first_child_position(self, pos):
+ return self._first_child_of.get(pos, None)
+
+ def last_child_position(self, pos):
+ return self._last_child_of.get(pos, None)
+
+ def next_sibling_position(self, pos):
+ return self._next_sibling_of.get(pos, None)
+
+ def prev_sibling_position(self, pos):
+ return self._prev_sibling_of.get(pos, None)