diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-01-08 17:54:46 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-01-08 17:54:46 +0000 |
commit | e318b74b143985a9b9edf127391af997c9a2c52f (patch) | |
tree | cf425079a275303e7da71bf568f1a8ff762f4bcb /alot | |
parent | 55702c5ed955dc230f310d229fa0c2bcaee4e3ac (diff) |
use callbacks for widget update in TagCommand
this makes thread.TagCommand update the buffers widgets
using the newly introduced callback feature offered by
Message.[add|remove]_tag.
issue #242,#236
Diffstat (limited to 'alot')
-rw-r--r-- | alot/commands/thread.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py index c5d8bd42..078e2cf5 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -654,13 +654,19 @@ class TagCommand(Command): messages = [mw.get_message() for mw in mwidgets] logging.debug('TAG %s' % str(messages)) + + def refresh_widgets(): + for mw in mwidgets: + ui.notify(str(mw.get_message().get_tags())) + mw.rebuild() + tags = filter(lambda x: x, self.tagsstring.split(',')) try: for m in messages: if self.action == 'add': - m.add_tags(tags) + m.add_tags(tags, afterwards=refresh_widgets) elif self.action == 'remove': - m.remove_tags(tags) + m.remove_tags(tags, afterwards=refresh_widgets) elif self.action == 'toggle': to_remove = [] to_add = [] @@ -670,14 +676,10 @@ class TagCommand(Command): else: to_add.append(t) m.remove_tags(to_remove) - m.add_tags(to_add) + m.add_tags(to_add, afterwards=refresh_widgets) except DatabaseROError: ui.notify('index in read-only mode', priority='error') return # flush index ui.apply_command(FlushCommand()) - - # TODO: refresh widgets - for mw in mwidgets: - mw.rebuild() |