[core] Add (partial) support for states

Add states to the modules and widgets. Widgets are mostly just a
pass-through (backwards compatibility, and ease of use - making states
directly inside the widgets would require more code inside the modules
to ensure that each widget is correctly updated).

Still missing:
- Separators during partial update (right now, it takes one interval
until separators are drawn correctly)
This commit is contained in:
Tobias Witek 2020-02-23 21:13:49 +01:00
parent fd57af9325
commit 84833dc7db
5 changed files with 27 additions and 3 deletions

View file

@ -5,6 +5,7 @@ class Widget(util.store.Store, core.input.Object):
def __init__(self, full_text):
super(Widget, self).__init__()
self._full_text = full_text
self._module = None
def full_text(self, value=None):
if value:
@ -14,4 +15,13 @@ class Widget(util.store.Store, core.input.Object):
return self._full_text(self)
return self._full_text
def module(self, module):
self._module = module
def state(self):
rv = []
if self._module:
rv = self._module.state(self)
return rv if isinstance(rv, list) else [rv]
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4