84833dc7db
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)
27 lines
723 B
Python
27 lines
723 B
Python
import core.input
|
|
import util.store
|
|
|
|
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:
|
|
self._full_text = value
|
|
else:
|
|
if callable(self._full_text):
|
|
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
|