summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpazz <patricktotzke@gmail.com>2011-08-06 10:09:56 +0100
committerpazz <patricktotzke@gmail.com>2011-08-06 10:09:56 +0100
commitbb0e91ec4709164c8cf7124cbde060de551790ef (patch)
treea71509be806f0e6ca480c33d41e3c76461ce067c
parent982016b885c53fe5828a7fbff17fbc2c216f4bf2 (diff)
deep focus. needed for select in threadbuffer
-rw-r--r--alot/ui.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/alot/ui.py b/alot/ui.py
index f72779e6..713a621f 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -160,6 +160,18 @@ class UI:
self.current_buffer.rebuild()
self.update()
+ def get_deep_focus(self, startfrom=None):
+ """returns focussed leaf in the widget tree"""
+ if not startfrom:
+ startfrom = self.current_buffer
+ if 'get_focus' in dir(startfrom):
+ focus = startfrom.get_focus()
+ if isinstance(focus, tuple):
+ focus = focus[0]
+ if isinstance(focus, urwid.Widget):
+ return self.get_deep_focus(startfrom=focus)
+ return startfrom
+
def get_buffers_of_type(self, t):
return filter(lambda x: isinstance(x, t), self.buffers)