diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2013-03-02 18:40:22 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2013-03-03 13:49:45 +0000 |
commit | 7224161f40fe918d59ae99fa63bc61cef3815f5a (patch) | |
tree | fed2985c653c5be5f02351225b68229c547d64e7 /alot | |
parent | 299973378e42950d43e67c8cee2a2ebea19cc4de (diff) |
re-implement toggle-all-headers
Diffstat (limited to 'alot')
-rw-r--r-- | alot/commands/thread.py | 45 | ||||
-rw-r--r-- | alot/widgets/thread.py | 22 |
2 files changed, 37 insertions, 30 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py index bde377c6..ce8189c8 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -58,8 +58,8 @@ def determine_sender(mail, action='reply'): # extract list of recipients to check for my address recipients = getaddresses(mail.get_all('To', []) - + mail.get_all('Cc', []) - + mail.get_all('Delivered-To', [])) + + mail.get_all('Cc', []) + + mail.get_all('Delivered-To', [])) logging.debug('recipients: %s' % recipients) # pick the most important account that has an address in recipients @@ -432,34 +432,31 @@ class ChangeDisplaymodeCommand(Command): messagetrees = tbuffer.messagetrees() for mt in messagetrees: - # update collapsed-status + # determine new display values for this message if self.visible == 'toggle': - self.visible = mt.is_collapsed(mt.root) - if self.visible is False: + visible = mt.is_collapsed(mt.root) + else: + visible = self.visible + raw = not mt.display_source if self.raw == 'toggle' else self.raw + all_headers = not mt.display_all_headers if self.all_headers == 'toggle' else self.all_headers + + # collapse/expand depending on new 'visible' value + if visible is False: mt.collapse(mt.root) - elif self.visible is True: + elif visible is True: # could be None mt.expand(mt.root) # in case the thread is yet unread, remove this tag msg = mt._message if 'unread' in msg.get_tags(): msg.remove_tags(['unread']) ui.apply_command(FlushCommand()) - # if visible == None, we don't touch the messagetree - + # set new values in messagetree obj + mt.display_source = raw + mt.display_all_headers = all_headers + # let the messagetree reassemble itself + mt.reassemble() + # refresh the buffer (clears Tree caches etc) tbuffer.refresh() - #if self.raw == 'toggle': - # self.raw = not widget.show_raw - #if self.all_headers == 'toggle': - # self.all_headers = not widget.show_all_headers - - #logging.debug((self.visible, self.raw, self.all_headers)) - #if self.visible is not None: - # widget.folded = not self.visible - #if self.raw is not None: - # widget.show_raw = self.raw - #if self.all_headers is not None: - # widget.show_all_headers = self.all_headers - #widget.rebuild() @registerCommand(MODE, 'pipeto', arguments=[ @@ -831,11 +828,6 @@ class OpenAttachmentCommand(Command): ui.notify('unknown mime type') - - - - - @registerCommand(MODE, 'move', help='move focus in current buffer', arguments=[(['movement'], { 'nargs':argparse.REMAINDER, @@ -864,6 +856,7 @@ class MoveFocusCommand(MoveCommand): # TODO: add next by date.. tbox.refresh() + @registerCommand(MODE, 'select') class ThreadSelectCommand(Command): """select focussed element. The fired action depends on the focus: diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py index 539641c1..27a618d7 100644 --- a/alot/widgets/thread.py +++ b/alot/widgets/thread.py @@ -350,13 +350,26 @@ class MessageTree(CollapsibleTree): self._message = message self._summaryw = MessageSummaryWidget(message, even=(not odd)) - self.display_headers = 'default' + self.display_all_headers = False + self.display_source = False self._all_headers_tree = None self._default_headers_tree = None self.display_attachments = True self._attachments = None + self._maintree = SimpleTree(self._assemble_structure()) + CollapsibleTree.__init__(self, self._maintree) - CollapsibleTree.__init__(self, SimpleTree(self._assemble_structure())) + def reassemble(self): + self._maintree._treelist = self._assemble_structure() + + def debug(self): + logging.debug('collapsed %s' % self.is_collapsed(self.root)) + logging.debug('display_source %s' % self.display_source) + logging.debug('display_all_headers %s' % self.display_all_headers) + logging.debug('display_attachements %s' % self.display_attachments) + logging.debug('AHT %s' % str(self._all_headers_tree)) + logging.debug('DHT %s' % str(self._default_headers_tree)) + logging.debug('MAINTREE %s' % str(self._maintree._treelist)) def _assemble_structure(self): mainstruct = [ @@ -367,6 +380,7 @@ class MessageTree(CollapsibleTree): if attachmenttree is not None: mainstruct.append((attachmenttree, None)) + # use self.display_source mainstruct.append((self._get_body(), None)) structure = [ (self._summaryw, mainstruct) @@ -381,11 +395,11 @@ class MessageTree(CollapsibleTree): return MessageBodyWidget(self._message) def _get_headers(self): - if self.display_headers == 'all': + if self.display_all_headers is True: if self._all_headers_tree is None: self._all_headers_tree = self.construct_header_pile() ret = self._all_headers_tree - elif self.display_headers == 'default': + else: if self._default_headers_tree is None: headers = settings.get('displayed_headers') self._default_headers_tree = self.construct_header_pile( |