summaryrefslogtreecommitdiff
path: root/alot/buffers
diff options
context:
space:
mode:
Diffstat (limited to 'alot/buffers')
-rw-r--r--alot/buffers/thread.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/alot/buffers/thread.py b/alot/buffers/thread.py
index 31dcb89f..1e751f1a 100644
--- a/alot/buffers/thread.py
+++ b/alot/buffers/thread.py
@@ -57,11 +57,8 @@ class ThreadBuffer(Buffer):
attr, attr_focus)
self.body = urwid.Pile([
- # 0 is a dummy value and is overridden later rebuild()
- ('weight', 0, self._msgtree_deco),
- # fixed weight for the message body
- # TODO: should it depend on the message body length (or perhaps something else)?
- ('weight', 50, cur_msg_deco),
+ ('weight', 0.5, self._msgtree_deco),
+ ('weight', 0.5, cur_msg_deco),
])
urwid.connect_signal(self._msgtree_widget.body, "modified", self._update_cur_msg)
@@ -124,15 +121,24 @@ class ThreadBuffer(Buffer):
self._msg_widgets.append(msg_wgt)
list_walker.append(wgt)
- # the weight given to the thread-tree widget is equal to the number of
+ # the weight given to the thread-tree widget is proportional to the number of
# messages in it plus 1 (for surrounding decoration), up to the limit of
- # 50 (when it is equal to the message body widget)
- tree_weight = min(len(self._msg_widgets) + 1, 50)
- self.body.contents[0] = (self._msgtree_deco, ('weight', tree_weight))
+ # 49 messages, when it is equal to the message body widget
+ tree_weight = min(0.01 * (len(self._msg_widgets) + 1), 0.5)
+ self.msgtree_weight = tree_weight
if len(self._msg_widgets) > 0:
self._cur_msg_holder.original_widget = self._msg_widgets[0]
+ @property
+ def msgtree_weight(self):
+ return self.body.contents[0][1][1]
+ @msgtree_weight.setter
+ def msgtree_weight(self, weight):
+ weight = min(1.0, max(weight, 0.0))
+ self.body.contents[0] = (self.body.contents[0][0], ('weight', weight))
+ self.body.contents[1] = (self.body.contents[1][0], ('weight', 1.0 - weight))
+
def get_selected_message_position(self):
"""Return position of focussed message in the thread tree."""
return self._msgtree_widget.focus_position