summaryrefslogtreecommitdiff
path: root/alot/widgets/search.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2018-07-09 14:38:54 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2018-07-24 22:11:38 +0100
commit51f109ad69e8d6df00a789aad14f45c0f14f3012 (patch)
tree6c4d4ddab56bf07e4b304fefc7632dc41605a4d7 /alot/widgets/search.py
parent1fa17e1845c51a4baccf74e273b579de1874b17d (diff)
deal with cases where part widget can be None
this is only possible for "tags" parts, in case the list of tags is empty or all tags are hidden.
Diffstat (limited to 'alot/widgets/search.py')
-rw-r--r--alot/widgets/search.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/alot/widgets/search.py b/alot/widgets/search.py
index 641aa5e8..71469e27 100644
--- a/alot/widgets/search.py
+++ b/alot/widgets/search.py
@@ -31,9 +31,19 @@ class ThreadlineWidget(urwid.AttrMap):
def rebuild(self):
self.thread = self.dbman.get_thread(self.tid)
self.widgets = []
- columns = []
self.structure = settings.get_threadline_theming(self.thread)
+ columns = []
+
+ # combine width info and widget into an urwid.Column entry
+ def add_column(width, part):
+ width_tuple = self.structure[partname]['width']
+ if width_tuple[0] == 'weight':
+ columnentry = width_tuple + (part,)
+ else:
+ columnentry = ('fixed', width, part)
+ columns.append(columnentry)
+
# create a column for every part of the threadline
for partname in self.structure['parts']:
# build widget(s) around this part's content and remember them so
@@ -42,21 +52,16 @@ class ThreadlineWidget(urwid.AttrMap):
width, part = build_tags_part(self.thread.get_tags(),
self.structure['tags']['normal'],
self.structure['tags']['focus'])
- for w in part.widget_list:
- self.widgets.append(w)
+ if part:
+ add_column(width, part)
+ for w in part.widget_list:
+ self.widgets.append(w)
else:
width, part = build_text_part(partname, self.thread,
self.structure[partname])
+ add_column(width, part)
self.widgets.append(part)
- # combine width info and widget into an urwid.Column entry
- width_tuple = self.structure[partname]['width']
- if width_tuple[0] == 'weight':
- columnentry = width_tuple + (part,)
- else:
- columnentry = ('fixed', width, part)
- columns.append(columnentry)
-
self.columns = urwid.Columns(columns, dividechars=1)
self.original_widget = self.columns