From 2507677179b8d4afef563422e5d7e05ffb86859b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 21 Oct 2020 15:03:57 +0200 Subject: buffers/thread: use LineBox frames to wrap the two main parts Drop the ugly divider that used to indicate which part is focused. --- alot/buffers/thread.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'alot/buffers') diff --git a/alot/buffers/thread.py b/alot/buffers/thread.py index b2d5f711..31dcb89f 100644 --- a/alot/buffers/thread.py +++ b/alot/buffers/thread.py @@ -28,15 +28,11 @@ class ThreadBuffer(Buffer): _msg_widgets = None # widget showing the thread tree _msgtree_widget = None + # decorations around the msgtree widget + _msgtree_deco = None # WidgetPlaceholder that wraps currently displayed message _cur_msg_holder = None - # WidgetPlaceholder that wraps current divider - _divider_holder = None - - # divider widgets placed between the thread tree and the message - _divider_up = None - _divider_down = None def __init__(self, thread): """ @@ -46,20 +42,26 @@ class ThreadBuffer(Buffer): self.thread = thread self._indent_width = settings.get('thread_indent_replies') + attr = settings.get_theming_attribute('thread', 'frame') + attr_focus = settings.get_theming_attribute('thread', 'frame_focus') + # create the widgets composing the buffer self._msgtree_widget = urwid.ListBox(urwid.SimpleFocusListWalker([])) - self._divider_up = urwid.Divider('↑') - self._divider_down = urwid.Divider('↓') - self._divider_holder = urwid.WidgetPlaceholder(self._divider_up) - self._cur_msg_holder = urwid.WidgetPlaceholder(urwid.SolidFill()) + self._msgtree_deco = urwid.AttrMap(urwid.LineBox(self._msgtree_widget), + attr, attr_focus) + + # initial placeholder has to be selectable + self._cur_msg_holder = urwid.WidgetPlaceholder(urwid.SelectableIcon('')) + + cur_msg_deco = urwid.AttrMap(urwid.LineBox(self._cur_msg_holder), + attr, attr_focus) self.body = urwid.Pile([ # 0 is a dummy value and is overridden later rebuild() - ('weight', 0, self._msgtree_widget), - ('pack', self._divider_holder), + ('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, self._cur_msg_holder), + ('weight', 50, cur_msg_deco), ]) urwid.connect_signal(self._msgtree_widget.body, "modified", self._update_cur_msg) @@ -77,7 +79,7 @@ class ThreadBuffer(Buffer): def _focus(self): if self.body.focus_position == 0: return _ThreadBufFocus.TREE - elif self.body.focus_position == 2: + elif self.body.focus_position == 1: return _ThreadBufFocus.MESSAGE else: raise ValueError('Invalid focus position: %s' % str(self.body.focus_position)) @@ -123,10 +125,10 @@ class ThreadBuffer(Buffer): list_walker.append(wgt) # the weight given to the thread-tree widget is equal to the number of - # messages in it, up to the limit of 50 (when it is equal to the message - # body widget) - tree_weight = min(len(self._msg_widgets), 50) - self.body.contents[0] = (self._msgtree_widget, ('weight', tree_weight)) + # 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)) if len(self._msg_widgets) > 0: self._cur_msg_holder.original_widget = self._msg_widgets[0] @@ -271,12 +273,10 @@ class ThreadBuffer(Buffer): """set focus on the thread widget""" logging.debug('setting focus to thread widget') self.body.focus_position = 0 - self._divider_holder.original_widget = self._divider_up def focus_msg_widget(self): """set focus on the message widget""" logging.debug('setting focus to message widget') - self.body.focus_position = 2 - self._divider_holder.original_widget = self._divider_down + self.body.focus_position = 1 def focus_toggle(self): if self._focus == _ThreadBufFocus.TREE: self.focus_msg_widget() -- cgit v1.2.3